From e9867f78044a2a33b575e274224d3a4c16b62439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Thu, 13 Jul 2023 21:05:31 +0200 Subject: [PATCH] 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: https://github.com/mkdocstrings/python/issues/32 --- src/griffe/agents/visitor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/griffe/agents/visitor.py b/src/griffe/agents/visitor.py index c5ddc1be..c97eabee 100644 --- a/src/griffe/agents/visitor.py +++ b/src/griffe/agents/visitor.py @@ -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(