mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 13:04:46 +08:00
Make all function annotations accessible from builtins complete
This commit is contained in:
@@ -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]):
|
||||
@@ -401,7 +403,7 @@ class bytearray(Sequence[int]):
|
||||
def translate(self, table: str) -> bytearray: ...
|
||||
def upper(self) -> bytearray: ...
|
||||
def zfill(self, width: int) -> bytearray: ...
|
||||
@staticmethod
|
||||
@classmethod
|
||||
def fromhex(self, x: str) -> bytearray: ...
|
||||
|
||||
def __len__(self) -> 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, exc: Any, tb: Any) -> bool: ...
|
||||
def flush(self) -> None: ...
|
||||
def fileno(self) -> int: ...
|
||||
def isatty(self) -> bool: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Dict, Set, Union, Tuple
|
||||
from typing import Any, Dict, Set, Union, Tuple, List
|
||||
import _weakrefset
|
||||
|
||||
# mypy has special processing for ABCMeta and abstractmethod.
|
||||
@@ -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: List[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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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, value: Any, traceback: Any) -> bool: ...
|
||||
|
||||
class BinaryIO(IO[bytes]):
|
||||
# TODO readinto
|
||||
|
||||
Reference in New Issue
Block a user