Skip to content

Commit c0fce06

Browse files
AlexWaygoodJelleZijlstra
authored andcommitted
Sync typeshed
Source commit: python/typeshed@5f12eeb
1 parent 95e7fcb commit c0fce06

Some content is hidden

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

52 files changed

+436
-169
lines changed

mypy/typeshed/stdlib/_codecs.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ _StrToStrEncoding: TypeAlias = Literal["rot13", "rot_13"]
4747
@overload
4848
def encode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = "strict") -> bytes: ...
4949
@overload
50-
def encode(obj: str, encoding: _StrToStrEncoding, errors: str = "strict") -> str: ... # type: ignore[misc]
50+
def encode(obj: str, encoding: _StrToStrEncoding, errors: str = "strict") -> str: ... # type: ignore[overload-overlap]
5151
@overload
5252
def encode(obj: str, encoding: str = "utf-8", errors: str = "strict") -> bytes: ...
5353
@overload
54-
def decode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = "strict") -> bytes: ... # type: ignore[misc]
54+
def decode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = "strict") -> bytes: ... # type: ignore[overload-overlap]
5555
@overload
5656
def decode(obj: str, encoding: _StrToStrEncoding, errors: str = "strict") -> str: ...
5757

mypy/typeshed/stdlib/_ctypes.pyi

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

mypy/typeshed/stdlib/argparse.pyi

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
172172
) -> None: ...
173173

174174
@overload
175-
def parse_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ... # type: ignore[misc]
175+
def parse_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ...
176176
@overload
177177
def parse_args(self, args: Sequence[str] | None, namespace: _N) -> _N: ...
178178
@overload
@@ -211,7 +211,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
211211
def format_usage(self) -> str: ...
212212
def format_help(self) -> str: ...
213213
@overload
214-
def parse_known_args(self, args: Sequence[str] | None = None, namespace: None = None) -> tuple[Namespace, list[str]]: ... # type: ignore[misc]
214+
def parse_known_args(self, args: Sequence[str] | None = None, namespace: None = None) -> tuple[Namespace, list[str]]: ...
215215
@overload
216216
def parse_known_args(self, args: Sequence[str] | None, namespace: _N) -> tuple[_N, list[str]]: ...
217217
@overload
@@ -220,13 +220,15 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
220220
def exit(self, status: int = 0, message: str | None = None) -> NoReturn: ...
221221
def error(self, message: str) -> NoReturn: ...
222222
@overload
223-
def parse_intermixed_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ... # type: ignore[misc]
223+
def parse_intermixed_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ...
224224
@overload
225225
def parse_intermixed_args(self, args: Sequence[str] | None, namespace: _N) -> _N: ...
226226
@overload
227227
def parse_intermixed_args(self, *, namespace: _N) -> _N: ...
228228
@overload
229-
def parse_known_intermixed_args(self, args: Sequence[str] | None = None, namespace: None = None) -> tuple[Namespace, list[str]]: ... # type: ignore[misc]
229+
def parse_known_intermixed_args(
230+
self, args: Sequence[str] | None = None, namespace: None = None
231+
) -> tuple[Namespace, list[str]]: ...
230232
@overload
231233
def parse_known_intermixed_args(self, args: Sequence[str] | None, namespace: _N) -> tuple[_N, list[str]]: ...
232234
@overload

mypy/typeshed/stdlib/asyncio/base_events.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,3 +471,5 @@ class BaseEventLoop(AbstractEventLoop):
471471
async def shutdown_default_executor(self, timeout: float | None = None) -> None: ...
472472
elif sys.version_info >= (3, 9):
473473
async def shutdown_default_executor(self) -> None: ...
474+
475+
def __del__(self) -> None: ...

mypy/typeshed/stdlib/asyncio/base_subprocess.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
5555
async def _wait(self) -> int: ... # undocumented
5656
def _try_finish(self) -> None: ... # undocumented
5757
def _call_connection_lost(self, exc: BaseException | None) -> None: ... # undocumented
58+
def __del__(self) -> None: ...
5859

5960
class WriteSubprocessPipeProto(protocols.BaseProtocol): # undocumented
6061
def __init__(self, proc: BaseSubprocessTransport, fd: int) -> None: ...

mypy/typeshed/stdlib/asyncio/events.pyi

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ from collections.abc import Callable, Coroutine, Generator, Sequence
66
from contextvars import Context
77
from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket
88
from typing import IO, Any, Protocol, TypeVar, overload
9-
from typing_extensions import Literal, Self, TypeAlias
9+
from typing_extensions import Literal, Self, TypeAlias, deprecated
1010

1111
from . import _AwaitableLike, _CoroutineLike
1212
from .base_events import Server
@@ -613,8 +613,17 @@ def set_event_loop_policy(policy: AbstractEventLoopPolicy | None) -> None: ...
613613
def get_event_loop() -> AbstractEventLoop: ...
614614
def set_event_loop(loop: AbstractEventLoop | None) -> None: ...
615615
def new_event_loop() -> AbstractEventLoop: ...
616-
def get_child_watcher() -> AbstractChildWatcher: ...
617-
def set_child_watcher(watcher: AbstractChildWatcher) -> None: ...
616+
617+
if sys.version_info >= (3, 12):
618+
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
619+
def get_child_watcher() -> AbstractChildWatcher: ...
620+
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
621+
def set_child_watcher(watcher: AbstractChildWatcher) -> None: ...
622+
623+
else:
624+
def get_child_watcher() -> AbstractChildWatcher: ...
625+
def set_child_watcher(watcher: AbstractChildWatcher) -> None: ...
626+
618627
def _set_running_loop(__loop: AbstractEventLoop | None) -> None: ...
619628
def _get_running_loop() -> AbstractEventLoop: ...
620629
def get_running_loop() -> AbstractEventLoop: ...

mypy/typeshed/stdlib/asyncio/sslproto.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport):
8383
def set_read_buffer_limits(self, high: int | None = None, low: int | None = None) -> None: ...
8484
def get_read_buffer_size(self) -> int: ...
8585

86+
def __del__(self) -> None: ...
87+
8688
if sys.version_info >= (3, 11):
8789
_SSLProtocolBase: TypeAlias = protocols.BufferedProtocol
8890
else:

mypy/typeshed/stdlib/asyncio/streams.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
128128
client_connected_cb: _ClientConnectedCallback | None = None,
129129
loop: events.AbstractEventLoop | None = None,
130130
) -> None: ...
131+
def __del__(self) -> None: ...
131132

132133
class StreamWriter:
133134
def __init__(
@@ -161,6 +162,8 @@ class StreamWriter:
161162
async def start_tls(
162163
self, sslcontext: ssl.SSLContext, *, server_hostname: str | None = None, ssl_handshake_timeout: float | None = None
163164
) -> None: ...
165+
if sys.version_info >= (3, 11):
166+
def __del__(self) -> None: ...
164167

165168
class StreamReader(AsyncIterator[bytes]):
166169
def __init__(self, limit: int = 65536, loop: events.AbstractEventLoop | None = None) -> None: ...

mypy/typeshed/stdlib/asyncio/subprocess.pyi

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ if sys.version_info >= (3, 11):
8080
stdout: int | IO[Any] | None = None,
8181
stderr: int | IO[Any] | None = None,
8282
limit: int = 65536,
83-
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
83+
# These parameters are forced to these values by BaseEventLoop.subprocess_exec
8484
universal_newlines: Literal[False] = False,
85-
shell: Literal[True] = True,
85+
shell: Literal[False] = False,
8686
bufsize: Literal[0] = 0,
8787
encoding: None = None,
8888
errors: None = None,
89+
text: Literal[False] | None = None,
8990
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
90-
text: bool | None = None,
9191
executable: StrOrBytesPath | None = None,
9292
preexec_fn: Callable[[], Any] | None = None,
9393
close_fds: bool = True,
@@ -145,14 +145,14 @@ elif sys.version_info >= (3, 10):
145145
stdout: int | IO[Any] | None = None,
146146
stderr: int | IO[Any] | None = None,
147147
limit: int = 65536,
148-
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
148+
# These parameters are forced to these values by BaseEventLoop.subprocess_exec
149149
universal_newlines: Literal[False] = False,
150-
shell: Literal[True] = True,
150+
shell: Literal[False] = False,
151151
bufsize: Literal[0] = 0,
152152
encoding: None = None,
153153
errors: None = None,
154+
text: Literal[False] | None = None,
154155
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
155-
text: bool | None = None,
156156
executable: StrOrBytesPath | None = None,
157157
preexec_fn: Callable[[], Any] | None = None,
158158
close_fds: bool = True,
@@ -210,14 +210,14 @@ else: # >= 3.9
210210
stderr: int | IO[Any] | None = None,
211211
loop: events.AbstractEventLoop | None = None,
212212
limit: int = 65536,
213-
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
213+
# These parameters are forced to these values by BaseEventLoop.subprocess_exec
214214
universal_newlines: Literal[False] = False,
215-
shell: Literal[True] = True,
215+
shell: Literal[False] = False,
216216
bufsize: Literal[0] = 0,
217217
encoding: None = None,
218218
errors: None = None,
219+
text: Literal[False] | None = None,
219220
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
220-
text: bool | None = None,
221221
executable: StrOrBytesPath | None = None,
222222
preexec_fn: Callable[[], Any] | None = None,
223223
close_fds: bool = True,

0 commit comments

Comments
 (0)