mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Sync with typeshed @ 0af84cd9a0526aea30107ccddc89aa3c401279ca
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
git+https://github.com/python/mypy.git@master
|
||||
typed-ast>=1.0.4
|
||||
flake8==3.3.0
|
||||
flake8-bugbear>=17.3.0
|
||||
flake8-pyi>=17.1.0
|
||||
flake8==3.5.0
|
||||
flake8-bugbear==18.2.0
|
||||
flake8-pyi>=18.3.1
|
||||
|
||||
@@ -7,7 +7,7 @@ from typing import (
|
||||
TypeVar, Iterator, Iterable, NoReturn, overload,
|
||||
Sequence, Mapping, Tuple, List, Any, Dict, Callable, Generic, Set,
|
||||
AbstractSet, FrozenSet, Sized, Reversible, SupportsInt, SupportsFloat, SupportsAbs,
|
||||
SupportsRound, IO, BinaryIO, Union, AnyStr, MutableSequence, MutableMapping,
|
||||
SupportsComplex, SupportsRound, IO, BinaryIO, Union, AnyStr, MutableSequence, MutableMapping,
|
||||
MutableSet, ItemsView, KeysView, ValuesView, Optional, Container, Type
|
||||
)
|
||||
from abc import abstractmethod, ABCMeta
|
||||
@@ -187,6 +187,8 @@ class complex:
|
||||
def __init__(self, re: float = ..., im: float = ...) -> None: ...
|
||||
@overload
|
||||
def __init__(self, s: str) -> None: ...
|
||||
@overload
|
||||
def __init__(self, s: SupportsComplex) -> None: ...
|
||||
|
||||
@property
|
||||
def real(self) -> float: ...
|
||||
@@ -213,6 +215,7 @@ class complex:
|
||||
def __neg__(self) -> complex: ...
|
||||
def __pos__(self) -> complex: ...
|
||||
|
||||
def __complex__(self) -> complex: ...
|
||||
def __str__(self) -> str: ...
|
||||
def __abs__(self) -> float: ...
|
||||
def __hash__(self) -> int: ...
|
||||
@@ -653,7 +656,6 @@ class set(MutableSet[_T], Generic[_T]):
|
||||
def __lt__(self, s: AbstractSet[object]) -> bool: ...
|
||||
def __ge__(self, s: AbstractSet[object]) -> bool: ...
|
||||
def __gt__(self, s: AbstractSet[object]) -> bool: ...
|
||||
# TODO more set operations
|
||||
|
||||
class frozenset(AbstractSet[_T], Generic[_T]):
|
||||
@overload
|
||||
|
||||
@@ -75,8 +75,8 @@ class ArgumentParser:
|
||||
required: bool = ...,
|
||||
help: _Text = ...,
|
||||
metavar: Union[_Text, Tuple[_Text, ...]] = ...,
|
||||
dest: _Text = ...,
|
||||
version: _Text = ...) -> None: ... # weirdly documented
|
||||
dest: Optional[_Text] = ...,
|
||||
version: _Text = ...) -> Action: ...
|
||||
def parse_args(self, args: Optional[Sequence[_Text]] = ...,
|
||||
namespace: Optional[Namespace] = ...) -> Namespace: ...
|
||||
def add_subparsers(self, title: _Text = ...,
|
||||
@@ -120,11 +120,12 @@ class Action:
|
||||
nargs: Optional[Union[int, _Text]]
|
||||
const: Any
|
||||
default: Any
|
||||
type: Optional[Union[Callable[[str], Any], FileType]]
|
||||
type: Union[Callable[[str], Any], FileType, None]
|
||||
choices: Optional[Iterable[Any]]
|
||||
required: bool
|
||||
help: Optional[_Text]
|
||||
metavar: Optional[Union[_Text, Tuple[_Text, ...]]]
|
||||
metavar: Union[_Text, Tuple[_Text, ...]]
|
||||
|
||||
def __init__(self,
|
||||
option_strings: Sequence[_Text],
|
||||
dest: _Text = ...,
|
||||
@@ -171,8 +172,8 @@ class _ArgumentGroup:
|
||||
required: bool = ...,
|
||||
help: _Text = ...,
|
||||
metavar: Union[_Text, Tuple[_Text, ...]] = ...,
|
||||
dest: _Text = ...,
|
||||
version: _Text = ...) -> None: ...
|
||||
dest: Optional[_Text] = ...,
|
||||
version: _Text = ...) -> Action: ...
|
||||
def add_mutually_exclusive_group(self, required: bool = ...) -> _MutuallyExclusiveGroup: ...
|
||||
|
||||
class _MutuallyExclusiveGroup(_ArgumentGroup): ...
|
||||
|
||||
@@ -2,10 +2,11 @@ from typing import Tuple, Union, Optional, Any, Dict, overload
|
||||
|
||||
import os
|
||||
import select
|
||||
import socket
|
||||
import sys
|
||||
import time
|
||||
import warnings
|
||||
from socket import SocketType
|
||||
from typing import Optional
|
||||
|
||||
from errno import (EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL,
|
||||
ENOTCONN, ESHUTDOWN, EINTR, EISCONN, EBADF, ECONNABORTED,
|
||||
@@ -38,19 +39,20 @@ class dispatcher:
|
||||
connecting = ... # type: bool
|
||||
closing = ... # type: bool
|
||||
ignore_log_types = ... # type: frozenset[str]
|
||||
socket = ... # type: Optional[SocketType] # undocumented
|
||||
|
||||
def __init__(self, sock: Optional[socket.socket] = ..., map: _maptype = ...) -> None: ...
|
||||
def __init__(self, sock: Optional[SocketType] = ..., map: _maptype = ...) -> None: ...
|
||||
def add_channel(self, map: _maptype = ...) -> None: ...
|
||||
def del_channel(self, map: _maptype = ...) -> None: ...
|
||||
def create_socket(self, family: int, type: int) -> None: ...
|
||||
def set_socket(self, sock: socket.socket, map: _maptype = ...) -> None: ...
|
||||
def set_socket(self, sock: SocketType, map: _maptype = ...) -> None: ...
|
||||
def set_reuse_addr(self) -> None: ...
|
||||
def readable(self) -> bool: ...
|
||||
def writable(self) -> bool: ...
|
||||
def listen(self, backlog: int) -> None: ...
|
||||
def bind(self, address: Union[tuple, str]) -> None: ...
|
||||
def connect(self, address: Union[tuple, str]) -> None: ...
|
||||
def accept(self) -> Optional[Tuple[socket.socket, Any]]: ...
|
||||
def accept(self) -> Optional[Tuple[SocketType, Any]]: ...
|
||||
def send(self, data: bytes) -> int: ...
|
||||
def recv(self, buffer_size: int) -> bytes: ...
|
||||
def close(self) -> None: ...
|
||||
@@ -108,7 +110,7 @@ class dispatcher:
|
||||
def shutdown(self, how: int) -> None: ...
|
||||
|
||||
class dispatcher_with_send(dispatcher):
|
||||
def __init__(self, sock: socket.socket = ..., map: _maptype = ...) -> None: ...
|
||||
def __init__(self, sock: SocketType = ..., map: _maptype = ...) -> None: ...
|
||||
def initiate_send(self) -> None: ...
|
||||
def handle_write(self) -> None: ...
|
||||
# incompatible signature:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Stubs for ctypes
|
||||
|
||||
from typing import (
|
||||
Any, Callable, ClassVar, Iterable, List, Mapping, Optional, Sequence, Sized, Text, Tuple, Type,
|
||||
Generic, TypeVar, overload,
|
||||
Any, Callable, ClassVar, Iterator, Iterable, List, Mapping, Optional, Sequence, Sized, Text,
|
||||
Tuple, Type, Generic, TypeVar, overload,
|
||||
)
|
||||
from typing import Union as _UnionT
|
||||
import sys
|
||||
@@ -46,12 +46,11 @@ pydll: LibraryLoader[PyDLL] = ...
|
||||
pythonapi: PyDLL = ...
|
||||
|
||||
class _CDataMeta(type):
|
||||
# TODO The return type is not accurate. The method definition *should* look like this:
|
||||
# def __mul__(cls: Type[_CT], other: int) -> Type[Array[_CT]]: ...
|
||||
# but that is not valid, because technically a _CDataMeta might not be a Type[_CT].
|
||||
# This can never actually happen, because all _CDataMeta instances are _CData subclasses, but a typechecker doesn't know that.
|
||||
def __mul__(cls: _CDataMeta, other: int) -> Type[Array[_CT]]: ...
|
||||
def __rmul__(cls: _CDataMeta, other: int) -> Type[Array[_CT]]: ...
|
||||
# By default mypy complains about the following two methods, because strictly speaking cls
|
||||
# might not be a Type[_CT]. However this can never actually happen, because the only class that
|
||||
# uses _CDataMeta as its metaclass is _CData. So it's safe to ignore the errors here.
|
||||
def __mul__(cls: Type[_CT], other: int) -> Type[Array[_CT]]: ... # type: ignore
|
||||
def __rmul__(cls: Type[_CT], other: int) -> Type[Array[_CT]]: ... # type: ignore
|
||||
class _CData(metaclass=_CDataMeta):
|
||||
_b_base: int = ...
|
||||
_b_needsfree_: bool = ...
|
||||
@@ -63,7 +62,7 @@ class _CData(metaclass=_CDataMeta):
|
||||
@classmethod
|
||||
def from_address(cls: Type[_CT], address: int) -> _CT: ...
|
||||
@classmethod
|
||||
def from_param(cls: Type[_CT], obj: Any) -> _UnionT[_CT, _cparam]: ...
|
||||
def from_param(cls: Type[_CT], obj: Any) -> _UnionT[_CT, _CArgObject]: ...
|
||||
@classmethod
|
||||
def in_dll(cls: Type[_CT], library: CDLL, name: str) -> _CT: ...
|
||||
|
||||
@@ -80,7 +79,7 @@ _PF = _UnionT[
|
||||
]
|
||||
class _FuncPointer(_PointerLike, _CData):
|
||||
restype: _UnionT[Type[_CData], Callable[[int], None], None] = ...
|
||||
argtypes: Tuple[Type[_CData], ...] = ...
|
||||
argtypes: Sequence[Type[_CData]] = ...
|
||||
errcheck: _ECT = ...
|
||||
@overload
|
||||
def __init__(self, address: int) -> None: ...
|
||||
@@ -92,31 +91,40 @@ class _FuncPointer(_PointerLike, _CData):
|
||||
@overload
|
||||
def __init__(self, vtlb_index: int, name: str,
|
||||
paramflags: Tuple[_PF, ...] = ...,
|
||||
iid: _Pointer[c_int] = ...) -> None: ...
|
||||
iid: pointer[c_int] = ...) -> None: ...
|
||||
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||
|
||||
class ArgumentError(Exception): ...
|
||||
|
||||
|
||||
def CFUNCTYPE(restype: Type[_CData],
|
||||
def CFUNCTYPE(restype: Optional[Type[_CData]],
|
||||
*argtypes: Type[_CData],
|
||||
use_errno: bool = ...,
|
||||
use_last_error: bool = ...) -> Type[_FuncPointer]: ...
|
||||
if sys.platform == 'win32':
|
||||
def WINFUNCTYPE(restype: Type[_CData],
|
||||
def WINFUNCTYPE(restype: Optional[Type[_CData]],
|
||||
*argtypes: Type[_CData],
|
||||
use_errno: bool = ...,
|
||||
use_last_error: bool = ...) -> Type[_FuncPointer]: ...
|
||||
def PYFUNCTYPE(restype: Type[_CData],
|
||||
def PYFUNCTYPE(restype: Optional[Type[_CData]],
|
||||
*argtypes: Type[_CData]) -> Type[_FuncPointer]: ...
|
||||
|
||||
class _cparam: ...
|
||||
class _CArgObject: ...
|
||||
|
||||
# Any type that can be implicitly converted to c_void_p when passed as a C function argument.
|
||||
# (bytes is not included here, see below.)
|
||||
_CVoidPLike = _UnionT[_PointerLike, Array[Any], _CArgObject, int]
|
||||
# Same as above, but including types known to be read-only (i. e. bytes).
|
||||
# This distinction is not strictly necessary (ctypes doesn't differentiate between const
|
||||
# and non-const pointers), but it catches errors like memmove(b'foo', buf, 4)
|
||||
# when memmove(buf, b'foo', 4) was intended.
|
||||
_CVoidConstPLike = _UnionT[_CVoidPLike, bytes]
|
||||
|
||||
def addressof(obj: _CData) -> int: ...
|
||||
def alignment(obj_or_type: _UnionT[_CData, Type[_CData]]) -> int: ...
|
||||
def byref(obj: _CData, offset: int = ...) -> _cparam: ...
|
||||
def byref(obj: _CData, offset: int = ...) -> _CArgObject: ...
|
||||
_PT = TypeVar('_PT', bound=_PointerLike)
|
||||
def cast(obj: _UnionT[_CData, _cparam], type: Type[_PT]) -> _PT: ...
|
||||
def cast(obj: _UnionT[_CData, _CArgObject], type: Type[_PT]) -> _PT: ...
|
||||
def create_string_buffer(init_or_size: _UnionT[int, bytes],
|
||||
size: Optional[int] = ...) -> Array[c_char]: ...
|
||||
c_buffer = create_string_buffer
|
||||
@@ -130,13 +138,26 @@ if sys.platform == 'win32':
|
||||
def get_errno() -> int: ...
|
||||
if sys.platform == 'win32':
|
||||
def get_last_error() -> int: ...
|
||||
def memmove(dst: _UnionT[int, _CData],
|
||||
src: _UnionT[int, _CData],
|
||||
count: int) -> None: ...
|
||||
def memset(dst: _UnionT[int, _CData],
|
||||
c: int, count: int) -> None: ...
|
||||
def POINTER(type: Type[_CT]) -> Type[_Pointer[_CT]]: ...
|
||||
def pointer(obj: _CT) -> _Pointer[_CT]: ...
|
||||
def memmove(dst: _CVoidPLike, src: _CVoidConstPLike, count: int) -> None: ...
|
||||
def memset(dst: _CVoidPLike, c: int, count: int) -> None: ...
|
||||
def POINTER(type: Type[_CT]) -> Type[pointer[_CT]]: ...
|
||||
|
||||
# The real ctypes.pointer is a function, not a class. The stub version of pointer behaves like
|
||||
# ctypes._Pointer in that it is the base class for all pointer types. Unlike the real _Pointer,
|
||||
# it can be instantiated directly (to mimic the behavior of the real pointer function).
|
||||
class pointer(Generic[_CT], _PointerLike, _CData):
|
||||
_type_: ClassVar[Type[_CT]] = ...
|
||||
contents: _CT = ...
|
||||
def __init__(self, arg: _CT = ...) -> None: ...
|
||||
@overload
|
||||
def __getitem__(self, i: int) -> _CT: ...
|
||||
@overload
|
||||
def __getitem__(self, s: slice) -> List[_CT]: ...
|
||||
@overload
|
||||
def __setitem__(self, i: int, o: _CT) -> None: ...
|
||||
@overload
|
||||
def __setitem__(self, s: slice, o: Iterable[_CT]) -> None: ...
|
||||
|
||||
def resize(obj: _CData, size: int) -> None: ...
|
||||
if sys.version_info < (3,):
|
||||
def set_conversion_mode(encoding: str, errors: str) -> Tuple[str, str]: ...
|
||||
@@ -144,11 +165,11 @@ def set_errno(value: int) -> int: ...
|
||||
if sys.platform == 'win32':
|
||||
def set_last_error(value: int) -> int: ...
|
||||
def sizeof(obj_or_type: _UnionT[_CData, Type[_CData]]) -> int: ...
|
||||
def string_at(address: int, size: int = ...) -> bytes: ...
|
||||
def string_at(address: _CVoidConstPLike, size: int = ...) -> bytes: ...
|
||||
if sys.platform == 'win32':
|
||||
def WinError(code: Optional[int] = ...,
|
||||
desc: Optional[str] = ...) -> OSError: ...
|
||||
def wstring_at(address: int, size: int = ...) -> str: ...
|
||||
desc: Optional[str] = ...) -> WindowsError: ...
|
||||
def wstring_at(address: _CVoidConstPLike, size: int = ...) -> str: ...
|
||||
|
||||
class _SimpleCData(Generic[_T], _CData):
|
||||
value: _T = ...
|
||||
@@ -202,7 +223,7 @@ class c_bool(_SimpleCData[bool]):
|
||||
def __init__(self, value: bool) -> None: ...
|
||||
|
||||
if sys.platform == 'win32':
|
||||
class HRESULT(_SimpleCData[Any]): ... # TODO undocumented
|
||||
class HRESULT(_SimpleCData[int]): ... # TODO undocumented
|
||||
|
||||
class py_object(_SimpleCData[_T]): ...
|
||||
|
||||
@@ -224,32 +245,33 @@ class Structure(_StructUnionBase): pass
|
||||
class BigEndianStructure(Structure): pass
|
||||
class LittleEndianStructure(Structure): pass
|
||||
|
||||
class Array(Generic[_T], Sized, _CData):
|
||||
class Array(Generic[_T], _CData):
|
||||
_length_: ClassVar[int] = ...
|
||||
_type_: ClassVar[Type[_T]] = ...
|
||||
raw: bytes = ... # TODO only available with _T == c_char
|
||||
value: bytes = ... # TODO only available with _T == c_char
|
||||
def __init__(self, *args: _T) -> None: ...
|
||||
# TODO These methods cannot be annotated correctly at the moment.
|
||||
# All of these "Any"s stand for the array's element type, but it's not possible to use _T here,
|
||||
# because of a special feature of ctypes.
|
||||
# By default, when accessing an element of an Array[_T], the returned object has type _T.
|
||||
# However, when _T is a "simple type" like c_int, ctypes automatically "unboxes" the object
|
||||
# and converts it to the corresponding Python primitive. For example, when accessing an element
|
||||
# of an Array[c_int], a Python int object is returned, not a c_int.
|
||||
# This behavior does *not* apply to subclasses of "simple types".
|
||||
# If MyInt is a subclass of c_int, then accessing an element of an Array[MyInt] returns
|
||||
# a MyInt, not an int.
|
||||
# This special behavior is not easy to model in a stub, so for now all places where
|
||||
# the array element type would belong are annotated with Any instead.
|
||||
def __init__(self, *args: Any) -> None: ...
|
||||
@overload
|
||||
def __getitem__(self, i: int) -> _T: ...
|
||||
def __getitem__(self, i: int) -> Any: ...
|
||||
@overload
|
||||
def __getitem__(self, s: slice) -> List[_T]: ...
|
||||
def __getitem__(self, s: slice) -> List[Any]: ...
|
||||
@overload
|
||||
def __setitem__(self, i: int, o: _T) -> None: ...
|
||||
def __setitem__(self, i: int, o: Any) -> None: ...
|
||||
@overload
|
||||
def __setitem__(self, s: slice, o: Iterable[_T]) -> None: ...
|
||||
def __iter__(self) -> Iterable[_T]: ...
|
||||
|
||||
|
||||
class _Pointer(Generic[_T], _PointerLike, _CData):
|
||||
_type_: ClassVar[Type[_T]] = ...
|
||||
contents: _T = ...
|
||||
def __init__(self, arg: _T = ...) -> None: ...
|
||||
@overload
|
||||
def __getitem__(self, i: int) -> _T: ...
|
||||
@overload
|
||||
def __getitem__(self, s: slice) -> List[_T]: ...
|
||||
@overload
|
||||
def __setitem__(self, i: int, o: _T) -> None: ...
|
||||
@overload
|
||||
def __setitem__(self, s: slice, o: Iterable[_T]) -> None: ...
|
||||
def __setitem__(self, s: slice, o: Iterable[Any]) -> None: ...
|
||||
def __iter__(self) -> Iterator[Any]: ...
|
||||
# Can't inherit from Sized because the metaclass conflict between
|
||||
# Sized and _CData prevents using _CDataMeta.
|
||||
def __len__(self) -> int: ...
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
from ctypes import (
|
||||
_SimpleCData, Array, Structure, c_byte, c_char, c_char_p, c_double, c_float, c_int, c_long,
|
||||
c_longlong, c_short, c_uint, c_ulong, c_ulonglong, c_ushort, c_void_p, c_wchar, c_wchar_p,
|
||||
pointer,
|
||||
)
|
||||
|
||||
BYTE = c_byte
|
||||
WORD = c_ushort
|
||||
DWORD = c_ulong
|
||||
CHAR = c_char
|
||||
WCHAR = c_wchar
|
||||
UINT = c_uint
|
||||
INT = c_int
|
||||
DOUBLE = c_double
|
||||
FLOAT = c_float
|
||||
BOOLEAN = BYTE
|
||||
BOOL = c_long
|
||||
class VARIANT_BOOL(_SimpleCData[bool]): ...
|
||||
ULONG = c_ulong
|
||||
LONG = c_long
|
||||
USHORT = c_ushort
|
||||
SHORT = c_short
|
||||
LARGE_INTEGER = c_longlong
|
||||
_LARGE_INTEGER = c_longlong
|
||||
ULARGE_INTEGER = c_ulonglong
|
||||
_ULARGE_INTEGER = c_ulonglong
|
||||
|
||||
OLESTR = c_wchar_p
|
||||
LPOLESTR = c_wchar_p
|
||||
LPCOLESTR = c_wchar_p
|
||||
LPWSTR = c_wchar_p
|
||||
LPCWSTR = c_wchar_p
|
||||
LPSTR = c_char_p
|
||||
LPCSTR = c_char_p
|
||||
LPVOID = c_void_p
|
||||
LPCVOID = c_void_p
|
||||
|
||||
# These two types are pointer-sized unsigned and signed ints, respectively.
|
||||
# At runtime, they are either c_[u]long or c_[u]longlong, depending on the host's pointer size
|
||||
# (they are not really separate classes).
|
||||
class WPARAM(_SimpleCData[int]): ...
|
||||
class LPARAM(_SimpleCData[int]): ...
|
||||
|
||||
ATOM = WORD
|
||||
LANGID = WORD
|
||||
COLORREF = DWORD
|
||||
LGRPID = DWORD
|
||||
LCTYPE = DWORD
|
||||
LCID = DWORD
|
||||
|
||||
HANDLE = c_void_p
|
||||
HACCEL = HANDLE
|
||||
HBITMAP = HANDLE
|
||||
HBRUSH = HANDLE
|
||||
HCOLORSPACE = HANDLE
|
||||
HDC = HANDLE
|
||||
HDESK = HANDLE
|
||||
HDWP = HANDLE
|
||||
HENHMETAFILE = HANDLE
|
||||
HFONT = HANDLE
|
||||
HGDIOBJ = HANDLE
|
||||
HGLOBAL = HANDLE
|
||||
HHOOK = HANDLE
|
||||
HICON = HANDLE
|
||||
HINSTANCE = HANDLE
|
||||
HKEY = HANDLE
|
||||
HKL = HANDLE
|
||||
HLOCAL = HANDLE
|
||||
HMENU = HANDLE
|
||||
HMETAFILE = HANDLE
|
||||
HMODULE = HANDLE
|
||||
HMONITOR = HANDLE
|
||||
HPALETTE = HANDLE
|
||||
HPEN = HANDLE
|
||||
HRGN = HANDLE
|
||||
HRSRC = HANDLE
|
||||
HSTR = HANDLE
|
||||
HTASK = HANDLE
|
||||
HWINSTA = HANDLE
|
||||
HWND = HANDLE
|
||||
SC_HANDLE = HANDLE
|
||||
SERVICE_STATUS_HANDLE = HANDLE
|
||||
|
||||
class RECT(Structure):
|
||||
left: LONG
|
||||
top: LONG
|
||||
right: LONG
|
||||
bottom: LONG
|
||||
RECTL = RECT
|
||||
_RECTL = RECT
|
||||
tagRECT = RECT
|
||||
|
||||
class _SMALL_RECT(Structure):
|
||||
Left: SHORT
|
||||
Top: SHORT
|
||||
Right: SHORT
|
||||
Bottom: SHORT
|
||||
SMALL_RECT = _SMALL_RECT
|
||||
|
||||
class _COORD(Structure):
|
||||
X: SHORT
|
||||
Y: SHORT
|
||||
|
||||
class POINT(Structure):
|
||||
x: LONG
|
||||
y: LONG
|
||||
POINTL = POINT
|
||||
_POINTL = POINT
|
||||
tagPOINT = POINT
|
||||
|
||||
class SIZE(Structure):
|
||||
cx: LONG
|
||||
cy: LONG
|
||||
SIZEL = SIZE
|
||||
tagSIZE = SIZE
|
||||
|
||||
def RGB(red: int, green: int, blue: int) -> int: ...
|
||||
|
||||
class FILETIME(Structure):
|
||||
dwLowDateTime: DWORD
|
||||
dwHighDateTime: DWORD
|
||||
_FILETIME = FILETIME
|
||||
|
||||
class MSG(Structure):
|
||||
hWnd: HWND
|
||||
message: UINT
|
||||
wParam: WPARAM
|
||||
lParam: LPARAM
|
||||
time: DWORD
|
||||
pt: POINT
|
||||
tagMSG = MSG
|
||||
MAX_PATH: int
|
||||
|
||||
class WIN32_FIND_DATAA(Structure):
|
||||
dwFileAttributes: DWORD
|
||||
ftCreationTime: FILETIME
|
||||
ftLastAccessTime: FILETIME
|
||||
ftLastWriteTime: FILETIME
|
||||
nFileSizeHigh: DWORD
|
||||
nFileSizeLow: DWORD
|
||||
dwReserved0: DWORD
|
||||
dwReserved1: DWORD
|
||||
cFileName: Array[CHAR]
|
||||
cAlternateFileName: Array[CHAR]
|
||||
|
||||
class WIN32_FIND_DATAW(Structure):
|
||||
dwFileAttributes: DWORD
|
||||
ftCreationTime: FILETIME
|
||||
ftLastAccessTime: FILETIME
|
||||
ftLastWriteTime: FILETIME
|
||||
nFileSizeHigh: DWORD
|
||||
nFileSizeLow: DWORD
|
||||
dwReserved0: DWORD
|
||||
dwReserved1: DWORD
|
||||
cFileName: Array[WCHAR]
|
||||
cAlternateFileName: Array[WCHAR]
|
||||
|
||||
# These pointer type definitions use pointer[...] instead of POINTER(...), to allow them
|
||||
# to be used in type annotations.
|
||||
PBOOL = pointer[BOOL]
|
||||
LPBOOL = pointer[BOOL]
|
||||
PBOOLEAN = pointer[BOOLEAN]
|
||||
PBYTE = pointer[BYTE]
|
||||
LPBYTE = pointer[BYTE]
|
||||
PCHAR = pointer[CHAR]
|
||||
LPCOLORREF = pointer[COLORREF]
|
||||
PDWORD = pointer[DWORD]
|
||||
LPDWORD = pointer[DWORD]
|
||||
PFILETIME = pointer[FILETIME]
|
||||
LPFILETIME = pointer[FILETIME]
|
||||
PFLOAT = pointer[FLOAT]
|
||||
PHANDLE = pointer[HANDLE]
|
||||
LPHANDLE = pointer[HANDLE]
|
||||
PHKEY = pointer[HKEY]
|
||||
LPHKL = pointer[HKL]
|
||||
PINT = pointer[INT]
|
||||
LPINT = pointer[INT]
|
||||
PLARGE_INTEGER = pointer[LARGE_INTEGER]
|
||||
PLCID = pointer[LCID]
|
||||
PLONG = pointer[LONG]
|
||||
LPLONG = pointer[LONG]
|
||||
PMSG = pointer[MSG]
|
||||
LPMSG = pointer[MSG]
|
||||
PPOINT = pointer[POINT]
|
||||
LPPOINT = pointer[POINT]
|
||||
PPOINTL = pointer[POINTL]
|
||||
PRECT = pointer[RECT]
|
||||
LPRECT = pointer[RECT]
|
||||
PRECTL = pointer[RECTL]
|
||||
LPRECTL = pointer[RECTL]
|
||||
LPSC_HANDLE = pointer[SC_HANDLE]
|
||||
PSHORT = pointer[SHORT]
|
||||
PSIZE = pointer[SIZE]
|
||||
LPSIZE = pointer[SIZE]
|
||||
PSIZEL = pointer[SIZEL]
|
||||
LPSIZEL = pointer[SIZEL]
|
||||
PSMALL_RECT = pointer[SMALL_RECT]
|
||||
PUINT = pointer[UINT]
|
||||
LPUINT = pointer[UINT]
|
||||
PULARGE_INTEGER = pointer[ULARGE_INTEGER]
|
||||
PULONG = pointer[ULONG]
|
||||
PUSHORT = pointer[USHORT]
|
||||
PWCHAR = pointer[WCHAR]
|
||||
PWIN32_FIND_DATAA = pointer[WIN32_FIND_DATAA]
|
||||
LPWIN32_FIND_DATAA = pointer[WIN32_FIND_DATAA]
|
||||
PWIN32_FIND_DATAW = pointer[WIN32_FIND_DATAW]
|
||||
LPWIN32_FIND_DATAW = pointer[WIN32_FIND_DATAW]
|
||||
PWORD = pointer[WORD]
|
||||
LPWORD = pointer[WORD]
|
||||
@@ -35,3 +35,6 @@ def compare_digest(a: str, b: str) -> bool: ...
|
||||
def compare_digest(a: bytes, b: bytes) -> bool: ...
|
||||
@overload
|
||||
def compare_digest(a: bytearray, b: bytearray) -> bool: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
def digest(key: _B, msg: _B, digest: str) -> bytes: ...
|
||||
|
||||
@@ -94,8 +94,12 @@ def strcoll(string1: _str, string2: _str) -> int: ...
|
||||
def strxfrm(string: _str) -> _str: ...
|
||||
def format(format: _str, val: Union[float, Decimal], grouping: bool = ...,
|
||||
monetary: bool = ...) -> _str: ...
|
||||
def format_string(format: _str, val: Sequence[Any],
|
||||
grouping: bool = ...) -> _str: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def format_string(format: _str, val: Sequence[Any],
|
||||
grouping: bool = ..., monetary: bool = ...) -> _str: ...
|
||||
else:
|
||||
def format_string(format: _str, val: Sequence[Any],
|
||||
grouping: bool = ...) -> _str: ...
|
||||
def currency(val: int, symbol: bool = ..., grouping: bool = ...,
|
||||
international: bool = ...) -> _str: ...
|
||||
if sys.version_info >= (3, 5):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Stubs for math
|
||||
# See: http://docs.python.org/2/library/math.html
|
||||
|
||||
from typing import Tuple, Iterable, Optional
|
||||
from typing import Tuple, Iterable, Optional, SupportsFloat, SupportsInt
|
||||
|
||||
import sys
|
||||
|
||||
@@ -13,57 +13,59 @@ if sys.version_info >= (3, 5):
|
||||
if sys.version_info >= (3, 6):
|
||||
tau = ... # type: float
|
||||
|
||||
def acos(x: float) -> float: ...
|
||||
def acosh(x: float) -> float: ...
|
||||
def asin(x: float) -> float: ...
|
||||
def asinh(x: float) -> float: ...
|
||||
def atan(x: float) -> float: ...
|
||||
def atan2(y: float, x: float) -> float: ...
|
||||
def atanh(x: float) -> float: ...
|
||||
def acos(x: SupportsFloat) -> float: ...
|
||||
def acosh(x: SupportsFloat) -> float: ...
|
||||
def asin(x: SupportsFloat) -> float: ...
|
||||
def asinh(x: SupportsFloat) -> float: ...
|
||||
def atan(x: SupportsFloat) -> float: ...
|
||||
def atan2(y: SupportsFloat, x: SupportsFloat) -> float: ...
|
||||
def atanh(x: SupportsFloat) -> float: ...
|
||||
if sys.version_info >= (3,):
|
||||
def ceil(x: float) -> int: ...
|
||||
def ceil(x: SupportsFloat) -> int: ...
|
||||
else:
|
||||
def ceil(x: float) -> float: ...
|
||||
def copysign(x: float, y: float) -> float: ...
|
||||
def cos(x: float) -> float: ...
|
||||
def cosh(x: float) -> float: ...
|
||||
def degrees(x: float) -> float: ...
|
||||
def erf(x: float) -> float: ...
|
||||
def erfc(x: float) -> float: ...
|
||||
def exp(x: float) -> float: ...
|
||||
def expm1(x: float) -> float: ...
|
||||
def fabs(x: float) -> float: ...
|
||||
def factorial(x: int) -> int: ...
|
||||
def ceil(x: SupportsFloat) -> float: ...
|
||||
def copysign(x: SupportsFloat, y: SupportsFloat) -> float: ...
|
||||
def cos(x: SupportsFloat) -> float: ...
|
||||
def cosh(x: SupportsFloat) -> float: ...
|
||||
def degrees(x: SupportsFloat) -> float: ...
|
||||
def erf(x: SupportsFloat) -> float: ...
|
||||
def erfc(x: SupportsFloat) -> float: ...
|
||||
def exp(x: SupportsFloat) -> float: ...
|
||||
def expm1(x: SupportsFloat) -> float: ...
|
||||
def fabs(x: SupportsFloat) -> float: ...
|
||||
def factorial(x: SupportsInt) -> int: ...
|
||||
if sys.version_info >= (3,):
|
||||
def floor(x: float) -> int: ...
|
||||
def floor(x: SupportsFloat) -> int: ...
|
||||
else:
|
||||
def floor(x: float) -> float: ...
|
||||
def fmod(x: float, y: float) -> float: ...
|
||||
def frexp(x: float) -> Tuple[float, int]: ...
|
||||
def floor(x: SupportsFloat) -> float: ...
|
||||
def fmod(x: SupportsFloat, y: SupportsFloat) -> float: ...
|
||||
def frexp(x: SupportsFloat) -> Tuple[float, int]: ...
|
||||
def fsum(iterable: Iterable) -> float: ...
|
||||
def gamma(x: float) -> float: ...
|
||||
def gamma(x: SupportsFloat) -> float: ...
|
||||
if sys.version_info >= (3, 5):
|
||||
def gcd(a: int, b: int) -> int: ...
|
||||
def hypot(x: float, y: float) -> float: ...
|
||||
def hypot(x: SupportsFloat, y: SupportsFloat) -> float: ...
|
||||
if sys.version_info >= (3, 5):
|
||||
def isclose(a: float, b: float, rel_tol: float = ..., abs_tol: float = ...) -> bool: ...
|
||||
def isinf(x: float) -> bool: ...
|
||||
def isclose(a: SupportsFloat, b: SupportsFloat, rel_tol: SupportsFloat = ..., abs_tol: SupportsFloat = ...) -> bool: ...
|
||||
def isinf(x: SupportsFloat) -> bool: ...
|
||||
if sys.version_info >= (3,):
|
||||
def isfinite(x: float) -> bool: ...
|
||||
def isnan(x: float) -> bool: ...
|
||||
def ldexp(x: float, i: int) -> float: ...
|
||||
def lgamma(x: float) -> float: ...
|
||||
def log(x: float, base: float = ...) -> float: ...
|
||||
def log10(x: float) -> float: ...
|
||||
def log1p(x: float) -> float: ...
|
||||
def isfinite(x: SupportsFloat) -> bool: ...
|
||||
def isnan(x: SupportsFloat) -> bool: ...
|
||||
def ldexp(x: SupportsFloat, i: int) -> float: ...
|
||||
def lgamma(x: SupportsFloat) -> float: ...
|
||||
def log(x: SupportsFloat, base: SupportsFloat = ...) -> float: ...
|
||||
def log10(x: SupportsFloat) -> float: ...
|
||||
def log1p(x: SupportsFloat) -> float: ...
|
||||
if sys.version_info >= (3, 3):
|
||||
def log2(x: float) -> float: ...
|
||||
def modf(x: float) -> Tuple[float, float]: ...
|
||||
def pow(x: float, y: float) -> float: ...
|
||||
def radians(x: float) -> float: ...
|
||||
def sin(x: float) -> float: ...
|
||||
def sinh(x: float) -> float: ...
|
||||
def sqrt(x: float) -> float: ...
|
||||
def tan(x: float) -> float: ...
|
||||
def tanh(x: float) -> float: ...
|
||||
def trunc(x: float) -> int: ...
|
||||
def log2(x: SupportsFloat) -> float: ...
|
||||
def modf(x: SupportsFloat) -> Tuple[float, float]: ...
|
||||
def pow(x: SupportsFloat, y: SupportsFloat) -> float: ...
|
||||
def radians(x: SupportsFloat) -> float: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def remainder(x: SupportsFloat, y: SupportsFloat) -> float: ...
|
||||
def sin(x: SupportsFloat) -> float: ...
|
||||
def sinh(x: SupportsFloat) -> float: ...
|
||||
def sqrt(x: SupportsFloat) -> float: ...
|
||||
def tan(x: SupportsFloat) -> float: ...
|
||||
def tanh(x: SupportsFloat) -> float: ...
|
||||
def trunc(x: SupportsFloat) -> int: ...
|
||||
|
||||
@@ -10,7 +10,8 @@ _PT = Tuple[str, int, str, Optional[str]]
|
||||
def print_tb(tb: Optional[TracebackType], limit: Optional[int] = ...,
|
||||
file: Optional[IO[str]] = ...) -> None: ...
|
||||
if sys.version_info >= (3,):
|
||||
def print_exception(etype: Type[BaseException], value: BaseException,
|
||||
def print_exception(etype: Optional[Type[BaseException]],
|
||||
value: Optional[BaseException],
|
||||
tb: Optional[TracebackType], limit: Optional[int] = ...,
|
||||
file: Optional[IO[str]] = ...,
|
||||
chain: bool = ...) -> None: ...
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import os
|
||||
|
||||
from pathlib import Path
|
||||
from types import ModuleType
|
||||
from typing import ContextManager, Iterator, Union, BinaryIO, TextIO
|
||||
|
||||
Package = Union[str, ModuleType]
|
||||
Resource = Union[str, os.PathLike]
|
||||
|
||||
def open_binary(package: Package, resource: Resource) -> BinaryIO: ...
|
||||
def open_text(package: Package,
|
||||
resource: Resource,
|
||||
encoding: str = ...,
|
||||
errors: str = ...) -> TextIO: ...
|
||||
def read_binary(package: Package, resource: Resource) -> bytes: ...
|
||||
def read_text(package: Package,
|
||||
resource: Resource,
|
||||
encoding: str = ...,
|
||||
errors: str = ...) -> str: ...
|
||||
def path(package: Package, resource: Resource) -> ContextManager[Path]: ...
|
||||
def is_resource(package: Package, name: str) -> bool: ...
|
||||
def contents(package: Package) -> Iterator[str]: ...
|
||||
@@ -4,8 +4,8 @@ from typing import (
|
||||
TypeVar, Iterator, Iterable, overload, Container,
|
||||
Sequence, MutableSequence, Mapping, MutableMapping, NoReturn, Tuple, List, Any, Dict, Callable, Generic,
|
||||
Set, AbstractSet, FrozenSet, MutableSet, Sized, Reversible, SupportsInt, SupportsFloat,
|
||||
SupportsBytes, SupportsAbs, SupportsRound, IO, Union, ItemsView, KeysView, ValuesView,
|
||||
ByteString, Optional, AnyStr, Type,
|
||||
SupportsComplex, SupportsBytes, SupportsAbs, SupportsRound, IO, Union, ItemsView, KeysView,
|
||||
ValuesView, ByteString, Optional, AnyStr, Type,
|
||||
)
|
||||
from abc import abstractmethod, ABCMeta
|
||||
from types import TracebackType, CodeType
|
||||
@@ -204,6 +204,8 @@ class complex:
|
||||
def __init__(self, re: float = ..., im: float = ...) -> None: ...
|
||||
@overload
|
||||
def __init__(self, s: str) -> None: ...
|
||||
@overload
|
||||
def __init__(self, s: SupportsComplex) -> None: ...
|
||||
|
||||
@property
|
||||
def real(self) -> float: ...
|
||||
@@ -229,6 +231,7 @@ class complex:
|
||||
def __pos__(self) -> complex: ...
|
||||
|
||||
def __str__(self) -> str: ...
|
||||
def __complex__(self) -> complex: ...
|
||||
def __abs__(self) -> float: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def __bool__(self) -> bool: ...
|
||||
@@ -503,7 +506,6 @@ class bytearray(MutableSequence[int], ByteString):
|
||||
def __gt__(self, x: bytes) -> bool: ...
|
||||
def __ge__(self, x: bytes) -> bool: ...
|
||||
|
||||
|
||||
class memoryview(Sized, Container[bytes]):
|
||||
format = ... # type: str
|
||||
itemsize = ... # type: int
|
||||
@@ -537,7 +539,6 @@ class memoryview(Sized, Container[bytes]):
|
||||
if sys.version_info >= (3, 5):
|
||||
def hex(self) -> str: ...
|
||||
|
||||
|
||||
class bool(int):
|
||||
def __init__(self, o: object = ...) -> None: ...
|
||||
@overload # type: ignore
|
||||
@@ -674,10 +675,10 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
|
||||
def items(self) -> ItemsView[_KT, _VT]: ...
|
||||
@staticmethod
|
||||
@overload
|
||||
def fromkeys(seq: Sequence[_T]) -> Dict[_T, Any]: ... # TODO: Actually a class method (mypy/issues#328)
|
||||
def fromkeys(seq: Iterable[_T]) -> Dict[_T, Any]: ... # TODO: Actually a class method (mypy/issues#328)
|
||||
@staticmethod
|
||||
@overload
|
||||
def fromkeys(seq: Sequence[_T], value: _S) -> Dict[_T, _S]: ...
|
||||
def fromkeys(seq: Iterable[_T], value: _S) -> Dict[_T, _S]: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __getitem__(self, k: _KT) -> _VT: ...
|
||||
def __setitem__(self, k: _KT, v: _VT) -> None: ...
|
||||
@@ -720,7 +721,6 @@ class set(MutableSet[_T], Generic[_T]):
|
||||
def __lt__(self, s: AbstractSet[object]) -> bool: ...
|
||||
def __ge__(self, s: AbstractSet[object]) -> bool: ...
|
||||
def __gt__(self, s: AbstractSet[object]) -> bool: ...
|
||||
# TODO more set operations
|
||||
|
||||
class frozenset(AbstractSet[_T], Generic[_T]):
|
||||
def __init__(self, iterable: Iterable[_T] = ...) -> None: ...
|
||||
@@ -888,7 +888,6 @@ else:
|
||||
errors: Optional[str] = ..., newline: Optional[str] = ..., closefd: bool = ...) -> IO[Any]: ...
|
||||
|
||||
def ord(c: Union[str, bytes, bytearray]) -> int: ...
|
||||
# TODO: in Python 3.2, print() does not support flush
|
||||
def print(*values: Any, sep: str = ..., end: str = ..., file: Optional[IO[str]] = ..., flush: bool = ...) -> None: ...
|
||||
@overload
|
||||
def pow(x: int, y: int) -> Any: ... # The return type can be int or float, depending on y
|
||||
@@ -954,11 +953,11 @@ Ellipsis = ... # type: ellipsis
|
||||
|
||||
class BaseException:
|
||||
args = ... # type: Tuple[Any, ...]
|
||||
__cause__ = ... # type: BaseException
|
||||
__context__ = ... # type: BaseException
|
||||
__traceback__ = ... # type: TracebackType
|
||||
__cause__ = ... # type: Optional[BaseException]
|
||||
__context__ = ... # type: Optional[BaseException]
|
||||
__traceback__ = ... # type: Optional[TracebackType]
|
||||
def __init__(self, *args: object, **kwargs: object) -> None: ...
|
||||
def with_traceback(self, tb: Any) -> BaseException: ...
|
||||
def with_traceback(self, tb: Optional[TracebackType]) -> BaseException: ...
|
||||
|
||||
class GeneratorExit(BaseException): ...
|
||||
class KeyboardInterrupt(BaseException): ...
|
||||
|
||||
@@ -187,7 +187,8 @@ class UserString(Sequence[str]):
|
||||
# methods did not exist).
|
||||
# But in practice it's not worth losing sleep over.
|
||||
class deque(MutableSequence[_T], Generic[_T]):
|
||||
maxlen = ... # type: Optional[int] # TODO readonly
|
||||
@property
|
||||
def maxlen(self) -> Optional[int]: ...
|
||||
def __init__(self, iterable: Iterable[_T] = ...,
|
||||
maxlen: int = ...) -> None: ...
|
||||
def append(self, x: _T) -> None: ...
|
||||
|
||||
@@ -125,7 +125,14 @@ else:
|
||||
exc_tb: Optional[types.TracebackType]) -> bool: ...
|
||||
|
||||
class HTTPConnection:
|
||||
if sys.version_info >= (3, 4):
|
||||
if sys.version_info >= (3, 7):
|
||||
def __init__(
|
||||
self,
|
||||
host: str, port: Optional[int] = ...,
|
||||
timeout: int = ...,
|
||||
source_address: Optional[Tuple[str, int]] = ..., blocksize: int = ...
|
||||
) -> None: ...
|
||||
elif sys.version_info >= (3, 4):
|
||||
def __init__(
|
||||
self,
|
||||
host: str, port: Optional[int] = ...,
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
# Stubs for http.server (Python 3.4)
|
||||
|
||||
import sys
|
||||
from typing import Any, BinaryIO, Dict, List, Mapping, Optional, Tuple, Union
|
||||
import socketserver
|
||||
import email.message
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from builtins import _PathLike
|
||||
|
||||
class HTTPServer(socketserver.TCPServer):
|
||||
server_name = ... # type: str
|
||||
server_port = ... # type: int
|
||||
@@ -53,8 +57,12 @@ class BaseHTTPRequestHandler:
|
||||
|
||||
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
|
||||
extensions_map = ... # type: Dict[str, str]
|
||||
def __init__(self, request: bytes, client_address: Tuple[str, int],
|
||||
server: socketserver.BaseServer) -> None: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def __init__(self, request: bytes, client_address: Tuple[str, int],
|
||||
server: socketserver.BaseServer, directory: Optional[Union[str, _PathLike[str]]]) -> None: ...
|
||||
else:
|
||||
def __init__(self, request: bytes, client_address: Tuple[str, int],
|
||||
server: socketserver.BaseServer) -> None: ...
|
||||
def do_GET(self) -> None: ...
|
||||
def do_HEAD(self) -> None: ...
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
import os
|
||||
import sys
|
||||
import types
|
||||
from typing import Any, Mapping, Optional, Sequence, Tuple, Union
|
||||
from typing import Any, IO, Iterator, Mapping, Optional, Sequence, Tuple, Union
|
||||
|
||||
# Loader is exported from this module, but for circular import reasons
|
||||
# exists in its own stub file (with ModuleSpec and ModuleType).
|
||||
@@ -87,3 +88,16 @@ if sys.version_info >= (3, 3):
|
||||
def __init__(self, fullname: str, path: _Path) -> None: ...
|
||||
def get_data(self, path: _Path) -> bytes: ...
|
||||
def get_filename(self, fullname: str) -> _Path: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
_PathLike = Union[bytes, str, os.PathLike[Any]]
|
||||
|
||||
class ResourceReader(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def open_resource(self, resource: _PathLike) -> IO[bytes]: ...
|
||||
@abstractmethod
|
||||
def resource_path(self, resource: _PathLike) -> str: ...
|
||||
@abstractmethod
|
||||
def is_resource(self, name: str) -> bool: ...
|
||||
@abstractmethod
|
||||
def contents(self) -> Iterator[str]: ...
|
||||
|
||||
@@ -203,7 +203,7 @@ ArgInfo = NamedTuple('ArgInfo', [('args', List[str]),
|
||||
])
|
||||
|
||||
def getargvalues(frame: FrameType) -> ArgInfo: ...
|
||||
def formatannotation(annotation: object, base_module: Optional[str] = None) -> str: ...
|
||||
def formatannotation(annotation: object, base_module: Optional[str] = ...) -> str: ...
|
||||
def formatannotationrelativeto(object: object) -> Callable[[object], str]: ...
|
||||
def formatargspec(args: List[str],
|
||||
varargs: Optional[str] = ...,
|
||||
|
||||
@@ -15,14 +15,14 @@ template = ... # type: str
|
||||
|
||||
if sys.version_info >= (3, 5):
|
||||
def TemporaryFile(
|
||||
mode: str = ..., buffering: int = ..., encoding: str = ...,
|
||||
newline: str = ..., suffix: Optional[AnyStr]= ..., prefix: Optional[AnyStr] = ...,
|
||||
mode: str = ..., buffering: int = ..., encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ..., suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ...,
|
||||
dir: Optional[AnyStr] = ...
|
||||
) -> IO[Any]:
|
||||
...
|
||||
def NamedTemporaryFile(
|
||||
mode: str = ..., buffering: int = ..., encoding: str = ...,
|
||||
newline: str = ..., suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ...,
|
||||
mode: str = ..., buffering: int = ..., encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ..., suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ...,
|
||||
dir: Optional[AnyStr] = ..., delete: bool =...
|
||||
) -> IO[Any]:
|
||||
...
|
||||
@@ -53,14 +53,14 @@ if sys.version_info >= (3, 5):
|
||||
def gettempprefixb() -> bytes: ...
|
||||
else:
|
||||
def TemporaryFile(
|
||||
mode: str = ..., buffering: int = ..., encoding: str = ...,
|
||||
newline: str = ..., suffix: str = ..., prefix: str = ...,
|
||||
mode: str = ..., buffering: int = ..., encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ..., suffix: str = ..., prefix: str = ...,
|
||||
dir: Optional[str] = ...
|
||||
) -> IO[Any]:
|
||||
...
|
||||
def NamedTemporaryFile(
|
||||
mode: str = ..., buffering: int = ..., encoding: str = ...,
|
||||
newline: str = ..., suffix: str = ..., prefix: str = ...,
|
||||
mode: str = ..., buffering: int = ..., encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ..., suffix: str = ..., prefix: str = ...,
|
||||
dir: Optional[str] = ..., delete: bool =...
|
||||
) -> IO[Any]:
|
||||
...
|
||||
|
||||
+14
-14
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Dict, List, Optional
|
||||
from typing import Any, Dict, List, Optional, Text
|
||||
from .mobile import Mobile as Mobile
|
||||
from selenium.webdriver.remote.webelement import WebElement
|
||||
from selenium.webdriver.remote.errorhandler import ErrorHandler
|
||||
@@ -14,10 +14,10 @@ class WebDriver:
|
||||
error_handler = ... # type: ErrorHandler
|
||||
file_detector = ... # type: FileDetector
|
||||
def __init__(self,
|
||||
command_executor: basestring='',
|
||||
desired_capabilities: Capabilities=None,
|
||||
browser_profile=None,
|
||||
proxy=None,
|
||||
command_executor: basestring = ...,
|
||||
desired_capabilities: Capabilities = ...,
|
||||
browser_profile: Optional[Any] = ..., # should be selenium.webdriver.firefox.firefox_profile.FirefoxProfile, but we don't have a stub for that
|
||||
proxy: Optional[Any] = ..., # should be selenium.webdriver.common.proxy.Proxy, but there's no stub for that
|
||||
keep_alive: bool = ...
|
||||
) -> None: ...
|
||||
@property
|
||||
@@ -83,15 +83,15 @@ class WebDriver:
|
||||
def find_element(self, by=..., value=None): ...
|
||||
def find_elements(self, by=..., value=None): ...
|
||||
@property
|
||||
def desired_capabilities(self): ...
|
||||
def get_screenshot_as_file(self, filename): ...
|
||||
save_screenshot = ... # type: Any
|
||||
def get_screenshot_as_png(self): ...
|
||||
def get_screenshot_as_base64(self): ...
|
||||
def set_window_size(self, width, height, windowHandle=''): ...
|
||||
def get_window_size(self, windowHandle=''): ...
|
||||
def set_window_position(self, x, y, windowHandle=''): ...
|
||||
def get_window_position(self, windowHandle=''): ...
|
||||
def desired_capabilities(self) -> Capabilities: ...
|
||||
def get_screenshot_as_file(self, filename: Text) -> bool: ...
|
||||
def save_screenshot(self, filename: Text) -> bool: ...
|
||||
def get_screenshot_as_png(self) -> bytes: ...
|
||||
def get_screenshot_as_base64(self) -> str: ...
|
||||
def set_window_size(self, width: int, height: int, windowHandle: str = ...) -> None: ...
|
||||
def get_window_size(self, windowHandle: str = ...) -> Dict[str, int]: ...
|
||||
def set_window_position(self, x: int, y: int, windowHandle: str = ...) -> None: ...
|
||||
def get_window_position(self, windowHandle: str = ...) -> Dict[str, int]: ...
|
||||
@property
|
||||
def file_detector(self): ...
|
||||
@file_detector.setter
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
from selenium.webdriver.remote.webdriver import WebDriver
|
||||
from typing import Any, Optional, Dict, List
|
||||
from typing import Optional, Dict, List, Text
|
||||
|
||||
SizeDict = Dict[str, int] # containing "height", "width"
|
||||
PointDict = Dict[str, int] # containing "x", "y"
|
||||
@@ -56,6 +56,6 @@ class WebElement:
|
||||
def id(self) -> Optional[basestring]: ...
|
||||
def __eq__(self, element: object) -> bool: ...
|
||||
def __ne__(self, element: object) -> bool: ...
|
||||
def find_element(self, by: basestring=..., value: basestring=None) -> WebElement: ...
|
||||
def find_elements(self, by: basestring=..., value: basestring=None) -> List[WebElement]: ...
|
||||
def find_element(self, by: Text = ..., value: Optional[Text] = ...) -> WebElement: ...
|
||||
def find_elements(self, by: Text = ..., value: Optional[Text] = ...) -> List[WebElement]: ...
|
||||
def __hash__(self) -> int: ...
|
||||
|
||||
+37
-35
@@ -1,7 +1,7 @@
|
||||
from datetime import datetime
|
||||
from typing import (
|
||||
Any, Iterable, Mapping, MutableMapping, Optional, Sequence, Tuple, Type,
|
||||
Union,
|
||||
Any, Callable, Iterable, Iterator, Mapping, MutableMapping, Optional, Sequence, Text,
|
||||
Tuple, Type, TypeVar, Union,
|
||||
)
|
||||
|
||||
from wsgiref.types import WSGIEnvironment
|
||||
@@ -14,13 +14,13 @@ from .datastructures import (
|
||||
class BaseRequest:
|
||||
charset = ... # type: str
|
||||
encoding_errors = ... # type: str
|
||||
max_content_length = ... # type: Union[int, long]
|
||||
max_form_memory_size = ... # type: Union[int, long]
|
||||
max_content_length = ... # type: int
|
||||
max_form_memory_size = ... # type: int
|
||||
parameter_storage_class = ... # type: Type
|
||||
list_storage_class = ... # type: Type
|
||||
dict_storage_class = ... # type: Type
|
||||
form_data_parser_class = ... # type: Type
|
||||
trusted_hosts = ... # type: Optional[Sequence[unicode]]
|
||||
trusted_hosts = ... # type: Optional[Sequence[Text]]
|
||||
disable_data_descriptor = ... # type: Any
|
||||
environ: WSGIEnvironment = ...
|
||||
shallow = ... # type: Any
|
||||
@@ -41,27 +41,27 @@ class BaseRequest:
|
||||
input_stream = ... # type: Any
|
||||
args = ... # type: ImmutableMultiDict
|
||||
@property
|
||||
def data(self) -> str: ...
|
||||
def get_data(self, cache: bool = ..., as_text: bool = ..., parse_form_data: bool = ...) -> str: ...
|
||||
def data(self) -> bytes: ...
|
||||
def get_data(self, cache: bool = ..., as_text: bool = ..., parse_form_data: bool = ...) -> bytes: ...
|
||||
form = ... # type: ImmutableMultiDict
|
||||
values = ... # type: CombinedMultiDict
|
||||
files = ... # type: MultiDict
|
||||
cookies = ... # type: TypeConversionDict
|
||||
headers = ... # type: EnvironHeaders
|
||||
path = ... # type: unicode
|
||||
full_path = ... # type: unicode
|
||||
script_root = ... # type: unicode
|
||||
url = ... # type: unicode
|
||||
base_url = ... # type: unicode
|
||||
url_root = ... # type: unicode
|
||||
host_url = ... # type: unicode
|
||||
host = ... # type: unicode
|
||||
query_string = ... # type: str
|
||||
method = ... # type: str
|
||||
path = ... # type: Text
|
||||
full_path = ... # type: Text
|
||||
script_root = ... # type: Text
|
||||
url = ... # type: Text
|
||||
base_url = ... # type: Text
|
||||
url_root = ... # type: Text
|
||||
host_url = ... # type: Text
|
||||
host = ... # type: Text
|
||||
query_string = ... # type: bytes
|
||||
method = ... # type: Text
|
||||
def access_route(self): ...
|
||||
@property
|
||||
def remote_addr(self) -> str: ...
|
||||
remote_user = ... # type: unicode
|
||||
remote_user = ... # type: Text
|
||||
scheme = ... # type: str
|
||||
is_xhr = ... # type: bool
|
||||
is_secure = ... # type: bool
|
||||
@@ -69,6 +69,9 @@ class BaseRequest:
|
||||
is_multiprocess = ... # type: bool
|
||||
is_run_once = ... # type: bool
|
||||
|
||||
_OnCloseT = TypeVar('_OnCloseT', bound=Callable[[], Any])
|
||||
_SelfT = TypeVar('_SelfT', bound=BaseResponse)
|
||||
|
||||
class BaseResponse:
|
||||
charset = ... # type: str
|
||||
default_status = ... # type: int
|
||||
@@ -80,27 +83,26 @@ class BaseResponse:
|
||||
status_code = ... # type: int
|
||||
status = ... # type: str
|
||||
direct_passthrough = ... # type: bool
|
||||
response = ... # type: Iterable[str]
|
||||
def __init__(self,
|
||||
response: Optional[Union[Iterable[str], str]] = ...,
|
||||
status: Optional[Union[basestring, int]] = ...,
|
||||
response = ... # type: Iterable[bytes]
|
||||
def __init__(self, response: Optional[Union[Iterable[bytes], bytes]] = ...,
|
||||
status: Optional[Union[Text, int]] = ...,
|
||||
headers: Optional[Union[Headers,
|
||||
Mapping[basestring, basestring],
|
||||
Sequence[Tuple[basestring, basestring]]]] = None,
|
||||
mimetype: Optional[basestring] = ...,
|
||||
content_type: Optional[basestring] = ...,
|
||||
direct_passthrough: Optional[bool] = ...) -> None: ...
|
||||
def call_on_close(self, func): ...
|
||||
Mapping[Text, Text],
|
||||
Sequence[Tuple[Text, Text]]]] = ...,
|
||||
mimetype: Optional[Text] = ...,
|
||||
content_type: Optional[Text] = ...,
|
||||
direct_passthrough: bool = ...) -> None: ...
|
||||
def call_on_close(self, func: _OnCloseT) -> _OnCloseT: ...
|
||||
@classmethod
|
||||
def force_type(cls, response, environ=None): ...
|
||||
def force_type(cls: Type[_SelfT], response: object, environ: Optional[WSGIEnvironment] = ...) -> _SelfT: ...
|
||||
@classmethod
|
||||
def from_app(cls, app, environ, buffered=False): ...
|
||||
def get_data(self, as_text=False): ...
|
||||
def set_data(self, value): ...
|
||||
def from_app(cls: Type[_SelfT], app: Any, environ: WSGIEnvironment, buffered: bool = ...) -> _SelfT: ...
|
||||
def get_data(self, as_text: bool = ...) -> Any: ... # returns bytes if as_text is False (the default), else Text
|
||||
def set_data(self, value: Union[bytes, Text]) -> None: ...
|
||||
data = ... # type: Any
|
||||
def calculate_content_length(self): ...
|
||||
def make_sequence(self): ...
|
||||
def iter_encoded(self): ...
|
||||
def calculate_content_length(self) -> Optional[int]: ...
|
||||
def make_sequence(self) -> None: ...
|
||||
def iter_encoded(self) -> Iterator[bytes]: ...
|
||||
def set_cookie(self, key, value='', max_age=None, expires=None, path='', domain=None, secure=False, httponly=False): ...
|
||||
def delete_cookie(self, key, path='', domain=None): ...
|
||||
@property
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
from typing import ContextManager, Iterator, Generic, TypeVar
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class ProgressBar(object, Generic[_T]):
|
||||
def update(self, n_steps: int) -> None: ...
|
||||
def finish(self) -> None: ...
|
||||
def __enter__(self) -> "ProgressBar[_T]": ...
|
||||
def __exit__(self, exc_type, exc_value, tb) -> None: ...
|
||||
def __iter__(self) -> "ProgressBar[_T]": ...
|
||||
def next(self) -> _T: ...
|
||||
def __next__(self) -> _T: ...
|
||||
+23
-5
@@ -1,4 +1,3 @@
|
||||
from contextlib import contextmanager
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
@@ -7,11 +6,13 @@ from typing import (
|
||||
IO,
|
||||
List,
|
||||
Optional,
|
||||
overload,
|
||||
Tuple,
|
||||
TypeVar,
|
||||
)
|
||||
|
||||
from click.types import _ConvertibleType
|
||||
from click._termui_impl import ProgressBar as _ProgressBar
|
||||
|
||||
|
||||
def hidden_prompt_func(prompt: str) -> str:
|
||||
@@ -62,10 +63,9 @@ def echo_via_pager(text: str, color: Optional[bool] = ...) -> None:
|
||||
|
||||
_T = TypeVar('_T')
|
||||
|
||||
|
||||
@contextmanager
|
||||
@overload
|
||||
def progressbar(
|
||||
iterable: Optional[Iterable[_T]] = ...,
|
||||
iterable: Iterable[_T],
|
||||
length: Optional[int] = ...,
|
||||
label: Optional[str] = ...,
|
||||
show_eta: bool = ...,
|
||||
@@ -79,9 +79,27 @@ def progressbar(
|
||||
width: int = ...,
|
||||
file: Optional[IO] = ...,
|
||||
color: Optional[bool] = ...,
|
||||
) -> Generator[_T, None, None]:
|
||||
) -> _ProgressBar[_T]:
|
||||
...
|
||||
|
||||
@overload
|
||||
def progressbar(
|
||||
iterable: None = ...,
|
||||
length: Optional[int] = ...,
|
||||
label: Optional[str] = ...,
|
||||
show_eta: bool = ...,
|
||||
show_percent: Optional[bool] = ...,
|
||||
show_pos: bool = ...,
|
||||
item_show_func: Optional[Callable[[_T], str]] = ...,
|
||||
fill_char: str = ...,
|
||||
empty_char: str = ...,
|
||||
bar_template: str = ...,
|
||||
info_sep: str = ...,
|
||||
width: int = ...,
|
||||
file: Optional[IO] = ...,
|
||||
color: Optional[bool] = ...,
|
||||
) -> _ProgressBar[int]:
|
||||
...
|
||||
|
||||
def clear() -> None:
|
||||
...
|
||||
|
||||
+28
-26
@@ -1,7 +1,6 @@
|
||||
from datetime import datetime
|
||||
from typing import (
|
||||
Any, Iterable, Mapping, MutableMapping, Optional, Sequence, Tuple, Type,
|
||||
Union,
|
||||
Any, Callable, Iterable, Iterator, Mapping, MutableMapping, Optional, Sequence, Text, Tuple, Type, TypeVar, Union,
|
||||
)
|
||||
|
||||
from wsgiref.types import WSGIEnvironment
|
||||
@@ -20,7 +19,7 @@ class BaseRequest:
|
||||
list_storage_class = ... # type: Type
|
||||
dict_storage_class = ... # type: Type
|
||||
form_data_parser_class = ... # type: Type
|
||||
trusted_hosts = ... # type: Optional[Sequence[str]]
|
||||
trusted_hosts = ... # type: Optional[Sequence[Text]]
|
||||
disable_data_descriptor = ... # type: Any
|
||||
environ: WSGIEnvironment = ...
|
||||
shallow = ... # type: Any
|
||||
@@ -48,20 +47,20 @@ class BaseRequest:
|
||||
files = ... # type: MultiDict
|
||||
cookies = ... # type: TypeConversionDict
|
||||
headers = ... # type: EnvironHeaders
|
||||
path = ... # type: str
|
||||
full_path = ... # type: str
|
||||
script_root = ... # type: str
|
||||
url = ... # type: str
|
||||
base_url = ... # type: str
|
||||
url_root = ... # type: str
|
||||
host_url = ... # type: str
|
||||
host = ... # type: str
|
||||
path = ... # type: Text
|
||||
full_path = ... # type: Text
|
||||
script_root = ... # type: Text
|
||||
url = ... # type: Text
|
||||
base_url = ... # type: Text
|
||||
url_root = ... # type: Text
|
||||
host_url = ... # type: Text
|
||||
host = ... # type: Text
|
||||
query_string = ... # type: bytes
|
||||
method = ... # type: str
|
||||
method = ... # type: Text
|
||||
def access_route(self): ...
|
||||
@property
|
||||
def remote_addr(self) -> str: ...
|
||||
remote_user = ... # type: str
|
||||
remote_user = ... # type: Text
|
||||
scheme = ... # type: str
|
||||
is_xhr = ... # type: bool
|
||||
is_secure = ... # type: bool
|
||||
@@ -69,6 +68,9 @@ class BaseRequest:
|
||||
is_multiprocess = ... # type: bool
|
||||
is_run_once = ... # type: bool
|
||||
|
||||
_OnCloseT = TypeVar('_OnCloseT', bound=Callable[[], Any])
|
||||
_SelfT = TypeVar('_SelfT', bound=BaseResponse)
|
||||
|
||||
class BaseResponse:
|
||||
charset = ... # type: str
|
||||
default_status = ... # type: int
|
||||
@@ -82,24 +84,24 @@ class BaseResponse:
|
||||
direct_passthrough = ... # type: bool
|
||||
response = ... # type: Iterable[bytes]
|
||||
def __init__(self, response: Optional[Union[Iterable[bytes], bytes]] = ...,
|
||||
status: Optional[Union[str, int]] = ...,
|
||||
status: Optional[Union[Text, int]] = ...,
|
||||
headers: Optional[Union[Headers,
|
||||
Mapping[str, str],
|
||||
Sequence[Tuple[str, str]]]]=None,
|
||||
mimetype: Optional[str] = ...,
|
||||
content_type: Optional[str] = ...,
|
||||
Mapping[Text, Text],
|
||||
Sequence[Tuple[Text, Text]]]] = ...,
|
||||
mimetype: Optional[Text] = ...,
|
||||
content_type: Optional[Text] = ...,
|
||||
direct_passthrough: bool = ...) -> None: ...
|
||||
def call_on_close(self, func): ...
|
||||
def call_on_close(self, func: _OnCloseT) -> _OnCloseT: ...
|
||||
@classmethod
|
||||
def force_type(cls, response, environ=None): ...
|
||||
def force_type(cls: Type[_SelfT], response: object, environ: Optional[WSGIEnvironment] = ...) -> _SelfT: ...
|
||||
@classmethod
|
||||
def from_app(cls, app, environ, buffered=False): ...
|
||||
def get_data(self, as_text=False): ...
|
||||
def set_data(self, value): ...
|
||||
def from_app(cls: Type[_SelfT], app: Any, environ: WSGIEnvironment, buffered: bool = ...) -> _SelfT: ...
|
||||
def get_data(self, as_text: bool = ...) -> Any: ... # returns bytes if as_text is False (the default), else Text
|
||||
def set_data(self, value: Union[bytes, Text]) -> None: ...
|
||||
data = ... # type: Any
|
||||
def calculate_content_length(self): ...
|
||||
def make_sequence(self): ...
|
||||
def iter_encoded(self): ...
|
||||
def calculate_content_length(self) -> Optional[int]: ...
|
||||
def make_sequence(self) -> None: ...
|
||||
def iter_encoded(self) -> Iterator[bytes]: ...
|
||||
def set_cookie(self, key, value='', max_age=None, expires=None, path='', domain=None, secure=False, httponly=False): ...
|
||||
def delete_cookie(self, key, path='', domain=None): ...
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user