Skip to content

Commit 41bc8e2

Browse files
tcloseeffigies
andauthored
Update pydra/utils/hash.py
Co-authored-by: Chris Markiewicz <[email protected]>
1 parent 2abf6fe commit 41bc8e2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pydra/utils/hash.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,14 @@ def __bytes_repr__(self, cache: Cache) -> Iterator[bytes]:
106106
def bytes_repr(obj: object, cache: Cache) -> Iterator[bytes]:
107107
cls = obj.__class__
108108
yield f"{cls.__module__}.{cls.__name__}:{{".encode()
109+
dct: Dict[str, ty.Any]
109110
if attrs.has(type(obj)):
110111
# Drop any attributes that aren't used in comparisons by default
111-
dct = attrs.asdict(obj, recurse=False, filter=lambda a, _: bool(a.eq)) # type: ignore
112+
dct = attrs.asdict(obj, recurse=False, filter=lambda a, _: bool(a.eq))
113+
elif hasattr(obj, "__slots__"):
114+
dct = {attr: getattr(obj, attr) for attr in obj.__slots__}
112115
else:
113-
try:
116+
dct = obj.__dict__
114117
dct = obj.__dict__
115118
except AttributeError as e:
116119
try:

0 commit comments

Comments
 (0)