Skip to content

Commit

Permalink
Sync typeshed
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood authored and JelleZijlstra committed Dec 1, 2023
1 parent 95e7fcb commit c0fce06
Show file tree
Hide file tree
Showing 52 changed files with 436 additions and 169 deletions.
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/_codecs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ _StrToStrEncoding: TypeAlias = Literal["rot13", "rot_13"]
@overload
def encode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = "strict") -> bytes: ...
@overload
def encode(obj: str, encoding: _StrToStrEncoding, errors: str = "strict") -> str: ... # type: ignore[misc]
def encode(obj: str, encoding: _StrToStrEncoding, errors: str = "strict") -> str: ... # type: ignore[overload-overlap]
@overload
def encode(obj: str, encoding: str = "utf-8", errors: str = "strict") -> bytes: ...
@overload
def decode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = "strict") -> bytes: ... # type: ignore[misc]
def decode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = "strict") -> bytes: ... # type: ignore[overload-overlap]
@overload
def decode(obj: str, encoding: _StrToStrEncoding, errors: str = "strict") -> str: ...

Expand Down
6 changes: 5 additions & 1 deletion mypy/typeshed/stdlib/_ctypes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ class Array(_CData, Generic[_CT]):
def _type_(self) -> type[_CT]: ...
@_type_.setter
def _type_(self, value: type[_CT]) -> None: ...
raw: bytes # Note: only available if _CT == c_char
# Note: only available if _CT == c_char
@property
def raw(self) -> bytes: ...
@raw.setter
def raw(self, value: ReadableBuffer) -> None: ...
value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise
# TODO These methods cannot be annotated correctly at the moment.
# All of these "Any"s stand for the array's element type, but it's not possible to use _CT
Expand Down
10 changes: 6 additions & 4 deletions mypy/typeshed/stdlib/argparse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
) -> None: ...

@overload
def parse_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ... # type: ignore[misc]
def parse_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ...
@overload
def parse_args(self, args: Sequence[str] | None, namespace: _N) -> _N: ...
@overload
Expand Down Expand Up @@ -211,7 +211,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
def format_usage(self) -> str: ...
def format_help(self) -> str: ...
@overload
def parse_known_args(self, args: Sequence[str] | None = None, namespace: None = None) -> tuple[Namespace, list[str]]: ... # type: ignore[misc]
def parse_known_args(self, args: Sequence[str] | None = None, namespace: None = None) -> tuple[Namespace, list[str]]: ...
@overload
def parse_known_args(self, args: Sequence[str] | None, namespace: _N) -> tuple[_N, list[str]]: ...
@overload
Expand All @@ -220,13 +220,15 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
def exit(self, status: int = 0, message: str | None = None) -> NoReturn: ...
def error(self, message: str) -> NoReturn: ...
@overload
def parse_intermixed_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ... # type: ignore[misc]
def parse_intermixed_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ...
@overload
def parse_intermixed_args(self, args: Sequence[str] | None, namespace: _N) -> _N: ...
@overload
def parse_intermixed_args(self, *, namespace: _N) -> _N: ...
@overload
def parse_known_intermixed_args(self, args: Sequence[str] | None = None, namespace: None = None) -> tuple[Namespace, list[str]]: ... # type: ignore[misc]
def parse_known_intermixed_args(
self, args: Sequence[str] | None = None, namespace: None = None
) -> tuple[Namespace, list[str]]: ...
@overload
def parse_known_intermixed_args(self, args: Sequence[str] | None, namespace: _N) -> tuple[_N, list[str]]: ...
@overload
Expand Down
2 changes: 2 additions & 0 deletions mypy/typeshed/stdlib/asyncio/base_events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -471,3 +471,5 @@ class BaseEventLoop(AbstractEventLoop):
async def shutdown_default_executor(self, timeout: float | None = None) -> None: ...
elif sys.version_info >= (3, 9):
async def shutdown_default_executor(self) -> None: ...

def __del__(self) -> None: ...
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/asyncio/base_subprocess.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
async def _wait(self) -> int: ... # undocumented
def _try_finish(self) -> None: ... # undocumented
def _call_connection_lost(self, exc: BaseException | None) -> None: ... # undocumented
def __del__(self) -> None: ...

class WriteSubprocessPipeProto(protocols.BaseProtocol): # undocumented
def __init__(self, proc: BaseSubprocessTransport, fd: int) -> None: ...
Expand Down
15 changes: 12 additions & 3 deletions mypy/typeshed/stdlib/asyncio/events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ from collections.abc import Callable, Coroutine, Generator, Sequence
from contextvars import Context
from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket
from typing import IO, Any, Protocol, TypeVar, overload
from typing_extensions import Literal, Self, TypeAlias
from typing_extensions import Literal, Self, TypeAlias, deprecated

from . import _AwaitableLike, _CoroutineLike
from .base_events import Server
Expand Down Expand Up @@ -613,8 +613,17 @@ def set_event_loop_policy(policy: AbstractEventLoopPolicy | None) -> None: ...
def get_event_loop() -> AbstractEventLoop: ...
def set_event_loop(loop: AbstractEventLoop | None) -> None: ...
def new_event_loop() -> AbstractEventLoop: ...
def get_child_watcher() -> AbstractChildWatcher: ...
def set_child_watcher(watcher: AbstractChildWatcher) -> None: ...

if sys.version_info >= (3, 12):
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
def get_child_watcher() -> AbstractChildWatcher: ...
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
def set_child_watcher(watcher: AbstractChildWatcher) -> None: ...

else:
def get_child_watcher() -> AbstractChildWatcher: ...
def set_child_watcher(watcher: AbstractChildWatcher) -> None: ...

def _set_running_loop(__loop: AbstractEventLoop | None) -> None: ...
def _get_running_loop() -> AbstractEventLoop: ...
def get_running_loop() -> AbstractEventLoop: ...
Expand Down
2 changes: 2 additions & 0 deletions mypy/typeshed/stdlib/asyncio/sslproto.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport):
def set_read_buffer_limits(self, high: int | None = None, low: int | None = None) -> None: ...
def get_read_buffer_size(self) -> int: ...

def __del__(self) -> None: ...

if sys.version_info >= (3, 11):
_SSLProtocolBase: TypeAlias = protocols.BufferedProtocol
else:
Expand Down
3 changes: 3 additions & 0 deletions mypy/typeshed/stdlib/asyncio/streams.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
client_connected_cb: _ClientConnectedCallback | None = None,
loop: events.AbstractEventLoop | None = None,
) -> None: ...
def __del__(self) -> None: ...

class StreamWriter:
def __init__(
Expand Down Expand Up @@ -161,6 +162,8 @@ class StreamWriter:
async def start_tls(
self, sslcontext: ssl.SSLContext, *, server_hostname: str | None = None, ssl_handshake_timeout: float | None = None
) -> None: ...
if sys.version_info >= (3, 11):
def __del__(self) -> None: ...

class StreamReader(AsyncIterator[bytes]):
def __init__(self, limit: int = 65536, loop: events.AbstractEventLoop | None = None) -> None: ...
Expand Down
18 changes: 9 additions & 9 deletions mypy/typeshed/stdlib/asyncio/subprocess.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ if sys.version_info >= (3, 11):
stdout: int | IO[Any] | None = None,
stderr: int | IO[Any] | None = None,
limit: int = 65536,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
# These parameters are forced to these values by BaseEventLoop.subprocess_exec
universal_newlines: Literal[False] = False,
shell: Literal[True] = True,
shell: Literal[False] = False,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
text: Literal[False] | None = None,
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
text: bool | None = None,
executable: StrOrBytesPath | None = None,
preexec_fn: Callable[[], Any] | None = None,
close_fds: bool = True,
Expand Down Expand Up @@ -145,14 +145,14 @@ elif sys.version_info >= (3, 10):
stdout: int | IO[Any] | None = None,
stderr: int | IO[Any] | None = None,
limit: int = 65536,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
# These parameters are forced to these values by BaseEventLoop.subprocess_exec
universal_newlines: Literal[False] = False,
shell: Literal[True] = True,
shell: Literal[False] = False,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
text: Literal[False] | None = None,
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
text: bool | None = None,
executable: StrOrBytesPath | None = None,
preexec_fn: Callable[[], Any] | None = None,
close_fds: bool = True,
Expand Down Expand Up @@ -210,14 +210,14 @@ else: # >= 3.9
stderr: int | IO[Any] | None = None,
loop: events.AbstractEventLoop | None = None,
limit: int = 65536,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
# These parameters are forced to these values by BaseEventLoop.subprocess_exec
universal_newlines: Literal[False] = False,
shell: Literal[True] = True,
shell: Literal[False] = False,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
text: Literal[False] | None = None,
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
text: bool | None = None,
executable: StrOrBytesPath | None = None,
preexec_fn: Callable[[], Any] | None = None,
close_fds: bool = True,
Expand Down
Loading

0 comments on commit c0fce06

Please sign in to comment.