Skip to content

Commit

Permalink
hotfix(id_generation): ignore attributes that fail hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
nkemnitz committed Dec 28, 2023
1 parent 7fb1390 commit 63bd41f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/unit/mazepa/test_id_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def __init__(self, a):
def method(self, b):
return self.a * b

@property
def prop(self):
return self.a


@taskable_operation_cls()
@attrs.mutable
Expand Down
7 changes: 7 additions & 0 deletions zetta_utils/mazepa/id_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ def _get_code_hash(
_visited.add(id(fn))

for attribute_name in {x for x in dir(fn) if not x.startswith("__")}:
attrib = getattr(fn.__class__, attribute_name, None)

if attrib is not None and isinstance(attrib, property):
_get_code_hash(attrib, _hash, _visited) # type: ignore
continue

attrib = getattr(fn, attribute_name)

if callable(attrib):
_get_code_hash(attrib, _hash, _visited)
else:
Expand Down

0 comments on commit 63bd41f

Please sign in to comment.