diff --git a/mypy/typeshed/stdlib/_bisect.pyi b/mypy/typeshed/stdlib/_bisect.pyi index 58488e3d15afe..5ac43b3e06414 100644 --- a/mypy/typeshed/stdlib/_bisect.pyi +++ b/mypy/typeshed/stdlib/_bisect.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import SupportsLenAndGetItem, SupportsRichComparisonT +from _typeshed import SupportsGetItem, SupportsLenAndGetItem, SupportsRichComparisonT from collections.abc import Callable, MutableSequence from typing import TypeVar, overload @@ -16,6 +16,14 @@ if sys.version_info >= (3, 10): key: None = None, ) -> int: ... @overload + def bisect_left( + a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int, hi: int, *, key: None = None + ) -> int: ... + @overload + def bisect_left( + a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, *, hi: int, key: None = None + ) -> int: ... + @overload def bisect_left( a: SupportsLenAndGetItem[_T], x: SupportsRichComparisonT, @@ -25,6 +33,19 @@ if sys.version_info >= (3, 10): key: Callable[[_T], SupportsRichComparisonT], ) -> int: ... @overload + def bisect_left( + a: SupportsGetItem[int, _T], x: SupportsRichComparisonT, lo: int, hi: int, *, key: Callable[[_T], SupportsRichComparisonT] + ) -> int: ... + @overload + def bisect_left( + a: SupportsGetItem[int, _T], + x: SupportsRichComparisonT, + lo: int = 0, + *, + hi: int, + key: Callable[[_T], SupportsRichComparisonT], + ) -> int: ... + @overload def bisect_right( a: SupportsLenAndGetItem[SupportsRichComparisonT], x: SupportsRichComparisonT, @@ -34,6 +55,14 @@ if sys.version_info >= (3, 10): key: None = None, ) -> int: ... @overload + def bisect_right( + a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int, hi: int, *, key: None = None + ) -> int: ... + @overload + def bisect_right( + a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, *, hi: int, key: None = None + ) -> int: ... + @overload def bisect_right( a: SupportsLenAndGetItem[_T], x: SupportsRichComparisonT, @@ -43,6 +72,19 @@ if sys.version_info >= (3, 10): key: Callable[[_T], SupportsRichComparisonT], ) -> int: ... @overload + def bisect_right( + a: SupportsGetItem[int, _T], x: SupportsRichComparisonT, lo: int, hi: int, *, key: Callable[[_T], SupportsRichComparisonT] + ) -> int: ... + @overload + def bisect_right( + a: SupportsGetItem[int, _T], + x: SupportsRichComparisonT, + lo: int = 0, + *, + hi: int, + key: Callable[[_T], SupportsRichComparisonT], + ) -> int: ... + @overload def insort_left( a: MutableSequence[SupportsRichComparisonT], x: SupportsRichComparisonT, @@ -70,12 +112,26 @@ if sys.version_info >= (3, 10): ) -> None: ... else: + @overload def bisect_left( a: SupportsLenAndGetItem[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None ) -> int: ... + @overload + def bisect_left(a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int, hi: int) -> int: ... + @overload + def bisect_left( + a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, *, hi: int + ) -> int: ... + @overload def bisect_right( a: SupportsLenAndGetItem[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None ) -> int: ... + @overload + def bisect_right(a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int, hi: int) -> int: ... + @overload + def bisect_right( + a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, *, hi: int + ) -> int: ... def insort_left( a: MutableSequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None ) -> None: ... diff --git a/mypy/typeshed/stdlib/builtins.pyi b/mypy/typeshed/stdlib/builtins.pyi index 03c3bd2e17c74..674142d709a29 100644 --- a/mypy/typeshed/stdlib/builtins.pyi +++ b/mypy/typeshed/stdlib/builtins.pyi @@ -1142,13 +1142,7 @@ class dict(MutableMapping[_KT, _VT]): def __reversed__(self) -> Iterator[_KT]: ... __hash__: ClassVar[None] # type: ignore[assignment] def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... - @overload - def __or__(self, value: dict[_KT, _VT], /) -> dict[_KT, _VT]: ... - @overload def __or__(self, value: dict[_T1, _T2], /) -> dict[_KT | _T1, _VT | _T2]: ... - @overload - def __ror__(self, value: dict[_KT, _VT], /) -> dict[_KT, _VT]: ... - @overload def __ror__(self, value: dict[_T1, _T2], /) -> dict[_KT | _T1, _VT | _T2]: ... # dict.__ior__ should be kept roughly in line with MutableMapping.update() @overload # type: ignore[misc] @@ -1164,16 +1158,16 @@ class set(MutableSet[_T]): def __init__(self, iterable: Iterable[_T], /) -> None: ... def add(self, element: _T, /) -> None: ... def copy(self) -> set[_T]: ... - def difference(self, *s: Iterable[Any]) -> set[_T]: ... - def difference_update(self, *s: Iterable[Any]) -> None: ... - def discard(self, element: _T, /) -> None: ... - def intersection(self, *s: Iterable[Any]) -> set[_T]: ... - def intersection_update(self, *s: Iterable[Any]) -> None: ... - def isdisjoint(self, s: Iterable[Any], /) -> bool: ... - def issubset(self, s: Iterable[Any], /) -> bool: ... - def issuperset(self, s: Iterable[Any], /) -> bool: ... + def difference(self, *s: Iterable[object]) -> set[_T]: ... + def difference_update(self, *s: Iterable[object]) -> None: ... + def discard(self, element: object, /) -> None: ... + def intersection(self, *s: Iterable[object]) -> set[_T]: ... + def intersection_update(self, *s: Iterable[object]) -> None: ... + def isdisjoint(self, s: Iterable[object], /) -> bool: ... + def issubset(self, s: Iterable[object], /) -> bool: ... + def issuperset(self, s: Iterable[object], /) -> bool: ... def remove(self, element: _T, /) -> None: ... - def symmetric_difference(self, s: Iterable[_T], /) -> set[_T]: ... + def symmetric_difference(self, s: Iterable[_S], /) -> set[_T | _S]: ... def symmetric_difference_update(self, s: Iterable[_T], /) -> None: ... def union(self, *s: Iterable[_S]) -> set[_T | _S]: ... def update(self, *s: Iterable[_T]) -> None: ... @@ -1205,15 +1199,15 @@ class frozenset(AbstractSet[_T_co]): def copy(self) -> frozenset[_T_co]: ... def difference(self, *s: Iterable[object]) -> frozenset[_T_co]: ... def intersection(self, *s: Iterable[object]) -> frozenset[_T_co]: ... - def isdisjoint(self, s: Iterable[_T_co], /) -> bool: ... + def isdisjoint(self, s: Iterable[object], /) -> bool: ... def issubset(self, s: Iterable[object], /) -> bool: ... def issuperset(self, s: Iterable[object], /) -> bool: ... - def symmetric_difference(self, s: Iterable[_T_co], /) -> frozenset[_T_co]: ... + def symmetric_difference(self, s: Iterable[_S], /) -> frozenset[_T_co | _S]: ... def union(self, *s: Iterable[_S]) -> frozenset[_T_co | _S]: ... def __len__(self) -> int: ... def __contains__(self, o: object, /) -> bool: ... def __iter__(self) -> Iterator[_T_co]: ... - def __and__(self, value: AbstractSet[_T_co], /) -> frozenset[_T_co]: ... + def __and__(self, value: AbstractSet[object], /) -> frozenset[_T_co]: ... def __or__(self, value: AbstractSet[_S], /) -> frozenset[_T_co | _S]: ... def __sub__(self, value: AbstractSet[object], /) -> frozenset[_T_co]: ... def __xor__(self, value: AbstractSet[_S], /) -> frozenset[_T_co | _S]: ... diff --git a/mypy/typeshed/stdlib/contextlib.pyi b/mypy/typeshed/stdlib/contextlib.pyi index 221102ee23956..cf831e5dcae81 100644 --- a/mypy/typeshed/stdlib/contextlib.pyi +++ b/mypy/typeshed/stdlib/contextlib.pyi @@ -197,7 +197,7 @@ if sys.version_info >= (3, 10): class nullcontext(AbstractContextManager[_T, None], AbstractAsyncContextManager[_T, None]): enter_result: _T @overload - def __init__(self: nullcontext[None], enter_result: None = None) -> None: ... + def __init__(self: nullcontext[None]) -> None: ... @overload def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780 def __enter__(self) -> _T: ... @@ -209,7 +209,7 @@ else: class nullcontext(AbstractContextManager[_T, None]): enter_result: _T @overload - def __init__(self: nullcontext[None], enter_result: None = None) -> None: ... + def __init__(self: nullcontext[None]) -> None: ... @overload def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780 def __enter__(self) -> _T: ... diff --git a/mypy/typeshed/stdlib/email/_header_value_parser.pyi b/mypy/typeshed/stdlib/email/_header_value_parser.pyi index 32caf83bd0220..a6d7c48d69cd8 100644 --- a/mypy/typeshed/stdlib/email/_header_value_parser.pyi +++ b/mypy/typeshed/stdlib/email/_header_value_parser.pyi @@ -26,8 +26,8 @@ SPECIALSNL: Final[set[str]] def make_quoted_pairs(value: Any) -> str: ... def quote_string(value: Any) -> str: ... -if sys.version_info >= (3, 13): - # Added in Python 3.13.12, 3.14.3 +if sys.version_info >= (3, 10): + # Added in Python 3.10.20, 3.11.15, 3.12.13, 3.13.12, 3.14.3 def make_parenthesis_pairs(value: Any) -> str: ... rfc2047_matcher: Final[Pattern[str]] diff --git a/mypy/typeshed/stdlib/encodings/__init__.pyi b/mypy/typeshed/stdlib/encodings/__init__.pyi index 61f86d243c720..e03758ce59a0e 100644 --- a/mypy/typeshed/stdlib/encodings/__init__.pyi +++ b/mypy/typeshed/stdlib/encodings/__init__.pyi @@ -1,6 +1,8 @@ import sys from codecs import CodecInfo +from . import aliases as aliases + class CodecRegistryError(LookupError, SystemError): ... def normalize_encoding(encoding: str | bytes) -> str: ... diff --git a/mypy/typeshed/stdlib/tarfile.pyi b/mypy/typeshed/stdlib/tarfile.pyi index 6e68c370f3aa3..7d6bb341db314 100644 --- a/mypy/typeshed/stdlib/tarfile.pyi +++ b/mypy/typeshed/stdlib/tarfile.pyi @@ -128,8 +128,8 @@ class TarFile: errors: str fileobject: type[ExFileObject] # undocumented pax_headers: Mapping[str, str] - debug: int - errorlevel: int + debug: Literal[0, 1, 2, 3] + errorlevel: Literal[0, 1, 2] offset: int # undocumented extraction_filter: _FilterFunction | None if sys.version_info >= (3, 13): @@ -146,8 +146,8 @@ class TarFile: encoding: str | None = None, errors: str = "surrogateescape", pax_headers: Mapping[str, str] | None = None, - debug: int | None = None, - errorlevel: int | None = None, + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 copybufsize: int | None = None, # undocumented stream: bool = False, ) -> None: ... @@ -164,8 +164,8 @@ class TarFile: encoding: str | None = None, errors: str = "surrogateescape", pax_headers: Mapping[str, str] | None = None, - debug: int | None = None, - errorlevel: int | None = None, + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 copybufsize: int | None = None, # undocumented ) -> None: ... @@ -190,8 +190,8 @@ class TarFile: encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 ) -> Self: ... if sys.version_info >= (3, 14): @overload @@ -210,8 +210,8 @@ class TarFile: encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 level: None = None, options: Mapping[int, int] | None = None, zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, @@ -233,8 +233,8 @@ class TarFile: encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 ) -> Self: ... @overload @classmethod @@ -252,8 +252,8 @@ class TarFile: encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 ) -> Self: ... @overload @classmethod @@ -271,8 +271,8 @@ class TarFile: encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 compresslevel: int = 9, ) -> Self: ... @overload @@ -291,8 +291,8 @@ class TarFile: encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 compresslevel: int = 9, ) -> Self: ... @overload @@ -311,8 +311,8 @@ class TarFile: encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 preset: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | None = ..., ) -> Self: ... @overload @@ -331,8 +331,8 @@ class TarFile: encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 preset: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | None = ..., ) -> Self: ... if sys.version_info >= (3, 14): @@ -352,8 +352,8 @@ class TarFile: encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 options: Mapping[int, int] | None = None, zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, ) -> Self: ... @@ -373,8 +373,8 @@ class TarFile: encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 options: Mapping[int, int] | None = None, zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, ) -> Self: ... @@ -395,8 +395,8 @@ class TarFile: encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 ) -> Self: ... @overload @classmethod @@ -414,8 +414,8 @@ class TarFile: encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 ) -> Self: ... @overload @classmethod @@ -433,8 +433,8 @@ class TarFile: encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 ) -> Self: ... @overload @classmethod @@ -452,8 +452,8 @@ class TarFile: encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 ) -> Self: ... @overload @classmethod @@ -471,8 +471,8 @@ class TarFile: encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 compresslevel: int = 9, ) -> Self: ... @overload @@ -491,8 +491,8 @@ class TarFile: encoding: str | None = ..., errors: str = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 compresslevel: int = 9, ) -> Self: ... @classmethod @@ -509,8 +509,8 @@ class TarFile: ignore_zeros: bool | None = ..., encoding: str | None = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 ) -> Self: ... @overload @classmethod @@ -527,8 +527,8 @@ class TarFile: ignore_zeros: bool | None = ..., encoding: str | None = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 ) -> Self: ... @overload @classmethod @@ -545,8 +545,8 @@ class TarFile: ignore_zeros: bool | None = ..., encoding: str | None = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 ) -> Self: ... @overload @classmethod @@ -563,8 +563,8 @@ class TarFile: ignore_zeros: bool | None = ..., encoding: str | None = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 ) -> Self: ... @overload @classmethod @@ -581,8 +581,8 @@ class TarFile: ignore_zeros: bool | None = ..., encoding: str | None = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 ) -> Self: ... @classmethod def xzopen( @@ -598,8 +598,8 @@ class TarFile: ignore_zeros: bool | None = ..., encoding: str | None = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 ) -> Self: ... if sys.version_info >= (3, 14): @overload @@ -619,8 +619,8 @@ class TarFile: ignore_zeros: bool | None = ..., encoding: str | None = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 ) -> Self: ... @overload @classmethod @@ -639,8 +639,8 @@ class TarFile: ignore_zeros: bool | None = ..., encoding: str | None = ..., pax_headers: Mapping[str, str] | None = ..., - debug: int | None = ..., - errorlevel: int | None = ..., + debug: Literal[0, 1, 2, 3] | None = None, # default 0 + errorlevel: Literal[0, 1, 2] | None = None, # default 1 ) -> Self: ... def getmember(self, name: str) -> TarInfo: ... diff --git a/mypy/typeshed/stdlib/tkinter/__init__.pyi b/mypy/typeshed/stdlib/tkinter/__init__.pyi index 90225a8a3652a..a70ef2351f3d4 100644 --- a/mypy/typeshed/stdlib/tkinter/__init__.pyi +++ b/mypy/typeshed/stdlib/tkinter/__init__.pyi @@ -1153,7 +1153,9 @@ class Grid: ipady: float | str = ..., padx: float | str | tuple[float | str, float | str] = ..., pady: float | str | tuple[float | str, float | str] = ..., - sticky: str = ..., # consists of letters 'n', 's', 'w', 'e', may contain repeats, may be empty + sticky: ( + str | list[str] | tuple[str, ...] + ) = ..., # consists of letters 'n', 's', 'w', 'e', may contain repeats, may be empty in_: Misc = ..., **kw: Any, # allow keyword argument named 'in', see #4836 ) -> None: ... diff --git a/mypy/typeshed/stdlib/urllib/request.pyi b/mypy/typeshed/stdlib/urllib/request.pyi index f7e1f278d3e68..d6bb2f9647824 100644 --- a/mypy/typeshed/stdlib/urllib/request.pyi +++ b/mypy/typeshed/stdlib/urllib/request.pyi @@ -92,7 +92,7 @@ else: context: None = None, ) -> _UrlopenRet: ... -def install_opener(opener: OpenerDirector) -> None: ... +def install_opener(opener: OpenerDirector | None) -> None: ... def build_opener(*handlers: BaseHandler | Callable[[], BaseHandler]) -> OpenerDirector: ... if sys.version_info >= (3, 14):