Skip to content

Commit e5546fe

Browse files
Sync typeshed (#18803)
Source commit: python/typeshed@cdfb10c
1 parent c99973c commit e5546fe

27 files changed

+402
-322
lines changed

mypy/typeshed/stdlib/_socket.pyi

+2-2
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: ...

mypy/typeshed/stdlib/_typeshed/__init__.pyi

+7-4
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

mypy/typeshed/stdlib/asyncio/__init__.pyi

+2
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

mypy/typeshed/stdlib/asyncio/base_events.pyi

+3-2
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,

mypy/typeshed/stdlib/asyncio/events.pyi

+3-2
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(

mypy/typeshed/stdlib/builtins.pyi

+21-18
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
@@ -88,8 +87,8 @@ _T2 = TypeVar("_T2")
8887
_T3 = TypeVar("_T3")
8988
_T4 = TypeVar("_T4")
9089
_T5 = TypeVar("_T5")
91-
_SupportsNextT = TypeVar("_SupportsNextT", bound=SupportsNext[Any], covariant=True)
92-
_SupportsAnextT = TypeVar("_SupportsAnextT", bound=SupportsAnext[Any], covariant=True)
90+
_SupportsNextT_co = TypeVar("_SupportsNextT_co", bound=SupportsNext[Any], covariant=True)
91+
_SupportsAnextT_co = TypeVar("_SupportsAnextT_co", bound=SupportsAnext[Any], covariant=True)
9392
_AwaitableT = TypeVar("_AwaitableT", bound=Awaitable[Any])
9493
_AwaitableT_co = TypeVar("_AwaitableT_co", bound=Awaitable[Any], covariant=True)
9594
_P = ParamSpec("_P")
@@ -772,7 +771,11 @@ class memoryview(Sequence[_I]):
772771
def __new__(cls, obj: ReadableBuffer) -> Self: ...
773772
def __enter__(self) -> Self: ...
774773
def __exit__(
775-
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None, /
774+
self,
775+
exc_type: type[BaseException] | None, # noqa: PYI036 # This is the module declaring BaseException
776+
exc_val: BaseException | None,
777+
exc_tb: TracebackType | None,
778+
/,
776779
) -> None: ...
777780
@overload
778781
def cast(self, format: Literal["c", "@c"], shape: list[int] | tuple[int, ...] = ...) -> memoryview[bytes]: ...
@@ -1042,7 +1045,7 @@ class dict(MutableMapping[_KT, _VT]):
10421045
def fromkeys(cls, iterable: Iterable[_T], value: _S, /) -> dict[_T, _S]: ...
10431046
# Positional-only in dict, but not in MutableMapping
10441047
@overload # type: ignore[override]
1045-
def get(self, key: _KT, /) -> _VT | None: ...
1048+
def get(self, key: _KT, default: None = None, /) -> _VT | None: ...
10461049
@overload
10471050
def get(self, key: _KT, default: _VT, /) -> _VT: ...
10481051
@overload
@@ -1221,7 +1224,7 @@ class _PathLike(Protocol[AnyStr_co]):
12211224
def __fspath__(self) -> AnyStr_co: ...
12221225

12231226
if sys.version_info >= (3, 10):
1224-
def aiter(async_iterable: SupportsAiter[_SupportsAnextT], /) -> _SupportsAnextT: ...
1227+
def aiter(async_iterable: SupportsAiter[_SupportsAnextT_co], /) -> _SupportsAnextT_co: ...
12251228

12261229
class _SupportsSynchronousAnext(Protocol[_AwaitableT_co]):
12271230
def __anext__(self) -> _AwaitableT_co: ...
@@ -1383,7 +1386,7 @@ class _GetItemIterable(Protocol[_T_co]):
13831386
def __getitem__(self, i: int, /) -> _T_co: ...
13841387

13851388
@overload
1386-
def iter(object: SupportsIter[_SupportsNextT], /) -> _SupportsNextT: ...
1389+
def iter(object: SupportsIter[_SupportsNextT_co], /) -> _SupportsNextT_co: ...
13871390
@overload
13881391
def iter(object: _GetItemIterable[_T], /) -> Iterator[_T]: ...
13891392
@overload
@@ -1590,17 +1593,17 @@ def print(
15901593
*values: object, sep: str | None = " ", end: str | None = "\n", file: _SupportsWriteAndFlush[str] | None = None, flush: bool
15911594
) -> None: ...
15921595

1593-
_E = TypeVar("_E", contravariant=True)
1594-
_M = TypeVar("_M", contravariant=True)
1596+
_E_contra = TypeVar("_E_contra", contravariant=True)
1597+
_M_contra = TypeVar("_M_contra", contravariant=True)
15951598

1596-
class _SupportsPow2(Protocol[_E, _T_co]):
1597-
def __pow__(self, other: _E, /) -> _T_co: ...
1599+
class _SupportsPow2(Protocol[_E_contra, _T_co]):
1600+
def __pow__(self, other: _E_contra, /) -> _T_co: ...
15981601

1599-
class _SupportsPow3NoneOnly(Protocol[_E, _T_co]):
1600-
def __pow__(self, other: _E, modulo: None = None, /) -> _T_co: ...
1602+
class _SupportsPow3NoneOnly(Protocol[_E_contra, _T_co]):
1603+
def __pow__(self, other: _E_contra, modulo: None = None, /) -> _T_co: ...
16011604

1602-
class _SupportsPow3(Protocol[_E, _M, _T_co]):
1603-
def __pow__(self, other: _E, modulo: _M, /) -> _T_co: ...
1605+
class _SupportsPow3(Protocol[_E_contra, _M_contra, _T_co]):
1606+
def __pow__(self, other: _E_contra, modulo: _M_contra, /) -> _T_co: ...
16041607

16051608
_SupportsSomeKindOfPow = ( # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed
16061609
_SupportsPow2[Any, Any] | _SupportsPow3NoneOnly[Any, Any] | _SupportsPow3[Any, Any, Any]
@@ -1636,11 +1639,11 @@ def pow(base: float, exp: complex | _SupportsSomeKindOfPow, mod: None = None) ->
16361639
@overload
16371640
def pow(base: complex, exp: complex | _SupportsSomeKindOfPow, mod: None = None) -> complex: ...
16381641
@overload
1639-
def pow(base: _SupportsPow2[_E, _T_co], exp: _E, mod: None = None) -> _T_co: ... # type: ignore[overload-overlap]
1642+
def pow(base: _SupportsPow2[_E_contra, _T_co], exp: _E_contra, mod: None = None) -> _T_co: ... # type: ignore[overload-overlap]
16401643
@overload
1641-
def pow(base: _SupportsPow3NoneOnly[_E, _T_co], exp: _E, mod: None = None) -> _T_co: ... # type: ignore[overload-overlap]
1644+
def pow(base: _SupportsPow3NoneOnly[_E_contra, _T_co], exp: _E_contra, mod: None = None) -> _T_co: ... # type: ignore[overload-overlap]
16421645
@overload
1643-
def pow(base: _SupportsPow3[_E, _M, _T_co], exp: _E, mod: _M) -> _T_co: ...
1646+
def pow(base: _SupportsPow3[_E_contra, _M_contra, _T_co], exp: _E_contra, mod: _M_contra) -> _T_co: ...
16441647
@overload
16451648
def pow(base: _SupportsSomeKindOfPow, exp: float, mod: None = None) -> Any: ...
16461649
@overload

mypy/typeshed/stdlib/contextlib.pyi

+5-5
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

mypy/typeshed/stdlib/distutils/cmd.pyi

+1-1
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]]]

mypy/typeshed/stdlib/distutils/dist.pyi

+3-3
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

mypy/typeshed/stdlib/distutils/fancy_getopt.pyi

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from collections.abc import Iterable, Mapping
2+
from getopt import _SliceableT, _StrSequenceT_co
23
from re import Pattern
34
from typing import Any, Final, overload
45
from typing_extensions import TypeAlias
56

67
_Option: TypeAlias = tuple[str, str | None, str]
7-
_GR: TypeAlias = tuple[list[str], OptionDummy]
88

99
longopt_pat: Final = r"[a-zA-Z](?:[a-zA-Z0-9-]*)"
1010
longopt_re: Final[Pattern[str]]
@@ -15,15 +15,25 @@ class FancyGetopt:
1515
def __init__(self, option_table: list[_Option] | None = None) -> None: ...
1616
# TODO kinda wrong, `getopt(object=object())` is invalid
1717
@overload
18-
def getopt(self, args: list[str] | None = None) -> _GR: ...
18+
def getopt(
19+
self, args: _SliceableT[_StrSequenceT_co] | None = None, object: None = None
20+
) -> tuple[_StrSequenceT_co, OptionDummy]: ...
1921
@overload
20-
def getopt(self, args: list[str] | None, object: Any) -> list[str]: ...
22+
def getopt(
23+
self, args: _SliceableT[_StrSequenceT_co] | None, object: Any
24+
) -> _StrSequenceT_co: ... # object is an arbitrary non-slotted object
2125
def get_option_order(self) -> list[tuple[str, str]]: ...
2226
def generate_help(self, header: str | None = None) -> list[str]: ...
2327

28+
# Same note as FancyGetopt.getopt
29+
@overload
2430
def fancy_getopt(
25-
options: list[_Option], negative_opt: Mapping[_Option, _Option], object: Any, args: list[str] | None
26-
) -> list[str] | _GR: ...
31+
options: list[_Option], negative_opt: Mapping[_Option, _Option], object: None, args: _SliceableT[_StrSequenceT_co] | None
32+
) -> tuple[_StrSequenceT_co, OptionDummy]: ...
33+
@overload
34+
def fancy_getopt(
35+
options: list[_Option], negative_opt: Mapping[_Option, _Option], object: Any, args: _SliceableT[_StrSequenceT_co] | None
36+
) -> _StrSequenceT_co: ...
2737

2838
WS_TRANS: Final[dict[int, str]]
2939

mypy/typeshed/stdlib/functools.pyi

+9-4
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,25 @@ class partialmethod(Generic[_T]):
151151
if sys.version_info >= (3, 9):
152152
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
153153

154+
if sys.version_info >= (3, 11):
155+
_RegType: TypeAlias = type[Any] | types.UnionType
156+
else:
157+
_RegType: TypeAlias = type[Any]
158+
154159
class _SingleDispatchCallable(Generic[_T]):
155160
registry: types.MappingProxyType[Any, Callable[..., _T]]
156161
def dispatch(self, cls: Any) -> Callable[..., _T]: ...
157162
# @fun.register(complex)
158163
# def _(arg, verbose=False): ...
159164
@overload
160-
def register(self, cls: type[Any], func: None = None) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
165+
def register(self, cls: _RegType, func: None = None) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
161166
# @fun.register
162167
# def _(arg: int, verbose=False):
163168
@overload
164169
def register(self, cls: Callable[..., _T], func: None = None) -> Callable[..., _T]: ...
165170
# fun.register(int, lambda x: x)
166171
@overload
167-
def register(self, cls: type[Any], func: Callable[..., _T]) -> Callable[..., _T]: ...
172+
def register(self, cls: _RegType, func: Callable[..., _T]) -> Callable[..., _T]: ...
168173
def _clear_cache(self) -> None: ...
169174
def __call__(self, /, *args: Any, **kwargs: Any) -> _T: ...
170175

@@ -177,11 +182,11 @@ class singledispatchmethod(Generic[_T]):
177182
@property
178183
def __isabstractmethod__(self) -> bool: ...
179184
@overload
180-
def register(self, cls: type[Any], method: None = None) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
185+
def register(self, cls: _RegType, method: None = None) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
181186
@overload
182187
def register(self, cls: Callable[..., _T], method: None = None) -> Callable[..., _T]: ...
183188
@overload
184-
def register(self, cls: type[Any], method: Callable[..., _T]) -> Callable[..., _T]: ...
189+
def register(self, cls: _RegType, method: Callable[..., _T]) -> Callable[..., _T]: ...
185190
def __get__(self, obj: _S, cls: type[_S] | None = None) -> Callable[..., _T]: ...
186191

187192
class cached_property(Generic[_T_co]):

mypy/typeshed/stdlib/getopt.pyi

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1-
from collections.abc import Iterable
1+
from collections.abc import Iterable, Sequence
2+
from typing import Protocol, TypeVar, overload, type_check_only
3+
4+
_StrSequenceT_co = TypeVar("_StrSequenceT_co", covariant=True, bound=Sequence[str])
5+
6+
@type_check_only
7+
class _SliceableT(Protocol[_StrSequenceT_co]):
8+
@overload
9+
def __getitem__(self, key: int, /) -> str: ...
10+
@overload
11+
def __getitem__(self, key: slice, /) -> _StrSequenceT_co: ...
212

313
__all__ = ["GetoptError", "error", "getopt", "gnu_getopt"]
414

5-
def getopt(args: list[str], shortopts: str, longopts: Iterable[str] | str = []) -> tuple[list[tuple[str, str]], list[str]]: ...
15+
def getopt(
16+
args: _SliceableT[_StrSequenceT_co], shortopts: str, longopts: Iterable[str] | str = []
17+
) -> tuple[list[tuple[str, str]], _StrSequenceT_co]: ...
618
def gnu_getopt(
7-
args: list[str], shortopts: str, longopts: Iterable[str] | str = []
19+
args: Sequence[str], shortopts: str, longopts: Iterable[str] | str = []
820
) -> tuple[list[tuple[str, str]], list[str]]: ...
921

1022
class GetoptError(Exception):

mypy/typeshed/stdlib/importlib/metadata/__init__.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ if sys.version_info >= (3, 10) and sys.version_info < (3, 12):
139139
class Deprecated(Generic[_KT, _VT]):
140140
def __getitem__(self, name: _KT) -> _VT: ...
141141
@overload
142-
def get(self, name: _KT) -> _VT | None: ...
142+
def get(self, name: _KT, default: None = None) -> _VT | None: ...
143143
@overload
144144
def get(self, name: _KT, default: _T) -> _VT | _T: ...
145145
def __iter__(self) -> Iterator[_KT]: ...

mypy/typeshed/stdlib/importlib/readers.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ if sys.version_info >= (3, 10):
1616
from zipimport import zipimporter
1717

1818
if sys.version_info >= (3, 11):
19-
import importlib.resources.abc as abc
19+
from importlib.resources import abc
2020
else:
21-
import importlib.abc as abc
21+
from importlib import abc
2222

2323
if sys.version_info >= (3, 10):
2424
if sys.version_info >= (3, 11):

mypy/typeshed/stdlib/inspect.pyi

+6-6
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ if sys.version_info >= (3, 11):
143143
_P = ParamSpec("_P")
144144
_T = TypeVar("_T")
145145
_F = TypeVar("_F", bound=Callable[..., Any])
146-
_T_cont = TypeVar("_T_cont", contravariant=True)
147-
_V_cont = TypeVar("_V_cont", contravariant=True)
146+
_T_contra = TypeVar("_T_contra", contravariant=True)
147+
_V_contra = TypeVar("_V_contra", contravariant=True)
148148

149149
#
150150
# Types and members
@@ -228,11 +228,11 @@ def isasyncgenfunction(obj: Callable[_P, Any]) -> TypeGuard[Callable[_P, AsyncGe
228228
@overload
229229
def isasyncgenfunction(obj: object) -> TypeGuard[Callable[..., AsyncGeneratorType[Any, Any]]]: ...
230230

231-
class _SupportsSet(Protocol[_T_cont, _V_cont]):
232-
def __set__(self, instance: _T_cont, value: _V_cont, /) -> None: ...
231+
class _SupportsSet(Protocol[_T_contra, _V_contra]):
232+
def __set__(self, instance: _T_contra, value: _V_contra, /) -> None: ...
233233

234-
class _SupportsDelete(Protocol[_T_cont]):
235-
def __delete__(self, instance: _T_cont, /) -> None: ...
234+
class _SupportsDelete(Protocol[_T_contra]):
235+
def __delete__(self, instance: _T_contra, /) -> None: ...
236236

237237
def isasyncgen(object: object) -> TypeIs[AsyncGeneratorType[Any, Any]]: ...
238238
def istraceback(object: object) -> TypeIs[TracebackType]: ...

0 commit comments

Comments
 (0)