Skip to content

Commit fca4039

Browse files
authored
Fix possible incorrectly resolved member path (#2614)
Don't look in sub-modules that are not in the original member path.
1 parent 32cb543 commit fca4039

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

util/doc_helpers/import_resolver.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,22 @@ def get_full_module_path(self) -> str:
3333
def resolve(self, full_path: str, level=0) -> str | None:
3434
"""Return the lowest import of a member in the tree."""
3535
name = full_path.split(".")[-1]
36+
modules = full_path.split(".")
3637

3738
# Find an import in this module likely to be the one we want.
3839
for imp in self.imports:
3940
if imp.name == name and imp.from_module in full_path:
40-
print(f"Found: {imp.name} in {imp.module}")
41+
# print(f"Found: {imp.name} in {imp.module}")
4142
return f"{imp.module}.{imp.name}"
4243

4344
# Move on to children
45+
module = modules[level + 1]
4446
for child in self.children:
45-
print(f"Checking child: {child.name}")
46-
result = child.resolve(full_path, level + 1)
47-
if result:
48-
return result
47+
if child.name == module:
48+
# print(f"Checking child: {child.name}")
49+
result = child.resolve(full_path, level + 1)
50+
if result:
51+
return result
4952

5053
# We're back from recursing and didn't find anything.
5154
if level == 0:

0 commit comments

Comments
 (0)