Skip to content

Commit da8819c

Browse files
committed
Sync typeshed
Source commit: python/typeshed@a92da58
1 parent cba07d7 commit da8819c

Some content is hidden

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

81 files changed

+1043
-751
lines changed

mypy/typeshed/stdlib/_compression.pyi

-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ class DecompressReader(RawIOBase):
2020
trailing_error: type[Exception] | tuple[type[Exception], ...] = ...,
2121
**decomp_args: Any,
2222
) -> None: ...
23-
def readable(self) -> bool: ...
24-
def close(self) -> None: ...
25-
def seekable(self) -> bool: ...
2623
def readinto(self, b: WriteableBuffer) -> int: ...
2724
def read(self, size: int = ...) -> bytes: ...
2825
def seek(self, offset: int, whence: int = ...) -> int: ...
29-
def tell(self) -> int: ...

mypy/typeshed/stdlib/_decimal.pyi

+5-4
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ class Decimal:
7474
def from_float(cls: type[Self], __f: float) -> Self: ...
7575
def __bool__(self) -> bool: ...
7676
def compare(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
77-
def __hash__(self) -> int: ...
7877
def as_tuple(self) -> DecimalTuple: ...
7978
def as_integer_ratio(self) -> tuple[int, int]: ...
8079
def to_eng_string(self, context: Context | None = ...) -> str: ...
@@ -179,6 +178,11 @@ class _ContextManager:
179178
_TrapType: TypeAlias = type[DecimalException]
180179

181180
class Context:
181+
# TODO: Context doesn't allow you to delete *any* attributes from instances of the class at runtime,
182+
# even settable attributes like `prec` and `rounding`,
183+
# but that's inexpressable in the stub.
184+
# Type checkers either ignore it or misinterpret it
185+
# if you add a `def __delattr__(self, __name: str) -> NoReturn` method to the stub
182186
prec: int
183187
rounding: str
184188
Emin: int
@@ -199,9 +203,6 @@ class Context:
199203
traps: None | dict[_TrapType, bool] | Container[_TrapType] = ...,
200204
_ignored_flags: list[_TrapType] | None = ...,
201205
) -> None: ...
202-
# __setattr__() only allows to set a specific set of attributes,
203-
# already defined above.
204-
def __delattr__(self, __name: str) -> None: ...
205206
def __reduce__(self: Self) -> tuple[type[Self], tuple[Any, ...]]: ...
206207
def clear_flags(self) -> None: ...
207208
def clear_traps(self) -> None: ...

mypy/typeshed/stdlib/_dummy_thread.pyi

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ def stack_size(size: int | None = ...) -> int: ...
1515

1616
class LockType:
1717
locked_status: bool
18-
def __init__(self) -> None: ...
1918
def acquire(self, waitflag: bool | None = ..., timeout: int = ...) -> bool: ...
2019
def __enter__(self, waitflag: bool | None = ..., timeout: int = ...) -> bool: ...
2120
def __exit__(self, typ: type[BaseException] | None, val: BaseException | None, tb: TracebackType | None) -> None: ...

mypy/typeshed/stdlib/_markupbase.pyi

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import sys
22
from typing import Any
33

44
class ParserBase:
5-
def __init__(self) -> None: ...
65
def reset(self) -> None: ...
76
def getpos(self) -> tuple[int, int]: ...
87
def unknown_decl(self, data: str) -> None: ...

mypy/typeshed/stdlib/_threading_local.pyi

-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ _LocalDict: TypeAlias = dict[Any, Any]
88
class _localimpl:
99
key: str
1010
dicts: dict[int, tuple[ReferenceType[Any], _LocalDict]]
11-
def __init__(self) -> None: ...
1211
def get_dict(self) -> _LocalDict: ...
1312
def create_dict(self) -> _LocalDict: ...
1413

1514
class local:
1615
def __getattribute__(self, name: str) -> Any: ...
1716
def __setattr__(self, name: str, value: Any) -> None: ...
18-
def __delattr__(self, name: str) -> None: ...

mypy/typeshed/stdlib/_weakref.pyi

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class ReferenceType(Generic[_T]):
2323
__callback__: Callable[[ReferenceType[_T]], Any]
2424
def __new__(cls: type[Self], o: _T, callback: Callable[[ReferenceType[_T]], Any] | None = ...) -> Self: ...
2525
def __call__(self) -> _T | None: ...
26-
def __hash__(self) -> int: ...
2726
if sys.version_info >= (3, 9):
2827
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
2928

mypy/typeshed/stdlib/_weakrefset.pyi

-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ class WeakSet(MutableSet[_T], Generic[_T]):
1717
@overload
1818
def __init__(self, data: Iterable[_T]) -> None: ...
1919
def add(self, item: _T) -> None: ...
20-
def clear(self) -> None: ...
2120
def discard(self, item: _T) -> None: ...
2221
def copy(self: Self) -> Self: ...
23-
def pop(self) -> _T: ...
2422
def remove(self, item: _T) -> None: ...
2523
def update(self, other: Iterable[_T]) -> None: ...
2624
def __contains__(self, item: object) -> bool: ...

mypy/typeshed/stdlib/array.pyi

-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class array(MutableSequence[_T], Generic[_T]):
4747
def insert(self, __i: int, __v: _T) -> None: ...
4848
def pop(self, __i: int = ...) -> _T: ...
4949
def remove(self, __v: _T) -> None: ...
50-
def reverse(self) -> None: ...
5150
def tobytes(self) -> bytes: ...
5251
def tofile(self, __f: SupportsWrite[bytes]) -> None: ...
5352
def tolist(self) -> list[_T]: ...
@@ -56,7 +55,6 @@ class array(MutableSequence[_T], Generic[_T]):
5655
def fromstring(self, __buffer: bytes) -> None: ...
5756
def tostring(self) -> bytes: ...
5857

59-
def __contains__(self, __key: object) -> bool: ...
6058
def __len__(self) -> int: ...
6159
@overload
6260
def __getitem__(self, __i: SupportsIndex) -> _T: ...

mypy/typeshed/stdlib/ast.pyi

+9-5
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,25 @@ from typing import Any, TypeVar, overload
55
from typing_extensions import Literal
66

77
if sys.version_info >= (3, 8):
8-
class Num(Constant):
8+
class _ABC(type):
9+
if sys.version_info >= (3, 9):
10+
def __init__(cls, *args: object) -> None: ...
11+
12+
class Num(Constant, metaclass=_ABC):
913
value: complex
1014

11-
class Str(Constant):
15+
class Str(Constant, metaclass=_ABC):
1216
value: str
1317
# Aliases for value, for backwards compatibility
1418
s: str
1519

16-
class Bytes(Constant):
20+
class Bytes(Constant, metaclass=_ABC):
1721
value: bytes
1822
# Aliases for value, for backwards compatibility
1923
s: bytes
2024

21-
class NameConstant(Constant): ...
22-
class Ellipsis(Constant): ...
25+
class NameConstant(Constant, metaclass=_ABC): ...
26+
class Ellipsis(Constant, metaclass=_ABC): ...
2327

2428
if sys.version_info >= (3, 9):
2529
class slice(AST): ...

mypy/typeshed/stdlib/asynchat.pyi

-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import asyncore
2-
import socket
32
from abc import abstractmethod
43

54
class simple_producer:
@@ -9,20 +8,14 @@ class simple_producer:
98
class async_chat(asyncore.dispatcher):
109
ac_in_buffer_size: int
1110
ac_out_buffer_size: int
12-
def __init__(self, sock: socket.socket | None = ..., map: asyncore._MapType | None = ...) -> None: ...
1311
@abstractmethod
1412
def collect_incoming_data(self, data: bytes) -> None: ...
1513
@abstractmethod
1614
def found_terminator(self) -> None: ...
1715
def set_terminator(self, term: bytes | int | None) -> None: ...
1816
def get_terminator(self) -> bytes | int | None: ...
19-
def handle_read(self) -> None: ...
20-
def handle_write(self) -> None: ...
21-
def handle_close(self) -> None: ...
2217
def push(self, data: bytes) -> None: ...
2318
def push_with_producer(self, producer: simple_producer) -> None: ...
24-
def readable(self) -> bool: ...
25-
def writable(self) -> bool: ...
2619
def close_when_done(self) -> None: ...
2720
def initiate_send(self) -> None: ...
2821
def discard_buffers(self) -> None: ...

mypy/typeshed/stdlib/asyncio/base_subprocess.pyi

+1-13
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,10 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
4444
bufsize: int,
4545
**kwargs: Any,
4646
) -> None: ... # undocumented
47-
def set_protocol(self, protocol: protocols.BaseProtocol) -> None: ...
48-
def get_protocol(self) -> protocols.BaseProtocol: ...
49-
def is_closing(self) -> bool: ...
50-
def close(self) -> None: ...
5147
def get_pid(self) -> int | None: ... # type: ignore[override]
52-
def get_returncode(self) -> int | None: ...
5348
def get_pipe_transport(self, fd: int) -> _File: ... # type: ignore[override]
5449
def _check_proc(self) -> None: ... # undocumented
5550
def send_signal(self, signal: int) -> None: ... # type: ignore[override]
56-
def terminate(self) -> None: ...
57-
def kill(self) -> None: ...
5851
async def _connect_pipes(self, waiter: futures.Future[Any] | None) -> None: ... # undocumented
5952
def _call(self, cb: Callable[..., object], *data: Any) -> None: ... # undocumented
6053
def _pipe_connection_lost(self, fd: int, exc: BaseException | None) -> None: ... # undocumented
@@ -66,10 +59,5 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
6659

6760
class WriteSubprocessPipeProto(protocols.BaseProtocol): # undocumented
6861
def __init__(self, proc: BaseSubprocessTransport, fd: int) -> None: ...
69-
def connection_made(self, transport: transports.BaseTransport) -> None: ...
70-
def connection_lost(self, exc: BaseException | None) -> None: ...
71-
def pause_writing(self) -> None: ...
72-
def resume_writing(self) -> None: ...
7362

74-
class ReadSubprocessPipeProto(WriteSubprocessPipeProto, protocols.Protocol): # undocumented
75-
def data_received(self, data: bytes) -> None: ...
63+
class ReadSubprocessPipeProto(WriteSubprocessPipeProto, protocols.Protocol): ... # undocumented

mypy/typeshed/stdlib/asyncio/events.pyi

-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ class TimerHandle(Handle):
8585
loop: AbstractEventLoop,
8686
context: Context | None = ...,
8787
) -> None: ...
88-
def __hash__(self) -> int: ...
8988
def when(self) -> float: ...
9089
def __lt__(self, other: TimerHandle) -> bool: ...
9190
def __le__(self, other: TimerHandle) -> bool: ...
@@ -612,7 +611,6 @@ class AbstractEventLoopPolicy:
612611
def set_child_watcher(self, watcher: AbstractChildWatcher) -> None: ...
613612

614613
class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy, metaclass=ABCMeta):
615-
def __init__(self) -> None: ...
616614
def get_event_loop(self) -> AbstractEventLoop: ...
617615
def set_event_loop(self, loop: AbstractEventLoop | None) -> None: ...
618616
def new_event_loop(self) -> AbstractEventLoop: ...

mypy/typeshed/stdlib/asyncio/locks.pyi

+1-5
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,7 @@ class Semaphore(_ContextManagerMixin):
9292
def release(self) -> None: ...
9393
def _wake_up_next(self) -> None: ...
9494

95-
class BoundedSemaphore(Semaphore):
96-
if sys.version_info >= (3, 11):
97-
def __init__(self, value: int = ...) -> None: ...
98-
else:
99-
def __init__(self, value: int = ..., *, loop: AbstractEventLoop | None = ...) -> None: ...
95+
class BoundedSemaphore(Semaphore): ...
10096

10197
if sys.version_info >= (3, 11):
10298
class _BarrierState(enum.Enum): # undocumented

mypy/typeshed/stdlib/asyncio/proactor_events.pyi

+4-27
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from collections.abc import Mapping
33
from socket import socket
4-
from typing import Any, Protocol
4+
from typing import Any, ClassVar, Protocol
55
from typing_extensions import Literal
66

77
from . import base_events, constants, events, futures, streams, transports
@@ -29,8 +29,6 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTr
2929
else:
3030
def __del__(self) -> None: ...
3131

32-
def get_write_buffer_size(self) -> int: ...
33-
3432
class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTransport):
3533
if sys.version_info >= (3, 10):
3634
def __init__(
@@ -54,33 +52,13 @@ class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTran
5452
server: events.AbstractServer | None = ...,
5553
) -> None: ...
5654

57-
class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.WriteTransport):
58-
def __init__(
59-
self,
60-
loop: events.AbstractEventLoop,
61-
sock: socket,
62-
protocol: streams.StreamReaderProtocol,
63-
waiter: futures.Future[Any] | None = ...,
64-
extra: Mapping[Any, Any] | None = ...,
65-
server: events.AbstractServer | None = ...,
66-
) -> None: ...
67-
68-
class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport):
69-
def __init__(
70-
self,
71-
loop: events.AbstractEventLoop,
72-
sock: socket,
73-
protocol: streams.StreamReaderProtocol,
74-
waiter: futures.Future[Any] | None = ...,
75-
extra: Mapping[Any, Any] | None = ...,
76-
server: events.AbstractServer | None = ...,
77-
) -> None: ...
78-
55+
class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.WriteTransport): ...
56+
class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport): ...
7957
class _ProactorDuplexPipeTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport): ...
8058

8159
class _ProactorSocketTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport):
8260

83-
_sendfile_compatible: constants._SendfileMode
61+
_sendfile_compatible: ClassVar[constants._SendfileMode]
8462
def __init__(
8563
self,
8664
loop: events.AbstractEventLoop,
@@ -92,7 +70,6 @@ class _ProactorSocketTransport(_ProactorReadPipeTransport, _ProactorBaseWritePip
9270
) -> None: ...
9371
def _set_extra(self, sock: socket) -> None: ...
9472
def can_write_eof(self) -> Literal[True]: ...
95-
def write_eof(self) -> None: ...
9673

9774
class BaseProactorEventLoop(base_events.BaseEventLoop):
9875
def __init__(self, proactor: Any) -> None: ...

mypy/typeshed/stdlib/asyncio/sslproto.pyi

-15
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,10 @@ class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport):
7272
_closed: bool
7373
def __init__(self, loop: events.AbstractEventLoop, ssl_protocol: SSLProtocol) -> None: ...
7474
def get_extra_info(self, name: str, default: Any | None = ...) -> dict[str, Any]: ...
75-
def set_protocol(self, protocol: protocols.BaseProtocol) -> None: ...
76-
def get_protocol(self) -> protocols.BaseProtocol: ...
77-
def is_closing(self) -> bool: ...
78-
def close(self) -> None: ...
79-
def is_reading(self) -> bool: ...
80-
def pause_reading(self) -> None: ...
81-
def resume_reading(self) -> None: ...
82-
def set_write_buffer_limits(self, high: int | None = ..., low: int | None = ...) -> None: ...
83-
def get_write_buffer_size(self) -> int: ...
8475
@property
8576
def _protocol_paused(self) -> bool: ...
8677
def write(self, data: bytes) -> None: ...
8778
def can_write_eof(self) -> Literal[False]: ...
88-
def abort(self) -> None: ...
8979
if sys.version_info >= (3, 11):
9080
def get_write_buffer_limits(self) -> tuple[int, int]: ...
9181
def get_read_buffer_limits(self) -> tuple[int, int]: ...
@@ -149,10 +139,7 @@ class SSLProtocol(_SSLProtocolBase):
149139

150140
def _set_app_protocol(self, app_protocol: protocols.BaseProtocol) -> None: ...
151141
def _wakeup_waiter(self, exc: BaseException | None = ...) -> None: ...
152-
def connection_made(self, transport: transports.BaseTransport) -> None: ...
153142
def connection_lost(self, exc: BaseException | None) -> None: ...
154-
def pause_writing(self) -> None: ...
155-
def resume_writing(self) -> None: ...
156143
def eof_received(self) -> None: ...
157144
def _get_extra_info(self, name: str, default: Any | None = ...) -> Any: ...
158145
def _start_shutdown(self) -> None: ...
@@ -167,9 +154,7 @@ class SSLProtocol(_SSLProtocolBase):
167154
def _fatal_error(self, exc: BaseException, message: str = ...) -> None: ...
168155
def _abort(self) -> None: ...
169156
if sys.version_info >= (3, 11):
170-
def buffer_updated(self, nbytes: int) -> None: ...
171157
def get_buffer(self, n: int) -> memoryview: ...
172158
else:
173159
def _finalize(self) -> None: ...
174160
def _process_write_backlog(self) -> None: ...
175-
def data_received(self, data: bytes) -> None: ...

mypy/typeshed/stdlib/asyncio/streams.pyi

-4
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,6 @@ class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
128128
client_connected_cb: _ClientConnectedCallback | None = ...,
129129
loop: events.AbstractEventLoop | None = ...,
130130
) -> None: ...
131-
def connection_made(self, transport: transports.BaseTransport) -> None: ...
132-
def connection_lost(self, exc: Exception | None) -> None: ...
133-
def data_received(self, data: bytes) -> None: ...
134-
def eof_received(self) -> bool: ...
135131

136132
class StreamWriter:
137133
def __init__(

mypy/typeshed/stdlib/asyncio/subprocess.pyi

-3
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ class SubprocessStreamProtocol(streams.FlowControlMixin, protocols.SubprocessPro
2222
stdout: streams.StreamReader | None
2323
stderr: streams.StreamReader | None
2424
def __init__(self, limit: int, loop: events.AbstractEventLoop) -> None: ...
25-
def connection_made(self, transport: transports.BaseTransport) -> None: ...
2625
def pipe_data_received(self, fd: int, data: bytes | str) -> None: ...
27-
def pipe_connection_lost(self, fd: int, exc: Exception | None) -> None: ...
28-
def process_exited(self) -> None: ...
2926

3027
class Process:
3128
stdin: streams.StreamWriter | None

mypy/typeshed/stdlib/asyncio/tasks.pyi

-4
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,6 @@ class Task(Future[_T], Generic[_T]):
285285

286286
def get_stack(self, *, limit: int | None = ...) -> list[FrameType]: ...
287287
def print_stack(self, *, limit: int | None = ..., file: TextIO | None = ...) -> None: ...
288-
if sys.version_info >= (3, 9):
289-
def cancel(self, msg: Any | None = ...) -> bool: ...
290-
else:
291-
def cancel(self) -> bool: ...
292288
if sys.version_info >= (3, 11):
293289
def cancelling(self) -> int: ...
294290
def uncancel(self) -> int: ...

mypy/typeshed/stdlib/asyncio/transports.pyi

-3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,3 @@ class SubprocessTransport(BaseTransport):
4545

4646
class _FlowControlMixin(Transport):
4747
def __init__(self, extra: Mapping[Any, Any] | None = ..., loop: AbstractEventLoop | None = ...) -> None: ...
48-
def set_write_buffer_limits(self, high: int | None = ..., low: int | None = ...) -> None: ...
49-
def get_write_buffer_size(self) -> int: ...
50-
def get_write_buffer_limits(self) -> tuple[int, int]: ...

mypy/typeshed/stdlib/asyncio/unix_events.pyi

-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ if sys.platform != "win32":
5757
# Doesn't actually have ABCMeta metaclass at runtime, but mypy complains if we don't have it in the stub.
5858
# See discussion in #7412
5959
class BaseChildWatcher(AbstractChildWatcher, metaclass=ABCMeta):
60-
def __init__(self) -> None: ...
6160
def close(self) -> None: ...
6261
if sys.version_info >= (3, 8):
6362
def is_active(self) -> bool: ...
@@ -95,7 +94,6 @@ if sys.platform != "win32":
9594
) -> object: ...
9695

9796
class MultiLoopChildWatcher(AbstractChildWatcher):
98-
def __init__(self) -> None: ...
9997
def is_active(self) -> bool: ...
10098
def close(self) -> None: ...
10199
def __enter__(self: Self) -> Self: ...
@@ -107,7 +105,6 @@ if sys.platform != "win32":
107105
def attach_loop(self, loop: AbstractEventLoop | None) -> None: ...
108106

109107
class ThreadedChildWatcher(AbstractChildWatcher):
110-
def __init__(self) -> None: ...
111108
def is_active(self) -> Literal[True]: ...
112109
def close(self) -> None: ...
113110
def __enter__(self: Self) -> Self: ...

mypy/typeshed/stdlib/asyncore.pyi

-2
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ class dispatcher:
6363
def handle_close(self) -> None: ...
6464

6565
class dispatcher_with_send(dispatcher):
66-
def __init__(self, sock: socket | None = ..., map: _MapType | None = ...) -> None: ...
6766
def initiate_send(self) -> None: ...
68-
def handle_write(self) -> None: ...
6967
# incompatible signature:
7068
# def send(self, data: bytes) -> int | None: ...
7169

0 commit comments

Comments
 (0)