From 2c7d924aa1707e5b138820a94b8e8e6ffa6b79c9 Mon Sep 17 00:00:00 2001 From: James Harr Date: Mon, 20 Nov 2023 16:00:34 +0000 Subject: [PATCH] refactor: Remove unnecessary DiffSyncModel.diffsync field handling from storage engines --- diffsync/store/__init__.py | 3 --- diffsync/store/local.py | 3 --- diffsync/store/redis.py | 3 --- 3 files changed, 9 deletions(-) diff --git a/diffsync/store/__init__.py b/diffsync/store/__init__.py index 3dacf330..2ed91238 100644 --- a/diffsync/store/__init__.py +++ b/diffsync/store/__init__.py @@ -95,9 +95,6 @@ def remove(self, *, obj: "DiffSyncModel", remove_children: bool = False) -> None self.remove_item(modelname, uid) - if obj.diffsync: - obj.diffsync = None - if remove_children: for child_type, child_fieldname in obj.get_children_mapping().items(): for child_id in getattr(obj, child_fieldname): diff --git a/diffsync/store/local.py b/diffsync/store/local.py index 82bb69ba..3ca8e972 100644 --- a/diffsync/store/local.py +++ b/diffsync/store/local.py @@ -108,9 +108,6 @@ def add(self, *, obj: "DiffSyncModel") -> None: # Return so we don't have to change anything on the existing object and underlying data return - if not obj.diffsync: - obj.diffsync = self.diffsync - self._data[modelname][uid] = obj def update(self, *, obj: "DiffSyncModel") -> None: diff --git a/diffsync/store/redis.py b/diffsync/store/redis.py index 927dbf5e..a867c004 100644 --- a/diffsync/store/redis.py +++ b/diffsync/store/redis.py @@ -65,7 +65,6 @@ def _get_object_from_redis_key(self, key: str) -> "DiffSyncModel": pickled_object = self._store.get(key) if pickled_object: obj_result = loads(pickled_object) # nosec - obj_result.diffsync = self.diffsync return obj_result raise ObjectNotFound(f"{key} not present in Cache") @@ -178,7 +177,6 @@ def add(self, *, obj: "DiffSyncModel") -> None: # Remove the diffsync object before sending to Redis obj_copy = copy.copy(obj) - obj_copy.diffsync = None self._store.set(object_key, dumps(obj_copy)) @@ -193,7 +191,6 @@ def update(self, *, obj: "DiffSyncModel") -> None: object_key = self._get_key_for_object(modelname, uid) obj_copy = copy.copy(obj) - obj_copy.diffsync = None self._store.set(object_key, dumps(obj_copy))