diff --git a/stdlib/2.7/__builtin__.pyi b/stdlib/2.7/__builtin__.pyi index 69a37feb9..1abfaf00f 100644 --- a/stdlib/2.7/__builtin__.pyi +++ b/stdlib/2.7/__builtin__.pyi @@ -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: ... diff --git a/stdlib/2.7/_weakrefset.pyi b/stdlib/2.7/_weakrefset.pyi index a3de693e6..d0689f16d 100644 --- a/stdlib/2.7/_weakrefset.pyi +++ b/stdlib/2.7/_weakrefset.pyi @@ -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: ... diff --git a/stdlib/2.7/abc.pyi b/stdlib/2.7/abc.pyi index 66f7183b4..0eb26f018 100644 --- a/stdlib/2.7/abc.pyi +++ b/stdlib/2.7/abc.pyi @@ -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 diff --git a/stdlib/2.7/typing.pyi b/stdlib/2.7/typing.pyi index a04ad24d5..b9384b917 100644 --- a/stdlib/2.7/typing.pyi +++ b/stdlib/2.7/typing.pyi @@ -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 diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index 505702f58..0eb1bc492 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -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: ... diff --git a/stdlib/3/io.pyi b/stdlib/3/io.pyi index ca410f0ab..2cc7ee999 100644 --- a/stdlib/3/io.pyi +++ b/stdlib/3/io.pyi @@ -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: ... diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index 1f31e8aa0..a2bcc4350 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -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