8000 Test decoupling of typing aliases by cdce8p · Pull Request #6262 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

Test decoupling of typing aliases #6262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion stdlib/_collections_abc.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from abc import abstractmethod
from typing import (
Any,
Generic,
TypeVar,
overload,
AbstractSet as Set,
AsyncGenerator as AsyncGenerator,
AsyncIterable as AsyncIterable,
Expand All @@ -21,7 +26,7 @@ from typing import (
MutableSequence as MutableSequence,
MutableSet as MutableSet,
Reversible as Reversible,
Sequence as Sequence,
# Sequence as Sequence,
Sized as Sized,
ValuesView as ValuesView,
)
Expand Down Expand Up @@ -53,3 +58,19 @@ __all__ = [
"MutableSequence",
"ByteString",
]

_T_co = TypeVar("_T_co", covariant=True) # Any type covariant containers.

class Sequence(Collection[_T_co], Reversible[_T_co], Generic[_T_co]):
@overload
@abstractmethod
def __getitem__(self, i: int) -> _T_co: ...
@overload
@abstractmethod
def __getitem__(self, s: slice) -> Sequence[_T_co]: ...
# Mixin methods
def index(self, value: Any, start: int = ..., stop: int = ...) -> int: ...
def count(self, value: Any) -> int: ...
def __contains__(self, x: object) -> bool: ...
def __iter__(self) -> Iterator[_T_co]: ...
def __reversed__(self) -> Iterator[_T_co]: ...
15 changes: 2 additions & 13 deletions stdlib/typing.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import collections # Needed by aliases like DefaultDict, see mypy issue 2986
import collections.abc
import sys
from abc import ABCMeta, abstractmethod
from types import BuiltinFunctionType, CodeType, FrameType, FunctionType, MethodType, ModuleType, TracebackType
Expand Down Expand Up @@ -304,19 +305,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]):
@overload
@abstractmethod
def __getitem__(self, i: int) -> _T_co: ...
@overload
@abstractmethod
def __getitem__(self, s: slice) -> Sequence[_T_co]: ...
# Mixin methods
def index(self, value: Any, start: int = ..., stop: int = ...) -> int: ...
def count(self, value: Any) -> int: ...
def __contains__(self, x: object) -> bool: ...
def __iter__(self) -> Iterator[_T_co]: ...
def __reversed__(self) -> Iterator[_T_co]: ...
Sequence = _Alias()

class MutableSequence(Sequence[_T], Generic[_T]):
@abstractmethod
Expand Down
0