Skip to content

Commit f5e076a

Browse files
committed
Sync typeshed
Source commit: python/typeshed@61ba4de
1 parent 2d785df commit f5e076a

28 files changed

+414
-149
lines changed

mypy/typeshed/stdlib/VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ __main__: 3.0-
2222
_ast: 3.0-
2323
_asyncio: 3.0-
2424
_bisect: 3.0-
25+
_blake2: 3.6-
2526
_bootlocale: 3.4-3.9
2627
_codecs: 3.0-
2728
_collections_abc: 3.3-

mypy/typeshed/stdlib/_blake2.pyi

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
import sys
2+
from _typeshed import ReadableBuffer
3+
from typing import ClassVar, final
4+
from typing_extensions import Self
5+
6+
BLAKE2B_MAX_DIGEST_SIZE: int = 64
7+
BLAKE2B_MAX_KEY_SIZE: int = 64
8+
BLAKE2B_PERSON_SIZE: int = 16
9+
BLAKE2B_SALT_SIZE: int = 16
10+
BLAKE2S_MAX_DIGEST_SIZE: int = 32
11+
BLAKE2S_MAX_KEY_SIZE: int = 32
12+
BLAKE2S_PERSON_SIZE: int = 8
13+
BLAKE2S_SALT_SIZE: int = 8
14+
15+
@final
16+
class blake2b:
17+
MAX_DIGEST_SIZE: ClassVar[int] = 64
18+
MAX_KEY_SIZE: ClassVar[int] = 64
19+
PERSON_SIZE: ClassVar[int] = 16
20+
SALT_SIZE: ClassVar[int] = 16
21+
block_size: int
22+
digest_size: int
23+
name: str
24+
if sys.version_info >= (3, 9):
25+
def __init__(
26+
self,
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+
) -> None: ...
43+
else:
44+
def __init__(
45+
self,
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+
) -> None: ...
61+
62+
def copy(self) -> Self: ...
63+
def digest(self) -> bytes: ...
64+
def hexdigest(self) -> str: ...
65+
def update(self, data: ReadableBuffer, /) -> None: ...
66+
67+
@final
68+
class blake2s:
69+
MAX_DIGEST_SIZE: ClassVar[int] = 32
70+
MAX_KEY_SIZE: ClassVar[int] = 32
71+
PERSON_SIZE: ClassVar[int] = 8
72+
SALT_SIZE: ClassVar[int] = 8
73+
block_size: int
74+
digest_size: int
75+
name: str
76+
if sys.version_info >= (3, 9):
77+
def __init__(
78+
self,
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+
) -> None: ...
95+
else:
96+
def __init__(
97+
self,
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+
) -> None: ...
113+
114+
def copy(self) -> Self: ...
115+
def digest(self) -> bytes: ...
116+
def hexdigest(self) -> str: ...
117+
def update(self, data: ReadableBuffer, /) -> None: ...

mypy/typeshed/stdlib/_ctypes.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ class Array(_CData, Generic[_CT]):
171171
def _type_(self) -> type[_CT]: ...
172172
@_type_.setter
173173
def _type_(self, value: type[_CT]) -> None: ...
174-
raw: bytes # Note: only available if _CT == c_char
174+
# Note: only available if _CT == c_char
175+
@property
176+
def raw(self) -> bytes: ...
177+
@raw.setter
178+
def raw(self, value: ReadableBuffer) -> None: ...
175179
value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise
176180
# TODO These methods cannot be annotated correctly at the moment.
177181
# All of these "Any"s stand for the array's element type, but it's not possible to use _CT

mypy/typeshed/stdlib/_interpreters.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ _Configs: TypeAlias = Literal["default", "isolated", "legacy", "empty", ""]
77

88
class InterpreterError(Exception): ...
99
class InterpreterNotFoundError(InterpreterError): ...
10-
class NotShareableError(Exception): ...
10+
class NotShareableError(ValueError): ...
1111

1212
class CrossInterpreterBufferView:
1313
def __buffer__(self, flags: int, /) -> memoryview: ...

mypy/typeshed/stdlib/_io.pyi

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,24 @@ class BytesIO(BufferedIOBase, _BufferedIOBase, BinaryIO): # type: ignore[misc]
8686

8787
class BufferedReader(BufferedIOBase, _BufferedIOBase, BinaryIO): # type: ignore[misc] # incompatible definitions of methods in the base classes
8888
raw: RawIOBase
89-
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
89+
def __init__(self, raw: RawIOBase, buffer_size: int = 8192) -> None: ...
9090
def peek(self, size: int = 0, /) -> bytes: ...
9191

9292
class BufferedWriter(BufferedIOBase, _BufferedIOBase, BinaryIO): # type: ignore[misc] # incompatible definitions of writelines in the base classes
9393
raw: RawIOBase
94-
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
94+
def __init__(self, raw: RawIOBase, buffer_size: int = 8192) -> None: ...
9595
def write(self, buffer: ReadableBuffer, /) -> int: ...
9696

97-
class BufferedRandom(BufferedReader, BufferedWriter, BufferedIOBase, _BufferedIOBase): # type: ignore[misc] # incompatible definitions of methods in the base classes
97+
class BufferedRandom(BufferedIOBase, _BufferedIOBase, BinaryIO): # type: ignore[misc] # incompatible definitions of methods in the base classes
98+
mode: str
99+
name: Any
100+
raw: RawIOBase
101+
def __init__(self, raw: RawIOBase, buffer_size: int = 8192) -> None: ...
98102
def seek(self, target: int, whence: int = 0, /) -> int: ... # stubtest needs this
103+
def peek(self, size: int = 0, /) -> bytes: ...
99104

100105
class BufferedRWPair(BufferedIOBase, _BufferedIOBase):
101-
def __init__(self, reader: RawIOBase, writer: RawIOBase, buffer_size: int = ...) -> None: ...
106+
def __init__(self, reader: RawIOBase, writer: RawIOBase, buffer_size: int = 8192) -> None: ...
102107
def peek(self, size: int = ..., /) -> bytes: ...
103108

104109
class _TextIOBase(_IOBase):
@@ -173,19 +178,23 @@ class TextIOWrapper(TextIOBase, _TextIOBase, TextIO, Generic[_BufferT_co]): # t
173178
# operations.
174179
def seek(self, cookie: int, whence: int = 0, /) -> int: ...
175180

176-
class StringIO(TextIOWrapper, TextIOBase, _TextIOBase): # type: ignore[misc] # incompatible definitions of write in the base classes
181+
class StringIO(TextIOBase, _TextIOBase, TextIO): # type: ignore[misc] # incompatible definitions of write in the base classes
177182
def __init__(self, initial_value: str | None = ..., newline: str | None = ...) -> None: ...
178183
# StringIO does not contain a "name" field. This workaround is necessary
179184
# to allow StringIO sub-classes to add this field, as it is defined
180185
# as a read-only property on IO[].
181186
name: Any
182187
def getvalue(self) -> str: ...
188+
@property
189+
def line_buffering(self) -> bool: ...
183190

184-
class IncrementalNewlineDecoder(codecs.IncrementalDecoder):
191+
class IncrementalNewlineDecoder:
185192
def __init__(self, decoder: codecs.IncrementalDecoder | None, translate: bool, errors: str = ...) -> None: ...
186193
def decode(self, input: ReadableBuffer | str, final: bool = False) -> str: ...
187194
@property
188195
def newlines(self) -> str | tuple[str, ...] | None: ...
196+
def getstate(self) -> tuple[bytes, int]: ...
197+
def reset(self) -> None: ...
189198
def setstate(self, state: tuple[bytes, int], /) -> None: ...
190199

191200
if sys.version_info >= (3, 10):

mypy/typeshed/stdlib/ast.pyi

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,11 +2023,18 @@ class NodeVisitor:
20232023
def visit_AugLoad(self, node: AugLoad) -> Any: ...
20242024
def visit_AugStore(self, node: AugStore) -> Any: ...
20252025
def visit_Param(self, node: Param) -> Any: ...
2026-
def visit_Num(self, node: Num) -> Any: ...
2027-
def visit_Str(self, node: Str) -> Any: ...
2028-
def visit_Bytes(self, node: Bytes) -> Any: ...
2029-
def visit_NameConstant(self, node: NameConstant) -> Any: ...
2030-
def visit_Ellipsis(self, node: Ellipsis) -> Any: ...
2026+
2027+
if sys.version_info < (3, 14):
2028+
@deprecated("Replaced by visit_Constant; removed in Python 3.14")
2029+
def visit_Num(self, node: Num) -> Any: ... # type: ignore[deprecated]
2030+
@deprecated("Replaced by visit_Constant; removed in Python 3.14")
2031+
def visit_Str(self, node: Str) -> Any: ... # type: ignore[deprecated]
2032+
@deprecated("Replaced by visit_Constant; removed in Python 3.14")
2033+
def visit_Bytes(self, node: Bytes) -> Any: ... # type: ignore[deprecated]
2034+
@deprecated("Replaced by visit_Constant; removed in Python 3.14")
2035+
def visit_NameConstant(self, node: NameConstant) -> Any: ... # type: ignore[deprecated]
2036+
@deprecated("Replaced by visit_Constant; removed in Python 3.14")
2037+
def visit_Ellipsis(self, node: Ellipsis) -> Any: ... # type: ignore[deprecated]
20312038

20322039
class NodeTransformer(NodeVisitor):
20332040
def generic_visit(self, node: AST) -> AST: ...

mypy/typeshed/stdlib/asyncio/tasks.pyi

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ from _asyncio import (
77
_register_task as _register_task,
88
_unregister_task as _unregister_task,
99
)
10-
from collections.abc import Awaitable, Coroutine, Generator, Iterable, Iterator
10+
from collections.abc import AsyncIterator, Awaitable, Coroutine, Generator, Iterable, Iterator
1111
from typing import Any, Literal, Protocol, TypeVar, overload
1212
from typing_extensions import TypeAlias
1313

@@ -84,7 +84,12 @@ FIRST_COMPLETED = concurrent.futures.FIRST_COMPLETED
8484
FIRST_EXCEPTION = concurrent.futures.FIRST_EXCEPTION
8585
ALL_COMPLETED = concurrent.futures.ALL_COMPLETED
8686

87-
if sys.version_info >= (3, 10):
87+
if sys.version_info >= (3, 13):
88+
class _SyncAndAsyncIterator(Iterator[_T_co], AsyncIterator[_T_co], Protocol[_T_co]): ...
89+
90+
def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> _SyncAndAsyncIterator[Future[_T]]: ...
91+
92+
elif sys.version_info >= (3, 10):
8893
def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> Iterator[Future[_T]]: ...
8994

9095
else:

0 commit comments

Comments
 (0)