Improve __subclasses__() signature. Fixes python/mypy#2236.

This commit is contained in:
Guido van Rossum
2016-10-27 17:31:03 -07:00
parent cb97bb54c0
commit c3ddd3c5f2
2 changed files with 4 additions and 4 deletions

View File

@@ -4,7 +4,7 @@
# Python 3, and stub files conform to Python 3 syntax.
from typing import (
TypeVar, Iterator, Iterable, overload,
TypeVar, Iterator, Iterable, overload, Type,
Sequence, Mapping, Tuple, List, Any, Dict, Callable, Generic, Set,
AbstractSet, Sized, Reversible, SupportsInt, SupportsFloat, SupportsAbs,
SupportsRound, IO, BinaryIO, Union, AnyStr, MutableSequence, MutableMapping,
@@ -60,7 +60,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) -> List[type]: ...
def __subclasses__(self: Type[_T]) -> List[Type[_T]]: ...
class int(SupportsInt, SupportsFloat, SupportsAbs[int]):
@overload

View File

@@ -1,7 +1,7 @@
# Stubs for builtins (Python 3)
from typing import (
TypeVar, Iterator, Iterable, overload,
TypeVar, Iterator, Iterable, overload, Type,
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
@@ -57,7 +57,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) -> List[type]: ...
def __subclasses__(self: Type[_T]) -> List[Type[_T]]: ...
# Note: the documentation doesnt specify what the return type is, the standard
# implementation seems to be returning a list.
def mro(self) -> List[type]: ...