Skip to content

Commit acfef9c

Browse files
Sync typeshed (#21021)
Source commit: python/typeshed@f8f0794
1 parent e704578 commit acfef9c

File tree

8 files changed

+133
-79
lines changed

8 files changed

+133
-79
lines changed

mypy/typeshed/stdlib/_bisect.pyi

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
from _typeshed import SupportsLenAndGetItem, SupportsRichComparisonT
2+
from _typeshed import SupportsGetItem, SupportsLenAndGetItem, SupportsRichComparisonT
33
from collections.abc import Callable, MutableSequence
44
from typing import TypeVar, overload
55

@@ -16,6 +16,14 @@ if sys.version_info >= (3, 10):
1616
key: None = None,
1717
) -> int: ...
1818
@overload
19+
def bisect_left(
20+
a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int, hi: int, *, key: None = None
21+
) -> int: ...
22+
@overload
23+
def bisect_left(
24+
a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, *, hi: int, key: None = None
25+
) -> int: ...
26+
@overload
1927
def bisect_left(
2028
a: SupportsLenAndGetItem[_T],
2129
x: SupportsRichComparisonT,
@@ -25,6 +33,19 @@ if sys.version_info >= (3, 10):
2533
key: Callable[[_T], SupportsRichComparisonT],
2634
) -> int: ...
2735
@overload
36+
def bisect_left(
37+
a: SupportsGetItem[int, _T], x: SupportsRichComparisonT, lo: int, hi: int, *, key: Callable[[_T], SupportsRichComparisonT]
38+
) -> int: ...
39+
@overload
40+
def bisect_left(
41+
a: SupportsGetItem[int, _T],
42+
x: SupportsRichComparisonT,
43+
lo: int = 0,
44+
*,
45+
hi: int,
46+
key: Callable[[_T], SupportsRichComparisonT],
47+
) -> int: ...
48+
@overload
2849
def bisect_right(
2950
a: SupportsLenAndGetItem[SupportsRichComparisonT],
3051
x: SupportsRichComparisonT,
@@ -34,6 +55,14 @@ if sys.version_info >= (3, 10):
3455
key: None = None,
3556
) -> int: ...
3657
@overload
58+
def bisect_right(
59+
a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int, hi: int, *, key: None = None
60+
) -> int: ...
61+
@overload
62+
def bisect_right(
63+
a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, *, hi: int, key: None = None
64+
) -> int: ...
65+
@overload
3766
def bisect_right(
3867
a: SupportsLenAndGetItem[_T],
3968
x: SupportsRichComparisonT,
@@ -43,6 +72,19 @@ if sys.version_info >= (3, 10):
4372
key: Callable[[_T], SupportsRichComparisonT],
4473
) -> int: ...
4574
@overload
75+
def bisect_right(
76+
a: SupportsGetItem[int, _T], x: SupportsRichComparisonT, lo: int, hi: int, *, key: Callable[[_T], SupportsRichComparisonT]
77+
) -> int: ...
78+
@overload
79+
def bisect_right(
80+
a: SupportsGetItem[int, _T],
81+
x: SupportsRichComparisonT,
82+
lo: int = 0,
83+
*,
84+
hi: int,
85+
key: Callable[[_T], SupportsRichComparisonT],
86+
) -> int: ...
87+
@overload
4688
def insort_left(
4789
a: MutableSequence[SupportsRichComparisonT],
4890
x: SupportsRichComparisonT,
@@ -70,12 +112,26 @@ if sys.version_info >= (3, 10):
70112
) -> None: ...
71113

72114
else:
115+
@overload
73116
def bisect_left(
74117
a: SupportsLenAndGetItem[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None
75118
) -> int: ...
119+
@overload
120+
def bisect_left(a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int, hi: int) -> int: ...
121+
@overload
122+
def bisect_left(
123+
a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, *, hi: int
124+
) -> int: ...
125+
@overload
76126
def bisect_right(
77127
a: SupportsLenAndGetItem[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None
78128
) -> int: ...
129+
@overload
130+
def bisect_right(a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int, hi: int) -> int: ...
131+
@overload
132+
def bisect_right(
133+
a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, *, hi: int
134+
) -> int: ...
79135
def insort_left(
80136
a: MutableSequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None
81137
) -> None: ...

mypy/typeshed/stdlib/builtins.pyi

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,13 +1142,7 @@ class dict(MutableMapping[_KT, _VT]):
11421142
def __reversed__(self) -> Iterator[_KT]: ...
11431143
__hash__: ClassVar[None] # type: ignore[assignment]
11441144
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
1145-
@overload
1146-
def __or__(self, value: dict[_KT, _VT], /) -> dict[_KT, _VT]: ...
1147-
@overload
11481145
def __or__(self, value: dict[_T1, _T2], /) -> dict[_KT | _T1, _VT | _T2]: ...
1149-
@overload
1150-
def __ror__(self, value: dict[_KT, _VT], /) -> dict[_KT, _VT]: ...
1151-
@overload
11521146
def __ror__(self, value: dict[_T1, _T2], /) -> dict[_KT | _T1, _VT | _T2]: ...
11531147
# dict.__ior__ should be kept roughly in line with MutableMapping.update()
11541148
@overload # type: ignore[misc]
@@ -1164,16 +1158,16 @@ class set(MutableSet[_T]):
11641158
def __init__(self, iterable: Iterable[_T], /) -> None: ...
11651159
def add(self, element: _T, /) -> None: ...
11661160
def copy(self) -> set[_T]: ...
1167-
def difference(self, *s: Iterable[Any]) -> set[_T]: ...
1168-
def difference_update(self, *s: Iterable[Any]) -> None: ...
1169-
def discard(self, element: _T, /) -> None: ...
1170-
def intersection(self, *s: Iterable[Any]) -> set[_T]: ...
1171-
def intersection_update(self, *s: Iterable[Any]) -> None: ...
1172-
def isdisjoint(self, s: Iterable[Any], /) -> bool: ...
1173-
def issubset(self, s: Iterable[Any], /) -> bool: ...
1174-
def issuperset(self, s: Iterable[Any], /) -> bool: ...
1161+
def difference(self, *s: Iterable[object]) -> set[_T]: ...
1162+
def difference_update(self, *s: Iterable[object]) -> None: ...
1163+
def discard(self, element: object, /) -> None: ...
1164+
def intersection(self, *s: Iterable[object]) -> set[_T]: ...
1165+
def intersection_update(self, *s: Iterable[object]) -> None: ...
1166+
def isdisjoint(self, s: Iterable[object], /) -> bool: ...
1167+
def issubset(self, s: Iterable[object], /) -> bool: ...
1168+
def issuperset(self, s: Iterable[object], /) -> bool: ...
11751169
def remove(self, element: _T, /) -> None: ...
1176-
def symmetric_difference(self, s: Iterable[_T], /) -> set[_T]: ...
1170+
def symmetric_difference(self, s: Iterable[_S], /) -> set[_T | _S]: ...
11771171
def symmetric_difference_update(self, s: Iterable[_T], /) -> None: ...
11781172
def union(self, *s: Iterable[_S]) -> set[_T | _S]: ...
11791173
def update(self, *s: Iterable[_T]) -> None: ...
@@ -1205,15 +1199,15 @@ class frozenset(AbstractSet[_T_co]):
12051199
def copy(self) -> frozenset[_T_co]: ...
12061200
def difference(self, *s: Iterable[object]) -> frozenset[_T_co]: ...
12071201
def intersection(self, *s: Iterable[object]) -> frozenset[_T_co]: ...
1208-
def isdisjoint(self, s: Iterable[_T_co], /) -> bool: ...
1202+
def isdisjoint(self, s: Iterable[object], /) -> bool: ...
12091203
def issubset(self, s: Iterable[object], /) -> bool: ...
12101204
def issuperset(self, s: Iterable[object], /) -> bool: ...
1211-
def symmetric_difference(self, s: Iterable[_T_co], /) -> frozenset[_T_co]: ...
1205+
def symmetric_difference(self, s: Iterable[_S], /) -> frozenset[_T_co | _S]: ...
12121206
def union(self, *s: Iterable[_S]) -> frozenset[_T_co | _S]: ...
12131207
def __len__(self) -> int: ...
12141208
def __contains__(self, o: object, /) -> bool: ...
12151209
def __iter__(self) -> Iterator[_T_co]: ...
1216-
def __and__(self, value: AbstractSet[_T_co], /) -> frozenset[_T_co]: ...
1210+
def __and__(self, value: AbstractSet[object], /) -> frozenset[_T_co]: ...
12171211
def __or__(self, value: AbstractSet[_S], /) -> frozenset[_T_co | _S]: ...
12181212
def __sub__(self, value: AbstractSet[object], /) -> frozenset[_T_co]: ...
12191213
def __xor__(self, value: AbstractSet[_S], /) -> frozenset[_T_co | _S]: ...

mypy/typeshed/stdlib/contextlib.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ if sys.version_info >= (3, 10):
197197
class nullcontext(AbstractContextManager[_T, None], AbstractAsyncContextManager[_T, None]):
198198
enter_result: _T
199199
@overload
200-
def __init__(self: nullcontext[None], enter_result: None = None) -> None: ...
200+
def __init__(self: nullcontext[None]) -> None: ...
201201
@overload
202202
def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780
203203
def __enter__(self) -> _T: ...
@@ -209,7 +209,7 @@ else:
209209
class nullcontext(AbstractContextManager[_T, None]):
210210
enter_result: _T
211211
@overload
212-
def __init__(self: nullcontext[None], enter_result: None = None) -> None: ...
212+
def __init__(self: nullcontext[None]) -> None: ...
213213
@overload
214214
def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... # pyright: ignore[reportInvalidTypeVarUse] #11780
215215
def __enter__(self) -> _T: ...

mypy/typeshed/stdlib/email/_header_value_parser.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ SPECIALSNL: Final[set[str]]
2626
def make_quoted_pairs(value: Any) -> str: ...
2727
def quote_string(value: Any) -> str: ...
2828

29-
if sys.version_info >= (3, 13):
30-
# Added in Python 3.13.12, 3.14.3
29+
if sys.version_info >= (3, 10):
30+
# Added in Python 3.10.20, 3.11.15, 3.12.13, 3.13.12, 3.14.3
3131
def make_parenthesis_pairs(value: Any) -> str: ...
3232

3333
rfc2047_matcher: Final[Pattern[str]]

mypy/typeshed/stdlib/encodings/__init__.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import sys
22
from codecs import CodecInfo
33

4+
from . import aliases as aliases
5+
46
class CodecRegistryError(LookupError, SystemError): ...
57

68
def normalize_encoding(encoding: str | bytes) -> str: ...

0 commit comments

Comments
 (0)