mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-03-06 23:24:25 +08:00
Update a bunch of stubs
This commit is contained in:
@@ -1,14 +1,19 @@
|
||||
"""Stub file for the '_functools' module."""
|
||||
|
||||
from typing import Any, Callable, Iterator, Optional, TypeVar, Tuple
|
||||
from typing import Any, Callable, Iterator, Optional, TypeVar, Tuple, overload
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
@overload
|
||||
def reduce(function: Callable[[_T, _T], _T],
|
||||
sequence: Iterator[_T], initial=Optional[_T]) -> _T: ...
|
||||
sequence: Iterator[_T]) -> _T: ...
|
||||
@overload
|
||||
def reduce(function: Callable[[_T, _T], _T],
|
||||
sequence: Iterator[_T], initial: _T) -> _T: ...
|
||||
|
||||
class partial(object):
|
||||
func = ... # type: Callable[..., Any]
|
||||
args = ... # type: Tuple[Any]
|
||||
args = ... # type: Tuple[Any, ...]
|
||||
keywords = ... # type: Dict[str, Any]
|
||||
def __init__(self, func: Callable[..., Any], *args, **kwargs) -> None: ...
|
||||
def __call__(self, *args, **kwargs) -> Any: ...
|
||||
def __init__(self, func: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ...
|
||||
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
from typing import Optional, Union, Any
|
||||
from typing import Tuple
|
||||
|
||||
# Actually Tuple[(int,) * 625]
|
||||
_State = Tuple[int, ...]
|
||||
|
||||
class Random(object):
|
||||
def __init__(self, seed: Optional[Union[int, Any]] = ..., object = ...) -> None: ...
|
||||
def getstate(self) -> tuple: ...
|
||||
def setstate(self, state: tuple) -> None: ...
|
||||
def __init__(self, seed: object = None) -> None: ...
|
||||
def seed(self, x: object = None) -> None: ...
|
||||
def getstate(self) -> _State: ...
|
||||
def setstate(self, state: _State) -> None: ...
|
||||
def random(self) -> float: ...
|
||||
def getrandbits(self, k: int) -> int: ...
|
||||
def jumpahead(self, i: int) -> None: ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Stubs for builtins (Python 2.7)
|
||||
|
||||
from typing import (
|
||||
Optional, TypeVar, Iterator, Iterable, overload,
|
||||
TypeVar, Iterator, Iterable, overload,
|
||||
Sequence, Mapping, Tuple, List, Any, Dict, Callable, Generic, Set,
|
||||
AbstractSet, Sized, Reversible, SupportsInt, SupportsFloat, SupportsAbs,
|
||||
SupportsRound, IO, BinaryIO, Union, AnyStr, MutableSequence, MutableMapping,
|
||||
@@ -496,6 +496,7 @@ class list(MutableSequence[_T], Reversible[_T], Generic[_T]):
|
||||
def __delitem__(self, i: Union[int, slice]) -> None: ...
|
||||
def __delslice(self, start: int, stop: int) -> None: ...
|
||||
def __add__(self, x: List[_T]) -> List[_T]: ...
|
||||
def __iadd__(self, x: Iterable[_T]) -> List[_T]: ...
|
||||
def __mul__(self, n: int) -> List[_T]: ...
|
||||
def __rmul__(self, n: int) -> List[_T]: ...
|
||||
def __contains__(self, o: object) -> bool: ...
|
||||
|
||||
@@ -1,38 +1,50 @@
|
||||
# Stubs for cStringIO (Python 2.7)
|
||||
# See https://docs.python.org/2/library/stringio.html
|
||||
|
||||
from typing import IO, List, Iterable, Iterator, Any, Union
|
||||
from typing import overload, IO, List, Iterable, Iterator, Union
|
||||
from types import TracebackType
|
||||
|
||||
class StringIO(IO[str]):
|
||||
softspace = ... # type: int
|
||||
# TODO the typing.IO[] generics should be split into input and output.
|
||||
|
||||
def __init__(self, s: str = None) -> None: ...
|
||||
class InputType(IO[str], Iterator[str]):
|
||||
def getvalue(self) -> str: ...
|
||||
def close(self) -> None: ...
|
||||
@property
|
||||
def closed(self) -> bool: ...
|
||||
def fileno(self) -> int: ...
|
||||
def flush(self) -> None: ...
|
||||
def isatty(self) -> bool: ...
|
||||
def read(self, size: int = -1) -> str: ...
|
||||
def readable(self) -> bool: ...
|
||||
def readline(self, size: int = -1) -> str: ...
|
||||
def readlines(self, hint: int = -1) -> List[str]: ...
|
||||
def seek(self, offset: int, whence: int = ...) -> None: ...
|
||||
def seekable(self) -> bool: ...
|
||||
def tell(self) -> int: ...
|
||||
def truncate(self, size: int = None) -> int:
|
||||
raise IOError()
|
||||
def writable(self) -> bool: ...
|
||||
def __next__(self) -> str: ...
|
||||
def __enter__(self) -> Any: ...
|
||||
def __exit__(self, exc_type: type, exc_val: Any, exc_tb: Any) -> Any: ...
|
||||
# The C extension actually returns an "InputType".
|
||||
def __iter__(self) -> Iterator[str]: ...
|
||||
# only StringO:
|
||||
def truncate(self, size: int = ...) -> None: ...
|
||||
def __iter__(self) -> 'InputType': ...
|
||||
def next(self) -> str: ...
|
||||
def reset(self) -> None: ...
|
||||
|
||||
class OutputType(IO[str], Iterator[str]):
|
||||
@property
|
||||
def softspace(self) -> int: ...
|
||||
def getvalue(self) -> str: ...
|
||||
def close(self) -> None: ...
|
||||
@property
|
||||
def closed(self) -> bool: ...
|
||||
def flush(self) -> None: ...
|
||||
def isatty(self) -> bool: ...
|
||||
def read(self, size: int = -1) -> str: ...
|
||||
def readline(self, size: int = -1) -> str: ...
|
||||
def readlines(self, hint: int = -1) -> List[str]: ...
|
||||
def seek(self, offset: int, whence: int = ...) -> None: ...
|
||||
def tell(self) -> int: ...
|
||||
def truncate(self, size: int = ...) -> None: ...
|
||||
def __iter__(self) -> 'OutputType': ...
|
||||
def next(self) -> str: ...
|
||||
def reset(self) -> None: ...
|
||||
def write(self, b: Union[str, unicode]) -> None: ...
|
||||
def writelines(self, lines: Iterable[Union[str, unicode]]) -> None: ...
|
||||
|
||||
InputType = StringIO
|
||||
OutputType = StringIO
|
||||
@overload
|
||||
def StringIO() -> OutputType: ...
|
||||
@overload
|
||||
def StringIO(s: str) -> InputType: ...
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
from typing import Callable, Any, Tuple, Union
|
||||
from types import FrameType
|
||||
|
||||
SIG_DFL = ... # type: long
|
||||
SIG_IGN = ... # type: long
|
||||
ITIMER_REAL = ... # type: long
|
||||
ITIMER_VIRTUAL = ... # type: long
|
||||
ITIMER_PROF = ... # type: long
|
||||
SIG_DFL = ... # type: int
|
||||
SIG_IGN = ... # type: int
|
||||
ITIMER_REAL = ... # type: int
|
||||
ITIMER_VIRTUAL = ... # type: int
|
||||
ITIMER_PROF = ... # type: int
|
||||
|
||||
SIGABRT = ... # type: int
|
||||
SIGALRM = ... # type: int
|
||||
@@ -43,24 +44,19 @@ SIGXCPU = ... # type: int
|
||||
SIGXFSZ = ... # type: int
|
||||
NSIG = ... # type: int
|
||||
|
||||
# Python 3 only:
|
||||
CTRL_C_EVENT = 0
|
||||
CTRL_BREAK_EVENT = 0
|
||||
GSIG = 0
|
||||
|
||||
class ItimerError(IOError): ...
|
||||
|
||||
_HANDLER = Union[Callable[[int, Any], Any], int, None]
|
||||
_HANDLER = Union[Callable[[int, FrameType], None], int, None]
|
||||
|
||||
def alarm(time: int) -> int: ...
|
||||
def getsignal(signalnum: int) -> _HANDLER: ...
|
||||
def pause() -> None: ...
|
||||
def setitimer(which: int, seconds: float, interval: float = None) -> Tuple[float, float]: ...
|
||||
def getitimer(which: int) -> Tuple[float, float]: ...
|
||||
def set_wakeup_fd(fd: int) -> long: ...
|
||||
def set_wakeup_fd(fd: int) -> int: ...
|
||||
def siginterrupt(signalnum: int, flag: bool) -> None:
|
||||
raise RuntimeError()
|
||||
def signal(signalnum: int, handler: _HANDLER) -> None:
|
||||
def signal(signalnum: int, handler: _HANDLER) -> _HANDLER:
|
||||
raise RuntimeError()
|
||||
def default_int_handler(*args, **kwargs) -> Any:
|
||||
def default_int_handler(signum: int, frame: FrameType) -> None:
|
||||
raise KeyboardInterrupt()
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
"""Stubs for the 'sys' module."""
|
||||
|
||||
from typing import (
|
||||
IO, Union, List, Sequence, Any, Dict, Tuple, BinaryIO, overload
|
||||
IO, Union, List, Sequence, Any, Dict, Tuple, BinaryIO, Optional, Callable, overload
|
||||
)
|
||||
from types import FrameType, ModuleType, TracebackType
|
||||
|
||||
class _flags:
|
||||
bytes_warning = ... # type: int
|
||||
@@ -42,10 +43,10 @@ class _version_info(Tuple[int, int, int, str, int]):
|
||||
releaselevel = ''
|
||||
serial = 0
|
||||
|
||||
_mercurial = ... # type: tuple
|
||||
_mercurial = ... # type: Tuple[str, str, str]
|
||||
api_version = ... # type: int
|
||||
argv = ... # type: List[str]
|
||||
builtin_module_names = ... # type: List[str]
|
||||
builtin_module_names = ... # type: Tuple[str, ...]
|
||||
byteorder = ... # type: str
|
||||
copyright = ... # type: str
|
||||
dont_write_bytecode = ... # type: bool
|
||||
@@ -58,19 +59,33 @@ long_info = ... # type: object
|
||||
maxint = ... # type: int
|
||||
maxsize = ... # type: int
|
||||
maxunicode = ... # type: int
|
||||
modules = ... # type: Dict[str, module]
|
||||
modules = ... # type: Dict[str, ModuleType]
|
||||
path = ... # type: List[str]
|
||||
platform = ... # type: str
|
||||
prefix = ... # type: str
|
||||
py3kwarning = ... # type: bool
|
||||
__stderr__ = ... # type: IO[str]
|
||||
__stdin__ = ... # type: IO[str]
|
||||
__stdout__ = ... # type: IO[str]
|
||||
stderr = ... # type: IO[str]
|
||||
stdin = ... # type: IO[str]
|
||||
stdout = ... # type: IO[str]
|
||||
subversion = ... # type: tuple
|
||||
subversion = ... # type: Tuple[str, str, str]
|
||||
version = ... # type: str
|
||||
warnoptions = ... # type: object
|
||||
float_info = ... # type: _float_info
|
||||
version_info = ... # type: _version_info
|
||||
ps1 = ''
|
||||
ps2 = ''
|
||||
last_type = ... # type: type
|
||||
last_value = ... # type: BaseException
|
||||
last_traceback = ... # type: TracebackType
|
||||
# TODO precise types
|
||||
meta_path = ... # type: List[Any]
|
||||
path_hooks = ... # type: List[Any]
|
||||
path_importer_cache = ... # type: Dict[str, Any]
|
||||
displayhook = ... # type: Optional[Callable[[int], None]]
|
||||
excepthook = ... # type: Optional[Callable[[type, BaseException, TracebackType], None]]
|
||||
|
||||
class _WindowsVersionType:
|
||||
major = ... # type: Any
|
||||
@@ -83,17 +98,17 @@ class _WindowsVersionType:
|
||||
suite_mask = ... # type: Any
|
||||
product_type = ... # type: Any
|
||||
|
||||
def getwindowsversion() -> _WindowsVersionType: ... # TODO return type
|
||||
def getwindowsversion() -> _WindowsVersionType: ...
|
||||
|
||||
def _clear_type_cache() -> None: ...
|
||||
def _current_frames() -> Dict[int, Any]: ...
|
||||
def _getframe(depth: int = ...) -> Any: ... # TODO: Return FrameObject
|
||||
def _current_frames() -> Dict[int, FrameType]: ...
|
||||
def _getframe(depth: int = ...) -> FrameType: ...
|
||||
def call_tracing(fn: Any, args: Any) -> Any: ...
|
||||
def displayhook(value: int) -> None: ... # value might be None
|
||||
def excepthook(type_: type, value: BaseException, traceback: Any) -> None: ... # TODO traceback type
|
||||
def __displayhook__(value: int) -> None: ...
|
||||
def __excepthook__(type_: type, value: BaseException, traceback: TracebackType) -> None: ...
|
||||
def exc_clear() -> None:
|
||||
raise DeprecationWarning()
|
||||
def exc_info() -> Tuple[type, Any, Any]: ... # TODO traceback type
|
||||
def exc_info() -> Tuple[type, BaseException, TracebackType]: ...
|
||||
def exit(arg: int = ...) -> None:
|
||||
raise SystemExit()
|
||||
def getcheckinterval() -> int: ... # deprecated
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Stubs for the 'unicodedata' module."""
|
||||
|
||||
from typing import Any, TypeVar, Union, Optional
|
||||
from typing import Any, TypeVar, Union
|
||||
|
||||
ucd_3_2_0 = ... # type: UCD
|
||||
unidata_version = ... # type: str
|
||||
@@ -12,29 +12,29 @@ _default = TypeVar("_default")
|
||||
def bidirectional(unichr: unicode) -> str: ...
|
||||
def category(unichr: unicode) -> str: ...
|
||||
def combining(unichr: unicode) -> int: ...
|
||||
def decimal(chr: unicode, default=_default) -> Union[int, _default]: ...
|
||||
def decimal(chr: unicode, default: _default = ...) -> Union[int, _default]: ...
|
||||
def decomposition(unichr: unicode) -> str: ...
|
||||
def digit(chr: unicode, default=_default) -> Union[int, _default]: ...
|
||||
def digit(chr: unicode, default: _default = ...) -> Union[int, _default]: ...
|
||||
def east_asian_width(unichr: unicode): str
|
||||
def lookup(name: str): unicode
|
||||
def mirrored(unichr: unicode): int
|
||||
def name(chr: unicode, default=_default) -> Union[str, _default]: ...
|
||||
def name(chr: unicode, default: _default = ...) -> Union[str, _default]: ...
|
||||
def normalize(form: str, unistr: unicode) -> unicode: ...
|
||||
def numeric(chr, default=_default) -> Union[float, _default]: ...
|
||||
def numeric(chr, default: _default = ...) -> Union[float, _default]: ...
|
||||
|
||||
class UCD(object):
|
||||
unidata_version = ... # type: str
|
||||
# The methods below are constructed from the same array in C
|
||||
# (unicodedata_functions) and hence identical to the methods above.
|
||||
def bidirectional(unichr: unicode) -> str: ...
|
||||
def category(unichr: unicode) -> str: ...
|
||||
def combining(unichr: unicode) -> int: ...
|
||||
def decimal(chr: unicode, default=_default) -> Union[int, _default]: ...
|
||||
def decomposition(unichr: unicode) -> str: ...
|
||||
def digit(chr: unicode, default=_default) -> Union[int, _default]: ...
|
||||
def east_asian_width(unichr: unicode): str
|
||||
def lookup(name: str): unicode
|
||||
def mirrored(unichr: unicode): int
|
||||
def name(chr: unicode, default=_default) -> Union[str, _default]: ...
|
||||
def normalize(form: str, unistr: unicode) -> unicode: ...
|
||||
def numeric(chr, default=_default) -> Union[float, _default]: ...
|
||||
def bidirectional(self, unichr: unicode) -> str: ...
|
||||
def category(self, unichr: unicode) -> str: ...
|
||||
def combining(self, unichr: unicode) -> int: ...
|
||||
def decimal(self, chr: unicode, default: _default = ...) -> Union[int, _default]: ...
|
||||
def decomposition(self, unichr: unicode) -> str: ...
|
||||
def digit(self, chr: unicode, default: _default = ...) -> Union[int, _default]: ...
|
||||
def east_asian_width(self, unichr: unicode): str
|
||||
def lookup(self, name: str): unicode
|
||||
def mirrored(self, unichr: unicode): int
|
||||
def name(self, chr: unicode, default: _default = ...) -> Union[str, _default]: ...
|
||||
def normalize(self, form: str, unistr: unicode) -> unicode: ...
|
||||
def numeric(self, chr: unicode, default: _default = ...) -> Union[float, _default]: ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Stub file for the 'zipimport' module."""
|
||||
|
||||
from typing import Dict, Optional
|
||||
from types import CodeType
|
||||
from types import CodeType, ModuleType
|
||||
|
||||
class ZipImportError(ImportError):
|
||||
pass
|
||||
@@ -14,12 +14,12 @@ class zipimporter(object):
|
||||
_files = ... # type: Dict[str, tuple]
|
||||
def __init__(self, path: str) -> None:
|
||||
raise ZipImportError
|
||||
def find_module(self, fullname: str, path: str = ...) -> Optional[zipimporter]: ...
|
||||
def get_code(self, fullname: str) -> types.CodeType: ...
|
||||
def find_module(self, fullname: str, path: str = ...) -> Optional['zipimporter']: ...
|
||||
def get_code(self, fullname: str) -> CodeType: ...
|
||||
def get_data(self, fullname: str) -> str:
|
||||
raise IOError
|
||||
def get_filename(self, fullname: str) -> str: ...
|
||||
def get_source(self, fullname: str) -> str: ...
|
||||
def is_package(self, fullname: str) -> bool: ...
|
||||
def load_module(self, fullname: str) -> module: ...
|
||||
def load_module(self, fullname: str) -> ModuleType: ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user