Skip to content

Commit 4291b2c

Browse files
github-actions[bot]hauntsaninjaAlexWaygood
authored
Sync typeshed (#16382)
Source commit: python/typeshed@3c872ca Co-authored-by: mypybot <> Co-authored-by: Shantanu <[email protected]> Co-authored-by: AlexWaygood <[email protected]>
1 parent 0ff7a29 commit 4291b2c

29 files changed

+476
-144
lines changed

mypy/typeshed/stdlib/VERSIONS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,12 @@ imp: 2.7-3.11
152152
importlib: 2.7-
153153
importlib.metadata: 3.8-
154154
importlib.metadata._meta: 3.10-
155+
importlib.readers: 3.10-
155156
importlib.resources: 3.7-
156157
importlib.resources.abc: 3.11-
158+
importlib.resources.readers: 3.11-
159+
importlib.resources.simple: 3.11-
160+
importlib.simple: 3.11-
157161
inspect: 2.7-
158162
io: 2.7-
159163
ipaddress: 3.3-
@@ -181,6 +185,7 @@ multiprocessing.shared_memory: 3.8-
181185
netrc: 2.7-
182186
nis: 2.7-
183187
nntplib: 2.7-
188+
nt: 2.7-
184189
ntpath: 2.7-
185190
nturl2path: 2.7-
186191
numbers: 2.7-
@@ -250,6 +255,7 @@ sunau: 2.7-
250255
symbol: 2.7-3.9
251256
symtable: 2.7-
252257
sys: 2.7-
258+
sys._monitoring: 3.12- # Doesn't actually exist. See comments in the stub.
253259
sysconfig: 2.7-
254260
syslog: 2.7-
255261
tabnanny: 2.7-

mypy/typeshed/stdlib/_collections_abc.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class dict_values(ValuesView[_VT_co], Generic[_KT_co, _VT_co]): # undocumented
8181
def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ...
8282

8383
@final
84-
class dict_items(ItemsView[_KT_co, _VT_co], Generic[_KT_co, _VT_co]): # undocumented
84+
class dict_items(ItemsView[_KT_co, _VT_co]): # undocumented
8585
def __eq__(self, __value: object) -> bool: ...
8686
if sys.version_info >= (3, 10):
8787
@property

mypy/typeshed/stdlib/_typeshed/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Unused: TypeAlias = object
4747
# _SentinelType = NewType("_SentinelType", object)
4848
# sentinel: _SentinelType
4949
# def foo(x: int | None | _SentinelType = ...) -> None: ...
50-
sentinel = Any # noqa: Y026
50+
sentinel: Any
5151

5252
# stable
5353
class IdentityFunction(Protocol):

mypy/typeshed/stdlib/_weakrefset.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
from collections.abc import Iterable, Iterator, MutableSet
3-
from typing import Any, Generic, TypeVar, overload
3+
from typing import Any, TypeVar, overload
44
from typing_extensions import Self
55

66
if sys.version_info >= (3, 9):
@@ -11,7 +11,7 @@ __all__ = ["WeakSet"]
1111
_S = TypeVar("_S")
1212
_T = TypeVar("_T")
1313

14-
class WeakSet(MutableSet[_T], Generic[_T]):
14+
class WeakSet(MutableSet[_T]):
1515
@overload
1616
def __init__(self, data: None = None) -> None: ...
1717
@overload

mypy/typeshed/stdlib/_winapi.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ if sys.platform == "win32":
5454
HIGH_PRIORITY_CLASS: Literal[0x80]
5555
INFINITE: Literal[0xFFFFFFFF]
5656
if sys.version_info >= (3, 8):
57-
# Ignore the flake8 error -- flake8-pyi assumes
57+
# Ignore the Flake8 error -- flake8-pyi assumes
5858
# most numbers this long will be implementation details,
5959
# but here we can see that it's a power of 2
6060
INVALID_HANDLE_VALUE: Literal[0xFFFFFFFFFFFFFFFF] # noqa: Y054

mypy/typeshed/stdlib/array.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite
33
from collections.abc import Iterable
44

55
# pytype crashes if array inherits from collections.abc.MutableSequence instead of typing.MutableSequence
6-
from typing import Any, Generic, MutableSequence, TypeVar, overload # noqa: Y022
6+
from typing import Any, MutableSequence, TypeVar, overload # noqa: Y022
77
from typing_extensions import Literal, Self, SupportsIndex, TypeAlias
88

99
if sys.version_info >= (3, 12):
@@ -18,7 +18,7 @@ _T = TypeVar("_T", int, float, str)
1818

1919
typecodes: str
2020

21-
class array(MutableSequence[_T], Generic[_T]):
21+
class array(MutableSequence[_T]):
2222
@property
2323
def typecode(self) -> _TypeCode: ...
2424
@property

mypy/typeshed/stdlib/asyncio/tasks.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import concurrent.futures
22
import sys
33
from collections.abc import Awaitable, Coroutine, Generator, Iterable, Iterator
44
from types import FrameType
5-
from typing import Any, Generic, Protocol, TextIO, TypeVar, overload
5+
from typing import Any, Protocol, TextIO, TypeVar, overload
66
from typing_extensions import Literal, TypeAlias
77

88
from . import _CoroutineLike
@@ -379,7 +379,7 @@ else:
379379
# While this is true in general, here it's sort-of okay to have a covariant subclass,
380380
# since the only reason why `asyncio.Future` is invariant is the `set_result()` method,
381381
# and `asyncio.Task.set_result()` always raises.
382-
class Task(Future[_T_co], Generic[_T_co]): # type: ignore[type-var] # pyright: ignore[reportGeneralTypeIssues]
382+
class Task(Future[_T_co]): # type: ignore[type-var] # pyright: ignore[reportGeneralTypeIssues]
383383
if sys.version_info >= (3, 12):
384384
def __init__(
385385
self,

mypy/typeshed/stdlib/builtins.pyi

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ class int:
287287
def __pow__(self, __value: _PositiveInteger, __mod: None = None) -> int: ...
288288
@overload
289289
def __pow__(self, __value: _NegativeInteger, __mod: None = None) -> float: ...
290-
# positive x -> int; negative x -> float
290+
# positive __value -> int; negative __value -> float
291291
# return type must be Any as `int | float` causes too many false-positive errors
292292
@overload
293293
def __pow__(self, __value: int, __mod: None = None) -> Any: ...
@@ -346,7 +346,7 @@ class float:
346346
def __divmod__(self, __value: float) -> tuple[float, float]: ...
347347
@overload
348348
def __pow__(self, __value: int, __mod: None = None) -> float: ...
349-
# positive x -> float; negative x -> complex
349+
# positive __value -> float; negative __value -> complex
350350
# return type must be Any as `float | complex` causes too many false-positive errors
351351
@overload
352352
def __pow__(self, __value: float, __mod: None = None) -> Any: ...
@@ -860,7 +860,7 @@ class slice:
860860
__hash__: ClassVar[None] # type: ignore[assignment]
861861
def indices(self, __len: SupportsIndex) -> tuple[int, int, int]: ...
862862

863-
class tuple(Sequence[_T_co], Generic[_T_co]):
863+
class tuple(Sequence[_T_co]):
864864
def __new__(cls, __iterable: Iterable[_T_co] = ...) -> Self: ...
865865
def __len__(self) -> int: ...
866866
def __contains__(self, __key: object) -> bool: ...
@@ -912,7 +912,7 @@ class function:
912912
# mypy uses `builtins.function.__get__` to represent methods, properties, and getset_descriptors so we type the return as Any.
913913
def __get__(self, __instance: object, __owner: type | None = None) -> Any: ...
914914

915-
class list(MutableSequence[_T], Generic[_T]):
915+
class list(MutableSequence[_T]):
916916
@overload
917917
def __init__(self) -> None: ...
918918
@overload
@@ -967,7 +967,7 @@ class list(MutableSequence[_T], Generic[_T]):
967967
if sys.version_info >= (3, 9):
968968
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
969969

970-
class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
970+
class dict(MutableMapping[_KT, _VT]):
971971
# __init__ should be kept roughly in line with `collections.UserDict.__init__`, which has similar semantics
972972
# Also multiprocessing.managers.SyncManager.dict()
973973
@overload
@@ -1040,7 +1040,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
10401040
@overload
10411041
def __ior__(self, __value: Iterable[tuple[_KT, _VT]]) -> Self: ...
10421042

1043-
class set(MutableSet[_T], Generic[_T]):
1043+
class set(MutableSet[_T]):
10441044
@overload
10451045
def __init__(self) -> None: ...
10461046
@overload
@@ -1080,7 +1080,7 @@ class set(MutableSet[_T], Generic[_T]):
10801080
if sys.version_info >= (3, 9):
10811081
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
10821082

1083-
class frozenset(AbstractSet[_T_co], Generic[_T_co]):
1083+
class frozenset(AbstractSet[_T_co]):
10841084
@overload
10851085
def __new__(cls) -> Self: ...
10861086
@overload
@@ -1109,7 +1109,7 @@ class frozenset(AbstractSet[_T_co], Generic[_T_co]):
11091109
if sys.version_info >= (3, 9):
11101110
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
11111111

1112-
class enumerate(Iterator[tuple[int, _T]], Generic[_T]):
1112+
class enumerate(Iterator[tuple[int, _T]]):
11131113
def __new__(cls, iterable: Iterable[_T], start: int = ...) -> Self: ...
11141114
def __iter__(self) -> Self: ...
11151115
def __next__(self) -> tuple[int, _T]: ...
@@ -1318,7 +1318,7 @@ else:
13181318

13191319
def exit(code: sys._ExitCode = None) -> NoReturn: ...
13201320

1321-
class filter(Iterator[_T], Generic[_T]):
1321+
class filter(Iterator[_T]):
13221322
@overload
13231323
def __new__(cls, __function: None, __iterable: Iterable[_T | None]) -> Self: ...
13241324
@overload
@@ -1377,7 +1377,7 @@ def len(__obj: Sized) -> int: ...
13771377
def license() -> None: ...
13781378
def locals() -> dict[str, Any]: ...
13791379

1380-
class map(Iterator[_S], Generic[_S]):
1380+
class map(Iterator[_S]):
13811381
@overload
13821382
def __new__(cls, __func: Callable[[_T1], _S], __iter1: Iterable[_T1]) -> Self: ...
13831383
@overload
@@ -1649,7 +1649,7 @@ else:
16491649

16501650
def quit(code: sys._ExitCode = None) -> NoReturn: ...
16511651

1652-
class reversed(Iterator[_T], Generic[_T]):
1652+
class reversed(Iterator[_T]):
16531653
@overload
16541654
def __init__(self, __sequence: Reversible[_T]) -> None: ...
16551655
@overload
@@ -1723,7 +1723,7 @@ def vars(__object: type) -> types.MappingProxyType[str, Any]: ... # type: ignor
17231723
@overload
17241724
def vars(__object: Any = ...) -> dict[str, Any]: ...
17251725

1726-
class zip(Iterator[_T_co], Generic[_T_co]):
1726+
class zip(Iterator[_T_co]):
17271727
if sys.version_info >= (3, 10):
17281728
@overload
17291729
def __new__(cls, *, strict: bool = ...) -> zip[Any]: ...

mypy/typeshed/stdlib/collections/__init__.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def namedtuple(
4545
defaults: Iterable[Any] | None = None,
4646
) -> type[tuple[Any, ...]]: ...
4747

48-
class UserDict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
48+
class UserDict(MutableMapping[_KT, _VT]):
4949
data: dict[_KT, _VT]
5050
# __init__ should be kept roughly in line with `dict.__init__`, which has the same semantics
5151
@overload
@@ -228,7 +228,7 @@ class UserString(Sequence[UserString]):
228228
def upper(self) -> Self: ...
229229
def zfill(self, width: int) -> Self: ...
230230

231-
class deque(MutableSequence[_T], Generic[_T]):
231+
class deque(MutableSequence[_T]):
232232
@property
233233
def maxlen(self) -> int | None: ...
234234
@overload
@@ -383,7 +383,7 @@ class OrderedDict(dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
383383
@overload
384384
def __ror__(self, __value: dict[_T1, _T2]) -> OrderedDict[_KT | _T1, _VT | _T2]: ... # type: ignore[misc]
385385

386-
class defaultdict(dict[_KT, _VT], Generic[_KT, _VT]):
386+
class defaultdict(dict[_KT, _VT]):
387387
default_factory: Callable[[], _VT] | None
388388
@overload
389389
def __init__(self) -> None: ...
@@ -424,7 +424,7 @@ class defaultdict(dict[_KT, _VT], Generic[_KT, _VT]):
424424
@overload
425425
def __ror__(self, __value: dict[_T1, _T2]) -> defaultdict[_KT | _T1, _VT | _T2]: ... # type: ignore[misc]
426426

427-
class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
427+
class ChainMap(MutableMapping[_KT, _VT]):
428428
maps: list[MutableMapping[_KT, _VT]]
429429
def __init__(self, *maps: MutableMapping[_KT, _VT]) -> None: ...
430430
def new_child(self, m: MutableMapping[_KT, _VT] | None = None) -> Self: ...

mypy/typeshed/stdlib/contextlib.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ if sys.version_info >= (3, 10):
9494
) -> bool | None: ...
9595

9696
else:
97-
class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co], Generic[_T_co]):
97+
class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co]):
9898
def __init__(self, func: Callable[..., AsyncIterator[_T_co]], args: tuple[Any, ...], kwds: dict[str, Any]) -> None: ...
9999
gen: AsyncGenerator[_T_co, Any]
100100
func: Callable[..., AsyncGenerator[_T_co, Any]]

mypy/typeshed/stdlib/csv.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ from _csv import (
2323
)
2424

2525
if sys.version_info >= (3, 12):
26-
from _csv import QUOTE_STRINGS as QUOTE_STRINGS, QUOTE_NOTNULL as QUOTE_NOTNULL
26+
from _csv import QUOTE_NOTNULL as QUOTE_NOTNULL, QUOTE_STRINGS as QUOTE_STRINGS
2727
from _typeshed import SupportsWrite
2828
from collections.abc import Collection, Iterable, Iterator, Mapping, Sequence
2929
from typing import Any, Generic, TypeVar, overload

mypy/typeshed/stdlib/fileinput.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import sys
22
from _typeshed import AnyStr_co, StrOrBytesPath
33
from collections.abc import Callable, Iterable, Iterator
44
from types import TracebackType
5-
from typing import IO, Any, AnyStr, Generic, Protocol, overload
5+
from typing import IO, Any, AnyStr, Protocol, overload
66
from typing_extensions import Literal, Self, TypeAlias
77

88
if sys.version_info >= (3, 9):
@@ -158,7 +158,7 @@ def fileno() -> int: ...
158158
def isfirstline() -> bool: ...
159159
def isstdin() -> bool: ...
160160

161-
class FileInput(Iterator[AnyStr], Generic[AnyStr]):
161+
class FileInput(Iterator[AnyStr]):
162162
if sys.version_info >= (3, 10):
163163
# encoding and errors are added
164164
@overload

mypy/typeshed/stdlib/hashlib.pyi

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,7 @@ shake_128 = _VarLenHash
113113
shake_256 = _VarLenHash
114114

115115
def scrypt(
116-
password: ReadableBuffer,
117-
*,
118-
salt: ReadableBuffer | None = None,
119-
n: int | None = None,
120-
r: int | None = None,
121-
p: int | None = None,
122-
maxmem: int = 0,
123-
dklen: int = 64,
116+
password: ReadableBuffer, *, salt: ReadableBuffer, n: int, r: int, p: int, maxmem: int = 0, dklen: int = 64
124117
) -> bytes: ...
125118
@final
126119
class _BlakeHash(_Hash):

0 commit comments

Comments
 (0)