Skip to content

Commit 3110512

Browse files
committed
Sync typeshed
Source commit: python/typeshed@ec8b6ec
1 parent 95c40f9 commit 3110512

File tree

206 files changed

+3907
-3920
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

206 files changed

+3907
-3920
lines changed

mypy/typeshed/stdlib/VERSIONS

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,14 @@ _bz2: 3.3-
2828
_codecs: 3.0-
2929
_collections_abc: 3.3-
3030
_compat_pickle: 3.1-
31-
_compression: 3.5-
31+
_compression: 3.5-3.13
3232
_contextvars: 3.7-
3333
_csv: 3.0-
3434
_ctypes: 3.0-
3535
_curses: 3.0-
3636
_curses_panel: 3.0-
3737
_dbm: 3.0-
3838
_decimal: 3.3-
39-
_dummy_thread: 3.0-3.8
40-
_dummy_threading: 3.0-3.8
4139
_frozen_importlib: 3.0-
4240
_frozen_importlib_external: 3.5-
4341
_gdbm: 3.0-
@@ -80,6 +78,7 @@ _weakrefset: 3.0-
8078
_winapi: 3.3-
8179
abc: 3.0-
8280
aifc: 3.0-3.12
81+
annotationlib: 3.14-
8382
antigravity: 3.0-
8483
argparse: 3.0-
8584
array: 3.0-
@@ -88,6 +87,7 @@ asynchat: 3.0-3.11
8887
asyncio: 3.4-
8988
asyncio.exceptions: 3.8-
9089
asyncio.format_helpers: 3.7-
90+
asyncio.graph: 3.14-
9191
asyncio.mixins: 3.10-
9292
asyncio.runners: 3.7-
9393
asyncio.staggered: 3.8-
@@ -119,7 +119,9 @@ collections: 3.0-
119119
collections.abc: 3.3-
120120
colorsys: 3.0-
121121
compileall: 3.0-
122+
compression: 3.14-
122123
concurrent: 3.2-
124+
concurrent.futures.interpreter: 3.14-
123125
configparser: 3.0-
124126
contextlib: 3.0-
125127
contextvars: 3.7-
@@ -140,15 +142,13 @@ distutils: 3.0-3.11
140142
distutils.command.bdist_msi: 3.0-3.10
141143
distutils.command.bdist_wininst: 3.0-3.9
142144
doctest: 3.0-
143-
dummy_threading: 3.0-3.8
144145
email: 3.0-
145146
encodings: 3.0-
146147
encodings.cp1125: 3.4-
147148
encodings.cp273: 3.4-
148149
encodings.cp858: 3.2-
149150
encodings.koi8_t: 3.5-
150151
encodings.kz1048: 3.5-
151-
encodings.mac_centeuro: 3.0-3.8
152152
ensurepip: 3.0-
153153
enum: 3.4-
154154
errno: 3.0-
@@ -230,6 +230,7 @@ os: 3.0-
230230
ossaudiodev: 3.0-3.12
231231
parser: 3.0-3.9
232232
pathlib: 3.4-
233+
pathlib.types: 3.14-
233234
pdb: 3.0-
234235
pickle: 3.0-
235236
pickletools: 3.0-
@@ -282,6 +283,7 @@ ssl: 3.0-
282283
stat: 3.0-
283284
statistics: 3.4-
284285
string: 3.0-
286+
string.templatelib: 3.14-
285287
stringprep: 3.0-
286288
struct: 3.0-
287289
subprocess: 3.0-

mypy/typeshed/stdlib/__main__.pyi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
from typing import Any
2-
3-
def __getattr__(name: str) -> Any: ...
1+
def __getattr__(name: str): ... # incomplete module

mypy/typeshed/stdlib/_ast.pyi

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,20 @@ from ast import (
111111
from typing import Literal
112112

113113
if sys.version_info >= (3, 12):
114-
from ast import ParamSpec as ParamSpec, TypeVar as TypeVar, TypeVarTuple as TypeVarTuple, type_param as type_param
114+
from ast import (
115+
ParamSpec as ParamSpec,
116+
TypeAlias as TypeAlias,
117+
TypeVar as TypeVar,
118+
TypeVarTuple as TypeVarTuple,
119+
type_param as type_param,
120+
)
115121

116122
if sys.version_info >= (3, 11):
117123
from ast import TryStar as TryStar
118124

119125
if sys.version_info >= (3, 10):
120126
from ast import (
127+
Match as Match,
121128
MatchAs as MatchAs,
122129
MatchClass as MatchClass,
123130
MatchMapping as MatchMapping,
@@ -130,17 +137,6 @@ if sys.version_info >= (3, 10):
130137
pattern as pattern,
131138
)
132139

133-
if sys.version_info < (3, 9):
134-
from ast import (
135-
AugLoad as AugLoad,
136-
AugStore as AugStore,
137-
ExtSlice as ExtSlice,
138-
Index as Index,
139-
Param as Param,
140-
Suite as Suite,
141-
slice as slice,
142-
)
143-
144140
PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192]
145141
PyCF_ONLY_AST: Literal[1024]
146142
PyCF_TYPE_COMMENTS: Literal[4096]

mypy/typeshed/stdlib/_asyncio.pyi

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
import sys
22
from asyncio.events import AbstractEventLoop
3-
from collections.abc import Awaitable, Callable, Coroutine, Generator, Iterable
3+
from collections.abc import Awaitable, Callable, Coroutine, Generator
44
from contextvars import Context
5-
from types import FrameType
5+
from types import FrameType, GenericAlias
66
from typing import Any, Literal, TextIO, TypeVar
77
from typing_extensions import Self, TypeAlias
88

9-
if sys.version_info >= (3, 9):
10-
from types import GenericAlias
11-
129
_T = TypeVar("_T")
1310
_T_co = TypeVar("_T_co", covariant=True)
1411
_TaskYieldType: TypeAlias = Future[object] | None
1512

16-
class Future(Awaitable[_T], Iterable[_T]):
13+
class Future(Awaitable[_T]):
1714
_state: str
1815
@property
1916
def _exception(self) -> BaseException | None: ...
@@ -29,11 +26,7 @@ class Future(Awaitable[_T], Iterable[_T]):
2926
@property
3027
def _callbacks(self) -> list[tuple[Callable[[Self], Any], Context]]: ...
3128
def add_done_callback(self, fn: Callable[[Self], object], /, *, context: Context | None = None) -> None: ...
32-
if sys.version_info >= (3, 9):
33-
def cancel(self, msg: Any | None = None) -> bool: ...
34-
else:
35-
def cancel(self) -> bool: ...
36-
29+
def cancel(self, msg: Any | None = None) -> bool: ...
3730
def cancelled(self) -> bool: ...
3831
def done(self) -> bool: ...
3932
def result(self) -> _T: ...
@@ -45,15 +38,12 @@ class Future(Awaitable[_T], Iterable[_T]):
4538
def __await__(self) -> Generator[Any, None, _T]: ...
4639
@property
4740
def _loop(self) -> AbstractEventLoop: ...
48-
if sys.version_info >= (3, 9):
49-
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
41+
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
5042

5143
if sys.version_info >= (3, 12):
5244
_TaskCompatibleCoro: TypeAlias = Coroutine[Any, Any, _T_co]
53-
elif sys.version_info >= (3, 9):
54-
_TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Coroutine[Any, Any, _T_co]
5545
else:
56-
_TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Awaitable[_T_co]
46+
_TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Coroutine[Any, Any, _T_co]
5747

5848
# mypy and pyright complain that a subclass of an invariant class shouldn't be covariant.
5949
# While this is true in general, here it's sort-of okay to have a covariant subclass,
@@ -99,13 +89,8 @@ class Task(Future[_T_co]): # type: ignore[type-var] # pyright: ignore[reportIn
9989
if sys.version_info >= (3, 11):
10090
def cancelling(self) -> int: ...
10191
def uncancel(self) -> int: ...
102-
if sys.version_info < (3, 9):
103-
@classmethod
104-
def current_task(cls, loop: AbstractEventLoop | None = None) -> Task[Any] | None: ...
105-
@classmethod
106-
def all_tasks(cls, loop: AbstractEventLoop | None = None) -> set[Task[Any]]: ...
107-
if sys.version_info >= (3, 9):
108-
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
92+
93+
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
10994

11095
def get_event_loop() -> AbstractEventLoop: ...
11196
def get_running_loop() -> AbstractEventLoop: ...
@@ -118,3 +103,7 @@ def _leave_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ...
118103

119104
if sys.version_info >= (3, 12):
120105
def current_task(loop: AbstractEventLoop | None = None) -> Task[Any] | None: ...
106+
107+
if sys.version_info >= (3, 14):
108+
def future_discard_from_awaited_by(future: Future[Any], waiter: Future[Any], /) -> None: ...
109+
def future_add_to_awaited_by(future: Future[Any], waiter: Future[Any], /) -> None: ...

mypy/typeshed/stdlib/_blake2.pyi

Lines changed: 36 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
from _typeshed import ReadableBuffer
32
from typing import ClassVar, final
43
from typing_extensions import Self
@@ -21,44 +20,24 @@ class blake2b:
2120
block_size: int
2221
digest_size: int
2322
name: str
24-
if sys.version_info >= (3, 9):
25-
def __new__(
26-
cls,
27-
data: ReadableBuffer = b"",
28-
/,
29-
*,
30-
digest_size: int = 64,
31-
key: ReadableBuffer = b"",
32-
salt: ReadableBuffer = b"",
33-
person: ReadableBuffer = b"",
34-
fanout: int = 1,
35-
depth: int = 1,
36-
leaf_size: int = 0,
37-
node_offset: int = 0,
38-
node_depth: int = 0,
39-
inner_size: int = 0,
40-
last_node: bool = False,
41-
usedforsecurity: bool = True,
42-
) -> Self: ...
43-
else:
44-
def __new__(
45-
cls,
46-
data: ReadableBuffer = b"",
47-
/,
48-
*,
49-
digest_size: int = 64,
50-
key: ReadableBuffer = b"",
51-
salt: ReadableBuffer = b"",
52-
person: ReadableBuffer = b"",
53-
fanout: int = 1,
54-
depth: int = 1,
55-
leaf_size: int = 0,
56-
node_offset: int = 0,
57-
node_depth: int = 0,
58-
inner_size: int = 0,
59-
last_node: bool = False,
60-
) -> Self: ...
61-
23+
def __new__(
24+
cls,
25+
data: ReadableBuffer = b"",
26+
/,
27+
*,
28+
digest_size: int = 64,
29+
key: ReadableBuffer = b"",
30+
salt: ReadableBuffer = b"",
31+
person: ReadableBuffer = b"",
32+
fanout: int = 1,
33+
depth: int = 1,
34+
leaf_size: int = 0,
35+
node_offset: int = 0,
36+
node_depth: int = 0,
37+
inner_size: int = 0,
38+
last_node: bool = False,
39+
usedforsecurity: bool = True,
40+
) -> Self: ...
6241
def copy(self) -> Self: ...
6342
def digest(self) -> bytes: ...
6443
def hexdigest(self) -> str: ...
@@ -73,44 +52,24 @@ class blake2s:
7352
block_size: int
7453
digest_size: int
7554
name: str
76-
if sys.version_info >= (3, 9):
77-
def __new__(
78-
cls,
79-
data: ReadableBuffer = b"",
80-
/,
81-
*,
82-
digest_size: int = 32,
83-
key: ReadableBuffer = b"",
84-
salt: ReadableBuffer = b"",
85-
person: ReadableBuffer = b"",
86-
fanout: int = 1,
87-
depth: int = 1,
88-
leaf_size: int = 0,
89-
node_offset: int = 0,
90-
node_depth: int = 0,
91-
inner_size: int = 0,
92-
last_node: bool = False,
93-
usedforsecurity: bool = True,
94-
) -> Self: ...
95-
else:
96-
def __new__(
97-
cls,
98-
data: ReadableBuffer = b"",
99-
/,
100-
*,
101-
digest_size: int = 32,
102-
key: ReadableBuffer = b"",
103-
salt: ReadableBuffer = b"",
104-
person: ReadableBuffer = b"",
105-
fanout: int = 1,
106-
depth: int = 1,
107-
leaf_size: int = 0,
108-
node_offset: int = 0,
109-
node_depth: int = 0,
110-
inner_size: int = 0,
111-
last_node: bool = False,
112-
) -> Self: ...
113-
55+
def __new__(
56+
cls,
57+
data: ReadableBuffer = b"",
58+
/,
59+
*,
60+
digest_size: int = 32,
61+
key: ReadableBuffer = b"",
62+
salt: ReadableBuffer = b"",
63+
person: ReadableBuffer = b"",
64+
fanout: int = 1,
65+
depth: int = 1,
66+
leaf_size: int = 0,
67+
node_offset: int = 0,
68+
node_depth: int = 0,
69+
inner_size: int = 0,
70+
last_node: bool = False,
71+
usedforsecurity: bool = True,
72+
) -> Self: ...
11473
def copy(self) -> Self: ...
11574
def digest(self) -> bytes: ...
11675
def hexdigest(self) -> str: ...

mypy/typeshed/stdlib/_codecs.pyi

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -81,26 +81,12 @@ def escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> t
8181
def escape_encode(data: bytes, errors: str | None = None, /) -> tuple[bytes, int]: ...
8282
def latin_1_decode(data: ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
8383
def latin_1_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
84-
85-
if sys.version_info >= (3, 9):
86-
def raw_unicode_escape_decode(
87-
data: str | ReadableBuffer, errors: str | None = None, final: bool = True, /
88-
) -> tuple[str, int]: ...
89-
90-
else:
91-
def raw_unicode_escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
92-
84+
def raw_unicode_escape_decode(
85+
data: str | ReadableBuffer, errors: str | None = None, final: bool = True, /
86+
) -> tuple[str, int]: ...
9387
def raw_unicode_escape_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
9488
def readbuffer_encode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[bytes, int]: ...
95-
96-
if sys.version_info >= (3, 9):
97-
def unicode_escape_decode(
98-
data: str | ReadableBuffer, errors: str | None = None, final: bool = True, /
99-
) -> tuple[str, int]: ...
100-
101-
else:
102-
def unicode_escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
103-
89+
def unicode_escape_decode(data: str | ReadableBuffer, errors: str | None = None, final: bool = True, /) -> tuple[str, int]: ...
10490
def unicode_escape_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
10591
def utf_16_be_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
10692
def utf_16_be_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...

mypy/typeshed/stdlib/_collections_abc.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from abc import abstractmethod
33
from types import MappingProxyType
4-
from typing import ( # noqa: Y022,Y038
4+
from typing import ( # noqa: Y022,Y038,UP035
55
AbstractSet as Set,
66
AsyncGenerator as AsyncGenerator,
77
AsyncIterable as AsyncIterable,
@@ -61,7 +61,7 @@ __all__ = [
6161
"MutableSequence",
6262
]
6363
if sys.version_info < (3, 14):
64-
from typing import ByteString as ByteString # noqa: Y057
64+
from typing import ByteString as ByteString # noqa: Y057,UP035
6565

6666
__all__ += ["ByteString"]
6767

mypy/typeshed/stdlib/_compression.pyi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from _typeshed import WriteableBuffer
1+
# _compression is replaced by compression._common._streams on Python 3.14+ (PEP-784)
2+
3+
from _typeshed import Incomplete, WriteableBuffer
24
from collections.abc import Callable
35
from io import DEFAULT_BUFFER_SIZE, BufferedIOBase, RawIOBase
46
from typing import Any, Protocol
@@ -16,9 +18,9 @@ class DecompressReader(RawIOBase):
1618
def __init__(
1719
self,
1820
fp: _Reader,
19-
decomp_factory: Callable[..., object],
21+
decomp_factory: Callable[..., Incomplete],
2022
trailing_error: type[Exception] | tuple[type[Exception], ...] = (),
21-
**decomp_args: Any,
23+
**decomp_args: Any, # These are passed to decomp_factory.
2224
) -> None: ...
2325
def readinto(self, b: WriteableBuffer) -> int: ...
2426
def read(self, size: int = -1) -> bytes: ...

0 commit comments

Comments
 (0)