Skip to content

Commit 182e428

Browse files
committed
Fixed #4259
Result of DeepDiff contain ordered sets. Also added fallback for usual sets to lists just in case, should be safe.
1 parent 7d31791 commit 182e428

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/ifcdiff/ifcdiff.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import ifcopenshell.util.classification
3535
import ifcopenshell.util.representation
3636
from deepdiff import DeepDiff
37+
from ordered_set import OrderedSet
3738

3839

3940
class IfcDiff:
@@ -234,6 +235,12 @@ def get_settings(self, ifc):
234235
settings.set_context_ids(body_contexts)
235236
return settings
236237

238+
def json_dump_default(self, obj):
239+
# result of DeepDiff may contain ordered sets
240+
if isinstance(obj, (OrderedSet, set)):
241+
return list(obj)
242+
return json.JSONEncoder.default(None, obj)
243+
237244
def export(self, path):
238245
with open(path, "w", encoding="utf-8") as diff_file:
239246
json.dump(
@@ -244,6 +251,7 @@ def export(self, path):
244251
},
245252
diff_file,
246253
indent=4,
254+
default=self.json_dump_default,
247255
)
248256

249257
def get_precision(self):

0 commit comments

Comments
 (0)