Skip to content

Commit e056768

Browse files
committed
fix non-duplicate member func for mify in python 3.11
1 parent 6b86010 commit e056768

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

mellea/stdlib/mify.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ def _get_all_fields(self) -> dict[str, Any]:
132132
if self._fields_exclude:
133133
fields_exclude = self._fields_exclude
134134

135-
# This includes fields defined by any superclasses, as long as it's not object.
136-
all_fields = _get_non_duplicate_fields(self, object)
135+
# This includes fields defined by any superclasses, as long as it's not Protocol.
136+
all_fields = _get_non_duplicate_fields(self, Protocol)
137137

138138
# It does matter if include is an empty set. Handle it's cases here.
139139
if self._fields_include is not None:
@@ -366,18 +366,15 @@ def mification(obj: T) -> T:
366366

367367

368368
def _get_non_duplicate_members(
369-
object: object, check_duplicates: object
369+
obj: object, check_duplicates: object
370370
) -> dict[str, Callable]:
371371
"""Returns all methods/functions unique to the object."""
372372
members = dict(
373373
inspect.getmembers(
374-
object,
374+
obj,
375375
# Checks for ismethod or isfunction because of the methods added from the MifiedProtocol.
376-
predicate=lambda x: inspect.ismethod(x)
377-
or (
378-
inspect.isfunction(x)
379-
and x.__name__ not in dict(inspect.getmembers(check_duplicates)).keys()
380-
),
376+
predicate=lambda x: (inspect.ismethod(x) or inspect.isfunction(x))
377+
and x.__name__ not in dict(inspect.getmembers(check_duplicates)).keys(),
381378
)
382379
)
383380
return members

0 commit comments

Comments
 (0)