Remove redundant inheritances from Generic and various typing protocols (#10981)

This commit is contained in:
Alex Waygood
2023-11-06 13:00:25 +00:00
committed by GitHub
parent c8073493fc
commit 8023ba764a
9 changed files with 16 additions and 25 deletions

View File

@@ -56,7 +56,7 @@ class AbstractAsyncContextManager(Protocol[_T_co]):
class ContextDecorator:
def __call__(self, func: _F) -> _F: ...
class _GeneratorContextManager(AbstractContextManager[_T_co], ContextDecorator, Generic[_T_co]):
class _GeneratorContextManager(AbstractContextManager[_T_co], ContextDecorator):
# __init__ and all instance attributes are actually inherited from _GeneratorContextManagerBase
# _GeneratorContextManagerBase is more trouble than it's worth to include in the stub; see #6676
def __init__(self, func: Callable[..., Iterator[_T_co]], args: tuple[Any, ...], kwds: dict[str, Any]) -> None: ...
@@ -81,7 +81,7 @@ if sys.version_info >= (3, 10):
class AsyncContextDecorator:
def __call__(self, func: _AF) -> _AF: ...
class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co], AsyncContextDecorator, Generic[_T_co]):
class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co], AsyncContextDecorator):
# __init__ and these attributes are actually defined in the base class _GeneratorContextManagerBase,
# which is more trouble than it's worth to include in the stub (see #6676)
def __init__(self, func: Callable[..., AsyncIterator[_T_co]], args: tuple[Any, ...], kwds: dict[str, Any]) -> None: ...

View File

@@ -1,5 +1,5 @@
import sys
from collections.abc import Container, Iterable, Iterator
from collections.abc import Iterable, Iterator
from typing import Any, Generic, SupportsInt, TypeVar, overload
from typing_extensions import Literal, Self, TypeAlias
@@ -70,7 +70,7 @@ class _BaseAddress(_IPAddressBase, SupportsInt):
@property
def packed(self) -> bytes: ...
class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]):
class _BaseNetwork(_IPAddressBase, Generic[_A]):
network_address: _A
netmask: _A
def __init__(self, address: object, strict: bool = ...) -> None: ...

View File

@@ -513,7 +513,7 @@ class Collection(Iterable[_T_co], Container[_T_co], Protocol[_T_co]):
@abstractmethod
def __len__(self) -> int: ...
class Sequence(Collection[_T_co], Reversible[_T_co], Generic[_T_co]):
class Sequence(Collection[_T_co], Reversible[_T_co]):
@overload
@abstractmethod
def __getitem__(self, index: int) -> _T_co: ...
@@ -607,7 +607,7 @@ class ItemsView(MappingView, AbstractSet[tuple[_KT_co, _VT_co]], Generic[_KT_co,
def __xor__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
def __rxor__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]):
class KeysView(MappingView, AbstractSet[_KT_co]):
def __init__(self, mapping: Mapping[_KT_co, Any]) -> None: ... # undocumented
def __and__(self, other: Iterable[Any]) -> set[_KT_co]: ...
def __rand__(self, other: Iterable[_T]) -> set[_T]: ...
@@ -623,7 +623,7 @@ class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]):
def __xor__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ...
def __rxor__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ...
class ValuesView(MappingView, Collection[_VT_co], Generic[_VT_co]):
class ValuesView(MappingView, Collection[_VT_co]):
def __init__(self, mapping: Mapping[Any, _VT_co]) -> None: ... # undocumented
def __contains__(self, value: object) -> bool: ...
def __iter__(self) -> Iterator[_VT_co]: ...

View File

@@ -2,7 +2,7 @@ from _typeshed import Incomplete, Unused
from collections.abc import AsyncIterator, Awaitable, Callable, Generator, Iterable, Mapping, MutableMapping, Sequence
from datetime import datetime, timedelta
from types import TracebackType
from typing import Any, ClassVar, Generic, NoReturn, Protocol, overload
from typing import Any, ClassVar, NoReturn, Protocol, overload
from typing_extensions import Literal, Self, TypeAlias, TypedDict
from redis import RedisError
@@ -24,7 +24,7 @@ class AsyncResponseCallbackProtocol(Protocol):
ResponseCallbackT: TypeAlias = ResponseCallbackProtocol | AsyncResponseCallbackProtocol
class Redis(AbstractRedis, RedisModuleCommands, AsyncCoreCommands[_StrType], AsyncSentinelCommands, Generic[_StrType]):
class Redis(AbstractRedis, RedisModuleCommands, AsyncCoreCommands[_StrType], AsyncSentinelCommands):
response_callbacks: MutableMapping[str | bytes, ResponseCallbackT]
auto_close_connection_pool: bool
connection_pool: Any

View File

@@ -4,7 +4,7 @@ from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from datetime import datetime, timedelta
from re import Pattern
from types import TracebackType
from typing import Any, ClassVar, Generic, TypeVar, overload
from typing import Any, ClassVar, TypeVar, overload
from typing_extensions import Literal, Self, TypeAlias
from redis import RedisError
@@ -76,7 +76,7 @@ _LockType = TypeVar("_LockType")
class AbstractRedis:
RESPONSE_CALLBACKS: dict[str, Any]
class Redis(AbstractRedis, RedisModuleCommands, CoreCommands[_StrType], SentinelCommands, Generic[_StrType]):
class Redis(AbstractRedis, RedisModuleCommands, CoreCommands[_StrType], SentinelCommands):
@overload
@classmethod
def from_url(

View File

@@ -2,7 +2,7 @@ from _typeshed import Incomplete, Unused
from collections.abc import Callable, Iterable, Sequence
from threading import Lock
from types import TracebackType
from typing import Any, ClassVar, Generic, NoReturn, Protocol
from typing import Any, ClassVar, NoReturn, Protocol
from typing_extensions import Literal, Self
from redis.client import CaseInsensitiveDict, PubSub, Redis, _ParseResponseOptions
@@ -45,7 +45,7 @@ class AbstractRedisCluster:
RESULT_CALLBACKS: ClassVar[dict[str, Callable[[Incomplete, Incomplete], Incomplete]]]
ERRORS_ALLOW_RETRY: ClassVar[tuple[type[RedisError], ...]]
class RedisCluster(AbstractRedisCluster, RedisClusterCommands[_StrType], Generic[_StrType]):
class RedisCluster(AbstractRedisCluster, RedisClusterCommands[_StrType]):
user_on_connect_func: Callable[[Connection], object] | None
encoder: Encoder
cluster_error_retry_attempts: int

View File

@@ -1,5 +1,5 @@
from _typeshed import Incomplete
from typing import Generic, NoReturn
from typing import NoReturn
from .core import ACLCommands, DataAccessCommands, ManagementCommands, PubSubCommands, _StrType
@@ -31,12 +31,7 @@ class ClusterDataAccessCommands(DataAccessCommands[_StrType]):
): ...
class RedisClusterCommands(
ClusterMultiKeyCommands,
ClusterManagementCommands,
ACLCommands[_StrType],
PubSubCommands,
ClusterDataAccessCommands[_StrType],
Generic[_StrType],
ClusterMultiKeyCommands, ClusterManagementCommands, ACLCommands[_StrType], PubSubCommands, ClusterDataAccessCommands[_StrType]
):
def cluster_addslots(self, target_node, *slots): ...
def cluster_countkeysinslot(self, slot_id): ...

View File

@@ -1705,7 +1705,6 @@ class DataAccessCommands(
SetCommands[_StrType],
StreamCommands,
SortedSetCommands[_StrType],
Generic[_StrType],
): ...
class AsyncDataAccessCommands(
AsyncBasicKeyCommands[_StrType],
@@ -1717,7 +1716,6 @@ class AsyncDataAccessCommands(
AsyncSetCommands[_StrType],
AsyncStreamCommands,
AsyncSortedSetCommands[_StrType],
Generic[_StrType],
): ...
class CoreCommands(
ACLCommands[_StrType],
@@ -1727,7 +1725,6 @@ class CoreCommands(
ModuleCommands,
PubSubCommands,
ScriptCommands[_StrType],
Generic[_StrType],
): ...
class AsyncCoreCommands(
AsyncACLCommands[_StrType],
@@ -1738,5 +1735,4 @@ class AsyncCoreCommands(
AsyncPubSubCommands,
AsyncScriptCommands[_StrType],
AsyncFunctionCommands,
Generic[_StrType],
): ...

View File

@@ -31,7 +31,7 @@ class TqdmMonitorWarning(TqdmWarning, RuntimeWarning): ...
_T = TypeVar("_T")
class tqdm(Iterable[_T], Comparable, Generic[_T]):
class tqdm(Comparable, Generic[_T]):
monitor_interval: ClassVar[int]
monitor: ClassVar[TMonitor | None]