Skip to content

Commit 2b1a039

Browse files
committed
gh-535: UUID set comparison failure
1 parent ecc823a commit 2b1a039

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

deepdiff/deephash.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22
import logging
33
import datetime
4+
import uuid
45
from typing import Union, Optional, Any, List, TYPE_CHECKING
56
from collections.abc import Iterable, MutableMapping
67
from collections import defaultdict
@@ -566,6 +567,17 @@ def _hash(self, obj, parent, parents_ids=EMPTY_FROZENSET):
566567
elif isinstance(obj, ipranges):
567568
result = self._prep_ipranges(obj)
568569

570+
elif isinstance(obj, uuid.UUID):
571+
# Handle UUID objects (including uuid6.UUID) by using their integer value
572+
result = f"uuid:{obj.int}"
573+
if self.apply_hash:
574+
result = self.hasher(result)
575+
try:
576+
self.hashes[obj] = (result, counts)
577+
except TypeError:
578+
self.hashes[get_id(obj)] = (result, counts)
579+
return result, counts
580+
569581
elif isinstance(obj, MutableMapping):
570582
result, counts = self._prep_dict(obj=obj, parent=parent, parents_ids=parents_ids)
571583

0 commit comments

Comments
 (0)