diff --git a/requirements-tests.txt b/requirements-tests.txt index ac7223db9faf..2b789786d283 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -7,7 +7,7 @@ flake8-noqa==1.4.0 # must match .pre-commit-config.yaml flake8-pyi==24.4.0 # must match .pre-commit-config.yaml mypy==1.9.0 pre-commit-hooks==4.5.0 # must match .pre-commit-config.yaml -pyright==1.1.358 +pyright==1.1.359 pytype==2024.4.11; platform_system != "Windows" and python_version < "3.12" ruff==0.3.7 # must match .pre-commit-config.yaml diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index f531c181b222..61357aa2dc2c 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1031,15 +1031,15 @@ class dict(MutableMapping[_KT, _VT]): @overload def __init__(self) -> None: ... @overload - def __init__(self: dict[str, _VT], **kwargs: _VT) -> None: ... + def __init__(self: dict[str, _T], **kwargs: _T) -> None: ... @overload - def __init__(self, map: SupportsKeysAndGetItem[_KT, _VT], /) -> None: ... + def __init__(self: dict[_T1, _T2], map: SupportsKeysAndGetItem[_T1, _T2], /) -> None: ... @overload - def __init__(self: dict[str, _VT], map: SupportsKeysAndGetItem[str, _VT], /, **kwargs: _VT) -> None: ... + def __init__(self: dict[str, _T], map: SupportsKeysAndGetItem[str, _T], /, **kwargs: _T) -> None: ... @overload - def __init__(self, iterable: Iterable[tuple[_KT, _VT]], /) -> None: ... + def __init__(self: dict[_T1, _T2], iterable: Iterable[tuple[_T1, _T2]], /) -> None: ... @overload - def __init__(self: dict[str, _VT], iterable: Iterable[tuple[str, _VT]], /, **kwargs: _VT) -> None: ... + def __init__(self: dict[str, _T], iterable: Iterable[tuple[str, _T]], /, **kwargs: _T) -> None: ... # Next two overloads are for dict(string.split(sep) for string in iterable) # Cannot be Iterable[Sequence[_T]] or otherwise dict(["foo", "bar", "baz"]) is not an error @overload diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 1d23ecd66a8d..4d2e188294fc 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -51,15 +51,15 @@ class UserDict(MutableMapping[_KT, _VT]): @overload def __init__(self, dict: None = None, /) -> None: ... @overload - def __init__(self: UserDict[str, _VT], dict: None = None, /, **kwargs: _VT) -> None: ... + def __init__(self: UserDict[str, _T], dict: None = None, /, **kwargs: _T) -> None: ... @overload - def __init__(self, dict: SupportsKeysAndGetItem[_KT, _VT], /) -> None: ... + def __init__(self: UserDict[_T1, _T2], dict: SupportsKeysAndGetItem[_T1, _T2], /) -> None: ... @overload - def __init__(self: UserDict[str, _VT], dict: SupportsKeysAndGetItem[str, _VT], /, **kwargs: _VT) -> None: ... + def __init__(self: UserDict[str, _T], dict: SupportsKeysAndGetItem[str, _T], /, **kwargs: _T) -> None: ... @overload - def __init__(self, iterable: Iterable[tuple[_KT, _VT]], /) -> None: ... + def __init__(self: UserDict[_T1, _T2], iterable: Iterable[tuple[_T1, _T2]], /) -> None: ... @overload - def __init__(self: UserDict[str, _VT], iterable: Iterable[tuple[str, _VT]], /, **kwargs: _VT) -> None: ... + def __init__(self: UserDict[str, _T], iterable: Iterable[tuple[str, _T]], /, **kwargs: _T) -> None: ... @overload def __init__(self: UserDict[str, str], iterable: Iterable[list[str]], /) -> None: ... @overload @@ -389,30 +389,30 @@ class defaultdict(dict[_KT, _VT]): @overload def __init__(self) -> None: ... @overload - def __init__(self: defaultdict[str, _VT], **kwargs: _VT) -> None: ... + def __init__(self: defaultdict[str, _T], **kwargs: _T) -> None: ... @overload - def __init__(self, default_factory: Callable[[], _VT] | None, /) -> None: ... + def __init__(self: defaultdict[_KT, _T], default_factory: Callable[[], _T] | None, /) -> None: ... @overload - def __init__(self: defaultdict[str, _VT], default_factory: Callable[[], _VT] | None, /, **kwargs: _VT) -> None: ... + def __init__(self: defaultdict[str, _T], default_factory: Callable[[], _T] | None, /, **kwargs: _T) -> None: ... @overload - def __init__(self, default_factory: Callable[[], _VT] | None, map: SupportsKeysAndGetItem[_KT, _VT], /) -> None: ... + def __init__( + self: defaultdict[_T1, _T2], default_factory: Callable[[], _T2] | None, map: SupportsKeysAndGetItem[_T1, _T2], / + ) -> None: ... @overload def __init__( - self: defaultdict[str, _VT], - default_factory: Callable[[], _VT] | None, - map: SupportsKeysAndGetItem[str, _VT], + self: defaultdict[str, _T], + default_factory: Callable[[], _T] | None, + map: SupportsKeysAndGetItem[str, _T], /, - **kwargs: _VT, + **kwargs: _T, ) -> None: ... @overload - def __init__(self, default_factory: Callable[[], _VT] | None, iterable: Iterable[tuple[_KT, _VT]], /) -> None: ... + def __init__( + self: defaultdict[_T1, _T2], default_factory: Callable[[], _T2] | None, iterable: Iterable[tuple[_T1, _T2]], / + ) -> None: ... @overload def __init__( - self: defaultdict[str, _VT], - default_factory: Callable[[], _VT] | None, - iterable: Iterable[tuple[str, _VT]], - /, - **kwargs: _VT, + self: defaultdict[str, _T], default_factory: Callable[[], _T] | None, iterable: Iterable[tuple[str, _T]], /, **kwargs: _T ) -> None: ... def __missing__(self, key: _KT, /) -> _VT: ... def __copy__(self) -> Self: ... diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index f82bb4b7b6ad..e27d5ab6a310 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -29,6 +29,7 @@ if sys.version_info >= (3, 11): __all__ += ["chdir"] _T = TypeVar("_T") +_T1 = TypeVar("_T1") _T_co = TypeVar("_T_co", covariant=True) _T_io = TypeVar("_T_io", bound=IO[str] | None) _F = TypeVar("_F", bound=Callable[..., Any]) @@ -182,7 +183,7 @@ if sys.version_info >= (3, 10): @overload def __init__(self: nullcontext[None], enter_result: None = None) -> None: ... @overload - def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... + def __init__(self: nullcontext[_T1], enter_result: _T1) -> None: ... def __enter__(self) -> _T: ... def __exit__(self, *exctype: Unused) -> None: ... async def __aenter__(self) -> _T: ... @@ -194,7 +195,7 @@ else: @overload def __init__(self: nullcontext[None], enter_result: None = None) -> None: ... @overload - def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... + def __init__(self: nullcontext[_T1], enter_result: _T1) -> None: ... def __enter__(self) -> _T: ... def __exit__(self, *exctype: Unused) -> None: ... diff --git a/stdlib/weakref.pyi b/stdlib/weakref.pyi index 8f3ad0631c10..8b9b34dc6b1e 100644 --- a/stdlib/weakref.pyi +++ b/stdlib/weakref.pyi @@ -51,10 +51,10 @@ class WeakValueDictionary(MutableMapping[_KT, _VT]): @overload def __init__(self) -> None: ... @overload - def __init__(self: WeakValueDictionary[_KT, _VT], other: Mapping[_KT, _VT] | Iterable[tuple[_KT, _VT]], /) -> None: ... + def __init__(self: WeakValueDictionary[_T1, _T2], other: Mapping[_T1, _T2] | Iterable[tuple[_T1, _T2]], /) -> None: ... @overload def __init__( - self: WeakValueDictionary[str, _VT], other: Mapping[str, _VT] | Iterable[tuple[str, _VT]] = (), /, **kwargs: _VT + self: WeakValueDictionary[str, _T], other: Mapping[str, _T] | Iterable[tuple[str, _T]] = (), /, **kwargs: _T ) -> None: ... def __len__(self) -> int: ... def __getitem__(self, key: _KT) -> _VT: ...