Skip to content

Commit

Permalink
refactor: Empty generic visit/inspect methods in base classes
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Jan 2, 2022
1 parent 60439ee commit 338760e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
8 changes: 2 additions & 6 deletions src/griffe/agents/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ def visit(self, node: ast.AST) -> None:
"""
getattr(self, f"visit_{node.kind}", self.generic_visit)(node) # type: ignore[attr-defined]

def generic_visit(self, node: ast.AST) -> None: # noqa: WPS231
def generic_visit(self, node: ast.AST) -> None:
"""Visit the children of a node.
Parameters:
node: The node to visit (its children).
"""
for child in node.children: # type: ignore[attr-defined] # noqa: WPS437
self.visit(child)


class BaseInspector:
Expand All @@ -39,11 +37,9 @@ def inspect(self, node: ObjectNode) -> None:
"""
getattr(self, f"inspect_{node.kind}", self.generic_inspect)(node)

def generic_inspect(self, node: ObjectNode) -> None: # noqa: WPS231
def generic_inspect(self, node: ObjectNode) -> None:
"""Inspect the children of a node.
Parameters:
node: The node to inspect (its children).
"""
for child in node.children:
self.inspect(child)
3 changes: 2 additions & 1 deletion src/griffe/agents/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ def generic_visit(self, node: ast.AST) -> None: # noqa: WPS231
"""
for before_visitor in self.extensions.before_children_visit:
before_visitor.visit(node)
super().generic_visit(node)
for child in node.children: # type: ignore[attr-defined] # noqa: WPS437
self.visit(child)
for after_visitor in self.extensions.after_children_visit:
after_visitor.visit(node)

Expand Down

0 comments on commit 338760e

Please sign in to comment.