feat(persist/util): init parent_is_dict

Check if a parent value is of type dict
This utility is helpfull for cross checking of flattened dicts
This commit is contained in:
Johannes Kirschbauer
2025-05-23 21:41:34 +02:00
parent 634b4f8e46
commit 60bd7bc3ce

View File

@@ -134,6 +134,16 @@ def find_deleted_paths(
return deleted_paths return deleted_paths
def parent_is_dict(key: str, data: dict[str, Any]) -> bool:
parts = key.split(".")
while len(parts) > 1:
parts.pop()
parent_key = ".".join(parts)
if parent_key in data:
return isinstance(data[parent_key], dict)
return False
def calc_patches( def calc_patches(
persisted: dict[str, Any], persisted: dict[str, Any],
update: dict[str, Any], update: dict[str, Any],