diff --git a/src/pydase/data_service/data_service_observer.py b/src/pydase/data_service/data_service_observer.py index 28569bc..75a78b5 100644 --- a/src/pydase/data_service/data_service_observer.py +++ b/src/pydase/data_service/data_service_observer.py @@ -8,7 +8,10 @@ from pydase.observer_pattern.observable.observable_object import ObservableObjec from pydase.observer_pattern.observer.property_observer import ( PropertyObserver, ) -from pydase.utils.helpers import get_object_attr_from_path +from pydase.utils.helpers import ( + get_object_attr_from_path, + normalize_full_access_path_string, +) from pydase.utils.serialization.serializer import ( SerializationPathError, SerializedObject, @@ -99,7 +102,8 @@ class DataServiceObserver(PropertyObserver): ) def _notify_dependent_property_changes(self, changed_attr_path: str) -> None: - changed_props = self.property_deps_dict.get(changed_attr_path, []) + normalized_attr_path = normalize_full_access_path_string(changed_attr_path) + changed_props = self.property_deps_dict.get(normalized_attr_path, []) for prop in changed_props: # only notify about changing attribute if it is not currently being # "changed" e.g. when calling the getter of a property within another diff --git a/src/pydase/utils/helpers.py b/src/pydase/utils/helpers.py index f47af3e..748213d 100644 --- a/src/pydase/utils/helpers.py +++ b/src/pydase/utils/helpers.py @@ -223,3 +223,25 @@ def current_event_loop_exists() -> bool: import asyncio return asyncio.get_event_loop_policy()._local._loop is not None # type: ignore + + +def normalize_full_access_path_string(s: str) -> str: + """Normalizes a string representing a full access path by converting double quotes + to single quotes. + + This function is useful for ensuring consistency in strings that represent access + paths containing dictionary keys, by replacing all double quotes (`"`) with single + quotes (`'`). + + Args: + s (str): The input string to be normalized. + + Returns: + A new string with all double quotes replaced by single quotes. + + Example: + >>> normalize_full_access_path_string('dictionary["first"].my_task') + "dictionary['first'].my_task" + """ + + return s.replace('"', "'")