8000 Resolve builtins/importlib inconsistencies (#6310) · python/typeshed@1274445 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1274445

Browse files
authored
Resolve builtins/importlib inconsistencies (#6310)
1 parent edf82e8 commit 1274445

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

stdlib/builtins.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,7 @@ class zip(Iterator[_T_co], Generic[_T_co]):
14431443
def __iter__(self) -> Iterator[_T_co]: ...
14441444
def __next__(self) -> _T_co: ...
14451445

1446+
# Signature of `builtins.__import__` should be kept identical to `importlib.__import__`
14461447
# Return type of `__import__` should be kept the same as return type of `importlib.import_module`
14471448
def __import__(
14481449
name: str,

stdlib/importlib/__init__.pyi

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
import types
21
from importlib.abc import Loader
3-
from typing import Any, Mapping, Sequence
2+
from types import ModuleType
3+
from typing import Mapping, Sequence
44

5-
# `__import__` and `import_module` return type should be kept the same as `builtins.__import__`
5+
# Signature of `builtins.__import__` should be kept identical to `importlib.__import__`
66
def __import__(
77
name: str,
8-
globals: Mapping[str, Any] | None = ...,
9-
locals: Mapping[str, Any] | None = ...,
8+
globals: Mapping[str, object] | None = ...,
9+
locals: Mapping[str, object] | None = ...,
1010
fromlist: Sequence[str] = ...,
1111
level: int = ...,
12-
) -> types.ModuleType: ...
13-
def import_module(name: str, package: str | None = ...) -> types.ModuleType: ...
12+
) -> ModuleType: ...
13+
14+
# `importlib.import_module` return type should be kept the same as `builtins.__import__`
15+
def import_module(name: str, package: str | None = ...) -> ModuleType: ...
1416
def find_loader(name: str, path: str | None = ...) -> Loader | None: ...
1517
def invalidate_caches() -> None: ...
16-
def reload(module: types.ModuleType) -> types.ModuleType: ...
18+
def reload(module: ModuleType) -> ModuleType: ...

0 commit comments

Comments
 (0)
0