16
16
"""
17
17
18
18
from functools import total_ordering
19
- from typing import Any , Iterator , Iterable , Mapping , Optional , Text
19
+ from typing import Any , Iterator , Iterable , Mapping , Optional , Text , Type
20
20
21
21
from .exceptions import ObjectAlreadyExists
22
22
from .utils import intersection , OrderedDefaultDict
@@ -126,7 +126,13 @@ class DiffElement: # pylint: disable=too-many-instance-attributes
126
126
"""DiffElement object, designed to represent a single item/object that may or may not have any diffs."""
127
127
128
128
def __init__ (
129
- self , obj_type : Text , name : Text , keys : Mapping , source_name : Text = "source" , dest_name : Text = "dest"
129
+ self ,
130
+ obj_type : Text ,
131
+ name : Text ,
132
+ keys : Mapping ,
133
+ source_name : Text = "source" ,
134
+ dest_name : Text = "dest" ,
135
+ diff_class : Type [Diff ] = Diff ,
130
136
): # pylint: disable=too-many-arguments
131
137
"""Instantiate a DiffElement.
132
138
@@ -137,6 +143,7 @@ def __init__(
137
143
keys: Primary keys and values uniquely describing this object, as in DSyncModel.get_identifiers().
138
144
source_name: Name of the source DSync object
139
145
dest_name: Name of the destination DSync object
146
+ diff_class: Diff or subclass thereof to use to calculate the diffs to use for synchronization
140
147
"""
141
148
if not isinstance (obj_type , str ):
142
149
raise ValueError (f"obj_type must be a string (not { type (obj_type )} )" )
@@ -152,7 +159,7 @@ def __init__(
152
159
# Note: *_attrs == None if no target object exists; it'll be an empty dict if it exists but has no _attributes
153
160
self .source_attrs : Optional [Mapping ] = None
154
161
self .dest_attrs : Optional [Mapping ] = None
155
- self .child_diff = Diff ()
162
+ self .child_diff = diff_class ()
156
163
157
164
def __lt__ (self , other ):
158
165
"""Logical ordering of DiffElements.
0 commit comments