Skip to content

Commit e9867f7

Browse files
committed
fix: Fix aliases for direct nested imports
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
1 parent 20f1f8f commit e9867f7

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/griffe/agents/visitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ def visit_import(self, node: ast.Import) -> None:
503503
node: The node to visit.
504504
"""
505505
for name in node.names:
506-
alias_path = name.name
506+
alias_path = name.name.split(".", 1)[0]
507507
alias_name = name.asname or alias_path.split(".", 1)[0]
508508
self.current.imports[alias_name] = alias_path
509509
self.current.set_member(

0 commit comments

Comments
 (0)