Loading src/mvvm_lib/bindings_map.py +2 −1 Original line number Diff line number Diff line Loading @@ -10,7 +10,8 @@ bindings_map: Dict[str, Any] = {} def update_bindings_map(source: Any, value: Any) -> None: if isinstance(source, BaseModel): # if isinstance(source, BaseModel): if issubclass(type(source), BaseModel): fields = rget_list_of_fields(source) for field in fields: bindings_map[field] = value src/mvvm_lib/interface.py +2 −2 Original line number Diff line number Diff line """Abstract interfaces and type definitions.""" from abc import ABC, abstractmethod from typing import Any, Callable, Dict, Optional, Union from typing import Any, Callable, Optional, Union LinkedObjectType = Optional[Union[object, Dict[str, Any], Callable]] LinkedObjectType = Optional[Any] LinkedObjectAttributesType = Optional[list[str]] CallbackAfterUpdateType = Optional[Callable[[Optional[str]], None]] ConnectCallbackType = Union[None, Callable[[Any, Optional[str]], None]] Loading src/mvvm_lib/pyqt6_binding/binding.py +1 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ class Communicator(QObject): self.callback_after_update = callback_after_update def _update_viewmodel_callback(self, key: Optional[str] = None, value: Any = None) -> None: if isinstance(self.viewmodel_linked_object, BaseModel): if issubclass(type(value), BaseModel): model = self.viewmodel_linked_object.copy(deep=True) rsetattr(model, key or "", value) try: Loading src/mvvm_lib/trame_binding/binding.py +4 −4 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ class TrameCommunicator(Communicator): if ( viewmodel_linked_object and not isinstance(viewmodel_linked_object, dict) and not isinstance(viewmodel_linked_object, BaseModel) and not issubclass(type(viewmodel_linked_object), BaseModel) and not is_callable(viewmodel_linked_object) ): if not linked_object_attributes: Loading Loading @@ -90,7 +90,7 @@ class CallBackConnection: self.linked_object_attributes = communicator.linked_object_attributes def _update_viewmodel_callback(self, value: Any, key: Optional[str] = None) -> None: if isinstance(self.viewmodel_linked_object, BaseModel): if self.viewmodel_linked_object and issubclass(type(self.viewmodel_linked_object), BaseModel): model = self.viewmodel_linked_object.copy(deep=True) rsetattr(model, key or "", value) try: Loading Loading @@ -179,7 +179,7 @@ class StateConnection: @self.state.change(state_variable_name) def update_viewmodel_callback(**kwargs: dict) -> None: success = True if isinstance(self.viewmodel_linked_object, BaseModel): if self.viewmodel_linked_object and issubclass(type(self.viewmodel_linked_object), BaseModel): json_str = json.dumps(kwargs[state_variable_name]) try: model = self.viewmodel_linked_object.model_validate_json(json_str) Loading @@ -197,7 +197,7 @@ class StateConnection: self.viewmodel_callback_after_update(state_variable_name) def update_in_view(self, value: Any) -> None: if hasattr(value, "model_dump"): if issubclass(type(value), BaseModel): value = value.model_dump() if self.linked_object_attributes: for attribute_name in self.linked_object_attributes: Loading Loading
src/mvvm_lib/bindings_map.py +2 −1 Original line number Diff line number Diff line Loading @@ -10,7 +10,8 @@ bindings_map: Dict[str, Any] = {} def update_bindings_map(source: Any, value: Any) -> None: if isinstance(source, BaseModel): # if isinstance(source, BaseModel): if issubclass(type(source), BaseModel): fields = rget_list_of_fields(source) for field in fields: bindings_map[field] = value
src/mvvm_lib/interface.py +2 −2 Original line number Diff line number Diff line """Abstract interfaces and type definitions.""" from abc import ABC, abstractmethod from typing import Any, Callable, Dict, Optional, Union from typing import Any, Callable, Optional, Union LinkedObjectType = Optional[Union[object, Dict[str, Any], Callable]] LinkedObjectType = Optional[Any] LinkedObjectAttributesType = Optional[list[str]] CallbackAfterUpdateType = Optional[Callable[[Optional[str]], None]] ConnectCallbackType = Union[None, Callable[[Any, Optional[str]], None]] Loading
src/mvvm_lib/pyqt6_binding/binding.py +1 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ class Communicator(QObject): self.callback_after_update = callback_after_update def _update_viewmodel_callback(self, key: Optional[str] = None, value: Any = None) -> None: if isinstance(self.viewmodel_linked_object, BaseModel): if issubclass(type(value), BaseModel): model = self.viewmodel_linked_object.copy(deep=True) rsetattr(model, key or "", value) try: Loading
src/mvvm_lib/trame_binding/binding.py +4 −4 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ class TrameCommunicator(Communicator): if ( viewmodel_linked_object and not isinstance(viewmodel_linked_object, dict) and not isinstance(viewmodel_linked_object, BaseModel) and not issubclass(type(viewmodel_linked_object), BaseModel) and not is_callable(viewmodel_linked_object) ): if not linked_object_attributes: Loading Loading @@ -90,7 +90,7 @@ class CallBackConnection: self.linked_object_attributes = communicator.linked_object_attributes def _update_viewmodel_callback(self, value: Any, key: Optional[str] = None) -> None: if isinstance(self.viewmodel_linked_object, BaseModel): if self.viewmodel_linked_object and issubclass(type(self.viewmodel_linked_object), BaseModel): model = self.viewmodel_linked_object.copy(deep=True) rsetattr(model, key or "", value) try: Loading Loading @@ -179,7 +179,7 @@ class StateConnection: @self.state.change(state_variable_name) def update_viewmodel_callback(**kwargs: dict) -> None: success = True if isinstance(self.viewmodel_linked_object, BaseModel): if self.viewmodel_linked_object and issubclass(type(self.viewmodel_linked_object), BaseModel): json_str = json.dumps(kwargs[state_variable_name]) try: model = self.viewmodel_linked_object.model_validate_json(json_str) Loading @@ -197,7 +197,7 @@ class StateConnection: self.viewmodel_callback_after_update(state_variable_name) def update_in_view(self, value: Any) -> None: if hasattr(value, "model_dump"): if issubclass(type(value), BaseModel): value = value.model_dump() if self.linked_object_attributes: for attribute_name in self.linked_object_attributes: Loading