-
Notifications
You must be signed in to change notification settings - Fork 115
Open
Labels
importsModule resolution, site-packages discovery, import-related diagnosticsModule resolution, site-packages discovery, import-related diagnosticsruntime semanticsAccurate modeling of how Python's semantics work at runtimeAccurate modeling of how Python's semantics work at runtime
Milestone
Description
Consider the following case (playground):
main.py
import module
# Missing explicit import of submodule:
# import module.submodule
print(module.submodule.SubmoduleClass)
module/__init__.py
from module.submodule import SubmoduleClass
module/submodule.py
class SubmoduleClass: ...
This works at runtime due to a quirk in module resolution (the from module.submodule import SubmoduleClass
import implicitly stores submodule
as an attribute on module
, thanks @AlexWaygood).
It is not considered good practice to rely on this, but people will probably write code that does so. Neither pyright nor mypy report any errors here. Should we attempt to model this behavior as well?
janosh, auscompgeek, danielhollas, edgarrmondragon, hauntsaninja and 1 more
Metadata
Metadata
Assignees
Labels
importsModule resolution, site-packages discovery, import-related diagnosticsModule resolution, site-packages discovery, import-related diagnosticsruntime semanticsAccurate modeling of how Python's semantics work at runtimeAccurate modeling of how Python's semantics work at runtime