Skip to content

Commit

Permalink
Fix immutability check: sets are not immutable. (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamHillier authored Mar 23, 2020
1 parent 899d23b commit 85686f8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions zookeeper/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,16 @@ def wrapper():
def is_immutable(value: Any) -> bool:
"""
Decide the immutability of `value`. Recurses a single level if `value` is a
set or a tuple, but does not recurse infinitely.
tuple, but does not recurse infinitely.
"""
return (
value is None
or isinstance(value, (int, float, bool, str, frozenset))
or (
isinstance(value, (set, tuple))
isinstance(value, tuple)
and all(
isinstance(inner_value, (int, float, bool, str, frozenset))
inner_value is None
or isinstance(inner_value, (int, float, bool, str, frozenset))
for inner_value in value
)
)
Expand Down

0 comments on commit 85686f8

Please sign in to comment.