Harmonise return type of builtins.__import__ and importlib.import_module (#6302)

builtins.__import__ now returns ModuleType instead of Any. In addition, add __getattr__() to ModuleType to ease using imported modules.
This commit is contained in:
Alex Waygood
2021-11-15 15:21:46 +00:00
committed by GitHub
parent 10c9d8cfce
commit aa7e277adb
4 changed files with 8 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ import types
from importlib.abc import Loader
from typing import Any, Mapping, Sequence
# `__import__` and `import_module` return type should be kept the same as `builtins.__import__`
def __import__(
name: str,
globals: Mapping[str, Any] | None = ...,