Skip to content

Make all function annotations accessible from builtins complete #113

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 3 commits into from
Mar 12, 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
8 changes: 5 additions & 3 deletions stdlib/2.7/__builtin__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down Expand Up @@ -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]: ...
Expand Down Expand Up @@ -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: ...
Expand Down
2 changes: 1 addition & 1 deletion stdlib/2.7/_weakrefset.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
12 changes: 6 additions & 6 deletions stdlib/2.7/abc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: ...

Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions stdlib/2.7/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:...
Expand Down Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions stdlib/3/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down Expand Up @@ -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: ...
Expand Down Expand Up @@ -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: ...
Expand Down
6 changes: 3 additions & 3 deletions stdlib/3/io.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ...,
Expand All @@ -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.
Expand Down Expand Up @@ -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: ...
8 changes: 4 additions & 4 deletions stdlib/3/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The typ arg can also be an exception instance (then I think no value is allowed and I'm not sure about the tb).


@abstractmethod
def close(self) -> None:...
Expand Down Expand Up @@ -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
Expand Down