Skip to content

Commit

Permalink
fix: Exclude some special low-level members that cause cyclic issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Jan 4, 2022
1 parent 349b703 commit b54ab34
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/griffe/agents/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ class ObjectNode:
parent: The parent node.
"""

# low level stuff known to cause issues when resolving aliases
exclude_specials = {"__builtins__", "__loader__", "__spec__"}

def __init__(self, obj: Any, name: str, parent: ObjectNode | None = None) -> None:
"""
Initialize the object.
Expand Down Expand Up @@ -341,7 +344,7 @@ def children(self) -> Sequence[ObjectNode]: # noqa: WPS231
"""
children = []
for name, member in inspect.getmembers(self.obj):
if self._pick_member(member):
if self._pick_member(name, member):
children.append(ObjectNode(member, name, parent=self))
return children

Expand Down Expand Up @@ -497,8 +500,13 @@ def _ids(self) -> set[int]:
return {id(self.obj)}
return {id(self.obj)} | self.parent._ids # noqa: WPS437

def _pick_member(self, member: Any) -> bool:
return member is not type and member is not object and id(member) not in self._ids
def _pick_member(self, name: str, member: Any) -> bool:
return (
name not in self.exclude_specials
and member is not type
and member is not object
and id(member) not in self._ids
)


def _join(sequence, item):
Expand Down

0 comments on commit b54ab34

Please sign in to comment.