From 24a01c09826df1f3a4355be548d266051c43d3e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mose=20M=C3=BCller?= Date: Tue, 5 Mar 2024 14:17:05 +0100 Subject: [PATCH] removes keys from cache entry if they are not part of the new value serialization --- src/pydase/utils/serializer.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pydase/utils/serializer.py b/src/pydase/utils/serializer.py index 4f136f8..e91ea77 100644 --- a/src/pydase/utils/serializer.py +++ b/src/pydase/utils/serializer.py @@ -273,10 +273,16 @@ def set_nested_value_by_path( value_type = serialized_value.pop("type") if "readonly" in current_dict and current_dict["type"] != "method": current_dict["type"] = value_type - # TODO: this does not yet remove keys that are not present in the serialized new - # value + current_dict.update(serialized_value) + # removes keys that are not present in the serialized new value + keys_to_keep = set(serialized_value.keys()) | {"type", "readonly"} + + for key in list(current_dict.keys()): + if key not in keys_to_keep: + current_dict.pop(key, None) + def get_nested_dict_by_path( serialization_dict: dict[str, Any],