Open jorgepiloto opened 9 months ago
I was able to come up with some logic to prevent this from happening:
module_node, assigns = lookup_node.lookup(top_level_name)
if len(assigns) == 1 and isinstance(assigns[0], astroid.ImportFrom) and ('*', None) == assigns[0].names[0]:
import_nodes = [
import_node
for import_node in module_node.get_children()
if is_import_or_importfrom_node(import_node)
]
for import_node in import_nodes:
if any(top_level_name in namealias for namealias in import_node.names):
assigns = [import_node]
I must confess I do not like previous code.
Also, it does not work when you run into a double wildcard import...
The issue π
Consider the following project:
The content of each file:
The result is:
Investigations π
It looks like the import matters:
I am a bit surprised that this behavior applies even if
__all__
is used in both modules.Origin of the problem It looks like the function resolve_qualname is the one causing the issue.