Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 57 additions & 1 deletion mypy/typeshed/stdlib/_bisect.pyi
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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: ...
Expand Down
30 changes: 12 additions & 18 deletions mypy/typeshed/stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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: ...
Expand Down Expand Up @@ -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]: ...
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/contextlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand All @@ -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: ...
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/email/_header_value_parser.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down
2 changes: 2 additions & 0 deletions mypy/typeshed/stdlib/encodings/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
Expand Down
Loading
Loading