diff --git a/python/helpers/typeshed/stdlib/2/__builtin__.pyi b/python/helpers/typeshed/stdlib/2/__builtin__.pyi index b781292ec2b6..0b8dfb1b3b19 100644 --- a/python/helpers/typeshed/stdlib/2/__builtin__.pyi +++ b/python/helpers/typeshed/stdlib/2/__builtin__.pyi @@ -789,7 +789,10 @@ def sorted(iterable: Iterable[_T], *, cmp: Callable[[_T, _T], int] = ..., key: Callable[[_T], Any] = ..., reverse: bool = ...) -> List[_T]: ... -def sum(iterable: Iterable[_T], start: _T = ...) -> _T: ... +@overload +def sum(iterable: Iterable[_T]) -> Union[_T, int]: ... +@overload +def sum(iterable: Iterable[_T], start: _S) -> Union[_T, _S]: ... def unichr(i: int) -> unicode: ... def vars(object: Any = ...) -> Dict[str, Any]: ... @overload diff --git a/python/helpers/typeshed/stdlib/2/datetime.pyi b/python/helpers/typeshed/stdlib/2/datetime.pyi index 2a804b213016..725aee3d8b56 100644 --- a/python/helpers/typeshed/stdlib/2/datetime.pyi +++ b/python/helpers/typeshed/stdlib/2/datetime.pyi @@ -141,10 +141,10 @@ class datetime(object): resolution = ... # type: timedelta def __init__(self, year: int, month: int, day: int, hour: int = ..., - minute: int = ..., second: int = ..., microseconds: int = ..., + minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: tzinfo = ...) -> None: ... def __new__(cls, year: int, month: int, day: int, hour: int = ..., - minute: int = ..., second: int = ..., microseconds: int = ..., + minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: tzinfo = ...) -> datetime: ... @property diff --git a/python/helpers/typeshed/stdlib/2/whichdb.pyi b/python/helpers/typeshed/stdlib/2/whichdb.pyi new file mode 100644 index 000000000000..b1a69f4816c4 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/whichdb.pyi @@ -0,0 +1,5 @@ +# Source: https://hg.python.org/cpython/file/2.7/Lib/whichdb.py + +from typing import Optional, Text + +def whichdb(filename: Text) -> Optional[str]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/crypt.pyi b/python/helpers/typeshed/stdlib/2and3/crypt.pyi new file mode 100644 index 000000000000..db0e24aaec34 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/crypt.pyi @@ -0,0 +1,18 @@ +import sys +from typing import List, NamedTuple, Optional, Union + + +if sys.version_info >= (3, 3): + class _Method: ... + + METHOD_CRYPT: _Method + METHOD_MD5: _Method + METHOD_SHA256: _Method + METHOD_SHA512: _Method + + methods: List[_Method] + + def mksalt(method: Optional[_Method] = ...) -> str: ... + def crypt(word: str, salt: Optional[Union[str, _Method]] = ...) -> str: ... +else: + def crypt(word: str, salt: str) -> str: ... diff --git a/python/helpers/typeshed/stdlib/2and3/socket.pyi b/python/helpers/typeshed/stdlib/2and3/socket.pyi index 34ed45206fa7..4fc8f0d030c4 100644 --- a/python/helpers/typeshed/stdlib/2and3/socket.pyi +++ b/python/helpers/typeshed/stdlib/2and3/socket.pyi @@ -6,21 +6,21 @@ # see: http://nullege.com/codes/search/socket # adapted for Python 2.7 by Michal Pokorny import sys -from typing import Any, Tuple, List, Optional, Union, overload, TypeVar +from typing import Any, Iterable, Tuple, List, Optional, Union, overload, TypeVar # ----- variables and constants ----- -AF_UNIX: int -AF_INET: int -AF_INET6: int -SOCK_STREAM: int -SOCK_DGRAM: int -SOCK_RAW: int -SOCK_RDM: int -SOCK_SEQPACKET: int -SOCK_CLOEXEC: int -SOCK_NONBLOCK: int +AF_UNIX: AddressFamily +AF_INET: AddressFamily +AF_INET6: AddressFamily +SOCK_STREAM: SocketKind +SOCK_DGRAM: SocketKind +SOCK_RAW: SocketKind +SOCK_RDM: SocketKind +SOCK_SEQPACKET: SocketKind +SOCK_CLOEXEC: SocketKind +SOCK_NONBLOCK: SocketKind SOMAXCONN: int has_ipv6: bool _GLOBAL_DEFAULT_TIMEOUT: Any @@ -28,46 +28,46 @@ SocketType: Any SocketIO: Any # These are flags that may exist on Python 3.6. Many don't exist on all platforms. -AF_AAL5: int -AF_APPLETALK: int -AF_ASH: int -AF_ATMPVC: int -AF_ATMSVC: int -AF_AX25: int -AF_BLUETOOTH: int -AF_BRIDGE: int -AF_CAN: int -AF_DECnet: int -AF_ECONET: int -AF_IPX: int -AF_IRDA: int -AF_KEY: int -AF_LLC: int -AF_NETBEUI: int -AF_NETLINK: int -AF_NETROM: int -AF_PACKET: int -AF_PPPOX: int -AF_RDS: int -AF_ROSE: int -AF_ROUTE: int -AF_SECURITY: int -AF_SNA: int -AF_SYSTEM: int -AF_TIPC: int -AF_UNSPEC: int -AF_WANPIPE: int -AF_X25: int -AI_ADDRCONFIG: int -AI_ALL: int -AI_CANONNAME: int -AI_DEFAULT: int -AI_MASK: int -AI_NUMERICHOST: int -AI_NUMERICSERV: int -AI_PASSIVE: int -AI_V4MAPPED: int -AI_V4MAPPED_CFG: int +AF_AAL5: AddressFamily +AF_APPLETALK: AddressFamily +AF_ASH: AddressFamily +AF_ATMPVC: AddressFamily +AF_ATMSVC: AddressFamily +AF_AX25: AddressFamily +AF_BLUETOOTH: AddressFamily +AF_BRIDGE: AddressFamily +AF_CAN: AddressFamily +AF_DECnet: AddressFamily +AF_ECONET: AddressFamily +AF_IPX: AddressFamily +AF_IRDA: AddressFamily +AF_KEY: AddressFamily +AF_LLC: AddressFamily +AF_NETBEUI: AddressFamily +AF_NETLINK: AddressFamily +AF_NETROM: AddressFamily +AF_PACKET: AddressFamily +AF_PPPOX: AddressFamily +AF_RDS: AddressFamily +AF_ROSE: AddressFamily +AF_ROUTE: AddressFamily +AF_SECURITY: AddressFamily +AF_SNA: AddressFamily +AF_SYSTEM: AddressFamily +AF_TIPC: AddressFamily +AF_UNSPEC: AddressFamily +AF_WANPIPE: AddressFamily +AF_X25: AddressFamily +AI_ADDRCONFIG: AddressInfo +AI_ALL: AddressInfo +AI_CANONNAME: AddressInfo +AI_DEFAULT: AddressInfo +AI_MASK: AddressInfo +AI_NUMERICHOST: AddressInfo +AI_NUMERICSERV: AddressInfo +AI_PASSIVE: AddressInfo +AI_V4MAPPED: AddressInfo +AI_V4MAPPED_CFG: AddressInfo BDADDR_ANY: str BDADDR_LOCAL: str BTPROTO_HCI: int @@ -198,26 +198,26 @@ IP_TRANSPARENT: int IP_TTL: int IPX_TYPE: int LOCAL_PEERCRED: int -MSG_BCAST: int -MSG_BTAG: int -MSG_CMSG_CLOEXEC: int -MSG_CONFIRM: int -MSG_CTRUNC: int -MSG_DONTROUTE: int -MSG_DONTWAIT: int -MSG_EOF: int -MSG_EOR: int -MSG_ERRQUEUE: int -MSG_ETAG: int -MSG_FASTOPEN: int -MSG_MCAST: int -MSG_MORE: int -MSG_NOSIGNAL: int -MSG_NOTIFICATION: int -MSG_OOB: int -MSG_PEEK: int -MSG_TRUNC: int -MSG_WAITALL: int +MSG_BCAST: MsgFlag +MSG_BTAG: MsgFlag +MSG_CMSG_CLOEXEC: MsgFlag +MSG_CONFIRM: MsgFlag +MSG_CTRUNC: MsgFlag +MSG_DONTROUTE: MsgFlag +MSG_DONTWAIT: MsgFlag +MSG_EOF: MsgFlag +MSG_EOR: MsgFlag +MSG_ERRQUEUE: MsgFlag +MSG_ETAG: MsgFlag +MSG_FASTOPEN: MsgFlag +MSG_MCAST: MsgFlag +MSG_MORE: MsgFlag +MSG_NOSIGNAL: MsgFlag +MSG_NOTIFICATION: MsgFlag +MSG_OOB: MsgFlag +MSG_PEEK: MsgFlag +MSG_TRUNC: MsgFlag +MSG_WAITALL: MsgFlag NETLINK_ARPD: int NETLINK_CRYPTO: int NETLINK_DNRTMSG: int @@ -368,7 +368,7 @@ if sys.version_info >= (3, 4): CAN_BCM_RX_STATUS: int CAN_BCM_RX_TIMEOUT: int CAN_BCM_RX_CHANGED: int - AF_LINK: int + AF_LINK: AddressFamily if sys.version_info >= (3, 5): CAN_RAW_FD_FRAMES: int @@ -380,7 +380,7 @@ if sys.version_info >= (3, 6): SO_PASSSEC: int TCP_USER_TIMEOUT: int TCP_CONGESTION: int - AF_ALG: int + AF_ALG: AddressFamily SOL_ALG: int ALG_SET_KEY: int ALG_SET_IV: int @@ -449,6 +449,9 @@ if sys.version_info >= (3, 4): SOCK_SEQPACKET = ... SOCK_CLOEXEC = ... SOCK_NONBLOCK = ... +else: + AddressFamily = int + SocketKind = int if sys.version_info >= (3, 6): from enum import IntFlag @@ -471,6 +474,9 @@ if sys.version_info >= (3, 6): MSG_PEEK = ... MSG_TRUNC = ... MSG_WAITALL = ... +else: + AddressInfo = int + MsgFlag = int # ----- exceptions ----- @@ -492,6 +498,7 @@ class timeout(error): # TODO AF_PACKET and AF_BLUETOOTH address objects +_CMSG = Tuple[int, int, bytes] _SelfT = TypeVar('_SelfT', bound=socket) # ----- classes ----- @@ -543,9 +550,9 @@ class socket: # return type is an address def recvfrom(self, bufsize: int, flags: int = ...) -> Any: ... - def recvfrom_into(self, buffer: bytes, nbytes: int, + def recvfrom_into(self, buffer: bytearray, nbytes: int, flags: int = ...) -> Any: ... - def recv_into(self, buffer: bytes, nbytes: int, + def recv_into(self, buffer: bytearray, nbytes: int, flags: int = ...) -> Any: ... def send(self, data: bytes, flags: int = ...) -> int: ... def sendall(self, data: bytes, flags: int =...) -> None: @@ -559,6 +566,14 @@ class socket: def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... def shutdown(self, how: int) -> None: ... + if sys.version_info >= (3, 3): + def recvmsg(self, __bufsize: int, __ancbufsize: int = ..., + __flags: int = ...) -> Tuple[bytes, List[_CMSG], int, Any]: ... + def recvmsg_into(self, __buffers: Iterable[bytearray], __ancbufsize: int = ..., + __flags: int = ...) -> Tuple[int, List[_CMSG], int, Any]: ... + def sendmsg(self, __buffers: Iterable[bytes], __ancdata: Iterable[_CMSG] = ..., + __flags: int = ..., __address: Any = ...) -> int: ... + # ----- functions ----- def create_connection(address: Tuple[str, int], @@ -597,3 +612,11 @@ def inet_pton(address_family: int, ip_string: str) -> bytes: ... def inet_ntop(address_family: int, packed_ip: bytes) -> str: ... def getdefaulttimeout() -> Optional[float]: ... def setdefaulttimeout(timeout: Optional[float]) -> None: ... + +if sys.version_info >= (3, 3): + def CMSG_LEN(length: int) -> int: ... + def CMSG_SPACE(length: int) -> int: ... + def sethostname(name: str) -> None: ... + def if_nameindex() -> List[Tuple[int, str]]: ... + def if_nametoindex(name: str) -> int: ... + def if_indextoname(index: int) -> str: ... diff --git a/python/helpers/typeshed/stdlib/2and3/threading.pyi b/python/helpers/typeshed/stdlib/2and3/threading.pyi index eb89a2749d13..efd941fbd539 100644 --- a/python/helpers/typeshed/stdlib/2and3/threading.pyi +++ b/python/helpers/typeshed/stdlib/2and3/threading.pyi @@ -35,7 +35,7 @@ def setprofile(func: _PF) -> None: ... def stack_size(size: int = ...) -> int: ... if sys.version_info >= (3,): - TIMEOUT_MAX = ... # type: int + TIMEOUT_MAX = ... # type: float class ThreadError(Exception): ... @@ -86,7 +86,7 @@ class Lock: exc_val: Optional[Exception], exc_tb: Optional[TracebackType]) -> bool: ... if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: int = ...) -> bool: ... + def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... else: def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... @@ -100,7 +100,7 @@ class _RLock: exc_val: Optional[Exception], exc_tb: Optional[TracebackType]) -> bool: ... if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: int = ...) -> bool: ... + def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... else: def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... @@ -116,7 +116,7 @@ class Condition: exc_val: Optional[Exception], exc_tb: Optional[TracebackType]) -> bool: ... if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: int = ...) -> bool: ... + def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... else: def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... @@ -136,7 +136,7 @@ class Semaphore: exc_val: Optional[Exception], exc_tb: Optional[TracebackType]) -> bool: ... if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: int = ...) -> bool: ... + def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... else: def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... @@ -148,7 +148,7 @@ class BoundedSemaphore: exc_val: Optional[Exception], exc_tb: Optional[TracebackType]) -> bool: ... if sys.version_info >= (3,): - def acquire(self, blocking: bool = ..., timeout: int = ...) -> bool: ... + def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... else: def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/warnings.pyi b/python/helpers/typeshed/stdlib/2and3/warnings.pyi index 6e8507bfaf6d..67d2b813d61a 100644 --- a/python/helpers/typeshed/stdlib/2and3/warnings.pyi +++ b/python/helpers/typeshed/stdlib/2and3/warnings.pyi @@ -13,7 +13,7 @@ def showwarning(message: str, category: Type[Warning], filename: str, lineno: int, file: Optional[TextIO] = ..., line: Optional[str] = ...) -> None: ... def formatwarning(message: str, category: Type[Warning], filename: str, - lineno: int, line: Optional[str] = ...) -> None: ... + lineno: int, line: Optional[str] = ...) -> str: ... def filterwarnings(action: str, message: str = ..., category: Type[Warning] = ..., module: str = ..., lineno: int = ..., append: bool = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementTree.pyi b/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementTree.pyi index 404726eb5898..4831ab0e0c61 100644 --- a/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementTree.pyi +++ b/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementTree.pyi @@ -113,7 +113,7 @@ else: def tostringlist(element: Element, encoding: str=..., method: str=...) -> List[_tostring_result_type]: ... def dump(elem: Element) -> None: ... def parse(source: _file_or_filename, parser: 'XMLParser'=...) -> ElementTree: ... -def iterparse(source: _file_or_filename, events: Sequence[str]=..., parser: 'XMLParser'=...) -> Iterator[Tuple[str, Element]]: ... +def iterparse(source: _file_or_filename, events: Sequence[str]=..., parser: 'XMLParser'=...) -> Iterator[Tuple[str, Any]]: ... if sys.version_info >= (3, 4): class XMLPullParser: diff --git a/python/helpers/typeshed/stdlib/3.4/asyncio/tasks.pyi b/python/helpers/typeshed/stdlib/3.4/asyncio/tasks.pyi index 65213e691f27..b17c321a3157 100644 --- a/python/helpers/typeshed/stdlib/3.4/asyncio/tasks.pyi +++ b/python/helpers/typeshed/stdlib/3.4/asyncio/tasks.pyi @@ -31,6 +31,9 @@ def gather(coro_or_future1: _FutureT[_T1], def gather(coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], *, loop: AbstractEventLoop = ..., return_exceptions: bool = False) -> Future[Tuple[_T1, _T2]]: ... @overload +def gather(coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], coro_or_future3: _FutureT[_T3], + *, loop: AbstractEventLoop = ..., return_exceptions: bool = False) -> Future[Tuple[_T1, _T2, _T3]]: ... +@overload def gather(coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], coro_or_future3: _FutureT[_T3], coro_or_future4: _FutureT[_T4], *, loop: AbstractEventLoop = ..., return_exceptions: bool = False) -> Future[Tuple[_T1, _T2, _T3, _T4]]: ... diff --git a/python/helpers/typeshed/stdlib/3/builtins.pyi b/python/helpers/typeshed/stdlib/3/builtins.pyi index 8d0dfb88319c..7780fccc8113 100644 --- a/python/helpers/typeshed/stdlib/3/builtins.pyi +++ b/python/helpers/typeshed/stdlib/3/builtins.pyi @@ -861,7 +861,10 @@ def setattr(object: Any, name: str, value: Any) -> None: ... def sorted(iterable: Iterable[_T], *, key: Optional[Callable[[_T], Any]] = None, reverse: bool = False) -> List[_T]: ... -def sum(iterable: Iterable[_T], start: _T = ...) -> _T: ... +@overload +def sum(iterable: Iterable[_T]) -> Union[_T, int]: ... +@overload +def sum(iterable: Iterable[_T], start: _S) -> Union[_T, _S]: ... def vars(object: Any = ...) -> Dict[str, Any]: ... @overload def zip(iter1: Iterable[_T1]) -> Iterator[Tuple[_T1]]: ... diff --git a/python/helpers/typeshed/stdlib/3/datetime.pyi b/python/helpers/typeshed/stdlib/3/datetime.pyi index 8b1b2e45a1b0..6ff3adab2fb9 100644 --- a/python/helpers/typeshed/stdlib/3/datetime.pyi +++ b/python/helpers/typeshed/stdlib/3/datetime.pyi @@ -1,11 +1,10 @@ import sys +from time import struct_time from typing import Optional, SupportsAbs, Tuple, overload MINYEAR = 0 MAXYEAR = 0 -_TimeTuple = Tuple[int, int, int, int, int, int, int, int, int] - class tzinfo: def tzname(self, dt: Optional[datetime]) -> str: ... def utcoffset(self, dt: Optional[datetime]) -> Optional[timedelta]: ... @@ -150,7 +149,7 @@ class datetime: max = ... # type: datetime resolution = ... # type: timedelta - def __init__(self, year: int, month: int = ..., day: int = ..., hour: int = ..., + def __init__(self, year: int, month: int, day: int, hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: Optional[tzinfo] = ...) -> None: ... @@ -188,9 +187,9 @@ class datetime: def strftime(self, fmt: str) -> str: ... def __format__(self, fmt: str) -> str: ... def toordinal(self) -> int: ... - def timetuple(self) -> _TimeTuple: ... + def timetuple(self) -> struct_time: ... def timestamp(self) -> float: ... - def utctimetuple(self) -> _TimeTuple: ... + def utctimetuple(self) -> struct_time: ... def date(self) -> _date: ... def time(self) -> _time: ... def timetz(self) -> _time: ... diff --git a/python/helpers/typeshed/stdlib/3/email/policy.pyi b/python/helpers/typeshed/stdlib/3/email/policy.pyi index 97f0c519c5a1..615200220c4a 100644 --- a/python/helpers/typeshed/stdlib/3/email/policy.pyi +++ b/python/helpers/typeshed/stdlib/3/email/policy.pyi @@ -42,8 +42,7 @@ if sys.version_info >= (3, 3): def header_source_parse(self, sourcelines: List[str]) -> str: ... def header_store_parse(self, name: str, value: str) -> Tuple[str, str]: ... - def header_fetch_parse(self, name: str, # type: ignore - value: str) -> Union[str, Header]: ... + def header_fetch_parse(self, name: str, value: str) -> Union[str, Header]: ... # type: ignore def fold(self, name: str, value: str) -> str: ... def fold_binary(self, name: str, value: str) -> bytes: ... diff --git a/python/helpers/typeshed/stdlib/3/email/utils.pyi b/python/helpers/typeshed/stdlib/3/email/utils.pyi index efc93c16e369..6c0a18319759 100644 --- a/python/helpers/typeshed/stdlib/3/email/utils.pyi +++ b/python/helpers/typeshed/stdlib/3/email/utils.pyi @@ -9,8 +9,8 @@ _PDTZ = Tuple[int, int, int, int, int, int, int, int, int, Optional[int]] def quote(str: str) -> str: ... def unquote(str: str) -> str: ... -def parseaddr(address: str) -> Tuple[str, str]: ... -def formataddr(pair: Tuple[str, str], +def parseaddr(address: Optional[str]) -> Tuple[str, str]: ... +def formataddr(pair: Tuple[Optional[str], str], charset: Union[str, Charset] = ...) -> str: ... def getaddresses(fieldvalues: List[str]) -> List[Tuple[str, str]]: ... def parsedate(date: str) -> Optional[Tuple[int, int, int, int, int, int, int, int, int]]: ... diff --git a/python/helpers/typeshed/stdlib/3/gzip.pyi b/python/helpers/typeshed/stdlib/3/gzip.pyi index c4420fb1c1a1..8a6f43ecbc6a 100644 --- a/python/helpers/typeshed/stdlib/3/gzip.pyi +++ b/python/helpers/typeshed/stdlib/3/gzip.pyi @@ -1,13 +1,13 @@ -from typing import Any +from typing import Any, Optional import _compression -def open(filename, mode='', compresslevel=9, encoding=None, errors=None, newline=None): ... +def open(filename, mode: str = ..., compresslevel: int = ..., encoding=None, errors=None, newline=None): ... class _PaddedFile: file = ... # type: Any - def __init__(self, f, prepend=b''): ... + def __init__(self, f, prepend: bytes = ...) -> None: ... def read(self, size): ... - def prepend(self, prepend=b''): ... + def prepend(self, prepend: bytes = ...): ... def seek(self, off): ... def seekable(self): ... @@ -17,15 +17,15 @@ class GzipFile(_compression.BaseStream): name = ... # type: Any compress = ... # type: Any fileobj = ... # type: Any - def __init__(self, filename=None, mode=None, compresslevel=9, fileobj=None, mtime=None): ... + def __init__(self, filename=None, mode=None, compresslevel: int = ..., fileobj=None, mtime=None) -> None: ... @property def filename(self): ... @property def mtime(self): ... crc = ... # type: Any def write(self, data): ... - def read(self, size=-1): ... - def read1(self, size=-1): ... + def read(self, size: Optional[int] = ...): ... + def read1(self, size: int = ...): ... def peek(self, n): ... @property def closed(self): ... @@ -37,11 +37,11 @@ class GzipFile(_compression.BaseStream): def writable(self): ... def seekable(self): ... def seek(self, offset, whence=...): ... - def readline(self, size=-1): ... + def readline(self, size: int = ...): ... class _GzipReader(_compression.DecompressReader): - def __init__(self, fp): ... - def read(self, size=-1): ... + def __init__(self, fp) -> None: ... + def read(self, size: int = ...): ... -def compress(data, compresslevel=9): ... +def compress(data, compresslevel: int = ...): ... def decompress(data): ... diff --git a/python/helpers/typeshed/stdlib/3/itertools.pyi b/python/helpers/typeshed/stdlib/3/itertools.pyi index 1f79cd2570f0..6421163ff161 100644 --- a/python/helpers/typeshed/stdlib/3/itertools.pyi +++ b/python/helpers/typeshed/stdlib/3/itertools.pyi @@ -7,9 +7,10 @@ from typing import (Iterator, TypeVar, Iterable, overload, Any, Callable, Tuple, _T = TypeVar('_T') _S = TypeVar('_S') +_N = TypeVar('_N', int, float) -def count(start: int = ..., - step: int = ...) -> Iterator[int]: ... # more general types? +def count(start: _N = ..., + step: _N = ...) -> Iterator[_N]: ... # more general types? def cycle(iterable: Iterable[_T]) -> Iterator[_T]: ... @overload diff --git a/python/helpers/typeshed/stdlib/3/json/decoder.pyi b/python/helpers/typeshed/stdlib/3/json/decoder.pyi index 1c3e9a05b05b..164fcadce81c 100644 --- a/python/helpers/typeshed/stdlib/3/json/decoder.pyi +++ b/python/helpers/typeshed/stdlib/3/json/decoder.pyi @@ -11,12 +11,12 @@ if sys.version_info >= (3, 5): def __init__(self, msg: str, doc: str, pos: int) -> None: ... class JSONDecoder: - object_hook = None # type: Callable[[Dict[str, Any]], Any] - parse_float = ... # Callable[[str], Any] - parse_int = ... # Callable[[str], Any] + object_hook = ... # type: Callable[[Dict[str, Any]], Any] + parse_float = ... # type: Callable[[str], Any] + parse_int = ... # type: Callable[[str], Any] parse_constant = ... # Callable[[str], Any] strict = ... # type: bool - object_pairs_hook = None # type: Callable[[List[Tuple[str, Any]]], Any] + object_pairs_hook = ... # type: Callable[[List[Tuple[str, Any]]], Any] def __init__(self, object_hook: Optional[Callable[[Dict[str, Any]], Any]] = None, parse_float: Optional[Callable[[str], Any]] = None, diff --git a/python/helpers/typeshed/stdlib/3/json/encoder.pyi b/python/helpers/typeshed/stdlib/3/json/encoder.pyi index c423c182ab50..ced7168b9a33 100644 --- a/python/helpers/typeshed/stdlib/3/json/encoder.pyi +++ b/python/helpers/typeshed/stdlib/3/json/encoder.pyi @@ -9,7 +9,7 @@ class JSONEncoder: check_circular = ... # type: bool allow_nan = ... # type: bool sort_keys = ... # type: bool - indent = None # type: int + indent = ... # type: int def __init__(self, skipkeys: bool = ..., ensure_ascii: bool = ..., check_circular: bool = ..., allow_nan: bool = ..., sort_keys: bool = ..., diff --git a/python/helpers/typeshed/stdlib/3/time.pyi b/python/helpers/typeshed/stdlib/3/time.pyi index 597fb8e53d2c..bde37d2eead4 100644 --- a/python/helpers/typeshed/stdlib/3/time.pyi +++ b/python/helpers/typeshed/stdlib/3/time.pyi @@ -91,4 +91,4 @@ if sys.version_info >= (3, 3): if sys.platform != 'win32': def clock_getres(clk_id: int) -> float: ... # Unix only def clock_gettime(clk_id: int) -> float: ... # Unix only - def clock_settime(clk_id: int, time: struct_time) -> float: ... # Unix only + def clock_settime(clk_id: int, time: float) -> None: ... # Unix only diff --git a/python/helpers/typeshed/stdlib/3/tkinter/__init__.pyi b/python/helpers/typeshed/stdlib/3/tkinter/__init__.pyi index 4ef707930fa8..f7f7f8cf061d 100644 --- a/python/helpers/typeshed/stdlib/3/tkinter/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/tkinter/__init__.pyi @@ -57,12 +57,12 @@ class Misc: def tk_bisque(self): ... def tk_setPalette(self, *args, **kw): ... def tk_menuBar(self, *args): ... - def wait_variable(self, name=''): ... + def wait_variable(self, name: str = ...): ... waitvar = ... # type: Any def wait_window(self, window=None): ... def wait_visibility(self, window=None): ... - def setvar(self, name='', value=''): ... - def getvar(self, name=''): ... + def setvar(self, name: str = ..., value: str = ...): ... + def getvar(self, name: str = ...): ... def getint(self, s): ... def getdouble(self, s): ... def getboolean(self, s): ... @@ -278,14 +278,14 @@ class Tk(Misc, Wm): master = ... # type: Any children = ... # type: Any tk = ... # type: Any - def __init__(self, screenName=None, baseName=None, className='', useTk=1, sync=0, use=None): ... + def __init__(self, screenName=None, baseName=None, className: str = ..., useTk=1, sync=0, use=None) -> None: ... def loadtk(self): ... def destroy(self): ... def readprofile(self, baseName, className): ... def report_callback_exception(self, exc, val, tb): ... def __getattr__(self, attr): ... -def Tcl(screenName=None, baseName=None, className='', useTk=0): ... +def Tcl(screenName=None, baseName=None, className: str = ..., useTk=0): ... class Pack: def pack_configure(self, cnf=..., **kw): ... @@ -461,7 +461,7 @@ class Listbox(Widget, XView, YView): class Menu(Widget): def __init__(self, master=None, cnf=..., **kw): ... - def tk_popup(self, x, y, entry=''): ... + def tk_popup(self, x, y, entry: str = ...): ... def tk_bindForTraversal(self): ... def activate(self, index): ... def add(self, itemType, cnf=..., **kw): ... @@ -603,8 +603,8 @@ class PhotoImage(Image): def cget(self, option): ... def __getitem__(self, key): ... def copy(self): ... - def zoom(self, x, y=''): ... - def subsample(self, x, y=''): ... + def zoom(self, x, y: str = ...): ... + def subsample(self, x, y: str = ...): ... def get(self, x, y): ... def put(self, data, to=None): ... def write(self, filename, format=None, from_coords=None): ... diff --git a/python/helpers/typeshed/stdlib/3/unittest/mock.pyi b/python/helpers/typeshed/stdlib/3/unittest/mock.pyi index 4c78a0f83d7b..2002f89338d0 100644 --- a/python/helpers/typeshed/stdlib/3/unittest/mock.pyi +++ b/python/helpers/typeshed/stdlib/3/unittest/mock.pyi @@ -38,7 +38,7 @@ if sys.version_info >= (3, 3): # expecting other classes (as is Mock's purpose) class NonCallableMock(Any): # type: ignore def __new__(cls, *args: Any, **kw: Any) -> Any: ... - def __init__(self, spec: Optional[Any] = None, wraps: Optional[Any] = None, name: Optional[Any] = None, spec_set: Optional[Any] = None, parent: Optional[Any] = None, _spec_state: Optional[Any] = None, _new_name: Any ='', _new_parent: Optional[Any] = None, _spec_as_instance: Any = False, _eat_self: Optional[Any] = None, unsafe: Any = False, **kwargs: Any) -> None: ... + def __init__(self, spec: Optional[Any] = None, wraps: Optional[Any] = None, name: Optional[Any] = None, spec_set: Optional[Any] = None, parent: Optional[Any] = None, _spec_state: Optional[Any] = None, _new_name: Any = ..., _new_parent: Optional[Any] = None, _spec_as_instance: Any = False, _eat_self: Optional[Any] = None, unsafe: Any = False, **kwargs: Any) -> None: ... def attach_mock(self, mock: Any, attribute: Any) -> Any: ... def mock_add_spec(self, spec: Any, spec_set: Any = False) -> Any: ... return_value = ... # type: Any @@ -64,7 +64,7 @@ if sys.version_info >= (3, 3): class CallableMixin(Base): side_effect = ... # type: Any - def __init__(self, spec: Optional[Any] = None, side_effect: Optional[Any] = None, return_value: Any = ..., wraps: Optional[Any] = None, name: Optional[Any] = None, spec_set: Optional[Any] = None, parent: Optional[Any] = None, _spec_state: Optional[Any] = None, _new_name: Any = '', _new_parent: Optional[Any] = None, **kwargs: Any) -> None: ... + def __init__(self, spec: Optional[Any] = None, side_effect: Optional[Any] = None, return_value: Any = ..., wraps: Optional[Any] = None, name: Optional[Any] = None, spec_set: Optional[Any] = None, parent: Optional[Any] = None, _spec_state: Optional[Any] = None, _new_name: Any = ..., _new_parent: Optional[Any] = None, **kwargs: Any) -> None: ... def __call__(_mock_self, *args: Any, **kwargs: Any) -> Any: ... class Mock(CallableMixin, NonCallableMock): @@ -167,7 +167,7 @@ if sys.version_info >= (3, 3): name = ... # type: Any def __init__(self, spec: Any, spec_set: Any = False, parent: Optional[Any] = None, name: Optional[Any] = None, ids: Optional[Any] = None, instance: Any = False) -> None: ... - def mock_open(mock: Optional[Any] = None, read_data: Any = '') -> Any: ... + def mock_open(mock: Optional[Any] = None, read_data: Any = ...) -> Any: ... class PropertyMock(Mock): def __get__(self, obj: Any, obj_type: Any) -> Any: ... diff --git a/python/helpers/typeshed/stdlib/3/urllib/parse.pyi b/python/helpers/typeshed/stdlib/3/urllib/parse.pyi index 637fa5fa66dc..c8f4c11010a5 100644 --- a/python/helpers/typeshed/stdlib/3/urllib/parse.pyi +++ b/python/helpers/typeshed/stdlib/3/urllib/parse.pyi @@ -4,23 +4,7 @@ import sys _Str = Union[bytes, str] -__all__ = ( - 'urlparse', - 'urlunparse', - 'urljoin', - 'urldefrag', - 'urlsplit', - 'urlunsplit', - 'urlencode', - 'parse_qs', - 'parse_qsl', - 'quote', - 'quote_plus', - 'quote_from_bytes', - 'unquote', - 'unquote_plus', - 'unquote_to_bytes' -) +__all__ = ... # type: Tuple[str] uses_relative = ... # type: List[str] uses_netloc = ... # type: List[str] diff --git a/python/helpers/typeshed/tests/pytype_blacklist.txt b/python/helpers/typeshed/tests/pytype_blacklist.txt index 53377dbe809d..332c8a14440e 100644 --- a/python/helpers/typeshed/tests/pytype_blacklist.txt +++ b/python/helpers/typeshed/tests/pytype_blacklist.txt @@ -8,9 +8,6 @@ stdlib/2/typing.pyi stdlib/3/builtins.pyi stdlib/3/typing.pyi -# Because of 'class ForkProcess(Any): # type: ignore' -stdlib/3/multiprocessing/context.pyi - # Because of 'from . import path': stdlib/2/os/__init__.pyi stdlib/3/os/__init__.pyi @@ -23,25 +20,17 @@ stdlib/3/concurrent/futures/__init__.pyi stdlib/3/concurrent/futures/_base.pyi stdlib/3/concurrent/futures/process.pyi stdlib/3/concurrent/futures/thread.pyi -stdlib/3/email/policy.pyi -stdlib/3/fileinput.pyi -stdlib/3/gzip.pyi stdlib/3/http/__init__.pyi stdlib/3/http/cookiejar.pyi stdlib/3/inspect.pyi stdlib/3/json/__init__.pyi -stdlib/3/json/decoder.pyi -stdlib/3/json/encoder.pyi stdlib/3/ssl.pyi stdlib/3/subprocess.pyi stdlib/3/sys.pyi stdlib/3/textwrap.pyi stdlib/3/time.pyi -stdlib/3/tkinter/__init__.pyi stdlib/3/types.pyi stdlib/3/unittest/__init__.pyi -stdlib/3/unittest/mock.pyi -stdlib/3/urllib/parse.pyi stdlib/3/wsgiref/types.pyi stdlib/3.4/asyncio/events.pyi stdlib/3.4/asyncio/futures.pyi @@ -50,4 +39,3 @@ stdlib/3.4/asyncio/queues.pyi stdlib/3.4/asyncio/streams.pyi stdlib/3.4/asyncio/subprocess.pyi stdlib/3.4/asyncio/tasks.pyi -stdlib/3.4/enum.pyi diff --git a/python/helpers/typeshed/third_party/2/pycurl.pyi b/python/helpers/typeshed/third_party/2/pycurl.pyi index 85f2b138727d..4272f28390fe 100644 --- a/python/helpers/typeshed/third_party/2/pycurl.pyi +++ b/python/helpers/typeshed/third_party/2/pycurl.pyi @@ -1,12 +1,13 @@ # TODO(MichalPokorny): more precise types -from typing import Any, Tuple, Optional +from typing import Any, Tuple +GLOBAL_ACK_EINTR = ... # type: int +GLOBAL_ALL = ... # type: int +GLOBAL_DEFAULT = ... # type: int +GLOBAL_NOTHING = ... # type: int GLOBAL_SSL = ... # type: int GLOBAL_WIN32 = ... # type: int -GLOBAL_ALL = ... # type: int -GLOBAL_NOTHING = ... # type: int -GLOBAL_DEFAULT = ... # type: int def global_init(option: int) -> None: ... def global_cleanup() -> None: ... @@ -39,20 +40,26 @@ class CurlMulti(object): def perform(self) -> Tuple[Any, int]: ... def fdset(self) -> tuple: ... def select(self, timeout: float = ...) -> int: ... - def info_read(self, max_objects: int) -> tuple: ... + def info_read(self, max_objects: int = ...) -> tuple: ... class CurlShare(object): def close(self) -> None: ... def setopt(self, option: int, value: Any) -> Any: ... +ACCEPTTIMEOUT_MS = ... # type: int +ACCEPT_ENCODING = ... # type: int ADDRESS_SCOPE = ... # type: int APPCONNECT_TIME = ... # type: int +APPEND = ... # type: int AUTOREFERER = ... # type: int BUFFERSIZE = ... # type: int CAINFO = ... # type: int CAPATH = ... # type: int +CLOSESOCKETFUNCTION = ... # type: int +COMPILE_DATE = ... # type: str COMPILE_LIBCURL_VERSION_NUM = ... # type: int COMPILE_PY_VERSION_HEX = ... # type: int +CONDITION_UNMET = ... # type: int CONNECTTIMEOUT = ... # type: int CONNECTTIMEOUT_MS = ... # type: int CONNECT_ONLY = ... # type: int @@ -64,6 +71,7 @@ COOKIE = ... # type: int COOKIEFILE = ... # type: int COOKIEJAR = ... # type: int COOKIELIST = ... # type: int +COOKIESESSION = ... # type: int COPYPOSTFIELDS = ... # type: int CRLF = ... # type: int CRLFILE = ... # type: int @@ -72,19 +80,26 @@ CSELECT_IN = ... # type: int CSELECT_OUT = ... # type: int CURL_HTTP_VERSION_1_0 = ... # type: int CURL_HTTP_VERSION_1_1 = ... # type: int +CURL_HTTP_VERSION_2 = ... # type: int +CURL_HTTP_VERSION_2_0 = ... # type: int CURL_HTTP_VERSION_LAST = ... # type: int CURL_HTTP_VERSION_NONE = ... # type: int CUSTOMREQUEST = ... # type: int DEBUGFUNCTION = ... # type: int +DIRLISTONLY = ... # type: int DNS_CACHE_TIMEOUT = ... # type: int +DNS_SERVERS = ... # type: int DNS_USE_GLOBAL_CACHE = ... # type: int EFFECTIVE_URL = ... # type: int EGDSOCKET = ... # type: int ENCODING = ... # type: int +EXPECT_100_TIMEOUT_MS = ... # type: int FAILONERROR = ... # type: int FILE = ... # type: int FOLLOWLOCATION = ... # type: int FORBID_REUSE = ... # type: int +FORM_BUFFER = ... # type: int +FORM_BUFFERPTR = ... # type: int FORM_CONTENTS = ... # type: int FORM_CONTENTTYPE = ... # type: int FORM_FILE = ... # type: int @@ -116,9 +131,17 @@ FTP_SSL = ... # type: int FTP_SSL_CCC = ... # type: int FTP_USE_EPRT = ... # type: int FTP_USE_EPSV = ... # type: int +FTP_USE_PRET = ... # type: int +GSSAPI_DELEGATION = ... # type: int +GSSAPI_DELEGATION_FLAG = ... # type: int +GSSAPI_DELEGATION_NONE = ... # type: int +GSSAPI_DELEGATION_POLICY_FLAG = ... # type: int HEADER = ... # type: int HEADERFUNCTION = ... # type: int +HEADEROPT = ... # type: int +HEADER_SEPARATE = ... # type: int HEADER_SIZE = ... # type: int +HEADER_UNIFIED = ... # type: int HTTP200ALIASES = ... # type: int HTTPAUTH = ... # type: int HTTPAUTH_ANY = ... # type: int @@ -126,9 +149,13 @@ HTTPAUTH_ANYSAFE = ... # type: int HTTPAUTH_AVAIL = ... # type: int HTTPAUTH_BASIC = ... # type: int HTTPAUTH_DIGEST = ... # type: int +HTTPAUTH_DIGEST_IE = ... # type: int HTTPAUTH_GSSNEGOTIATE = ... # type: int +HTTPAUTH_NEGOTIATE = ... # type: int HTTPAUTH_NONE = ... # type: int HTTPAUTH_NTLM = ... # type: int +HTTPAUTH_NTLM_WB = ... # type: int +HTTPAUTH_ONLY = ... # type: int HTTPGET = ... # type: int HTTPHEADER = ... # type: int HTTPPOST = ... # type: int @@ -149,8 +176,13 @@ INFOTYPE_HEADER_OUT = ... # type: int INFOTYPE_SSL_DATA_IN = ... # type: int INFOTYPE_SSL_DATA_OUT = ... # type: int INFOTYPE_TEXT = ... # type: int +INFO_CERTINFO = ... # type: int INFO_COOKIELIST = ... # type: int INFO_FILETIME = ... # type: int +INFO_RTSP_CLIENT_CSEQ = ... # type: int +INFO_RTSP_CSEQ_RECV = ... # type: int +INFO_RTSP_SERVER_CSEQ = ... # type: int +INFO_RTSP_SESSION_ID = ... # type: int INTERFACE = ... # type: int IOCMD_NOP = ... # type: int IOCMD_RESTARTREAD = ... # type: int @@ -164,20 +196,51 @@ IPRESOLVE_V4 = ... # type: int IPRESOLVE_V6 = ... # type: int IPRESOLVE_WHATEVER = ... # type: int ISSUERCERT = ... # type: int +KEYPASSWD = ... # type: int +KHMATCH_MISMATCH = ... # type: int +KHMATCH_MISSING = ... # type: int +KHMATCH_OK = ... # type: int +KHSTAT_DEFER = ... # type: int +KHSTAT_FINE = ... # type: int +KHSTAT_FINE_ADD_TO_FILE = ... # type: int +KHSTAT_REJECT = ... # type: int +KHTYPE_DSS = ... # type: int +KHTYPE_RSA = ... # type: int +KHTYPE_RSA1 = ... # type: int +KHTYPE_UNKNOWN = ... # type: int KRB4LEVEL = ... # type: int +KRBLEVEL = ... # type: int LASTSOCKET = ... # type: int LOCALPORT = ... # type: int LOCALPORTRANGE = ... # type: int +LOCAL_IP = ... # type: int +LOCAL_PORT = ... # type: int LOCK_DATA_COOKIE = ... # type: int LOCK_DATA_DNS = ... # type: int +LOCK_DATA_SSL_SESSION = ... # type: int +LOGIN_OPTIONS = ... # type: int LOW_SPEED_LIMIT = ... # type: int LOW_SPEED_TIME = ... # type: int +MAIL_AUTH = ... # type: int +MAIL_FROM = ... # type: int +MAIL_RCPT = ... # type: int MAXCONNECTS = ... # type: int MAXFILESIZE = ... # type: int MAXFILESIZE_LARGE = ... # type: int MAXREDIRS = ... # type: int MAX_RECV_SPEED_LARGE = ... # type: int MAX_SEND_SPEED_LARGE = ... # type: int +M_CHUNK_LENGTH_PENALTY_SIZE = ... # type: int +M_CONTENT_LENGTH_PENALTY_SIZE = ... # type: int +M_MAXCONNECTS = ... # type: int +M_MAX_HOST_CONNECTIONS = ... # type: int +M_MAX_PIPELINE_LENGTH = ... # type: int +M_MAX_TOTAL_CONNECTIONS = ... # type: int +M_PIPELINING = ... # type: int +M_PIPELINING_SERVER_BL = ... # type: int +M_PIPELINING_SITE_BL = ... # type: int +M_SOCKETFUNCTION = ... # type: int +M_TIMERFUNCTION = ... # type: int NAMELOOKUP_TIME = ... # type: int NETRC = ... # type: int NETRC_FILE = ... # type: int @@ -188,11 +251,24 @@ NEW_DIRECTORY_PERMS = ... # type: int NEW_FILE_PERMS = ... # type: int NOBODY = ... # type: int NOPROGRESS = ... # type: int +NOPROXY = ... # type: int NOSIGNAL = ... # type: int NUM_CONNECTS = ... # type: int OPENSOCKETFUNCTION = ... # type: int +OPT_CERTINFO = ... # type: int OPT_FILETIME = ... # type: int OS_ERRNO = ... # type: int +PASSWORD = ... # type: int +PATH_AS_IS = ... # type: int +PAUSE_ALL = ... # type: int +PAUSE_CONT = ... # type: int +PAUSE_RECV = ... # type: int +PAUSE_SEND = ... # type: int +PINNEDPUBLICKEY = ... # type: int +PIPEWAIT = ... # type: int +PIPE_HTTP1 = ... # type: int +PIPE_MULTIPLEX = ... # type: int +PIPE_NOTHING = ... # type: int POLL_IN = ... # type: int POLL_INOUT = ... # type: int POLL_NONE = ... # type: int @@ -205,19 +281,58 @@ POSTFIELDS = ... # type: int POSTFIELDSIZE = ... # type: int POSTFIELDSIZE_LARGE = ... # type: int POSTQUOTE = ... # type: int +POSTREDIR = ... # type: int PREQUOTE = ... # type: int PRETRANSFER_TIME = ... # type: int PRIMARY_IP = ... # type: int +PRIMARY_PORT = ... # type: int PROGRESSFUNCTION = ... # type: int +PROTOCOLS = ... # type: int +PROTO_ALL = ... # type: int +PROTO_DICT = ... # type: int +PROTO_FILE = ... # type: int +PROTO_FTP = ... # type: int +PROTO_FTPS = ... # type: int +PROTO_GOPHER = ... # type: int +PROTO_HTTP = ... # type: int +PROTO_HTTPS = ... # type: int +PROTO_IMAP = ... # type: int +PROTO_IMAPS = ... # type: int +PROTO_LDAP = ... # type: int +PROTO_LDAPS = ... # type: int +PROTO_POP3 = ... # type: int +PROTO_POP3S = ... # type: int +PROTO_RTMP = ... # type: int +PROTO_RTMPE = ... # type: int +PROTO_RTMPS = ... # type: int +PROTO_RTMPT = ... # type: int +PROTO_RTMPTE = ... # type: int +PROTO_RTMPTS = ... # type: int +PROTO_RTSP = ... # type: int +PROTO_SCP = ... # type: int +PROTO_SFTP = ... # type: int +PROTO_SMB = ... # type: int +PROTO_SMBS = ... # type: int +PROTO_SMTP = ... # type: int +PROTO_SMTPS = ... # type: int +PROTO_TELNET = ... # type: int +PROTO_TFTP = ... # type: int PROXY = ... # type: int PROXYAUTH = ... # type: int PROXYAUTH_AVAIL = ... # type: int +PROXYHEADER = ... # type: int +PROXYPASSWORD = ... # type: int PROXYPORT = ... # type: int PROXYTYPE = ... # type: int PROXYTYPE_HTTP = ... # type: int +PROXYTYPE_HTTP_1_0 = ... # type: int PROXYTYPE_SOCKS4 = ... # type: int +PROXYTYPE_SOCKS4A = ... # type: int PROXYTYPE_SOCKS5 = ... # type: int +PROXYTYPE_SOCKS5_HOSTNAME = ... # type: int +PROXYUSERNAME = ... # type: int PROXYUSERPWD = ... # type: int +PROXY_SERVICE_NAME = ... # type: int PROXY_TRANSFER_MODE = ... # type: int PUT = ... # type: int QUOTE = ... # type: int @@ -226,20 +341,41 @@ RANGE = ... # type: int READDATA = ... # type: int READFUNCTION = ... # type: int READFUNC_ABORT = ... # type: int +READFUNC_PAUSE = ... # type: int REDIRECT_COUNT = ... # type: int REDIRECT_TIME = ... # type: int REDIRECT_URL = ... # type: int +REDIR_POST_301 = ... # type: int +REDIR_POST_302 = ... # type: int +REDIR_POST_303 = ... # type: int +REDIR_POST_ALL = ... # type: int +REDIR_PROTOCOLS = ... # type: int REFERER = ... # type: int REQUEST_SIZE = ... # type: int +RESOLVE = ... # type: int RESPONSE_CODE = ... # type: int RESUME_FROM = ... # type: int RESUME_FROM_LARGE = ... # type: int +SASL_IR = ... # type: int +SEEKFUNCTION = ... # type: int +SEEKFUNC_CANTSEEK = ... # type: int +SEEKFUNC_FAIL = ... # type: int +SEEKFUNC_OK = ... # type: int +SERVICE_NAME = ... # type: int SHARE = ... # type: int SH_SHARE = ... # type: int SH_UNSHARE = ... # type: int SIZE_DOWNLOAD = ... # type: int SIZE_UPLOAD = ... # type: int SOCKET_TIMEOUT = ... # type: int +SOCKOPTFUNCTION = ... # type: int +SOCKOPT_ALREADY_CONNECTED = ... # type: int +SOCKOPT_ERROR = ... # type: int +SOCKOPT_OK = ... # type: int +SOCKS5_GSSAPI_NEC = ... # type: int +SOCKS5_GSSAPI_SERVICE = ... # type: int +SOCKTYPE_ACCEPT = ... # type: int +SOCKTYPE_IPCXN = ... # type: int SPEED_DOWNLOAD = ... # type: int SPEED_UPLOAD = ... # type: int SSH_AUTH_ANY = ... # type: int @@ -251,6 +387,8 @@ SSH_AUTH_PASSWORD = ... # type: int SSH_AUTH_PUBLICKEY = ... # type: int SSH_AUTH_TYPES = ... # type: int SSH_HOST_PUBLIC_KEY_MD5 = ... # type: int +SSH_KEYFUNCTION = ... # type: int +SSH_KNOWNHOSTS = ... # type: int SSH_PRIVATE_KEYFILE = ... # type: int SSH_PUBLIC_KEYFILE = ... # type: int SSLCERT = ... # type: int @@ -261,20 +399,34 @@ SSLENGINE_DEFAULT = ... # type: int SSLKEY = ... # type: int SSLKEYPASSWD = ... # type: int SSLKEYTYPE = ... # type: int +SSLOPT_ALLOW_BEAST = ... # type: int SSLVERSION = ... # type: int SSLVERSION_DEFAULT = ... # type: int SSLVERSION_SSLv2 = ... # type: int SSLVERSION_SSLv3 = ... # type: int SSLVERSION_TLSv1 = ... # type: int +SSLVERSION_TLSv1_0 = ... # type: int +SSLVERSION_TLSv1_1 = ... # type: int +SSLVERSION_TLSv1_2 = ... # type: int SSL_CIPHER_LIST = ... # type: int +SSL_ENABLE_ALPN = ... # type: int +SSL_ENABLE_NPN = ... # type: int SSL_ENGINES = ... # type: int +SSL_FALSESTART = ... # type: int +SSL_OPTIONS = ... # type: int SSL_SESSIONID_CACHE = ... # type: int SSL_VERIFYHOST = ... # type: int SSL_VERIFYPEER = ... # type: int SSL_VERIFYRESULT = ... # type: int +SSL_VERIFYSTATUS = ... # type: int STARTTRANSFER_TIME = ... # type: int STDERR = ... # type: int +TCP_KEEPALIVE = ... # type: int +TCP_KEEPIDLE = ... # type: int +TCP_KEEPINTVL = ... # type: int TCP_NODELAY = ... # type: int +TELNETOPTIONS = ... # type: int +TFTP_BLKSIZE = ... # type: int TIMECONDITION = ... # type: int TIMECONDITION_IFMODSINCE = ... # type: int TIMECONDITION_IFUNMODSINCE = ... # type: int @@ -283,23 +435,63 @@ TIMECONDITION_NONE = ... # type: int TIMEOUT = ... # type: int TIMEOUT_MS = ... # type: int TIMEVALUE = ... # type: int +TLSAUTH_PASSWORD = ... # type: int +TLSAUTH_TYPE = ... # type: int +TLSAUTH_USERNAME = ... # type: int TOTAL_TIME = ... # type: int TRANSFERTEXT = ... # type: int +TRANSFER_ENCODING = ... # type: int +UNIX_SOCKET_PATH = ... # type: int UNRESTRICTED_AUTH = ... # type: int UPLOAD = ... # type: int URL = ... # type: int USERAGENT = ... # type: int +USERNAME = ... # type: int USERPWD = ... # type: int +USESSL_ALL = ... # type: int +USESSL_CONTROL = ... # type: int +USESSL_NONE = ... # type: int +USESSL_TRY = ... # type: int +USE_SSL = ... # type: int VERBOSE = ... # type: int +VERSION_ASYNCHDNS = ... # type: int +VERSION_CONV = ... # type: int +VERSION_CURLDEBUG = ... # type: int +VERSION_DEBUG = ... # type: int +VERSION_GSSAPI = ... # type: int +VERSION_GSSNEGOTIATE = ... # type: int +VERSION_HTTP2 = ... # type: int +VERSION_IDN = ... # type: int +VERSION_IPV6 = ... # type: int +VERSION_KERBEROS4 = ... # type: int +VERSION_KERBEROS5 = ... # type: int +VERSION_LARGEFILE = ... # type: int +VERSION_LIBZ = ... # type: int +VERSION_NTLM = ... # type: int +VERSION_NTLM_WB = ... # type: int +VERSION_SPNEGO = ... # type: int +VERSION_SSL = ... # type: int +VERSION_SSPI = ... # type: int +VERSION_TLSAUTH_SRP = ... # type: int +VERSION_UNIX_SOCKETS = ... # type: int +WILDCARDMATCH = ... # type: int WRITEDATA = ... # type: int WRITEFUNCTION = ... # type: int +WRITEFUNC_PAUSE = ... # type: int WRITEHEADER = ... # type: int +XFERINFOFUNCTION = ... # type: int +XOAUTH2_BEARER = ... # type: int E_ABORTED_BY_CALLBACK = ... # type: int +E_AGAIN = ... # type: int +E_ALREADY_COMPLETE = ... # type: int +E_BAD_CALLING_ORDER = ... # type: int E_BAD_CONTENT_ENCODING = ... # type: int E_BAD_DOWNLOAD_RESUME = ... # type: int E_BAD_FUNCTION_ARGUMENT = ... # type: int +E_BAD_PASSWORD_ENTERED = ... # type: int E_CALL_MULTI_PERFORM = ... # type: int +E_CHUNK_FAILED = ... # type: int E_CONV_FAILED = ... # type: int E_CONV_REQD = ... # type: int E_COULDNT_CONNECT = ... # type: int @@ -308,18 +500,26 @@ E_COULDNT_RESOLVE_PROXY = ... # type: int E_FAILED_INIT = ... # type: int E_FILESIZE_EXCEEDED = ... # type: int E_FILE_COULDNT_READ_FILE = ... # type: int +E_FTP_ACCEPT_FAILED = ... # type: int +E_FTP_ACCEPT_TIMEOUT = ... # type: int E_FTP_ACCESS_DENIED = ... # type: int +E_FTP_BAD_DOWNLOAD_RESUME = ... # type: int +E_FTP_BAD_FILE_LIST = ... # type: int E_FTP_CANT_GET_HOST = ... # type: int E_FTP_CANT_RECONNECT = ... # type: int E_FTP_COULDNT_GET_SIZE = ... # type: int E_FTP_COULDNT_RETR_FILE = ... # type: int E_FTP_COULDNT_SET_ASCII = ... # type: int E_FTP_COULDNT_SET_BINARY = ... # type: int +E_FTP_COULDNT_SET_TYPE = ... # type: int E_FTP_COULDNT_STOR_FILE = ... # type: int E_FTP_COULDNT_USE_REST = ... # type: int +E_FTP_PARTIAL_FILE = ... # type: int E_FTP_PORT_FAILED = ... # type: int +E_FTP_PRET_FAILED = ... # type: int E_FTP_QUOTE_ERROR = ... # type: int E_FTP_SSL_FAILED = ... # type: int +E_FTP_USER_PASSWORD_INCORRECT = ... # type: int E_FTP_WEIRD_227_FORMAT = ... # type: int E_FTP_WEIRD_PASS_REPLY = ... # type: int E_FTP_WEIRD_PASV_REPLY = ... # type: int @@ -328,6 +528,9 @@ E_FTP_WEIRD_USER_REPLY = ... # type: int E_FTP_WRITE_ERROR = ... # type: int E_FUNCTION_NOT_FOUND = ... # type: int E_GOT_NOTHING = ... # type: int +E_HTTP2 = ... # type: int +E_HTTP_NOT_FOUND = ... # type: int +E_HTTP_PORT_FAILED = ... # type: int E_HTTP_POST_ERROR = ... # type: int E_HTTP_RANGE_ERROR = ... # type: int E_HTTP_RETURNED_ERROR = ... # type: int @@ -337,18 +540,35 @@ E_LDAP_INVALID_URL = ... # type: int E_LDAP_SEARCH_FAILED = ... # type: int E_LIBRARY_NOT_FOUND = ... # type: int E_LOGIN_DENIED = ... # type: int +E_MALFORMAT_USER = ... # type: int +E_MULTI_ADDED_ALREADY = ... # type: int E_MULTI_BAD_EASY_HANDLE = ... # type: int E_MULTI_BAD_HANDLE = ... # type: int +E_MULTI_BAD_SOCKET = ... # type: int +E_MULTI_CALL_MULTI_PERFORM = ... # type: int +E_MULTI_CALL_MULTI_SOCKET = ... # type: int E_MULTI_INTERNAL_ERROR = ... # type: int E_MULTI_OK = ... # type: int E_MULTI_OUT_OF_MEMORY = ... # type: int +E_MULTI_UNKNOWN_OPTION = ... # type: int +E_NOT_BUILT_IN = ... # type: int +E_NO_CONNECTION_AVAILABLE = ... # type: int E_OK = ... # type: int +E_OPERATION_TIMEDOUT = ... # type: int E_OPERATION_TIMEOUTED = ... # type: int E_OUT_OF_MEMORY = ... # type: int E_PARTIAL_FILE = ... # type: int +E_PEER_FAILED_VERIFICATION = ... # type: int +E_QUOTE_ERROR = ... # type: int +E_RANGE_ERROR = ... # type: int E_READ_ERROR = ... # type: int E_RECV_ERROR = ... # type: int +E_REMOTE_ACCESS_DENIED = ... # type: int +E_REMOTE_DISK_FULL = ... # type: int +E_REMOTE_FILE_EXISTS = ... # type: int E_REMOTE_FILE_NOT_FOUND = ... # type: int +E_RTSP_CSEQ_ERROR = ... # type: int +E_RTSP_SESSION_ERROR = ... # type: int E_SEND_ERROR = ... # type: int E_SEND_FAIL_REWIND = ... # type: int E_SHARE_IN_USE = ... # type: int @@ -358,10 +578,14 @@ E_SSL_CACERT_BADFILE = ... # type: int E_SSL_CERTPROBLEM = ... # type: int E_SSL_CIPHER = ... # type: int E_SSL_CONNECT_ERROR = ... # type: int +E_SSL_CRL_BADFILE = ... # type: int E_SSL_ENGINE_INITFAILED = ... # type: int E_SSL_ENGINE_NOTFOUND = ... # type: int E_SSL_ENGINE_SETFAILED = ... # type: int +E_SSL_INVALIDCERTSTATUS = ... # type: int +E_SSL_ISSUER_ERROR = ... # type: int E_SSL_PEER_CERTIFICATE = ... # type: int +E_SSL_PINNEDPUBKEYNOTMATCH = ... # type: int E_SSL_SHUTDOWN_FAILED = ... # type: int E_TELNET_OPTION_SYNTAX = ... # type: int E_TFTP_DISKFULL = ... # type: int @@ -372,7 +596,11 @@ E_TFTP_NOTFOUND = ... # type: int E_TFTP_PERM = ... # type: int E_TFTP_UNKNOWNID = ... # type: int E_TOO_MANY_REDIRECTS = ... # type: int +E_UNKNOWN_OPTION = ... # type: int E_UNKNOWN_TELNET_OPTION = ... # type: int E_UNSUPPORTED_PROTOCOL = ... # type: int +E_UPLOAD_FAILED = ... # type: int E_URL_MALFORMAT = ... # type: int +E_URL_MALFORMAT_USER = ... # type: int +E_USE_SSL_FAILED = ... # type: int E_WRITE_ERROR = ... # type: int diff --git a/python/helpers/typeshed/third_party/2and3/boto/utils.pyi b/python/helpers/typeshed/third_party/2and3/boto/utils.pyi new file mode 100644 index 000000000000..b3c542540d9f --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/boto/utils.pyi @@ -0,0 +1,239 @@ +import datetime +import logging.handlers +import subprocess +import sys +import time + +import boto.connection +from typing import ( + Any, + Callable, + ContextManager, + Dict, + IO, + Iterable, + List, + Mapping, + Optional, + Sequence, + Tuple, + Type, + TypeVar, + Union, +) + +_KT = TypeVar('_KT') +_VT = TypeVar('_VT') + +if sys.version_info[0] >= 3: + # TODO move _StringIO definition into boto.compat once stubs exist and rename to StringIO + import io + _StringIO = io.StringIO + + from hashlib import _Hash + _HashType = _Hash + + from email.message import Message as _Message +else: + # TODO move _StringIO definition into boto.compat once stubs exist and rename to StringIO + import StringIO + _StringIO = StringIO.StringIO + + from hashlib import _hash + _HashType = _hash + + # TODO use email.message.Message once stubs exist + _Message = Any + +_Provider = Any # TODO replace this with boto.provider.Provider once stubs exist +_LockType = Any # TODO replace this with _thread.LockType once stubs exist + + +JSONDecodeError = ... # type: Type[ValueError] +qsa_of_interest = ... # type: List[str] + + +def unquote_v(nv: str) -> Union[str, Tuple[str, str]]: ... +def canonical_string( + method: str, + path: str, + headers: Mapping[str, Optional[str]], + expires: Optional[int] = ..., + provider: Optional[_Provider] = ..., +) -> str: ... +def merge_meta( + headers: Mapping[str, str], + metadata: Mapping[str, str], + provider: Optional[_Provider] = ..., +) -> Mapping[str, str]: ... +def get_aws_metadata( + headers: Mapping[str, str], + provider: Optional[_Provider] = ..., +) -> Mapping[str, str]: ... +def retry_url( + url: str, + retry_on_404: bool = ..., + num_retries: int = ..., + timeout: Optional[int] = ..., +) -> str: ... + +class LazyLoadMetadata(Dict[_KT, _VT]): + def __init__( + self, + url: str, + num_retries: int, + timeout: Optional[int] = ..., + ) -> None: ... + +def get_instance_metadata( + version: str = ..., + url: str = ..., + data: str = ..., + timeout: Optional[int] = ..., + num_retries: int = ..., +) -> Optional[LazyLoadMetadata]: ... +def get_instance_identity( + version: str = ..., + url: str = ..., + timeout: Optional[int] = ..., + num_retries: int = ..., +) -> Optional[Mapping[str, Any]]: ... +def get_instance_userdata( + version: str = ..., + sep: Optional[str] = ..., + url: str = ..., + timeout: Optional[int] = ..., + num_retries: int = ..., +) -> Mapping[str, str]: ... + +ISO8601 = ... # type: str +ISO8601_MS = ... # type: str +RFC1123 = ... # type: str +LOCALE_LOCK = ... # type: _LockType + +def setlocale(name: Union[str, Tuple[str, str]]) -> ContextManager[str]: ... +def get_ts(ts: Optional[time.struct_time] = ...) -> str: ... +def parse_ts(ts: str) -> datetime.datetime: ... +def find_class(module_name: str, class_name: Optional[str] = ...) -> Optional[Type[Any]]: ... +def update_dme(username: str, password: str, dme_id: str, ip_address: str) -> str: ... +def fetch_file( + uri: str, + file: Optional[IO[str]] = ..., + username: Optional[str] = ..., + password: Optional[str] = ..., +) -> Optional[IO[str]]: ... + +class ShellCommand: + exit_code = ... # type: int + command = ... # type: subprocess._CMD + log_fp = ... # type: _StringIO + wait = ... # type: bool + fail_fast = ... # type: bool + + def __init__( + self, + command: subprocess._CMD, + wait: bool = ..., + fail_fast: bool = ..., + cwd: Optional[subprocess._TXT] = ..., + ) -> None: ... + + process = ... # type: subprocess.Popen + + def run(self, cwd: Optional[subprocess._CMD] = ...) -> Optional[int]: ... + def setReadOnly(self, value) -> None: ... + def getStatus(self) -> Optional[int]: ... + + status = ... # type: Optional[int] + + def getOutput(self) -> str: ... + + output = ... # type: str + +class AuthSMTPHandler(logging.handlers.SMTPHandler): + username = ... # type: str + password = ... # type: str + def __init__( + self, + mailhost: str, + username: str, + password: str, + fromaddr: str, + toaddrs: Sequence[str], + subject: str, + ) -> None: ... + +class LRUCache(Dict[_KT, _VT]): + class _Item: + previous = ... # type: Optional[LRUCache._Item] + next = ... # type: Optional[LRUCache._Item] + key = ... + value = ... + def __init__(self, key, value) -> None: ... + + _dict = ... # type: Dict[_KT, LRUCache._Item] + capacity = ... # type: int + head = ... # type: Optional[LRUCache._Item] + tail = ... # type: Optional[LRUCache._Item] + + def __init__(self, capacity: int) -> None: ... + + +# This exists to work around Password.str's name shadowing the str type +_str = str + +class Password: + hashfunc = ... # type: Callable[[bytes], _HashType] + str = ... # type: Optional[_str] + + def __init__( + self, + str: Optional[_str] = ..., + hashfunc: Optional[Callable[[bytes], _HashType]] = ..., + ) -> None: ... + def set(self, value: Union[bytes, _str]) -> None: ... + def __eq__(self, other: Any) -> bool: ... + def __len__(self) -> int: ... + +def notify( + subject: str, + body: Optional[str] = ..., + html_body: Optional[Union[Sequence[str], str]] = ..., + to_string: Optional[str] = ..., + attachments: Optional[Iterable[_Message]] = ..., + append_instance_id: bool = ..., +) -> None: ... +def get_utf8_value(value: str) -> bytes: ... +def mklist(value: Any) -> List: ... +def pythonize_name(name: str) -> str: ... +def write_mime_multipart( + content: List[Tuple[str, str]], + compress: bool = ..., + deftype: str = ..., + delimiter: str = ..., +) -> str: ... +def guess_mime_type(content: str, deftype: str) -> str: ... +def compute_md5( + fp: IO[Any], + buf_size: int = ..., + size: Optional[int] = ..., +) -> Tuple[str, str, int]: ... +def compute_hash( + fp: IO[Any], + buf_size: int = ..., + size: Optional[int] = ..., + hash_algorithm: Any = ..., +) -> Tuple[str, str, int]: ... +def find_matching_headers(name: str, headers: Mapping[str, Optional[str]]) -> List[str]: ... +def merge_headers_by_name(name: str, headers: Mapping[str, Optional[str]]) -> str: ... + +class RequestHook: + def handle_request_data( + self, + request: boto.connection.HTTPRequest, + response: boto.connection.HTTPResponse, + error: bool = ..., + ) -> Any: ... + +def host_is_ipv6(hostname: str) -> bool: ... +def parse_host(hostname: str) -> str: ... diff --git a/python/helpers/typeshed/third_party/2and3/pymysql/connections.pyi b/python/helpers/typeshed/third_party/2and3/pymysql/connections.pyi index 62109ba60044..dd8b5e01f3c1 100644 --- a/python/helpers/typeshed/third_party/2and3/pymysql/connections.pyi +++ b/python/helpers/typeshed/third_party/2and3/pymysql/connections.pyi @@ -92,6 +92,7 @@ class Connection: def close(self): ... def autocommit(self, value): ... def commit(self): ... + def begin(self) -> None: ... def rollback(self): ... def escape(self, obj): ... def literal(self, obj): ...