mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-24 03:51:52 +08:00
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:
@@ -178,6 +178,10 @@ class ModuleType:
|
||||
__path__: MutableSequence[str]
|
||||
__spec__: ModuleSpec | None
|
||||
def __init__(self, name: str, doc: str | None = ...) -> None: ...
|
||||
# __getattr__ doesn't exist at runtime,
|
||||
# but having it here in typeshed makes dynamic imports
|
||||
# using `builtins.__import__` or `importlib.import_module` less painful
|
||||
def __getattr__(self, name: str) -> Any: ...
|
||||
|
||||
@final
|
||||
class GeneratorType(Generator[_T_co, _T_contra, _V_co]):
|
||||
|
||||
Reference in New Issue
Block a user