Skip to content

Commit a946304

Browse files
committed
Merge pull request #113 from ddfisher/master
Make all function annotations accessible from builtins complete
2 parents 35c3917 + 44d2780 commit a946304

File tree

7 files changed

+29
-25
lines changed

7 files changed

+29
-25
lines changed

stdlib/2.7/__builtin__.pyi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ class type:
4949
@overload
5050
def __init__(self, name: str, bases: Tuple[type, ...], dict: Dict[str, Any]) -> None: ...
5151
# TODO: __new__ may have to be special and not a static method.
52-
@staticmethod
52+
@overload
53+
def __new__(cls, o: object) -> type: ...
54+
@overload
5355
def __new__(cls, name: str, bases: Tuple[type, ...], namespace: Dict[str, Any]) -> type: ...
5456

5557
class int(SupportsInt, SupportsFloat, SupportsAbs[int]):
@@ -402,7 +404,7 @@ class bytearray(Sequence[int]):
402404
def upper(self) -> bytearray: ...
403405
def zfill(self, width: int) -> bytearray: ...
404406
@staticmethod
405-
def fromhex(self, x: str) -> bytearray: ...
407+
def fromhex(x: str) -> bytearray: ...
406408

407409
def __len__(self) -> int: ...
408410
def __iter__(self) -> Iterator[int]: ...
@@ -858,7 +860,7 @@ class file(BinaryIO):
858860
def __iter__(self) -> Iterator[str]: ...
859861
def read(self, n: int = ...) -> str: ...
860862
def __enter__(self) -> BinaryIO: ...
861-
def __exit__(self, typ, exc, tb) -> bool: ...
863+
def __exit__(self, t: type = None, exc: BaseException = None, tb: Any = None) -> bool: ...
862864
def flush(self) -> None: ...
863865
def fileno(self) -> int: ...
864866
def isatty(self) -> bool: ...

stdlib/2.7/_weakrefset.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ from typing import Iterator, Any
22

33
class WeakSet:
44
def __iter__(self) -> Iterator[Any]: ...
5-
def add(self, *args, **kwargs) -> Any: ...
5+
def add(self, *args: Any, **kwargs: Any) -> Any: ...

stdlib/2.7/abc.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ WeakSet = ... # type: _weakrefset.WeakSet
77
_InstanceType = ... # type: type
88
types = ... # type: module
99

10-
def abstractmethod(funcobj) -> Any: ...
10+
def abstractmethod(funcobj: Any) -> Any: ...
1111

1212
class ABCMeta(type):
1313
# TODO: FrozenSet
@@ -18,10 +18,10 @@ class ABCMeta(type):
1818
_abc_negative_cache = ... # type: _weakrefset.WeakSet
1919
_abc_negative_cache_version = ... # type: int
2020
_abc_registry = ... # type: _weakrefset.WeakSet
21-
def __init__(self, name, bases, namespace: Dict[Any, Any]) -> None: ...
22-
def __instancecheck__(cls: "ABCMeta", instance) -> Any: ...
23-
def __subclasscheck__(cls: "ABCMeta", subclass) -> Any: ...
24-
def _dump_registry(cls: "ABCMeta", *args, **kwargs) -> None: ...
21+
def __init__(self, name: str, bases: Tuple[type, ...], namespace: Dict[Any, Any]) -> None: ...
22+
def __instancecheck__(cls: "ABCMeta", instance: Any) -> Any: ...
23+
def __subclasscheck__(cls: "ABCMeta", subclass: Any) -> Any: ...
24+
def _dump_registry(cls: "ABCMeta", *args: Any, **kwargs: Any) -> None: ...
2525
# TODO: subclass: Union["ABCMeta", type, Tuple[type, ...]]
2626
def register(cls: "ABCMeta", subclass: Any) -> None: ...
2727

@@ -30,7 +30,7 @@ class _C:
3030

3131
# TODO: The real abc.abstractproperty inherits from "property".
3232
class abstractproperty(object):
33-
def __new__(cls, func): ...
33+
def __new__(cls, func: Any) -> Any: ...
3434
__doc__ = ... # type: str
3535
__isabstractmethod__ = ... # type: bool
3636
doc = ... # type: Any

stdlib/2.7/typing.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ NamedTuple = object()
2020

2121
class TypeAlias:
2222
# Class for defining generic aliases for library types.
23-
def __init__(self, target_type) -> None: ...
24-
def __getitem__(self, typeargs): ...
23+
def __init__(self, target_type: type) -> None: ...
24+
def __getitem__(self, typeargs: Any) -> Any: ...
2525

2626
Union = TypeAlias(object)
2727
Optional = TypeAlias(object)
@@ -84,7 +84,7 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):
8484
def send(self, value: _T_contra) -> _T_co:...
8585

8686
@abstractmethod
87-
def throw(self, typ: BaseException, val: Any=None, tb=None) -> None:...
87+
def throw(self, typ: BaseException, val: Any = None, tb: Any = None) -> None:...
8888

8989
@abstractmethod
9090
def close(self) -> None:...
@@ -227,7 +227,7 @@ class IO(Iterable[AnyStr], Generic[AnyStr]):
227227
@abstractmethod
228228
def __enter__(self) -> 'IO[AnyStr]': ...
229229
@abstractmethod
230-
def __exit__(self, type, value, traceback) -> bool: ...
230+
def __exit__(self, t: type, value: Any, traceback: Any) -> bool: ...
231231

232232
class BinaryIO(IO[str]):
233233
# TODO readinto

stdlib/3/builtins.pyi

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ class type:
4848
def __init__(self, o: object) -> None: ...
4949
@overload
5050
def __init__(self, name: str, bases: Tuple[type, ...], dict: Dict[str, Any]) -> None: ...
51-
@staticmethod
51+
@overload
52+
def __new__(cls, o: object) -> type: ...
53+
@overload
5254
def __new__(cls, name: str, bases: Tuple[type, ...], namespace: Dict[str, Any]) -> type: ...
5355

5456
class int(SupportsInt, SupportsFloat, SupportsAbs[int]):
@@ -224,10 +226,10 @@ class str(Sequence[str]):
224226
def zfill(self, width: int) -> str: ...
225227
@staticmethod
226228
@overload
227-
def maketrans(self, x: Union[Dict[int, Any], Dict[str, Any]]) -> Dict[int, Any]: ...
229+
def maketrans(x: Union[Dict[int, Any], Dict[str, Any]]) -> Dict[int, Any]: ...
228230
@staticmethod
229231
@overload
230-
def maketrans(self, x: str, y: str, z: str = ...) -> Dict[int, Any]: ...
232+
def maketrans(x: str, y: str, z: str = ...) -> Dict[int, Any]: ...
231233

232234
def __getitem__(self, i: Union[int, slice]) -> str: ...
233235
def __add__(self, s: str) -> str: ...
@@ -408,7 +410,7 @@ class bytearray(MutableSequence[int], ByteString):
408410

409411
class memoryview():
410412
# TODO arg can be any obj supporting the buffer protocol
411-
def __init__(self, bytearray) -> None: ...
413+
def __init__(self, b: bytearray) -> None: ...
412414

413415
class bool(int, SupportsInt, SupportsFloat):
414416
def __init__(self, o: object = ...) -> None: ...

stdlib/3/io.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class BytesIO(BinaryIO):
9090

9191
def __iter__(self) -> Iterator[bytes]: ...
9292
def __enter__(self) -> 'BytesIO': ...
93-
def __exit__(self, type, value, traceback) -> bool: ...
93+
def __exit__(self, t: type = None, value: BaseException = None, traceback: Any = None) -> bool: ...
9494

9595
class StringIO(TextIO):
9696
def __init__(self, initial_value: str = ...,
@@ -117,7 +117,7 @@ class StringIO(TextIO):
117117

118118
def __iter__(self) -> Iterator[str]: ...
119119
def __enter__(self) -> 'StringIO': ...
120-
def __exit__(self, type, value, traceback) -> bool: ...
120+
def __exit__(self, t: type = None, value: BaseException = None, traceback: Any = None) -> bool: ...
121121

122122
class TextIOWrapper(TextIO):
123123
# TODO: This is actually a base class of _io._TextIOBase.
@@ -147,4 +147,4 @@ class TextIOWrapper(TextIO):
147147

148148
def __iter__(self) -> Iterator[str]: ...
149149
def __enter__(self) -> StringIO: ...
150-
def __exit__(self, type, value, traceback) -> bool: ...
150+
def __exit__(self, t: type = None, value: BaseException = None, traceback: Any = None) -> bool: ...

stdlib/3/typing.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ no_type_check = object()
2121

2222
class TypeAlias:
2323
# Class for defining generic aliases for library types.
24-
def __init__(self, target_type) -> None: ...
25-
def __getitem__(self, typeargs): ...
24+
def __init__(self, target_type: type) -> None: ...
25+
def __getitem__(self, typeargs: Any) -> Any: ...
2626

2727
Union = TypeAlias(object)
2828
Optional = TypeAlias(object)
@@ -102,7 +102,7 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):
102102
def send(self, value: _T_contra) -> _T_co:...
103103

104104
@abstractmethod
105-
def throw(self, typ: BaseException, val: Any=None, tb=None) -> None:...
105+
def throw(self, typ: BaseException, val: Any = None, tb: Any = None) -> None:...
106106

107107
@abstractmethod
108108
def close(self) -> None:...
@@ -284,7 +284,7 @@ class IO(Iterable[AnyStr], Generic[AnyStr]):
284284
@abstractmethod
285285
def __enter__(self) -> 'IO[AnyStr]': ...
286286
@abstractmethod
287-
def __exit__(self, type, value, traceback) -> bool: ...
287+
def __exit__(self, t: type = None, value: BaseException = None, traceback: Any = None) -> bool: ...
288288

289289
class BinaryIO(IO[bytes]):
290290
# TODO readinto

0 commit comments

Comments
 (0)