Skip to content

Commit 1fab292

Browse files
Sync vendored typeshed stubs (astral-sh#16762)
Close and reopen this PR to trigger CI Co-authored-by: typeshedbot <>
1 parent c755eec commit 1fab292

File tree

28 files changed

+403
-323
lines changed

28 files changed

+403
-323
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0b13c1deb6d0b2cdc78b246da9a0863c87dd8424
1+
cdfb10c340c3df0f8b4112705e6e229b6ae269fd

crates/red_knot_vendored/vendor/typeshed/stdlib/_socket.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,12 +812,12 @@ def getaddrinfo(
812812
type: int = ...,
813813
proto: int = ...,
814814
flags: int = ...,
815-
) -> list[tuple[int, int, int, str, tuple[str, int] | tuple[str, int, int, int]]]: ...
815+
) -> list[tuple[int, int, int, str, tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes]]]: ...
816816
def gethostbyname(hostname: str, /) -> str: ...
817817
def gethostbyname_ex(hostname: str, /) -> tuple[str, list[str], list[str]]: ...
818818
def gethostname() -> str: ...
819819
def gethostbyaddr(ip_address: str, /) -> tuple[str, list[str], list[str]]: ...
820-
def getnameinfo(sockaddr: tuple[str, int] | tuple[str, int, int, int], flags: int, /) -> tuple[str, str]: ...
820+
def getnameinfo(sockaddr: tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes], flags: int, /) -> tuple[str, str]: ...
821821
def getprotobyname(protocolname: str, /) -> int: ...
822822
def getservbyname(servicename: str, protocolname: str = ..., /) -> int: ...
823823
def getservbyport(port: int, protocolname: str = ..., /) -> str: ...

crates/red_knot_vendored/vendor/typeshed/stdlib/_typeshed/__init__.pyi

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ class SupportsSub(Protocol[_T_contra, _T_co]):
117117
class SupportsRSub(Protocol[_T_contra, _T_co]):
118118
def __rsub__(self, x: _T_contra, /) -> _T_co: ...
119119

120+
class SupportsMul(Protocol[_T_contra, _T_co]):
121+
def __mul__(self, x: _T_contra, /) -> _T_co: ...
122+
123+
class SupportsRMul(Protocol[_T_contra, _T_co]):
124+
def __rmul__(self, x: _T_contra, /) -> _T_co: ...
125+
120126
class SupportsDivMod(Protocol[_T_contra, _T_co]):
121127
def __divmod__(self, other: _T_contra, /) -> _T_co: ...
122128

@@ -151,11 +157,8 @@ class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]):
151157
def keys(self) -> Iterable[_KT]: ...
152158
def __getitem__(self, key: _KT, /) -> _VT_co: ...
153159

154-
# This protocol is currently under discussion. Use SupportsContainsAndGetItem
155-
# instead, if you require the __contains__ method.
156-
# See https://github.com/python/typeshed/issues/11822.
160+
# stable
157161
class SupportsGetItem(Protocol[_KT_contra, _VT_co]):
158-
def __contains__(self, x: Any, /) -> bool: ...
159162
def __getitem__(self, key: _KT_contra, /) -> _VT_co: ...
160163

161164
# stable

crates/red_knot_vendored/vendor/typeshed/stdlib/asyncio/__init__.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# ruff: noqa: PLR5501 # This condition is so big, it's clearer to keep to platform condition in two blocks
2+
# Can't NOQA on a specific line: https://github.com/plinss/flake8-noqa/issues/22
13
import sys
24
from collections.abc import Awaitable, Coroutine, Generator
35
from typing import Any, TypeVar

crates/red_knot_vendored/vendor/typeshed/stdlib/asyncio/base_events.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ from asyncio.protocols import BaseProtocol
88
from asyncio.tasks import Task
99
from asyncio.transports import BaseTransport, DatagramTransport, ReadTransport, SubprocessTransport, Transport, WriteTransport
1010
from collections.abc import Callable, Iterable, Sequence
11+
from concurrent.futures import Executor, ThreadPoolExecutor
1112
from contextvars import Context
1213
from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket
1314
from typing import IO, Any, Literal, TypeVar, overload
@@ -96,8 +97,8 @@ class BaseEventLoop(AbstractEventLoop):
9697
def call_soon_threadsafe(
9798
self, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
9899
) -> Handle: ...
99-
def run_in_executor(self, executor: Any, func: Callable[[Unpack[_Ts]], _T], *args: Unpack[_Ts]) -> Future[_T]: ...
100-
def set_default_executor(self, executor: Any) -> None: ...
100+
def run_in_executor(self, executor: Executor | None, func: Callable[[Unpack[_Ts]], _T], *args: Unpack[_Ts]) -> Future[_T]: ...
101+
def set_default_executor(self, executor: ThreadPoolExecutor) -> None: ... # type: ignore[override]
101102
# Network I/O methods returning Futures.
102103
async def getaddrinfo(
103104
self,

crates/red_knot_vendored/vendor/typeshed/stdlib/asyncio/events.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ from _asyncio import (
99
from _typeshed import FileDescriptorLike, ReadableBuffer, StrPath, Unused, WriteableBuffer
1010
from abc import ABCMeta, abstractmethod
1111
from collections.abc import Callable, Sequence
12+
from concurrent.futures import Executor
1213
from contextvars import Context
1314
from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket
1415
from typing import IO, Any, Literal, Protocol, TypeVar, overload
@@ -188,9 +189,9 @@ class AbstractEventLoop:
188189
def call_soon_threadsafe(self, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]) -> Handle: ...
189190

190191
@abstractmethod
191-
def run_in_executor(self, executor: Any, func: Callable[[Unpack[_Ts]], _T], *args: Unpack[_Ts]) -> Future[_T]: ...
192+
def run_in_executor(self, executor: Executor | None, func: Callable[[Unpack[_Ts]], _T], *args: Unpack[_Ts]) -> Future[_T]: ...
192193
@abstractmethod
193-
def set_default_executor(self, executor: Any) -> None: ...
194+
def set_default_executor(self, executor: Executor) -> None: ...
194195
# Network I/O methods returning Futures.
195196
@abstractmethod
196197
async def getaddrinfo(

crates/red_knot_vendored/vendor/typeshed/stdlib/builtins.pyi

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# ruff: noqa: PYI036 # This is the module declaring BaseException
21
import _ast
32
import _sitebuiltins
43
import _typeshed
@@ -89,8 +88,8 @@ _T2 = TypeVar("_T2")
8988
_T3 = TypeVar("_T3")
9089
_T4 = TypeVar("_T4")
9190
_T5 = TypeVar("_T5")
92-
_SupportsNextT = TypeVar("_SupportsNextT", bound=SupportsNext[Any], covariant=True)
93-
_SupportsAnextT = TypeVar("_SupportsAnextT", bound=SupportsAnext[Any], covariant=True)
91+
_SupportsNextT_co = TypeVar("_SupportsNextT_co", bound=SupportsNext[Any], covariant=True)
92+
_SupportsAnextT_co = TypeVar("_SupportsAnextT_co", bound=SupportsAnext[Any], covariant=True)
9493
_AwaitableT = TypeVar("_AwaitableT", bound=Awaitable[Any])
9594
_AwaitableT_co = TypeVar("_AwaitableT_co", bound=Awaitable[Any], covariant=True)
9695
_P = ParamSpec("_P")
@@ -870,7 +869,11 @@ class memoryview(Sequence[_I]):
870869
def __new__(cls, obj: ReadableBuffer) -> Self: ...
871870
def __enter__(self) -> Self: ...
872871
def __exit__(
873-
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None, /
872+
self,
873+
exc_type: type[BaseException] | None, # noqa: PYI036 # This is the module declaring BaseException
874+
exc_val: BaseException | None,
875+
exc_tb: TracebackType | None,
876+
/,
874877
) -> None: ...
875878
@overload
876879
def cast(self, format: Literal["c", "@c"], shape: list[int] | tuple[int, ...] = ...) -> memoryview[bytes]: ...
@@ -1140,7 +1143,7 @@ class dict(MutableMapping[_KT, _VT]):
11401143
def fromkeys(cls, iterable: Iterable[_T], value: _S, /) -> dict[_T, _S]: ...
11411144
# Positional-only in dict, but not in MutableMapping
11421145
@overload # type: ignore[override]
1143-
def get(self, key: _KT, /) -> _VT | None: ...
1146+
def get(self, key: _KT, default: None = None, /) -> _VT | None: ...
11441147
@overload
11451148
def get(self, key: _KT, default: _VT, /) -> _VT: ...
11461149
@overload
@@ -1319,7 +1322,7 @@ class _PathLike(Protocol[AnyStr_co]):
13191322
def __fspath__(self) -> AnyStr_co: ...
13201323

13211324
if sys.version_info >= (3, 10):
1322-
def aiter(async_iterable: SupportsAiter[_SupportsAnextT], /) -> _SupportsAnextT: ...
1325+
def aiter(async_iterable: SupportsAiter[_SupportsAnextT_co], /) -> _SupportsAnextT_co: ...
13231326

13241327
class _SupportsSynchronousAnext(Protocol[_AwaitableT_co]):
13251328
def __anext__(self) -> _AwaitableT_co: ...
@@ -1481,7 +1484,7 @@ class _GetItemIterable(Protocol[_T_co]):
14811484
def __getitem__(self, i: int, /) -> _T_co: ...
14821485

14831486
@overload
1484-
def iter(object: SupportsIter[_SupportsNextT], /) -> _SupportsNextT: ...
1487+
def iter(object: SupportsIter[_SupportsNextT_co], /) -> _SupportsNextT_co: ...
14851488
@overload
14861489
def iter(object: _GetItemIterable[_T], /) -> Iterator[_T]: ...
14871490
@overload
@@ -1688,17 +1691,17 @@ def print(
16881691
*values: object, sep: str | None = " ", end: str | None = "\n", file: _SupportsWriteAndFlush[str] | None = None, flush: bool
16891692
) -> None: ...
16901693

1691-
_E = TypeVar("_E", contravariant=True)
1692-
_M = TypeVar("_M", contravariant=True)
1694+
_E_contra = TypeVar("_E_contra", contravariant=True)
1695+
_M_contra = TypeVar("_M_contra", contravariant=True)
16931696

1694-
class _SupportsPow2(Protocol[_E, _T_co]):
1695-
def __pow__(self, other: _E, /) -> _T_co: ...
1697+
class _SupportsPow2(Protocol[_E_contra, _T_co]):
1698+
def __pow__(self, other: _E_contra, /) -> _T_co: ...
16961699

1697-
class _SupportsPow3NoneOnly(Protocol[_E, _T_co]):
1698-
def __pow__(self, other: _E, modulo: None = None, /) -> _T_co: ...
1700+
class _SupportsPow3NoneOnly(Protocol[_E_contra, _T_co]):
1701+
def __pow__(self, other: _E_contra, modulo: None = None, /) -> _T_co: ...
16991702

1700-
class _SupportsPow3(Protocol[_E, _M, _T_co]):
1701-
def __pow__(self, other: _E, modulo: _M, /) -> _T_co: ...
1703+
class _SupportsPow3(Protocol[_E_contra, _M_contra, _T_co]):
1704+
def __pow__(self, other: _E_contra, modulo: _M_contra, /) -> _T_co: ...
17021705

17031706
_SupportsSomeKindOfPow = ( # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed
17041707
_SupportsPow2[Any, Any] | _SupportsPow3NoneOnly[Any, Any] | _SupportsPow3[Any, Any, Any]
@@ -1734,11 +1737,11 @@ def pow(base: float, exp: complex | _SupportsSomeKindOfPow, mod: None = None) ->
17341737
@overload
17351738
def pow(base: complex, exp: complex | _SupportsSomeKindOfPow, mod: None = None) -> complex: ...
17361739
@overload
1737-
def pow(base: _SupportsPow2[_E, _T_co], exp: _E, mod: None = None) -> _T_co: ... # type: ignore[overload-overlap]
1740+
def pow(base: _SupportsPow2[_E_contra, _T_co], exp: _E_contra, mod: None = None) -> _T_co: ... # type: ignore[overload-overlap]
17381741
@overload
1739-
def pow(base: _SupportsPow3NoneOnly[_E, _T_co], exp: _E, mod: None = None) -> _T_co: ... # type: ignore[overload-overlap]
1742+
def pow(base: _SupportsPow3NoneOnly[_E_contra, _T_co], exp: _E_contra, mod: None = None) -> _T_co: ... # type: ignore[overload-overlap]
17401743
@overload
1741-
def pow(base: _SupportsPow3[_E, _M, _T_co], exp: _E, mod: _M) -> _T_co: ...
1744+
def pow(base: _SupportsPow3[_E_contra, _M_contra, _T_co], exp: _E_contra, mod: _M_contra) -> _T_co: ...
17421745
@overload
17431746
def pow(base: _SupportsSomeKindOfPow, exp: float, mod: None = None) -> Any: ...
17441747
@overload

crates/red_knot_vendored/vendor/typeshed/stdlib/contextlib.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ _T_co = TypeVar("_T_co", covariant=True)
3333
_T_io = TypeVar("_T_io", bound=IO[str] | None)
3434
_ExitT_co = TypeVar("_ExitT_co", covariant=True, bound=bool | None, default=bool | None)
3535
_F = TypeVar("_F", bound=Callable[..., Any])
36-
_G = TypeVar("_G", bound=Generator[Any, Any, Any] | AsyncGenerator[Any, Any], covariant=True)
36+
_G_co = TypeVar("_G_co", bound=Generator[Any, Any, Any] | AsyncGenerator[Any, Any], covariant=True)
3737
_P = ParamSpec("_P")
3838

3939
_SendT_contra = TypeVar("_SendT_contra", contravariant=True, default=None)
@@ -68,11 +68,11 @@ class ContextDecorator:
6868
def _recreate_cm(self) -> Self: ...
6969
def __call__(self, func: _F) -> _F: ...
7070

71-
class _GeneratorContextManagerBase(Generic[_G]):
71+
class _GeneratorContextManagerBase(Generic[_G_co]):
7272
# Ideally this would use ParamSpec, but that requires (*args, **kwargs), which this isn't. see #6676
73-
def __init__(self, func: Callable[..., _G], args: tuple[Any, ...], kwds: dict[str, Any]) -> None: ...
74-
gen: _G
75-
func: Callable[..., _G]
73+
def __init__(self, func: Callable[..., _G_co], args: tuple[Any, ...], kwds: dict[str, Any]) -> None: ...
74+
gen: _G_co
75+
func: Callable[..., _G_co]
7676
args: tuple[Any, ...]
7777
kwds: dict[str, Any]
7878

crates/red_knot_vendored/vendor/typeshed/stdlib/distutils/cmd.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ _CommandT = TypeVar("_CommandT", bound=Command)
3030
_Ts = TypeVarTuple("_Ts")
3131

3232
class Command:
33-
dry_run: Literal[0, 1] # Exposed from __getattr_. Same as Distribution.dry_run
33+
dry_run: bool | Literal[0, 1] # Exposed from __getattr_. Same as Distribution.dry_run
3434
distribution: Distribution
3535
# Any to work around variance issues
3636
sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]]

crates/red_knot_vendored/vendor/typeshed/stdlib/distutils/dist.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ class Distribution:
8888
display_options: ClassVar[_OptionsList]
8989
display_option_names: ClassVar[list[str]]
9090
negative_opt: ClassVar[dict[str, str]]
91-
verbose: Literal[0, 1]
92-
dry_run: Literal[0, 1]
93-
help: Literal[0, 1]
91+
verbose: bool | Literal[0, 1]
92+
dry_run: bool | Literal[0, 1]
93+
help: bool | Literal[0, 1]
9494
command_packages: list[str] | None
9595
script_name: str | None
9696
script_args: list[str] | None

0 commit comments

Comments
 (0)