Python: Fix import * from __init__.py files

This commit is contained in:
Rasmus Wriedt Larsen
2023-02-15 13:57:18 +01:00
parent df6039d6cf
commit 66c3529465
2 changed files with 3 additions and 2 deletions

View File

@@ -167,8 +167,9 @@ module ImportResolution {
)
}
/** Gets the module from which attributes are imported by `i`. */
Module getModuleImportedByImportStar(ImportStar i) {
isPreferredModuleForName(result.getFile(), i.getImportedModuleName())
isPreferredModuleForName(result.getFile(), i.getImportedModuleName() + ["", ".__init__"])
}
/**

View File

@@ -87,7 +87,7 @@ check("non_clashing_submodule", non_clashing_submodule, "<module attr_clash.non_
# check that import * from an __init__ file works
from package.subpackage2 import *
check("subpackage2_attr", subpackage2_attr, "subpackage2_attr", globals()) #$ MISSING: prints=subpackage2_attr
check("subpackage2_attr", subpackage2_attr, "subpackage2_attr", globals()) #$ prints=subpackage2_attr
exit(__file__)