Merge pull request #113 from ddfisher/master

Make all function annotations accessible from builtins complete
This commit is contained in:
Guido van Rossum
2016-03-11 16:49:23 -08:00
7 changed files with 29 additions and 25 deletions

View File

@@ -49,7 +49,9 @@ class type:
@overload
def __init__(self, name: str, bases: Tuple[type, ...], dict: Dict[str, Any]) -> None: ...
# TODO: __new__ may have to be special and not a static method.
@staticmethod
@overload
def __new__(cls, o: object) -> type: ...
@overload
def __new__(cls, name: str, bases: Tuple[type, ...], namespace: Dict[str, Any]) -> type: ...
class int(SupportsInt, SupportsFloat, SupportsAbs[int]):
@@ -402,7 +404,7 @@ class bytearray(Sequence[int]):
def upper(self) -> bytearray: ...
def zfill(self, width: int) -> bytearray: ...
@staticmethod
def fromhex(self, x: str) -> bytearray: ...
def fromhex(x: str) -> bytearray: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[int]: ...
@@ -858,7 +860,7 @@ class file(BinaryIO):
def __iter__(self) -> Iterator[str]: ...
def read(self, n: int = ...) -> str: ...
def __enter__(self) -> BinaryIO: ...
def __exit__(self, typ, exc, tb) -> bool: ...
def __exit__(self, t: type = None, exc: BaseException = None, tb: Any = None) -> bool: ...
def flush(self) -> None: ...
def fileno(self) -> int: ...
def isatty(self) -> bool: ...

View File

@@ -2,4 +2,4 @@ from typing import Iterator, Any
class WeakSet:
def __iter__(self) -> Iterator[Any]: ...
def add(self, *args, **kwargs) -> Any: ...
def add(self, *args: Any, **kwargs: Any) -> Any: ...

View File

@@ -7,7 +7,7 @@ WeakSet = ... # type: _weakrefset.WeakSet
_InstanceType = ... # type: type
types = ... # type: module
def abstractmethod(funcobj) -> Any: ...
def abstractmethod(funcobj: Any) -> Any: ...
class ABCMeta(type):
# TODO: FrozenSet
@@ -18,10 +18,10 @@ class ABCMeta(type):
_abc_negative_cache = ... # type: _weakrefset.WeakSet
_abc_negative_cache_version = ... # type: int
_abc_registry = ... # type: _weakrefset.WeakSet
def __init__(self, name, bases, namespace: Dict[Any, Any]) -> None: ...
def __instancecheck__(cls: "ABCMeta", instance) -> Any: ...
def __subclasscheck__(cls: "ABCMeta", subclass) -> Any: ...
def _dump_registry(cls: "ABCMeta", *args, **kwargs) -> None: ...
def __init__(self, name: str, bases: Tuple[type, ...], namespace: Dict[Any, Any]) -> None: ...
def __instancecheck__(cls: "ABCMeta", instance: Any) -> Any: ...
def __subclasscheck__(cls: "ABCMeta", subclass: Any) -> Any: ...
def _dump_registry(cls: "ABCMeta", *args: Any, **kwargs: Any) -> None: ...
# TODO: subclass: Union["ABCMeta", type, Tuple[type, ...]]
def register(cls: "ABCMeta", subclass: Any) -> None: ...
@@ -30,7 +30,7 @@ class _C:
# TODO: The real abc.abstractproperty inherits from "property".
class abstractproperty(object):
def __new__(cls, func): ...
def __new__(cls, func: Any) -> Any: ...
__doc__ = ... # type: str
__isabstractmethod__ = ... # type: bool
doc = ... # type: Any

View File

@@ -20,8 +20,8 @@ NamedTuple = object()
class TypeAlias:
# Class for defining generic aliases for library types.
def __init__(self, target_type) -> None: ...
def __getitem__(self, typeargs): ...
def __init__(self, target_type: type) -> None: ...
def __getitem__(self, typeargs: Any) -> Any: ...
Union = TypeAlias(object)
Optional = TypeAlias(object)
@@ -84,7 +84,7 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):
def send(self, value: _T_contra) -> _T_co:...
@abstractmethod
def throw(self, typ: BaseException, val: Any=None, tb=None) -> None:...
def throw(self, typ: BaseException, val: Any = None, tb: Any = None) -> None:...
@abstractmethod
def close(self) -> None:...
@@ -227,7 +227,7 @@ class IO(Iterable[AnyStr], Generic[AnyStr]):
@abstractmethod
def __enter__(self) -> 'IO[AnyStr]': ...
@abstractmethod
def __exit__(self, type, value, traceback) -> bool: ...
def __exit__(self, t: type, value: Any, traceback: Any) -> bool: ...
class BinaryIO(IO[str]):
# TODO readinto

View File

@@ -48,7 +48,9 @@ class type:
def __init__(self, o: object) -> None: ...
@overload
def __init__(self, name: str, bases: Tuple[type, ...], dict: Dict[str, Any]) -> None: ...
@staticmethod
@overload
def __new__(cls, o: object) -> type: ...
@overload
def __new__(cls, name: str, bases: Tuple[type, ...], namespace: Dict[str, Any]) -> type: ...
class int(SupportsInt, SupportsFloat, SupportsAbs[int]):
@@ -224,10 +226,10 @@ class str(Sequence[str]):
def zfill(self, width: int) -> str: ...
@staticmethod
@overload
def maketrans(self, x: Union[Dict[int, Any], Dict[str, Any]]) -> Dict[int, Any]: ...
def maketrans(x: Union[Dict[int, Any], Dict[str, Any]]) -> Dict[int, Any]: ...
@staticmethod
@overload
def maketrans(self, x: str, y: str, z: str = ...) -> Dict[int, Any]: ...
def maketrans(x: str, y: str, z: str = ...) -> Dict[int, Any]: ...
def __getitem__(self, i: Union[int, slice]) -> str: ...
def __add__(self, s: str) -> str: ...
@@ -408,7 +410,7 @@ class bytearray(MutableSequence[int], ByteString):
class memoryview():
# TODO arg can be any obj supporting the buffer protocol
def __init__(self, bytearray) -> None: ...
def __init__(self, b: bytearray) -> None: ...
class bool(int, SupportsInt, SupportsFloat):
def __init__(self, o: object = ...) -> None: ...

View File

@@ -90,7 +90,7 @@ class BytesIO(BinaryIO):
def __iter__(self) -> Iterator[bytes]: ...
def __enter__(self) -> 'BytesIO': ...
def __exit__(self, type, value, traceback) -> bool: ...
def __exit__(self, t: type = None, value: BaseException = None, traceback: Any = None) -> bool: ...
class StringIO(TextIO):
def __init__(self, initial_value: str = ...,
@@ -117,7 +117,7 @@ class StringIO(TextIO):
def __iter__(self) -> Iterator[str]: ...
def __enter__(self) -> 'StringIO': ...
def __exit__(self, type, value, traceback) -> bool: ...
def __exit__(self, t: type = None, value: BaseException = None, traceback: Any = None) -> bool: ...
class TextIOWrapper(TextIO):
# TODO: This is actually a base class of _io._TextIOBase.
@@ -147,4 +147,4 @@ class TextIOWrapper(TextIO):
def __iter__(self) -> Iterator[str]: ...
def __enter__(self) -> StringIO: ...
def __exit__(self, type, value, traceback) -> bool: ...
def __exit__(self, t: type = None, value: BaseException = None, traceback: Any = None) -> bool: ...

View File

@@ -21,8 +21,8 @@ no_type_check = object()
class TypeAlias:
# Class for defining generic aliases for library types.
def __init__(self, target_type) -> None: ...
def __getitem__(self, typeargs): ...
def __init__(self, target_type: type) -> None: ...
def __getitem__(self, typeargs: Any) -> Any: ...
Union = TypeAlias(object)
Optional = TypeAlias(object)
@@ -102,7 +102,7 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):
def send(self, value: _T_contra) -> _T_co:...
@abstractmethod
def throw(self, typ: BaseException, val: Any=None, tb=None) -> None:...
def throw(self, typ: BaseException, val: Any = None, tb: Any = None) -> None:...
@abstractmethod
def close(self) -> None:...
@@ -284,7 +284,7 @@ class IO(Iterable[AnyStr], Generic[AnyStr]):
@abstractmethod
def __enter__(self) -> 'IO[AnyStr]': ...
@abstractmethod
def __exit__(self, type, value, traceback) -> bool: ...
def __exit__(self, t: type = None, value: BaseException = None, traceback: Any = None) -> bool: ...
class BinaryIO(IO[bytes]):
# TODO readinto