From ab82d80866274affabf656f6edb07599e87baa6a Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Sun, 19 Feb 2017 19:02:24 +0300 Subject: [PATCH] Sync with typeshed @ 06074e1e02249a366b314acb3938022f82f116a0 --- python/helpers/typeshed/.gitignore | 1 + .../helpers/typeshed/stdlib/2/__builtin__.pyi | 23 ++-- .../helpers/typeshed/stdlib/2/collections.pyi | 3 +- python/helpers/typeshed/stdlib/2/csv.pyi | 8 +- python/helpers/typeshed/stdlib/2/hashlib.pyi | 18 +-- python/helpers/typeshed/stdlib/2/inspect.pyi | 42 ++++--- python/helpers/typeshed/stdlib/2/posix.pyi | 2 +- python/helpers/typeshed/stdlib/2/repr.pyi | 31 +++++ python/helpers/typeshed/stdlib/2/socket.pyi | 9 +- python/helpers/typeshed/stdlib/2/ssl.pyi | 6 +- python/helpers/typeshed/stdlib/2/time.pyi | 4 +- python/helpers/typeshed/stdlib/2/types.pyi | 3 +- python/helpers/typeshed/stdlib/2/typing.pyi | 23 ++-- python/helpers/typeshed/stdlib/2/unittest.pyi | 6 +- python/helpers/typeshed/stdlib/2/uuid.pyi | 47 +++++-- .../stdlib/2/xml/etree/ElementTree.pyi | 116 ----------------- .../typeshed/stdlib/2/xml/etree/__init__.pyi | 0 .../stdlib/2and3/logging/__init__.pyi | 2 +- .../helpers/typeshed/stdlib/2and3/pstats.pyi | 2 +- .../{2 => 2and3}/xml/etree/ElementInclude.pyi | 2 - .../{2 => 2and3}/xml/etree/ElementPath.pyi | 2 - .../{3.2 => 2and3}/xml/etree/ElementTree.pyi | 48 +++---- .../{2/xml => 2and3/xml/etree}/__init__.pyi | 0 .../{2 => 2and3}/xml/etree/cElementTree.pyi | 2 - .../typeshed/stdlib/3.2/xml/__init__.pyi | 0 .../stdlib/3.2/xml/etree/ElementInclude.pyi | 19 --- .../stdlib/3.2/xml/etree/ElementPath.pyi | 35 ------ .../stdlib/3.2/xml/etree/__init__.pyi | 0 .../stdlib/3.2/xml/etree/cElementTree.pyi | 5 - .../typeshed/stdlib/3.3/xml/__init__.pyi | 0 .../stdlib/3.3/xml/etree/ElementInclude.pyi | 19 --- .../stdlib/3.3/xml/etree/ElementPath.pyi | 35 ------ .../stdlib/3.3/xml/etree/ElementTree.pyi | 113 ----------------- .../stdlib/3.3/xml/etree/__init__.pyi | 0 .../stdlib/3.3/xml/etree/cElementTree.pyi | 5 - .../typeshed/stdlib/3.4/asyncio/__init__.pyi | 6 + .../typeshed/stdlib/3.4/asyncio/events.pyi | 17 +-- .../typeshed/stdlib/3.4/asyncio/locks.pyi | 12 +- .../typeshed/stdlib/3.4/asyncio/queues.pyi | 10 +- .../typeshed/stdlib/3.4/asyncio/streams.pyi | 10 +- .../stdlib/3.4/asyncio/subprocess.pyi | 10 +- .../typeshed/stdlib/3.4/asyncio/tasks.pyi | 2 +- .../helpers/typeshed/stdlib/3.4/pathlib.pyi | 2 +- .../typeshed/stdlib/3.4/xml/__init__.pyi | 0 .../stdlib/3.4/xml/etree/ElementInclude.pyi | 19 --- .../stdlib/3.4/xml/etree/ElementPath.pyi | 35 ------ .../stdlib/3.4/xml/etree/ElementTree.pyi | 118 ------------------ .../stdlib/3.4/xml/etree/__init__.pyi | 0 .../stdlib/3.4/xml/etree/cElementTree.pyi | 5 - .../typeshed/stdlib/3.5/xml/__init__.pyi | 0 .../stdlib/3.5/xml/etree/ElementInclude.pyi | 19 --- .../stdlib/3.5/xml/etree/ElementPath.pyi | 35 ------ .../stdlib/3.5/xml/etree/ElementTree.pyi | 118 ------------------ .../stdlib/3.5/xml/etree/__init__.pyi | 0 .../stdlib/3.5/xml/etree/cElementTree.pyi | 5 - python/helpers/typeshed/stdlib/3/builtins.pyi | 76 ++++++++--- .../stdlib/3/collections/__init__.pyi | 10 +- .../stdlib/3/concurrent/futures/_base.pyi | 4 +- python/helpers/typeshed/stdlib/3/dis.pyi | 2 +- python/helpers/typeshed/stdlib/3/hashlib.pyi | 24 ++-- .../typeshed/stdlib/3/http/__init__.pyi | 114 ++++++++--------- .../helpers/typeshed/stdlib/3/itertools.pyi | 2 +- python/helpers/typeshed/stdlib/3/shutil.pyi | 65 ++++++++-- python/helpers/typeshed/stdlib/3/socket.pyi | 4 +- python/helpers/typeshed/stdlib/3/ssl.pyi | 2 +- python/helpers/typeshed/stdlib/3/sys.pyi | 5 + python/helpers/typeshed/stdlib/3/types.pyi | 1 + python/helpers/typeshed/stdlib/3/typing.pyi | 27 ++-- .../typeshed/stdlib/3/urllib/parse.pyi | 21 +++- .../typeshed/stdlib/3/urllib/request.pyi | 1 + .../stdlib/3/xml/etree/ElementInclude.pyi | 19 --- .../stdlib/3/xml/etree/ElementPath.pyi | 25 ---- .../stdlib/3/xml/etree/ElementTree.pyi | 98 --------------- .../typeshed/stdlib/3/xml/etree/__init__.pyi | 0 .../stdlib/3/xml/etree/cElementTree.pyi | 5 - .../2/concurrent/futures/__init__.pyi | 4 +- .../third_party/2/dateutil/relativedelta.pyi | 2 +- .../typeshed/third_party/2/dateutil/tz/tz.pyi | 2 +- .../typeshed/third_party/2/requests/api.pyi | 14 +-- .../typeshed/third_party/2/six/__init__.pyi | 2 +- .../third_party/2and3/boto/s3/bucket.pyi | 2 +- .../third_party/2and3/pytz/__init__.pyi | 33 +++-- .../2and3/sqlalchemy/sql/schema.pyi | 2 +- .../third_party/3/dateutil/parser.pyi | 2 +- .../third_party/3/dateutil/relativedelta.pyi | 2 +- .../typeshed/third_party/3/dateutil/tz/tz.pyi | 2 +- .../typeshed/third_party/3/requests/api.pyi | 14 +-- .../third_party/3/typed_ast/__init__.pyi | 4 +- .../3/typed_ast/{ast35.pyi => ast3.pyi} | 26 +++- .../third_party/3/typed_ast/conversions.pyi | 4 +- 90 files changed, 515 insertions(+), 1159 deletions(-) create mode 100644 python/helpers/typeshed/stdlib/2/repr.pyi delete mode 100644 python/helpers/typeshed/stdlib/2/xml/etree/ElementTree.pyi delete mode 100644 python/helpers/typeshed/stdlib/2/xml/etree/__init__.pyi rename python/helpers/typeshed/stdlib/{2 => 2and3}/xml/etree/ElementInclude.pyi (89%) rename python/helpers/typeshed/stdlib/{2 => 2and3}/xml/etree/ElementPath.pyi (95%) rename python/helpers/typeshed/stdlib/{3.2 => 2and3}/xml/etree/ElementTree.pyi (78%) rename python/helpers/typeshed/stdlib/{2/xml => 2and3/xml/etree}/__init__.pyi (100%) rename python/helpers/typeshed/stdlib/{2 => 2and3}/xml/etree/cElementTree.pyi (55%) delete mode 100644 python/helpers/typeshed/stdlib/3.2/xml/__init__.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.2/xml/etree/ElementInclude.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.2/xml/etree/ElementPath.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.2/xml/etree/__init__.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.2/xml/etree/cElementTree.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.3/xml/__init__.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.3/xml/etree/ElementInclude.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.3/xml/etree/ElementPath.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.3/xml/etree/ElementTree.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.3/xml/etree/__init__.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.3/xml/etree/cElementTree.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.4/xml/__init__.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.4/xml/etree/ElementInclude.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.4/xml/etree/ElementPath.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.4/xml/etree/ElementTree.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.4/xml/etree/__init__.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.4/xml/etree/cElementTree.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.5/xml/__init__.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.5/xml/etree/ElementInclude.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.5/xml/etree/ElementPath.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.5/xml/etree/ElementTree.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.5/xml/etree/__init__.pyi delete mode 100644 python/helpers/typeshed/stdlib/3.5/xml/etree/cElementTree.pyi delete mode 100644 python/helpers/typeshed/stdlib/3/xml/etree/ElementInclude.pyi delete mode 100644 python/helpers/typeshed/stdlib/3/xml/etree/ElementPath.pyi delete mode 100644 python/helpers/typeshed/stdlib/3/xml/etree/ElementTree.pyi delete mode 100644 python/helpers/typeshed/stdlib/3/xml/etree/__init__.pyi delete mode 100644 python/helpers/typeshed/stdlib/3/xml/etree/cElementTree.pyi rename python/helpers/typeshed/third_party/3/typed_ast/{ast35.pyi => ast3.pyi} (93%) diff --git a/python/helpers/typeshed/.gitignore b/python/helpers/typeshed/.gitignore index 161b9cb9141d..838b2a41ad67 100644 --- a/python/helpers/typeshed/.gitignore +++ b/python/helpers/typeshed/.gitignore @@ -60,3 +60,4 @@ analyze.py *~ .*.sw? .vscode/ +.idea/ diff --git a/python/helpers/typeshed/stdlib/2/__builtin__.pyi b/python/helpers/typeshed/stdlib/2/__builtin__.pyi index c10dfcea5828..59b01e58a738 100644 --- a/python/helpers/typeshed/stdlib/2/__builtin__.pyi +++ b/python/helpers/typeshed/stdlib/2/__builtin__.pyi @@ -30,13 +30,13 @@ class classmethod: pass # Special, only valid as a decorator. class object: __doc__ = ... # type: Optional[str] __class__ = ... # type: type - __dict__ = ... # type: Dict[str, Any] __slots__ = ... # type: Optional[Union[str, unicode, Iterable[Union[str, unicode]]]] - __module__ = ... # type: Any def __init__(self) -> None: ... def __new__(cls) -> Any: ... def __setattr__(self, name: str, value: Any) -> None: ... + def __eq__(self, o: object) -> bool: ... + def __ne__(self, o: object) -> bool: ... def __str__(self) -> str: ... def __repr__(self) -> str: ... def __hash__(self) -> int: ... @@ -44,13 +44,12 @@ class object: def __getattribute__(self, name: str) -> Any: ... def __delattr__(self, name: str) -> None: ... def __sizeof__(self) -> int: ... - def __reduce__(self) -> Union[str, unicode, tuple]: ... - def __reduce_ex__(self, protocol: int) -> Union[str, unicode, tuple]: ... class type(object): __bases__ = ... # type: Tuple[type, ...] __name__ = ... # type: str __module__ = ... # type: str + __dict__ = ... # type: Dict[unicode, Any] @overload def __init__(self, o: object) -> None: ... @@ -471,9 +470,9 @@ class slice(object): step = ... # type: Optional[int] stop = ... # type: Optional[int] @overload - def __init__(self, stop: int) -> None: ... + def __init__(self, stop: int = None) -> None: ... @overload - def __init__(self, start: int, stop: int, step: int = None) -> None: ... + def __init__(self, start: int = None, stop: int = None, step: int = None) -> None: ... class tuple(Sequence[_T_co], Generic[_T_co]): def __init__(self, iterable: Iterable[_T_co] = ...) -> None: ... @@ -488,14 +487,17 @@ class tuple(Sequence[_T_co], Generic[_T_co]): def __le__(self, x: Tuple[_T_co, ...]) -> bool: ... def __gt__(self, x: Tuple[_T_co, ...]) -> bool: ... def __ge__(self, x: Tuple[_T_co, ...]) -> bool: ... - def __eq__(self, x: Tuple[_T_co, ...]) -> bool: ... - def __ne__(self, x: Tuple[_T_co, ...]) -> bool: ... def __add__(self, x: Tuple[_T_co, ...]) -> Tuple[_T_co, ...]: ... def __mul__(self, n: int) -> Tuple[_T_co, ...]: ... def __rmul__(self, n: int) -> Tuple[_T_co, ...]: ... def count(self, x: Any) -> int: ... def index(self, x: Any) -> int: ... +class function: + # TODO name of the class (corresponds to Python 'function' class) + __name__ = ... # type: str + __module__ = ... # type: str + class list(MutableSequence[_T], Generic[_T]): @overload def __init__(self) -> None: ... @@ -656,11 +658,12 @@ class xrange(Sized, Iterable[int], Reversible[int]): def __getitem__(self, i: int) -> int: ... def __reversed__(self) -> Iterator[int]: ... -class module(object): +class module: __name__ = ... # type: str __file__ = ... # type: str + __dict__ = ... # type: Dict[unicode, Any] -class property(object): +class property: def __init__(self, fget: Callable[[Any], Any] = None, fset: Callable[[Any, Any], None] = None, fdel: Callable[[Any], None] = None, doc: str = None) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2/collections.pyi b/python/helpers/typeshed/stdlib/2/collections.pyi index c2f0af268841..3235e9bd12f9 100644 --- a/python/helpers/typeshed/stdlib/2/collections.pyi +++ b/python/helpers/typeshed/stdlib/2/collections.pyi @@ -70,9 +70,10 @@ class Counter(Dict[_T, int], Generic[_T]): @overload def update(self, m: Union[Iterable[_T], Iterable[Tuple[_T, int]]], **kwargs: _VT) -> None: ... -class OrderedDict(Dict[_KT, _VT], Generic[_KT, _VT]): +class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]): def popitem(self, last: bool = ...) -> Tuple[_KT, _VT]: ... def move_to_end(self, key: _KT, last: bool = ...) -> None: ... + def __reversed__(self) -> Iterator[_KT]: ... class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]): default_factory = ... # type: Callable[[], _VT] diff --git a/python/helpers/typeshed/stdlib/2/csv.pyi b/python/helpers/typeshed/stdlib/2/csv.pyi index c91d3305e0f6..51a57e41ca67 100644 --- a/python/helpers/typeshed/stdlib/2/csv.pyi +++ b/python/helpers/typeshed/stdlib/2/csv.pyi @@ -2,7 +2,7 @@ # # NOTE: Based on a dynamically typed stub automatically generated by stubgen. -from typing import Any, Dict, Iterable, List, Sequence, Union +from typing import Any, Dict, Iterable, List, Sequence, Type, Union # Public interface of _csv.reader's return type class _Reader(Iterable[List[str]]): @@ -11,7 +11,7 @@ class _Reader(Iterable[List[str]]): def next(self) -> List[str]: ... -_Row = Sequence[Union[str, int]] +_Row = Sequence[Any] # May contain anything: csv calls str() on the elements that are not None # Public interface of _csv.writer's return type class _Writer: @@ -27,7 +27,7 @@ QUOTE_NONNUMERIC = ... # type: int class Error(Exception): ... -_Dialect = Union[str, Dialect] +_Dialect = Union[str, Dialect, Type[Dialect]] def writer(csvfile: Any, dialect: _Dialect = ..., **fmtparams) -> _Writer: ... def reader(csvfile: Iterable[str], dialect: _Dialect = ..., **fmtparams) -> _Reader: ... @@ -66,7 +66,7 @@ class DictReader(Iterable): def __init__(self, f: Iterable[str], fieldnames: Sequence[Any] = ..., restkey=..., restval=..., dialect: _Dialect = ..., *args, **kwds) -> None: ... def __iter__(self): ... - def __next__(self): ... + def next(self): ... _DictRow = Dict[Any, Union[str, int]] diff --git a/python/helpers/typeshed/stdlib/2/hashlib.pyi b/python/helpers/typeshed/stdlib/2/hashlib.pyi index 95f2b82f6395..375cc59aa88b 100644 --- a/python/helpers/typeshed/stdlib/2/hashlib.pyi +++ b/python/helpers/typeshed/stdlib/2/hashlib.pyi @@ -1,24 +1,26 @@ # Stubs for hashlib (Python 2) -from typing import Tuple +from typing import Tuple, Union + +_DataType = Union[str, bytearray, buffer, memoryview] class _hash(object): # This is not actually in the module namespace. digest_size = 0 block_size = 0 - def update(self, arg: str) -> None: ... + def update(self, arg: _DataType) -> None: ... def digest(self) -> str: ... def hexdigest(self) -> str: ... def copy(self) -> _hash: ... def new(name: str, data: str = ...) -> _hash: ... -def md5(s: str = ...) -> _hash: ... -def sha1(s: str = ...) -> _hash: ... -def sha224(s: str = ...) -> _hash: ... -def sha256(s: str = ...) -> _hash: ... -def sha384(s: str = ...) -> _hash: ... -def sha512(s: str = ...) -> _hash: ... +def md5(s: _DataType = ...) -> _hash: ... +def sha1(s: _DataType = ...) -> _hash: ... +def sha224(s: _DataType = ...) -> _hash: ... +def sha256(s: _DataType = ...) -> _hash: ... +def sha384(s: _DataType = ...) -> _hash: ... +def sha512(s: _DataType = ...) -> _hash: ... algorithms = ... # type: Tuple[str, ...] algorithms_guaranteed = ... # type: Tuple[str, ...] diff --git a/python/helpers/typeshed/stdlib/2/inspect.pyi b/python/helpers/typeshed/stdlib/2/inspect.pyi index e86da66ba5e4..a3569346c648 100644 --- a/python/helpers/typeshed/stdlib/2/inspect.pyi +++ b/python/helpers/typeshed/stdlib/2/inspect.pyi @@ -1,6 +1,5 @@ -# TODO incomplete from types import TracebackType, FrameType, ModuleType -from typing import Any, Callable, List, Optional, Tuple, Union, NamedTuple +from typing import Any, Dict, Callable, List, Optional, Tuple, Union, NamedTuple, Type # Types and members ModuleInfo = NamedTuple('ModuleInfo', [('name', str), @@ -47,22 +46,31 @@ def getsource(object: object) -> str: ... def cleandoc(doc: str) -> str: ... # Classes and functions -# TODO make the return type more specific -def getclasstree(classes: List[type], unique: bool = ...) -> Any: ... +def getclasstree(classes: List[type], unique: bool = ...) -> List[ + Union[Tuple[type, Tuple[type, ...]], list]]: ... ArgSpec = NamedTuple('ArgSpec', [('args', List[str]), - ('varargs', str), - ('keywords', str), + ('varargs', Optional[str]), + ('keywords', Optional[str]), ('defaults', tuple), ]) +ArgInfo = NamedTuple('ArgInfo', [('args', List[str]), + ('varargs', Optional[str]), + ('keywords', Optional[str]), + ('locals', Dict[str, Any]), + ]) + def getargspec(func: object) -> ArgSpec: ... -# TODO make the return type more specific -def getargvalues(frame: FrameType) -> Any: ... -# TODO formatargspec -# TODO formatargvalues +def getargvalues(frame: FrameType) -> ArgInfo: ... +def formatargspec(args, varargs=..., varkw=..., defaults=..., + formatarg=..., formatvarargs=..., formatvarkw=..., formatvalue=..., + join=...) -> str: ... +def formatargvalues(args, varargs=..., varkw=..., defaults=..., + formatarg=..., formatvarargs=..., formatvarkw=..., formatvalue=..., + join=...) -> str: ... def getmro(cls: type) -> Tuple[type, ...]: ... -# TODO getcallargs +def getcallargs(func, *args, **kwds) -> Dict[str, Any]: ... # The interpreter stack @@ -77,12 +85,12 @@ Traceback = NamedTuple( ] ) -_FrameRecord = Tuple[FrameType, str, int, str, List[str], int] +_FrameInfo = Tuple[FrameType, str, int, str, List[str], int] -def getouterframes(frame: FrameType, context: int = ...) -> List[FrameType]: ... +def getouterframes(frame: FrameType, context: int = ...) -> List[_FrameInfo]: ... def getframeinfo(frame: Union[FrameType, TracebackType], context: int = ...) -> Traceback: ... -def getinnerframes(traceback: TracebackType, context: int = ...) -> List[FrameType]: ... +def getinnerframes(traceback: TracebackType, context: int = ...) -> List[_FrameInfo]: ... -def currentframe() -> FrameType: ... -def stack(context: int = ...) -> List[_FrameRecord]: ... -def trace(context: int = ...) -> List[_FrameRecord]: ... +def currentframe(depth: int = ...) -> FrameType: ... +def stack(context: int = ...) -> List[_FrameInfo]: ... +def trace(context: int = ...) -> List[_FrameInfo]: ... diff --git a/python/helpers/typeshed/stdlib/2/posix.pyi b/python/helpers/typeshed/stdlib/2/posix.pyi index f8feb0360edd..ba01df0b7e1b 100644 --- a/python/helpers/typeshed/stdlib/2/posix.pyi +++ b/python/helpers/typeshed/stdlib/2/posix.pyi @@ -1,4 +1,4 @@ -from typing import List, Mapping, Tuple, Union, Sequence, IO, Optional, TypeVar +from typing import Dict, List, Mapping, Tuple, Union, Sequence, IO, Optional, TypeVar error = OSError diff --git a/python/helpers/typeshed/stdlib/2/repr.pyi b/python/helpers/typeshed/stdlib/2/repr.pyi new file mode 100644 index 000000000000..5e54f6961cbe --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/repr.pyi @@ -0,0 +1,31 @@ +class Repr: + maxarray = ... # type: int + maxdeque = ... # type: int + maxdict = ... # type: int + maxfrozenset = ... # type: int + maxlevel = ... # type: int + maxlist = ... # type: int + maxlong = ... # type: int + maxother = ... # type: int + maxset = ... # type: int + maxstring = ... # type: int + maxtuple = ... # type: int + def __init__(self) -> None: ... + def _repr_iterable(self, x, level: complex, left, right, maxiter, trail=...) -> str: ... + def repr(self, x) -> str: ... + def repr1(self, x, level: complex) -> str: ... + def repr_array(self, x, level: complex) -> str: ... + def repr_deque(self, x, level: complex) -> str: ... + def repr_dict(self, x, level: complex) -> str: ... + def repr_frozenset(self, x, level: complex) -> str: ... + def repr_instance(self, x, level: complex) -> str: ... + def repr_list(self, x, level: complex) -> str: ... + def repr_long(self, x, level: complex) -> str: ... + def repr_set(self, x, level: complex) -> str: ... + def repr_str(self, x, level: complex) -> str: ... + def repr_tuple(self, x, level: complex) -> str: ... + +def _possibly_sorted(x) -> list: ... + +aRepr = ... # type: Repr +def repr(x) -> str: ... diff --git a/python/helpers/typeshed/stdlib/2/socket.pyi b/python/helpers/typeshed/stdlib/2/socket.pyi index cbc3573d9402..77525aa78e74 100644 --- a/python/helpers/typeshed/stdlib/2/socket.pyi +++ b/python/helpers/typeshed/stdlib/2/socket.pyi @@ -319,7 +319,10 @@ class socket: def send(self, data: str, flags: int = ...) -> int: ... def sendall(self, data: str, flags: int = ...) -> None: ... # return type: None on success - def sendto(self, data: str, address: Union[tuple, str], flags: int = ...) -> int: ... + @overload + def sendto(self, data: str, address: Union[tuple, str]) -> int: ... + @overload + def sendto(self, data: str, flags: int, address: Union[tuple, str]) -> int: ... def setblocking(self, flag: bool) -> None: ... def settimeout(self, value: Union[float, None]) -> None: ... def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... @@ -358,5 +361,5 @@ def inet_aton(ip_string: str) -> str: ... # ret val 4 bytes in length def inet_ntoa(packed_ip: str) -> str: ... def inet_pton(address_family: int, ip_string: str) -> str: ... def inet_ntop(address_family: int, packed_ip: str) -> str: ... -def getdefaulttimeout() -> Union[float, None]: ... -def setdefaulttimeout(timeout: float) -> None: ... +def getdefaulttimeout() -> Optional[float]: ... +def setdefaulttimeout(timeout: Optional[float]) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2/ssl.pyi b/python/helpers/typeshed/stdlib/2/ssl.pyi index 3c07549a57bd..d3a3c1b73b00 100644 --- a/python/helpers/typeshed/stdlib/2/ssl.pyi +++ b/python/helpers/typeshed/stdlib/2/ssl.pyi @@ -148,6 +148,10 @@ class SSLSocket(socket.socket): def selected_npn_protocol(self) -> Optional[str]: ... def unwrap(self) -> socket.socket: ... def version(self) -> Optional[str]: ... + def read(self, len: int = ..., + buffer: Optional[bytearray] = ...) -> str: ... + def write(self, buf: str) -> int: ... + def pending(self) -> int: ... class SSLContext: @@ -178,7 +182,7 @@ class SSLContext: def wrap_socket(self, sock: socket.socket, server_side: bool = ..., do_handshake_on_connect: bool = ..., suppress_ragged_eofs: bool = ..., - server_hostname: Optional[str] = ...) -> 'SSLContext': ... + server_hostname: Optional[str] = ...) -> SSLSocket: ... def session_stats(self) -> Dict[str, int]: ... diff --git a/python/helpers/typeshed/stdlib/2/time.pyi b/python/helpers/typeshed/stdlib/2/time.pyi index 6bea2093f68c..6d2499f62639 100644 --- a/python/helpers/typeshed/stdlib/2/time.pyi +++ b/python/helpers/typeshed/stdlib/2/time.pyi @@ -20,7 +20,7 @@ class struct_time(NamedTuple('_struct_time', _TIME_TUPLE = Tuple[int, int, int, int, int, int, int, int, int] -def asctime(t: struct_time = ...) -> str: +def asctime(t: Union[struct_time, _TIME_TUPLE] = ...) -> str: raise ValueError() def clock() -> float: ... @@ -38,7 +38,7 @@ def mktime(t: struct_time) -> float: def sleep(secs: float) -> None: ... -def strftime(format: str, t: struct_time = ...) -> str: +def strftime(format: str, t: Union[struct_time, _TIME_TUPLE] = ...) -> str: raise MemoryError() raise ValueError() diff --git a/python/helpers/typeshed/stdlib/2/types.pyi b/python/helpers/typeshed/stdlib/2/types.pyi index 399c34bef649..15c8dd9c0d63 100644 --- a/python/helpers/typeshed/stdlib/2/types.pyi +++ b/python/helpers/typeshed/stdlib/2/types.pyi @@ -28,7 +28,7 @@ DictType = DictionaryType = dict class _Cell: cell_contents = ... # type: Any -class FunctionType(object): +class FunctionType: func_closure = ... # type: Optional[Tuple[_Cell, ...]] func_code = ... # type: CodeType func_defaults = ... # type: Optional[Tuple[Any, ...]] @@ -39,6 +39,7 @@ class FunctionType(object): __closure__ = func_closure __code__ = func_code __defaults__ = func_defaults + __dict__ = func_dict __globals__ = func_globals __name__ = func_name def __call__(self, *args: Any, **kwargs: Any) -> Any: ... diff --git a/python/helpers/typeshed/stdlib/2/typing.pyi b/python/helpers/typeshed/stdlib/2/typing.pyi index f3a76acf479a..9b693b407d9c 100644 --- a/python/helpers/typeshed/stdlib/2/typing.pyi +++ b/python/helpers/typeshed/stdlib/2/typing.pyi @@ -1,7 +1,6 @@ # Stubs for typing (Python 2.7) from abc import abstractmethod, ABCMeta -from types import CodeType, FrameType # Definitions of special type checking related constructs. Their definition # are not used, so their value does not matter. @@ -31,6 +30,8 @@ List = TypeAlias(object) Dict = TypeAlias(object) DefaultDict = TypeAlias(object) Set = TypeAlias(object) +Counter = TypeAlias(object) +Deque = TypeAlias(object) # Predefined type variables. AnyStr = TypeVar('AnyStr', str, unicode) @@ -93,10 +94,6 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]): @abstractmethod def close(self) -> None: ... - gi_code = ... # type: CodeType - gi_frame = ... # type: FrameType - gi_running = ... # type: bool - class Container(Generic[_T_co]): @abstractmethod def __contains__(self, x: object) -> bool: ... @@ -191,9 +188,9 @@ class Mapping(Iterable[_KT], Container[_KT], Sized, Generic[_KT, _VT_co]): def get(self, k: _KT) -> Optional[_VT_co]: ... @overload # type: ignore def get(self, k: _KT, default: Union[_VT_co, _T]) -> Union[_VT_co, _T]: ... - def keys(self) -> List[_KT]: ... - def values(self) -> List[_VT_co]: ... - def items(self) -> List[Tuple[_KT, _VT_co]]: ... + def keys(self) -> list[_KT]: ... + def values(self) -> list[_VT_co]: ... + def items(self) -> list[Tuple[_KT, _VT_co]]: ... def iterkeys(self) -> Iterator[_KT]: ... def itervalues(self) -> Iterator[_VT_co]: ... def iteritems(self) -> Iterator[Tuple[_KT, _VT_co]]: ... @@ -243,7 +240,7 @@ class IO(Iterator[AnyStr], Generic[AnyStr]): @abstractmethod def readline(self, limit: int = ...) -> AnyStr: ... @abstractmethod - def readlines(self, hint: int = ...) -> List[AnyStr]: ... + def readlines(self, hint: int = ...) -> list[AnyStr]: ... @abstractmethod def seek(self, offset: int, whence: int = ...) -> None: ... @abstractmethod @@ -318,7 +315,7 @@ class Match(Generic[AnyStr]): *groups: str) -> Sequence[AnyStr]: ... def groups(self, default: AnyStr = ...) -> Sequence[AnyStr]: ... - def groupdict(self, default: AnyStr = ...) -> Dict[str, AnyStr]: ... + def groupdict(self, default: AnyStr = ...) -> dict[str, AnyStr]: ... def start(self, group: Union[int, str] = ...) -> int: ... def end(self, group: Union[int, str] = ...) -> int: ... def span(self, group: Union[int, str] = ...) -> Tuple[int, int]: ... @@ -333,9 +330,9 @@ class Pattern(Generic[AnyStr]): endpos: int = ...) -> Match[AnyStr]: ... def match(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Match[AnyStr]: ... - def split(self, string: AnyStr, maxsplit: int = ...) -> List[AnyStr]: ... + def split(self, string: AnyStr, maxsplit: int = ...) -> list[AnyStr]: ... def findall(self, string: AnyStr, pos: int = ..., - endpos: int = ...) -> List[Any]: ... + endpos: int = ...) -> list[Any]: ... def finditer(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Iterator[Match[AnyStr]]: ... @@ -355,7 +352,7 @@ class Pattern(Generic[AnyStr]): # Functions -def get_type_hints(obj: Callable) -> Dict[str, Any]: ... +def get_type_hints(obj: Callable) -> dict[str, Any]: ... def cast(tp: Type[_T], obj: Any) -> _T: ... diff --git a/python/helpers/typeshed/stdlib/2/unittest.pyi b/python/helpers/typeshed/stdlib/2/unittest.pyi index 163ccceee67b..dbfccac9248e 100644 --- a/python/helpers/typeshed/stdlib/2/unittest.pyi +++ b/python/helpers/typeshed/stdlib/2/unittest.pyi @@ -6,7 +6,7 @@ from typing import ( Any, Callable, Dict, Iterable, Tuple, List, TextIO, Sequence, - overload, Set, TypeVar, Union, Pattern + overload, Set, TypeVar, Union, Pattern, Type ) from abc import abstractmethod, ABCMeta @@ -41,7 +41,7 @@ class TestResult: class _AssertRaisesBaseContext: expected = ... # type: Any - failureException = ... # type: type + failureException = ... # type: Type[BaseException] obj_name = ... # type: str expected_regex = ... # type: Pattern[str] @@ -51,8 +51,8 @@ class _AssertRaisesContext(_AssertRaisesBaseContext): def __exit__(self, exc_type, exc_value, tb) -> bool: ... class TestCase(Testable): + failureException = ... # type: Type[BaseException] def __init__(self, methodName: str = ...) -> None: ... - # TODO failureException def setUp(self) -> None: ... def tearDown(self) -> None: ... def run(self, result: TestResult = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2/uuid.pyi b/python/helpers/typeshed/stdlib/2/uuid.pyi index ce8a2a4c806d..8091cda70207 100644 --- a/python/helpers/typeshed/stdlib/2/uuid.pyi +++ b/python/helpers/typeshed/stdlib/2/uuid.pyi @@ -1,23 +1,44 @@ -from typing import NamedTuple, Any, Tuple +from typing import Any, Tuple, Optional -_int_type = int - -class _UUIDFields(NamedTuple('_UUIDFields', - [('time_low', int), ('time_mid', int), ('time_hi_version', int), ('clock_seq_hi_variant', int), ('clock_seq_low', int), ('node', int)])): - time = ... # type: int - clock_seq = ... # type: int +_int = int class UUID: - def __init__(self, hex: str = ..., bytes: str = ..., bytes_le: str = ..., - fields: Tuple[int, int, int, int, int, int] = ..., int: int = ..., version: Any = ...) -> None: ... + def __init__(self, hex: Optional[str] = ..., bytes: Optional[str] = ..., + bytes_le: Optional[str] = ..., + fields: Optional[Tuple[int, int, int, int, int, int]] = ..., + int: Optional[int] = ..., + version: Optional[int] = ...) -> None: ... + int = ... # type: _int + def get_bytes(self) -> _int: ... bytes = ... # type: str + def get_bytes_le(self) -> str: ... bytes_le = ... # type: str - fields = ... # type: _UUIDFields + def get_fields(self) -> Tuple[_int, _int, _int, _int, _int, _int]: ... + fields = ... # type: Tuple[_int, _int, _int, _int, _int, _int] + def get_time_low(self) -> _int: ... + time_low = ... # type: _int + def get_time_mid(self) -> _int: ... + time_mid = ... # type: _int + def get_time_hi_version(self) -> _int: ... + time_hi_version = ... # type: _int + def get_clock_seq_hi_variant(self) -> _int: ... + clock_seq_hi_variant = ... # type: _int + def get_clock_seq_low(self) -> _int: ... + clock_seq_low = ... # type: _int + def get_time(self) -> _int: ... + time = ... # type: _int + def get_clock_seq(self) -> _int: ... + clock_seq = ... # type: _int + def get_node(self) -> _int: ... + node = ... # type: _int + def get_hex(self) -> str: ... hex = ... # type: str - int = ... # type: _int_type + def get_urn(self) -> str: ... urn = ... # type: str - variant = ... # type: _int_type - version = ... # type: _int_type + def get_variant(self) -> _int: ... + variant = ... # type: _int + def get_version(self) -> _int: ... + version = ... # type: _int RESERVED_NCS = ... # type: int RFC_4122 = ... # type: int diff --git a/python/helpers/typeshed/stdlib/2/xml/etree/ElementTree.pyi b/python/helpers/typeshed/stdlib/2/xml/etree/ElementTree.pyi deleted file mode 100644 index 89e61f62ba52..000000000000 --- a/python/helpers/typeshed/stdlib/2/xml/etree/ElementTree.pyi +++ /dev/null @@ -1,116 +0,0 @@ -# Stubs for xml.etree.ElementTree (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any, AnyStr, Union, IO, Callable, Dict, List, Tuple, Sequence, Iterator, TypeVar, Optional, Generator -import io - -VERSION = ... # type: str - -_Ss = TypeVar('_Ss', str, bytes) -_T = TypeVar('_T') -_str_or_bytes = Union[str, bytes] - -class _SimpleElementPath: - def find(self, element: 'Element', tag: _str_or_bytes, namespaces: Any=...) -> Optional['Element']: ... - def findtext(self, element: 'Element', tag: _str_or_bytes, default: _T=..., namespaces: Any=...) -> Union[str, bytes, _T]: ... - def iterfind(self, element: 'Element', tag: _str_or_bytes, namespaces: Any=...) -> Generator['Element', None, None]: ... - def findall(self, element: 'Element', tag: _str_or_bytes, namespaces: Any=...) -> List['Element']: ... - -class ParseError(SyntaxError): ... - -def iselement(element: 'Element') -> bool: ... - -class Element(Sequence['Element']): - tag = ... # type: _str_or_bytes - attrib = ... # type: Dict[_str_or_bytes, _str_or_bytes] - text = ... # type: Optional[_str_or_bytes] - tail = ... # type: Optional[_str_or_bytes] - def __init__(self, tag: Union[AnyStr, Callable[..., 'Element']], attrib: Dict[AnyStr, AnyStr]=..., **extra: AnyStr) -> None: ... - def append(self, element: 'Element') -> None: ... - def clear(self) -> None: ... - def copy(self) -> 'Element': ... - def extend(self, elements: Sequence['Element']) -> None: ... - def find(self, path: str, namespaces: Dict[str, str]=...) -> Optional['Element']: ... - def findall(self, path: str, namespaces: Dict[str, str]=...) -> List['Element']: ... - def findtext(self, path: str, default: _T=..., namespaces: Dict[str, str]=...) -> Union[_T, str]: ... - def get(self, key: AnyStr, default: _T=...) -> Union[AnyStr, _T]: ... - def getchildren(self) -> List['Element']: ... - def getiterator(self, tag: Union[str, AnyStr]=...) -> List['Element']: ... - def insert(self, index: int, element: 'Element') -> None: ... - def items(self) -> List[Tuple[AnyStr, AnyStr]]: ... - def iter(self, tag: Union[str, AnyStr]=...) -> Generator['Element', None, None]: ... - def iterfind(self, path: str, namespaces: Dict[str, str]=...) -> List['Element']: ... - def itertext(self) -> Generator[str, None, None]: ... - def keys(self) -> List[AnyStr]: ... - def makeelement(self, tag: _Ss, attrib: Dict[_Ss, _Ss]) -> 'Element': ... - def remove(self, element: 'Element') -> None: ... - def set(self, key: AnyStr, value: AnyStr) -> None: ... - def __bool__(self) -> bool: ... - def __delitem__(self, index: int) -> None: ... - def __getitem__(self, index) -> 'Element': ... - def __len__(self) -> int: ... - def __setitem__(self, index: int, element: 'Element') -> None: ... - -def SubElement(parent: Element, tag: AnyStr, attrib: Dict[AnyStr, AnyStr]=..., **extra: AnyStr) -> Element: ... -def Comment(text: _str_or_bytes=...) -> Element: ... -def ProcessingInstruction(target: str, text: str=...) -> Element: ... - -PI = ... # type: Callable[..., Element] - -class QName: - text = ... # type: str - def __init__(self, text_or_uri: str, tag: str=...) -> None: ... - - -_file_or_filename = Union[str, bytes, int, IO[Any]] - -class ElementTree: - def __init__(self, element: Element=..., file: _file_or_filename=...) -> None: ... - def getroot(self) -> Element: ... - def parse(self, source: _file_or_filename, parser: 'XMLParser'=...) -> Element: ... - def iter(self, tag: Union[str, AnyStr]=...) -> Generator[Element, None, None]: ... - def getiterator(self, tag: Union[str, AnyStr]=...) -> List[Element]: ... - def find(self, path: str, namespaces: Dict[str, str]=...) -> Optional[Element]: ... - def findtext(self, path: str, default: _T=..., namespaces: Dict[str, str]=...) -> Union[_T, str]: ... - def findall(self, path: str, namespaces: Dict[str, str]=...) -> List[Element]: ... - def iterfind(self, path: str, namespaces: Dict[str, str]=...) -> List[Element]: ... - def write(self, file_or_filename: _file_or_filename, encoding: str=..., xml_declaration: Optional[bool]=..., default_namespace: str=..., method: str=...) -> None: ... - def write_c14n(self, file: _file_or_filename) -> None: ... - -def register_namespace(prefix: str, uri: str) -> None: ... -def tostring(element: Element, encoding: str=..., method: str=...) -> str: ... -def tostringlist(element: Element, encoding: str=..., method: str=...) -> List[str]: ... -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]]: ... - -class _IterParseIterator: - root = ... # type: Any - def __init__(self, source: _file_or_filename, events: Sequence[str], parser: 'XMLParser', close_source: bool=...) -> None: ... - def next(self) -> Tuple[str, Element]: ... - def __iter__(self) -> _IterParseIterator: ... - -def XML(text: AnyStr, parser: 'XMLParser'=...) -> Element: ... -def XMLID(text: AnyStr, parser: 'XMLParser'=...) -> Tuple[Element, Dict[str, Element]]: ... -# TODO-improve this type -fromstring = ... # type: Callable[..., Element] -def fromstringlist(sequence: Sequence[AnyStr], parser: 'XMLParser'=...) -> Element: ... - -class TreeBuilder: - def __init__(self, element_factory: Callable[[AnyStr, Dict[AnyStr, AnyStr]], Element]=...) -> None: ... - def close(self) -> Element: ... - def data(self, data: AnyStr) -> None: ... - def start(self, tag: AnyStr, attrs: Dict[AnyStr, AnyStr]) -> Element: ... - def end(self, tag: AnyStr) -> Element: ... - -class XMLParser: - parser = ... # type: Any - target = ... # type: TreeBuilder - # TODO-what is entity used for??? - entity = ... # type: Any - version = ... # type: str - def __init__(self, html: int=..., target: TreeBuilder=..., encoding: str=...) -> None: ... - def doctype(self, name: str, pubid: str, system: str) -> None: ... - def close(self) -> Any: ... # TODO-most of the time, this will be Element, but it can be anything target.close() returns - def feed(self, data: AnyStr)-> None: ... diff --git a/python/helpers/typeshed/stdlib/2/xml/etree/__init__.pyi b/python/helpers/typeshed/stdlib/2/xml/etree/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/python/helpers/typeshed/stdlib/2and3/logging/__init__.pyi b/python/helpers/typeshed/stdlib/2and3/logging/__init__.pyi index f7751db13ec0..1503775b6ddd 100644 --- a/python/helpers/typeshed/stdlib/2and3/logging/__init__.pyi +++ b/python/helpers/typeshed/stdlib/2and3/logging/__init__.pyi @@ -1,7 +1,7 @@ # Stubs for logging (Python 3.4) from typing import ( - Any, Callable, Dict, Iterable, Mapping, MutableMapping, Optional, IO, + Any, Callable, Dict, Iterable, List, Mapping, MutableMapping, Optional, IO, Tuple, Text, Union, overload, ) from string import Template diff --git a/python/helpers/typeshed/stdlib/2and3/pstats.pyi b/python/helpers/typeshed/stdlib/2and3/pstats.pyi index 9a872c2dda37..2d70f88594fd 100644 --- a/python/helpers/typeshed/stdlib/2and3/pstats.pyi +++ b/python/helpers/typeshed/stdlib/2and3/pstats.pyi @@ -8,7 +8,7 @@ _T = TypeVar('_T', bound='Stats') class Stats: def __init__(self: _T, __arg: Union[None, str, Text, Profile, cProfile] = ..., *args: Union[None, str, Text, Profile, cProfile, _T], - stream: IO[Any]) -> None: ... + stream: IO[Any] = ...) -> None: ... def init(self, arg: Union[None, str, Text, Profile, cProfile]) -> None: ... def load_stats(self, arg: Union[None, str, Text, Profile, cProfile]) -> None: ... def get_top_level_stats(self) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2/xml/etree/ElementInclude.pyi b/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementInclude.pyi similarity index 89% rename from python/helpers/typeshed/stdlib/2/xml/etree/ElementInclude.pyi rename to python/helpers/typeshed/stdlib/2and3/xml/etree/ElementInclude.pyi index 290ee09cd737..519506e6605b 100644 --- a/python/helpers/typeshed/stdlib/2/xml/etree/ElementInclude.pyi +++ b/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementInclude.pyi @@ -1,6 +1,4 @@ # Stubs for xml.etree.ElementInclude (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. from typing import Union, Optional, Callable from xml.etree.ElementTree import Element diff --git a/python/helpers/typeshed/stdlib/2/xml/etree/ElementPath.pyi b/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementPath.pyi similarity index 95% rename from python/helpers/typeshed/stdlib/2/xml/etree/ElementPath.pyi rename to python/helpers/typeshed/stdlib/2and3/xml/etree/ElementPath.pyi index d0095e3cc7e4..91e85cd6c872 100644 --- a/python/helpers/typeshed/stdlib/2/xml/etree/ElementPath.pyi +++ b/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementPath.pyi @@ -1,6 +1,4 @@ # Stubs for xml.etree.ElementPath (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. from typing import Pattern, Dict, Generator, Tuple, List, Union, TypeVar, Callable, Optional from xml.etree.ElementTree import Element diff --git a/python/helpers/typeshed/stdlib/3.2/xml/etree/ElementTree.pyi b/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementTree.pyi similarity index 78% rename from python/helpers/typeshed/stdlib/3.2/xml/etree/ElementTree.pyi rename to python/helpers/typeshed/stdlib/2and3/xml/etree/ElementTree.pyi index 0ae1e3f6a42b..fe93987965d7 100644 --- a/python/helpers/typeshed/stdlib/3.2/xml/etree/ElementTree.pyi +++ b/python/helpers/typeshed/stdlib/2and3/xml/etree/ElementTree.pyi @@ -1,26 +1,19 @@ # Stubs for xml.etree.ElementTree (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. from typing import Any, AnyStr, Union, IO, Callable, Dict, List, Tuple, Sequence, Iterator, TypeVar, Optional, KeysView, ItemsView, Generator import io +import sys VERSION = ... # type: str -_Ss = TypeVar('_Ss', str, bytes) -_T = TypeVar('_T') -_str_or_bytes = Union[str, bytes] - -class _SimpleElementPath: - def find(self, element: 'Element', tag: _str_or_bytes, namespaces: Any=...) -> Optional['Element']: ... - def findtext(self, element: 'Element', tag: _str_or_bytes, default: _T=..., namespaces: Any=...) -> Union[str, bytes, _T]: ... - def iterfind(self, element: 'Element', tag: _str_or_bytes, namespaces: Any=...) -> Generator['Element', None, None]: ... - def findall(self, element: 'Element', tag: _str_or_bytes, namespaces: Any=...) -> List['Element']: ... - class ParseError(SyntaxError): ... def iselement(element: 'Element') -> bool: ... +_Ss = TypeVar('_Ss', str, bytes) +_T = TypeVar('_T') +_str_or_bytes = Union[str, bytes] + class Element(Sequence['Element']): tag = ... # type: _str_or_bytes attrib = ... # type: Dict[_str_or_bytes, _str_or_bytes] @@ -37,7 +30,10 @@ class Element(Sequence['Element']): def get(self, key: AnyStr, default: _T=...) -> Union[AnyStr, _T]: ... def getchildren(self) -> List['Element']: ... def getiterator(self, tag: Union[str, AnyStr]=...) -> List['Element']: ... - def insert(self, index: int, subelement: 'Element') -> None: ... + if sys.version_info >= (3, 2): + def insert(self, index: int, subelement: 'Element') -> None: ... + else: + def insert(self, index: int, element: 'Element') -> None: ... def items(self) -> ItemsView[AnyStr, AnyStr]: ... def iter(self, tag: Union[str, AnyStr]=...) -> Generator['Element', None, None]: ... def iterfind(self, path: str, namespaces: Dict[str, str]=...) -> List['Element']: ... @@ -75,23 +71,29 @@ class ElementTree: def findtext(self, path: str, default: _T=..., namespaces: Dict[str, str]=...) -> Union[_T, str]: ... def findall(self, path: str, namespaces: Dict[str, str]=...) -> List[Element]: ... def iterfind(self, path: str, namespaces: Dict[str, str]=...) -> List[Element]: ... - def write(self, file_or_filename: _file_or_filename, encoding: str=..., xml_declaration: Optional[bool]=..., default_namespace: str=..., method: str=...) -> None: ... + if sys.version_info >= (3, 4): + def write(self, file_or_filename: _file_or_filename, encoding: str=..., xml_declaration: Optional[bool]=..., default_namespace: str=..., method: str=..., *, short_empty_elements: bool=...) -> None: ... + else: + def write(self, file_or_filename: _file_or_filename, encoding: str=..., xml_declaration: Optional[bool]=..., default_namespace: str=..., method: str=...) -> None: ... def write_c14n(self, file: _file_or_filename) -> None: ... def register_namespace(prefix: str, uri: str) -> None: ... -def tostring(element: Element, encoding: str=..., method: str=...) -> str: ... - -def tostringlist(element: Element, encoding: str=..., method: str=...) -> List[str]: ... +if sys.version_info >= (3, 4): + def tostring(element: Element, encoding: str=..., method: str=..., *, short_empty_elements: bool=...) -> str: ... + def tostringlist(element: Element, encoding: str=..., method: str=..., *, short_empty_elements: bool=...) -> List[str]: ... +else: + def tostring(element: Element, encoding: str=..., method: str=...) -> str: ... + def tostringlist(element: Element, encoding: str=..., method: str=...) -> List[str]: ... 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]]: ... - -class _IterParseIterator: - root = ... # type: Any - def __init__(self, source: _file_or_filename, events: Sequence[str], parser: 'XMLParser', close_source: bool=...) -> None: ... - def __next__(self) -> Tuple[str, Element]: ... - def __iter__(self) -> _IterParseIterator: ... +if sys.version_info >= (3, 4): + class XMLPullParser: + def __init__(self, events: Sequence[str]=..., *, _parser: 'XMLParser'=...) -> None: ... + def feed(self, data: bytes) -> None: ... + def close(self) -> None: ... + def read_events(self) -> Iterator[Tuple[str, Element]]: ... def XML(text: AnyStr, parser: 'XMLParser'=...) -> Element: ... def XMLID(text: AnyStr, parser: 'XMLParser'=...) -> Tuple[Element, Dict[str, Element]]: ... diff --git a/python/helpers/typeshed/stdlib/2/xml/__init__.pyi b/python/helpers/typeshed/stdlib/2and3/xml/etree/__init__.pyi similarity index 100% rename from python/helpers/typeshed/stdlib/2/xml/__init__.pyi rename to python/helpers/typeshed/stdlib/2and3/xml/etree/__init__.pyi diff --git a/python/helpers/typeshed/stdlib/2/xml/etree/cElementTree.pyi b/python/helpers/typeshed/stdlib/2and3/xml/etree/cElementTree.pyi similarity index 55% rename from python/helpers/typeshed/stdlib/2/xml/etree/cElementTree.pyi rename to python/helpers/typeshed/stdlib/2and3/xml/etree/cElementTree.pyi index 8f689de4b1aa..c384968d08ff 100644 --- a/python/helpers/typeshed/stdlib/2/xml/etree/cElementTree.pyi +++ b/python/helpers/typeshed/stdlib/2and3/xml/etree/cElementTree.pyi @@ -1,5 +1,3 @@ # Stubs for xml.etree.cElementTree (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. from xml.etree.ElementTree import * # noqa: F403 diff --git a/python/helpers/typeshed/stdlib/3.2/xml/__init__.pyi b/python/helpers/typeshed/stdlib/3.2/xml/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/python/helpers/typeshed/stdlib/3.2/xml/etree/ElementInclude.pyi b/python/helpers/typeshed/stdlib/3.2/xml/etree/ElementInclude.pyi deleted file mode 100644 index bbe3fb3ed057..000000000000 --- a/python/helpers/typeshed/stdlib/3.2/xml/etree/ElementInclude.pyi +++ /dev/null @@ -1,19 +0,0 @@ -# Stubs for xml.etree.ElementInclude (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Union, Optional, Callable -from .ElementTree import Element - -XINCLUDE = ... # type: str -XINCLUDE_INCLUDE = ... # type: str -XINCLUDE_FALLBACK = ... # type: str - -class FatalIncludeError(SyntaxError): ... - -def default_loader(href: Union[str, bytes, int], parse: str, encoding: Optional[str]=...) -> Union[str, Element]: ... - -# TODO: loader is of type default_loader ie it takes a callable that has the -# same signature as default_loader. But default_loader has a keyword argument -# Which can't be represented using Callable... -def include(elem: Element, loader: Callable[..., Union[str, Element]]=...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3.2/xml/etree/ElementPath.pyi b/python/helpers/typeshed/stdlib/3.2/xml/etree/ElementPath.pyi deleted file mode 100644 index b1ea50e68cf0..000000000000 --- a/python/helpers/typeshed/stdlib/3.2/xml/etree/ElementPath.pyi +++ /dev/null @@ -1,35 +0,0 @@ -# Stubs for xml.etree.ElementPath (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Pattern, Dict, Generator, Tuple, List, Union, TypeVar, Callable, Optional -from .ElementTree import Element - -xpath_tokenizer_re = ... # type: Pattern - -_token = Tuple[str, str] -_next = Callable[[], _token] -_callback = Callable[['_SelectorContext', List[Element]], Generator[Element, None, None]] - -def xpath_tokenizer(pattern: str, namespaces: Dict[str, str]=...) -> Generator[_token, None, None]: ... -def get_parent_map(context: '_SelectorContext') -> Dict[Element, Element]: ... -def prepare_child(next: _next, token: _token) -> _callback: ... -def prepare_star(next: _next, token: _token) -> _callback: ... -def prepare_self(next: _next, token: _token) -> _callback: ... -def prepare_descendant(next: _next, token: _token) -> _callback: ... -def prepare_parent(next: _next, token: _token) -> _callback: ... -def prepare_predicate(next: _next, token: _token) -> _callback: ... - -ops = ... # type: Dict[str, Callable[[_next, _token], _callback]] - -class _SelectorContext: - parent_map = ... # type: Dict[Element, Element] - root = ... # type: Element - def __init__(self, root: Element) -> None: ... - -_T = TypeVar('_T') - -def iterfind(elem: Element, path: str, namespaces: Dict[str, str]=...) -> List[Element]: ... -def find(elem: Element, path: str, namespaces: Dict[str, str]=...) -> Optional[Element]: ... -def findall(elem: Element, path: str, namespaces: Dict[str, str]=...) -> List[Element]: ... -def findtext(elem: Element, path: str, default: _T=..., namespaces: Dict[str, str]=...) -> Union[_T, str]: ... diff --git a/python/helpers/typeshed/stdlib/3.2/xml/etree/__init__.pyi b/python/helpers/typeshed/stdlib/3.2/xml/etree/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/python/helpers/typeshed/stdlib/3.2/xml/etree/cElementTree.pyi b/python/helpers/typeshed/stdlib/3.2/xml/etree/cElementTree.pyi deleted file mode 100644 index 8f689de4b1aa..000000000000 --- a/python/helpers/typeshed/stdlib/3.2/xml/etree/cElementTree.pyi +++ /dev/null @@ -1,5 +0,0 @@ -# Stubs for xml.etree.cElementTree (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from xml.etree.ElementTree import * # noqa: F403 diff --git a/python/helpers/typeshed/stdlib/3.3/xml/__init__.pyi b/python/helpers/typeshed/stdlib/3.3/xml/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/python/helpers/typeshed/stdlib/3.3/xml/etree/ElementInclude.pyi b/python/helpers/typeshed/stdlib/3.3/xml/etree/ElementInclude.pyi deleted file mode 100644 index bbe3fb3ed057..000000000000 --- a/python/helpers/typeshed/stdlib/3.3/xml/etree/ElementInclude.pyi +++ /dev/null @@ -1,19 +0,0 @@ -# Stubs for xml.etree.ElementInclude (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Union, Optional, Callable -from .ElementTree import Element - -XINCLUDE = ... # type: str -XINCLUDE_INCLUDE = ... # type: str -XINCLUDE_FALLBACK = ... # type: str - -class FatalIncludeError(SyntaxError): ... - -def default_loader(href: Union[str, bytes, int], parse: str, encoding: Optional[str]=...) -> Union[str, Element]: ... - -# TODO: loader is of type default_loader ie it takes a callable that has the -# same signature as default_loader. But default_loader has a keyword argument -# Which can't be represented using Callable... -def include(elem: Element, loader: Callable[..., Union[str, Element]]=...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3.3/xml/etree/ElementPath.pyi b/python/helpers/typeshed/stdlib/3.3/xml/etree/ElementPath.pyi deleted file mode 100644 index b1ea50e68cf0..000000000000 --- a/python/helpers/typeshed/stdlib/3.3/xml/etree/ElementPath.pyi +++ /dev/null @@ -1,35 +0,0 @@ -# Stubs for xml.etree.ElementPath (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Pattern, Dict, Generator, Tuple, List, Union, TypeVar, Callable, Optional -from .ElementTree import Element - -xpath_tokenizer_re = ... # type: Pattern - -_token = Tuple[str, str] -_next = Callable[[], _token] -_callback = Callable[['_SelectorContext', List[Element]], Generator[Element, None, None]] - -def xpath_tokenizer(pattern: str, namespaces: Dict[str, str]=...) -> Generator[_token, None, None]: ... -def get_parent_map(context: '_SelectorContext') -> Dict[Element, Element]: ... -def prepare_child(next: _next, token: _token) -> _callback: ... -def prepare_star(next: _next, token: _token) -> _callback: ... -def prepare_self(next: _next, token: _token) -> _callback: ... -def prepare_descendant(next: _next, token: _token) -> _callback: ... -def prepare_parent(next: _next, token: _token) -> _callback: ... -def prepare_predicate(next: _next, token: _token) -> _callback: ... - -ops = ... # type: Dict[str, Callable[[_next, _token], _callback]] - -class _SelectorContext: - parent_map = ... # type: Dict[Element, Element] - root = ... # type: Element - def __init__(self, root: Element) -> None: ... - -_T = TypeVar('_T') - -def iterfind(elem: Element, path: str, namespaces: Dict[str, str]=...) -> List[Element]: ... -def find(elem: Element, path: str, namespaces: Dict[str, str]=...) -> Optional[Element]: ... -def findall(elem: Element, path: str, namespaces: Dict[str, str]=...) -> List[Element]: ... -def findtext(elem: Element, path: str, default: _T=..., namespaces: Dict[str, str]=...) -> Union[_T, str]: ... diff --git a/python/helpers/typeshed/stdlib/3.3/xml/etree/ElementTree.pyi b/python/helpers/typeshed/stdlib/3.3/xml/etree/ElementTree.pyi deleted file mode 100644 index 148b89e55f0a..000000000000 --- a/python/helpers/typeshed/stdlib/3.3/xml/etree/ElementTree.pyi +++ /dev/null @@ -1,113 +0,0 @@ -# Stubs for xml.etree.ElementTree (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any, AnyStr, Union, IO, Callable, Dict, List, Tuple, Sequence, Iterator, TypeVar, Optional, KeysView, ItemsView, Generator -import io - -VERSION = ... # type: str - -class ParseError(SyntaxError): ... - -def iselement(element: 'Element') -> bool: ... - -_Ss = TypeVar('_Ss', str, bytes) -_T = TypeVar('_T') -_str_or_bytes = Union[str, bytes] - -class Element(Sequence['Element']): - tag = ... # type: _str_or_bytes - attrib = ... # type: Dict[_str_or_bytes, _str_or_bytes] - text = ... # type: Optional[_str_or_bytes] - tail = ... # type: Optional[_str_or_bytes] - def __init__(self, tag: Union[AnyStr, Callable[..., 'Element']], attrib: Dict[AnyStr, AnyStr]=..., **extra: AnyStr) -> None: ... - def append(self, subelement: 'Element') -> None: ... - def clear(self) -> None: ... - def copy(self) -> 'Element': ... - def extend(self, elements: Sequence['Element']) -> None: ... - def find(self, path: str, namespaces: Dict[str, str]=...) -> Optional['Element']: ... - def findall(self, path: str, namespaces: Dict[str, str]=...) -> List['Element']: ... - def findtext(self, path: str, default: _T=..., namespaces: Dict[str, str]=...) -> Union[_T, str]: ... - def get(self, key: AnyStr, default: _T=...) -> Union[AnyStr, _T]: ... - def getchildren(self) -> List['Element']: ... - def getiterator(self, tag: Union[str, AnyStr]=...) -> List['Element']: ... - def insert(self, index: int, subelement: 'Element') -> None: ... - def items(self) -> ItemsView[AnyStr, AnyStr]: ... - def iter(self, tag: Union[str, AnyStr]=...) -> Generator['Element', None, None]: ... - def iterfind(self, path: str, namespaces: Dict[str, str]=...) -> List['Element']: ... - def itertext(self) -> Generator[str, None, None]: ... - def keys(self) -> KeysView[AnyStr]: ... - def makeelement(self, tag: _Ss, attrib: Dict[_Ss, _Ss]) -> 'Element': ... - def remove(self, subelement: 'Element') -> None: ... - def set(self, key: AnyStr, value: AnyStr) -> None: ... - def __bool__(self) -> bool: ... - def __delitem__(self, index: int) -> None: ... - def __getitem__(self, index) -> 'Element': ... - def __len__(self) -> int: ... - def __setitem__(self, index: int, element: 'Element') -> None: ... - -def SubElement(parent: Element, tag: AnyStr, attrib: Dict[AnyStr, AnyStr]=..., **extra: AnyStr) -> Element: ... -def Comment(text: _str_or_bytes=...) -> Element: ... -def ProcessingInstruction(target: str, text: str=...) -> Element: ... - -PI = ... # type: Callable[..., Element] - -class QName: - text = ... # type: str - def __init__(self, text_or_uri: str, tag: str=...) -> None: ... - - -_file_or_filename = Union[str, bytes, int, IO[Any]] - -class ElementTree: - def __init__(self, element: Element=..., file: _file_or_filename=...) -> None: ... - def getroot(self) -> Element: ... - def parse(self, source: _file_or_filename, parser: 'XMLParser'=...) -> Element: ... - def iter(self, tag: Union[str, AnyStr]=...) -> Generator[Element, None, None]: ... - def getiterator(self, tag: Union[str, AnyStr]=...) -> List[Element]: ... - def find(self, path: str, namespaces: Dict[str, str]=...) -> Optional[Element]: ... - def findtext(self, path: str, default: _T=..., namespaces: Dict[str, str]=...) -> Union[_T, str]: ... - def findall(self, path: str, namespaces: Dict[str, str]=...) -> List[Element]: ... - def iterfind(self, path: str, namespaces: Dict[str, str]=...) -> List[Element]: ... - def write(self, file_or_filename: _file_or_filename, encoding: str=..., xml_declaration: Optional[bool]=..., default_namespace: str=..., method: str=...) -> None: ... - def write_c14n(self, file: _file_or_filename) -> None: ... - -def register_namespace(prefix: str, uri: str) -> None: ... -def tostring(element: Element, encoding: str=..., method: str=...) -> str: ... -def tostringlist(element: Element, encoding: str=..., method: str=...) -> List[str]: ... -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]]: ... - - -class _IterParseIterator: - root = ... # type: Any - def __init__(self, source: _file_or_filename, events: Sequence[str], parser: 'XMLParser', close_source: bool=...) -> None: ... - def __next__(self) -> Tuple[str, Element]: ... - def __iter__(self) -> _IterParseIterator: ... - -def XML(text: AnyStr, parser: 'XMLParser'=...) -> Element: ... -def XMLID(text: AnyStr, parser: 'XMLParser'=...) -> Tuple[Element, Dict[str, Element]]: ... - -# TODO-improve this type -fromstring = ... # type: Callable[..., Element] - -def fromstringlist(sequence: Sequence[AnyStr], parser: 'XMLParser'=...) -> Element: ... - -class TreeBuilder: - def __init__(self, element_factory: Callable[[AnyStr, Dict[AnyStr, AnyStr]], Element]=...) -> None: ... - def close(self) -> Element: ... - def data(self, data: AnyStr) -> None: ... - def start(self, tag: AnyStr, attrs: Dict[AnyStr, AnyStr]) -> Element: ... - def end(self, tag: AnyStr) -> Element: ... - -class XMLParser: - parser = ... # type: Any - target = ... # type: TreeBuilder - # TODO-what is entity used for??? - entity = ... # type: Any - version = ... # type: str - def __init__(self, html: int=..., target: TreeBuilder=..., encoding: str=...) -> None: ... - def doctype(self, name: str, pubid: str, system: str) -> None: ... - def close(self) -> Any: ... # TODO-most of the time, this will be Element, but it can be anything target.close() returns - def feed(self, data: AnyStr)-> None: ... diff --git a/python/helpers/typeshed/stdlib/3.3/xml/etree/__init__.pyi b/python/helpers/typeshed/stdlib/3.3/xml/etree/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/python/helpers/typeshed/stdlib/3.3/xml/etree/cElementTree.pyi b/python/helpers/typeshed/stdlib/3.3/xml/etree/cElementTree.pyi deleted file mode 100644 index 8f689de4b1aa..000000000000 --- a/python/helpers/typeshed/stdlib/3.3/xml/etree/cElementTree.pyi +++ /dev/null @@ -1,5 +0,0 @@ -# Stubs for xml.etree.cElementTree (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from xml.etree.ElementTree import * # noqa: F403 diff --git a/python/helpers/typeshed/stdlib/3.4/asyncio/__init__.pyi b/python/helpers/typeshed/stdlib/3.4/asyncio/__init__.pyi index 3f88dac0149b..2364ff6cf6a5 100644 --- a/python/helpers/typeshed/stdlib/3.4/asyncio/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3.4/asyncio/__init__.pyi @@ -1,5 +1,6 @@ """The asyncio package, tracking PEP 3156.""" +import socket import sys from typing import Type @@ -85,6 +86,11 @@ from asyncio.locks import ( if sys.version_info < (3, 5): from asyncio.queues import JoinableQueue as JoinableQueue +if sys.platform != 'win32': + from asyncio.streams import ( + open_unix_connection as open_unix_connection, + start_unix_server as start_unix_server, + ) # TODO: It should be possible to instantiate these classes, but mypy # currently disallows this. diff --git a/python/helpers/typeshed/stdlib/3.4/asyncio/events.pyi b/python/helpers/typeshed/stdlib/3.4/asyncio/events.pyi index 2e87f70b3138..ade397d0ba89 100644 --- a/python/helpers/typeshed/stdlib/3.4/asyncio/events.pyi +++ b/python/helpers/typeshed/stdlib/3.4/asyncio/events.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Awaitable, TypeVar, List, Callable, Tuple, Union, Dict, Generator, overload, Optional +from typing import Any, Awaitable, Callable, Dict, Generator, List, Optional, Tuple, TypeVar, Union, overload from abc import ABCMeta, abstractmethod from asyncio.futures import Future from asyncio.coroutines import coroutine @@ -8,6 +8,7 @@ from asyncio.tasks import Task __all__ = ... # type: str _T = TypeVar('_T') +_Context = Dict[str, Any] PIPE = ... # type: Any # from subprocess.PIPE @@ -71,7 +72,7 @@ class AbstractEventLoop(metaclass=ABCMeta): def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any) -> Handle: ... @abstractmethod def run_in_executor(self, executor: Any, - callback: Callable[[], Any], *args: Any) -> Future[Any]: ... + callback: Callable[..., Any], *args: Any) -> Future[Any]: ... @abstractmethod def set_default_executor(self, executor: Any) -> None: ... # Network I/O methods returning Futures. @@ -113,11 +114,11 @@ class AbstractEventLoop(metaclass=ABCMeta): stdout: Any = ..., stderr: Any = ..., **kwargs: Any) -> tuple: ... @abstractmethod - def add_reader(self, fd: int, callback: Callable[[], Any], *args: List[Any]) -> None: ... + def add_reader(self, fd: int, callback: Callable[..., Any], *args: List[Any]) -> None: ... @abstractmethod def remove_reader(self, fd: int) -> None: ... @abstractmethod - def add_writer(self, fd: int, callback: Callable[[], Any], *args: List[Any]) -> None: ... + def add_writer(self, fd: int, callback: Callable[..., Any], *args: List[Any]) -> None: ... @abstractmethod def remove_writer(self, fd: int) -> None: ... # Completion based I/O methods returning Futures. @@ -131,16 +132,16 @@ class AbstractEventLoop(metaclass=ABCMeta): def sock_accept(self, sock: Any) -> Any: ... # Signal handling. @abstractmethod - def add_signal_handler(self, sig: int, callback: Callable[[], Any], *args: List[Any]) -> None: ... + def add_signal_handler(self, sig: int, callback: Callable[..., Any], *args: List[Any]) -> None: ... @abstractmethod def remove_signal_handler(self, sig: int) -> None: ... # Error handlers. @abstractmethod - def set_exception_handler(self, handler: Callable[[], Any]) -> None: ... + def set_exception_handler(self, handler: Callable[[AbstractEventLoop, _Context], Any]) -> None: ... @abstractmethod - def default_exception_handler(self, context: Any) -> None: ... + def default_exception_handler(self, context: _Context) -> None: ... @abstractmethod - def call_exception_handler(self, context: Any) -> None: ... + def call_exception_handler(self, context: _Context) -> None: ... # Debug flag management. @abstractmethod def get_debug(self) -> bool: ... diff --git a/python/helpers/typeshed/stdlib/3.4/asyncio/locks.pyi b/python/helpers/typeshed/stdlib/3.4/asyncio/locks.pyi index 2467ffec0225..21459490d8d8 100644 --- a/python/helpers/typeshed/stdlib/3.4/asyncio/locks.pyi +++ b/python/helpers/typeshed/stdlib/3.4/asyncio/locks.pyi @@ -24,7 +24,7 @@ class Lock(_ContextManagerMixin): def __init__(self, *, loop: AbstractEventLoop = None) -> None: ... def locked(self) -> bool: ... @coroutine - def acquire(self) -> Future[bool]: ... + def acquire(self) -> Generator[Any, None, bool]: ... def release(self) -> None: ... class Event: @@ -33,18 +33,18 @@ class Event: def set(self) -> None: ... def clear(self) -> None: ... @coroutine - def wait(self) -> bool: ... + def wait(self) -> Generator[Any, None, bool]: ... class Condition(_ContextManagerMixin): def __init__(self, lock: Lock = None, *, loop: AbstractEventLoop = None) -> None: ... def locked(self) -> bool: ... @coroutine - def acquire(self) -> Future[bool]: ... + def acquire(self) -> Generator[Any, None, bool]: ... def release(self) -> None: ... @coroutine - def wait(self) -> Future[bool]: ... + def wait(self) -> Generator[Any, None, bool]: ... @coroutine - def wait_for(self, predicate: Callable[[], T]) -> Future[T]: ... + def wait_for(self, predicate: Callable[[], T]) -> Generator[Any, None, T]: ... def notify(self, n: int = 1) -> None: ... def notify_all(self) -> None: ... @@ -52,7 +52,7 @@ class Semaphore(_ContextManagerMixin): def __init__(self, value: int = 1, *, loop: AbstractEventLoop = None) -> None: ... def locked(self) -> bool: ... @coroutine - def acquire(self) -> Future[bool]: ... + def acquire(self) -> Generator[Any, None, bool]: ... def release(self) -> None: ... class BoundedSemaphore(Semaphore): diff --git a/python/helpers/typeshed/stdlib/3.4/asyncio/queues.pyi b/python/helpers/typeshed/stdlib/3.4/asyncio/queues.pyi index 2901218f5ba8..1c9363edb9b6 100644 --- a/python/helpers/typeshed/stdlib/3.4/asyncio/queues.pyi +++ b/python/helpers/typeshed/stdlib/3.4/asyncio/queues.pyi @@ -2,7 +2,7 @@ import sys from asyncio.events import AbstractEventLoop from .coroutines import coroutine from .futures import Future -from typing import TypeVar, Generic +from typing import Any, Generator, Generic, TypeVar __all__ = ... # type: str @@ -28,14 +28,14 @@ class Queue(Generic[T]): def empty(self) -> bool: ... def full(self) -> bool: ... @coroutine - def put(self, item: T) -> Future[None]: ... + def put(self, item: T) -> Generator[Any, None, None]: ... def put_nowait(self, item: T) -> None: ... @coroutine - def get(self) -> Future[T]: ... + def get(self) -> Generator[Any, None, T]: ... def get_nowait(self) -> T: ... if sys.version_info >= (3, 4): @coroutine - def join(self) -> None: ... + def join(self) -> Generator[Any, None, bool]: ... def task_done(self) -> None: ... @@ -48,4 +48,4 @@ if sys.version_info < (3, 5): class JoinableQueue(Queue): def task_done(self) -> None: ... @coroutine - def join(self) -> None: ... + def join(self) -> Generator[Any, None, bool]: ... diff --git a/python/helpers/typeshed/stdlib/3.4/asyncio/streams.pyi b/python/helpers/typeshed/stdlib/3.4/asyncio/streams.pyi index ee46a87b5faa..fd677ab75a8b 100644 --- a/python/helpers/typeshed/stdlib/3.4/asyncio/streams.pyi +++ b/python/helpers/typeshed/stdlib/3.4/asyncio/streams.pyi @@ -1,12 +1,12 @@ -import socket -from typing import Any, Callable, Generator, Iterable, Tuple +import sys +from typing import Any, Awaitable, Callable, Generator, Iterable, Optional, Tuple from . import coroutines from . import events from . import protocols from . import transports -ClientConnectedCallback = Callable[[Tuple[StreamReader, StreamWriter]], None] +ClientConnectedCallback = Callable[[StreamReader, StreamWriter], Optional[Awaitable[None]]] __all__ = ... # type: str @@ -38,7 +38,7 @@ def start_server( **kwds: Any ) -> Generator[Any, None, events.AbstractServer]: ... -if hasattr(socket, 'AF_UNIX'): +if sys.platform != 'win32': @coroutines.coroutine def open_unix_connection( path: str = ..., @@ -84,7 +84,7 @@ class StreamWriter: def close(self) -> None: ... def get_extra_info(self, name: str, default: Any = ...) -> Any: ... @coroutines.coroutine - def drain(self) -> None: ... + def drain(self) -> Generator[Any, None, None]: ... class StreamReader: def __init__(self, diff --git a/python/helpers/typeshed/stdlib/3.4/asyncio/subprocess.pyi b/python/helpers/typeshed/stdlib/3.4/asyncio/subprocess.pyi index b492506e18a5..21a33a3ab60b 100644 --- a/python/helpers/typeshed/stdlib/3.4/asyncio/subprocess.pyi +++ b/python/helpers/typeshed/stdlib/3.4/asyncio/subprocess.pyi @@ -3,7 +3,7 @@ from asyncio import protocols from asyncio import streams from asyncio import transports from asyncio.coroutines import coroutine -from typing import Any, AnyStr, Optional, Tuple, Union +from typing import Any, AnyStr, Generator, Optional, Tuple, Union __all__ = ... # type: str @@ -28,12 +28,12 @@ class Process: @property def returncode(self) -> int: ... @coroutine - def wait(self) -> int: ... + def wait(self) -> Generator[Any, None, int]: ... def send_signal(self, signal: int) -> None: ... def terminate(self) -> None: ... def kill(self) -> None: ... @coroutine - def communicate(self, input: Optional[bytes] = ...) -> Tuple[bytes, bytes]: ... + def communicate(self, input: Optional[bytes] = ...) -> Generator[Any, None, Tuple[bytes, bytes]]: ... @coroutine @@ -45,7 +45,7 @@ def create_subprocess_shell( loop: events.AbstractEventLoop = ..., limit: int = ..., **kwds: Any -): ... +) -> Generator[Any, None, Process]: ... @coroutine def create_subprocess_exec( @@ -57,4 +57,4 @@ def create_subprocess_exec( loop: events.AbstractEventLoop = ..., limit: int = ..., **kwds: Any -) -> Process: ... +) -> Generator[Any, None, Process]: ... diff --git a/python/helpers/typeshed/stdlib/3.4/asyncio/tasks.pyi b/python/helpers/typeshed/stdlib/3.4/asyncio/tasks.pyi index de4f4ccd716d..e95d758ae989 100644 --- a/python/helpers/typeshed/stdlib/3.4/asyncio/tasks.pyi +++ b/python/helpers/typeshed/stdlib/3.4/asyncio/tasks.pyi @@ -26,7 +26,7 @@ def run_coroutine_threadsafe(coro: _FutureT[_T], loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ... def shield(arg: _FutureT[_T], *, loop: AbstractEventLoop = ...) -> Future[_T]: ... def sleep(delay: float, result: _T = ..., loop: AbstractEventLoop = ...) -> Future[_T]: ... -def wait(fs: List[_FutureT[_T]], *, loop: AbstractEventLoop = ..., +def wait(fs: Iterable[_FutureT[_T]], *, loop: AbstractEventLoop = ..., timeout: float = ..., return_when: str = ...) -> Future[Tuple[Set[Future[_T]], Set[Future[_T]]]]: ... def wait_for(fut: _FutureT[_T], timeout: Optional[float], diff --git a/python/helpers/typeshed/stdlib/3.4/pathlib.pyi b/python/helpers/typeshed/stdlib/3.4/pathlib.pyi index 67ad85376e84..ef142a7c7fb0 100644 --- a/python/helpers/typeshed/stdlib/3.4/pathlib.pyi +++ b/python/helpers/typeshed/stdlib/3.4/pathlib.pyi @@ -1,6 +1,6 @@ # Stubs for pathlib (Python 3.4) -from typing import Any, Generator, IO, Optional, Sequence, Tuple, Type, TypeVar, Union +from typing import Any, Generator, IO, Optional, Sequence, Tuple, Type, TypeVar, Union, List import os import sys diff --git a/python/helpers/typeshed/stdlib/3.4/xml/__init__.pyi b/python/helpers/typeshed/stdlib/3.4/xml/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/python/helpers/typeshed/stdlib/3.4/xml/etree/ElementInclude.pyi b/python/helpers/typeshed/stdlib/3.4/xml/etree/ElementInclude.pyi deleted file mode 100644 index bbe3fb3ed057..000000000000 --- a/python/helpers/typeshed/stdlib/3.4/xml/etree/ElementInclude.pyi +++ /dev/null @@ -1,19 +0,0 @@ -# Stubs for xml.etree.ElementInclude (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Union, Optional, Callable -from .ElementTree import Element - -XINCLUDE = ... # type: str -XINCLUDE_INCLUDE = ... # type: str -XINCLUDE_FALLBACK = ... # type: str - -class FatalIncludeError(SyntaxError): ... - -def default_loader(href: Union[str, bytes, int], parse: str, encoding: Optional[str]=...) -> Union[str, Element]: ... - -# TODO: loader is of type default_loader ie it takes a callable that has the -# same signature as default_loader. But default_loader has a keyword argument -# Which can't be represented using Callable... -def include(elem: Element, loader: Callable[..., Union[str, Element]]=...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3.4/xml/etree/ElementPath.pyi b/python/helpers/typeshed/stdlib/3.4/xml/etree/ElementPath.pyi deleted file mode 100644 index b1ea50e68cf0..000000000000 --- a/python/helpers/typeshed/stdlib/3.4/xml/etree/ElementPath.pyi +++ /dev/null @@ -1,35 +0,0 @@ -# Stubs for xml.etree.ElementPath (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Pattern, Dict, Generator, Tuple, List, Union, TypeVar, Callable, Optional -from .ElementTree import Element - -xpath_tokenizer_re = ... # type: Pattern - -_token = Tuple[str, str] -_next = Callable[[], _token] -_callback = Callable[['_SelectorContext', List[Element]], Generator[Element, None, None]] - -def xpath_tokenizer(pattern: str, namespaces: Dict[str, str]=...) -> Generator[_token, None, None]: ... -def get_parent_map(context: '_SelectorContext') -> Dict[Element, Element]: ... -def prepare_child(next: _next, token: _token) -> _callback: ... -def prepare_star(next: _next, token: _token) -> _callback: ... -def prepare_self(next: _next, token: _token) -> _callback: ... -def prepare_descendant(next: _next, token: _token) -> _callback: ... -def prepare_parent(next: _next, token: _token) -> _callback: ... -def prepare_predicate(next: _next, token: _token) -> _callback: ... - -ops = ... # type: Dict[str, Callable[[_next, _token], _callback]] - -class _SelectorContext: - parent_map = ... # type: Dict[Element, Element] - root = ... # type: Element - def __init__(self, root: Element) -> None: ... - -_T = TypeVar('_T') - -def iterfind(elem: Element, path: str, namespaces: Dict[str, str]=...) -> List[Element]: ... -def find(elem: Element, path: str, namespaces: Dict[str, str]=...) -> Optional[Element]: ... -def findall(elem: Element, path: str, namespaces: Dict[str, str]=...) -> List[Element]: ... -def findtext(elem: Element, path: str, default: _T=..., namespaces: Dict[str, str]=...) -> Union[_T, str]: ... diff --git a/python/helpers/typeshed/stdlib/3.4/xml/etree/ElementTree.pyi b/python/helpers/typeshed/stdlib/3.4/xml/etree/ElementTree.pyi deleted file mode 100644 index 0592be78ed24..000000000000 --- a/python/helpers/typeshed/stdlib/3.4/xml/etree/ElementTree.pyi +++ /dev/null @@ -1,118 +0,0 @@ -# Stubs for xml.etree.ElementTree (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any, AnyStr, Union, IO, Callable, Dict, List, Tuple, Sequence, Iterator, TypeVar, Optional, KeysView, ItemsView, Generator -import io - -VERSION = ... # type: str - -class ParseError(SyntaxError): ... - -def iselement(element: 'Element') -> bool: ... - -_Ss = TypeVar('_Ss', str, bytes) -_T = TypeVar('_T') -_str_or_bytes = Union[str, bytes] - -class Element(Sequence['Element']): - tag = ... # type: _str_or_bytes - attrib = ... # type: Dict[_str_or_bytes, _str_or_bytes] - text = ... # type: Optional[_str_or_bytes] - tail = ... # type: Optional[_str_or_bytes] - def __init__(self, tag: Union[AnyStr, Callable[..., 'Element']], attrib: Dict[AnyStr, AnyStr]=..., **extra: AnyStr) -> None: ... - def append(self, subelement: 'Element') -> None: ... - def clear(self) -> None: ... - def copy(self) -> 'Element': ... - def extend(self, elements: Sequence['Element']) -> None: ... - def find(self, path: str, namespaces: Dict[str, str]=...) -> Optional['Element']: ... - def findall(self, path: str, namespaces: Dict[str, str]=...) -> List['Element']: ... - def findtext(self, path: str, default: _T=..., namespaces: Dict[str, str]=...) -> Union[_T, str]: ... - def get(self, key: AnyStr, default: _T=...) -> Union[AnyStr, _T]: ... - def getchildren(self) -> List['Element']: ... - def getiterator(self, tag: Union[str, AnyStr]=...) -> List['Element']: ... - def insert(self, index: int, subelement: 'Element') -> None: ... - def items(self) -> ItemsView[AnyStr, AnyStr]: ... - def iter(self, tag: Union[str, AnyStr]=...) -> Generator['Element', None, None]: ... - def iterfind(self, path: str, namespaces: Dict[str, str]=...) -> List['Element']: ... - def itertext(self) -> Generator[str, None, None]: ... - def keys(self) -> KeysView[AnyStr]: ... - def makeelement(self, tag: _Ss, attrib: Dict[_Ss, _Ss]) -> 'Element': ... - def remove(self, subelement: 'Element') -> None: ... - def set(self, key: AnyStr, value: AnyStr) -> None: ... - def __bool__(self) -> bool: ... - def __delitem__(self, index: int) -> None: ... - def __getitem__(self, index) -> 'Element': ... - def __len__(self) -> int: ... - def __setitem__(self, index: int, element: 'Element') -> None: ... - -def SubElement(parent: Element, tag: AnyStr, attrib: Dict[AnyStr, AnyStr]=..., **extra: AnyStr) -> Element: ... -def Comment(text: _str_or_bytes=...) -> Element: ... -def ProcessingInstruction(target: str, text: str=...) -> Element: ... - -PI = ... # type: Callable[..., Element] - -class QName: - text = ... # type: str - def __init__(self, text_or_uri: str, tag: str=...) -> None: ... - - -_file_or_filename = Union[str, bytes, int, IO[Any]] - -class ElementTree: - def __init__(self, element: Element=..., file: _file_or_filename=...) -> None: ... - def getroot(self) -> Element: ... - def parse(self, source: _file_or_filename, parser: 'XMLParser'=...) -> Element: ... - def iter(self, tag: Union[str, AnyStr]=...) -> Generator[Element, None, None]: ... - def getiterator(self, tag: Union[str, AnyStr]=...) -> List[Element]: ... - def find(self, path: str, namespaces: Dict[str, str]=...) -> Optional[Element]: ... - def findtext(self, path: str, default: _T=..., namespaces: Dict[str, str]=...) -> Union[_T, str]: ... - def findall(self, path: str, namespaces: Dict[str, str]=...) -> List[Element]: ... - def iterfind(self, path: str, namespaces: Dict[str, str]=...) -> List[Element]: ... - def write(self, file_or_filename: _file_or_filename, encoding: str=..., xml_declaration: Optional[bool]=..., default_namespace: str=..., method: str=..., *, short_empty_elements: bool=...) -> None: ... - def write_c14n(self, file: _file_or_filename) -> None: ... - -def register_namespace(prefix: str, uri: str) -> None: ... -def tostring(element: Element, encoding: str=..., method: str=..., *, short_empty_elements: bool=...) -> str: ... -def tostringlist(element: Element, encoding: str=..., method: str=..., *, short_empty_elements: bool=...) -> List[str]: ... -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]]: ... - -class XMLPullParser: - def __init__(self, events: Sequence[str]=..., *, _parser: 'XMLParser'=...) -> None: ... - def feed(self, data: bytes) -> None: ... - def close(self) -> None: ... - def read_events(self) -> Iterator[Tuple[str, Element]]: ... - -class _IterParseIterator: - root = ... # type: Any - def __init__(self, source: _file_or_filename, events: Sequence[str], parser: 'XMLParser', close_source: bool=...) -> None: ... - def __next__(self) -> Tuple[str, Element]: ... - def __iter__(self) -> _IterParseIterator: ... - -def XML(text: AnyStr, parser: 'XMLParser'=...) -> Element: ... -def XMLID(text: AnyStr, parser: 'XMLParser'=...) -> Tuple[Element, Dict[str, Element]]: ... - -# TODO-improve this type -fromstring = ... # type: Callable[..., Element] - -def fromstringlist(sequence: Sequence[AnyStr], parser: 'XMLParser'=...) -> Element: ... - -class TreeBuilder: - def __init__(self, element_factory: Callable[[AnyStr, Dict[AnyStr, AnyStr]], Element]=...) -> None: ... - def close(self) -> Element: ... - def data(self, data: AnyStr) -> None: ... - def start(self, tag: AnyStr, attrs: Dict[AnyStr, AnyStr]) -> Element: ... - def end(self, tag: AnyStr) -> Element: ... - -class XMLParser: - parser = ... # type: Any - target = ... # type: TreeBuilder - # TODO-what is entity used for??? - entity = ... # type: Any - version = ... # type: str - def __init__(self, html: int=..., target: TreeBuilder=..., encoding: str=...) -> None: ... - def doctype(self, name: str, pubid: str, system: str) -> None: ... - def close(self) -> Any: ... # TODO-most of the time, this will be Element, but it can be anything target.close() returns - def feed(self, data: AnyStr)-> None: ... diff --git a/python/helpers/typeshed/stdlib/3.4/xml/etree/__init__.pyi b/python/helpers/typeshed/stdlib/3.4/xml/etree/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/python/helpers/typeshed/stdlib/3.4/xml/etree/cElementTree.pyi b/python/helpers/typeshed/stdlib/3.4/xml/etree/cElementTree.pyi deleted file mode 100644 index 8f689de4b1aa..000000000000 --- a/python/helpers/typeshed/stdlib/3.4/xml/etree/cElementTree.pyi +++ /dev/null @@ -1,5 +0,0 @@ -# Stubs for xml.etree.cElementTree (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from xml.etree.ElementTree import * # noqa: F403 diff --git a/python/helpers/typeshed/stdlib/3.5/xml/__init__.pyi b/python/helpers/typeshed/stdlib/3.5/xml/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/python/helpers/typeshed/stdlib/3.5/xml/etree/ElementInclude.pyi b/python/helpers/typeshed/stdlib/3.5/xml/etree/ElementInclude.pyi deleted file mode 100644 index bbe3fb3ed057..000000000000 --- a/python/helpers/typeshed/stdlib/3.5/xml/etree/ElementInclude.pyi +++ /dev/null @@ -1,19 +0,0 @@ -# Stubs for xml.etree.ElementInclude (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Union, Optional, Callable -from .ElementTree import Element - -XINCLUDE = ... # type: str -XINCLUDE_INCLUDE = ... # type: str -XINCLUDE_FALLBACK = ... # type: str - -class FatalIncludeError(SyntaxError): ... - -def default_loader(href: Union[str, bytes, int], parse: str, encoding: Optional[str]=...) -> Union[str, Element]: ... - -# TODO: loader is of type default_loader ie it takes a callable that has the -# same signature as default_loader. But default_loader has a keyword argument -# Which can't be represented using Callable... -def include(elem: Element, loader: Callable[..., Union[str, Element]]=...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3.5/xml/etree/ElementPath.pyi b/python/helpers/typeshed/stdlib/3.5/xml/etree/ElementPath.pyi deleted file mode 100644 index b1ea50e68cf0..000000000000 --- a/python/helpers/typeshed/stdlib/3.5/xml/etree/ElementPath.pyi +++ /dev/null @@ -1,35 +0,0 @@ -# Stubs for xml.etree.ElementPath (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Pattern, Dict, Generator, Tuple, List, Union, TypeVar, Callable, Optional -from .ElementTree import Element - -xpath_tokenizer_re = ... # type: Pattern - -_token = Tuple[str, str] -_next = Callable[[], _token] -_callback = Callable[['_SelectorContext', List[Element]], Generator[Element, None, None]] - -def xpath_tokenizer(pattern: str, namespaces: Dict[str, str]=...) -> Generator[_token, None, None]: ... -def get_parent_map(context: '_SelectorContext') -> Dict[Element, Element]: ... -def prepare_child(next: _next, token: _token) -> _callback: ... -def prepare_star(next: _next, token: _token) -> _callback: ... -def prepare_self(next: _next, token: _token) -> _callback: ... -def prepare_descendant(next: _next, token: _token) -> _callback: ... -def prepare_parent(next: _next, token: _token) -> _callback: ... -def prepare_predicate(next: _next, token: _token) -> _callback: ... - -ops = ... # type: Dict[str, Callable[[_next, _token], _callback]] - -class _SelectorContext: - parent_map = ... # type: Dict[Element, Element] - root = ... # type: Element - def __init__(self, root: Element) -> None: ... - -_T = TypeVar('_T') - -def iterfind(elem: Element, path: str, namespaces: Dict[str, str]=...) -> List[Element]: ... -def find(elem: Element, path: str, namespaces: Dict[str, str]=...) -> Optional[Element]: ... -def findall(elem: Element, path: str, namespaces: Dict[str, str]=...) -> List[Element]: ... -def findtext(elem: Element, path: str, default: _T=..., namespaces: Dict[str, str]=...) -> Union[_T, str]: ... diff --git a/python/helpers/typeshed/stdlib/3.5/xml/etree/ElementTree.pyi b/python/helpers/typeshed/stdlib/3.5/xml/etree/ElementTree.pyi deleted file mode 100644 index 0592be78ed24..000000000000 --- a/python/helpers/typeshed/stdlib/3.5/xml/etree/ElementTree.pyi +++ /dev/null @@ -1,118 +0,0 @@ -# Stubs for xml.etree.ElementTree (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any, AnyStr, Union, IO, Callable, Dict, List, Tuple, Sequence, Iterator, TypeVar, Optional, KeysView, ItemsView, Generator -import io - -VERSION = ... # type: str - -class ParseError(SyntaxError): ... - -def iselement(element: 'Element') -> bool: ... - -_Ss = TypeVar('_Ss', str, bytes) -_T = TypeVar('_T') -_str_or_bytes = Union[str, bytes] - -class Element(Sequence['Element']): - tag = ... # type: _str_or_bytes - attrib = ... # type: Dict[_str_or_bytes, _str_or_bytes] - text = ... # type: Optional[_str_or_bytes] - tail = ... # type: Optional[_str_or_bytes] - def __init__(self, tag: Union[AnyStr, Callable[..., 'Element']], attrib: Dict[AnyStr, AnyStr]=..., **extra: AnyStr) -> None: ... - def append(self, subelement: 'Element') -> None: ... - def clear(self) -> None: ... - def copy(self) -> 'Element': ... - def extend(self, elements: Sequence['Element']) -> None: ... - def find(self, path: str, namespaces: Dict[str, str]=...) -> Optional['Element']: ... - def findall(self, path: str, namespaces: Dict[str, str]=...) -> List['Element']: ... - def findtext(self, path: str, default: _T=..., namespaces: Dict[str, str]=...) -> Union[_T, str]: ... - def get(self, key: AnyStr, default: _T=...) -> Union[AnyStr, _T]: ... - def getchildren(self) -> List['Element']: ... - def getiterator(self, tag: Union[str, AnyStr]=...) -> List['Element']: ... - def insert(self, index: int, subelement: 'Element') -> None: ... - def items(self) -> ItemsView[AnyStr, AnyStr]: ... - def iter(self, tag: Union[str, AnyStr]=...) -> Generator['Element', None, None]: ... - def iterfind(self, path: str, namespaces: Dict[str, str]=...) -> List['Element']: ... - def itertext(self) -> Generator[str, None, None]: ... - def keys(self) -> KeysView[AnyStr]: ... - def makeelement(self, tag: _Ss, attrib: Dict[_Ss, _Ss]) -> 'Element': ... - def remove(self, subelement: 'Element') -> None: ... - def set(self, key: AnyStr, value: AnyStr) -> None: ... - def __bool__(self) -> bool: ... - def __delitem__(self, index: int) -> None: ... - def __getitem__(self, index) -> 'Element': ... - def __len__(self) -> int: ... - def __setitem__(self, index: int, element: 'Element') -> None: ... - -def SubElement(parent: Element, tag: AnyStr, attrib: Dict[AnyStr, AnyStr]=..., **extra: AnyStr) -> Element: ... -def Comment(text: _str_or_bytes=...) -> Element: ... -def ProcessingInstruction(target: str, text: str=...) -> Element: ... - -PI = ... # type: Callable[..., Element] - -class QName: - text = ... # type: str - def __init__(self, text_or_uri: str, tag: str=...) -> None: ... - - -_file_or_filename = Union[str, bytes, int, IO[Any]] - -class ElementTree: - def __init__(self, element: Element=..., file: _file_or_filename=...) -> None: ... - def getroot(self) -> Element: ... - def parse(self, source: _file_or_filename, parser: 'XMLParser'=...) -> Element: ... - def iter(self, tag: Union[str, AnyStr]=...) -> Generator[Element, None, None]: ... - def getiterator(self, tag: Union[str, AnyStr]=...) -> List[Element]: ... - def find(self, path: str, namespaces: Dict[str, str]=...) -> Optional[Element]: ... - def findtext(self, path: str, default: _T=..., namespaces: Dict[str, str]=...) -> Union[_T, str]: ... - def findall(self, path: str, namespaces: Dict[str, str]=...) -> List[Element]: ... - def iterfind(self, path: str, namespaces: Dict[str, str]=...) -> List[Element]: ... - def write(self, file_or_filename: _file_or_filename, encoding: str=..., xml_declaration: Optional[bool]=..., default_namespace: str=..., method: str=..., *, short_empty_elements: bool=...) -> None: ... - def write_c14n(self, file: _file_or_filename) -> None: ... - -def register_namespace(prefix: str, uri: str) -> None: ... -def tostring(element: Element, encoding: str=..., method: str=..., *, short_empty_elements: bool=...) -> str: ... -def tostringlist(element: Element, encoding: str=..., method: str=..., *, short_empty_elements: bool=...) -> List[str]: ... -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]]: ... - -class XMLPullParser: - def __init__(self, events: Sequence[str]=..., *, _parser: 'XMLParser'=...) -> None: ... - def feed(self, data: bytes) -> None: ... - def close(self) -> None: ... - def read_events(self) -> Iterator[Tuple[str, Element]]: ... - -class _IterParseIterator: - root = ... # type: Any - def __init__(self, source: _file_or_filename, events: Sequence[str], parser: 'XMLParser', close_source: bool=...) -> None: ... - def __next__(self) -> Tuple[str, Element]: ... - def __iter__(self) -> _IterParseIterator: ... - -def XML(text: AnyStr, parser: 'XMLParser'=...) -> Element: ... -def XMLID(text: AnyStr, parser: 'XMLParser'=...) -> Tuple[Element, Dict[str, Element]]: ... - -# TODO-improve this type -fromstring = ... # type: Callable[..., Element] - -def fromstringlist(sequence: Sequence[AnyStr], parser: 'XMLParser'=...) -> Element: ... - -class TreeBuilder: - def __init__(self, element_factory: Callable[[AnyStr, Dict[AnyStr, AnyStr]], Element]=...) -> None: ... - def close(self) -> Element: ... - def data(self, data: AnyStr) -> None: ... - def start(self, tag: AnyStr, attrs: Dict[AnyStr, AnyStr]) -> Element: ... - def end(self, tag: AnyStr) -> Element: ... - -class XMLParser: - parser = ... # type: Any - target = ... # type: TreeBuilder - # TODO-what is entity used for??? - entity = ... # type: Any - version = ... # type: str - def __init__(self, html: int=..., target: TreeBuilder=..., encoding: str=...) -> None: ... - def doctype(self, name: str, pubid: str, system: str) -> None: ... - def close(self) -> Any: ... # TODO-most of the time, this will be Element, but it can be anything target.close() returns - def feed(self, data: AnyStr)-> None: ... diff --git a/python/helpers/typeshed/stdlib/3.5/xml/etree/__init__.pyi b/python/helpers/typeshed/stdlib/3.5/xml/etree/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/python/helpers/typeshed/stdlib/3.5/xml/etree/cElementTree.pyi b/python/helpers/typeshed/stdlib/3.5/xml/etree/cElementTree.pyi deleted file mode 100644 index 8f689de4b1aa..000000000000 --- a/python/helpers/typeshed/stdlib/3.5/xml/etree/cElementTree.pyi +++ /dev/null @@ -1,5 +0,0 @@ -# Stubs for xml.etree.cElementTree (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from xml.etree.ElementTree import * # noqa: F403 diff --git a/python/helpers/typeshed/stdlib/3/builtins.pyi b/python/helpers/typeshed/stdlib/3/builtins.pyi index f9ed70f6a705..3c82247a6ae6 100644 --- a/python/helpers/typeshed/stdlib/3/builtins.pyi +++ b/python/helpers/typeshed/stdlib/3/builtins.pyi @@ -34,11 +34,12 @@ class object: __class__ = ... # type: type __dict__ = ... # type: Dict[str, Any] __slots__ = ... # type: Optional[Union[str, Iterable[str]]] - __module__ = ... # type: Any def __init__(self) -> None: ... def __new__(cls) -> Any: ... def __setattr__(self, name: str, value: Any) -> None: ... + def __eq__(self, o: object) -> bool: ... + def __ne__(self, o: object) -> bool: ... def __str__(self) -> str: ... def __repr__(self) -> str: ... def __hash__(self) -> int: ... @@ -46,8 +47,6 @@ class object: def __getattribute__(self, name: str) -> Any: ... def __delattr__(self, name: str) -> None: ... def __sizeof__(self) -> int: ... - def __reduce__(self) -> Union[str, tuple]: ... - def __reduce_ex__(self, protocol: int) -> Union[str, tuple]: ... if sys.version_info >= (3, 6): def __init_subclass__(cls) -> None: ... @@ -57,6 +56,7 @@ class type: __name__ = ... # type: str __qualname__ = ... # type: str __module__ = ... # type: str + __dict__ = ... # type: Dict[str, Any] __mro__ = ... # type: Tuple[type, ...] @overload @@ -299,14 +299,23 @@ class bytes(ByteString): def __init__(self, o: SupportsBytes) -> None: ... def capitalize(self) -> bytes: ... def center(self, width: int, fillchar: bytes = ...) -> bytes: ... - def count(self, x: bytes) -> int: ... + if sys.version_info >= (3, 3): + def count(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ... + else: + def count(self, sub: bytes, start: int = None, end: int = None) -> int: ... def decode(self, encoding: str = 'utf-8', errors: str = 'strict') -> str: ... def endswith(self, suffix: Union[bytes, Tuple[bytes, ...]]) -> bool: ... def expandtabs(self, tabsize: int = 8) -> bytes: ... - def find(self, sub: bytes, start: int = 0, end: int = 0) -> int: ... + if sys.version_info >= (3, 3): + def find(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ... + else: + def find(self, sub: bytes, start: int = None, end: int = None) -> int: ... if sys.version_info >= (3, 5): def hex(self) -> str: ... - def index(self, sub: bytes, start: int = 0, end: int = 0) -> int: ... + if sys.version_info >= (3, 3): + def index(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ... + else: + def index(self, sub: bytes, start: int = None, end: int = None) -> int: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... def isdigit(self) -> bool: ... @@ -320,8 +329,14 @@ class bytes(ByteString): def lstrip(self, chars: bytes = None) -> bytes: ... def partition(self, sep: bytes) -> Tuple[bytes, bytes, bytes]: ... def replace(self, old: bytes, new: bytes, count: int = -1) -> bytes: ... - def rfind(self, sub: bytes, start: int = 0, end: int = 0) -> int: ... - def rindex(self, sub: bytes, start: int = 0, end: int = 0) -> int: ... + if sys.version_info >= (3, 3): + def rfind(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ... + else: + def rfind(self, sub: bytes, start: int = None, end: int = None) -> int: ... + if sys.version_info >= (3, 3): + def rindex(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ... + else: + def rindex(self, sub: bytes, start: int = None, end: int = None) -> int: ... def rjust(self, width: int, fillchar: bytes = ...) -> bytes: ... def rpartition(self, sep: bytes) -> Tuple[bytes, bytes, bytes]: ... def rsplit(self, sep: bytes = None, maxsplit: int = -1) -> List[bytes]: ... @@ -373,14 +388,23 @@ class bytearray(MutableSequence[int], ByteString): def __init__(self) -> None: ... def capitalize(self) -> bytearray: ... def center(self, width: int, fillchar: bytes = ...) -> bytearray: ... - def count(self, x: bytes) -> int: ... + if sys.version_info >= (3, 3): + def count(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ... + else: + def count(self, sub: bytes, start: int = None, end: int = None) -> int: ... def decode(self, encoding: str = 'utf-8', errors: str = 'strict') -> str: ... def endswith(self, suffix: bytes) -> bool: ... def expandtabs(self, tabsize: int = 8) -> bytearray: ... - def find(self, sub: bytes, start: int = 0, end: int = 0) -> int: ... + if sys.version_info >= (3, 3): + def find(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ... + else: + def find(self, sub: bytes, start: int = None, end: int = None) -> int: ... if sys.version_info >= (3, 5): def hex(self) -> str: ... - def index(self, sub: bytes, start: int = 0, end: int = 0) -> int: ... + if sys.version_info >= (3, 3): + def index(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ... + else: + def index(self, sub: bytes, start: int = None, end: int = None) -> int: ... def insert(self, index: int, object: int) -> None: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... @@ -395,8 +419,14 @@ class bytearray(MutableSequence[int], ByteString): def lstrip(self, chars: bytes = None) -> bytearray: ... def partition(self, sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... def replace(self, old: bytes, new: bytes, count: int = -1) -> bytearray: ... - def rfind(self, sub: bytes, start: int = 0, end: int = 0) -> int: ... - def rindex(self, sub: bytes, start: int = 0, end: int = 0) -> int: ... + if sys.version_info >= (3, 3): + def rfind(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ... + else: + def rfind(self, sub: bytes, start: int = None, end: int = None) -> int: ... + if sys.version_info >= (3, 3): + def rindex(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ... + else: + def rindex(self, sub: bytes, start: int = None, end: int = None) -> int: ... def rjust(self, width: int, fillchar: bytes = ...) -> bytearray: ... def rpartition(self, sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... def rsplit(self, sep: bytes = None, maxsplit: int = -1) -> List[bytearray]: ... @@ -487,9 +517,9 @@ class slice: step = ... # type: Optional[int] stop = ... # type: Optional[int] @overload - def __init__(self, stop: int) -> None: ... + def __init__(self, stop: int = None) -> None: ... @overload - def __init__(self, start: int, stop: int, step: int = None) -> None: ... + def __init__(self, start: int = None, stop: int = None, step: int = None) -> None: ... class tuple(Sequence[_T_co], Generic[_T_co]): def __init__(self, iterable: Iterable[_T_co] = ...) -> None: ... @@ -504,8 +534,6 @@ class tuple(Sequence[_T_co], Generic[_T_co]): def __le__(self, x: Tuple[_T_co, ...]) -> bool: ... def __gt__(self, x: Tuple[_T_co, ...]) -> bool: ... def __ge__(self, x: Tuple[_T_co, ...]) -> bool: ... - def __eq__(self, x: Tuple[_T_co, ...]) -> bool: ... - def __ne__(self, x: Tuple[_T_co, ...]) -> bool: ... def __add__(self, x: Tuple[_T_co, ...]) -> Tuple[_T_co, ...]: ... def __mul__(self, n: int) -> Tuple[_T_co, ...]: ... def __rmul__(self, n: int) -> Tuple[_T_co, ...]: ... @@ -515,6 +543,13 @@ class tuple(Sequence[_T_co], Generic[_T_co]): else: def index(self, x: Any) -> int: ... +class function: + # TODO not defined in builtins! + __name__ = ... # type: str + __qualname__ = ... # type: str + __module__ = ... # type: str + __code__ = ... # type: Any + class list(MutableSequence[_T], Generic[_T]): @overload def __init__(self) -> None: ... @@ -673,10 +708,11 @@ class range(Sequence[int]): def __repr__(self) -> str: ... def __reversed__(self) -> Iterator[int]: ... -class module(object): +class module: # TODO not defined in builtins! __name__ = ... # type: str __file__ = ... # type: str + __dict__ = ... # type: Dict[str, Any] class property: def __init__(self, fget: Callable[[Any], Any] = None, @@ -753,8 +789,8 @@ def next(i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ... def oct(i: int) -> str: ... # TODO __index__ if sys.version_info >= (3, 6): - import os - def open(file: Union[str, bytes, int, os.PathLike], mode: str = 'r', buffering: int = -1, encoding: str = None, + from pathlib import Path + def open(file: Union[str, bytes, int, Path], mode: str = 'r', buffering: int = -1, encoding: str = None, errors: str = None, newline: str = None, closefd: bool = ...) -> IO[Any]: ... else: def open(file: Union[str, bytes, int], mode: str = 'r', buffering: int = -1, encoding: str = None, diff --git a/python/helpers/typeshed/stdlib/3/collections/__init__.pyi b/python/helpers/typeshed/stdlib/3/collections/__init__.pyi index 5cb89f7a3aa1..328644412600 100644 --- a/python/helpers/typeshed/stdlib/3/collections/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/collections/__init__.pyi @@ -139,10 +139,10 @@ class Counter(Dict[_T, int], Generic[_T]): def __iand__(self, other: Counter[_T]) -> Counter[_T]: ... def __ior__(self, other: Counter[_T]) -> Counter[_T]: ... -class OrderedDict(Dict[_KT, _VT], Generic[_KT, _VT]): +class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]): def popitem(self, last: bool = ...) -> Tuple[_KT, _VT]: ... def move_to_end(self, key: _KT, last: bool = ...) -> None: ... - + def __reversed__(self) -> Iterator[_KT]: ... class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]): default_factory = ... # type: Callable[[], _VT] @@ -180,3 +180,9 @@ if sys.version_info >= (3, 3): @property def parents(self) -> ChainMap[_KT, _VT]: ... + + def __setitem__(self, k: _KT, v: _VT) -> None: ... + def __delitem__(self, v: _KT) -> None: ... + def __getitem__(self, k: _KT) -> _VT: ... + def __iter__(self) -> Iterator[_KT]: ... + def __len__(self) -> int: ... diff --git a/python/helpers/typeshed/stdlib/3/concurrent/futures/_base.pyi b/python/helpers/typeshed/stdlib/3/concurrent/futures/_base.pyi index 27c2711feb98..00ef5b6c343c 100644 --- a/python/helpers/typeshed/stdlib/3/concurrent/futures/_base.pyi +++ b/python/helpers/typeshed/stdlib/3/concurrent/futures/_base.pyi @@ -27,10 +27,10 @@ class Future(Generic[_T]): def done(self) -> bool: ... def add_done_callback(self, fn: Callable[[Future], Any]) -> None: ... def result(self, timeout: Optional[float] = ...) -> _T: ... - def exception(self, timeout: Optional[float] = ...) -> Exception: ... + def exception(self, timeout: Optional[float] = ...) -> BaseException: ... def set_running_or_notify_cancel(self) -> None: ... def set_result(self, result: _T) -> None: ... - def set_exception(self, exception: Exception) -> None: ... + def set_exception(self, exception: BaseException) -> None: ... class Executor: def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ... diff --git a/python/helpers/typeshed/stdlib/3/dis.pyi b/python/helpers/typeshed/stdlib/3/dis.pyi index c26afc17b264..c63725691986 100644 --- a/python/helpers/typeshed/stdlib/3/dis.pyi +++ b/python/helpers/typeshed/stdlib/3/dis.pyi @@ -1,4 +1,4 @@ -from typing import List, Union, Iterator, Tuple, Optional, Any, IO, NamedTuple +from typing import List, Union, Iterator, Tuple, Optional, Any, IO, NamedTuple, Dict from opcode import (hasconst, hasname, hasjrel, hasjabs, haslocal, hascompare, hasfree, hasnargs, cmp_op, opname, opmap, HAVE_ARGUMENT, diff --git a/python/helpers/typeshed/stdlib/3/hashlib.pyi b/python/helpers/typeshed/stdlib/3/hashlib.pyi index 4d3709b206fc..fd47015d5b98 100644 --- a/python/helpers/typeshed/stdlib/3/hashlib.pyi +++ b/python/helpers/typeshed/stdlib/3/hashlib.pyi @@ -1,7 +1,9 @@ # Stubs for hashlib from abc import abstractmethod, ABCMeta -from typing import AbstractSet +from typing import AbstractSet, Union + +_DataType = Union[bytes, bytearray, memoryview] class Hash(metaclass=ABCMeta): digest_size = ... # type: int @@ -13,7 +15,7 @@ class Hash(metaclass=ABCMeta): name = ... # type: str @abstractmethod - def update(self, arg: bytes) -> None: ... + def update(self, arg: _DataType) -> None: ... @abstractmethod def digest(self) -> bytes: ... @abstractmethod @@ -21,20 +23,18 @@ class Hash(metaclass=ABCMeta): @abstractmethod def copy(self) -> 'Hash': ... -def md5(arg: bytes = ...) -> Hash: ... -def sha1(arg: bytes = ...) -> Hash: ... -def sha224(arg: bytes = ...) -> Hash: ... -def sha256(arg: bytes = ...) -> Hash: ... -def sha384(arg: bytes = ...) -> Hash: ... -def sha512(arg: bytes = ...) -> Hash: ... +def md5(arg: _DataType = ...) -> Hash: ... +def sha1(arg: _DataType = ...) -> Hash: ... +def sha224(arg: _DataType = ...) -> Hash: ... +def sha256(arg: _DataType = ...) -> Hash: ... +def sha384(arg: _DataType = ...) -> Hash: ... +def sha512(arg: _DataType = ...) -> Hash: ... -def new(name: str, data: bytes = ...) -> Hash: ... +def new(name: str, data: _DataType = ...) -> Hash: ... # New in version 3.2 algorithms_guaranteed = ... # type: AbstractSet[str] algorithms_available = ... # type: AbstractSet[str] # New in version 3.4 -# TODO The documentation says "password and salt are interpreted as buffers of -# bytes", should we declare something other than bytes here? -def pbkdf2_hmac(name: str, password: bytes, salt: bytes, rounds: int, dklen: int = ...) -> bytes: ... +def pbkdf2_hmac(name: str, password: _DataType, salt: _DataType, rounds: int, dklen: int = ...) -> bytes: ... diff --git a/python/helpers/typeshed/stdlib/3/http/__init__.pyi b/python/helpers/typeshed/stdlib/3/http/__init__.pyi index a9a77da045d4..a72ccba396fa 100644 --- a/python/helpers/typeshed/stdlib/3/http/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/http/__init__.pyi @@ -9,60 +9,60 @@ if sys.version_info >= (3, 5): self.phrase = ... # type: str self.description = ... # type: str - CONTINUE = ... # type: object - SWITCHING_PROTOCOLS = ... # type: object - PROCESSING = ... # type: object - OK = ... # type: object - CREATED = ... # type: object - ACCEPTED = ... # type: object - NON_AUTHORITATIVE_INFORMATION = ... # type: object - NO_CONTENT = ... # type: object - RESET_CONTENT = ... # type: object - PARTIAL_CONTENT = ... # type: object - MULTI_STATUS = ... # type: object - ALREADY_REPORTED = ... # type: object - IM_USED = ... # type: object - MULTIPLE_CHOICES = ... # type: object - MOVED_PERMANENTLY = ... # type: object - FOUND = ... # type: object - SEE_OTHER = ... # type: object - NOT_MODIFIED = ... # type: object - USE_PROXY = ... # type: object - TEMPORARY_REDIRECT = ... # type: object - PERMANENT_REDIRECT = ... # type: object - BAD_REQUEST = ... # type: object - UNAUTHORIZED = ... # type: object - PAYMENT_REQUIRED = ... # type: object - FORBIDDEN = ... # type: object - NOT_FOUND = ... # type: object - METHOD_NOT_ALLOWED = ... # type: object - NOT_ACCEPTABLE = ... # type: object - PROXY_AUTHENTICATION_REQUIRED = ... # type: object - REQUEST_TIMEOUT = ... # type: object - CONFLICT = ... # type: object - GONE = ... # type: object - LENGTH_REQUIRED = ... # type: object - PRECONDITION_FAILED = ... # type: object - REQUEST_ENTITY_TOO_LARGE = ... # type: object - REQUEST_URI_TOO_LONG = ... # type: object - UNSUPPORTED_MEDIA_TYPE = ... # type: object - REQUESTED_RANGE_NOT_SATISFIABLE = ... # type: object - EXPECTATION_FAILED = ... # type: object - UNPROCESSABLE_ENTITY = ... # type: object - LOCKED = ... # type: object - FAILED_DEPENDENCY = ... # type: object - UPGRADE_REQUIRED = ... # type: object - PRECONDITION_REQUIRED = ... # type: object - TOO_MANY_REQUESTS = ... # type: object - REQUEST_HEADER_FIELDS_TOO_LARGE = ... # type: object - INTERNAL_SERVER_ERROR = ... # type: object - NOT_IMPLEMENTED = ... # type: object - BAD_GATEWAY = ... # type: object - SERVICE_UNAVAILABLE = ... # type: object - GATEWAY_TIMEOUT = ... # type: object - HTTP_VERSION_NOT_SUPPORTED = ... # type: object - VARIANT_ALSO_NEGOTIATES = ... # type: object - INSUFFICIENT_STORAGE = ... # type: object - LOOP_DETECTED = ... # type: object - NOT_EXTENDED = ... # type: object - NETWORK_AUTHENTICATION_REQUIRED = ... # type: object + CONTINUE = ... # type: HTTPStatus + SWITCHING_PROTOCOLS = ... # type: HTTPStatus + PROCESSING = ... # type: HTTPStatus + OK = ... # type: HTTPStatus + CREATED = ... # type: HTTPStatus + ACCEPTED = ... # type: HTTPStatus + NON_AUTHORITATIVE_INFORMATION = ... # type: HTTPStatus + NO_CONTENT = ... # type: HTTPStatus + RESET_CONTENT = ... # type: HTTPStatus + PARTIAL_CONTENT = ... # type: HTTPStatus + MULTI_STATUS = ... # type: HTTPStatus + ALREADY_REPORTED = ... # type: HTTPStatus + IM_USED = ... # type: HTTPStatus + MULTIPLE_CHOICES = ... # type: HTTPStatus + MOVED_PERMANENTLY = ... # type: HTTPStatus + FOUND = ... # type: HTTPStatus + SEE_OTHER = ... # type: HTTPStatus + NOT_MODIFIED = ... # type: HTTPStatus + USE_PROXY = ... # type: HTTPStatus + TEMPORARY_REDIRECT = ... # type: HTTPStatus + PERMANENT_REDIRECT = ... # type: HTTPStatus + BAD_REQUEST = ... # type: HTTPStatus + UNAUTHORIZED = ... # type: HTTPStatus + PAYMENT_REQUIRED = ... # type: HTTPStatus + FORBIDDEN = ... # type: HTTPStatus + NOT_FOUND = ... # type: HTTPStatus + METHOD_NOT_ALLOWED = ... # type: HTTPStatus + NOT_ACCEPTABLE = ... # type: HTTPStatus + PROXY_AUTHENTICATION_REQUIRED = ... # type: HTTPStatus + REQUEST_TIMEOUT = ... # type: HTTPStatus + CONFLICT = ... # type: HTTPStatus + GONE = ... # type: HTTPStatus + LENGTH_REQUIRED = ... # type: HTTPStatus + PRECONDITION_FAILED = ... # type: HTTPStatus + REQUEST_ENTITY_TOO_LARGE = ... # type: HTTPStatus + REQUEST_URI_TOO_LONG = ... # type: HTTPStatus + UNSUPPORTED_MEDIA_TYPE = ... # type: HTTPStatus + REQUESTED_RANGE_NOT_SATISFIABLE = ... # type: HTTPStatus + EXPECTATION_FAILED = ... # type: HTTPStatus + UNPROCESSABLE_ENTITY = ... # type: HTTPStatus + LOCKED = ... # type: HTTPStatus + FAILED_DEPENDENCY = ... # type: HTTPStatus + UPGRADE_REQUIRED = ... # type: HTTPStatus + PRECONDITION_REQUIRED = ... # type: HTTPStatus + TOO_MANY_REQUESTS = ... # type: HTTPStatus + REQUEST_HEADER_FIELDS_TOO_LARGE = ... # type: HTTPStatus + INTERNAL_SERVER_ERROR = ... # type: HTTPStatus + NOT_IMPLEMENTED = ... # type: HTTPStatus + BAD_GATEWAY = ... # type: HTTPStatus + SERVICE_UNAVAILABLE = ... # type: HTTPStatus + GATEWAY_TIMEOUT = ... # type: HTTPStatus + HTTP_VERSION_NOT_SUPPORTED = ... # type: HTTPStatus + VARIANT_ALSO_NEGOTIATES = ... # type: HTTPStatus + INSUFFICIENT_STORAGE = ... # type: HTTPStatus + LOOP_DETECTED = ... # type: HTTPStatus + NOT_EXTENDED = ... # type: HTTPStatus + NETWORK_AUTHENTICATION_REQUIRED = ... # type: HTTPStatus diff --git a/python/helpers/typeshed/stdlib/3/itertools.pyi b/python/helpers/typeshed/stdlib/3/itertools.pyi index 8296d62827e3..889d583c5dd0 100644 --- a/python/helpers/typeshed/stdlib/3/itertools.pyi +++ b/python/helpers/typeshed/stdlib/3/itertools.pyi @@ -17,7 +17,7 @@ def repeat(object: _T) -> Iterator[_T]: ... @overload def repeat(object: _T, times: int) -> Iterator[_T]: ... -def accumulate(iterable: Iterable[_T]) -> Iterator[_T]: ... +def accumulate(iterable: Iterable[_T], func: Callable[[_T, _T], _T] = ...) -> Iterator[_T]: ... class chain(Iterator[_T], Generic[_T]): def __init__(self, *iterables: Iterable[_T]) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/shutil.pyi b/python/helpers/typeshed/stdlib/3/shutil.pyi index 1b917e6d1125..c2865c831618 100644 --- a/python/helpers/typeshed/stdlib/3/shutil.pyi +++ b/python/helpers/typeshed/stdlib/3/shutil.pyi @@ -7,25 +7,67 @@ import sys # sometimes they only work partially (broken exception messages), and the test # cases don't use them. -from typing import List, Iterable, Callable, Any, Tuple, Sequence, IO, AnyStr, Optional +from typing import ( + List, Iterable, Callable, Any, Tuple, Sequence, NamedTuple, IO, + AnyStr, Optional +) def copyfileobj(fsrc: IO[AnyStr], fdst: IO[AnyStr], length: int = ...) -> None: ... def copyfile(src: str, dst: str) -> None: ... -def copymode(src: str, dst: str) -> None: ... -def copystat(src: str, dst: str) -> None: ... -def copy(src: str, dst: str) -> None: ... -def copy2(src: str, dst: str) -> None: ... + +if sys.version_info >= (3, 3): + def copymode(src: str, dst: str, *, + follow_symlinks: bool = ...) -> None: ... + def copystat(src: str, dst: str, *, + follow_symlinks: bool = ...) -> None: ... + def copy(src: str, dst: str, *, + follow_symlinks: bool = ...) -> None: ... + def copy2(src: str, dst: str, *, + follow_symlinks: bool = ...) -> None: ... +else: + def copymode(src: str, dst: str) -> None: ... + def copystat(src: str, dst: str) -> None: ... + def copy(src: str, dst: str) -> None: ... + def copy2(src: str, dst: str) -> None: ... + def ignore_patterns(*patterns: str) -> Callable[[str, List[str]], Iterable[str]]: ... -def copytree(src: str, dst: str, symlinks: bool = ..., - ignore: Optional[Callable[[str, List[str]], Iterable[str]]] = ..., - copy_function: Callable[[str, str], None] = ..., - ignore_dangling_symlinks: bool = ...) -> None: ... + +if sys.version_info >= (3, 3): + def copytree(src: str, dst: str, symlinks: bool = ..., + ignore: Optional[Callable[[str, List[str]], + Iterable[str]]] = ..., + copy_function: Callable[[str, str], None] = ..., + ignore_dangling_symlinks: bool = ...) -> str: ... +else: + def copytree(src: str, dst: str, symlinks: bool = ..., + ignore: Optional[Callable[[str, List[str]], + Iterable[str]]] = ..., + copy_function: Callable[[str, str], None] = ..., + ignore_dangling_symlinks: bool = ...) -> None: ... + def rmtree(path: str, ignore_errors: bool = ..., onerror: Callable[[Any, str, Any], None] = ...) -> None: ... -def move(src: str, dst: str) -> None: ... + +if sys.version_info >= (3, 5): + def move(src: str, dst: str, + copy_function: Callable[[str, str], None] = ...) -> str: ... +elif sys.version_info >= (3, 3): + def move(src: str, dst: str) -> str: ... +else: + def move(src: str, dst: str) -> None: ... + +if sys.version_info >= (3, 3): + _ntuple_diskusage = NamedTuple('usage', [('total', int), + ('used', int), + ('free', int)]) + def disk_usage(path: str) -> _ntuple_diskusage: ... + def chown(path: str, user: Optional[str] = ..., + group: Optional[str] = ...) -> None: ... + def which(cmd: str, mode: int = ..., + path: Optional[str] = ...) -> Optional[str]: ... class Error(Exception): ... if sys.version_info >= (3, 4): @@ -48,4 +90,5 @@ def register_unpack_format(name: str, extensions: List[str], function: Any, def unregister_unpack_format(name: str) -> None: ... def get_unpack_formats() -> List[Tuple[str, List[str], str]]: ... -def which(cmd: str, mode: int = ..., path: str = ...) -> Optional[str]: ... +if sys.version_info >= (3, 3): + def get_terminal_size(fallback: Tuple[int, int] = ...) -> Tuple[int, int]: ... diff --git a/python/helpers/typeshed/stdlib/3/socket.pyi b/python/helpers/typeshed/stdlib/3/socket.pyi index 4915d8aa17a2..e0c21b08e88f 100644 --- a/python/helpers/typeshed/stdlib/3/socket.pyi +++ b/python/helpers/typeshed/stdlib/3/socket.pyi @@ -357,5 +357,5 @@ def inet_aton(ip_string: str) -> bytes: ... # ret val 4 bytes in length def inet_ntoa(packed_ip: bytes) -> str: ... def inet_pton(address_family: int, ip_string: str) -> bytes: ... def inet_ntop(address_family: int, packed_ip: bytes) -> str: ... -def getdefaulttimeout() -> Union[float, None]: ... -def setdefaulttimeout(timeout: float) -> None: ... +def getdefaulttimeout() -> Optional[float]: ... +def setdefaulttimeout(timeout: Optional[float]) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/ssl.pyi b/python/helpers/typeshed/stdlib/3/ssl.pyi index 250034ecdfb4..56d281b19bd3 100644 --- a/python/helpers/typeshed/stdlib/3/ssl.pyi +++ b/python/helpers/typeshed/stdlib/3/ssl.pyi @@ -229,7 +229,7 @@ class SSLContext: def wrap_socket(self, sock: socket.socket, server_side: bool = ..., do_handshake_on_connect: bool = ..., suppress_ragged_eofs: bool = ..., - server_hostname: Optional[str] = ...) -> 'SSLContext': ... + server_hostname: Optional[str] = ...) -> SSLSocket: ... if sys.version_info >= (3, 5): def wrap_bio(self, incoming: 'MemoryBIO', outgoing: 'MemoryBIO', server_side: bool = ..., diff --git a/python/helpers/typeshed/stdlib/3/sys.pyi b/python/helpers/typeshed/stdlib/3/sys.pyi index 042fcf14c08b..b3042e2ec058 100644 --- a/python/helpers/typeshed/stdlib/3/sys.pyi +++ b/python/helpers/typeshed/stdlib/3/sys.pyi @@ -7,6 +7,7 @@ from typing import ( List, Sequence, Any, Dict, Tuple, TextIO, overload, Optional, Union, TypeVar, Callable, Type, ) +import sys from types import TracebackType from mypy_extensions import NoReturn @@ -146,6 +147,10 @@ def getprofile() -> Any: ... # TODO return type def gettrace() -> Any: ... # TODO return def getwindowsversion() -> Any: ... # Windows only, TODO return type def intern(string: str) -> str: ... + +if sys.version_info >= (3, 5): + def is_finalizing() -> bool: ... + def setcheckinterval(interval: int) -> None: ... # deprecated def setdlopenflags(n: int) -> None: ... # Linux only def setprofile(profilefunc: Any) -> None: ... # TODO type diff --git a/python/helpers/typeshed/stdlib/3/types.pyi b/python/helpers/typeshed/stdlib/3/types.pyi index e6270bbca713..4c9535b37e26 100644 --- a/python/helpers/typeshed/stdlib/3/types.pyi +++ b/python/helpers/typeshed/stdlib/3/types.pyi @@ -24,6 +24,7 @@ class FunctionType: __closure__ = ... # type: Optional[Tuple[_Cell, ...]] __code__ = ... # type: CodeType __defaults__ = ... # type: Optional[Tuple[Any, ...]] + __dict__ = ... # type: Dict[str, Any] __globals__ = ... # type: Dict[str, Any] __name__ = ... # type: str __annotations__ = ... # type: Dict[str, Any] diff --git a/python/helpers/typeshed/stdlib/3/typing.pyi b/python/helpers/typeshed/stdlib/3/typing.pyi index 291d85ab34ab..fa53e5728b00 100644 --- a/python/helpers/typeshed/stdlib/3/typing.pyi +++ b/python/helpers/typeshed/stdlib/3/typing.pyi @@ -2,7 +2,6 @@ import sys from abc import abstractmethod, ABCMeta -from types import CodeType, FrameType # Definitions of special type checking related constructs. Their definition # are not used, so their value does not matter. @@ -33,6 +32,10 @@ List = TypeAlias(object) Dict = TypeAlias(object) DefaultDict = TypeAlias(object) Set = TypeAlias(object) +Counter = TypeAlias(object) +Deque = TypeAlias(object) +if sys.version_info >= (3, 3): + ChainMap = TypeAlias(object) # Predefined type variables. AnyStr = TypeVar('AnyStr', str, bytes) @@ -116,11 +119,6 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]): @abstractmethod def __iter__(self) -> 'Generator[_T_co, _T_contra, _V_co]': ... - gi_code = ... # type: CodeType - gi_frame = ... # type: FrameType - gi_running = ... # type: bool - gi_yieldfrom = ... # type: Optional[Generator] - # TODO: Several types should only be defined if sys.python_version >= (3, 5): # Awaitable, AsyncIterator, AsyncIterable, Coroutine, Collection, ContextManager. # See https: //github.com/python/typeshed/issues/655 for why this is not easy. @@ -176,11 +174,6 @@ if sys.version_info >= (3, 6): @abstractmethod def __aiter__(self) -> 'AsyncGenerator[_T_co, _T_contra]': ... - ag_await = ... # type: Any - ag_code = ... # type: CodeType - ag_frame = ... # type: FrameType - ag_running = ... # type: bool - class Container(Generic[_T_co]): @abstractmethod def __contains__(self, x: object) -> bool: ... @@ -343,7 +336,7 @@ class IO(Iterator[AnyStr], Generic[AnyStr]): @abstractmethod def readline(self, limit: int = ...) -> AnyStr: ... @abstractmethod - def readlines(self, hint: int = ...) -> List[AnyStr]: ... + def readlines(self, hint: int = ...) -> list[AnyStr]: ... @abstractmethod def seek(self, offset: int, whence: int = ...) -> int: ... @abstractmethod @@ -428,10 +421,12 @@ class Match(Generic[AnyStr]): *groups: str) -> Sequence[AnyStr]: ... def groups(self, default: AnyStr = ...) -> Sequence[AnyStr]: ... - def groupdict(self, default: AnyStr = ...) -> Dict[str, AnyStr]: ... + def groupdict(self, default: AnyStr = ...) -> dict[str, AnyStr]: ... def start(self, group: Union[int, str] = ...) -> int: ... def end(self, group: Union[int, str] = ...) -> int: ... def span(self, group: Union[int, str] = ...) -> Tuple[int, int]: ... + if sys.version_info >= (3, 6): + def __getitem__(self, g: Union[int, str]) -> AnyStr: ... class Pattern(Generic[AnyStr]): flags = 0 @@ -446,9 +441,9 @@ class Pattern(Generic[AnyStr]): # New in Python 3.4 def fullmatch(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Optional[Match[AnyStr]]: ... - def split(self, string: AnyStr, maxsplit: int = ...) -> List[AnyStr]: ... + def split(self, string: AnyStr, maxsplit: int = ...) -> list[AnyStr]: ... def findall(self, string: AnyStr, pos: int = ..., - endpos: int = ...) -> List[Any]: ... + endpos: int = ...) -> list[Any]: ... def finditer(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Iterator[Match[AnyStr]]: ... @@ -468,7 +463,7 @@ class Pattern(Generic[AnyStr]): # Functions -def get_type_hints(obj: Callable) -> Dict[str, Any]: ... +def get_type_hints(obj: Callable) -> dict[str, Any]: ... def cast(tp: Type[_T], obj: Any) -> _T: ... diff --git a/python/helpers/typeshed/stdlib/3/urllib/parse.pyi b/python/helpers/typeshed/stdlib/3/urllib/parse.pyi index d427e40229ce..25aec929d320 100644 --- a/python/helpers/typeshed/stdlib/3/urllib/parse.pyi +++ b/python/helpers/typeshed/stdlib/3/urllib/parse.pyi @@ -1,5 +1,6 @@ # Stubs for urllib.parse -from typing import Any, List, Dict, Tuple, AnyStr, Generic, overload, Sequence, Mapping, Union, NamedTuple +from typing import Any, List, Dict, Tuple, AnyStr, Generic, overload, Sequence, Mapping, Union, NamedTuple, Callable +import sys __all__ = ( 'urlparse', @@ -123,11 +124,19 @@ def urldefrag(url: str) -> DefragResult: ... @overload def urldefrag(url: bytes) -> DefragResultBytes: ... -def urlencode(query: Union[Mapping[Any, Any], - Mapping[Any, Sequence[Any]], - Sequence[Tuple[Any, Any]], - Sequence[Tuple[Any, Sequence[Any]]]], - doseq: bool = ..., safe: AnyStr = ..., encoding: str = ..., errors: str = ...) -> str: ... +if sys.version_info >= (3, 5): + def urlencode(query: Union[Mapping[Any, Any], + Mapping[Any, Sequence[Any]], + Sequence[Tuple[Any, Any]], + Sequence[Tuple[Any, Sequence[Any]]]], + doseq: bool = ..., safe: AnyStr = ..., encoding: str = ..., errors: str = ..., + quote_via: Callable[[str, AnyStr, str, str], str] = ...) -> str: ... +else: + def urlencode(query: Union[Mapping[Any, Any], + Mapping[Any, Sequence[Any]], + Sequence[Tuple[Any, Any]], + Sequence[Tuple[Any, Sequence[Any]]]], + doseq: bool = ..., safe: AnyStr = ..., encoding: str = ..., errors: str = ...) -> str: ... def urljoin(base: AnyStr, url: AnyStr, allow_fragments: bool = ...) -> AnyStr: ... diff --git a/python/helpers/typeshed/stdlib/3/urllib/request.pyi b/python/helpers/typeshed/stdlib/3/urllib/request.pyi index b8d21903b9cd..0d8c2763b44e 100644 --- a/python/helpers/typeshed/stdlib/3/urllib/request.pyi +++ b/python/helpers/typeshed/stdlib/3/urllib/request.pyi @@ -30,6 +30,7 @@ def url2pathname(path: str) -> str: ... def pathname2url(path: str) -> str: ... def getproxies() -> Dict[str, str]: ... def parse_http_list(s: str) -> List[str]: ... +def parse_keqv_list(l: List[str]) -> Dict[str, str]: ... class Request: if sys.version_info >= (3, 4): diff --git a/python/helpers/typeshed/stdlib/3/xml/etree/ElementInclude.pyi b/python/helpers/typeshed/stdlib/3/xml/etree/ElementInclude.pyi deleted file mode 100644 index ef1a5916ea96..000000000000 --- a/python/helpers/typeshed/stdlib/3/xml/etree/ElementInclude.pyi +++ /dev/null @@ -1,19 +0,0 @@ -# Stubs for xml.etree.ElementInclude (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Union, Optional, Callable -from .ElementTree import _ElementInterface - -XINCLUDE = ... # type: str -XINCLUDE_INCLUDE = ... # type: str -XINCLUDE_FALLBACK = ... # type: str - -class FatalIncludeError(SyntaxError): ... - -def default_loader(href: Union[str, bytes, int], parse: str, encoding: Optional[str]=...) -> Union[str, _ElementInterface]: ... - -# TODO: loader is of type default_loader ie it takes a callable that has the -# same signature as default_loader. But default_loader has a keyword argument -# Which can't be represented using Callable... -def include(elem: _ElementInterface, loader: Callable[..., Union[str, _ElementInterface]]=...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/xml/etree/ElementPath.pyi b/python/helpers/typeshed/stdlib/3/xml/etree/ElementPath.pyi deleted file mode 100644 index db0aa36edc5d..000000000000 --- a/python/helpers/typeshed/stdlib/3/xml/etree/ElementPath.pyi +++ /dev/null @@ -1,25 +0,0 @@ -# Stubs for xml.etree.ElementPath (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Tuple, List, Union, TypeVar, Callable, Optional -from .ElementTree import _ElementInterface - -xpath_tokenizer_re = ... # type: Callable[..., List[Tuple[str, str]]] - - -class xpath_descendant_or_self: ... - -_T = TypeVar('_T') - -class Path: - def __init__(self, path: str) -> None: ... - def find(self, element: _ElementInterface) -> Optional[_ElementInterface]: ... - def findtext(self, element: _ElementInterface, default: _T=...) -> Union[str, _T]: ... - def findall(self, element: _ElementInterface) -> List[_ElementInterface]: ... - -def find(element: _ElementInterface, path: str) -> Optional[_ElementInterface]: ... - -def findtext(element: _ElementInterface, path: str, default: _T=...) -> Union[str, _T]: ... - -def findall(element: _ElementInterface, path: str) -> List[_ElementInterface]: ... diff --git a/python/helpers/typeshed/stdlib/3/xml/etree/ElementTree.pyi b/python/helpers/typeshed/stdlib/3/xml/etree/ElementTree.pyi deleted file mode 100644 index 6f268189465d..000000000000 --- a/python/helpers/typeshed/stdlib/3/xml/etree/ElementTree.pyi +++ /dev/null @@ -1,98 +0,0 @@ -# Stubs for xml.etree.ElementTree (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any, AnyStr, Union, IO, Callable, Dict, List, Tuple, Sequence, Iterator, TypeVar, Optional, KeysView, ItemsView, Generator -import io - -VERSION = ... # type: str - -_Ss = TypeVar('_Ss', str, bytes) -_T = TypeVar('_T') -_str_or_bytes = Union[str, bytes] - -class _ElementInterface(Sequence['_ElementInterface']): - tag = ... # type: _str_or_bytes - attrib = ... # type: Dict[_str_or_bytes, _str_or_bytes] - text = ... # type: Optional[_str_or_bytes] - tail = ... # type: Optional[_str_or_bytes] - def __init__(self, tag: Union[AnyStr, Callable[..., '_ElementInterface']], attrib: Dict[AnyStr, AnyStr]) -> None: ... - def makeelement(self, tag: _Ss, attrib: Dict[_Ss, _Ss]) -> '_ElementInterface': ... - def __len__(self) -> int: ... - def __getitem__(self, index: int) -> '_ElementInterface': ... - def __setitem__(self, index: int, element: '_ElementInterface') -> None: ... - def __delitem__(self, index: int) -> None: ... - def __getslice__(self, start: int, stop: int) -> Sequence['_ElementInterface']: ... - def __setslice__(self, start: int, stop: int, elements: Sequence['_ElementInterface']) -> None: ... - def __delslice__(self, start: int, stop: int) -> None: ... - def append(self, element: '_ElementInterface') -> None: ... - def insert(self, index: int, element: '_ElementInterface') -> None: ... - def remove(self, element: '_ElementInterface') -> None: ... - def getchildren(self) -> List['_ElementInterface']: ... - def find(self, path: str) -> Optional['_ElementInterface']: ... - def findtext(self, path: str, default: _T=...) -> Union[str, _T]: ... - def findall(self, path: str) -> List['_ElementInterface']: ... - def clear(self) -> None: ... - def get(self, key: AnyStr, default: _T=...) -> Union[AnyStr, _T]: ... - def set(self, key: AnyStr, value: AnyStr) -> None: ... - def keys(self) -> KeysView[AnyStr]: ... - def items(self) -> ItemsView[AnyStr, AnyStr]: ... - def getiterator(self, tag: Union[str, AnyStr]=...) -> List['_ElementInterface']: ... - -def Element(tag: Union[AnyStr, Callable[..., _ElementInterface]], attrib: Dict[AnyStr, AnyStr]=..., **extra: AnyStr) -> _ElementInterface: ... -def SubElement(parent: _ElementInterface, tag: AnyStr, attrib: Dict[AnyStr, AnyStr]=..., **extra: AnyStr) -> _ElementInterface: ... -def Comment(text: _str_or_bytes=...) -> _ElementInterface: ... -def ProcessingInstruction(target: str, text: str=...) -> _ElementInterface: ... - -PI = ... # type: Callable[..., _ElementInterface] - -class QName: - text = ... # type: str - def __init__(self, text_or_uri: str, tag: str=...) -> None: ... - - -_file_or_filename = Union[str, bytes, int, IO[Any]] - -class ElementTree: - def __init__(self, element: _ElementInterface=..., file: _file_or_filename=...) -> None: ... - def getroot(self) -> _ElementInterface: ... - def parse(self, source: _file_or_filename, parser: 'XMLTreeBuilder'=...) -> _ElementInterface: ... - def getiterator(self, tag: Union[str, AnyStr]=...) -> List[_ElementInterface]: ... - def find(self, path: str) -> Optional[_ElementInterface]: ... - def findtext(self, path: str, default: _T=...) -> Union[_T, str]: ... - def findall(self, path: str) -> List[_ElementInterface]: ... - def write(self, file_or_filename: _file_or_filename, encoding: str=...) -> None: ... - -def iselement(element: _ElementInterface) -> bool: ... -def dump(elem: _ElementInterface) -> None: ... -def fixtag(tag: Union[str, QName], namespaces: Dict[str, str]) -> Tuple[str, Optional[str]]: ... -def parse(source: _file_or_filename, parser: 'XMLTreeBuilder'=...) -> ElementTree: ... - - -class iterparse: - def __init__(self, source: _file_or_filename, events: Sequence[str]=...) -> None: ... - # TODO-figure out this type... - def __next__(self) -> Tuple[str, _ElementInterface]: ... - -def XML(text: AnyStr) -> _ElementInterface: ... -def XMLID(text: AnyStr) -> Tuple[_ElementInterface, Dict[str, _ElementInterface]]: ... - -# TODO-improve this type -fromstring = ... # type: Callable[..., _ElementInterface] - -def tostring(element: _ElementInterface, encoding: str=...) -> AnyStr: ... - -class TreeBuilder: - def __init__(self, element_factory: Callable[[AnyStr, Dict[AnyStr, AnyStr]], _ElementInterface]=...) -> None: ... - def close(self) -> _ElementInterface: ... - def data(self, data: AnyStr) -> None: ... - def start(self, tag: AnyStr, attrs: Dict[AnyStr, AnyStr]) -> _ElementInterface: ... - def end(self, tag: AnyStr) -> _ElementInterface: ... - -class XMLTreeBuilder: - # TODO-what is entity used for??? - entity = ... # type: Any - def __init__(self, html: int=..., target: TreeBuilder=...) -> None: ... - def doctype(self, name: str, pubid: str, system: str) -> None: ... - def close(self) -> Any: ... # TODO-most of the time, this will be Element, but it can be anything target.close() returns - def feed(self, data: AnyStr)-> None: ... diff --git a/python/helpers/typeshed/stdlib/3/xml/etree/__init__.pyi b/python/helpers/typeshed/stdlib/3/xml/etree/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/python/helpers/typeshed/stdlib/3/xml/etree/cElementTree.pyi b/python/helpers/typeshed/stdlib/3/xml/etree/cElementTree.pyi deleted file mode 100644 index 8f689de4b1aa..000000000000 --- a/python/helpers/typeshed/stdlib/3/xml/etree/cElementTree.pyi +++ /dev/null @@ -1,5 +0,0 @@ -# Stubs for xml.etree.cElementTree (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from xml.etree.ElementTree import * # noqa: F403 diff --git a/python/helpers/typeshed/third_party/2/concurrent/futures/__init__.pyi b/python/helpers/typeshed/third_party/2/concurrent/futures/__init__.pyi index 8e915ae276a0..492ee1bfa906 100644 --- a/python/helpers/typeshed/third_party/2/concurrent/futures/__init__.pyi +++ b/python/helpers/typeshed/third_party/2/concurrent/futures/__init__.pyi @@ -8,12 +8,12 @@ class Future(Generic[_T]): def running(self) -> bool: ... def done(self) -> bool: ... def result(self, timeout: float = ...) -> _T: ... - def exception(self, timeout: float = ...) -> Exception: ... + def exception(self, timeout: float = ...) -> BaseException: ... def add_done_callback(self, fn: Callable[[Future], Any]) -> None: ... def set_running_or_notify_cancel(self) -> None: ... def set_result(self, result: _T) -> None: ... - def set_exception(self, exception: Exception) -> None: ... + def set_exception(self, exception: BaseException) -> None: ... class Executor: def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ... diff --git a/python/helpers/typeshed/third_party/2/dateutil/relativedelta.pyi b/python/helpers/typeshed/third_party/2/dateutil/relativedelta.pyi index 3a99eaf40fef..f910e9005b4a 100644 --- a/python/helpers/typeshed/third_party/2/dateutil/relativedelta.pyi +++ b/python/helpers/typeshed/third_party/2/dateutil/relativedelta.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Union +from typing import Any, List, Optional, Union from datetime import date, datetime, timedelta __all__ = ... # type: List[str] diff --git a/python/helpers/typeshed/third_party/2/dateutil/tz/tz.pyi b/python/helpers/typeshed/third_party/2/dateutil/tz/tz.pyi index ccd38198a227..5027e62eb4ee 100644 --- a/python/helpers/typeshed/third_party/2/dateutil/tz/tz.pyi +++ b/python/helpers/typeshed/third_party/2/dateutil/tz/tz.pyi @@ -2,7 +2,7 @@ # # NOTE: This dynamically typed stub was automatically generated by stubgen. -from typing import Any, Optional, Union, IO, Tuple +from typing import Any, IO, List, Optional, Tuple, Union import datetime from ._common import tzname_in_python2 as tzname_in_python2, _tzinfo as _tzinfo from ._common import tzrangebase as tzrangebase, enfold as enfold diff --git a/python/helpers/typeshed/third_party/2/requests/api.pyi b/python/helpers/typeshed/third_party/2/requests/api.pyi index 9f041d21c31b..fee191eae02c 100644 --- a/python/helpers/typeshed/third_party/2/requests/api.pyi +++ b/python/helpers/typeshed/third_party/2/requests/api.pyi @@ -4,18 +4,18 @@ from typing import Union, Optional, Iterable, Mapping, Tuple from .models import Response -ParamsMappingValueType = Union[str, unicode, int, float, Iterable[Union[str, unicode, int, float]]] +_ParamsMappingValueType = Union[str, unicode, int, float, Iterable[Union[str, unicode, int, float]]] def request(method: str, url: str, **kwargs) -> Response: ... def get(url: Union[str, unicode], params: Optional[ - Union[Mapping[Union[str, unicode, int, float], ParamsMappingValueType], + Union[Mapping[Union[str, unicode, int, float], _ParamsMappingValueType], Union[str, unicode], - Tuple[Union[str, unicode, int, float], ParamsMappingValueType], - Mapping[str, ParamsMappingValueType], - Mapping[unicode, ParamsMappingValueType], - Mapping[int, ParamsMappingValueType], - Mapping[float, ParamsMappingValueType]]] = None, + Tuple[Union[str, unicode, int, float], _ParamsMappingValueType], + Mapping[str, _ParamsMappingValueType], + Mapping[unicode, _ParamsMappingValueType], + Mapping[int, _ParamsMappingValueType], + Mapping[float, _ParamsMappingValueType]]] = None, **kwargs) -> Response: ... def options(url: Union[str, unicode], **kwargs) -> Response: ... def head(url: Union[str, unicode], **kwargs) -> Response: ... diff --git a/python/helpers/typeshed/third_party/2/six/__init__.pyi b/python/helpers/typeshed/third_party/2/six/__init__.pyi index 302c45886043..c4c4723f868b 100644 --- a/python/helpers/typeshed/third_party/2/six/__init__.pyi +++ b/python/helpers/typeshed/third_party/2/six/__init__.pyi @@ -27,7 +27,7 @@ PY2 = True PY3 = False PY34 = False -string_types = basestring, +string_types = (str, unicode) integer_types = (int, long) class_types = (type, types.ClassType) text_type = unicode diff --git a/python/helpers/typeshed/third_party/2and3/boto/s3/bucket.pyi b/python/helpers/typeshed/third_party/2and3/boto/s3/bucket.pyi index 3b6efb6f8437..beb1d27cd17d 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/s3/bucket.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/s3/bucket.pyi @@ -6,7 +6,7 @@ from .bucketlistresultset import BucketListResultSet from .connection import S3Connection from .key import Key -from typing import Any, Dict, Optional, Text, Type +from typing import Any, Dict, Optional, Text, Type, List class S3WebsiteEndpointTranslate: trans_region = ... # type: Dict[str, str] diff --git a/python/helpers/typeshed/third_party/2and3/pytz/__init__.pyi b/python/helpers/typeshed/third_party/2and3/pytz/__init__.pyi index 6bc917e5e573..2c2accd67559 100644 --- a/python/helpers/typeshed/third_party/2and3/pytz/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/pytz/__init__.pyi @@ -1,7 +1,7 @@ # Stubs for pytz (Python 3.5) -import datetime as dt -from typing import Optional, List, Set, Dict # NOQA +import datetime +from typing import Optional, List, Set, Dict, Union all_timezones = ... # type: List all_timezones_set = ... # type: Set @@ -11,16 +11,29 @@ country_timezones = ... # type: Dict country_names = ... # type: Dict -class _UTCclass(dt.tzinfo): +class _UTCclass(datetime.tzinfo): zone = ... # type: str - def fromutc(self, dt: dt.datetime) -> dt.datetime: ... - def utcoffset(self, dt: Optional[dt.datetime]) -> dt.timedelta: ... # type: ignore - def tzname(self, dt: Optional[dt.datetime]) -> str: ... - def dst(self, dt: Optional[dt.datetime]) -> dt.timedelta: ... # type: ignore - def localize(self, dt: dt.datetime, is_dst: bool=...) -> dt.datetime: ... - def normalize(self, dt: dt.datetime, is_dst: bool=...) -> dt.datetime: ... + def fromutc(self, dt: datetime.datetime) -> datetime.datetime: ... + def utcoffset(self, dt: Optional[datetime.datetime]) -> datetime.timedelta: ... # type: ignore + def tzname(self, dt: Optional[datetime.datetime]) -> str: ... + def dst(self, dt: Optional[datetime.datetime]) -> datetime.timedelta: ... # type: ignore + def localize(self, dt: datetime.datetime, is_dst: bool = ...) -> datetime.datetime: ... + def normalize(self, dt: datetime.datetime, is_dst: bool = ...) -> datetime.datetime: ... utc = ... # type: _UTCclass UTC = ... # type: _UTCclass -def timezone(zone: str) -> dt.tzinfo: ... + +class _BaseTzInfo(datetime.tzinfo): + zone = ... # type: str + + def fromutc(self, dt: datetime.datetime) -> datetime.datetime: ... + def localize(self, dt: datetime.datetime, is_dst: Optional[bool] = ...) -> datetime.datetime: ... + def normalize(self, dt: datetime.datetime) -> datetime.datetime: ... + + +class _StaticTzInfo(_BaseTzInfo): + def normalize(self, dt: datetime.datetime, is_dst: Optional[bool] = ...) -> datetime.datetime: ... + + +def timezone(zone: str) -> _BaseTzInfo: ... diff --git a/python/helpers/typeshed/third_party/2and3/sqlalchemy/sql/schema.pyi b/python/helpers/typeshed/third_party/2and3/sqlalchemy/sql/schema.pyi index b2b3e4cb620a..a0f4b576db9a 100644 --- a/python/helpers/typeshed/third_party/2and3/sqlalchemy/sql/schema.pyi +++ b/python/helpers/typeshed/third_party/2and3/sqlalchemy/sql/schema.pyi @@ -1,4 +1,4 @@ -from typing import Any, AnyStr +from typing import Any, AnyStr, Set from .base import SchemaEventTarget, DialectKWArgs from .base import ColumnCollection diff --git a/python/helpers/typeshed/third_party/3/dateutil/parser.pyi b/python/helpers/typeshed/third_party/3/dateutil/parser.pyi index 32df99654e67..1597acdf96b2 100644 --- a/python/helpers/typeshed/third_party/3/dateutil/parser.pyi +++ b/python/helpers/typeshed/third_party/3/dateutil/parser.pyi @@ -1,4 +1,4 @@ -from typing import List, Tuple, Optional, Callable, Union, IO, Any +from typing import List, Tuple, Optional, Callable, Union, IO, Any, Dict from datetime import datetime __all__ = ... # type: List[str] diff --git a/python/helpers/typeshed/third_party/3/dateutil/relativedelta.pyi b/python/helpers/typeshed/third_party/3/dateutil/relativedelta.pyi index 35e6d079d56c..dc7e97bc095d 100644 --- a/python/helpers/typeshed/third_party/3/dateutil/relativedelta.pyi +++ b/python/helpers/typeshed/third_party/3/dateutil/relativedelta.pyi @@ -1,4 +1,4 @@ -from typing import Optional, overload, Union +from typing import Optional, overload, Union, List from datetime import date, datetime, timedelta __all__ = ... # type: List[str] diff --git a/python/helpers/typeshed/third_party/3/dateutil/tz/tz.pyi b/python/helpers/typeshed/third_party/3/dateutil/tz/tz.pyi index 42bf05a89155..3f7879a65437 100644 --- a/python/helpers/typeshed/third_party/3/dateutil/tz/tz.pyi +++ b/python/helpers/typeshed/third_party/3/dateutil/tz/tz.pyi @@ -2,7 +2,7 @@ # # NOTE: This dynamically typed stub was automatically generated by stubgen. -from typing import Any, Optional, Union, IO, Tuple +from typing import Any, Optional, Union, IO, Tuple, List import datetime from ._common import tzname_in_python2 as tzname_in_python2, _tzinfo as _tzinfo from ._common import tzrangebase as tzrangebase, enfold as enfold diff --git a/python/helpers/typeshed/third_party/3/requests/api.pyi b/python/helpers/typeshed/third_party/3/requests/api.pyi index 120f695c43fb..432a82002ec3 100644 --- a/python/helpers/typeshed/third_party/3/requests/api.pyi +++ b/python/helpers/typeshed/third_party/3/requests/api.pyi @@ -4,19 +4,19 @@ from typing import Optional, Union, Any, Iterable, Mapping, Tuple from .models import Response -ParamsMappingValueType = Union[str, bytes, int, float, Iterable[Union[str, bytes, int, float]]] +_ParamsMappingValueType = Union[str, bytes, int, float, Iterable[Union[str, bytes, int, float]]] def request(method: str, url: str, **kwargs) -> Response: ... def get(url: Union[str, bytes], params: Optional[ Union[ - Mapping[Union[str, bytes, int, float], ParamsMappingValueType], + Mapping[Union[str, bytes, int, float], _ParamsMappingValueType], Union[str, bytes], - Tuple[Union[str, bytes, int, float], ParamsMappingValueType], - Mapping[str, ParamsMappingValueType], - Mapping[bytes, ParamsMappingValueType], - Mapping[int, ParamsMappingValueType], - Mapping[float, ParamsMappingValueType]]]=None, + Tuple[Union[str, bytes, int, float], _ParamsMappingValueType], + Mapping[str, _ParamsMappingValueType], + Mapping[bytes, _ParamsMappingValueType], + Mapping[int, _ParamsMappingValueType], + Mapping[float, _ParamsMappingValueType]]]=None, **kwargs) -> Response: ... def options(url: str, **kwargs) -> Response: ... def head(url: str, **kwargs) -> Response: ... diff --git a/python/helpers/typeshed/third_party/3/typed_ast/__init__.pyi b/python/helpers/typeshed/third_party/3/typed_ast/__init__.pyi index 92e1216b1150..f260032dddb6 100644 --- a/python/helpers/typeshed/third_party/3/typed_ast/__init__.pyi +++ b/python/helpers/typeshed/third_party/3/typed_ast/__init__.pyi @@ -1,2 +1,2 @@ -# This module is a fork of the CPython 2.7 and 3.5 ast modules with PEP 484 support. -# See: https://github.com/dropbox/typed_ast +# This module is a fork of the CPython 2 and 3 ast modules with PEP 484 support. +# See: https://github.com/python/typed_ast diff --git a/python/helpers/typeshed/third_party/3/typed_ast/ast35.pyi b/python/helpers/typeshed/third_party/3/typed_ast/ast3.pyi similarity index 93% rename from python/helpers/typeshed/third_party/3/typed_ast/ast35.pyi rename to python/helpers/typeshed/third_party/3/typed_ast/ast3.pyi index 71ac1bae386b..1e96daf0c292 100644 --- a/python/helpers/typeshed/third_party/3/typed_ast/ast35.pyi +++ b/python/helpers/typeshed/third_party/3/typed_ast/ast3.pyi @@ -8,7 +8,10 @@ class NodeVisitor(): class NodeTransformer(NodeVisitor): def generic_visit(self, node: AST) -> None: ... -def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: str = ...) -> AST: ... +def parse(source: Union[str, bytes], + filename: Union[str, bytes] = ..., + mode: str = ..., + feature_version: int = ...) -> AST: ... def copy_location(new_node: AST, old_node: AST) -> AST: ... def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ... def fix_missing_locations(node: AST) -> AST: ... @@ -86,15 +89,20 @@ class Delete(stmt): class Assign(stmt): targets = ... # type: typing.List[expr] - value = ... # type: Optional[expr] + value = ... # type: expr type_comment = ... # type: Optional[str] - annotation = ... # type: Optional[expr] class AugAssign(stmt): target = ... # type: expr op = ... # type: operator value = ... # type: expr +class AnnAssign(stmt): + target = ... # type: expr + annotation = ... # type: expr + value = ... # type: Optional[expr] + simple = ... # type: int + class For(stmt): target = ... # type: expr iter = ... # type: expr @@ -107,6 +115,7 @@ class AsyncFor(stmt): iter = ... # type: expr body = ... # type: typing.List[stmt] orelse = ... # type: typing.List[stmt] + type_comment = ... # type: Optional[str] class While(stmt): test = ... # type: expr @@ -126,6 +135,7 @@ class With(stmt): class AsyncWith(stmt): items = ... # type: typing.List[withitem] body = ... # type: typing.List[stmt] + type_comment = ... # type: Optional[str] class Raise(stmt): exc = ... # type: Optional[expr] @@ -255,6 +265,14 @@ class Num(expr): class Str(expr): s = ... # type: str +class FormattedValue(expr): + value = ... # type: expr + conversion = ... # type: typing.Optional[int] + format_spec = ... # type: typing.Optional[expr] + +class JoinedStr(expr): + values = ... # type: typing.List[expr] + class Bytes(expr): s = ... # type: bytes @@ -351,6 +369,7 @@ class comprehension(AST): target = ... # type: expr iter = ... # type: expr ifs = ... # type: typing.List[expr] + is_async = ... # type: int class ExceptHandler(AST): @@ -374,6 +393,7 @@ class arg(AST): annotation = ... # type: Optional[expr] lineno = ... # type: int col_offset = ... # type: int + type_comment = ... # type: typing.Optional[str] class keyword(AST): arg = ... # type: Optional[identifier] diff --git a/python/helpers/typeshed/third_party/3/typed_ast/conversions.pyi b/python/helpers/typeshed/third_party/3/typed_ast/conversions.pyi index 53fcc3283cd4..d5f18299f02b 100644 --- a/python/helpers/typeshed/third_party/3/typed_ast/conversions.pyi +++ b/python/helpers/typeshed/third_party/3/typed_ast/conversions.pyi @@ -1,4 +1,4 @@ from . import ast27 -from . import ast35 +from . import ast3 -def py2to3(ast: ast27.AST) -> ast35.AST: ... +def py2to3(ast: ast27.AST) -> ast3.AST: ...