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]: ...