Skip to content

Dedicated TypeVar for type.__subclasses__ #639

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

Merged
merged 6 commits into from
Oct 30, 2016
Merged
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
5 changes: 3 additions & 2 deletions stdlib/2/__builtin__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Python 3, and stub files conform to Python 3 syntax.

from typing import (
TypeVar, Iterator, Iterable, overload, Type,
TypeVar, Iterator, Iterable, overload,
Sequence, Mapping, Tuple, List, Any, Dict, Callable, Generic, Set,
AbstractSet, Sized, Reversible, SupportsInt, SupportsFloat, SupportsAbs,
SupportsRound, IO, BinaryIO, Union, AnyStr, MutableSequence, MutableMapping,
Expand All @@ -21,6 +21,7 @@ _T1 = TypeVar('_T1')
_T2 = TypeVar('_T2')
_T3 = TypeVar('_T3')
_T4 = TypeVar('_T4')
_TT = TypeVar('_TT', bound='type')

class staticmethod: pass # Special, only valid as a decorator.
class classmethod: pass # Special, only valid as a decorator.
Expand Down Expand Up @@ -60,7 +61,7 @@ class type:
# Note: the documentation doesnt specify what the return type is, the standard
# implementation seems to be returning a list.
def mro(self) -> List[type]: ...
def __subclasses__(self: Type[_T]) -> List[Type[_T]]: ...
def __subclasses__(self: _TT) -> List[_TT]: ...

class int(SupportsInt, SupportsFloat, SupportsAbs[int]):
@overload
Expand Down
5 changes: 3 additions & 2 deletions stdlib/3/builtins.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Stubs for builtins (Python 3)

from typing import (
TypeVar, Iterator, Iterable, overload, Type,
TypeVar, Iterator, Iterable, overload,
Sequence, MutableSequence, Mapping, MutableMapping, Tuple, List, Any, Dict, Callable, Generic,
Set, AbstractSet, MutableSet, Sized, Reversible, SupportsInt, SupportsFloat, SupportsBytes,
SupportsAbs, SupportsRound, IO, Union, ItemsView, KeysView, ValuesView, ByteString, Optional
Expand All @@ -22,6 +22,7 @@ _T1 = TypeVar('_T1')
_T2 = TypeVar('_T2')
_T3 = TypeVar('_T3')
_T4 = TypeVar('_T4')
_TT = TypeVar('_TT', bound='type')

class staticmethod: pass # Special, only valid as a decorator.
class classmethod: pass # Special, only valid as a decorator.
Expand Down Expand Up @@ -57,7 +58,7 @@ class type:
@overload
def __new__(cls, name: str, bases: Tuple[type, ...], namespace: Dict[str, Any]) -> type: ...
def __call__(self, *args: Any, **kwds: Any) -> Any: ...
def __subclasses__(self: Type[_T]) -> List[Type[_T]]: ...
def __subclasses__(self: _TT) -> List[_TT]: ...
# Note: the documentation doesnt specify what the return type is, the standard
# implementation seems to be returning a list.
def mro(self) -> List[type]: ...
Expand Down