Skip to content

Commit

Permalink
fix: Fix aliases for direct nested imports
Browse files Browse the repository at this point in the history
Previously `import a.b.c` was creating an alias
with name `a` pointing to `a.b.c`.
Now it creates an alias with name `a`
pointing to `a`.
We don't care about the nested attributes.

Issue mkdocstrings/python#32: mkdocstrings/python#32
  • Loading branch information
pawamoy committed Jul 13, 2023
1 parent 20f1f8f commit e9867f7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/griffe/agents/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def visit_import(self, node: ast.Import) -> None:
node: The node to visit.
"""
for name in node.names:
alias_path = name.name
alias_path = name.name.split(".", 1)[0]
alias_name = name.asname or alias_path.split(".", 1)[0]
self.current.imports[alias_name] = alias_path
self.current.set_member(
Expand Down

0 comments on commit e9867f7

Please # to comment.