Skip to content

Commit 24481f1

Browse files
author
mypybot
committed
Sync typeshed
Source commit: python/typeshed@ecd5141
1 parent 5081c59 commit 24481f1

30 files changed

+624
-119
lines changed

mypy/typeshed/stdlib/VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ _warnings: 3.0-
7676
_weakref: 3.0-
7777
_weakrefset: 3.0-
7878
_winapi: 3.3-
79+
_zstd: 3.14-
7980
abc: 3.0-
8081
aifc: 3.0-3.12
8182
annotationlib: 3.14-

mypy/typeshed/stdlib/_asyncio.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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
55
from types import FrameType, GenericAlias
66
from typing import Any, Literal, TextIO, TypeVar
@@ -10,7 +10,7 @@ _T = TypeVar("_T")
1010
_T_co = TypeVar("_T_co", covariant=True)
1111
_TaskYieldType: TypeAlias = Future[object] | None
1212

13-
class Future(Awaitable[_T], Iterable[_T]):
13+
class Future(Awaitable[_T]):
1414
_state: str
1515
@property
1616
def _exception(self) -> BaseException | None: ...

mypy/typeshed/stdlib/_ctypes.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,11 @@ class Array(_CData, Generic[_CT], metaclass=_PyCArrayType):
291291
def _type_(self) -> type[_CT]: ...
292292
@_type_.setter
293293
def _type_(self, value: type[_CT]) -> None: ...
294-
raw: bytes # Note: only available if _CT == c_char
294+
# Note: only available if _CT == c_char
295+
@property
296+
def raw(self) -> bytes: ...
297+
@raw.setter
298+
def raw(self, value: ReadableBuffer) -> None: ...
295299
value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise
296300
# TODO: These methods cannot be annotated correctly at the moment.
297301
# All of these "Any"s stand for the array's element type, but it's not possible to use _CT

mypy/typeshed/stdlib/_hashlib.pyi

Lines changed: 57 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,63 @@ def compare_digest(a: ReadableBuffer, b: ReadableBuffer, /) -> bool: ...
6060
def compare_digest(a: AnyStr, b: AnyStr, /) -> bool: ...
6161
def get_fips_mode() -> int: ...
6262
def hmac_new(key: bytes | bytearray, msg: ReadableBuffer = b"", digestmod: _DigestMod = None) -> HMAC: ...
63-
def new(name: str, string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
64-
def openssl_md5(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
65-
def openssl_sha1(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
66-
def openssl_sha224(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
67-
def openssl_sha256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
68-
def openssl_sha384(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
69-
def openssl_sha512(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
70-
def openssl_sha3_224(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
71-
def openssl_sha3_256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
72-
def openssl_sha3_384(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
73-
def openssl_sha3_512(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
74-
def openssl_shake_128(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASHXOF: ...
75-
def openssl_shake_256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASHXOF: ...
63+
64+
if sys.version_info >= (3, 13):
65+
def new(
66+
name: str, data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
67+
) -> HASH: ...
68+
def openssl_md5(
69+
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
70+
) -> HASH: ...
71+
def openssl_sha1(
72+
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
73+
) -> HASH: ...
74+
def openssl_sha224(
75+
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
76+
) -> HASH: ...
77+
def openssl_sha256(
78+
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
79+
) -> HASH: ...
80+
def openssl_sha384(
81+
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
82+
) -> HASH: ...
83+
def openssl_sha512(
84+
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
85+
) -> HASH: ...
86+
def openssl_sha3_224(
87+
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
88+
) -> HASH: ...
89+
def openssl_sha3_256(
90+
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
91+
) -> HASH: ...
92+
def openssl_sha3_384(
93+
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
94+
) -> HASH: ...
95+
def openssl_sha3_512(
96+
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
97+
) -> HASH: ...
98+
def openssl_shake_128(
99+
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
100+
) -> HASHXOF: ...
101+
def openssl_shake_256(
102+
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
103+
) -> HASHXOF: ...
104+
105+
else:
106+
def new(name: str, string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
107+
def openssl_md5(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
108+
def openssl_sha1(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
109+
def openssl_sha224(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
110+
def openssl_sha256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
111+
def openssl_sha384(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
112+
def openssl_sha512(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
113+
def openssl_sha3_224(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
114+
def openssl_sha3_256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
115+
def openssl_sha3_384(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
116+
def openssl_sha3_512(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
117+
def openssl_shake_128(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASHXOF: ...
118+
def openssl_shake_256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASHXOF: ...
119+
76120
def hmac_digest(key: bytes | bytearray, msg: ReadableBuffer, digest: str) -> bytes: ...
77121
def pbkdf2_hmac(
78122
hash_name: str, password: ReadableBuffer, salt: ReadableBuffer, iterations: int, dklen: int | None = None

mypy/typeshed/stdlib/_socket.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ if sys.platform != "win32":
229229
IP_RECVOPTS: int
230230
IP_RECVRETOPTS: int
231231
IP_RETOPTS: int
232+
if sys.version_info >= (3, 13) and sys.platform == "linux":
233+
CAN_RAW_ERR_FILTER: int
232234
if sys.version_info >= (3, 14):
233235
IP_RECVTTL: int
234236

@@ -246,7 +248,6 @@ if sys.version_info >= (3, 14):
246248
TCP_QUICKACK: int
247249

248250
if sys.platform == "linux":
249-
CAN_RAW_ERR_FILTER: int
250251
IP_FREEBIND: int
251252
IP_RECVORIGDSTADDR: int
252253
VMADDR_CID_LOCAL: int

mypy/typeshed/stdlib/_zstd.pyi

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
from _typeshed import ReadableBuffer
2+
from collections.abc import Mapping
3+
from compression.zstd import CompressionParameter, DecompressionParameter
4+
from typing import Final, Literal, final
5+
from typing_extensions import Self, TypeAlias
6+
7+
ZSTD_CLEVEL_DEFAULT: Final = 3
8+
ZSTD_DStreamOutSize: Final = 131072
9+
ZSTD_btlazy2: Final = 6
10+
ZSTD_btopt: Final = 7
11+
ZSTD_btultra: Final = 8
12+
ZSTD_btultra2: Final = 9
13+
ZSTD_c_chainLog: Final = 103
14+
ZSTD_c_checksumFlag: Final = 201
15+
ZSTD_c_compressionLevel: Final = 100
16+
ZSTD_c_contentSizeFlag: Final = 200
17+
ZSTD_c_dictIDFlag: Final = 202
18+
ZSTD_c_enableLongDistanceMatching: Final = 160
19+
ZSTD_c_hashLog: Final = 102
20+
ZSTD_c_jobSize: Final = 401
21+
ZSTD_c_ldmBucketSizeLog: Final = 163
22+
ZSTD_c_ldmHashLog: Final = 161
23+
ZSTD_c_ldmHashRateLog: Final = 164
24+
ZSTD_c_ldmMinMatch: Final = 162
25+
ZSTD_c_minMatch: Final = 105
26+
ZSTD_c_nbWorkers: Final = 400
27+
ZSTD_c_overlapLog: Final = 402
28+
ZSTD_c_searchLog: Final = 104
29+
ZSTD_c_strategy: Final = 107
30+
ZSTD_c_targetLength: Final = 106
31+
ZSTD_c_windowLog: Final = 101
32+
ZSTD_d_windowLogMax: Final = 100
33+
ZSTD_dfast: Final = 2
34+
ZSTD_fast: Final = 1
35+
ZSTD_greedy: Final = 3
36+
ZSTD_lazy: Final = 4
37+
ZSTD_lazy2: Final = 5
38+
39+
_ZstdCompressorContinue: TypeAlias = Literal[0]
40+
_ZstdCompressorFlushBlock: TypeAlias = Literal[1]
41+
_ZstdCompressorFlushFrame: TypeAlias = Literal[2]
42+
43+
@final
44+
class ZstdCompressor:
45+
CONTINUE: Final = 0
46+
FLUSH_BLOCK: Final = 1
47+
FLUSH_FRAME: Final = 2
48+
def __init__(
49+
self, level: int | None = None, options: Mapping[int, int] | None = None, zstd_dict: ZstdDict | None = None
50+
) -> None: ...
51+
def compress(
52+
self, /, data: ReadableBuffer, mode: _ZstdCompressorContinue | _ZstdCompressorFlushBlock | _ZstdCompressorFlushFrame = 0
53+
) -> bytes: ...
54+
def flush(self, /, mode: _ZstdCompressorFlushBlock | _ZstdCompressorFlushFrame = 2) -> bytes: ...
55+
@property
56+
def last_mode(self) -> _ZstdCompressorContinue | _ZstdCompressorFlushBlock | _ZstdCompressorFlushFrame: ...
57+
58+
@final
59+
class ZstdDecompressor:
60+
def __init__(self, zstd_dict: ZstdDict | None = None, options: Mapping[int, int] | None = None) -> None: ...
61+
def decompress(self, /, data: ReadableBuffer, max_length: int = -1) -> bytes: ...
62+
@property
63+
def eof(self) -> bool: ...
64+
@property
65+
def needs_input(self) -> bool: ...
66+
@property
67+
def unused_data(self) -> bytes: ...
68+
69+
@final
70+
class ZstdDict:
71+
def __init__(self, dict_content: bytes, /, *, is_raw: bool = False) -> None: ...
72+
def __len__(self, /) -> int: ...
73+
@property
74+
def as_digested_dict(self) -> tuple[Self, int]: ...
75+
@property
76+
def as_prefix(self) -> tuple[Self, int]: ...
77+
@property
78+
def as_undigested_dict(self) -> tuple[Self, int]: ...
79+
@property
80+
def dict_content(self) -> bytes: ...
81+
@property
82+
def dict_id(self) -> int: ...
83+
84+
class ZstdError(Exception): ...
85+
86+
def finalize_dict(
87+
custom_dict_bytes: bytes, samples_bytes: bytes, samples_sizes: tuple[int, ...], dict_size: int, compression_level: int, /
88+
) -> bytes: ...
89+
def get_frame_info(frame_buffer: ReadableBuffer) -> tuple[int, int]: ...
90+
def get_frame_size(frame_buffer: ReadableBuffer) -> int: ...
91+
def get_param_bounds(parameter: int, is_compress: bool) -> tuple[int, int]: ...
92+
def set_parameter_types(c_parameter_type: type[CompressionParameter], d_parameter_type: type[DecompressionParameter]) -> None: ...
93+
def train_dict(samples_bytes: bytes, samples_sizes: tuple[int, ...], dict_size: int, /) -> bytes: ...
94+
95+
zstd_version: Final[str]
96+
zstd_version_number: Final[int]

mypy/typeshed/stdlib/argparse.pyi

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import sys
22
from _typeshed import SupportsWrite, sentinel
33
from collections.abc import Callable, Generator, Iterable, Sequence
44
from re import Pattern
5-
from typing import IO, Any, ClassVar, Final, Generic, NewType, NoReturn, Protocol, TypeVar, overload
5+
from typing import IO, Any, ClassVar, Final, Generic, NoReturn, Protocol, TypeVar, overload
66
from typing_extensions import Self, TypeAlias, deprecated
77

88
__all__ = [
@@ -36,9 +36,7 @@ ONE_OR_MORE: Final = "+"
3636
OPTIONAL: Final = "?"
3737
PARSER: Final = "A..."
3838
REMAINDER: Final = "..."
39-
_SUPPRESS_T = NewType("_SUPPRESS_T", str)
40-
SUPPRESS: _SUPPRESS_T | str # not using Literal because argparse sometimes compares SUPPRESS with is
41-
# the | str is there so that foo = argparse.SUPPRESS; foo = "test" checks out in mypy
39+
SUPPRESS: Final = "==SUPPRESS=="
4240
ZERO_OR_MORE: Final = "*"
4341
_UNRECOGNIZED_ARGS_ATTR: Final = "_unrecognized_args" # undocumented
4442

@@ -81,7 +79,7 @@ class _ActionsContainer:
8179
# more precisely, Literal["?", "*", "+", "...", "A...", "==SUPPRESS=="],
8280
# but using this would make it hard to annotate callers that don't use a
8381
# literal argument and for subclasses to override this method.
84-
nargs: int | str | _SUPPRESS_T | None = None,
82+
nargs: int | str | None = None,
8583
const: Any = ...,
8684
default: Any = ...,
8785
type: _ActionType = ...,

mypy/typeshed/stdlib/asyncio/tasks.pyi

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,25 @@ if sys.version_info >= (3, 12):
423423
else:
424424
def current_task(loop: AbstractEventLoop | None = None) -> Task[Any] | None: ...
425425

426+
if sys.version_info >= (3, 14):
427+
def eager_task_factory(
428+
loop: AbstractEventLoop | None,
429+
coro: _TaskCompatibleCoro[_T_co],
430+
*,
431+
name: str | None = None,
432+
context: Context | None = None,
433+
eager_start: bool = True,
434+
) -> Task[_T_co]: ...
435+
436+
elif sys.version_info >= (3, 12):
437+
def eager_task_factory(
438+
loop: AbstractEventLoop | None,
439+
coro: _TaskCompatibleCoro[_T_co],
440+
*,
441+
name: str | None = None,
442+
context: Context | None = None,
443+
) -> Task[_T_co]: ...
444+
426445
if sys.version_info >= (3, 12):
427446
_TaskT_co = TypeVar("_TaskT_co", bound=Task[Any], covariant=True)
428447

@@ -451,10 +470,3 @@ if sys.version_info >= (3, 12):
451470
def create_eager_task_factory(
452471
custom_task_constructor: _CustomTaskConstructor[_TaskT_co],
453472
) -> _EagerTaskFactoryType[_TaskT_co]: ...
454-
def eager_task_factory(
455-
loop: AbstractEventLoop | None,
456-
coro: _TaskCompatibleCoro[_T_co],
457-
*,
458-
name: str | None = None,
459-
context: Context | None = None,
460-
) -> Task[_T_co]: ...

0 commit comments

Comments
 (0)