Falko Schindler 2 лет назад
Родитель
Сommit
4a889ed7ff
1 измененных файлов с 6 добавлено и 5 удалено
  1. 6 5
      nicegui/binding.py

+ 6 - 5
nicegui/binding.py

@@ -2,6 +2,7 @@ import asyncio
 import logging
 import logging
 import time
 import time
 from collections import defaultdict
 from collections import defaultdict
+from collections.abc import Mapping
 from typing import Any, Callable, DefaultDict, Dict, List, Optional, Set, Tuple, Type, Union
 from typing import Any, Callable, DefaultDict, Dict, List, Optional, Set, Tuple, Type, Union
 
 
 from . import globals
 from . import globals
@@ -11,21 +12,21 @@ bindable_properties: Dict[Tuple[int, str], Any] = {}
 active_links: List[Tuple[Any, str, Any, str, Callable[[Any], Any]]] = []
 active_links: List[Tuple[Any, str, Any, str, Callable[[Any], Any]]] = []
 
 
 
 
-def has_attribute(obj: Union[object, Dict], name: str) -> Any:
-    if isinstance(obj, dict):
+def has_attribute(obj: Union[object, Mapping], name: str) -> Any:
+    if isinstance(obj, Mapping):
         return name in obj
         return name in obj
     else:
     else:
         return hasattr(obj, name)
         return hasattr(obj, name)
 
 
 
 
-def get_attribute(obj: Union[object, Dict], name: str) -> Any:
-    if isinstance(obj, dict):
+def get_attribute(obj: Union[object, Mapping], name: str) -> Any:
+    if isinstance(obj, Mapping):
         return obj[name]
         return obj[name]
     else:
     else:
         return getattr(obj, name)
         return getattr(obj, name)
 
 
 
 
-def set_attribute(obj: Union[object, Dict], name: str, value: Any) -> None:
+def set_attribute(obj: Union[object, Mapping], name: str, value: Any) -> None:
     if isinstance(obj, dict):
     if isinstance(obj, dict):
         obj[name] = value
         obj[name] = value
     else:
     else: