Skip to content

Commit

Permalink
fix: Do not create aliases pointing to themselves
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Feb 10, 2024
1 parent 3a4d054 commit 356305f
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/griffe/agents/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,16 +536,20 @@ def visit_importfrom(self, node: ast.ImportFrom) -> None:
else:
alias_name = name.asname or name.name
self.current.imports[alias_name] = alias_path
self.current.set_member(
alias_name,
Alias(
# Do not create aliases pointing to themselves (it happens with
# `from package.current_module import Thing as Thing` or
# `from . import thing as thing`).
if alias_path != f"{self.current.path}.{alias_name}":
self.current.set_member(
alias_name,
alias_path,
lineno=node.lineno,
endlineno=node.end_lineno,
runtime=not self.type_guarded,
),
)
Alias(
alias_name,
alias_path,
lineno=node.lineno,
endlineno=node.end_lineno,
runtime=not self.type_guarded,
),
)

def handle_attribute(
self,
Expand Down

0 comments on commit 356305f

Please sign in to comment.