Skip to content

Commit

Permalink
feat: _is_method_like with include argument defaulted to __post_init__
Browse files Browse the repository at this point in the history
  • Loading branch information
thorwhalen committed Apr 8, 2024
1 parent 5219dd2 commit a90514a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions i2/footprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,16 @@ def accessed_attributes(func, object_name=None):
return visitor.attributes


def _is_method_like(name, obj, *, no_dunders=True):
if no_dunders and name.startswith('__') and name.endswith('__'):
def _is_method_like(
name,
obj,
*,
no_dunders=True,
include=('__post_init__',),
):
if name in include:
return True
elif no_dunders and name.startswith('__') and name.endswith('__'):
return False
return isinstance(obj, (Callable, property, cached_property))

Expand Down

0 comments on commit a90514a

Please sign in to comment.