diff --git a/python/helpers/typeshed/.flake8 b/python/helpers/typeshed/.flake8 index a011f30b4457..a105e9346ea3 100644 --- a/python/helpers/typeshed/.flake8 +++ b/python/helpers/typeshed/.flake8 @@ -1,21 +1,22 @@ # Some PEP8 deviations are considered irrelevant to stub files: -# (error counts as of 2016-12-19) -# 17381 E704 multiple statements on one line (def) -# 11840 E301 expected 1 blank line -# 7467 E302 expected 2 blank lines -# 1772 E501 line too long -# 1487 F401 imported but unused -# 1248 E701 multiple statements on one line (colon) -# 427 F811 redefinition -# 356 E305 expected 2 blank lines +# (error counts as of 2017-05-22) +# 17952 E704 multiple statements on one line (def) +# 12197 E301 expected 1 blank line +# 7155 E302 expected 2 blank lines +# 2307 E501 line too long +# 1463 F401 imported but unused +# 967 E701 multiple statements on one line (colon) +# 457 F811 redefinition +# 390 E305 expected 2 blank lines # Nice-to-haves ignored for now -# 152 E128 continuation line under-indented for visual indent -# 43 E127 continuation line over-indented for visual indent +# 159 E128 continuation line under-indented for visual indent +# 34 E127 continuation line over-indented for visual indent [flake8] -ignore = F401, F811, E127, E128, E301, E302, E305, E501, E701, E704, B303 +ignore = F401, F403, F405, F811, E127, E128, E301, E302, E305, E501, E701, E704, B303 # We are checking with Python 3 but many of the stubs are Python 2 stubs. # A nice future improvement would be to provide separate .flake8 # configurations for Python 2 and Python 3 files. builtins = StandardError,apply,basestring,buffer,cmp,coerce,execfile,file,intern,long,raw_input,reduce,reload,unichr,unicode,xrange +exclude = .venv*,@* diff --git a/python/helpers/typeshed/.gitignore b/python/helpers/typeshed/.gitignore index 838b2a41ad67..d211927a9b3a 100644 --- a/python/helpers/typeshed/.gitignore +++ b/python/helpers/typeshed/.gitignore @@ -61,3 +61,7 @@ analyze.py .*.sw? .vscode/ .idea/ +.venv*/ + +# Mypy cache +.mypy_cache/ diff --git a/python/helpers/typeshed/.travis.yml b/python/helpers/typeshed/.travis.yml index 369e41967781..1dd1e896e6b4 100644 --- a/python/helpers/typeshed/.travis.yml +++ b/python/helpers/typeshed/.travis.yml @@ -5,13 +5,15 @@ matrix: include: - python: "3.6-dev" env: TEST_CMD="flake8" + - python: "3.6" + env: TEST_CMD="./tests/mypy_selftest.py" - python: "3.5" - env: TEST_CMD="./tests/mypy_test.py" + env: TEST_CMD="./tests/mypy_test.py --no-implicit-optional" - python: "2.7" env: TEST_CMD="./tests/pytype_test.py --num-parallel=4" install: - # pytype needs py-2.7, mypy needs py-3.2+. Additional logic in runtests.py + # pytype needs py-2.7, mypy needs py-3.3+. Additional logic in runtests.py - if [[ $TRAVIS_PYTHON_VERSION == '3.6-dev' ]]; then pip install -U flake8==3.3.0 flake8-bugbear>=17.3.0 flake8-pyi>=17.1.0; fi - if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then pip install -U git+git://github.com/python/mypy git+git://github.com/python/typed_ast; fi - if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then pip install -U git+git://github.com/google/pytype; fi diff --git a/python/helpers/typeshed/CONTRIBUTING.md b/python/helpers/typeshed/CONTRIBUTING.md index e2f39a41efc2..1337d588e44c 100644 --- a/python/helpers/typeshed/CONTRIBUTING.md +++ b/python/helpers/typeshed/CONTRIBUTING.md @@ -9,12 +9,12 @@ are important to the project's success. ## The contribution process at a glance 1. Read the [README.md file](README.md). -2. Set up your environment to be able to run all tests with `runtests.sh`. They should pass. +2. Set up your environment to be able to [run all tests](README.md#running-the-tests). They should pass. 3. [Prepare your changes](#preparing-changes): * [Contact us](#discussion) before starting significant work. * IMPORTANT: For new libraries, [get permission from the library owner first](#adding-a-new-library). * Create your stubs [conforming to the coding style](#stub-file-coding-style). - * Make sure `runtests.sh` passes cleanly on Mypy, pytype, and flake8. + * Make sure your tests pass cleanly on `mypy`, `pytype`, and `flake8`. 4. [Submit your changes](#submitting-changes): * Open a pull request * For new libraries, [include a reference to where you got permission](#adding-a-new-library) @@ -37,8 +37,8 @@ tracker](https://github.com/python/typeshed/issues). This is the right place to start a discussion of any of the above or most any other topic concerning the project. -For less formal discussion, try the Mypy chat room on -[gitter.im](https://gitter.im/python/mypy). Some Mypy core developers +For less formal discussion, try the typing chat room on +[gitter.im](https://gitter.im/python/typing). Some Mypy core developers are almost always present; feel free to find us there and we're happy to chat. Substantive technical discussion will be directed to the issue tracker. @@ -69,6 +69,12 @@ For every pull request, we aim to promptly either merge it or say why it's not yet ready; if you go a few days without a reply, please feel free to ping the thread by adding a new comment. +To get your pull request merged sooner, you should explain why you are +making the change. For example, you can point to a code sample that is +processed incorrectly by a type checker. It is also helpful to add +links to online documentation or to the implementation of the code +you are changing. + At present the core developers are (alphabetically): * David Fisher (@ddfisher) * Ɓukasz Langa (@ambv) @@ -103,8 +109,8 @@ should prefer to external type stubs). When the project owners agree for you to submit stubs here, open a pull request **referencing the message where you received permission**. -Make sure your changes pass tests by running ``runtests.sh`` (the -[README](README.md) has more information). +Make sure your changes pass the tests (the [README](README.md#running-the-tests) +has more information). ### Using stubgen @@ -135,12 +141,8 @@ rule is that they should be as concise as possible. Specifically: names, or methods and fields within a single class; * use a single blank line between top-level class definitions, or none if the classes are very small; -* add a top-level comment followed by an empty line that makes it clear - the file contains a stub and not the actual code for the module, - for example `# Stubs for pathlib (Python 3.4)`; * do not use docstrings; -* prefer type comments over variable annotations unless your stubs are - exclusively targeting Python 3.6. +* for arguments with a type and a default, use spaces around the `=`. Imports in stubs are considered private (not part of the exported API) unless: @@ -149,6 +151,14 @@ unless: * they use the form ``from library import *`` which means all names from that library are exported. +For arguments with type and a default value of `None`, PEP 484 +prescribes that the type automatically becomes `Optional`. However we +prefer explicit over implicit in this case, and require the explicit +`Optional[]` around the type. The mypy tests enforce this (through +the use of --no-implicit-optional) and the error looks like +`Incompatible types in assignment (expression has type None, variable +has type "Blah") `. + Stub files support forward references natively. In other words, the order of class declarations and type aliases does not matter in a stub file. You can also use the name of the class within its own @@ -159,11 +169,6 @@ Type variables and aliases you introduce purely for legibility reasons should be prefixed with an underscore to make it obvious to the reader they are not part of the stubbed API. -Finally, remember to include a comment on the top of your file about the -version of the Python language your stubs were tested against and -version of the library they were built for. This makes it easier to -maintain the stubs in the future. - NOTE: there are stubs in this repository that don't conform to the style described above. Fixing them is a great starting point for new contributors. @@ -172,9 +177,23 @@ contributors. There are separate directories for `stdlib` and `third_party` stubs. Within those, there are separate directories for different versions of -Python the stubs target. If the given library works on both Python 2 -and Python 3, prefer to put your stubs in an `2and3` directory, unless -the types are so different that the stubs become unreadable that way. +Python the stubs target. + +The directory name indicates the major version of Python that a stub targets +and optionally the lowest minor version, with the exception of the `2and3` +directory which applies to both Python 2 and 3. + +For example, stubs in the `3` directory will be applied to all versions of +Python 3, though stubs in the `3.6` directory will only be applied to versions +3.6 and above. However, stubs in the `2` directory will not be applied to +Python 3. + +It is preferred to use a single stub in the more generic directory that +conditionally targets specific versions when needed, as opposed +to maintaining multiple stub files within more specific directories. Similarly, +if the given library works on both Python 2 and Python 3, prefer to put your +stubs in the `2and3` directory, unless the types are so different that the stubs +become unreadable that way. You can use checks like `if sys.version_info >= (3, 4):` to denote new functionality introduced in a given Python version or solve type @@ -217,23 +236,25 @@ project's tracker to fix their documentation. ## Issue-tracker conventions -We aim to reply to all new issues promptly. We'll assign a milestone -to help us track which issues we intend to get to when, and may apply -labels to carry some other information. Here's what our milestones -and labels mean. +We aim to reply to all new issues promptly. We'll assign one or more +labels to to indicate we've triaged an issue, but most typeshed issues +are relatively simple (stubs for a given module or package are +missing, incomplete or incorrect) and we won't add noise to the +tracker by labeling all of them. Here's what our labels mean. (We +also apply these to pull requests.) -### Labels - -* **needs discussion**: This issue needs agreement on some kind of - design before it makes sense to implement it, and it either doesn't - yet have a design or doesn't yet have agreement on one. -* **help wanted**: This issue could use a volunteer willing to implement - it. Those issues can be great starting points for new contributors! -* **enhancement**, **bug**, **refactoring**: These classify the - user-facing impact of the change. Specifically "refactoring" means - there should be no user-facing effect. -* **duplicate**, **wontfix**: These identify issues that we've closed - for the respective reasons. +* **blocked**: This issue is waiting for the resolution of some issue + external to typeshed. +* **bug**: It's a bug in a stub. +* **bytes-unicode**: It's related to bytes vs. unicode, usually Python 2. +* **feature**: It's a new typeshed feature. +* **priority-high**: This issue is more important than most. +* **priority-low**: This issue is less important than most. +* **priority-normal**: This issue has average priority. +* **question**: Not really an issue, but a question on how to do something. +* **size-large**: An issue of high complexity or affecting many files. +* **size-medium**: An issue of average complexity. +* **size-small**: An issue that will take only little effort to fix. ### Core developer guidelines @@ -242,3 +263,5 @@ Core developers should follow these rules when processing pull requests: * Always wait for tests to pass before merging PRs. * Use "[Squash and merge](https://github.com/blog/2141-squash-your-commits)" to merge PRs. * Delete branches for merged PRs (by core devs pushing to the main repo). +* Make sure commit messages to master are meaningful. For example, remove irrelevant + intermediate commit messages. diff --git a/python/helpers/typeshed/README.md b/python/helpers/typeshed/README.md index 5aadf1edbfd6..56f44953a7f2 100644 --- a/python/helpers/typeshed/README.md +++ b/python/helpers/typeshed/README.md @@ -1,5 +1,8 @@ # typeshed +[![Build Status](https://travis-ci.org/python/typeshed.svg?branch=master)](https://travis-ci.org/python/typeshed) +[![Chat at https://gitter.im/python/typing](https://badges.gitter.im/python/typing.svg)](https://gitter.im/python/typing?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + ## About Typeshed contains external type annotations for the Python standard library @@ -11,6 +14,34 @@ For information on how to use `typeshed`, read below. Information for contributors can be found in [CONTRIBUTING.md](CONTRIBUTING.md). **Please read it before submitting pull requests.** +Typeshed supports Python versions 2.7 and 3.3 and up. + +## Using + +If you're just using mypy (or pytype or PyCharm), as opposed to +developing it, you don't need to interact with the typeshed repo at +all: a copy of typeshed is bundled with mypy. + +When you use a checked-out clone of the mypy repo, a copy of typeshed +should be included as a submodule, using + + $ git clone --recurse-submodules https://github.com/python/mypy.git + +or + + $ git clone https://github.com/python/mypy.git + $ cd mypy + $ git submodule init + $ git submodule update + +and occasionally you will have to repeat the final command (`git +submodule update`) to pull in changes made in the upstream typeshed +repo. + +PyCharm and pytype similarly include a copy of typeshed. The one in +pytype can be updated in the same way if you are working with the +pytype repo. + ## Format Each Python module is represented by a `.pyi` "stub". This is a normal Python @@ -26,13 +57,15 @@ of the stub files. The below is an excerpt from the types for the `datetime` module. ```python +from typing import Union + MAXYEAR = ... # type: int MINYEAR = ... # type: int class date(object): def __init__(self, year: int, month: int, day: int) -> None: ... @classmethod - def fromtimestamp(cls, timestamp: int or float) -> date: ... + def fromtimestamp(cls, timestamp: Union[int, float]) -> date: ... @classmethod def fromordinal(cls, ordinal: int) -> date: ... @classmethod @@ -41,6 +74,24 @@ class date(object): def weekday(self) -> int: ... ``` +## Conventions + +* At the time of this writing, `unicode` arguments, in Python 2 stubs, are + interpreted by type-checkers as `Union[bytes, unicode]` (so it means the same + as `Text`). + Even so, in Python 2, whenever possible, use `unicode` if that's the only + possible type, and `Text` if it can be either `unicode` or `bytes`. +* Most type-checkers interpret optional parameters of the form `x : Foo = None` + as `x : Optional[Foo] = ...`. (So the former is a shortcut for the latter) + In typeshed, however, we prefer the explicit latter form. +* When something is declared as taking only float, it also takes `int`. See + https://www.python.org/dev/peps/pep-0484/#the-numeric-tower. So write `float` + instead of `Union[int, float]`. +* Avoid Union return types: https://github.com/python/mypy/issues/1693 +* Avoid invariant collection types (List, Dict) in argument positions, in favor + of covariant types like Mapping or Sequence. + + ## Directory structure ### stdlib @@ -71,16 +122,15 @@ https://github.com/python/typeshed/blob/master/CONTRIBUTING.md#stub-versioning). ## Contributing Please read [CONTRIBUTING.md](CONTRIBUTING.md) before submitting pull -requests. +requests. If you have questions related to contributing, drop by the [typing Gitter](https://gitter.im/python/typing). ## Running the tests The tests are automatically run by Travis CI on every PR and push to -the repo. There are two separate sets of tests: `tests/mypy_test.py` +the repo. There are several sets of tests: `tests/mypy_test.py` runs tests against [mypy](https://github.com/python/mypy/), while -`tests/pytype_tests.py` runs tests against -[pytype](https://github.com/google/pytype/). The script runtests.sh -runs both sets of tests and flake8 over all .pyi files. +`tests/pytype_test.py` runs tests against +[pytype](https://github.com/google/pytype/). Both sets of tests are shallow -- they verify that all stubs can be imported but they don't check whether stubs match their implementation @@ -88,21 +138,33 @@ imported but they don't check whether stubs match their implementation that each set of tests has a blacklist of modules that are not tested at all. The blacklists also live in the tests directory. -To manually run the mypy tests, you need to have Python 3.5 or higher. +In addition, you can run `tests/mypy_selftest.py` to run mypy's own +test suite using the typeshed code in your repo. This will sometimes +catch issues with incorrectly typed stubs, but is much slower than the +other tests. + +To manually run the mypy tests, you need to have Python 3.5 or higher; +Python 3.6.1 or higher is recommended. + Run: ``` -$ python3.5 -m venv .venv3 +$ python3.6 -m venv .venv3 $ source .venv3/bin/activate -(.venv3)$ pip install -r requirements-tests-py3.txt +(.venv3)$ pip3 install -r requirements-tests-py3.txt ``` -This will install mypy-lang, typed-ast, and flake8. You can then run -mypy tests and flake8 tests by invoking: +This will install mypy (you need the latest master branch from GitHub), +typed-ast, and flake8. You can then run mypy tests and flake8 tests by +invoking: ``` -(.venv3)$ python tests/mypy_test.py +(.venv3)$ python3 tests/mypy_test.py +... +(.venv3)$ python3 tests/mypy_selftest.py ... (.venv3)$ flake8 ... ``` +(Note that flake8 only works with Python 3.6 or higher.) + To run the pytype tests, you need a separate virtual environment with Python 2.7. Run: ``` @@ -116,25 +178,6 @@ tests by running: (.venv2)$ python tests/pytype_test.py ``` -To be able to everything with ``runtests.sh``, copy the ``pytype`` script -from the Python 2 virtualenv to the Python 3 one: -``` -$ cp .venv2/bin/pytype .venv3/bin/pytype -$ source .venv3/bin/activate -(.venv3)$ ./runtests.sh -running mypy --python-version 3.6 --strict-optional # with 479 files -running mypy --python-version 3.5 --strict-optional # with 469 files -running mypy --python-version 3.4 --strict-optional # with 469 files -running mypy --python-version 3.3 --strict-optional # with 454 files -running mypy --python-version 3.2 --strict-optional # with 453 files -running mypy --python-version 2.7 --strict-optional # with 502 files -Running pytype tests... -Ran pytype with 244 pyis, got 0 errors. -Running flake8... -flake8 run clean. -(.venv3)$ -``` - For mypy, if you are in the typeshed repo that is submodule of the mypy repo (so `..` refers to the mypy repo), there's a shortcut to run the mypy tests that avoids installing mypy: diff --git a/python/helpers/typeshed/requirements-tests-py3.txt b/python/helpers/typeshed/requirements-tests-py3.txt index 7454792694a5..84a9fd655bd5 100644 --- a/python/helpers/typeshed/requirements-tests-py3.txt +++ b/python/helpers/typeshed/requirements-tests-py3.txt @@ -1,5 +1,5 @@ -mypy>=0.501 -typed-ast>=1.0.2 +git+https://github.com/python/mypy.git@master +typed-ast>=1.0.4 flake8==3.3.0 flake8-bugbear>=17.3.0 flake8-pyi>=17.1.0 diff --git a/python/helpers/typeshed/stdlib/2/ConfigParser.pyi b/python/helpers/typeshed/stdlib/2/ConfigParser.pyi index 5191e99767b6..b1cd51785f90 100644 --- a/python/helpers/typeshed/stdlib/2/ConfigParser.pyi +++ b/python/helpers/typeshed/stdlib/2/ConfigParser.pyi @@ -78,10 +78,10 @@ class RawConfigParser: def optionxform(self, optionstr: str) -> str: ... def has_option(self, section: str, option: str) -> bool: ... def set(self, section: str, option: str, value: Any = ...) -> None: ... - def write(self, fp: file) -> None: ... + def write(self, fp: IO[str]) -> None: ... def remove_option(self, section: str, option: Any) -> bool: ... def remove_section(self, section: str) -> bool: ... - def _read(self, fp: file, fpname: str) -> None: ... + def _read(self, fp: IO[str], fpname: str) -> None: ... class ConfigParser(RawConfigParser): _KEYCRE = ... # type: Any diff --git a/python/helpers/typeshed/stdlib/2/Cookie.pyi b/python/helpers/typeshed/stdlib/2/Cookie.pyi index 2df4eb037dad..a4e634404050 100644 --- a/python/helpers/typeshed/stdlib/2/Cookie.pyi +++ b/python/helpers/typeshed/stdlib/2/Cookie.pyi @@ -1,7 +1,3 @@ -# Stubs for Cookie (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class CookieError(Exception): ... diff --git a/python/helpers/typeshed/stdlib/2/SimpleHTTPServer.pyi b/python/helpers/typeshed/stdlib/2/SimpleHTTPServer.pyi new file mode 100644 index 000000000000..5bfed2a5f631 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/SimpleHTTPServer.pyi @@ -0,0 +1,16 @@ +# Stubs for SimpleHTTPServer (Python 2) + +from typing import Any, AnyStr, IO, Mapping, Optional, Union +import BaseHTTPServer +from StringIO import StringIO + +class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): + server_version = ... # type: str + def do_GET(self) -> None: ... + def do_HEAD(self) -> None: ... + def send_head(self) -> Optional[IO[str]]: ... + def list_directory(self, path: Union[str, unicode]) -> Optional[StringIO]: ... + def translate_path(self, path: AnyStr) -> AnyStr: ... + def copyfile(self, source: IO[AnyStr], outputfile: IO[AnyStr]): ... + def guess_type(self, path: Union[str, unicode]) -> str: ... + extensions_map = ... # type: Mapping[str, str] diff --git a/python/helpers/typeshed/stdlib/2/__builtin__.pyi b/python/helpers/typeshed/stdlib/2/__builtin__.pyi index c006cecac75a..b781292ec2b6 100644 --- a/python/helpers/typeshed/stdlib/2/__builtin__.pyi +++ b/python/helpers/typeshed/stdlib/2/__builtin__.pyi @@ -92,11 +92,6 @@ class int(SupportsInt, SupportsFloat, SupportsAbs[int]): @overload def __init__(self, x: Union[str, unicode, bytearray], base: int = ...) -> None: ... - @overload - def __new__(cls: Type[_T1], x: SupportsInt = ...) -> _T1: ... - @overload - def __new__(cls: Type[_T1], x: Union[str, unicode, bytearray], base: int = ...) -> _T1: ... - def bit_length(self) -> int: ... def __add__(self, x: int) -> int: ... @@ -144,14 +139,7 @@ class int(SupportsInt, SupportsFloat, SupportsAbs[int]): def __nonzero__(self) -> bool: ... class float(SupportsFloat, SupportsInt, SupportsAbs[float]): - @overload - def __init__(self) -> None: ... - @overload - def __init__(self, x: SupportsFloat) -> None: ... - @overload - def __init__(self, x: unicode) -> None: ... - @overload - def __init__(self, x: bytearray) -> None: ... + def __init__(self, x: Union[SupportsFloat, str, unicode, bytearray] = ...) -> None: ... def as_integer_ratio(self) -> Tuple[int, int]: ... def hex(self) -> str: ... def is_integer(self) -> bool: ... @@ -314,7 +302,6 @@ class unicode(basestring, Sequence[unicode]): class str(basestring, Sequence[str]): def __init__(self, object: object = ...) -> None: ... - def __new__(cls: Type[_T1], object: object = ...) -> _T1: ... def capitalize(self) -> str: ... def center(self, width: int, fillchar: str = ...) -> str: ... def count(self, x: unicode, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... @@ -492,7 +479,7 @@ class slice(object): @overload def __init__(self, stop: Optional[int]) -> None: ... @overload - def __init__(self, start: Optional[int], stop: Optional[int], step: int = None) -> None: ... + def __init__(self, start: Optional[int], stop: Optional[int], step: Optional[int] = None) -> None: ... def indices(self, len: int) -> Tuple[int, int, int]: ... class tuple(Sequence[_T_co], Generic[_T_co]): @@ -613,9 +600,9 @@ class set(MutableSet[_T], Generic[_T]): def discard(self, element: _T) -> None: ... def intersection(self, *s: Iterable[Any]) -> Set[_T]: ... def intersection_update(self, *s: Iterable[Any]) -> None: ... - def isdisjoint(self, s: Iterable[Any]) -> bool: ... - def issubset(self, s: Iterable[Any]) -> bool: ... - def issuperset(self, s: Iterable[Any]) -> bool: ... + def isdisjoint(self, s: Iterable[object]) -> bool: ... + def issubset(self, s: Iterable[object]) -> bool: ... + def issuperset(self, s: Iterable[object]) -> bool: ... def pop(self) -> _T: ... def remove(self, element: _T) -> None: ... def symmetric_difference(self, s: Iterable[_T]) -> Set[_T]: ... @@ -626,18 +613,18 @@ class set(MutableSet[_T], Generic[_T]): def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[_T]: ... def __str__(self) -> str: ... - def __and__(self, s: AbstractSet[Any]) -> Set[_T]: ... - def __iand__(self, s: AbstractSet[Any]) -> Set[_T]: ... + def __and__(self, s: AbstractSet[object]) -> Set[_T]: ... + def __iand__(self, s: AbstractSet[object]) -> Set[_T]: ... def __or__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ... def __ior__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ... - def __sub__(self, s: AbstractSet[Any]) -> Set[_T]: ... - def __isub__(self, s: AbstractSet[Any]) -> Set[_T]: ... + def __sub__(self, s: AbstractSet[object]) -> Set[_T]: ... + def __isub__(self, s: AbstractSet[object]) -> Set[_T]: ... def __xor__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ... def __ixor__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ... - def __le__(self, s: AbstractSet[Any]) -> bool: ... - def __lt__(self, s: AbstractSet[Any]) -> bool: ... - def __ge__(self, s: AbstractSet[Any]) -> bool: ... - def __gt__(self, s: AbstractSet[Any]) -> bool: ... + def __le__(self, s: AbstractSet[object]) -> bool: ... + def __lt__(self, s: AbstractSet[object]) -> bool: ... + def __ge__(self, s: AbstractSet[object]) -> bool: ... + def __gt__(self, s: AbstractSet[object]) -> bool: ... # TODO more set operations class frozenset(AbstractSet[_T], Generic[_T]): @@ -646,11 +633,11 @@ class frozenset(AbstractSet[_T], Generic[_T]): @overload def __init__(self, iterable: Iterable[_T]) -> None: ... def copy(self) -> FrozenSet[_T]: ... - def difference(self, *s: Iterable[Any]) -> FrozenSet[_T]: ... - def intersection(self, *s: Iterable[Any]) -> FrozenSet[_T]: ... + def difference(self, *s: Iterable[object]) -> FrozenSet[_T]: ... + def intersection(self, *s: Iterable[object]) -> FrozenSet[_T]: ... def isdisjoint(self, s: Iterable[_T]) -> bool: ... - def issubset(self, s: Iterable[Any]) -> bool: ... - def issuperset(self, s: Iterable[Any]) -> bool: ... + def issubset(self, s: Iterable[object]) -> bool: ... + def issuperset(self, s: Iterable[object]) -> bool: ... def symmetric_difference(self, s: Iterable[_T]) -> FrozenSet[_T]: ... def union(self, *s: Iterable[_T]) -> FrozenSet[_T]: ... def __len__(self) -> int: ... @@ -661,10 +648,10 @@ class frozenset(AbstractSet[_T], Generic[_T]): def __or__(self, s: AbstractSet[_S]) -> FrozenSet[Union[_T, _S]]: ... def __sub__(self, s: AbstractSet[_T]) -> FrozenSet[_T]: ... def __xor__(self, s: AbstractSet[_S]) -> FrozenSet[Union[_T, _S]]: ... - def __le__(self, s: AbstractSet[Any]) -> bool: ... - def __lt__(self, s: AbstractSet[Any]) -> bool: ... - def __ge__(self, s: AbstractSet[Any]) -> bool: ... - def __gt__(self, s: AbstractSet[Any]) -> bool: ... + def __le__(self, s: AbstractSet[object]) -> bool: ... + def __lt__(self, s: AbstractSet[object]) -> bool: ... + def __ge__(self, s: AbstractSet[object]) -> bool: ... + def __gt__(self, s: AbstractSet[object]) -> bool: ... class enumerate(Iterator[Tuple[int, _T]], Generic[_T]): def __init__(self, iterable: Iterable[_T], start: int = 0) -> None: ... @@ -682,19 +669,14 @@ class xrange(Sized, Iterable[int], Reversible[int]): def __getitem__(self, i: int) -> int: ... def __reversed__(self) -> Iterator[int]: ... -class module: - __name__ = ... # type: str - __file__ = ... # type: str - __dict__ = ... # type: Dict[unicode, Any] - class property(object): - def __init__(self, fget: Callable[[Any], Any] = None, - fset: Callable[[Any, Any], None] = None, - fdel: Callable[[Any], None] = None, doc: str = None) -> None: ... + def __init__(self, fget: Optional[Callable[[Any], Any]] = None, + fset: Optional[Callable[[Any, Any], None]] = None, + fdel: Optional[Callable[[Any], None]] = None, doc: Optional[str] = None) -> None: ... def getter(self, fget: Callable[[Any], Any]) -> property: ... def setter(self, fset: Callable[[Any, Any], None]) -> property: ... def deleter(self, fdel: Callable[[Any], None]) -> property: ... - def __get__(self, obj: Any, type: type=None) -> Any: ... + def __get__(self, obj: Any, type: Optional[type] = None) -> Any: ... def __set__(self, obj: Any, value: Any) -> None: ... def __delete__(self, obj: Any) -> None: ... def fget(self) -> Any: ... @@ -707,8 +689,8 @@ bytes = str NotImplemented = ... # type: Any def abs(n: SupportsAbs[_T]) -> _T: ... -def all(i: Iterable) -> bool: ... -def any(i: Iterable) -> bool: ... +def all(i: Iterable[object]) -> bool: ... +def any(i: Iterable[object]) -> bool: ... def bin(number: int) -> str: ... def callable(o: object) -> bool: ... def chr(code: int) -> str: ... @@ -728,7 +710,7 @@ def filter(function: Callable[[_T], Any], def filter(function: None, iterable: Iterable[Optional[_T]]) -> List[_T]: ... def format(o: object, format_spec: str = '') -> str: ... # TODO unicode -def getattr(o: Any, name: unicode, default: Any = None) -> Any: ... +def getattr(o: Any, name: unicode, default: Optional[Any] = None) -> Any: ... def hasattr(o: Any, name: unicode) -> bool: ... def hash(o: object) -> int: ... def hex(i: int) -> str: ... # TODO __index__ @@ -762,14 +744,14 @@ def next(i: Iterator[_T]) -> _T: ... def next(i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ... def oct(i: int) -> str: ... # TODO __index__ @overload -def open(file: str, mode: str = 'r', buffering: int = ...) -> BinaryIO: ... +def open(file: str, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... @overload -def open(file: unicode, mode: str = 'r', buffering: int = ...) -> BinaryIO: ... +def open(file: unicode, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... @overload -def open(file: int, mode: str = 'r', buffering: int = ...) -> BinaryIO: ... +def open(file: int, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... def ord(c: unicode) -> int: ... # This is only available after from __future__ import print_function. -def print(*values: Any, sep: unicode = u' ', end: unicode = u'\n', +def print(*values: Any, sep: unicode = ..., end: unicode = ..., file: IO[Any] = ...) -> None: ... @overload def pow(x: int, y: int) -> Any: ... # The return type can be int or float, depending on y. @@ -780,7 +762,7 @@ def pow(x: float, y: float) -> float: ... @overload def pow(x: float, y: float, z: float) -> float: ... def quit(code: int = ...) -> None: ... -def range(x: int, y: int = 0, step: int = 1) -> List[int]: ... +def range(x: int, y: int = ..., step: int = ...) -> List[int]: ... def raw_input(prompt: Any = ...) -> str: ... @overload @@ -927,6 +909,7 @@ class SyntaxError(StandardError): lineno = ... # type: int offset = ... # type: int text = ... # type: str + filename = ... # type: str class IndentationError(SyntaxError): ... class TabError(IndentationError): ... class SystemError(StandardError): ... @@ -950,14 +933,14 @@ class UnicodeWarning(Warning): ... class BytesWarning(Warning): ... class ResourceWarning(Warning): ... -def eval(s: str, globals: Dict[str, Any] = ..., locals: Dict[str, Any] = ...) -> Any: ... +def eval(s: Union[str, unicode], globals: Dict[str, Any] = ..., locals: Dict[str, Any] = ...) -> Any: ... def exec(object: str, - globals: Dict[str, Any] = None, - locals: Dict[str, Any] = None) -> Any: ... # TODO code object as source + globals: Optional[Dict[str, Any]] = None, + locals: Optional[Dict[str, Any]] = None) -> Any: ... # TODO code object as source def cmp(x: Any, y: Any) -> int: ... -def execfile(filename: str, globals: Dict[str, Any] = None, locals: Dict[str, Any] = None) -> None: ... +def execfile(filename: str, globals: Optional[Dict[str, Any]] = None, locals: Optional[Dict[str, Any]] = None) -> None: ... class file(BinaryIO): @overload @@ -969,7 +952,7 @@ class file(BinaryIO): def __iter__(self) -> Iterator[str]: ... def read(self, n: int = ...) -> str: ... def __enter__(self) -> BinaryIO: ... - def __exit__(self, t: type = None, exc: BaseException = None, tb: Any = None) -> bool: ... + def __exit__(self, t: Optional[type] = None, exc: Optional[BaseException] = None, tb: Optional[Any] = None) -> bool: ... def flush(self) -> None: ... def fileno(self) -> int: ... def isatty(self) -> bool: ... @@ -987,6 +970,6 @@ class file(BinaryIO): def truncate(self, pos: Optional[int] = ...) -> int: ... # Very old builtins -def apply(func: Callable[..., _T], args: Sequence[Any] = None, kwds: Mapping[str, Any] = None) -> _T: ... +def apply(func: Callable[..., _T], args: Optional[Sequence[Any]] = None, kwds: Optional[Mapping[str, Any]] = None) -> _T: ... _N = TypeVar('_N', bool, int, float, complex) def coerce(x: _N, y: _N) -> Tuple[_N, _N]: ... diff --git a/python/helpers/typeshed/stdlib/2/_ast.pyi b/python/helpers/typeshed/stdlib/2/_ast.pyi index 02236a840d81..a0a7a00c8002 100644 --- a/python/helpers/typeshed/stdlib/2/_ast.pyi +++ b/python/helpers/typeshed/stdlib/2/_ast.pyi @@ -5,7 +5,7 @@ __version__ = ... # type: str PyCF_ONLY_AST = ... # type: int -identifier = str +_identifier = str class AST: _attributes = ... # type: typing.Tuple[str, ...] @@ -33,13 +33,13 @@ class stmt(AST): col_offset = ... # type: int class FunctionDef(stmt): - name = ... # type: identifier + name = ... # type: _identifier args = ... # type: arguments body = ... # type: typing.List[stmt] decorator_list = ... # type: typing.List[expr] class ClassDef(stmt): - name = ... # type: identifier + name = ... # type: _identifier bases = ... # type: typing.List[expr] body = ... # type: typing.List[stmt] decorator_list = ... # type: typing.List[expr] @@ -107,7 +107,7 @@ class Import(stmt): names = ... # type: typing.List[alias] class ImportFrom(stmt): - module = ... # type: Optional[identifier] + module = ... # type: Optional[_identifier] names = ... # type: typing.List[alias] level = ... # type: Optional[int] @@ -117,7 +117,7 @@ class Exec(stmt): locals = ... # type: Optional[expr] class Global(stmt): - names = ... # type: typing.List[identifier] + names = ... # type: typing.List[_identifier] class Expr(stmt): value = ... # type: expr @@ -222,7 +222,7 @@ class Str(expr): class Attribute(expr): value = ... # type: expr - attr = ... # type: identifier + attr = ... # type: _identifier ctx = ... # type: expr_context class Subscript(expr): @@ -231,7 +231,7 @@ class Subscript(expr): ctx = ... # type: expr_context class Name(expr): - id = ... # type: identifier + id = ... # type: _identifier ctx = ... # type: expr_context class List(expr): @@ -315,14 +315,14 @@ class ExceptHandler(AST): class arguments(AST): args = ... # type: typing.List[expr] - vararg = ... # type: Optional[identifier] - kwarg = ... # type: Optional[identifier] + vararg = ... # type: Optional[_identifier] + kwarg = ... # type: Optional[_identifier] defaults = ... # type: typing.List[expr] class keyword(AST): - arg = ... # type: identifier + arg = ... # type: _identifier value = ... # type: expr class alias(AST): - name = ... # type: identifier - asname = ... # type: Optional[identifier] + name = ... # type: _identifier + asname = ... # type: Optional[_identifier] diff --git a/python/helpers/typeshed/stdlib/2/_io.pyi b/python/helpers/typeshed/stdlib/2/_io.pyi index e85da33176c4..3f1baab15792 100644 --- a/python/helpers/typeshed/stdlib/2/_io.pyi +++ b/python/helpers/typeshed/stdlib/2/_io.pyi @@ -1,107 +1,168 @@ -from typing import Any, Optional, Iterable, Tuple, List, Union +from typing import Any, AnyStr, BinaryIO, IO, Text, TextIO, Iterable, Iterator, List, Optional, Type, Tuple, TypeVar, Union +from types import TracebackType DEFAULT_BUFFER_SIZE = ... # type: int - class BlockingIOError(IOError): characters_written = ... # type: int class UnsupportedOperation(ValueError, IOError): ... +_T = TypeVar("_T") -class _IOBase(object): - closed = ... # type: bool - def __enter__(self) -> "_IOBase": ... - def __exit__(self, type, value, traceback) -> bool: ... - def __iter__(self) -> "_IOBase": ... +class _IOBase(BinaryIO): + @property + def closed(self) -> bool: ... def _checkClosed(self) -> None: ... def _checkReadable(self) -> None: ... def _checkSeekable(self) -> None: ... def _checkWritable(self) -> None: ... + # All these methods are concrete here (you can instantiate this) def close(self) -> None: ... def fileno(self) -> int: ... def flush(self) -> None: ... def isatty(self) -> bool: ... - def next(self) -> str: ... def readable(self) -> bool: ... - def readline(self, limit: int = ...) -> str: ... - def readlines(self, hint: int = ...) -> List[str]: ... - def seek(self, offset: int, whence: int = ...) -> None: ... + def seek(self, offset: int, whence: int = ...) -> int: ... def seekable(self) -> bool: ... def tell(self) -> int: ... - def truncate(self, size: int = ...) -> int: ... + def truncate(self, size: Optional[int] = ...) -> int: ... def writable(self) -> bool: ... - def writelines(self, lines: Iterable[str]) -> None: ... + def __enter__(self: _T) -> _T: ... + def __exit__(self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[Any]) -> bool: ... + def __iter__(self: _T) -> _T: ... + # The parameter type of writelines[s]() is determined by that of write(): + def writelines(self, lines: Iterable[bytes]) -> None: ... + # The return type of readline[s]() and next() is determined by that of read(): + def readline(self, limit: int = ...) -> bytes: ... + def readlines(self, hint: int = ...) -> list[bytes]: ... + def next(self) -> bytes: ... class _BufferedIOBase(_IOBase): - def read1(self, n: int) -> str: ... - def read(self, n: int = ...) -> str: ... + def read1(self, n: int) -> bytes: ... + def read(self, size: int = ...) -> bytes: ... def readinto(self, buffer: bytearray) -> int: ... - def write(self, s: str) -> int: ... - def detach(self) -> "_BufferedIOBase": ... + def write(self, s: bytes) -> int: ... + def detach(self) -> _IOBase: ... class BufferedRWPair(_BufferedIOBase): - def peek(self, n: int = ...) -> str: ... + def __init__(self, reader: _RawIOBase, writer: _RawIOBase, + buffer_size: int = ..., max_buffer_size: int = ...) -> None: ... + def peek(self, n: int = ...) -> bytes: ... + def __enter__(self) -> BufferedRWPair: ... class BufferedRandom(_BufferedIOBase): + mode = ... # type: str name = ... # type: str raw = ... # type: _IOBase - mode = ... # type: str - def peek(self, n: int = ...) -> str: ... + def __init__(self, raw: _IOBase, + buffer_size: int = ..., + max_buffer_size: int = ...) -> None: ... + def peek(self, n: int = ...) -> bytes: ... class BufferedReader(_BufferedIOBase): + mode = ... # type: str name = ... # type: str raw = ... # type: _IOBase - mode = ... # type: str - def peek(self, n: int = ...) -> str: ... + def __init__(self, raw: _IOBase, buffer_size: int = ...) -> None: ... + def peek(self, n: int = ...) -> bytes: ... class BufferedWriter(_BufferedIOBase): name = ... # type: str raw = ... # type: _IOBase mode = ... # type: str + def __init__(self, raw: _IOBase, + buffer_size: int = ..., + max_buffer_size: int = ...) -> None: ... class BytesIO(_BufferedIOBase): + def __init__(self, initial_bytes: bytes = ...) -> None: ... def __setstate__(self, tuple) -> None: ... def __getstate__(self) -> tuple: ... - def getvalue(self) -> str: ... + def getvalue(self) -> bytes: ... + def write(self, s: bytes) -> int: ... + def writelines(self, lines: Iterable[bytes]) -> None: ... + def read1(self, size: int) -> bytes: ... + def next(self) -> bytes: ... class _RawIOBase(_IOBase): def readall(self) -> str: ... def read(self, n: int = ...) -> str: ... -class FileIO(_RawIOBase): +class FileIO(_RawIOBase, BytesIO): # type: ignore # for __enter__ mode = ... # type: str closefd = ... # type: bool + def __init__(self, file: str, mode: str = ..., closefd: bool = ...) -> None: ... def readinto(self, buffer: bytearray)-> int: ... def write(self, pbuf: str) -> int: ... class IncrementalNewlineDecoder(object): newlines = ... # type: Union[str, unicode] + def __init__(self, decoder, translate, z=...) -> None: ... def decode(self, input, final) -> Any: ... def getstate(self) -> Tuple[Any, int]: ... def setstate(self, state: Tuple[Any, int]) -> None: ... def reset(self) -> None: ... -class _TextIOBase(_IOBase): + +# Note: In the actual _io.py, _TextIOBase inherits from _IOBase. +class _TextIOBase(TextIO): errors = ... # type: Optional[str] - newlines = ... # type: Union[str, unicode] - encoding = ... # type: Optional[str] - def read(self, n: int = ...) -> str: ... - def write(self) -> None: - raise UnsupportedOperation - def detach(self) -> None: - raise UnsupportedOperation + # TODO: On _TextIOBase, this is always None. But it's unicode/bytes in subclasses. + newlines = ... # type: Union[None, unicode, bytes] + encoding = ... # type: str + @property + def closed(self) -> bool: ... + def _checkClosed(self) -> None: ... + def _checkReadable(self) -> None: ... + def _checkSeekable(self) -> None: ... + def _checkWritable(self) -> None: ... + def close(self) -> None: ... + def detach(self) -> IO: ... + def fileno(self) -> int: ... + def flush(self) -> None: ... + def isatty(self) -> bool: ... + def next(self) -> unicode: ... + def read(self, size: int = ...) -> unicode: ... + def readable(self) -> bool: ... + def readline(self, limit: int = ...) -> unicode: ... + def readlines(self, hint: int = ...) -> list[unicode]: ... + def seek(self, offset: int, whence: int = ...) -> int: ... + def seekable(self) -> bool: ... + def tell(self) -> int: ... + def truncate(self, size: Optional[int] = ...) -> int: ... + def writable(self) -> bool: ... + def write(self, pbuf: unicode) -> int: ... + def writelines(self, lines: Iterable[unicode]) -> None: ... + def __enter__(self: _T) -> _T: ... + def __exit__(self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[Any]) -> bool: ... + def __iter__(self: _T) -> _T: ... class StringIO(_TextIOBase): line_buffering = ... # type: bool - def getvalue(self) -> str: ... + def __init__(self, + initial_value: Optional[unicode] = ..., + newline: Optional[unicode] = ...) -> None: ... def __setstate__(self, state: tuple) -> None: ... def __getstate__(self) -> tuple: ... + def getvalue(self) -> unicode: ... class TextIOWrapper(_TextIOBase): name = ... # type: str line_buffering = ... # type: bool - buffer = ... # type: str + buffer = ... # type: BinaryIO _CHUNK_SIZE = ... # type: int + def __init__(self, buffer: IO, + encoding: Optional[Text] = ..., + errors: Optional[Text] = ..., + newline: Optional[Text] = ..., + line_buffering: bool = ..., + write_through: bool = ...) -> None: ... -def open(file: Union[int, str], mode: str = ...) -> _IOBase: ... +def open(file: Union[str, unicode, int], + mode: unicode = ..., + buffering: int = ..., + encoding: Optional[Text] = ..., + errors: Optional[Text] = ..., + newline: Optional[Text] = ..., + closefd: bool = ...) -> IO[Any]: ... diff --git a/python/helpers/typeshed/stdlib/2/_threading_local.pyi b/python/helpers/typeshed/stdlib/2/_threading_local.pyi new file mode 100644 index 000000000000..512bf5874df7 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/_threading_local.pyi @@ -0,0 +1,14 @@ +# Source: https://hg.python.org/cpython/file/2.7/Lib/_threading_local.py +from typing import Any, List + +__all__: List[str] + +class _localbase(object): ... + +class local(_localbase): + def __getattribute__(self, name: str) -> Any: ... + def __setattr__(self, name: str, value: Any) -> None: ... + def __delattr__(self, name: str) -> None: ... + def __del__(self) -> None: ... + +def _patch(self: local) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2/_warnings.pyi b/python/helpers/typeshed/stdlib/2/_warnings.pyi index 4f54529db75e..63fd9d486f1f 100644 --- a/python/helpers/typeshed/stdlib/2/_warnings.pyi +++ b/python/helpers/typeshed/stdlib/2/_warnings.pyi @@ -1,11 +1,11 @@ -from typing import Any, List +from typing import Any, List, Optional, Type default_action = ... # type: str filters = ... # type: List[tuple] once_registry = ... # type: dict -def warn(message: Warning, category: type = ..., stacklevel: int = ...) -> None: ... -def warn_explicit(message: Warning, category: type, +def warn(message: Warning, category: Optional[Type[Warning]] = ..., stacklevel: int = ...) -> None: ... +def warn_explicit(message: Warning, category: Optional[Type[Warning]], filename: str, lineno: int, module: Any = ..., registry: dict = ..., module_globals: dict = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2/abc.pyi b/python/helpers/typeshed/stdlib/2/abc.pyi index a2d270f76f08..e21065e5c1db 100644 --- a/python/helpers/typeshed/stdlib/2/abc.pyi +++ b/python/helpers/typeshed/stdlib/2/abc.pyi @@ -1,11 +1,7 @@ from typing import Any, Dict, Set, Tuple, Type import _weakrefset -# mypy has special processing for ABCMeta and abstractmethod. - -WeakSet = ... # type: _weakrefset.WeakSet -_InstanceType = ... # type: type -types = ... # type: module +# NOTE: mypy has special processing for ABCMeta and abstractmethod. def abstractmethod(funcobj: Any) -> Any: ... @@ -23,9 +19,6 @@ class ABCMeta(type): def _dump_registry(cls: "ABCMeta", *args: Any, **kwargs: Any) -> None: ... def register(cls: "ABCMeta", subclass: Type[Any]) -> None: ... -class _C: - pass - # TODO: The real abc.abstractproperty inherits from "property". class abstractproperty(object): def __new__(cls, func: Any) -> Any: ... diff --git a/python/helpers/typeshed/stdlib/2/ast.pyi b/python/helpers/typeshed/stdlib/2/ast.pyi index 244b230929ff..e4ba3b6f1b1e 100644 --- a/python/helpers/typeshed/stdlib/2/ast.pyi +++ b/python/helpers/typeshed/stdlib/2/ast.pyi @@ -3,25 +3,14 @@ import typing from typing import Any, Iterator, Union -from _ast import ( - Add, alias, And, arguments, Assert, Assign, AST, Attribute, AugAssign, - AugLoad, AugStore, BinOp, BitAnd, BitOr, BitXor, BoolOp, boolop, Break, - Call, ClassDef, cmpop, Compare, comprehension, Continue, Del, Delete, Dict, - DictComp, Div, Ellipsis, Eq, ExceptHandler, Exec, Expr, expr, Expression, - expr_context, ExtSlice, FloorDiv, For, FunctionDef, GeneratorExp, Global, - Gt, GtE, If, IfExp, Import, ImportFrom, In, Index, Interactive, Invert, Is, - IsNot, keyword, Lambda, List, ListComp, Load, LShift, Lt, LtE, Mod, mod, - Module, Mult, Name, Not, NotEq, NotIn, Num, operator, Or, Param, Pass, Pow, - Print, Raise, Repr, Return, RShift, Set, SetComp, Slice, slice, stmt, - Store, Str, Sub, Subscript, Suite, TryExcept, TryFinally, Tuple, UAdd, - UnaryOp, unaryop, USub, While, With, Yield -) +from _ast import * +from _ast import AST, Module __version__ = ... # type: str PyCF_ONLY_AST = ... # type: int -def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: str = ...) -> Module: ... +def parse(source: Union[str, unicode], filename: Union[str, unicode] = ..., mode: Union[str, unicode] = ...) -> Module: ... 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: ... @@ -29,7 +18,7 @@ def get_docstring(node: AST, clean: bool = ...) -> str: ... def increment_lineno(node: AST, n: int = ...) -> AST: ... def iter_child_nodes(node: AST) -> Iterator[AST]: ... def iter_fields(node: AST) -> Iterator[typing.Tuple[str, Any]]: ... -def literal_eval(node_or_string: Union[str, AST]) -> Any: ... +def literal_eval(node_or_string: Union[str, unicode, AST]) -> Any: ... def walk(node: AST) -> Iterator[AST]: ... class NodeVisitor(): diff --git a/python/helpers/typeshed/stdlib/2/collections.pyi b/python/helpers/typeshed/stdlib/2/collections.pyi index b5d4fef7bf4a..e0d983ea67cc 100644 --- a/python/helpers/typeshed/stdlib/2/collections.pyi +++ b/python/helpers/typeshed/stdlib/2/collections.pyi @@ -2,23 +2,36 @@ # Based on http://docs.python.org/2.7/library/collections.html -# TODO more abstract base classes (interfaces in mypy) - -# NOTE: These are incomplete! - -from typing import ( - Any, Container, Dict, Generic, TypeVar, Iterable, Tuple, Callable, Mapping, overload, - Iterator, Type, Sized, Optional, List, Set, Sequence, Union, Reversible, - MutableMapping, MutableSet, MutableSequence, -) +# These are not exported. import typing +from typing import Dict, Generic, TypeVar, Tuple, overload, Type, Optional, List, Union, Reversible + +# These are exported. +from typing import ( + Callable as Callable, + Container as Container, + Hashable as Hashable, + ItemsView as ItemsView, + Iterable as Iterable, + Iterator as Iterator, + KeysView as KeysView, + Mapping as Mapping, + MappingView as MappingView, + MutableMapping as MutableMapping, + MutableSequence as MutableSequence, + MutableSet as MutableSet, + Sequence as Sequence, + AbstractSet as Set, + Sized as Sized, + ValuesView as ValuesView, +) _T = TypeVar('_T') _KT = TypeVar('_KT') _VT = TypeVar('_VT') # namedtuple is special-cased in the type checker; the initializer is ignored. -def namedtuple(typename: Union[str, unicode], field_names: Union[str, unicode, Iterable[Any]], *, +def namedtuple(typename: Union[str, unicode], field_names: Union[str, unicode, Iterable[Union[str, unicode]]], *, verbose: bool = ..., rename: bool = ...) -> Type[tuple]: ... class deque(Sized, Iterable[_T], Reversible[_T], Generic[_T]): @@ -47,17 +60,16 @@ class deque(Sized, Iterable[_T], Reversible[_T], Generic[_T]): def __reversed__(self) -> Iterator[_T]: ... class Counter(Dict[_T, int], Generic[_T]): - # TODO: __init__ keyword arguments @overload - def __init__(self) -> None: ... + def __init__(self, **kwargs: int) -> None: ... @overload - def __init__(self, Mapping: Mapping[_T, int]) -> None: ... + def __init__(self, mapping: Mapping[_T, int]) -> None: ... @overload def __init__(self, iterable: Iterable[_T]) -> None: ... def elements(self) -> Iterator[_T]: ... - def most_common(self, n: int = ...) -> List[_T]: ... + def most_common(self, n: Optional[int] = ...) -> List[Tuple[_T, int]]: ... @overload - def subtract(self, mapping: Mapping[_T, int]) -> None: ... + def subtract(self, __mapping: Mapping[_T, int]) -> None: ... @overload def subtract(self, iterable: Iterable[_T]) -> None: ... # The Iterable[Tuple[...]] argument type is not actually desirable @@ -72,26 +84,29 @@ class Counter(Dict[_T, int], Generic[_T]): @overload def update(self, **kwargs: int) -> None: ... + def __add__(self, other: Counter[_T]) -> Counter[_T]: ... + def __sub__(self, other: Counter[_T]) -> Counter[_T]: ... + def __and__(self, other: Counter[_T]) -> Counter[_T]: ... + def __or__(self, other: Counter[_T]) -> Counter[_T]: ... + def __iadd__(self, other: Counter[_T]) -> Counter[_T]: ... + def __isub__(self, other: Counter[_T]) -> Counter[_T]: ... + def __iand__(self, other: Counter[_T]) -> Counter[_T]: ... + def __ior__(self, other: Counter[_T]) -> Counter[_T]: ... + 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] - # TODO: __init__ keyword args @overload - def __init__(self) -> None: ... + def __init__(self, **kwargs: _VT) -> None: ... @overload - def __init__(self, map: Mapping[_KT, _VT]) -> None: ... + def __init__(self, default_factory: Optional[Callable[[], _VT]]) -> None: ... @overload - def __init__(self, iterable: Iterable[Tuple[_KT, _VT]]) -> None: ... - @overload - def __init__(self, default_factory: Callable[[], _VT]) -> None: ... - @overload - def __init__(self, default_factory: Callable[[], _VT], + def __init__(self, default_factory: Optional[Callable[[], _VT]], map: Mapping[_KT, _VT]) -> None: ... @overload - def __init__(self, default_factory: Callable[[], _VT], + def __init__(self, default_factory: Optional[Callable[[], _VT]], iterable: Iterable[Tuple[_KT, _VT]]) -> None: ... def __missing__(self, key: _KT) -> _VT: ... diff --git a/python/helpers/typeshed/stdlib/2/compileall.pyi b/python/helpers/typeshed/stdlib/2/compileall.pyi index 28f079a5b2c2..c3e861e1e99d 100644 --- a/python/helpers/typeshed/stdlib/2/compileall.pyi +++ b/python/helpers/typeshed/stdlib/2/compileall.pyi @@ -4,7 +4,7 @@ from typing import Optional, Pattern, Union _Path = Union[str, bytes] -# fx can be any object with a 'search' method; once we have Protocols we can change the type -def compile_dir(dir: _Path, maxlevels: int = ..., ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ...) -> None: ... -def compile_file(fullname: _Path, ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ...) -> None: ... -def compile_path(skip_curdir: bool = ..., maxlevels: int = ..., force: bool = ..., quiet: int = ...) -> None: ... +# rx can be any object with a 'search' method; once we have Protocols we can change the type +def compile_dir(dir: _Path, maxlevels: int = ..., ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ...) -> int: ... +def compile_file(fullname: _Path, ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ...) -> int: ... +def compile_path(skip_curdir: bool = ..., maxlevels: int = ..., force: bool = ..., quiet: int = ...) -> int: ... diff --git a/python/helpers/typeshed/stdlib/2/cookielib.pyi b/python/helpers/typeshed/stdlib/2/cookielib.pyi index f7389dfe97f2..e17f17ad9daa 100644 --- a/python/helpers/typeshed/stdlib/2/cookielib.pyi +++ b/python/helpers/typeshed/stdlib/2/cookielib.pyi @@ -1,7 +1,3 @@ -# Stubs for cookielib (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class Cookie: diff --git a/python/helpers/typeshed/stdlib/2/datetime.pyi b/python/helpers/typeshed/stdlib/2/datetime.pyi index f2d45d97e57f..2a804b213016 100644 --- a/python/helpers/typeshed/stdlib/2/datetime.pyi +++ b/python/helpers/typeshed/stdlib/2/datetime.pyi @@ -3,7 +3,7 @@ # NOTE: These are incomplete! from time import struct_time -from typing import Optional, SupportsAbs, Tuple, Union, overload +from typing import AnyStr, Optional, SupportsAbs, Tuple, Union, overload MINYEAR = 0 MAXYEAR = 0 @@ -39,7 +39,7 @@ class date(object): def ctime(self) -> str: ... def strftime(self, fmt: Union[str, unicode]) -> str: ... - def __format__(self, fmt: Union[str, unicode]) -> str: ... + def __format__(self, fmt: AnyStr) -> AnyStr: ... def isoformat(self) -> str: ... def timetuple(self) -> struct_time: ... def toordinal(self) -> int: ... @@ -84,12 +84,12 @@ class time: def __hash__(self) -> int: ... def isoformat(self) -> str: ... def strftime(self, fmt: Union[str, unicode]) -> str: ... - def __format__(self, fmt: str) -> str: ... + def __format__(self, fmt: AnyStr) -> AnyStr: ... def utcoffset(self) -> Optional[timedelta]: ... def tzname(self) -> Optional[str]: ... def dst(self) -> Optional[int]: ... def replace(self, hour: int = ..., minute: int = ..., second: int = ..., - microsecond: int = ..., tzinfo: Union[_tzinfo, bool] = ...) -> time: ... + microsecond: int = ..., tzinfo: Optional[_tzinfo] = ...) -> time: ... _date = date _time = time @@ -114,7 +114,7 @@ class timedelta(SupportsAbs[timedelta]): def __add__(self, other: timedelta) -> timedelta: ... def __radd__(self, other: timedelta) -> timedelta: ... def __sub__(self, other: timedelta) -> timedelta: ... - def __rsub(self, other: timedelta) -> timedelta: ... + def __rsub__(self, other: timedelta) -> timedelta: ... def __neg__(self) -> timedelta: ... def __pos__(self) -> timedelta: ... def __abs__(self) -> timedelta: ... @@ -135,7 +135,7 @@ class timedelta(SupportsAbs[timedelta]): def __hash__(self) -> int: ... class datetime(object): - # TODO: is actually subclass of date, but __le__, __lt__, __ge__, __gt__ don't work with date. + # TODO: is actually subclass of date, but __le__, __lt__, __ge__, __gt__, __sub__ don't work with date. min = ... # type: datetime max = ... # type: datetime resolution = ... # type: timedelta @@ -143,6 +143,9 @@ class datetime(object): def __init__(self, year: int, month: int, day: int, hour: int = ..., minute: int = ..., second: int = ..., microseconds: int = ..., tzinfo: tzinfo = ...) -> None: ... + def __new__(cls, year: int, month: int, day: int, hour: int = ..., + minute: int = ..., second: int = ..., microseconds: int = ..., + tzinfo: tzinfo = ...) -> datetime: ... @property def year(self) -> int: ... @@ -176,7 +179,7 @@ class datetime(object): @classmethod def combine(cls, date: date, time: time) -> datetime: ... def strftime(self, fmt: Union[str, unicode]) -> str: ... - def __format__(self, fmt: str) -> str: ... + def __format__(self, fmt: AnyStr) -> AnyStr: ... def toordinal(self) -> int: ... def timetuple(self) -> struct_time: ... def utctimetuple(self) -> struct_time: ... @@ -185,7 +188,7 @@ class datetime(object): def timetz(self) -> _time: ... def replace(self, year: int = ..., month: int = ..., day: int = ..., hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: - Union[_tzinfo, bool] = ...) -> datetime: ... + Optional[_tzinfo] = ...) -> datetime: ... def astimezone(self, tz: _tzinfo) -> datetime: ... def ctime(self) -> str: ... def isoformat(self, sep: str = ...) -> str: ... diff --git a/python/helpers/typeshed/stdlib/2/dummy_thread.pyi b/python/helpers/typeshed/stdlib/2/dummy_thread.pyi new file mode 100644 index 000000000000..df1b21a4a811 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/dummy_thread.pyi @@ -0,0 +1,22 @@ +from mypy_extensions import NoReturn +from typing import Any, Callable, Dict, Optional, Tuple + +class error(Exception): + def __init__(self, *args: Any) -> None: ... + +def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs: Dict[str, Any] = ...) -> None: ... +def exit() -> NoReturn: ... +def get_ident() -> int: ... +def allocate_lock() -> LockType: ... +def stack_size(size: Optional[int] = ...) -> int: ... + +class LockType(object): + locked_status: bool + def __init__(self) -> None: ... + def acquire(self, waitflag: Optional[bool] = ...) -> bool: ... + def __enter__(self, waitflag: Optional[bool] = ...) -> bool: ... + def __exit__(self, typ: Any, val: Any, tb: Any) -> None: ... + def release(self) -> bool: ... + def locked(self) -> bool: ... + +def interrupt_main() -> None: ... diff --git a/python/helpers/typeshed/stdlib/2/email/MIMEText.pyi b/python/helpers/typeshed/stdlib/2/email/MIMEText.pyi index a15eb1d35b86..3b059778aa66 100644 --- a/python/helpers/typeshed/stdlib/2/email/MIMEText.pyi +++ b/python/helpers/typeshed/stdlib/2/email/MIMEText.pyi @@ -1,7 +1,3 @@ -# Stubs for email.MIMEText (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from email.mime.nonmultipart import MIMENonMultipart class MIMEText(MIMENonMultipart): diff --git a/python/helpers/typeshed/stdlib/2/email/_parseaddr.pyi b/python/helpers/typeshed/stdlib/2/email/_parseaddr.pyi index 97e859e7130a..beba33f19f51 100644 --- a/python/helpers/typeshed/stdlib/2/email/_parseaddr.pyi +++ b/python/helpers/typeshed/stdlib/2/email/_parseaddr.pyi @@ -1,7 +1,3 @@ -# Stubs for email._parseaddr (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any def parsedate_tz(data): ... diff --git a/python/helpers/typeshed/stdlib/2/email/mime/application.pyi b/python/helpers/typeshed/stdlib/2/email/mime/application.pyi new file mode 100644 index 000000000000..99da67287bd5 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/email/mime/application.pyi @@ -0,0 +1,11 @@ +# Stubs for email.mime.application + +from typing import Callable, Optional, Tuple, Union +from email.mime.nonmultipart import MIMENonMultipart + +_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] + +class MIMEApplication(MIMENonMultipart): + def __init__(self, _data: bytes, _subtype: str = ..., + _encoder: Callable[[MIMEApplication], None] = ..., + **_params: _ParamsType) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2/email/mime/base.pyi b/python/helpers/typeshed/stdlib/2/email/mime/base.pyi index 0a3eb4cf985f..4eaabce66747 100644 --- a/python/helpers/typeshed/stdlib/2/email/mime/base.pyi +++ b/python/helpers/typeshed/stdlib/2/email/mime/base.pyi @@ -1,6 +1,4 @@ -# Stubs for email.mime.base (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. +# NOTE: This stub is incomplete. # import message diff --git a/python/helpers/typeshed/stdlib/2/email/mime/multipart.pyi b/python/helpers/typeshed/stdlib/2/email/mime/multipart.pyi index 2bc5a9ec0961..0a7d3fa8acb0 100644 --- a/python/helpers/typeshed/stdlib/2/email/mime/multipart.pyi +++ b/python/helpers/typeshed/stdlib/2/email/mime/multipart.pyi @@ -1,7 +1,3 @@ -# Stubs for email.mime.multipart (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from email.mime.base import MIMEBase class MIMEMultipart(MIMEBase): diff --git a/python/helpers/typeshed/stdlib/2/email/mime/nonmultipart.pyi b/python/helpers/typeshed/stdlib/2/email/mime/nonmultipart.pyi index b0894ab38742..04d130e3da88 100644 --- a/python/helpers/typeshed/stdlib/2/email/mime/nonmultipart.pyi +++ b/python/helpers/typeshed/stdlib/2/email/mime/nonmultipart.pyi @@ -1,7 +1,3 @@ -# Stubs for email.mime.nonmultipart (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from email.mime.base import MIMEBase class MIMENonMultipart(MIMEBase): diff --git a/python/helpers/typeshed/stdlib/2/email/mime/text.pyi b/python/helpers/typeshed/stdlib/2/email/mime/text.pyi index b6ec4c8356cc..3b059778aa66 100644 --- a/python/helpers/typeshed/stdlib/2/email/mime/text.pyi +++ b/python/helpers/typeshed/stdlib/2/email/mime/text.pyi @@ -1,7 +1,3 @@ -# Stubs for email.mime.text (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from email.mime.nonmultipart import MIMENonMultipart class MIMEText(MIMENonMultipart): diff --git a/python/helpers/typeshed/stdlib/2/email/utils.pyi b/python/helpers/typeshed/stdlib/2/email/utils.pyi index 48d2aa35803c..293a4c3e48d4 100644 --- a/python/helpers/typeshed/stdlib/2/email/utils.pyi +++ b/python/helpers/typeshed/stdlib/2/email/utils.pyi @@ -1,7 +1,3 @@ -# Stubs for email.utils (Python 2) -# -# Derived from stub automatically generated by stubgen. - from email._parseaddr import AddressList as _AddressList from email._parseaddr import mktime_tz as mktime_tz from email._parseaddr import parsedate as _parsedate diff --git a/python/helpers/typeshed/stdlib/2/encodings/utf_8.pyi b/python/helpers/typeshed/stdlib/2/encodings/utf_8.pyi index 0111184b7fc7..d38bd58d0e43 100644 --- a/python/helpers/typeshed/stdlib/2/encodings/utf_8.pyi +++ b/python/helpers/typeshed/stdlib/2/encodings/utf_8.pyi @@ -1,14 +1,15 @@ import codecs +from typing import Text, Tuple class IncrementalEncoder(codecs.IncrementalEncoder): - pass + def encode(self, input: Text, final: bool = ...) -> bytes: ... + class IncrementalDecoder(codecs.BufferedIncrementalDecoder): - pass -class StreamWriter(codecs.StreamWriter): - pass -class StreamReader(codecs.StreamReader): - pass + def _buffer_decode(self, input: bytes, errors: str, final: bool) -> Tuple[Text, int]: ... + +class StreamWriter(codecs.StreamWriter): ... +class StreamReader(codecs.StreamReader): ... def getregentry() -> codecs.CodecInfo: ... -def encode(input: str, errors: str = ...) -> bytes: ... -def decode(input: bytes, errors: str = ...) -> str: ... +def encode(input: Text, errors: Text = ...) -> bytes: ... +def decode(input: bytes, errors: Text = ...) -> Text: ... diff --git a/python/helpers/typeshed/stdlib/2/exceptions.pyi b/python/helpers/typeshed/stdlib/2/exceptions.pyi index 299c9cbf8259..6e4bafc9a00f 100644 --- a/python/helpers/typeshed/stdlib/2/exceptions.pyi +++ b/python/helpers/typeshed/stdlib/2/exceptions.pyi @@ -1,79 +1,48 @@ -from typing import Any, Tuple, Optional - -class StandardError(Exception): ... -class ArithmeticError(StandardError): ... -class AssertionError(StandardError): ... -class AttributeError(StandardError): ... -class BaseException(object): - args = ... # type: Tuple[Any, ...] - message = ... # type: str - def __getslice__(self, start, end) -> Any: ... - def __getitem__(self, start, end) -> Any: ... - def __unicode__(self) -> unicode: ... -class BufferError(StandardError): ... -class BytesWarning(Warning): ... -class DeprecationWarning(Warning): ... -class EOFError(StandardError): ...class EnvironmentError(StandardError): - errno = ... # type: int - strerror = ... # type: str - filename = ... # type: str -class Exception(BaseException): ... -class FloatingPointError(ArithmeticError): ... -class FutureWarning(Warning): ... -class GeneratorExit(BaseException): ... -class IOError(EnvironmentError): ... -class ImportError(StandardError): ... -class ImportWarning(Warning): ... -class IndentationError(SyntaxError): ... -class IndexError(LookupError): ... -class KeyError(LookupError): ... -class KeyboardInterrupt(BaseException): ... -class LookupError(StandardError): ... -class MemoryError(StandardError): ... -class NameError(StandardError): ... -class NotImplementedError(RuntimeError): ... -class OSError(EnvironmentError): ... -class OverflowError(ArithmeticError): ... -class PendingDeprecationWarning(Warning): ... -class ReferenceError(StandardError): ... -class RuntimeError(StandardError): ... -class RuntimeWarning(Warning): ... -class StopIteration(Exception): ... -class SyntaxError(StandardError): - text = ... # type: str - print_file_and_line = ... # type: Optional[str] - filename = ... # type: str - lineno = ... # type: int - offset = ... # type: int - msg = ... # type: str -class SyntaxWarning(Warning): ... -class SystemError(StandardError): ... -class SystemExit(BaseException): - code = ... # type: int -class TabError(IndentationError): ... -class TypeError(StandardError): ... -class UnboundLocalError(NameError): ... -class UnicodeError(ValueError): ... -class UnicodeDecodeError(UnicodeError): - start = ... # type: int - reason = ... # type: str - object = ... # type: str - end = ... # type: int - encoding = ... # type: str -class UnicodeEncodeError(UnicodeError): - start = ... # type: int - reason = ... # type: str - object = ... # type: unicode - end = ... # type: int - encoding = ... # type: str -class UnicodeTranslateError(UnicodeError): - start = ... # type: int - reason = ... # type: str - object = ... # type: Any - end = ... # type: int - encoding = ... # type: str -class UnicodeWarning(Warning): ... -class UserWarning(Warning): ... -class ValueError(StandardError): ... -class Warning(Exception): ... -class ZeroDivisionError(ArithmeticError): ... +from __builtin__ import ArithmeticError as ArithmeticError +from __builtin__ import AssertionError as AssertionError +from __builtin__ import AttributeError as AttributeError +from __builtin__ import BaseException as BaseException +from __builtin__ import BufferError as BufferError +from __builtin__ import BytesWarning as BytesWarning +from __builtin__ import DeprecationWarning as DeprecationWarning +from __builtin__ import EOFError as EOFError +from __builtin__ import EnvironmentError as EnvironmentError +from __builtin__ import Exception as Exception +from __builtin__ import FloatingPointError as FloatingPointError +from __builtin__ import FutureWarning as FutureWarning +from __builtin__ import GeneratorExit as GeneratorExit +from __builtin__ import IOError as IOError +from __builtin__ import ImportError as ImportError +from __builtin__ import ImportWarning as ImportWarning +from __builtin__ import IndentationError as IndentationError +from __builtin__ import IndexError as IndexError +from __builtin__ import KeyError as KeyError +from __builtin__ import KeyboardInterrupt as KeyboardInterrupt +from __builtin__ import LookupError as LookupError +from __builtin__ import MemoryError as MemoryError +from __builtin__ import NameError as NameError +from __builtin__ import NotImplementedError as NotImplementedError +from __builtin__ import OSError as OSError +from __builtin__ import OverflowError as OverflowError +from __builtin__ import PendingDeprecationWarning as PendingDeprecationWarning +from __builtin__ import ReferenceError as ReferenceError +from __builtin__ import RuntimeError as RuntimeError +from __builtin__ import RuntimeWarning as RuntimeWarning +from __builtin__ import StandardError as StandardError +from __builtin__ import StopIteration as StopIteration +from __builtin__ import SyntaxError as SyntaxError +from __builtin__ import SyntaxWarning as SyntaxWarning +from __builtin__ import SystemError as SystemError +from __builtin__ import SystemExit as SystemExit +from __builtin__ import TabError as TabError +from __builtin__ import TypeError as TypeError +from __builtin__ import UnboundLocalError as UnboundLocalError +from __builtin__ import UnicodeError as UnicodeError +from __builtin__ import UnicodeDecodeError as UnicodeDecodeError +from __builtin__ import UnicodeEncodeError as UnicodeEncodeError +from __builtin__ import UnicodeTranslateError as UnicodeTranslateError +from __builtin__ import UnicodeWarning as UnicodeWarning +from __builtin__ import UserWarning as UserWarning +from __builtin__ import ValueError as ValueError +from __builtin__ import Warning as Warning +from __builtin__ import ZeroDivisionError as ZeroDivisionError diff --git a/python/helpers/typeshed/stdlib/2/fcntl.pyi b/python/helpers/typeshed/stdlib/2/fcntl.pyi index 5e7da7fef7cd..c7ff895e4fdc 100644 --- a/python/helpers/typeshed/stdlib/2/fcntl.pyi +++ b/python/helpers/typeshed/stdlib/2/fcntl.pyi @@ -1,4 +1,4 @@ -from typing import Any, Union +from typing import Any, Union, IO import io FASYNC = ... # type: int @@ -72,7 +72,7 @@ LOCK_SH = ... # type: int LOCK_UN = ... # type: int LOCK_WRITE = ... # type: int -_ANYFILE = Union[int, io.IOBase] +_ANYFILE = Union[int, IO] # TODO All these return either int or bytes depending on the value of # cmd (not on the type of arg). diff --git a/python/helpers/typeshed/stdlib/2/functools.pyi b/python/helpers/typeshed/stdlib/2/functools.pyi index f3bcc905b251..a0e1a8fa2fa4 100644 --- a/python/helpers/typeshed/stdlib/2/functools.pyi +++ b/python/helpers/typeshed/stdlib/2/functools.pyi @@ -21,7 +21,7 @@ WRAPPER_ASSIGNMENTS = ... # type: Sequence[str] WRAPPER_UPDATES = ... # type: Sequence[str] def update_wrapper(wrapper: _AnyCallable, wrapped: _AnyCallable, assigned: Sequence[str] = ..., - updated: Sequence[str] = ...) -> None: ... + updated: Sequence[str] = ...) -> _AnyCallable: ... def wraps(wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> Callable[[_AnyCallable], _AnyCallable]: ... def total_ordering(cls: type) -> type: ... def cmp_to_key(mycmp: Callable[[_T, _T], int]) -> Callable[[_T], Any]: ... diff --git a/python/helpers/typeshed/stdlib/2/genericpath.pyi b/python/helpers/typeshed/stdlib/2/genericpath.pyi index 85f1c0f84174..24bbbba3b3ce 100644 --- a/python/helpers/typeshed/stdlib/2/genericpath.pyi +++ b/python/helpers/typeshed/stdlib/2/genericpath.pyi @@ -1,14 +1,12 @@ -# Stubs for genericpath (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. +from typing import AnyStr, List class _unicode: ... -def exists(path): ... -def isfile(path): ... -def isdir(s): ... -def getsize(filename): ... -def getmtime(filename): ... -def getatime(filename): ... -def getctime(filename): ... -def commonprefix(m): ... +def commonprefix(list: List[AnyStr]) -> AnyStr: ... +def exists(path: unicode) -> bool: ... +def getatime(path: unicode) -> float: ... +def getmtime(path: unicode) -> float: ... +def getctime(path: unicode) -> float: ... +def getsize(path: unicode) -> int: ... +def isfile(path: unicode) -> bool: ... +def isdir(path: unicode) -> bool: ... diff --git a/python/helpers/typeshed/stdlib/2/glob.pyi b/python/helpers/typeshed/stdlib/2/glob.pyi index 9b70e5cb0e55..667a51f2f9d5 100644 --- a/python/helpers/typeshed/stdlib/2/glob.pyi +++ b/python/helpers/typeshed/stdlib/2/glob.pyi @@ -1,4 +1,6 @@ -from typing import List, Iterator, AnyStr +from typing import List, Iterator, Union, AnyStr def glob(pathname: AnyStr) -> List[AnyStr]: ... def iglob(pathname: AnyStr) -> Iterator[AnyStr]: ... +def glob1(dirname: Union[str, unicode], pattern: AnyStr) -> List[AnyStr]: ... +def glob0(dirname: Union[str, unicode], basename: AnyStr) -> List[AnyStr]: ... diff --git a/python/helpers/typeshed/stdlib/2/gzip.pyi b/python/helpers/typeshed/stdlib/2/gzip.pyi index 30d9e8377b22..3177bbaf9e89 100644 --- a/python/helpers/typeshed/stdlib/2/gzip.pyi +++ b/python/helpers/typeshed/stdlib/2/gzip.pyi @@ -1,8 +1,4 @@ -# Stubs for gzip (Python 2) -# -# NOTE: Based on a dynamically typed stub automatically generated by stubgen. - -from typing import Any, IO +from typing import Any, IO, Text import io class GzipFile(io.BufferedIOBase): @@ -18,7 +14,7 @@ class GzipFile(io.BufferedIOBase): fileobj = ... # type: Any offset = ... # type: Any mtime = ... # type: Any - def __init__(self, filename: str = ..., mode: str = ..., compresslevel: int = ..., + def __init__(self, filename: str = ..., mode: Text = ..., compresslevel: int = ..., fileobj: IO[str] = ..., mtime: float = ...) -> None: ... @property def filename(self): ... @@ -38,4 +34,4 @@ class GzipFile(io.BufferedIOBase): def seek(self, offset, whence=...): ... def readline(self, size=...): ... -def open(filename: str, mode: str = ..., compresslevel: int = ...) -> GzipFile: ... +def open(filename: str, mode: Text = ..., compresslevel: int = ...) -> GzipFile: ... diff --git a/python/helpers/typeshed/stdlib/2/hashlib.pyi b/python/helpers/typeshed/stdlib/2/hashlib.pyi index 375cc59aa88b..fa1dbce59131 100644 --- a/python/helpers/typeshed/stdlib/2/hashlib.pyi +++ b/python/helpers/typeshed/stdlib/2/hashlib.pyi @@ -2,12 +2,14 @@ from typing import Tuple, Union -_DataType = Union[str, bytearray, buffer, memoryview] +_DataType = Union[str, unicode, bytearray, buffer, memoryview] -class _hash(object): - # This is not actually in the module namespace. - digest_size = 0 +class _hash(object): # This is not actually in the module namespace. + name = ... # type: str block_size = 0 + digest_size = 0 + digestsize = 0 + def __init__(self, arg: _DataType = ...) -> None: ... def update(self, arg: _DataType) -> None: ... def digest(self) -> str: ... def hexdigest(self) -> str: ... diff --git a/python/helpers/typeshed/stdlib/2/heapq.pyi b/python/helpers/typeshed/stdlib/2/heapq.pyi index 4a7a65f6209e..00abb31a6c59 100644 --- a/python/helpers/typeshed/stdlib/2/heapq.pyi +++ b/python/helpers/typeshed/stdlib/2/heapq.pyi @@ -1,4 +1,4 @@ -from typing import TypeVar, List, Iterable, Any, Callable +from typing import TypeVar, List, Iterable, Any, Callable, Optional _T = TypeVar('_T') @@ -11,5 +11,6 @@ def heapify(x: List[_T]) -> None: ... def heapreplace(heap: List[_T], item: _T) -> _T: raise IndexError() # if heap is empty def merge(*iterables: Iterable[_T]) -> Iterable[_T]: ... -def nlargest(n: int, iterable: Iterable[_T]) -> List[_T]: ... +def nlargest(n: int, iterable: Iterable[_T], + key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ... def nsmallest(n: int, iterable: Iterable[_T]) -> List[_T]: ... diff --git a/python/helpers/typeshed/stdlib/2/htmlentitydefs.pyi b/python/helpers/typeshed/stdlib/2/htmlentitydefs.pyi index c90f3a9e52ef..08445e6d946b 100644 --- a/python/helpers/typeshed/stdlib/2/htmlentitydefs.pyi +++ b/python/helpers/typeshed/stdlib/2/htmlentitydefs.pyi @@ -1,7 +1,3 @@ -# Stubs for htmlentitydefs (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Mapping name2codepoint = ... # type: Mapping[str, int] diff --git a/python/helpers/typeshed/stdlib/2/inspect.pyi b/python/helpers/typeshed/stdlib/2/inspect.pyi index a3569346c648..d5bb4d50f6db 100644 --- a/python/helpers/typeshed/stdlib/2/inspect.pyi +++ b/python/helpers/typeshed/stdlib/2/inspect.pyi @@ -18,7 +18,7 @@ def ismodule(object: object) -> bool: ... def isclass(object: object) -> bool: ... def ismethod(object: object) -> bool: ... def isfunction(object: object) -> bool: ... -def isisgeneratorfunction(object: object) -> bool: ... +def isgeneratorfunction(object: object) -> bool: ... def isgenerator(object: object) -> bool: ... def istraceback(object: object) -> bool: ... def isframe(object: object) -> bool: ... diff --git a/python/helpers/typeshed/stdlib/2/io.pyi b/python/helpers/typeshed/stdlib/2/io.pyi index 330b9843a124..e78ec50687d6 100644 --- a/python/helpers/typeshed/stdlib/2/io.pyi +++ b/python/helpers/typeshed/stdlib/2/io.pyi @@ -5,101 +5,41 @@ # Only a subset of functionality is included. from typing import List, BinaryIO, TextIO, IO, overload, Iterator, Iterable, Any, Union, Optional +import _io -DEFAULT_BUFFER_SIZE = 0 +from _io import BlockingIOError as BlockingIOError +from _io import BufferedRWPair as BufferedRWPair +from _io import BufferedRandom as BufferedRandom +from _io import BufferedReader as BufferedReader +from _io import BufferedWriter as BufferedWriter +from _io import BytesIO as BytesIO +from _io import DEFAULT_BUFFER_SIZE as DEFAULT_BUFFER_SIZE +from _io import FileIO as FileIO +from _io import IncrementalNewlineDecoder as IncrementalNewlineDecoder +from _io import StringIO as StringIO +from _io import TextIOWrapper as TextIOWrapper +from _io import UnsupportedOperation as UnsupportedOperation +from _io import open as open -def open(file: Union[str, unicode, int], +def _OpenWrapper(file: Union[str, unicode, int], mode: unicode = ..., buffering: int = ..., encoding: unicode = ..., errors: unicode = ..., newline: unicode = ..., closefd: bool = ...) -> IO[Any]: ... -class IOBase: - # TODO - ... +SEEK_SET = ... # type: int +SEEK_CUR = ... # type: int +SEEK_END = ... # type: int -class BytesIO(BinaryIO): - def __init__(self, initial_bytes: str = ...) -> None: ... - # TODO getbuffer - # TODO see comments in BinaryIO for missing functionality - def close(self) -> None: ... - def closed(self) -> bool: ... - def fileno(self) -> int: ... - def flush(self) -> None: ... - def isatty(self) -> bool: ... - def read(self, n: int = ...) -> str: ... - def readable(self) -> bool: ... - def readline(self, limit: int = ...) -> str: ... - def readlines(self, hint: int = ...) -> List[str]: ... - def seek(self, offset: int, whence: int = ...) -> int: ... - def seekable(self) -> bool: ... - def tell(self) -> int: ... - def truncate(self, size: Optional[int] = ...) -> int: ... - def writable(self) -> bool: ... - def write(self, s: str) -> int: ... - def writelines(self, lines: Iterable[str]) -> None: ... - def getvalue(self) -> str: ... - def read1(self) -> str: ... - def __iter__(self) -> Iterator[str]: ... - def next(self) -> str: ... - def __enter__(self) -> 'BytesIO': ... - def __exit__(self, type, value, traceback) -> bool: ... +class IOBase(_io._IOBase): ... -class StringIO(TextIO): - def __init__(self, initial_value: unicode = ..., - newline: unicode = ...) -> None: ... - # TODO see comments in BinaryIO for missing functionality - name = ... # type: str - def close(self) -> None: ... - def closed(self) -> bool: ... - def fileno(self) -> int: ... - def flush(self) -> None: ... - def isatty(self) -> bool: ... - def read(self, n: int = ...) -> unicode: ... - def readable(self) -> bool: ... - def readline(self, limit: int = ...) -> unicode: ... - def readlines(self, hint: int = ...) -> List[unicode]: ... - def seek(self, offset: int, whence: int = ...) -> int: ... - def seekable(self) -> bool: ... - def tell(self) -> int: ... - def truncate(self, size: Optional[int] = ...) -> int: ... - def writable(self) -> bool: ... - def write(self, s: unicode) -> int: ... - def writelines(self, lines: Iterable[unicode]) -> None: ... - def getvalue(self) -> unicode: ... +class RawIOBase(_io._RawIOBase, IOBase): + pass - def __iter__(self) -> Iterator[unicode]: ... - def next(self) -> unicode: ... - def __enter__(self) -> 'StringIO': ... - def __exit__(self, type, value, traceback) -> bool: ... +class BufferedIOBase(_io._BufferedIOBase, IOBase): + pass -class TextIOWrapper(TextIO): - # write_through is undocumented but used by subprocess - def __init__(self, buffer: IO[str], encoding: unicode = ..., - errors: unicode = ..., newline: unicode = ..., - line_buffering: bool = ..., - write_through: bool = ...) -> None: ... - # TODO see comments in BinaryIO for missing functionality - def close(self) -> None: ... - def closed(self) -> bool: ... - def fileno(self) -> int: ... - def flush(self) -> None: ... - def isatty(self) -> bool: ... - def read(self, n: int = ...) -> unicode: ... - def readable(self) -> bool: ... - def readline(self, limit: int = ...) -> unicode: ... - def readlines(self, hint: int = ...) -> List[unicode]: ... - def seek(self, offset: int, whence: int = ...) -> int: ... - def seekable(self) -> bool: ... - def tell(self) -> int: ... - def truncate(self, size: Optional[int] = ...) -> int: ... - def writable(self) -> bool: ... - def write(self, s: unicode) -> int: ... - def writelines(self, lines: Iterable[unicode]) -> None: ... - - def __iter__(self) -> Iterator[unicode]: ... - def next(self) -> unicode: ... - def __enter__(self) -> StringIO: ... - def __exit__(self, type, value, traceback) -> bool: ... - -class BufferedIOBase(IOBase): ... +# Note: In the actual io.py, TextIOBase subclasses IOBase. +# (Which we don't do here because we don't want to subclass both TextIO and BinaryIO.) +class TextIOBase(_io._TextIOBase): + pass diff --git a/python/helpers/typeshed/stdlib/2/itertools.pyi b/python/helpers/typeshed/stdlib/2/itertools.pyi index 644d9f1b1042..31e34be1e972 100644 --- a/python/helpers/typeshed/stdlib/2/itertools.pyi +++ b/python/helpers/typeshed/stdlib/2/itertools.pyi @@ -26,9 +26,9 @@ class chain(Iterator[_T], Generic[_T]): def compress(data: Iterable[_T], selectors: Iterable[Any]) -> Iterator[_T]: ... def dropwhile(predicate: Callable[[_T], Any], iterable: Iterable[_T]) -> Iterator[_T]: ... -def ifilter(predicate: Callable[[_T], Any], +def ifilter(predicate: Optional[Callable[[_T], Any]], iterable: Iterable[_T]) -> Iterator[_T]: ... -def ifilterfalse(predicate: Callable[[_T], Any], +def ifilterfalse(predicate: Optional[Callable[[_T], Any]], iterable: Iterable[_T]) -> Iterator[_T]: ... @overload @@ -40,7 +40,7 @@ def groupby(iterable: Iterable[_T], @overload def islice(iterable: Iterable[_T], stop: int) -> Iterator[_T]: ... @overload -def islice(iterable: Iterable[_T], start: int, stop: Optional[int], +def islice(iterable: Iterable[_T], start: Optional[int], stop: Optional[int], step: int = ...) -> Iterator[_T]: ... _T1 = TypeVar('_T1') @@ -60,7 +60,7 @@ def imap(func: Callable[[_T1, _T2], _S], def starmap(func: Any, iterable: Iterable[Any]) -> Iterator[Any]: ... def takewhile(predicate: Callable[[_T], Any], iterable: Iterable[_T]) -> Iterator[_T]: ... -def tee(iterable: Iterable[Any], n: int = ...) -> Iterator[Any]: ... +def tee(iterable: Iterable[_T], n: int = ...) -> Tuple[Iterator[_T], ...]: ... @overload def izip(iter1: Iterable[_T1]) -> Iterator[Tuple[_T1]]: ... @@ -93,9 +93,43 @@ def izip(iter1: Iterable[Any], iter2: Iterable[Any], def izip_longest(*p: Iterable[Any], fillvalue: Any = ...) -> Iterator[Any]: ... -# TODO: Return type should be Iterator[Tuple[..]], but unknown tuple shape. -# Iterator[Sequence[_T]] loses this type information. -def product(*p: Iterable[_T], repeat: int = ...) -> Iterator[Sequence[_T]]: ... +@overload +def product(iter1: Iterable[_T1]) -> Iterator[Tuple[_T1]]: ... +@overload +def product(iter1: Iterable[_T1], + iter2: Iterable[_T2]) -> Iterator[Tuple[_T1, _T2]]: ... +@overload +def product(iter1: Iterable[_T1], + iter2: Iterable[_T2], + iter3: Iterable[_T3]) -> Iterator[Tuple[_T1, _T2, _T3]]: ... +@overload +def product(iter1: Iterable[_T1], + iter2: Iterable[_T2], + iter3: Iterable[_T3], + iter4: Iterable[_T4]) -> Iterator[Tuple[_T1, _T2, _T3, _T4]]: ... +@overload +def product(iter1: Iterable[_T1], + iter2: Iterable[_T2], + iter3: Iterable[_T3], + iter4: Iterable[_T4], + iter5: Iterable[_T5]) -> Iterator[Tuple[_T1, _T2, _T3, _T4, _T5]]: ... +@overload +def product(iter1: Iterable[_T1], + iter2: Iterable[_T2], + iter3: Iterable[_T3], + iter4: Iterable[_T4], + iter5: Iterable[_T5], + iter6: Iterable[_T6]) -> Iterator[Tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ... +@overload +def product(iter1: Iterable[Any], + iter2: Iterable[Any], + iter3: Iterable[Any], + iter4: Iterable[Any], + iter5: Iterable[Any], + iter6: Iterable[Any], + iter7: Iterable[Any], *iterables: Iterable) -> Iterator[Tuple]: ... +@overload +def product(*iter: Iterable[_T], repeat: int) -> Iterator[Tuple[_T, ...]]: ... def permutations(iterable: Iterable[_T], r: int = ...) -> Iterator[Sequence[_T]]: ... diff --git a/python/helpers/typeshed/stdlib/2/macpath.pyi b/python/helpers/typeshed/stdlib/2/macpath.pyi new file mode 120000 index 000000000000..d2d185799bcc --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/macpath.pyi @@ -0,0 +1 @@ +posixpath.pyi \ No newline at end of file diff --git a/python/helpers/typeshed/stdlib/2/md5.pyi b/python/helpers/typeshed/stdlib/2/md5.pyi index 3488466afdbd..fe6ad719d110 100644 --- a/python/helpers/typeshed/stdlib/2/md5.pyi +++ b/python/helpers/typeshed/stdlib/2/md5.pyi @@ -1,11 +1,6 @@ # Stubs for Python 2.7 md5 stdlib module -class md5(object): - def update(self, arg: str) -> None: ... - def digest(self) -> str: ... - def hexdigest(self) -> str: ... - def copy(self) -> md5: ... +from hashlib import md5 as md5, md5 as new -def new(string: str = ...) -> md5: ... blocksize = 0 digest_size = 0 diff --git a/python/helpers/typeshed/stdlib/2/mimetools.pyi b/python/helpers/typeshed/stdlib/2/mimetools.pyi index abae2b540b4e..a2651318c1cf 100644 --- a/python/helpers/typeshed/stdlib/2/mimetools.pyi +++ b/python/helpers/typeshed/stdlib/2/mimetools.pyi @@ -1,7 +1,3 @@ -# Stubs for mimetools (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any import rfc822 diff --git a/python/helpers/typeshed/stdlib/2/multiprocessing/__init__.pyi b/python/helpers/typeshed/stdlib/2/multiprocessing/__init__.pyi index c830c8b89c9f..556d8cf75196 100644 --- a/python/helpers/typeshed/stdlib/2/multiprocessing/__init__.pyi +++ b/python/helpers/typeshed/stdlib/2/multiprocessing/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for multiprocessing (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from multiprocessing.process import Process as Process, current_process as current_process, active_children as active_children from multiprocessing.util import SUBDEBUG as SUBDEBUG, SUBWARNING as SUBWARNING diff --git a/python/helpers/typeshed/stdlib/2/multiprocessing/process.pyi b/python/helpers/typeshed/stdlib/2/multiprocessing/process.pyi index 8d4af5d06d4c..c4a84a42179e 100644 --- a/python/helpers/typeshed/stdlib/2/multiprocessing/process.pyi +++ b/python/helpers/typeshed/stdlib/2/multiprocessing/process.pyi @@ -1,7 +1,3 @@ -# Stubs for multiprocessing.process (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any def current_process(): ... diff --git a/python/helpers/typeshed/stdlib/2/multiprocessing/util.pyi b/python/helpers/typeshed/stdlib/2/multiprocessing/util.pyi index e660fab0ceab..7d116273d1db 100644 --- a/python/helpers/typeshed/stdlib/2/multiprocessing/util.pyi +++ b/python/helpers/typeshed/stdlib/2/multiprocessing/util.pyi @@ -1,7 +1,3 @@ -# Stubs for multiprocessing.util (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any import threading diff --git a/python/helpers/typeshed/stdlib/2/mutex.pyi b/python/helpers/typeshed/stdlib/2/mutex.pyi new file mode 100644 index 000000000000..df1e71cc1dec --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/mutex.pyi @@ -0,0 +1,15 @@ +# Source: https://hg.python.org/cpython/file/2.7/Lib/mutex.py + +from collections import deque +from typing import Any, Callable, TypeVar + +_ArgType = TypeVar('_ArgType') + +class mutex: + locked = ... # type: bool + queue = ... # type: deque + def __init__(self) -> None: ... + def test(self) -> bool: ... + def testandset(self) -> bool: ... + def lock(self, function: Callable[[_ArgType], Any], argument: _ArgType) -> None: ... + def unlock(self) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2/ntpath.pyi b/python/helpers/typeshed/stdlib/2/ntpath.pyi new file mode 120000 index 000000000000..d2d185799bcc --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/ntpath.pyi @@ -0,0 +1 @@ +posixpath.pyi \ No newline at end of file diff --git a/python/helpers/typeshed/stdlib/2/nturl2path.pyi b/python/helpers/typeshed/stdlib/2/nturl2path.pyi new file mode 100644 index 000000000000..b87b008e4cec --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/nturl2path.pyi @@ -0,0 +1,4 @@ +from typing import AnyStr + +def url2pathname(url: AnyStr) -> AnyStr: ... +def pathname2url(p: AnyStr) -> AnyStr: ... diff --git a/python/helpers/typeshed/stdlib/2/os/__init__.pyi b/python/helpers/typeshed/stdlib/2/os/__init__.pyi index c11d9728f1b7..3951ba6c99af 100644 --- a/python/helpers/typeshed/stdlib/2/os/__init__.pyi +++ b/python/helpers/typeshed/stdlib/2/os/__init__.pyi @@ -1,103 +1,133 @@ -# created from https://docs.python.org/2/library/os.html +# Stubs for os +# Ron Murawski +from builtins import OSError as error +from io import TextIOWrapper as _TextIOWrapper +from posix import stat_result as stat_result # TODO: use this, see https://github.com/python/mypy/issues/3078 +import sys from typing import ( Mapping, MutableMapping, Dict, List, Any, Tuple, Iterator, overload, Union, AnyStr, - Optional, Generic, Set, Callable, Text, Sequence, IO, NamedTuple + Optional, Generic, Set, Callable, Text, Sequence, IO, NamedTuple, TypeVar ) -from . import path +from . import path as path from mypy_extensions import NoReturn -error = OSError -SEEK_SET = 0 -SEEK_CUR = 0 -SEEK_END = 0 +_T = TypeVar('_T') -# More constants, copied from stdlib/3/os/__init__.pyi -O_RDONLY = 0 -O_WRONLY = 0 -O_RDWR = 0 -O_APPEND = 0 -O_CREAT = 0 -O_EXCL = 0 -O_TRUNC = 0 -O_DSYNC = 0 # Unix only -O_RSYNC = 0 # Unix only -O_SYNC = 0 # Unix only -O_NDELAY = 0 # Unix only -O_NONBLOCK = 0 # Unix only -O_NOCTTY = 0 # Unix only -O_SHLOCK = 0 # Unix only -O_EXLOCK = 0 # Unix only -O_BINARY = 0 # Windows only -O_NOINHERIT = 0 # Windows only -O_SHORT_LIVED = 0 # Windows only -O_TEMPORARY = 0 # Windows only -O_RANDOM = 0 # Windows only -O_SEQUENTIAL = 0 # Windows only -O_TEXT = 0 # Windows only -O_ASYNC = 0 # Gnu extension if in C library -O_DIRECT = 0 # Gnu extension if in C library -O_DIRECTORY = 0 # Gnu extension if in C library -O_NOFOLLOW = 0 # Gnu extension if in C library -O_NOATIME = 0 # Gnu extension if in C library -O_LARGEFILE = 0 # Gnu extension if in C library +# ----- os variables ----- -curdir = ... # type: str -pardir = ... # type: str -sep = ... # type: str -altsep = ... # type: str -extsep = ... # type: str -pathsep = ... # type: str -defpath = ... # type: str -linesep = ... # type: str -devnull = ... # type: str -name = ... # type: str +if sys.version_info >= (3, 2): + supports_bytes_environ: bool -F_OK = 0 -R_OK = 0 -W_OK = 0 -X_OK = 0 +if sys.version_info >= (3, 3): + supports_dir_fd: Set[Callable[..., Any]] + supports_fd: Set[Callable[..., Any]] + supports_effective_ids: Set[Callable[..., Any]] + supports_follow_symlinks: Set[Callable[..., Any]] -class _Environ(MutableMapping[str, str]): - def copy(self) -> Dict[str, str]: ... +SEEK_SET: int +SEEK_CUR: int +SEEK_END: int -environ = ... # type: _Environ -confstr_names = ... # type: Mapping[str, int] # Unix only -pathconf_names = ... # type: Mapping[str, int] # Unix only -sysconf_names = ... # type: Mapping[str, int] # Unix only -EX_OK = 0 # Unix only -EX_USAGE = 0 # Unix only -EX_DATAERR = 0 # Unix only -EX_NOINPUT = 0 # Unix only -EX_NOUSER = 0 # Unix only -EX_NOHOST = 0 # Unix only -EX_UNAVAILABLE = 0 # Unix only -EX_SOFTWARE = 0 # Unix only -EX_OSERR = 0 # Unix only -EX_OSFILE = 0 # Unix only -EX_CANTCREAT = 0 # Unix only -EX_IOERR = 0 # Unix only -EX_TEMPFAIL = 0 # Unix only -EX_PROTOCOL = 0 # Unix only -EX_NOPERM = 0 # Unix only -EX_CONFIG = 0 # Unix only -P_NOWAIT = 0 -P_NOWAITO = 0 -P_WAIT = 0 -# P_DETACH = 0 # Windows only -# P_OVERLAY = 0 # Windows only +O_RDONLY: int +O_WRONLY: int +O_RDWR: int +O_APPEND: int +O_CREAT: int +O_EXCL: int +O_TRUNC: int +O_DSYNC: int # Unix only +O_RSYNC: int # Unix only +O_SYNC: int # Unix only +O_NDELAY: int # Unix only +O_NONBLOCK: int # Unix only +O_NOCTTY: int # Unix only +O_SHLOCK: int # Unix only +O_EXLOCK: int # Unix only +O_BINARY: int # Windows only +O_NOINHERIT: int # Windows only +O_SHORT_LIVED: int # Windows only +O_TEMPORARY: int # Windows only +O_RANDOM: int # Windows only +O_SEQUENTIAL: int # Windows only +O_TEXT: int # Windows only +O_ASYNC: int # Gnu extension if in C library +O_DIRECT: int # Gnu extension if in C library +O_DIRECTORY: int # Gnu extension if in C library +O_NOFOLLOW: int # Gnu extension if in C library +O_NOATIME: int # Gnu extension if in C library +O_LARGEFILE: int # Gnu extension if in C library + +curdir: str +pardir: str +sep: str +altsep: str +extsep: str +pathsep: str +defpath: str +linesep: str +devnull: str +name: str + +F_OK: int +R_OK: int +W_OK: int +X_OK: int + +class _Environ(MutableMapping[AnyStr, AnyStr], Generic[AnyStr]): + def copy(self) -> Dict[AnyStr, AnyStr]: ... + +environ: _Environ[str] +if sys.version_info >= (3, 2): + environb: _Environ[bytes] + +confstr_names: Dict[str, int] # Unix only +pathconf_names: Dict[str, int] # Unix only +sysconf_names: Dict[str, int] # Unix only + +EX_OK: int # Unix only +EX_USAGE: int # Unix only +EX_DATAERR: int # Unix only +EX_NOINPUT: int # Unix only +EX_NOUSER: int # Unix only +EX_NOHOST: int # Unix only +EX_UNAVAILABLE: int # Unix only +EX_SOFTWARE: int # Unix only +EX_OSERR: int # Unix only +EX_OSFILE: int # Unix only +EX_CANTCREAT: int # Unix only +EX_IOERR: int # Unix only +EX_TEMPFAIL: int # Unix only +EX_PROTOCOL: int # Unix only +EX_NOPERM: int # Unix only +EX_CONFIG: int # Unix only +EX_NOTFOUND: int # Unix only + +P_NOWAIT: int +P_NOWAITO: int +P_WAIT: int +if sys.platform == 'win32': + P_DETACH: int # Windows only + P_OVERLAY: int # Windows only # wait()/waitpid() options -WNOHANG = 0 # Unix only -WCONTINUED = 0 # some Unix systems -WUNTRACED = 0 # Unix only +WNOHANG: int # Unix only +WCONTINUED: int # some Unix systems +WUNTRACED: int # Unix only + +TMP_MAX: int # Undocumented, but used by tempfile + +# ----- os classes (structures) ----- +if sys.version_info >= (3, 6): + from builtins import _PathLike as PathLike # See comment in builtins + +_PathType = path._PathType -TMP_MAX = 0 # Undocumented, but used by tempfile -_PathType = Union[bytes, Text] _StatVFS = NamedTuple('_StatVFS', [('f_bsize', int), ('f_frsize', int), ('f_blocks', int), ('f_bfree', int), ('f_bavail', int), ('f_files', int), ('f_ffree', int), ('f_favail', int), ('f_flag', int), ('f_namemax', int)]) + def ctermid() -> str: ... # Unix only def getegid() -> int: ... # Unix only def geteuid() -> int: ... # Unix only @@ -112,8 +142,6 @@ def getppid() -> int: ... def getresuid() -> Tuple[int, int, int]: ... # Unix only def getresgid() -> Tuple[int, int, int]: ... # Unix only def getuid() -> int: ... # Unix only -def getenv(varname: unicode, value: unicode = ...) -> str: ... -def putenv(varname: unicode, value: unicode) -> None: ... def setegid(egid: int) -> None: ... # Unix only def seteuid(euid: int) -> None: ... # Unix only def setgid(gid: int) -> None: ... # Unix only @@ -130,7 +158,14 @@ def setuid(uid: int) -> None: ... # Unix only def strerror(code: int) -> str: ... def umask(mask: int) -> int: ... def uname() -> Tuple[str, str, str, str, str]: ... # Unix only -def unsetenv(varname: str) -> None: ... + +@overload +def getenv(key: Text) -> Optional[str]: ... +@overload +def getenv(key: Text, default: _T) -> Union[str, _T]: ... +def putenv(key: Union[bytes, Text], value: Union[bytes, Text]) -> None: ... +def unsetenv(key: Union[bytes, Text]) -> None: ... + def fdopen(fd: int, *args, **kwargs) -> IO[Any]: ... def close(fd: int) -> None: ... def closerange(fd_low: int, fd_high: int) -> None: ... @@ -191,12 +226,21 @@ def stat_float_times() -> bool: ... def statvfs(path: _PathType) -> _StatVFS: ... # Unix only def symlink(source: _PathType, link_name: _PathType) -> None: ... def unlink(path: _PathType) -> None: ... -def utime(path: _PathType, times: Optional[Tuple[float, float]]) -> None: ... +# TODO: add ns, dir_fd, follow_symlinks argument +if sys.version_info >= (3, 0): + def utime(path: _PathType, times: Optional[Tuple[float, float]] = ...) -> None: ... +else: + def utime(path: _PathType, times: Optional[Tuple[float, float]]) -> None: ... -# TODO onerror: function from OSError to void -def walk(top: AnyStr, topdown: bool = ..., onerror: Any = ..., - followlinks: bool = ...) -> Iterator[Tuple[AnyStr, List[AnyStr], - List[AnyStr]]]: ... +if sys.version_info >= (3, 6): + def walk(top: Union[AnyStr, PathLike[AnyStr]], topdown: bool = ..., + onerror: Optional[Callable[[OSError], Any]] = ..., + followlinks: bool = ...) -> Iterator[Tuple[AnyStr, List[AnyStr], + List[AnyStr]]]: ... +else: + def walk(top: AnyStr, topdown: bool = ..., onerror: Optional[Callable[[OSError], Any]] = ..., + followlinks: bool = ...) -> Iterator[Tuple[AnyStr, List[AnyStr], + List[AnyStr]]]: ... def abort() -> NoReturn: ... # These are defined as execl(file, *args) but the first *arg is mandatory. @@ -221,11 +265,19 @@ def forkpty() -> Tuple[int, int]: ... # some flavors of Unix def kill(pid: int, sig: int) -> None: ... def killpg(pgid: int, sig: int) -> None: ... # Unix only def nice(increment: int) -> int: ... # Unix only -# TODO: plock, popen*, P_* -def popen(command: str, *args, **kwargs) -> Optional[IO[Any]]: ... -def popen2(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any]]: ... -def popen3(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any], IO[Any]]: ... -def popen4(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any]]: ... +def plock(op: int) -> None: ... # Unix only ???op is int? + +if sys.version_info >= (3, 0): + class popen(_TextIOWrapper): + # TODO 'b' modes or bytes command not accepted? + def __init__(self, command: str, mode: str = ..., + bufsize: int = ...) -> None: ... + def close(self) -> Any: ... # may return int +else: + def popen(command: str, *args, **kwargs) -> Optional[IO[Any]]: ... + def popen2(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any]]: ... + def popen3(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any], IO[Any]]: ... + def popen4(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any]]: ... def spawnl(mode: int, path: _PathType, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ... def spawnle(mode: int, path: _PathType, arg0: Union[bytes, Text], @@ -261,10 +313,34 @@ def getloadavg() -> Tuple[float, float, float]: ... # Unix only def sysconf(name: Union[str, int]) -> int: ... # Unix only def urandom(n: int) -> bytes: ... -def tmpfile() -> IO[Any]: ... -def tmpnam() -> str: ... -def tempnam(dir: str = ..., prefix: str = ...) -> str: ... +if sys.version_info >= (3, 0): + def sched_getaffinity(id: int) -> Set[int]: ... +if sys.version_info >= (3, 3): + class waitresult: + si_pid: int + def waitid(idtype: int, id: int, options: int) -> waitresult: ... -P_ALL = 0 -WEXITED = 0 -WNOWAIT = 0 +if sys.version_info < (3, 0): + def tmpfile() -> IO[Any]: ... + def tmpnam() -> str: ... + def tempnam(dir: str = ..., prefix: str = ...) -> str: ... + +P_ALL: int +WEXITED: int +WNOWAIT: int + +if sys.version_info >= (3, 3): + def sync() -> None: ... # Unix only + + def truncate(path: Union[_PathType, int], length: int) -> None: ... # Unix only up to version 3.4 + + def fwalk(top: AnyStr = ..., topdown: bool = ..., + onerror: Callable = ..., *, follow_symlinks: bool = ..., + dir_fd: int = ...) -> Iterator[Tuple[AnyStr, List[AnyStr], + List[AnyStr], int]]: ... # Unix only + + terminal_size = NamedTuple('terminal_size', [('columns', int), ('lines', int)]) + def get_terminal_size(fd: int = ...) -> terminal_size: ... + +if sys.version_info >= (3, 4): + def cpu_count() -> Optional[int]: ... diff --git a/python/helpers/typeshed/stdlib/2/os/path.pyi b/python/helpers/typeshed/stdlib/2/os/path.pyi index bfd88a454622..961c7a8838cc 100644 --- a/python/helpers/typeshed/stdlib/2/os/path.pyi +++ b/python/helpers/typeshed/stdlib/2/os/path.pyi @@ -3,8 +3,19 @@ # based on http://docs.python.org/3.2/library/os.path.html # adapted for 2.7 by Michal Pokorny +import sys +from typing import ( + overload, List, Any, AnyStr, Sequence, Tuple, BinaryIO, TextIO, + TypeVar, Union, Text, Callable +) -from typing import overload, List, Any, Tuple, BinaryIO, TextIO, TypeVar, Callable, AnyStr +_T = TypeVar('_T') + +if sys.version_info >= (3, 6): + from builtins import _PathLike + _PathType = Union[bytes, Text, _PathLike] +else: + _PathType = Union[bytes, Text] # ----- os.path variables ----- supports_unicode_filenames = False @@ -22,34 +33,60 @@ devnull = ... # type: str def abspath(path: AnyStr) -> AnyStr: ... def basename(path: AnyStr) -> AnyStr: ... -def commonprefix(list: List[AnyStr]) -> AnyStr: ... +if sys.version_info >= (3, 5): + def commonpath(paths: Sequence[AnyStr]) -> AnyStr: ... + +# NOTE: Empty lists results in '' (str) regardless of contained type. +# Also, in Python 2 mixed sequences of Text and bytes results in either Text or bytes +# So, fall back to Any +def commonprefix(list: Sequence[AnyStr]) -> Any: ... + def dirname(path: AnyStr) -> AnyStr: ... -def exists(path: unicode) -> bool: ... -def lexists(path: unicode) -> bool: ... +def exists(path: _PathType) -> bool: ... +def lexists(path: _PathType) -> bool: ... def expanduser(path: AnyStr) -> AnyStr: ... def expandvars(path: AnyStr) -> AnyStr: ... # These return float if os.stat_float_times() == True, # but int is a subclass of float. -def getatime(path: unicode) -> float: ... -def getmtime(path: unicode) -> float: ... -def getctime(path: unicode) -> float: ... +def getatime(path: _PathType) -> float: ... +def getmtime(path: _PathType) -> float: ... +def getctime(path: _PathType) -> float: ... -def getsize(path: unicode) -> int: ... -def isabs(path: unicode) -> bool: ... -def isfile(path: unicode) -> bool: ... -def isdir(path: unicode) -> bool: ... -def islink(path: unicode) -> bool: ... -def ismount(path: unicode) -> bool: ... +def getsize(path: _PathType) -> int: ... +def isabs(path: _PathType) -> bool: ... +def isfile(path: _PathType) -> bool: ... +def isdir(path: _PathType) -> bool: ... +def islink(path: _PathType) -> bool: ... +def ismount(path: _PathType) -> bool: ... -def join(path: AnyStr, *paths: AnyStr) -> AnyStr: ... +if sys.version_info < (3, 0): + # Make sure signatures are disjunct, and allow combinations of bytes and unicode. + # (Since Python 2 allows that, too) + # Note that e.g. os.path.join("a", "b", "c", "d", u"e") will still result in + # a type error. + @overload + def join(__p1: bytes, *p: bytes) -> bytes: ... + @overload + def join(__p1: Text, *p: _PathType) -> Text: ... + @overload + def join(__p1: bytes, __p2: Text, *p: _PathType) -> Text: ... + @overload + def join(__p1: bytes, __p2: bytes, __p3: Text, *p: _PathType) -> Text: ... + @overload + def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: _PathType) -> Text: ... +else: + def join(path: AnyStr, *paths: AnyStr) -> AnyStr: ... def normcase(path: AnyStr) -> AnyStr: ... def normpath(path: AnyStr) -> AnyStr: ... -def realpath(path: AnyStr) -> AnyStr: ... -def relpath(path: AnyStr, start: AnyStr = ...) -> AnyStr: ... +if sys.platform == 'win32': + def realpath(path: AnyStr) -> AnyStr: ... +else: + def realpath(filename: AnyStr) -> AnyStr: ... +def relpath(path: AnyStr, start: _PathType = ...) -> AnyStr: ... -def samefile(path1: unicode, path2: unicode) -> bool: ... +def samefile(path1: _PathType, path2: _PathType) -> bool: ... def sameopenfile(fp1: int, fp2: int) -> bool: ... # TODO # def samestat(stat1: stat_result, @@ -61,5 +98,5 @@ def splitext(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... def splitunc(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... # Windows only, deprecated -_T = TypeVar('_T') -def walk(path: AnyStr, visit: Callable[[_T, AnyStr, List[AnyStr]], Any], arg: _T) -> None: ... +if sys.version_info < (3,): + def walk(path: AnyStr, visit: Callable[[_T, AnyStr, List[AnyStr]], Any], arg: _T) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2/os2emxpath.pyi b/python/helpers/typeshed/stdlib/2/os2emxpath.pyi new file mode 120000 index 000000000000..d2d185799bcc --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/os2emxpath.pyi @@ -0,0 +1 @@ +posixpath.pyi \ No newline at end of file diff --git a/python/helpers/typeshed/stdlib/2/popen2.pyi b/python/helpers/typeshed/stdlib/2/popen2.pyi new file mode 100644 index 000000000000..3d050b46f0f8 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/popen2.pyi @@ -0,0 +1,29 @@ +from typing import Any, Iterable, List, Optional, Union, TextIO, Tuple, TypeVar + +_T = TypeVar('_T') + +__all__ = ... # type: List[str] + +class Popen3: + sts = ... # type: int + cmd = ... # type: Iterable + pid = ... # type: int + tochild = ... # type: TextIO + fromchild = ... # type: TextIO + childerr = ... # type: Optional[TextIO] + def __init__(self, cmd: Iterable = ..., capturestderr: bool = ..., bufsize: int = ...) -> None: ... + def __del__(self) -> None: ... + def poll(self, _deadstate: _T = ...) -> Union[int, _T]: ... + def wait(self) -> int: ... + +class Popen4(Popen3): + childerr = ... # type: None + cmd = ... # type: Iterable + pid = ... # type: int + tochild = ... # type: TextIO + fromchild = ... # type: TextIO + def __init__(self, cmd: Iterable = ..., bufsize: int = ...) -> None: ... + +def popen2(cmd: Iterable = ..., bufsize: int = ..., mode: str = ...) -> Tuple[TextIO, TextIO]: ... +def popen3(cmd: Iterable = ..., bufsize: int = ..., mode: str = ...) -> Tuple[TextIO, TextIO, TextIO]: ... +def popen4(cmd: Iterable = ..., bufsize: int = ..., mode: str = ...) -> Tuple[TextIO, TextIO]: ... diff --git a/python/helpers/typeshed/stdlib/2/posixpath.pyi b/python/helpers/typeshed/stdlib/2/posixpath.pyi index 5e5439fa698a..06a251c3d90b 100644 --- a/python/helpers/typeshed/stdlib/2/posixpath.pyi +++ b/python/helpers/typeshed/stdlib/2/posixpath.pyi @@ -1,8 +1,4 @@ -# Stubs for posixpath (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any, AnyStr, List +from typing import Any from genericpath import * # noqa: F403 curdir = ... # type: Any @@ -38,13 +34,3 @@ def realpath(filename): ... supports_unicode_filenames = ... # type: Any def relpath(path, start=...): ... - -# posixpath imports these from genericpath.py: -def commonprefix(list: List[AnyStr]) -> AnyStr: ... -def exists(path: unicode) -> bool: ... -def getatime(path: unicode) -> float: ... -def getmtime(path: unicode) -> float: ... -def getctime(path: unicode) -> float: ... -def getsize(path: unicode) -> int: ... -def isfile(path: unicode) -> bool: ... -def isdir(path: unicode) -> bool: ... diff --git a/python/helpers/typeshed/stdlib/2/pydoc.pyi b/python/helpers/typeshed/stdlib/2/pydoc.pyi new file mode 100644 index 000000000000..bde952aab082 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/pydoc.pyi @@ -0,0 +1,177 @@ +from typing import Any, AnyStr, Callable, Container, Dict, IO, List, Mapping, MutableMapping, Optional, Tuple, Type, Union +from mypy_extensions import NoReturn +from repr import Repr + +from types import FunctionType, MethodType, ModuleType, TracebackType +# the return type of sys.exc_info(), used by ErrorDuringImport.__init__ +_Exc_Info = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] + +__author__ = ... # type: str +__date__ = ... # type: str +__version__ = ... # type: str +__credits__ = ... # type: str + +def pathdirs() -> List[str]: ... +def getdoc(object: object) -> Union[str, unicode]: ... +def splitdoc(doc: AnyStr) -> Tuple[AnyStr, AnyStr]: ... +def classname(object: object, modname: str) -> str: ... +def isdata(object: object) -> bool: ... +def replace(text: AnyStr, *pairs: AnyStr) -> AnyStr: ... +def cram(text: str, maxlen: int) -> str: ... +def stripid(text: str) -> str: ... +def allmethods(cl: type) -> MutableMapping[str, MethodType]: ... +def visiblename(name: str, all: Optional[Container[str]] = ..., obj: Optional[object] = ...) -> bool: ... +def classify_class_attrs(object: object) -> List[Tuple[str, str, type, str]]: ... + +def ispackage(path: str) -> bool: ... +def source_synopsis(file: IO[AnyStr]) -> Optional[AnyStr]: ... +def synopsis(filename: str, cache: MutableMapping[str, Tuple[int, str]] = ...) -> Optional[str]: ... + +class ErrorDuringImport(Exception): + filename = ... # type: str + exc = ... # type: Optional[Type[BaseException]] + value = ... # type: Optional[BaseException] + tb = ... # type: Optional[TracebackType] + def __init__(self, filename: str, exc_info: _Exc_Info) -> None: ... + +def importfile(path: str) -> ModuleType: ... +def safeimport(path: str, forceload: bool = ..., cache: MutableMapping[str, ModuleType] = ...) -> ModuleType: ... + +class Doc: + def document(self, object: object, name: Optional[str] = ..., *args: Any) -> str: ... + def fail(self, object: object, name: Optional[str] = ..., *args: Any) -> NoReturn: ... + def docmodule(self, object: object, name: Optional[str] = ..., *args: Any) -> str: ... + def docclass(self, object: object, name: Optional[str] = ..., *args: Any) -> str: ... + def docroutine(self, object: object, name: Optional[str] = ..., *args: Any) -> str: ... + def docother(self, object: object, name: Optional[str] = ..., *args: Any) -> str: ... + def docproperty(self, object: object, name: Optional[str] = ..., *args: Any) -> str: ... + def docdata(self, object: object, name: Optional[str] = ..., *args: Any) -> str: ... + def getdocloc(self, object: object) -> Optional[str]: ... + +class HTMLRepr(Repr): + maxlist = ... # type: int + maxtuple = ... # type: int + maxdict = ... # type: int + maxstring = ... # type: int + maxother = ... # type: int + def __init__(self) -> None: ... + def escape(self, text: str) -> str: ... + def repr(self, object: object) -> str: ... + def repr1(self, x: object, level: complex) -> str: ... + def repr_string(self, x: Union[str, unicode], level: complex) -> str: ... + def repr_str(self, x: Union[str, unicode], level: complex) -> str: ... + def repr_instance(self, x: object, level: complex) -> str: ... + def repr_unicode(self, x: AnyStr, level: complex) -> str: ... + +class HTMLDoc(Doc): + def repr(self, object: object) -> str: ... + def escape(self, test: str) -> str: ... + def page(self, title: str, contents: str) -> str: ... + def heading(self, title: str, fgcol: str, bgcol: str, extras: str = ...) -> str: ... + def section(self, title: str, fgcol: str, bgcol: str, contents: str, width: int = ..., prelude: str = ..., marginalia: Optional[str] = ..., gap: str = ...) -> str: ... + def bigsection(self, title: str, *args) -> str: ... + def preformat(self, text: str) -> str: ... + def multicolumn(self, list: List[Any], format: Callable[[Any], str], cols: int = ...) -> str: ... + def grey(self, text: str) -> str: ... + def namelink(self, name: str, *dicts: MutableMapping[str, str]) -> str: ... + def classlink(self, object: object, modname: str) -> str: ... + def modulelink(self, object: object) -> str: ... + def modpkglink(self, data: Tuple[str, str, bool, bool]) -> str: ... + def markup(self, text: str, escape: Optional[Callable[[str], str]] = ..., funcs: Mapping[str, str] = ..., classes: Mapping[str, str] = ..., methods: Mapping[str, str] = ...) -> str: ... + def formattree(self, tree: List[Union[Tuple[type, Tuple[type, ...]], list]], modname: str, parent: Optional[type] = ...) -> str: ... + def docmodule(self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., *ignored) -> str: ... + def docclass(self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., funcs: Mapping[str, str] = ..., classes: Mapping[str, str] = ..., *ignored) -> str: ... + def formatvalue(self, object: object) -> str: ... + def docroutine(self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., funcs: Mapping[str, str] = ..., classes: Mapping[str, str] = ..., methods: Mapping[str, str] = ..., cl: Optional[type] = ..., *ignored) -> str: ... + def docproperty(self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., cl: Optional[Any] = ..., *ignored) -> str: ... + def docother(self, object: object, name: Optional[str] = ..., mod: Optional[Any] = ..., *ignored) -> str: ... + def docdata(self, object: object, name: Optional[str] = ..., mod: Optional[Any] = ..., cl: Optional[Any] = ..., *ignored) -> str: ... + def index(self, dir: str, shadowed: Optional[MutableMapping[str, bool]] = ...) -> str: ... + +class TextRepr(Repr): + maxlist = ... # type: int + maxtuple = ... # type: int + maxdict = ... # type: int + maxstring = ... # type: int + maxother = ... # type: int + def __init__(self) -> None: ... + def repr1(self, x: object, level: complex) -> str: ... + def repr_string(self, x: str, level: complex) -> str: ... + def repr_str(self, x: str, level: complex) -> str: ... + def repr_instance(self, x: object, level: complex) -> str: ... + +class TextDoc(Doc): + def repr(self, object: object) -> str: ... + def bold(self, text: str) -> str: ... + def indent(self, text: str, prefix: str = ...) -> str: ... + def section(self, title: str, contents: str) -> str: ... + def formattree(self, tree: List[Union[Tuple[type, Tuple[type, ...]], list]], modname: str, parent: Optional[type] = ..., prefix: str = ...) -> str: ... + def docmodule(self, object: object, name: Optional[str] = ..., mod: Optional[Any] = ..., *ignored) -> str: ... + def docclass(self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., *ignored) -> str: ... + def formatvalue(self, object: object) -> str: ... + def docroutine(self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., cl: Optional[Any] = ..., *ignored) -> str: ... + def docproperty(self, object: object, name: Optional[str] = ..., mod: Optional[Any] = ..., cl: Optional[Any] = ..., *ignored) -> str: ... + def docdata(self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., cl: Optional[Any] = ..., *ignored) -> str: ... + def docother(self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., parent: Optional[str] = ..., maxlen: Optional[int] = ..., doc: Optional[Any] = ..., *ignored) -> str: ... + +def pager(text: str) -> None: ... +def getpager() -> Callable[[str], None]: ... +def plain(text: str) -> str: ... +def pipepager(text: str, cmd: str) -> None: ... +def tempfilepager(text: str, cmd: str) -> None: ... +def ttypager(text: str) -> None: ... +def plainpager(text: str) -> None: ... +def describe(thing: Any) -> str: ... +def locate(path: str, forceload: bool = ...) -> object: ... + +text = ... # type: TextDoc +html = ... # type: HTMLDoc + +class _OldStyleClass: ... + +def resolve(thing: Union[str, object], forceload: bool = ...) -> Optional[Tuple[object, str]]: ... +def render_doc(thing: Union[str, object], title: str = ..., forceload: bool = ...) -> str: ... +def doc(thing: Union[str, object], title: str = ..., forceload: bool = ...) -> None: ... +def writedoc(thing: Union[str, object], forceload: bool = ...) -> None: ... +def writedocs(dir: str, pkgpath: str = ..., done: Optional[Any] = ...) -> None: ... + +class Helper: + keywords = ... # type: Dict[str, Union[str, Tuple[str, str]]] + symbols = ... # type: Dict[str, str] + topics = ... # type: Dict[str, Union[str, Tuple[str, ...]]] + def __init__(self, input: Optional[IO[str]] = ..., output: Optional[IO[str]] = ...) -> None: ... + input = ... # type: IO[str] + output = ... # type: IO[str] + def __call__(self, request: Union[str, Helper, object] = ...) -> None: ... + def interact(self) -> None: ... + def getline(self, prompt: str) -> str: ... + def help(self, request: Any) -> None: ... + def intro(self) -> None: ... + def list(self, items: List[str], columns: int = ..., width: int = ...) -> None: ... + def listkeywords(self) -> None: ... + def listsymbols(self) -> None: ... + def listtopics(self) -> None: ... + def showtopic(self, topic: str, more_xrefs: str = ...) -> None: ... + def showsymbol(self, symbol: str) -> None: ... + def listmodules(self, key: str = ...) -> None: ... + +help = ... # type: Helper + +# See Python issue #11182: "remove the unused and undocumented pydoc.Scanner class" +# class Scanner: +# roots = ... # type: Any +# state = ... # type: Any +# children = ... # type: Any +# descendp = ... # type: Any +# def __init__(self, roots, children, descendp) -> None: ... +# def next(self): ... + +class ModuleScanner: + quit = ... # type: bool + def run(self, callback: Callable[[Optional[str], str, str], None], key: Optional[Any] = ..., completer: Optional[Callable[[], None]] = ..., onerror: Optional[Callable] = ...) -> None: ... + +def apropos(key: str) -> None: ... +def serve(port: int, callback: Optional[Callable[[Any], None]] = ..., completer: Optional[Callable[[], None]] = ...) -> None: ... +def gui() -> None: ... +def ispath(x: Any) -> bool: ... +def cli() -> None: ... diff --git a/python/helpers/typeshed/stdlib/2/re.pyi b/python/helpers/typeshed/stdlib/2/re.pyi index 8df3a4461a64..110e194af426 100644 --- a/python/helpers/typeshed/stdlib/2/re.pyi +++ b/python/helpers/typeshed/stdlib/2/re.pyi @@ -97,3 +97,4 @@ def subn(pattern: Union[Pattern[str], Pattern[unicode]], repl: Callable[[Match[A def escape(string: AnyStr) -> AnyStr: ... def purge() -> None: ... +def template(pattern: Union[AnyStr, Pattern[AnyStr]], flags: int = ...) -> Pattern[AnyStr]: ... diff --git a/python/helpers/typeshed/stdlib/2/runpy.pyi b/python/helpers/typeshed/stdlib/2/runpy.pyi index 0d24e7e7528f..193a320eb9e6 100644 --- a/python/helpers/typeshed/stdlib/2/runpy.pyi +++ b/python/helpers/typeshed/stdlib/2/runpy.pyi @@ -1,7 +1,3 @@ -# Stubs for runpy (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class _TempModule: diff --git a/python/helpers/typeshed/stdlib/2/sets.pyi b/python/helpers/typeshed/stdlib/2/sets.pyi new file mode 100644 index 000000000000..a68994f2f2b6 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/sets.pyi @@ -0,0 +1,61 @@ +# Stubs for sets (Python 2) +from typing import Any, Callable, Hashable, Iterable, Iterator, MutableMapping, Optional, TypeVar, Union + +_T = TypeVar('_T') +_Setlike = Union[BaseSet[_T], Iterable[_T]] +_SelfT = TypeVar('_SelfT', bound=BaseSet) + +class BaseSet(Iterable[_T]): + def __init__(self) -> None: ... + def __len__(self) -> int: ... + def __repr__(self) -> str: ... + def __str__(self) -> str: ... + def __iter__(self) -> Iterator[_T]: ... + def __cmp__(self, other: Any) -> int: ... + def __eq__(self, other: Any) -> bool: ... + def __ne__(self, other: Any) -> bool: ... + def copy(self: _SelfT) -> _SelfT: ... + def __copy__(self: _SelfT) -> _SelfT: ... + def __deepcopy__(self: _SelfT, memo: MutableMapping[int, BaseSet[_T]]) -> _SelfT: ... + def __or__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ... + def union(self: _SelfT, other: _Setlike) -> _SelfT: ... + def __and__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ... + def intersection(self: _SelfT, other: _Setlike) -> _SelfT: ... + def __xor__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ... + def symmetric_difference(self: _SelfT, other: _Setlike) -> _SelfT: ... + def __sub__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ... + def difference(self: _SelfT, other: _Setlike) -> _SelfT: ... + def __contains__(self, element: Any) -> bool: ... + def issubset(self, other: BaseSet[_T]) -> bool: ... + def issuperset(self, other: BaseSet[_T]) -> bool: ... + def __le__(self, other: BaseSet[_T]) -> bool: ... + def __ge__(self, other: BaseSet[_T]) -> bool: ... + def __lt__(self, other: BaseSet[_T]) -> bool: ... + def __gt__(self, other: BaseSet[_T]) -> bool: ... + +class ImmutableSet(BaseSet[_T], Hashable): + def __init__(self, iterable: Optional[_Setlike] = ...) -> None: ... + def __hash__(self) -> int: ... + +class Set(BaseSet[_T]): + def __init__(self, iterable: Optional[_Setlike] = ...) -> None: ... + def __ior__(self, other: BaseSet[_T]) -> Set: ... + def union_update(self, other: _Setlike) -> None: ... + def __iand__(self, other: BaseSet[_T]) -> Set: ... + def intersection_update(self, other: _Setlike) -> None: ... + def __ixor__(self, other: BaseSet[_T]) -> Set: ... + def symmetric_difference_update(self, other: _Setlike) -> None: ... + def __isub__(self, other: BaseSet[_T]) -> Set: ... + def difference_update(self, other: _Setlike) -> None: ... + def update(self, iterable: _Setlike) -> None: ... + def clear(self) -> None: ... + def add(self, element: _T) -> None: ... + def remove(self, element: _T) -> None: ... + def discard(self, element: _T) -> None: ... + def pop(self) -> _T: ... + def __as_immutable__(self) -> ImmutableSet[_T]: ... + def __as_temporarily_immutable__(self) -> _TemporarilyImmutableSet[_T]: ... + +class _TemporarilyImmutableSet(BaseSet[_T]): + def __init__(self, set: BaseSet[_T]) -> None: ... + def __hash__(self) -> int: ... diff --git a/python/helpers/typeshed/stdlib/2/shutil.pyi b/python/helpers/typeshed/stdlib/2/shutil.pyi index c39f257804de..94d0952cedfe 100644 --- a/python/helpers/typeshed/stdlib/2/shutil.pyi +++ b/python/helpers/typeshed/stdlib/2/shutil.pyi @@ -1,7 +1,3 @@ -# Stubs for shutil (Python 2) -# -# NOTE: Based on a dynamically typed stub automatically generated by stubgen. - from typing import List, Iterable, Callable, IO, AnyStr, Any, Optional, Tuple, Sequence class Error(EnvironmentError): ... diff --git a/python/helpers/typeshed/stdlib/2/smtplib.pyi b/python/helpers/typeshed/stdlib/2/smtplib.pyi index cb5f893e7c0b..76bdcb459569 100644 --- a/python/helpers/typeshed/stdlib/2/smtplib.pyi +++ b/python/helpers/typeshed/stdlib/2/smtplib.pyi @@ -1,7 +1,3 @@ -# Stubs for smtplib (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class SMTPException(Exception): ... diff --git a/python/helpers/typeshed/stdlib/2/spwd.pyi b/python/helpers/typeshed/stdlib/2/spwd.pyi new file mode 100644 index 000000000000..1d5899031919 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/spwd.pyi @@ -0,0 +1,14 @@ +from typing import List, NamedTuple + +struct_spwd = NamedTuple("struct_spwd", [("sp_nam", str), + ("sp_pwd", str), + ("sp_lstchg", int), + ("sp_min", int), + ("sp_max", int), + ("sp_warn", int), + ("sp_inact", int), + ("sp_expire", int), + ("sp_flag", int)]) + +def getspall() -> List[struct_spwd]: ... +def getspnam(name: str) -> struct_spwd: ... diff --git a/python/helpers/typeshed/stdlib/2/sqlite3/__init__.pyi b/python/helpers/typeshed/stdlib/2/sqlite3/__init__.pyi index fc22e5d50e0a..d5d20d67b58e 100644 --- a/python/helpers/typeshed/stdlib/2/sqlite3/__init__.pyi +++ b/python/helpers/typeshed/stdlib/2/sqlite3/__init__.pyi @@ -1,5 +1 @@ -# Stubs for sqlite3 (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from sqlite3.dbapi2 import * # noqa: F403 diff --git a/python/helpers/typeshed/stdlib/2/sqlite3/dbapi2.pyi b/python/helpers/typeshed/stdlib/2/sqlite3/dbapi2.pyi index bd4443323d9d..8d55e04a664f 100644 --- a/python/helpers/typeshed/stdlib/2/sqlite3/dbapi2.pyi +++ b/python/helpers/typeshed/stdlib/2/sqlite3/dbapi2.pyi @@ -1,8 +1,7 @@ # Filip Hron # based heavily on Andrey Vlasovskikh's python-skeletons https://github.com/JetBrains/python-skeletons/blob/master/sqlite3.py -from typing import Any, Union, List, Iterator -from numbers import Integral +from typing import Any, Union, List, Iterator, Optional from datetime import time, datetime from collections import Iterable @@ -141,7 +140,7 @@ class Cursor(Iterator[Any]): def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable]): ... def executescript(self, sql_script: Union[bytes, unicode]) -> Cursor: ... def fetchall(self) -> List[Any]: ... - def fetchmany(self, size: Integral = ...) -> List[Any]: ... + def fetchmany(self, size: Optional[int] = ...) -> List[Any]: ... def fetchone(self) -> Any: ... def setinputsizes(self, *args, **kwargs): ... def setoutputsize(self, *args, **kwargs): ... diff --git a/python/helpers/typeshed/stdlib/2/sre_constants.pyi b/python/helpers/typeshed/stdlib/2/sre_constants.pyi new file mode 100644 index 000000000000..4404873f61db --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/sre_constants.pyi @@ -0,0 +1,94 @@ +# Source: https://hg.python.org/cpython/file/2.7/Lib/sre_constants.py + +from typing import Dict, List, TypeVar + +MAGIC = ... # type: int +MAXREPEAT = ... # type: int + +class error(Exception): ... + +FAILURE = ... # type: str +SUCCESS = ... # type: str +ANY = ... # type: str +ANY_ALL = ... # type: str +ASSERT = ... # type: str +ASSERT_NOT = ... # type: str +AT = ... # type: str +BIGCHARSET = ... # type: str +BRANCH = ... # type: str +CALL = ... # type: str +CATEGORY = ... # type: str +CHARSET = ... # type: str +GROUPREF = ... # type: str +GROUPREF_IGNORE = ... # type: str +GROUPREF_EXISTS = ... # type: str +IN = ... # type: str +IN_IGNORE = ... # type: str +INFO = ... # type: str +JUMP = ... # type: str +LITERAL = ... # type: str +LITERAL_IGNORE = ... # type: str +MARK = ... # type: str +MAX_REPEAT = ... # type: str +MAX_UNTIL = ... # type: str +MIN_REPEAT = ... # type: str +MIN_UNTIL = ... # type: str +NEGATE = ... # type: str +NOT_LITERAL = ... # type: str +NOT_LITERAL_IGNORE = ... # type: str +RANGE = ... # type: str +REPEAT = ... # type: str +REPEAT_ONE = ... # type: str +SUBPATTERN = ... # type: str +MIN_REPEAT_ONE = ... # type: str +AT_BEGINNING = ... # type: str +AT_BEGINNING_LINE = ... # type: str +AT_BEGINNING_STRING = ... # type: str +AT_BOUNDARY = ... # type: str +AT_NON_BOUNDARY = ... # type: str +AT_END = ... # type: str +AT_END_LINE = ... # type: str +AT_END_STRING = ... # type: str +AT_LOC_BOUNDARY = ... # type: str +AT_LOC_NON_BOUNDARY = ... # type: str +AT_UNI_BOUNDARY = ... # type: str +AT_UNI_NON_BOUNDARY = ... # type: str +CATEGORY_DIGIT = ... # type: str +CATEGORY_NOT_DIGIT = ... # type: str +CATEGORY_SPACE = ... # type: str +CATEGORY_NOT_SPACE = ... # type: str +CATEGORY_WORD = ... # type: str +CATEGORY_NOT_WORD = ... # type: str +CATEGORY_LINEBREAK = ... # type: str +CATEGORY_NOT_LINEBREAK = ... # type: str +CATEGORY_LOC_WORD = ... # type: str +CATEGORY_LOC_NOT_WORD = ... # type: str +CATEGORY_UNI_DIGIT = ... # type: str +CATEGORY_UNI_NOT_DIGIT = ... # type: str +CATEGORY_UNI_SPACE = ... # type: str +CATEGORY_UNI_NOT_SPACE = ... # type: str +CATEGORY_UNI_WORD = ... # type: str +CATEGORY_UNI_NOT_WORD = ... # type: str +CATEGORY_UNI_LINEBREAK = ... # type: str +CATEGORY_UNI_NOT_LINEBREAK = ... # type: str + +_T = TypeVar('_T') +def makedict(list: List[_T]) -> Dict[_T, int]: ... + +OP_IGNORE = ... # type: Dict[str, str] +AT_MULTILINE = ... # type: Dict[str, str] +AT_LOCALE = ... # type: Dict[str, str] +AT_UNICODE = ... # type: Dict[str, str] +CH_LOCALE = ... # type: Dict[str, str] +CH_UNICODE = ... # type: Dict[str, str] +SRE_FLAG_TEMPLATE = ... # type: int +SRE_FLAG_IGNORECASE = ... # type: int +SRE_FLAG_LOCALE = ... # type: int +SRE_FLAG_MULTILINE = ... # type: int +SRE_FLAG_DOTALL = ... # type: int +SRE_FLAG_UNICODE = ... # type: int +SRE_FLAG_VERBOSE = ... # type: int +SRE_FLAG_DEBUG = ... # type: int +SRE_INFO_PREFIX = ... # type: int +SRE_INFO_LITERAL = ... # type: int +SRE_INFO_CHARSET = ... # type: int diff --git a/python/helpers/typeshed/stdlib/2/sre_parse.pyi b/python/helpers/typeshed/stdlib/2/sre_parse.pyi new file mode 100644 index 000000000000..544a6182de8d --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/sre_parse.pyi @@ -0,0 +1,63 @@ +# Source: https://hg.python.org/cpython/file/2.7/Lib/sre_parse.py + +from typing import Any, Dict, Iterable, List, Match, Optional, Pattern as _Pattern, Set, Tuple, Union + +SPECIAL_CHARS = ... # type: str +REPEAT_CHARS = ... # type: str +DIGITS = ... # type: Set +OCTDIGITS = ... # type: Set +HEXDIGITS = ... # type: Set +WHITESPACE = ... # type: Set +ESCAPES = ... # type: Dict[str, Tuple[str, int]] +CATEGORIES = ... # type: Dict[str, Union[Tuple[str, str], Tuple[str, List[Tuple[str, str]]]]] +FLAGS = ... # type: Dict[str, int] + +class Pattern: + flags = ... # type: int + open = ... # type: List[int] + groups = ... # type: int + groupdict = ... # type: Dict[str, int] + lookbehind = ... # type: int + def __init__(self) -> None: ... + def opengroup(self, name: str = ...) -> int: ... + def closegroup(self, gid: int) -> None: ... + def checkgroup(self, gid: int) -> bool: ... + + +_OpSubpatternType = Tuple[Optional[int], int, int, SubPattern] +_OpGroupRefExistsType = Tuple[int, SubPattern, SubPattern] +_OpInType = List[Tuple[str, int]] +_OpBranchType = Tuple[None, List[SubPattern]] +_AvType = Union[_OpInType, _OpBranchType, Iterable[SubPattern], _OpGroupRefExistsType, _OpSubpatternType] +_CodeType = Union[str, _AvType] + +class SubPattern: + pattern = ... # type: str + data = ... # type: List[_CodeType] + width = ... # type: Optional[int] + def __init__(self, pattern, data: List[_CodeType] = ...) -> None: ... + def dump(self, level: int = ...) -> None: ... + def __len__(self) -> int: ... + def __delitem__(self, index: Union[int, slice]) -> None: ... + def __getitem__(self, index: Union[int, slice]) -> Union[SubPattern, _CodeType]: ... + def __setitem__(self, index: Union[int, slice], code: _CodeType): ... + def insert(self, index, code: _CodeType) -> None: ... + def append(self, code: _CodeType) -> None: ... + def getwidth(self) -> int: ... + +class Tokenizer: + string = ... # type: str + index = ... # type: int + def __init__(self, string: str) -> None: ... + def match(self, char: str, skip: int = ...) -> int: ... + def get(self) -> Optional[str]: ... + def tell(self) -> Tuple[int, Optional[str]]: ... + def seek(self, index: int) -> None: ... + +def isident(char: str) -> bool: ... +def isdigit(char: str) -> bool: ... +def isname(name: str) -> bool: ... +def parse(str: str, flags: int = ..., pattern: Pattern = ...) -> SubPattern: ... +_Template = Tuple[List[Tuple[int, int]], List[Optional[int]]] +def parse_template(source: str, pattern: _Pattern) -> _Template: ... +def expand_template(template: _Template, match: Match) -> str: ... diff --git a/python/helpers/typeshed/stdlib/2/string.pyi b/python/helpers/typeshed/stdlib/2/string.pyi index 4bbfb486c9fc..751fd28a064f 100644 --- a/python/helpers/typeshed/stdlib/2/string.pyi +++ b/python/helpers/typeshed/stdlib/2/string.pyi @@ -41,9 +41,9 @@ def strip(s: AnyStr, chars: AnyStr = ...) -> AnyStr: ... def swapcase(s: AnyStr) -> AnyStr: ... def translate(s: str, table: str, deletechars: str = ...) -> str: ... def upper(s: AnyStr) -> AnyStr: ... -def ljust(s: AnyStr, width: int, fillhar: AnyStr = ...) -> AnyStr: ... -def rjust(s: AnyStr, width: int, fillhar: AnyStr = ...) -> AnyStr: ... -def center(s: AnyStr, width: int, fillhar: AnyStr = ...) -> AnyStr: ... +def ljust(s: AnyStr, width: int, fillchar: AnyStr = ...) -> AnyStr: ... +def rjust(s: AnyStr, width: int, fillchar: AnyStr = ...) -> AnyStr: ... +def center(s: AnyStr, width: int, fillchar: AnyStr = ...) -> AnyStr: ... def zfill(s: AnyStr, width: int) -> AnyStr: ... def replace(s: AnyStr, old: AnyStr, new: AnyStr, maxreplace: int = ...) -> AnyStr: ... diff --git a/python/helpers/typeshed/stdlib/2/stringold.pyi b/python/helpers/typeshed/stdlib/2/stringold.pyi new file mode 100644 index 000000000000..7d31ebe5b4ce --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/stringold.pyi @@ -0,0 +1,46 @@ +# Source: https://hg.python.org/cpython/file/2.7/Lib/stringold.py +from typing import AnyStr, Iterable, List, Optional, Type + +whitespace = ... # type: str +lowercase = ... # type: str +uppercase = ... # type: str +letters = ... # type: str +digits = ... # type: str +hexdigits = ... # type: str +octdigits = ... # type: str +_idmap = ... # type: str +_idmapL = ... # type: Optional[List[str]] +index_error = ValueError +atoi_error = ValueError +atof_error = ValueError +atol_error = ValueError + + +def lower(s: AnyStr) -> AnyStr: ... +def upper(s: AnyStr) -> AnyStr: ... +def swapcase(s: AnyStr) -> AnyStr: ... +def strip(s: AnyStr) -> AnyStr: ... +def lstrip(s: AnyStr) -> AnyStr: ... +def rstrip(s: AnyStr) -> AnyStr: ... +def split(s: AnyStr, sep: AnyStr = ..., maxsplit: int = ...) -> List[AnyStr]: ... +def splitfields(s: AnyStr, sep: AnyStr = ..., maxsplit: int = ...) -> List[AnyStr]: ... +def join(words: Iterable[AnyStr], sep: AnyStr = ...) -> AnyStr: ... +def joinfields(words: Iterable[AnyStr], sep: AnyStr = ...) -> AnyStr: ... +def index(s: unicode, sub: unicode, start: int = ..., end: int = ...) -> int: ... +def rindex(s: unicode, sub: unicode, start: int = ..., end: int = ...) -> int: ... +def count(s: unicode, sub: unicode, start: int = ..., end: int = ...) -> int: ... +def find(s: unicode, sub: unicode, start: int = ..., end: int = ...) -> int: ... +def rfind(s: unicode, sub: unicode, start: int = ..., end: int = ...) -> int: ... +def atof(s: unicode) -> float: ... +def atoi(s: unicode, base: int = ...) -> int: ... +def atol(s: unicode, base: int = ...) -> long: ... +def ljust(s: AnyStr, width: int, fillchar: AnyStr = ...) -> AnyStr: ... +def rjust(s: AnyStr, width: int, fillchar: AnyStr = ...) -> AnyStr: ... +def center(s: AnyStr, width: int, fillchar: AnyStr = ...) -> AnyStr: ... +def zfill(s: AnyStr, width: int) -> AnyStr: ... +def expandtabs(s: AnyStr, tabsize: int = ...) -> AnyStr: ... +def translate(s: str, table: str, deletions: str = ...) -> str: ... +def capitalize(s: AnyStr) -> AnyStr: ... +def capwords(s: AnyStr, sep: AnyStr = ...) -> AnyStr: ... +def maketrans(fromstr: str, tostr: str) -> str: ... +def replace(s: AnyStr, old: AnyStr, new: AnyStr, maxreplace: int = ...) -> AnyStr: ... diff --git a/python/helpers/typeshed/stdlib/2/subprocess.pyi b/python/helpers/typeshed/stdlib/2/subprocess.pyi index 448df12f1c79..047b6bd723e4 100644 --- a/python/helpers/typeshed/stdlib/2/subprocess.pyi +++ b/python/helpers/typeshed/stdlib/2/subprocess.pyi @@ -2,9 +2,9 @@ # Based on http://docs.python.org/2/library/subprocess.html and Python 3 stub -from typing import Sequence, Any, AnyStr, Mapping, Callable, Tuple, IO, Union, Optional, List, Text +from typing import Sequence, Any, Mapping, Callable, Tuple, IO, Union, Optional, List, Text -_FILE = Union[int, IO[Any]] +_FILE = Union[None, int, IO[Any]] _TXT = Union[bytes, Text] _CMD = Union[_TXT, Sequence[_TXT]] _ENV = Union[Mapping[bytes, _TXT], Mapping[Text, _TXT]] diff --git a/python/helpers/typeshed/stdlib/2/symbol.pyi b/python/helpers/typeshed/stdlib/2/symbol.pyi index dd334444a120..ef41c81296e6 100644 --- a/python/helpers/typeshed/stdlib/2/symbol.pyi +++ b/python/helpers/typeshed/stdlib/2/symbol.pyi @@ -88,4 +88,4 @@ testlist1 = ... # type: int encoding_decl = ... # type: int yield_expr = ... # type: int -symbol = ... # type: Dict[int, str] +sym_name = ... # type: Dict[int, str] diff --git a/python/helpers/typeshed/stdlib/2/sys.pyi b/python/helpers/typeshed/stdlib/2/sys.pyi index cb9172a84c45..2eaeea76bdc4 100644 --- a/python/helpers/typeshed/stdlib/2/sys.pyi +++ b/python/helpers/typeshed/stdlib/2/sys.pyi @@ -61,7 +61,7 @@ long_info = ... # type: object maxint = ... # type: int maxsize = ... # type: int maxunicode = ... # type: int -modules = ... # type: Dict[str, ModuleType] +modules = ... # type: Dict[str, Any] path = ... # type: List[str] platform = ... # type: str prefix = ... # type: str @@ -124,7 +124,7 @@ def exit(arg: Any = ...) -> NoReturn: def getcheckinterval() -> int: ... # deprecated def getdefaultencoding() -> str: ... def getdlopenflags() -> int: ... -def getfilesystemencoding() -> Union[str, None]: ... +def getfilesystemencoding() -> str: ... # In practice, never returns None def getrefcount(arg: Any) -> int: ... def getrecursionlimit() -> int: ... def getsizeof(obj: object, default: int = ...) -> int: ... diff --git a/python/helpers/typeshed/stdlib/2/textwrap.pyi b/python/helpers/typeshed/stdlib/2/textwrap.pyi index 7d1a6d387e5e..df8afa6244e2 100644 --- a/python/helpers/typeshed/stdlib/2/textwrap.pyi +++ b/python/helpers/typeshed/stdlib/2/textwrap.pyi @@ -1,8 +1,4 @@ -# Stubs for textwrap (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any +from typing import Any, AnyStr class _unicode: ... @@ -30,4 +26,4 @@ class TextWrapper: def wrap(text, width=..., **kwargs): ... def fill(text, width=..., **kwargs): ... -def dedent(text): ... +def dedent(text: AnyStr) -> AnyStr: ... diff --git a/python/helpers/typeshed/stdlib/2/thread.pyi b/python/helpers/typeshed/stdlib/2/thread.pyi index a54a946a4910..2f0483ff5540 100644 --- a/python/helpers/typeshed/stdlib/2/thread.pyi +++ b/python/helpers/typeshed/stdlib/2/thread.pyi @@ -13,7 +13,7 @@ class LockType: def locked(self) -> bool: ... def locked_lock(self) -> bool: ... def __enter__(self) -> LockType: ... - def __exit__(self, value: Any, traceback: Any) -> None: ... + def __exit__(self, typ: Any, value: Any, traceback: Any) -> None: ... class _local(object): pass diff --git a/python/helpers/typeshed/stdlib/2/time.pyi b/python/helpers/typeshed/stdlib/2/time.pyi index 6d2499f62639..e75d8e0d7140 100644 --- a/python/helpers/typeshed/stdlib/2/time.pyi +++ b/python/helpers/typeshed/stdlib/2/time.pyi @@ -17,6 +17,9 @@ class struct_time(NamedTuple('_struct_time', def __init__(self, o: Tuple[int, int, int, int, int, int, int, int, int], _arg: Any = ...) -> None: ... + def __new__(cls, o: Tuple[int, int, int, + int, int, int, + int, int, int], _arg: Any = ...) -> struct_time: ... _TIME_TUPLE = Tuple[int, int, int, int, int, int, int, int, int] @@ -32,7 +35,7 @@ def gmtime(secs: Optional[float] = ...) -> struct_time: ... def localtime(secs: Optional[float] = ...) -> struct_time: ... -def mktime(t: struct_time) -> float: +def mktime(t: Union[struct_time, _TIME_TUPLE]) -> float: raise OverflowError() raise ValueError() diff --git a/python/helpers/typeshed/stdlib/2/toaiff.pyi b/python/helpers/typeshed/stdlib/2/toaiff.pyi new file mode 100644 index 000000000000..77334c7f525e --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/toaiff.pyi @@ -0,0 +1,16 @@ +# Stubs for toaiff (Python 2) + +# Source: https://hg.python.org/cpython/file/2.7/Lib/toaiff.py +from pipes import Template +from typing import Dict, List + + +__all__: List[str] +table: Dict[str, Template] +t: Template +uncompress: Template + +class error(Exception): ... + +def toaiff(filename: str) -> str: ... +def _toaiff(filename: str, temps: List[str]) -> str: ... diff --git a/python/helpers/typeshed/stdlib/2/tokenize.pyi b/python/helpers/typeshed/stdlib/2/tokenize.pyi index 159adf96d5f5..834e2197d064 100644 --- a/python/helpers/typeshed/stdlib/2/tokenize.pyi +++ b/python/helpers/typeshed/stdlib/2/tokenize.pyi @@ -102,15 +102,11 @@ chain = ... # type: type double3prog = ... # type: type endprogs = ... # type: Dict[str, Any] pseudoprog = ... # type: type -re = ... # type: module single3prog = ... # type: type single_quoted = ... # type: Dict[str, str] -string = ... # type: module -sys = ... # type: module t = ... # type: str tabsize = ... # type: int tok_name = ... # type: Dict[int, str] -token = ... # type: module tokenprog = ... # type: type triple_quoted = ... # type: Dict[str, str] x = ... # type: str diff --git a/python/helpers/typeshed/stdlib/2/types.pyi b/python/helpers/typeshed/stdlib/2/types.pyi index ceecd79c2b79..87380b32478d 100644 --- a/python/helpers/typeshed/stdlib/2/types.pyi +++ b/python/helpers/typeshed/stdlib/2/types.pyi @@ -3,7 +3,7 @@ from typing import ( Any, Callable, Dict, Iterable, Iterator, List, Optional, - Tuple, TypeVar, Union, overload, + Tuple, Type, TypeVar, Union, overload, ) _T = TypeVar('_T') @@ -19,11 +19,12 @@ BooleanType = bool ComplexType = complex StringType = str UnicodeType = unicode -StringTypes = (StringType, UnicodeType) +StringTypes = ... # type: Tuple[Type[StringType], Type[UnicodeType]] BufferType = buffer TupleType = tuple ListType = list -DictType = DictionaryType = dict +DictType = dict +DictionaryType = dict class _Cell: cell_contents = ... # type: Any @@ -81,6 +82,7 @@ class UnboundMethodType: im_class = ... # type: type im_func = ... # type: FunctionType im_self = ... # type: object + __name__ = ... # type: str __func__ = im_func __self__ = im_self def __init__(self, func: Callable, obj: object) -> None: ... @@ -104,6 +106,7 @@ class ModuleType: __name__ = ... # type: str __package__ = ... # type: Optional[str] __path__ = ... # type: Optional[Iterable[str]] + __dict__ = ... # type: Dict[str, Any] def __init__(self, name: str, doc: Optional[str] = ...) -> None: ... FileType = file XRangeType = xrange diff --git a/python/helpers/typeshed/stdlib/2/typing.pyi b/python/helpers/typeshed/stdlib/2/typing.pyi index 059db3d6406a..d8c49a421796 100644 --- a/python/helpers/typeshed/stdlib/2/typing.pyi +++ b/python/helpers/typeshed/stdlib/2/typing.pyi @@ -1,7 +1,8 @@ # Stubs for typing (Python 2.7) from abc import abstractmethod, ABCMeta -from types import CodeType, FrameType +from types import CodeType, FrameType, TracebackType +import collections # Needed by aliases like DefaultDict, see mypy issue 2986 # Definitions of special type checking related constructs. Their definitions # are not used, so their value does not matter. @@ -9,16 +10,25 @@ from types import CodeType, FrameType overload = object() Any = object() TypeVar = object() -Generic = object() -Tuple = object() -Callable = object() -Type = object() _promote = object() no_type_check = object() -ClassVar = object() + +class _SpecialForm(object): + def __getitem__(self, typeargs: Any) -> object: ... + +Tuple: _SpecialForm = ... +Generic: _SpecialForm = ... +Callable: _SpecialForm = ... +Type: _SpecialForm = ... +ClassVar: _SpecialForm = ... class GenericMeta(type): ... +# Return type that indicates a function does not return. +# This type is equivalent to the None type, but the no-op Union is necessary to +# distinguish the None type from the None value. +NoReturn = Union[None] + # Type aliases and type constructors class TypeAlias: @@ -199,6 +209,12 @@ class ValuesView(MappingView, Iterable[_VT_co], Generic[_VT_co]): def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[_VT_co]: ... +class ContextManager(Generic[_T_co]): + def __enter__(self) -> _T_co: ... + def __exit__(self, exc_type: Optional[Type[BaseException]], + exc_value: Optional[BaseException], + traceback: Optional[TracebackType]) -> Optional[bool]: ... + class Mapping(Iterable[_KT], Container[_KT], Sized, Generic[_KT, _VT_co]): # TODO: We wish the key type could also be covariant, but that doesn't work, # see discussion in https: //github.com/python/typing/pull/273. @@ -206,9 +222,9 @@ class Mapping(Iterable[_KT], Container[_KT], Sized, Generic[_KT, _VT_co]): def __getitem__(self, k: _KT) -> _VT_co: ... # Mixin methods - @overload # type: ignore + @overload def get(self, k: _KT) -> Optional[_VT_co]: ... - @overload # type: ignore + @overload 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]: ... @@ -381,7 +397,8 @@ class Pattern(Generic[AnyStr]): # Functions -def get_type_hints(obj: Callable) -> dict[str, Any]: ... +def get_type_hints(obj: Callable, globalns: Optional[dict[Text, Any]] = ..., + localns: Optional[dict[Text, Any]] = ...) -> None: ... 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 9f3f7d600288..1a7a069cd5e4 100644 --- a/python/helpers/typeshed/stdlib/2/unittest.pyi +++ b/python/helpers/typeshed/stdlib/2/unittest.pyi @@ -4,11 +4,11 @@ # Only a subset of functionality is included. -from typing import ( - Any, Callable, Dict, Iterable, Tuple, List, TextIO, Sequence, - overload, Set, FrozenSet, TypeVar, Union, Pattern, Type -) +from typing import (Any, Callable, Dict, FrozenSet, Iterable, List, Optional, + overload, Pattern, Sequence, Set, TextIO, Tuple, Type, + TypeVar, Union) from abc import abstractmethod, ABCMeta +import types _T = TypeVar('_T') _FT = TypeVar('_FT') @@ -152,11 +152,26 @@ class TestSuite(Testable): def debug(self) -> None: ... def countTestCases(self) -> int: ... -# TODO TestLoader -# TODO defaultTestLoader +class TestLoader: + testMethodPrefix = ... # type: str + sortTestMethodsUsing = ... # type: Optional[Callable[[str, str], int]] + suiteClass = ... # type: Callable[[List[TestCase]], TestSuite] + def loadTestsFromTestCase(self, + testCaseClass: Type[TestCase]) -> TestSuite: ... + def loadTestsFromModule(self, module: str = ..., + use_load_tests: bool = ...) -> TestSuite: ... + def loadTestsFromName(self, name: str = ..., + module: Optional[str] = ...) -> TestSuite: ... + def loadTestsFromNames(self, names: List[str] = ..., + module: Optional[str] = ...) -> TestSuite: ... + def discover(self, start_dir: str, pattern: str = ..., + top_level_dir: Optional[str] = ...) -> TestSuite: ... + def getTestCaseNames(self, testCaseClass: Type[TestCase] = ...) -> List[str]: ... + +defaultTestLoader = TestLoader class TextTestRunner: - def __init__(self, stream: TextIO = ..., descriptions: bool = ..., + def __init__(self, stream: Optional[TextIO] = ..., descriptions: bool = ..., verbosity: int = ..., failfast: bool = ...) -> None: ... class SkipTest(Exception): @@ -168,9 +183,16 @@ def skipIf(condition: Any, reason: Union[str, unicode]) -> Any: ... def expectedFailure(func: _FT) -> _FT: ... def skip(reason: Union[str, unicode]) -> Any: ... -def main(module: str = ..., defaultTest: str = ..., - argv: List[str] = ..., testRunner: Any = ..., - testLoader: Any = ...) -> None: ... # TODO types +# not really documented +class TestProgram: + result = ... # type: TestResult + +def main(module: str = ..., defaultTest: Optional[str] = ..., + argv: Optional[Sequence[str]] = ..., + testRunner: Union[Type[TextTestRunner], TextTestRunner, None] = ..., + testLoader: TestLoader = ..., exit: bool = ..., verbosity: int = ..., + failfast: Optional[bool] = ..., catchbreak: Optional[bool] = ..., + buffer: Optional[bool] = ...) -> TestProgram: ... # private but occasionally used -util = ... # type: module +util = ... # type: types.ModuleType diff --git a/python/helpers/typeshed/stdlib/2/urllib.pyi b/python/helpers/typeshed/stdlib/2/urllib.pyi index 0882926ba65c..5f47c1865320 100644 --- a/python/helpers/typeshed/stdlib/2/urllib.pyi +++ b/python/helpers/typeshed/stdlib/2/urllib.pyi @@ -1,6 +1,3 @@ -# Stubs for urllib (Python 2) -# NOTE: This dynamically typed stub was originally automatically generated by stubgen. - from typing import Any, Mapping, Union, Tuple, Sequence, IO def url2pathname(pathname: str) -> str: ... diff --git a/python/helpers/typeshed/stdlib/2/urllib2.pyi b/python/helpers/typeshed/stdlib/2/urllib2.pyi index 8602ec9d2fd1..cfa399e4826b 100644 --- a/python/helpers/typeshed/stdlib/2/urllib2.pyi +++ b/python/helpers/typeshed/stdlib/2/urllib2.pyi @@ -41,7 +41,7 @@ class Request(object): def add_header(self, key: str, val: str) -> None: ... def add_unredirected_header(self, key: str, val: str) -> None: ... def has_header(self, header_name: str) -> bool: ... - def get_header(self, header_name: str, default: str = None) -> str: ... + def get_header(self, header_name: str, default: Optional[str] = None) -> str: ... def header_items(self): ... class OpenerDirector(object): @@ -128,7 +128,7 @@ class ProxyDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler): def http_error_407(self, req, fp, code, msg, headers): ... class AbstractHTTPHandler(BaseHandler): - def __init__(self, debuglevel: int) -> None: ... + def __init__(self, debuglevel: int=0) -> None: ... def do_request_(self, request): ... def do_open(self, http_class, req): ... diff --git a/python/helpers/typeshed/stdlib/2/urlparse.pyi b/python/helpers/typeshed/stdlib/2/urlparse.pyi index 9d0a7021d522..169de2ff0fc8 100644 --- a/python/helpers/typeshed/stdlib/2/urlparse.pyi +++ b/python/helpers/typeshed/stdlib/2/urlparse.pyi @@ -1,6 +1,8 @@ # Stubs for urlparse (Python 2) -from typing import Dict, List, NamedTuple, Tuple, Sequence, Union, overload +from typing import AnyStr, Dict, List, NamedTuple, Tuple, Sequence, Union, overload + +_String = Union[str, unicode] uses_relative = ... # type: List[str] uses_netloc = ... # type: List[str] @@ -46,23 +48,23 @@ class ParseResult( ): def geturl(self) -> str: ... -def urlparse(url: Union[str, unicode], scheme: str = ..., +def urlparse(url: _String, scheme: _String = ..., allow_fragments: bool = ...) -> ParseResult: ... -def urlsplit(url: Union[str, unicode], scheme: str = ..., +def urlsplit(url: _String, scheme: _String = ..., allow_fragments: bool = ...) -> SplitResult: ... @overload -def urlunparse(data: Tuple[str, str, str, str, str, str]) -> str: ... +def urlunparse(data: Tuple[_String, _String, _String, _String, _String, _String]) -> str: ... @overload -def urlunparse(data: Sequence[str]) -> str: ... +def urlunparse(data: Sequence[_String]) -> str: ... @overload -def urlunsplit(data: Tuple[str, str, str, str, str]) -> str: ... +def urlunsplit(data: Tuple[_String, _String, _String, _String, _String]) -> str: ... @overload -def urlunsplit(data: Sequence[str]) -> str: ... -def urljoin(base: Union[str, unicode], url: Union[str, unicode], +def urlunsplit(data: Sequence[_String]) -> str: ... +def urljoin(base: _String, url: _String, allow_fragments: bool = ...) -> str: ... -def urldefrag(url: Union[str, unicode]) -> str: ... -def unquote(s: str) -> str: ... -def parse_qs(qs: str, keep_blank_values: bool = ..., - strict_parsing: bool = ...) -> Dict[str, List[str]]: ... -def parse_qsl(qs: str, keep_blank_values: int = ..., - strict_parsing: bool = ...) -> List[Tuple[str, str]]: ... +def urldefrag(url: AnyStr) -> Tuple[AnyStr, str]: ... +def unquote(s: AnyStr) -> AnyStr: ... +def parse_qs(qs: AnyStr, keep_blank_values: bool = ..., + strict_parsing: bool = ...) -> Dict[AnyStr, List[AnyStr]]: ... +def parse_qsl(qs: AnyStr, keep_blank_values: int = ..., + strict_parsing: bool = ...) -> List[Tuple[AnyStr, AnyStr]]: ... diff --git a/python/helpers/typeshed/stdlib/2/user.pyi b/python/helpers/typeshed/stdlib/2/user.pyi new file mode 100644 index 000000000000..e6beaa919393 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/user.pyi @@ -0,0 +1,9 @@ +# Stubs for user (Python 2) + +# Docs: https://docs.python.org/2/library/user.html +# Source: https://hg.python.org/cpython/file/2.7/Lib/user.py +from typing import Any + +def __getattr__(name) -> Any: ... # type: ignore +home: str +pythonrc: str diff --git a/python/helpers/typeshed/stdlib/2/wsgiref/validate.pyi b/python/helpers/typeshed/stdlib/2/wsgiref/validate.pyi index 490889c8f58c..bd0c7b7d94a1 100644 --- a/python/helpers/typeshed/stdlib/2/wsgiref/validate.pyi +++ b/python/helpers/typeshed/stdlib/2/wsgiref/validate.pyi @@ -1,7 +1,3 @@ -# Stubs for wsgiref.validate (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class WSGIWarning(Warning): ... diff --git a/python/helpers/typeshed/stdlib/2/xmlrpclib.pyi b/python/helpers/typeshed/stdlib/2/xmlrpclib.pyi new file mode 100644 index 000000000000..9f6fb98588f9 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2/xmlrpclib.pyi @@ -0,0 +1,199 @@ +# Stubs for xmlrpclib (Python 2) + +from typing import Any, AnyStr, Callable, IO, Iterable, List, Mapping, MutableMapping, Optional, Tuple, Type, TypeVar, Union +from types import InstanceType +from datetime import datetime +from time import struct_time +from httplib import HTTPConnection, HTTPResponse, HTTPSConnection +from ssl import SSLContext +from StringIO import StringIO +from gzip import GzipFile + +_Unmarshaller = Any +_timeTuple = Tuple[int, int, int, int, int, int, int, int, int] +# Represents types that can be compared against a DateTime object +_dateTimeComp = Union[AnyStr, DateTime, datetime, _timeTuple] +# A "host description" used by Transport factories +_hostDesc = Union[str, Tuple[str, Mapping[Any, Any]]] + +def escape(s: AnyStr, replace: Callable[[AnyStr, AnyStr, AnyStr], AnyStr] = ...) -> AnyStr: ... + +MAXINT = ... # type: int +MININT = ... # type: int +PARSE_ERROR = ... # type: int +SERVER_ERROR = ... # type: int +APPLICATION_ERROR = ... # type: int +SYSTEM_ERROR = ... # type: int +TRANSPORT_ERROR = ... # type: int +NOT_WELLFORMED_ERROR = ... # type: int +UNSUPPORTED_ENCODING = ... # type: int +INVALID_ENCODING_CHAR = ... # type: int +INVALID_XMLRPC = ... # type: int +METHOD_NOT_FOUND = ... # type: int +INVALID_METHOD_PARAMS = ... # type: int +INTERNAL_ERROR = ... # type: int + +class Error(Exception): ... + +class ProtocolError(Error): + url = ... # type: str + errcode = ... # type: int + errmsg = ... # type: str + headers = ... # type: Any + def __init__(self, url: str, errcode: int, errmsg: str, headers: Any) -> None: ... + +class ResponseError(Error): ... + +class Fault(Error): + faultCode = ... # type: Any + faultString = ... # type: str + def __init__(self, faultCode: Any, faultString: str, **extra: Any) -> None: ... + +boolean = ... # type: Type[bool] +Boolean = ... # type: Type[bool] + +class DateTime: + value = ... # type: str + def __init__(self, value: Union[str, unicode, datetime, float, int, _timeTuple, struct_time] = ...) -> None: ... + def make_comparable(self, other: _dateTimeComp) -> Tuple[_dateTimeComp, _dateTimeComp]: ... + def __lt__(self, other: _dateTimeComp) -> bool: ... + def __le__(self, other: _dateTimeComp) -> bool: ... + def __gt__(self, other: _dateTimeComp) -> bool: ... + def __ge__(self, other: _dateTimeComp) -> bool: ... + def __eq__(self, other: _dateTimeComp) -> bool: ... + def __ne__(self, other: _dateTimeComp) -> bool: ... + def timetuple(self) -> struct_time: ... + def __cmp__(self, other: _dateTimeComp) -> int: ... + def decode(self, data: Any) -> None: ... + def encode(self, out: IO) -> None: ... + +class Binary: + data = ... # type: str + def __init__(self, data: Optional[str] = ...) -> None: ... + def __cmp__(self, other: Any) -> int: ... + def decode(self, data: str) -> None: ... + def encode(self, out: IO) -> None: ... + +WRAPPERS = ... # type: tuple + +# Still part of the public API, but see http://bugs.python.org/issue1773632 +FastParser = ... # type: None +FastUnmarshaller = ... # type: None +FastMarshaller = ... # type: None + +# xmlrpclib.py will leave ExpatParser undefined if it can't import expat from +# xml.parsers. Because this is Python 2.7, the import will succeed. +class ExpatParser: + def __init__(self, target: _Unmarshaller) -> None: ... + def feed(self, data: str): ... + def close(self): ... + +# TODO: Add xmllib.XMLParser as base class +class SlowParser: + handle_xml = ... # type: Callable[[str, bool], None] + unknown_starttag = ... # type: Callable[[str, Any], None] + handle_data = ... # type: Callable[[str], None] + handle_cdata = ... # type: Callable[[str], None] + unknown_endtag = ... # type: Callable[[str, Callable[[Iterable[str], str], str]], None] + def __init__(self, target: _Unmarshaller) -> None: ... + +class Marshaller: + memo = ... # type: MutableMapping[int, Any] + data = ... # type: Optional[str] + encoding = ... # type: Optional[str] + allow_none = ... # type: bool + def __init__(self, encoding: Optional[str] = ..., allow_none: bool = ...) -> None: ... + dispatch = ... # type: Mapping[type, Callable[[Marshaller, str, Callable[[str], None]], None]] + def dumps(self, values: Union[Iterable[Union[None, int, bool, long, float, str, unicode, List, Tuple, Mapping, datetime, InstanceType]], Fault]) -> str: ... + def dump_nil(self, value: None, write: Callable[[str], None]) -> None: ... + def dump_int(self, value: int, write: Callable[[str], None]) -> None: ... + def dump_bool(self, value: bool, write: Callable[[str], None]) -> None: ... + def dump_long(self, value: long, write: Callable[[str], None]) -> None: ... + def dump_double(self, value: float, write: Callable[[str], None]) -> None: ... + def dump_string(self, value: str, write: Callable[[str], None], escape: Callable[[AnyStr, Callable[[AnyStr, AnyStr, AnyStr], AnyStr]], AnyStr] = ...) -> None: ... + def dump_unicode(self, value: unicode, write: Callable[[str], None], escape: Callable[[AnyStr, Callable[[AnyStr, AnyStr, AnyStr], AnyStr]], AnyStr] = ...) -> None: ... + def dump_array(self, value: Union[List, Tuple], write: Callable[[str], None]) -> None: ... + def dump_struct(self, value: Mapping, write: Callable[[str], None], escape: Callable[[AnyStr, Callable[[AnyStr, AnyStr, AnyStr], AnyStr]], AnyStr] = ...) -> None: ... + def dump_datetime(self, value: datetime, write: Callable[[str], None]) -> None: ... + def dump_instance(self, value: InstanceType, write: Callable[[str], None]) -> None: ... + +class Unmarshaller: + def append(self, object: Any) -> None: ... + def __init__(self, use_datetime: bool = ...) -> None: ... + def close(self) -> tuple: ... + def getmethodname(self) -> Optional[str]: ... + def xml(self, encoding: str, standalone: bool) -> None: ... + def start(self, tag: str, attrs: Any) -> None: ... + def data(self, text: str) -> None: ... + def end(self, tag: str, join: Callable[[Iterable[str], str], str] = ...) -> None: ... + def end_dispatch(self, tag: str, data: str) -> None: ... + dispatch = ... # type: Mapping[str, Callable[[Unmarshaller, str], None]] + def end_nil(self, data: str): ... + def end_boolean(self, data: str) -> None: ... + def end_int(self, data: str) -> None: ... + def end_double(self, data: str) -> None: ... + def end_string(self, data: str) -> None: ... + def end_array(self, data: str) -> None: ... + def end_struct(self, data: str) -> None: ... + def end_base64(self, data: str) -> None: ... + def end_dateTime(self, data: str) -> None: ... + def end_value(self, data: str) -> None: ... + def end_params(self, data: str) -> None: ... + def end_fault(self, data: str) -> None: ... + def end_methodName(self, data: str) -> None: ... + +class _MultiCallMethod: + def __init__(self, call_list: List[Tuple[str, tuple]], name: str) -> None: ... +class MultiCallIterator: + def __init__(self, results: List) -> None: ... + +class MultiCall: + def __init__(self, server: ServerProxy) -> None: ... + def __getattr__(self, name: str) -> _MultiCallMethod: ... + def __call__(self) -> MultiCallIterator: ... + +def getparser(use_datetime: bool = ...) -> Tuple[Union[ExpatParser, SlowParser], Unmarshaller]: ... +def dumps(params: Union[tuple, Fault], methodname: Optional[str] = ..., methodresponse: Optional[bool] = ..., encoding: Optional[str] = ..., allow_none: bool = ...) -> str: ... +def loads(data: str, use_datetime: bool = ...) -> Tuple[tuple, Optional[str]]: ... + +def gzip_encode(data: str) -> str: ... +def gzip_decode(data: str, max_decode: int = ...) -> str: ... + +class GzipDecodedResponse(GzipFile): + stringio = ... # type: StringIO + def __init__(self, response: HTTPResponse) -> None: ... + def close(self): ... + +class _Method: + def __init__(self, send: Callable[[str, tuple], Any], name: str) -> None: ... + def __getattr__(self, name: str) -> _Method: ... + def __call__(self, *args: Any) -> Any: ... + +class Transport: + user_agent = ... # type: str + accept_gzip_encoding = ... # type: bool + encode_threshold = ... # type: Optional[int] + def __init__(self, use_datetime: bool = ...) -> None: ... + def request(self, host: _hostDesc, handler: str, request_body: str, verbose: bool = ...) -> tuple: ... + verbose = ... # type: bool + def single_request(self, host: _hostDesc, handler: str, request_body: str, verbose: bool = ...) -> tuple: ... + def getparser(self) -> Tuple[Union[ExpatParser, SlowParser], Unmarshaller]: ... + def get_host_info(self, host: _hostDesc) -> Tuple[str, Optional[List[Tuple[str, str]]], Optional[Mapping[Any, Any]]]: ... + def make_connection(self, host: _hostDesc) -> HTTPConnection: ... + def close(self) -> None: ... + def send_request(self, connection: HTTPConnection, handler: str, request_body: str) -> None: ... + def send_host(self, connection: HTTPConnection, host: str) -> None: ... + def send_user_agent(self, connection: HTTPConnection) -> None: ... + def send_content(self, connection: HTTPConnection, request_body: str) -> None: ... + def parse_response(self, response: HTTPResponse) -> tuple: ... + +class SafeTransport(Transport): + def __init__(self, use_datetime: bool = ..., context: Optional[SSLContext] = ...) -> None: ... + def make_connection(self, host: _hostDesc) -> HTTPSConnection: ... + +class ServerProxy: + def __init__(self, uri: str, transport: Optional[Transport] = ..., encoding: Optional[str] = ..., verbose: bool = ..., allow_none: bool = ..., use_datetime: bool = ..., context: Optional[SSLContext] = ...) -> None: ... + def __getattr__(self, name: str) -> _Method: ... + def __call__(self, attr: str) -> Optional[Transport]: ... + +Server = ServerProxy diff --git a/python/helpers/typeshed/stdlib/2and3/__future__.pyi b/python/helpers/typeshed/stdlib/2and3/__future__.pyi new file mode 100644 index 000000000000..7eed90e5677f --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/__future__.pyi @@ -0,0 +1,21 @@ +import sys +from typing import List + +class _Feature: + def getOptionalRelease(self) -> sys._version_info: ... + def getMandatoryRelease(self) -> sys._version_info: ... + +absolute_import: _Feature +division: _Feature +generators: _Feature +nested_scopes: _Feature +print_function: _Feature +unicode_literals: _Feature +with_statement: _Feature +if sys.version_info >= (3, 0): + barry_as_FLUFL: _Feature + +if sys.version_info >= (3, 5): + generator_stop: _Feature + +all_feature_names: List[str] diff --git a/python/helpers/typeshed/stdlib/2and3/_codecs.pyi b/python/helpers/typeshed/stdlib/2and3/_codecs.pyi new file mode 100644 index 000000000000..32163eb913d0 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/_codecs.pyi @@ -0,0 +1,74 @@ +"""Stub file for the '_codecs' module.""" + +import sys +from typing import Any, Callable, Tuple, Optional, Dict, Text, Union + +import codecs + +# For convenience: +_Handler = Callable[[Exception], Tuple[Text, int]] +_String = Union[bytes, str] +_Errors = Union[str, Text, None] +if sys.version_info < (3, 0): + _Decodable = Union[bytes, Text] + _Encodable = Union[bytes, Text] +else: + _Decodable = bytes + _Encodable = str + +# This type is not exposed; it is defined in unicodeobject.c +class _EncodingMap(object): + def size(self) -> int: ... +_MapT = Union[Dict[int, int], _EncodingMap] + +def register(search_function: Callable[[str], Any]) -> None: ... +def register_error(errors: Union[str, Text], handler: _Handler) -> None: ... +def lookup(encoding: Union[str, Text]) -> codecs.CodecInfo: ... +def lookup_error(name: Union[str, Text]) -> _Handler: ... +def decode(obj: Any, encoding: Union[str, Text] = ..., errors: _Errors = ...) -> Any: ... +def encode(obj: Any, encoding: Union[str, Text] = ..., errors: _Errors = ...) -> Any: ... +def charmap_build(map: Text) -> _MapT: ... + +def ascii_decode(data: _Decodable, errors: _Errors = ...) -> Tuple[Text, int]: ... +def ascii_encode(data: _Encodable, errors: _Errors = ...) -> Tuple[bytes, int]: ... +def charbuffer_encode(data: _Encodable, errors: _Errors = ...) -> Tuple[bytes, int]: ... +def charmap_decode(data: _Decodable, errors: _Errors = ..., mapping: Optional[_MapT] = ...) -> Tuple[Text, int]: ... +def charmap_encode(data: _Encodable, errors: _Errors, mapping: Optional[_MapT] = ...) -> Tuple[bytes, int]: ... +def escape_decode(data: _String, errors: _Errors = ...) -> Tuple[str, int]: ... +def escape_encode(data: bytes, errors: _Errors = ...) -> Tuple[bytes, int]: ... +def latin_1_decode(data: _Decodable, errors: _Errors = ...) -> Tuple[Text, int]: ... +def latin_1_encode(data: _Encodable, errors: _Errors = ...) -> Tuple[bytes, int]: ... +def raw_unicode_escape_decode(data: _String, errors: _Errors = ...) -> Tuple[Text, int]: ... +def raw_unicode_escape_encode(data: _Encodable, errors: _Errors = ...) -> Tuple[bytes, int]: ... +def readbuffer_encode(data: _String, errors: _Errors = ...) -> Tuple[bytes, int]: ... +def unicode_escape_decode(data: _String, errors: _Errors = ...) -> Tuple[Text, int]: ... +def unicode_escape_encode(data: _Encodable, errors: _Errors = ...) -> Tuple[bytes, int]: ... +def unicode_internal_decode(data: _String, errors: _Errors = ...) -> Tuple[Text, int]: ... +def unicode_internal_encode(data: _String, errors: _Errors = ...) -> Tuple[bytes, int]: ... +def utf_16_be_decode(data: _Decodable, errors: _Errors = ..., final: int = ...) -> Tuple[Text, int]: ... +def utf_16_be_encode(data: _Encodable, errors: _Errors = ...) -> Tuple[bytes, int]: ... +def utf_16_decode(data: _Decodable, errors: _Errors = ..., final: int = ...) -> Tuple[Text, int]: ... +def utf_16_encode(data: _Encodable, errors: _Errors = ..., byteorder: int = ...) -> Tuple[bytes, int]: ... +def utf_16_ex_decode(data: _Decodable, errors: _Errors = ..., final: int = ...) -> Tuple[Text, int, int]: ... +def utf_16_le_decode(data: _Decodable, errors: _Errors = ..., final: int = ...) -> Tuple[Text, int]: ... +def utf_16_le_encode(data: _Encodable, errors: _Errors = ...) -> Tuple[bytes, int]: ... +def utf_32_be_decode(data: _Decodable, errors: _Errors = ..., final: int = ...) -> Tuple[Text, int]: ... +def utf_32_be_encode(data: _Encodable, errors: _Errors = ...) -> Tuple[bytes, int]: ... +def utf_32_decode(data: _Decodable, errors: _Errors = ..., final: int = ...) -> Tuple[Text, int]: ... +def utf_32_encode(data: _Encodable, errors: _Errors = ..., byteorder: int = ...) -> Tuple[bytes, int]: ... +def utf_32_ex_decode(data: _Decodable, errors: _Errors = ..., final: int = ...) -> Tuple[Text, int, int]: ... +def utf_32_le_decode(data: _Decodable, errors: _Errors = ..., final: int = ...) -> Tuple[Text, int]: ... +def utf_32_le_encode(data: _Encodable, errors: _Errors = ...) -> Tuple[bytes, int]: ... +def utf_7_decode(data: _Decodable, errors: _Errors = ..., final: int = ...) -> Tuple[Text, int]: ... +def utf_7_encode(data: _Encodable, errors: _Errors = ...) -> Tuple[bytes, int]: ... +def utf_8_decode(data: _Decodable, errors: _Errors = ..., final: int = ...) -> Tuple[Text, int]: ... +def utf_8_encode(data: _Encodable, errors: _Errors = ...) -> Tuple[bytes, int]: ... + +if sys.platform == 'win32': + def mbcs_decode(data: _Decodable, errors: _Errors = ..., final: int = ...) -> Tuple[Text, int]: ... + def mbcs_encode(str: _Encodable, errors: _Errors = ...) -> Tuple[bytes, int]: ... + if sys.version_info >= (3, 0): + def oem_decode(data: bytes, errors: _Errors = ..., final: int = ...) -> Tuple[Text, int]: ... + def code_page_decode(codepage: int, data: bytes, errors: _Errors = ..., final: int = ...) -> Tuple[Text, int]: ... + def oem_encode(str: Text, errors: _Errors = ...) -> Tuple[bytes, int]: ... + def code_page_encode(code_page: int, str: Text, errors: _Errors = ...) -> Tuple[bytes, int]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/_csv.pyi b/python/helpers/typeshed/stdlib/2and3/_csv.pyi new file mode 100644 index 000000000000..d5119aea8acb --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/_csv.pyi @@ -0,0 +1,45 @@ +import sys + +from typing import Any, Iterable, Iterator, List, Optional, Sequence + +QUOTE_ALL = ... # type: int +QUOTE_MINIMAL = ... # type: int +QUOTE_NONE = ... # type: int +QUOTE_NONNUMERIC = ... # type: int + +class Error(Exception): ... + +class Dialect: + delimiter = ... # type: str + quotechar = ... # type: Optional[str] + escapechar = ... # type: Optional[str] + doublequote = ... # type: bool + skipinitialspace = ... # type: bool + lineterminator = ... # type: str + quoting = ... # type: int + strict = ... # type: int + def __init__(self) -> None: ... + +class _reader(Iterator[List[str]]): + dialect = ... # type: Dialect + line_num = ... # type: int + +class _writer: + dialect = ... # type: Dialect + + if sys.version_info >= (3, 5): + def writerow(self, row: Iterable[Any]) -> None: ... + def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ... + else: + def writerow(self, row: Sequence[Any]) -> None: ... + def writerows(self, rows: Iterable[Sequence[Any]]) -> None: ... + + +# TODO: precise type +def writer(csvfile: Any, dialect: Any = ..., **fmtparams: Any) -> _writer: ... +def reader(csvfile: Iterable[str], dialect: Any = ..., **fmtparams: Any) -> _reader: ... +def register_dialect(name: str, dialect: Any = ..., **fmtparams: Any) -> None: ... +def unregister_dialect(name: str) -> None: ... +def get_dialect(name: str) -> Dialect: ... +def list_dialects() -> List[str]: ... +def field_size_limit(new_limit: int = ...) -> int: ... diff --git a/python/helpers/typeshed/stdlib/2and3/_random.pyi b/python/helpers/typeshed/stdlib/2and3/_random.pyi new file mode 100644 index 000000000000..a37149da00b3 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/_random.pyi @@ -0,0 +1,17 @@ +# Stubs for _random + +import sys +from typing import Tuple + +# Actually Tuple[(int,) * 625] +_State = Tuple[int, ...] + +class Random(object): + def __init__(self, seed: object = ...) -> None: ... + def seed(self, x: object = ...) -> None: ... + def getstate(self) -> _State: ... + def setstate(self, state: _State) -> None: ... + def random(self) -> float: ... + def getrandbits(self, k: int) -> int: ... + if sys.version_info < (3,): + def jumpahead(self, i: int) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/_weakref.pyi b/python/helpers/typeshed/stdlib/2and3/_weakref.pyi new file mode 100644 index 000000000000..76c97df54e8f --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/_weakref.pyi @@ -0,0 +1,24 @@ +import sys +from typing import Any, Callable, Generic, Optional, TypeVar + +_T = TypeVar('_T') + +class CallableProxyType(object): # "weakcallableproxy" + def __getattr__(self, attr: str) -> Any: ... + +class ProxyType(object): # "weakproxy" + def __getattr__(self, attr: str) -> Any: ... + +class ReferenceType(Generic[_T]): + if sys.version_info >= (3, 4): + __callback__: Callable[[ReferenceType[_T]], Any] + def __init__(self, o: _T, callback: Callable[[ReferenceType[_T]], + Any] = ...) -> None: ... + def __call__(self) -> Optional[_T]: ... + def __hash__(self) -> int: ... + +ref = ReferenceType + +def getweakrefcount(object: Any) -> int: ... +def getweakrefs(object: Any) -> int: ... +def proxy(object: _T, callback: Callable[[_T], Any] = ...) -> ref[_T]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/_weakrefset.pyi b/python/helpers/typeshed/stdlib/2and3/_weakrefset.pyi new file mode 100644 index 000000000000..950d3fe64265 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/_weakrefset.pyi @@ -0,0 +1,43 @@ +from typing import Iterator, Any, Iterable, MutableSet, Optional, TypeVar, Generic, Union + +_S = TypeVar('_S') +_T = TypeVar('_T') +_SelfT = TypeVar('_SelfT', bound=WeakSet) + +class WeakSet(MutableSet[_T], Generic[_T]): + def __init__(self, data: Optional[Iterable[_T]] = ...) -> None: ... + + def add(self, item: _T) -> None: ... + def clear(self) -> None: ... + def discard(self, item: _T) -> None: ... + def copy(self: _SelfT) -> _SelfT: ... + def pop(self) -> _T: ... + def remove(self, item: _T) -> None: ... + def update(self, other: Iterable[_T]) -> None: ... + def __contains__(self, item: object) -> bool: ... + def __len__(self) -> int: ... + def __iter__(self) -> Iterator[_T]: ... + + def __ior__(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ... + def difference(self: _SelfT, other: Iterable[_T]) -> _SelfT: ... + def __sub__(self: _SelfT, other: Iterable[_T]) -> _SelfT: ... + def difference_update(self: _SelfT, other: Iterable[_T]) -> None: ... + def __isub__(self: _SelfT, other: Iterable[_T]) -> _SelfT: ... + def intersection(self: _SelfT, other: Iterable[_T]) -> _SelfT: ... + def __and__(self: _SelfT, other: Iterable[_T]) -> _SelfT: ... + def intersection_update(self, other: Iterable[_T]) -> None: ... + def __iand__(self: _SelfT, other: Iterable[_T]) -> _SelfT: ... + def issubset(self, other: Iterable[_T]) -> bool: ... + def __le__(self, other: Iterable[_T]) -> bool: ... + def __lt__(self, other: Iterable[_T]) -> bool: ... + def issuperset(self, other: Iterable[_T]) -> bool: ... + def __ge__(self, other: Iterable[_T]) -> bool: ... + def __gt__(self, other: Iterable[_T]) -> bool: ... + def __eq__(self, other: object) -> bool: ... + def symmetric_difference(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ... + def __xor__(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ... + def symmetric_difference_update(self, other: Iterable[_S]) -> None: ... + def __ixor__(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ... + def union(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ... + def __or__(self, other: Iterable[_S]) -> WeakSet[Union[_S, _T]]: ... + def isdisjoint(self, other: Iterable[_T]) -> bool: ... diff --git a/python/helpers/typeshed/stdlib/2and3/argparse.pyi b/python/helpers/typeshed/stdlib/2and3/argparse.pyi index c481d9ece67e..323ea463a5d9 100644 --- a/python/helpers/typeshed/stdlib/2and3/argparse.pyi +++ b/python/helpers/typeshed/stdlib/2and3/argparse.pyi @@ -117,8 +117,10 @@ class Action: option_string: _Text = ...) -> None: ... class Namespace: + def __init__(self, **kwargs: Any) -> None: ... def __getattr__(self, name: _Text) -> Any: ... def __setattr__(self, name: _Text, value: Any) -> None: ... + def __contains__(self, key: str) -> bool: ... class FileType: if sys.version_info >= (3, 4): diff --git a/python/helpers/typeshed/stdlib/2and3/asynchat.pyi b/python/helpers/typeshed/stdlib/2and3/asynchat.pyi index d397b4c24ef0..7195f807677d 100644 --- a/python/helpers/typeshed/stdlib/2and3/asynchat.pyi +++ b/python/helpers/typeshed/stdlib/2and3/asynchat.pyi @@ -2,28 +2,28 @@ from abc import abstractmethod import asyncore import socket import sys -from typing import Union, Tuple, Sequence +from typing import Optional, Sequence, Tuple, Union class simple_producer: - def __init__(self, data: str, buffer_size: int = ...) -> None: ... - def more(self) -> str: ... + def __init__(self, data: bytes, buffer_size: int = ...) -> None: ... + def more(self) -> bytes: ... -class async_chat (asyncore.dispatcher): +class async_chat(asyncore.dispatcher): ac_in_buffer_size = ... # type: int ac_out_buffer_size = ... # type: int - def __init__(self, sock: socket.socket = None, map: asyncore._maptype = None) -> None: ... + def __init__(self, sock: Optional[socket.socket] = None, map: Optional[asyncore._maptype] = None) -> None: ... @abstractmethod - def collect_incoming_data(self, data: str) -> None: ... + def collect_incoming_data(self, data: bytes) -> None: ... @abstractmethod def found_terminator(self) -> None: ... - def set_terminator(self, term: Union[str, int, None]) -> None: ... - def get_terminator(self) -> Union[str, int, None]: ... + def set_terminator(self, term: Union[bytes, int, None]) -> None: ... + def get_terminator(self) -> Union[bytes, int, None]: ... def handle_read(self) -> None: ... def handle_write(self) -> None: ... def handle_close(self) -> None: ... - def push(self, data: str) -> None: ... + def push(self, data: bytes) -> None: ... def push_with_producer(self, producer: simple_producer) -> None: ... def readable(self) -> bool: ... def writable(self) -> bool: ... @@ -33,9 +33,9 @@ class async_chat (asyncore.dispatcher): if sys.version_info < (3, 0): class fifo: - def __init__(self, list: Sequence[Union[str, simple_producer]] = ...) -> None: ... + def __init__(self, list: Sequence[Union[bytes, simple_producer]] = ...) -> None: ... def __len__(self) -> int: ... def is_empty(self) -> bool: ... - def first(self) -> str: ... - def push(self, data: Union[str, simple_producer]) -> None: ... - def pop(self) -> Tuple[int, str]: ... + def first(self) -> bytes: ... + def push(self, data: Union[bytes, simple_producer]) -> None: ... + def pop(self) -> Tuple[int, bytes]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/asyncore.pyi b/python/helpers/typeshed/stdlib/2and3/asyncore.pyi index 4816da00ff6f..075319788210 100644 --- a/python/helpers/typeshed/stdlib/2and3/asyncore.pyi +++ b/python/helpers/typeshed/stdlib/2and3/asyncore.pyi @@ -25,7 +25,7 @@ def poll2(timeout: float = ..., map: _maptype = ...) -> None: ... poll3 = poll2 -def loop(timeout: float = ..., use_poll: bool = ..., map: _maptype = ..., count: int = None) -> None: ... +def loop(timeout: float = ..., use_poll: bool = ..., map: _maptype = ..., count: Optional[int] = None) -> None: ... # Not really subclass of socket.socket; it's only delegation. @@ -39,7 +39,7 @@ class dispatcher: closing = ... # type: bool ignore_log_types = ... # type: frozenset[str] - def __init__(self, sock: socket.socket = None, map: _maptype = ...) -> None: ... + def __init__(self, sock: Optional[socket.socket] = None, map: _maptype = ...) -> None: ... def add_channel(self, map: _maptype = ...) -> None: ... def del_channel(self, map: _maptype = ...) -> None: ... def create_socket(self, family: int, type: int) -> None: ... @@ -47,10 +47,15 @@ class dispatcher: def set_reuse_addr(self) -> None: ... def readable(self) -> bool: ... def writable(self) -> bool: ... + def listen(self, backlog: int) -> None: ... + def bind(self, address: Union[tuple, str]) -> None: ... + def connect(self, address: Union[tuple, str]) -> None: ... def accept(self) -> Optional[Tuple[socket.socket, Any]]: ... - def recv(self, buffer_size: int) -> str: ... - def log(self, message: Any) -> None: ... + def send(self, data: bytes) -> int: ... + def recv(self, buffer_size: int) -> bytes: ... + def close(self) -> None: ... + def log(self, message: Any) -> None: ... def log_info(self, message: Any, type: str = ...) -> None: ... def handle_read_event(self) -> None: ... def handle_connect_event(self) -> None: ... @@ -63,46 +68,51 @@ class dispatcher: def handle_connect(self) -> None: ... def handle_accept(self) -> None: ... def handle_close(self) -> None: ... - def detach(self) -> int: ... - def fileno(self) -> int: ... - # return value is an address - def getpeername(self) -> Any: ... - def getsockname(self) -> Any: ... + if sys.version_info < (3, 5): + # Historically, some methods were "imported" from `self.socket` by + # means of `__getattr__`. This was long deprecated, and as of Python + # 3.5 has been removed; simply call the relevant methods directly on + # self.socket if necessary. - @overload - def getsockopt(self, level: int, optname: int) -> int: ... - @overload - def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ... + def detach(self) -> int: ... + def fileno(self) -> int: ... - def gettimeout(self) -> float: ... - def ioctl(self, control: object, - option: Tuple[int, int, int]) -> None: ... - def listen(self, backlog: int) -> None: ... - # TODO the return value may be BinaryIO or TextIO, depending on mode - def makefile(self, mode: str = ..., buffering: int = ..., - encoding: str = ..., errors: str = ..., - newline: str = ...) -> Any: - ... + # return value is an address + def getpeername(self) -> Any: ... + def getsockname(self) -> Any: ... - # return type is an address - def recvfrom(self, bufsize: int, flags: int = ...) -> Any: ... - def recvfrom_into(self, buffer: str, nbytes: int, flags: int = ...) -> Any: ... - def recv_into(self, buffer: str, nbytes: int, flags: int = ...) -> Any: ... - def send(self, data: str, flags: int = ...) -> Optional[int]: ... - def sendall(self, data: str, flags: int = ...) -> None: ... - def sendto(self, data: str, address: Union[tuple, str], flags: int = ...) -> 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, str]) -> None: ... - def shutdown(self, how: int) -> None: ... + @overload + def getsockopt(self, level: int, optname: int) -> int: ... + @overload + def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ... + + def gettimeout(self) -> float: ... + def ioctl(self, control: object, + option: Tuple[int, int, int]) -> None: ... + # TODO the return value may be BinaryIO or TextIO, depending on mode + def makefile(self, mode: str = ..., buffering: int = ..., + encoding: str = ..., errors: str = ..., + newline: str = ...) -> Any: + ... + + # return type is an address + def recvfrom(self, bufsize: int, flags: int = ...) -> Any: ... + def recvfrom_into(self, buffer: bytes, nbytes: int, flags: int = ...) -> Any: ... + def recv_into(self, buffer: bytes, nbytes: int, flags: int = ...) -> Any: ... + def sendall(self, data: bytes, flags: int = ...) -> None: ... + def sendto(self, data: bytes, address: Union[tuple, str], flags: int = ...) -> 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: ... + def shutdown(self, how: int) -> None: ... class dispatcher_with_send(dispatcher): def __init__(self, sock: socket.socket = ..., map: _maptype = ...) -> None: ... def initiate_send(self) -> None: ... def handle_write(self) -> None: ... # incompatible signature: - # def send(self, data: str) -> Optional[int]: ... + # def send(self, data: bytes) -> Optional[int]: ... def compact_traceback() -> Tuple[Tuple[str, str, str], type, type, str]: ... def close_all(map: _maptype = ..., ignore_all: bool = ...) -> None: ... @@ -113,16 +123,16 @@ class file_wrapper: fd = ... # type: int def __init__(self, fd: int) -> None: ... - def recv(self, bufsize: int, flags: int = ...) -> str: ... - def send(self, data: str, flags: int = ...) -> int: ... + def recv(self, bufsize: int, flags: int = ...) -> bytes: ... + def send(self, data: bytes, flags: int = ...) -> int: ... @overload def getsockopt(self, level: int, optname: int) -> int: ... @overload def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ... - def read(self, bufsize: int, flags: int = ...) -> str: ... - def write(self, data: str, flags: int = ...) -> int: ... + def read(self, bufsize: int, flags: int = ...) -> bytes: ... + def write(self, data: bytes, flags: int = ...) -> int: ... def close(self) -> None: ... def fileno(self) -> int: ... diff --git a/python/helpers/typeshed/stdlib/2and3/base64.pyi b/python/helpers/typeshed/stdlib/2and3/base64.pyi new file mode 100644 index 000000000000..70db6ad80df5 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/base64.pyi @@ -0,0 +1,44 @@ +# Stubs for base64 + +from typing import IO, Union, Text +import sys + +if sys.version_info < (3,): + _encodable = Union[bytes, Text] + _decodable = Union[bytes, Text] +elif sys.version_info < (3, 3): + _encodable = bytes + _decodable = bytes +elif sys.version_info[:2] == (3, 3): + _encodable = bytes + _decodable = Union[bytes, str] +elif sys.version_info >= (3, 4): + _encodable = Union[bytes, bytearray, memoryview] + _decodable = Union[bytes, bytearray, memoryview, str] + +def b64encode(s: _encodable, altchars: bytes = ...) -> bytes: ... +def b64decode(s: _decodable, altchars: bytes = ..., + validate: bool = ...) -> bytes: ... +def standard_b64encode(s: _encodable) -> bytes: ... +def standard_b64decode(s: _decodable) -> bytes: ... +def urlsafe_b64encode(s: _encodable) -> bytes: ... +def urlsafe_b64decode(s: _decodable) -> bytes: ... +def b32encode(s: _encodable) -> bytes: ... +def b32decode(s: _decodable, casefold: bool = ..., + map01: bytes = ...) -> bytes: ... +def b16encode(s: _encodable) -> bytes: ... +def b16decode(s: _decodable, casefold: bool = ...) -> bytes: ... +if sys.version_info >= (3, 4): + def a85encode(b: _encodable, *, foldspaces: bool = ..., wrapcol: int = ..., + pad: bool = ..., adobe: bool = ...) -> bytes: ... + def a85decode(b: _decodable, *, foldspaces: bool = ..., + adobe: bool = ..., ignorechars: Union[str, bytes] = ...) -> bytes: ... + def b85encode(b: _encodable, pad: bool = ...) -> bytes: ... + def b85decode(b: _decodable) -> bytes: ... + +def decode(input: IO[bytes], output: IO[bytes]) -> None: ... +def decodebytes(s: bytes) -> bytes: ... +def decodestring(s: bytes) -> bytes: ... +def encode(input: IO[bytes], output: IO[bytes]) -> None: ... +def encodebytes(s: bytes) -> bytes: ... +def encodestring(s: bytes) -> bytes: ... diff --git a/python/helpers/typeshed/stdlib/2and3/binascii.pyi b/python/helpers/typeshed/stdlib/2and3/binascii.pyi new file mode 100644 index 000000000000..393c4afcb8ce --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/binascii.pyi @@ -0,0 +1,45 @@ +# Stubs for binascii + +# Based on http://docs.python.org/3.2/library/binascii.html + +import sys +from typing import Union, Text + + +if sys.version_info < (3,): + # Python 2 accepts unicode ascii pretty much everywhere. + _Bytes = Union[bytes, Text] + _Ascii = Union[bytes, Text] +elif sys.version_info < (3, 3): + # Python 3.2 and below only accepts bytes. + _Bytes = bytes + _Ascii = bytes +else: + # But since Python 3.3 ASCII-only unicode strings are accepted by the + # a2b_* functions. + _Bytes = bytes + _Ascii = Union[bytes, Text] + +def a2b_uu(string: _Ascii) -> bytes: ... +def b2a_uu(data: _Bytes) -> bytes: ... +def a2b_base64(string: _Ascii) -> bytes: ... +if sys.version_info >= (3, 6): + def b2a_base64(data: _Bytes, *, newline: bool = ...) -> bytes: ... +else: + def b2a_base64(data: _Bytes) -> bytes: ... +def a2b_qp(string: _Ascii, header: bool = ...) -> bytes: ... +def b2a_qp(data: _Bytes, quotetabs: bool = ..., istext: bool = ..., + header: bool = ...) -> bytes: ... +def a2b_hqx(string: _Ascii) -> bytes: ... +def rledecode_hqx(data: _Bytes) -> bytes: ... +def rlecode_hqx(data: _Bytes) -> bytes: ... +def b2a_hqx(data: _Bytes) -> bytes: ... +def crc_hqx(data: _Bytes, crc: int) -> int: ... +def crc32(data: _Bytes, crc: int = ...) -> int: ... +def b2a_hex(data: _Bytes) -> bytes: ... +def hexlify(data: _Bytes) -> bytes: ... +def a2b_hex(hexstr: _Ascii) -> bytes: ... +def unhexlify(hexlify: _Ascii) -> bytes: ... + +class Error(Exception): ... +class Incomplete(Exception): ... diff --git a/python/helpers/typeshed/stdlib/2and3/bz2.pyi b/python/helpers/typeshed/stdlib/2and3/bz2.pyi index e7cdab594d43..7c92e4359aff 100644 --- a/python/helpers/typeshed/stdlib/2and3/bz2.pyi +++ b/python/helpers/typeshed/stdlib/2and3/bz2.pyi @@ -1,21 +1,21 @@ # Stubs for bz2 -from typing import Any, BinaryIO, TextIO, IO, Union +from typing import Any, BinaryIO, TextIO, IO, Optional, Union def compress(data: bytes, compresslevel: int = ...) -> bytes: ... def decompress(data: bytes) -> bytes: ... def open(filename: Union[str, bytes, IO[Any]], mode: str = 'rb', - encoding: str = None, - errors: str = None, - newline: str = None) -> IO[Any]: ... + encoding: Optional[str] = None, + errors: Optional[str] = None, + newline: Optional[str] = None) -> IO[Any]: ... class BZ2File(BinaryIO): def __init__(self, filename: Union[str, bytes, IO[Any]], mode: str = "r", - buffering: Any = None, + buffering: Optional[Any] = None, compresslevel: int = 9) -> None: ... class BZ2Compressor(object): diff --git a/python/helpers/typeshed/stdlib/2and3/calendar.pyi b/python/helpers/typeshed/stdlib/2and3/calendar.pyi new file mode 100644 index 000000000000..6b59fd055163 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/calendar.pyi @@ -0,0 +1,111 @@ +import datetime +import sys +from time import struct_time +from typing import Any, Iterable, List, Optional, Sequence, Tuple, Union + + +_LocaleType = Tuple[Optional[str], Optional[str]] + +class IllegalMonthError(ValueError): + def __init__(self, month: int) -> None: ... + def __str__(self) -> str: ... + +class IllegalWeekdayError(ValueError): + def __init__(self, weekday: int) -> None: ... + def __str__(self) -> str: ... + +def isleap(year: int) -> bool: ... +def leapdays(y1: int, y2: int) -> int: ... +def weekday(year: int, month: int, day: int) -> int: ... +def monthrange(year: int, month: int) -> Tuple[int, int]: ... + +class Calendar: + def __init__(self, firstweekday: int = ...) -> None: ... + def getfirstweekday(self) -> int: ... + def setfirstweekday(self, firstweekday: int) -> None: ... + def iterweekdays(self) -> Iterable[int]: ... + def itermonthdates(self, year: int, month: int) -> Iterable[datetime.date]: ... + def itermonthdays2(self, year: int, month: int) -> Iterable[Tuple[int, int]]: ... + def itermonthdays(self, year: int, month: int) -> Iterable[int]: ... + def monthdatescalendar(self, year: int, month: int) -> List[List[datetime.date]]: ... + def monthdays2calendar(self, year: int, month: int) -> List[List[Tuple[int, int]]]: ... + def monthdayscalendar(self, year: int, month: int) -> List[List[int]]: ... + def yeardatescalendar(self, year: int, width: int = ...) -> List[List[int]]: ... + def yeardays2calendar(self, year: int, width: int = ...) -> List[List[Tuple[int, int]]]: ... + def yeardayscalendar(self, year: int, width: int = ...) -> List[List[int]]: ... + +class TextCalendar(Calendar): + def prweek(self, theweek: int, width: int) -> None: ... + def formatday(self, day: int, weekday: int, width: int) -> str: ... + def formatweek(self, theweek: int, width: int) -> str: ... + def formatweekday(self, day: int, width: int) -> str: ... + def formatweekheader(self, width: int) -> str: ... + def formatmonthname(self, theyear: int, themonth: int, width: int, withyear: bool = ...) -> str: ... + def prmonth(self, theyear: int, themonth: int, w: int = ..., l: int = ...) -> None: ... + def formatmonth(self, theyear: int, themonth: int, w: int = ..., l: int = ...) -> str: ... + def formatyear(self, theyear: int, w: int = ..., l: int = ..., c: int = ..., m: int = ...) -> str: ... + def pryear(self, theyear: int, w: int = ..., l: int = ..., c: int = ..., m: int = ...) -> None: ... + +def firstweekday() -> int: ... +def monthcalendar(year: int, month: int) -> List[List[int]]: ... +def prweek(theweek: int, width: int) -> None: ... +def week(theweek: int, width: int) -> str: ... +def weekheader(width: int) -> str: ... +def prmonth(theyear: int, themonth: int, w: int = ..., l: int = ...) -> None: ... +def month(theyear: int, themonth: int, w: int = ..., l: int = ...) -> str: ... +def calendar(theyear: int, w: int = ..., l: int = ..., c: int = ..., m: int = ...) -> str: ... +def prcal(theyear: int, w: int = ..., l: int = ..., c: int = ..., m: int = ...) -> None: ... + +class HTMLCalendar(Calendar): + def formatday(self, day: int, weekday: int) -> str: ... + def formatweek(self, theweek: int) -> str: ... + def formatweekday(self, day: int) -> str: ... + def formatweekheader(self) -> str: ... + def formatmonthname(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ... + def formatmonth(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ... + def formatyear(self, theyear: int, width: int = ...) -> str: ... + def formatyearpage(self, theyear: int, width: int = ..., css: Optional[str] = ..., encoding: Optional[str] = ...) -> str: ... + +if sys.version_info < (3, 0): + class TimeEncoding: + def __init__(self, locale: _LocaleType) -> None: ... + def __enter__(self) -> _LocaleType: ... + def __exit__(self, *args) -> None: ... +else: + class different_locale: + def __init__(self, locale: _LocaleType) -> None: ... + def __enter__(self) -> _LocaleType: ... + def __exit__(self, *args) -> None: ... + +class LocaleTextCalendar(TextCalendar): + def __init__(self, firstweekday: int = ..., locale: Optional[_LocaleType] = ...) -> None: ... + def formatweekday(self, day: int, width: int) -> str: ... + def formatmonthname(self, theyear: int, themonth: int, width: int, withyear: bool = ...) -> str: ... + +class LocaleHTMLCalendar(HTMLCalendar): + def __init__(self, firstweekday: int = ..., locale: Optional[_LocaleType] = ...) -> None: ... + def formatweekday(self, day: int) -> str: ... + def formatmonthname(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ... + +c = ... # type: TextCalendar +def setfirstweekday(firstweekday: int) -> None: ... +def format(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ... +def formatstring(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ... +def timegm(tuple: Union[Tuple[int, ...], struct_time]) -> int: ... + +# Data attributes +day_name = ... # type: Sequence[str] +day_abbr = ... # type: Sequence[str] +month_name = ... # type: Sequence[str] +month_abbr = ... # type: Sequence[str] + +# Below constants are not in docs or __all__, but enough people have used them +# they are now effectively public. + +MONDAY = ... # type: int +TUESDAY = ... # type: int +WEDNESDAY = ... # type: int +THURSDAY = ... # type: int +FRIDAY = ... # type: int +SATURDAY = ... # type: int +SUNDAY = ... # type: int diff --git a/python/helpers/typeshed/stdlib/2and3/cgi.pyi b/python/helpers/typeshed/stdlib/2and3/cgi.pyi index 3898e7c6089d..e8a9fd924753 100644 --- a/python/helpers/typeshed/stdlib/2and3/cgi.pyi +++ b/python/helpers/typeshed/stdlib/2and3/cgi.pyi @@ -38,6 +38,7 @@ class MiniFieldStorage: class FieldStorage(object): + FieldStorageClass = ... # type: Optional[type] keep_blank_values = ... # type: int strict_parsing = ... # type: int qs_on_post = ... # type: Optional[str] diff --git a/python/helpers/typeshed/stdlib/2and3/chunk.pyi b/python/helpers/typeshed/stdlib/2and3/chunk.pyi new file mode 100644 index 000000000000..79255c22fa0e --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/chunk.pyi @@ -0,0 +1,23 @@ +# Source(py2): https://hg.python.org/cpython/file/2.7/Lib/chunk.py +# Source(py3): https://github.com/python/cpython/blob/master/Lib/chunk.py + +from typing import IO + +class Chunk: + closed = ... # type: bool + align = ... # type: bool + file = ... # type: IO[bytes] + chunkname = ... # type: bytes + chunksize = ... # type: int + size_read = ... # type: int + offset = ... # type: int + seekable = ... # type: bool + def __init__(self, file: IO[bytes], align: bool = ..., bigendian: bool = ..., inclheader: bool = ...) -> None: ... + def getname(self) -> bytes: ... + def getsize(self) -> int: ... + def close(self) -> None: ... + def isatty(self) -> bool: ... + def seek(self, pos: int, whence: int = ...) -> None: ... + def tell(self) -> int: ... + def read(self, size: int = ...) -> bytes: ... + def skip(self) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/cmd.pyi b/python/helpers/typeshed/stdlib/2and3/cmd.pyi new file mode 100644 index 000000000000..dc305c95c2d3 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/cmd.pyi @@ -0,0 +1,41 @@ +# Stubs for cmd (Python 2/3) + +from typing import Any, Optional, Text, IO, List, Callable, Tuple + +class Cmd: + prompt = ... # type: str + identchars = ... # type: str + ruler = ... # type: str + lastcmd = ... # type: str + intro = ... # type: Optional[Any] + doc_leader = ... # type: str + doc_header = ... # type: str + misc_header = ... # type: str + undoc_header = ... # type: str + nohelp = ... # type: str + use_rawinput = ... # type: bool + stdin = ... # type: IO[str] + stdout = ... # type: IO[str] + cmdqueue = ... # type: List[str] + completekey = ... # type: str + def __init__(self, completekey: str = ..., stdin: Optional[IO[str]] = ..., stdout: Optional[IO[str]] = ...) -> None: ... + old_completer = ... # type: Optional[Callable[[str, int], Optional[str]]] + def cmdloop(self, intro: Optional[Any] = ...) -> None: ... + def precmd(self, line: str) -> str: ... + def postcmd(self, stop: bool, line: str) -> bool: ... + def preloop(self) -> None: ... + def postloop(self) -> None: ... + def parseline(self, line: str) -> Tuple[Optional[str], Optional[str], str]: ... + def onecmd(self, line: str) -> bool: ... + def emptyline(self) -> bool: ... + def default(self, line: str) -> bool: ... + def completedefault(self, *ignored: Any) -> List[str]: ... + def completenames(self, text: str, *ignored: Any) -> List[str]: ... + completion_matches = ... # type: Optional[List[str]] + def complete(self, text: str, state: int) -> Optional[List[str]]: ... + def get_names(self) -> List[str]: ... + # Only the first element of args matters. + def complete_help(self, *args: Any) -> List[str]: ... + def do_help(self, arg: Optional[str]) -> None: ... + def print_topics(self, header: str, cmds: Optional[List[str]], cmdlen: Any, maxcol: int) -> None: ... + def columnize(self, list: Optional[List[str]], displaywidth: int = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/codeop.pyi b/python/helpers/typeshed/stdlib/2and3/codeop.pyi new file mode 100644 index 000000000000..826e40882a7c --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/codeop.pyi @@ -0,0 +1,17 @@ +# Source(py2): https://hg.python.org/cpython/file/2.7/Lib/codeop.py +# Source(py3): https://github.com/python/cpython/blob/master/Lib/codeop.py + +from types import CodeType +from typing import Optional + +def compile_command(source: str, filename: str = ..., symbol: str = ...) -> Optional[CodeType]: ... + +class Compile: + flags = ... # type: int + def __init__(self) -> None: ... + def __call__(self, source: str, filename: str, symbol: str) -> CodeType: ... + +class CommandCompiler: + compiler = ... # type: Compile + def __init__(self) -> None: ... + def __call__(self, source: str, filename: str = ..., symbol: str = ...) -> Optional[CodeType]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/contextlib.pyi b/python/helpers/typeshed/stdlib/2and3/contextlib.pyi index 0f14afaeec20..480546fb95ac 100644 --- a/python/helpers/typeshed/stdlib/2and3/contextlib.pyi +++ b/python/helpers/typeshed/stdlib/2and3/contextlib.pyi @@ -2,30 +2,40 @@ from typing import ( Any, Callable, Generator, IO, Iterable, Iterator, Optional, Type, - Generic, TypeVar, + Generic, TypeVar ) from types import TracebackType import sys +# Aliased here for backwards compatibility; TODO eventually remove this +from typing import ContextManager as ContextManager + +if sys.version_info >= (3, 5): + from typing import AsyncContextManager, AsyncIterator + +if sys.version_info >= (3, 6): + from typing import ContextManager as AbstractContextManager _T = TypeVar('_T') + _ExitFunc = Callable[[Optional[Type[BaseException]], - Optional[Exception], + Optional[BaseException], Optional[TracebackType]], bool] _CM_EF = TypeVar('_CM_EF', ContextManager, _ExitFunc) -# TODO already in PEP, have to get added to mypy -class ContextManager(Generic[_T]): - def __enter__(self) -> _T: ... - def __exit__(self, exc_type: Optional[Type[BaseException]], - exc_val: Optional[Exception], - exc_tb: Optional[TracebackType]) -> bool: ... +if sys.version_info >= (3, 2): + class GeneratorContextManager(ContextManager[_T], Generic[_T]): + def __call__(self, func: Callable[..., _T]) -> Callable[..., _T]: ... + def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., GeneratorContextManager[_T]]: ... +else: + def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ... -def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ... +if sys.version_info >= (3, 7): + def asynccontextmanager(func: Callable[..., AsyncIterator[_T]]) -> Callable[..., AsyncContextManager[_T]]: ... if sys.version_info < (3,): def nested(*mgr: ContextManager[Any]) -> ContextManager[Iterable[Any]]: ... -class closing(Generic[_T], ContextManager[_T]): +class closing(ContextManager[_T], Generic[_T]): def __init__(self, thing: _T) -> None: ... if sys.version_info >= (3, 4): diff --git a/python/helpers/typeshed/stdlib/2and3/copy.pyi b/python/helpers/typeshed/stdlib/2and3/copy.pyi new file mode 100644 index 000000000000..523802a84ee7 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/copy.pyi @@ -0,0 +1,14 @@ +# Stubs for copy + +from typing import TypeVar, Optional, Dict, Any + +_T = TypeVar('_T') + +# None in CPython but non-None in Jython +PyStringMap: Any + +# Note: memo and _nil are internal kwargs. +def deepcopy(x: _T, memo: Optional[Dict[int, _T]] = ..., _nil: Any = ...) -> _T: ... +def copy(x: _T) -> _T: ... +class Error(Exception): ... +error = Error diff --git a/python/helpers/typeshed/stdlib/2and3/csv.pyi b/python/helpers/typeshed/stdlib/2and3/csv.pyi new file mode 100644 index 000000000000..8f6b57ddde7b --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/csv.pyi @@ -0,0 +1,93 @@ +from collections import OrderedDict +import sys +from typing import Any, Dict, Iterable, Iterator, List, Optional, Sequence, Union + +from _csv import (_reader, + _writer, + reader as reader, + writer as writer, + register_dialect as register_dialect, + unregister_dialect as unregister_dialect, + get_dialect as get_dialect, + list_dialects as list_dialects, + field_size_limit as field_size_limit, + QUOTE_ALL as QUOTE_ALL, + QUOTE_MINIMAL as QUOTE_MINIMAL, + QUOTE_NONE as QUOTE_NONE, + QUOTE_NONNUMERIC as QUOTE_NONNUMERIC, + Error as Error, + ) + +_Dialect = Union[str, Dialect] +_DictRow = Dict[str, Any] + +class Dialect(object): + delimiter = ... # type: str + quotechar = ... # type: Optional[str] + escapechar = ... # type: Optional[str] + doublequote = ... # type: bool + skipinitialspace = ... # type: bool + lineterminator = ... # type: str + quoting = ... # type: int + def __init__(self) -> None: ... + +class excel(Dialect): + delimiter = ... # type: str + quotechar = ... # type: str + doublequote = ... # type: bool + skipinitialspace = ... # type: bool + lineterminator = ... # type: str + quoting = ... # type: int + +class excel_tab(excel): + delimiter = ... # type: str + +if sys.version_info >= (3,): + class unix_dialect(Dialect): + delimiter = ... # type: str + quotechar = ... # type: str + doublequote = ... # type: bool + skipinitialspace = ... # type: bool + lineterminator = ... # type: str + quoting = ... # type: int + +if sys.version_info >= (3, 6): + _DRMapping = OrderedDict[str, str] +else: + _DRMapping = Dict[str, str] + + +class DictReader(Iterator[_DRMapping]): + restkey = ... # type: Optional[str] + restval = ... # type: Optional[str] + reader = ... # type: _reader + dialect = ... # type: _Dialect + line_num = ... # type: int + fieldnames = ... # type: Sequence[str] + def __init__(self, f: Iterable[str], fieldnames: Sequence[str] = ..., + restkey: Optional[str] = ..., restval: Optional[str] = ..., dialect: _Dialect = ..., + *args: Any, **kwds: Any) -> None: ... + def __iter__(self) -> 'DictReader': ... + if sys.version_info >= (3,): + def __next__(self) -> _DRMapping: ... + else: + def next(self) -> _DRMapping: ... + + +class DictWriter(object): + fieldnames = ... # type: Sequence[str] + restval = ... # type: Optional[Any] + extrasaction = ... # type: str + writer = ... # type: _writer + def __init__(self, f: Any, fieldnames: Sequence[str], + restval: Optional[Any] = ..., extrasaction: str = ..., dialect: _Dialect = ..., + *args: Any, **kwds: Any) -> None: ... + def writeheader(self) -> None: ... + def writerow(self, rowdict: _DictRow) -> None: ... + def writerows(self, rowdicts: Iterable[_DictRow]) -> None: ... + +class Sniffer(object): + preferred = ... # type: List[str] + def __init__(self) -> None: ... + def sniff(self, sample: str, delimiters: Optional[str] = ...) -> Dialect: ... + def has_header(self, sample: str) -> bool: ... diff --git a/python/helpers/typeshed/stdlib/2and3/difflib.pyi b/python/helpers/typeshed/stdlib/2and3/difflib.pyi new file mode 100644 index 000000000000..4701e32a2ab2 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/difflib.pyi @@ -0,0 +1,82 @@ +# Based on https://docs.python.org/2.7/library/difflib.html and https://docs.python.org/3.2/library/difflib.html + +# TODO: Support unicode in Python 2? + +import sys +from typing import ( + TypeVar, Callable, Iterable, Iterator, List, NamedTuple, Sequence, Tuple, + Generic, Optional +) + +_T = TypeVar('_T') + +Match = NamedTuple('Match', [ + ('a', int), + ('b', int), + ('size', int), +]) + +class SequenceMatcher(Generic[_T]): + def __init__(self, isjunk: Optional[Callable[[_T], bool]] = ..., + a: Sequence[_T] = ..., b: Sequence[_T] = ..., + autojunk: bool = ...) -> None: ... + def set_seqs(self, a: Sequence[_T], b: Sequence[_T]) -> None: ... + def set_seq1(self, a: Sequence[_T]) -> None: ... + def set_seq2(self, b: Sequence[_T]) -> None: ... + def find_longest_match(self, alo: int, ahi: int, blo: int, + bhi: int) -> Tuple[int, int, int]: ... + def get_matching_blocks(self) -> List[Match]: ... + def get_opcodes(self) -> List[Tuple[str, int, int, int, int]]: ... + def get_grouped_opcodes(self, n: int = ... + ) -> Iterable[Tuple[str, int, int, int, int]]: ... + def ratio(self) -> float: ... + def quick_ratio(self) -> float: ... + def real_quick_ratio(self) -> float: ... + +def get_close_matches(word: Sequence[_T], possibilities: List[Sequence[_T]], + n: int = ..., cutoff: float = ...) -> List[Sequence[_T]]: ... + +class Differ: + def __init__(self, linejunk: Callable[[str], bool] = ..., + charjunk: Callable[[str], bool] = ...) -> None: ... + def compare(self, a: Sequence[str], b: Sequence[str]) -> Iterator[str]: ... + +def IS_LINE_JUNK(str) -> bool: ... +def IS_CHARACTER_JUNK(str) -> bool: ... +def unified_diff(a: Sequence[str], b: Sequence[str], fromfile: str = ..., + tofile: str = ..., fromfiledate: str = ..., tofiledate: str = ..., + n: int = ..., lineterm: str = ...) -> Iterator[str]: ... +def context_diff(a: Sequence[str], b: Sequence[str], fromfile: str=..., + tofile: str = ..., fromfiledate: str = ..., tofiledate: str = ..., + n: int = ..., lineterm: str = ...) -> Iterator[str]: ... +def ndiff(a: Sequence[str], b: Sequence[str], + linejunk: Callable[[str], bool] = ..., + charjunk: Callable[[str], bool] = ... + ) -> Iterator[str]: ... + +class HtmlDiff(object): + def __init__(self, tabsize: int = ..., wrapcolumn: int = ..., + linejunk: Callable[[str], bool] = ..., + charjunk: Callable[[str], bool] = ... + ) -> None: ... + def make_file(self, fromlines: Sequence[str], tolines: Sequence[str], + fromdesc: str = ..., todesc: str = ..., context: bool = ..., + numlines: int = ...) -> str: ... + def make_table(self, fromlines: Sequence[str], tolines: Sequence[str], + fromdesc: str = ..., todesc: str = ..., context: bool = ..., + numlines: int = ...) -> str: ... + +def restore(delta: Iterable[str], which: int) -> Iterator[int]: ... + +if sys.version_info >= (3, 5): + def diff_bytes( + dfunc: Callable[[Sequence[str], Sequence[str], str, str, str, str, int, str], Iterator[str]], + a: Sequence[bytes], + b: Sequence[bytes], + fromfile: bytes = ..., + tofile: bytes = ..., + fromfiledate: bytes = ..., + tofiledate: bytes = ..., + n: int = ..., + lineterm: bytes = ... + ) -> Iterator[bytes]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/distutils/command/bdist_msi.pyi b/python/helpers/typeshed/stdlib/2and3/distutils/command/bdist_msi.pyi index 3813699f5d25..a761792018a9 100644 --- a/python/helpers/typeshed/stdlib/2and3/distutils/command/bdist_msi.pyi +++ b/python/helpers/typeshed/stdlib/2and3/distutils/command/bdist_msi.pyi @@ -1,5 +1,6 @@ -# Stubs for distutils.command.bdist_msi - from distutils.cmd import Command -class bdist_msi(Command): ... +class bdist_msi(Command): + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/distutils/command/build_py.pyi b/python/helpers/typeshed/stdlib/2and3/distutils/command/build_py.pyi index 23b3f9e69b07..34753e4a75b6 100644 --- a/python/helpers/typeshed/stdlib/2and3/distutils/command/build_py.pyi +++ b/python/helpers/typeshed/stdlib/2and3/distutils/command/build_py.pyi @@ -1,8 +1,10 @@ -# Stubs for distutils.command.bdist_msi - from distutils.cmd import Command import sys if sys.version_info >= (3,): - class build_py(Command): ... - class build_py_2to3(Command): ... + class build_py(Command): + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... + + class build_py_2to3(build_py): ... diff --git a/python/helpers/typeshed/stdlib/2and3/distutils/core.pyi b/python/helpers/typeshed/stdlib/2and3/distutils/core.pyi index 38d6a1a0f425..9d41daf5f9fd 100644 --- a/python/helpers/typeshed/stdlib/2and3/distutils/core.pyi +++ b/python/helpers/typeshed/stdlib/2and3/distutils/core.pyi @@ -29,7 +29,22 @@ def setup(name: str = ..., platforms: Union[List[str], str] = ..., cmdclass: Mapping[str, Command] = ..., data_files: List[Tuple[str, List[str]]] = ..., - package_dir: Mapping[str, str] = ...) -> None: ... + package_dir: Mapping[str, str] = ..., + obsoletes: List[str] = ..., + provides: List[str] = ..., + requires: List[str] = ..., + command_packages: List[str] = ..., + command_options: Mapping[str, Mapping[str, Tuple[Any, Any]]] = ..., + package_data: Mapping[str, List[str]] = ..., + include_package_data: bool = ..., + libraries: List[str] = ..., + headers: List[str] = ..., + ext_package: str = ..., + include_dirs: List[str] = ..., + password: str = ..., + fullname: str = ..., + **attrs: Any) -> None: ... + def run_setup(script_name: str, script_args: Optional[List[str]] = ..., stop_after: str = ...) -> Distribution: ... diff --git a/python/helpers/typeshed/stdlib/2and3/distutils/version.pyi b/python/helpers/typeshed/stdlib/2and3/distutils/version.pyi index 6b6efbf03afb..d44a6f2ee3a9 100644 --- a/python/helpers/typeshed/stdlib/2and3/distutils/version.pyi +++ b/python/helpers/typeshed/stdlib/2and3/distutils/version.pyi @@ -1,7 +1,3 @@ -# Stubs for distutils.version (Python 2 and 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - import sys from typing import Any diff --git a/python/helpers/typeshed/stdlib/2and3/doctest.pyi b/python/helpers/typeshed/stdlib/2and3/doctest.pyi new file mode 100644 index 000000000000..8151fb572799 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/doctest.pyi @@ -0,0 +1,161 @@ +from typing import Any, Callable, Dict, List, NamedTuple, Optional, Tuple, Type, Union + +import sys +import types +import unittest + +TestResults = NamedTuple('TestResults', [ + ('failed', int), + ('attempted', int), +]) + +OPTIONFLAGS_BY_NAME: Dict[str, int] +def register_optionflag(name: str) -> int: ... +DONT_ACCEPT_TRUE_FOR_1: int +DONT_ACCEPT_BLANKLINE: int +NORMALIZE_WHITESPACE: int +ELLIPSIS: int +SKIP: int +IGNORE_EXCEPTION_DETAIL: int + +COMPARISON_FLAGS: int + +REPORT_UDIFF: int +REPORT_CDIFF: int +REPORT_NDIFF: int +REPORT_ONLY_FIRST_FAILURE: int +if sys.version_info >= (3, 4): + FAIL_FAST: int + +REPORTING_FLAGS: int + +BLANKLINE_MARKER: str +ELLIPSIS_MARKER: str + +class Example: + source: str + want: str + exc_msg: Optional[str] + lineno: int + indent: int + options: Dict[int, bool] + def __init__(self, source: str, want: str, exc_msg: Optional[str] = ..., lineno: int = ..., indent: int = ..., + options: Optional[Dict[int, bool]] = ...) -> None: ... + def __hash__(self) -> int: ... + +class DocTest: + examples: List[Example] + globs: Dict[str, Any] + name: str + filename: Optional[str] + lineno: Optional[int] + docstring: Optional[str] + def __init__(self, examples: List[Example], globs: Dict[str, Any], name: str, filename: Optional[str], lineno: Optional[int], docstring: Optional[str]) -> None: ... + def __hash__(self) -> int: ... + def __lt__(self, other: DocTest) -> bool: ... + +class DocTestParser: + def parse(self, string: str, name: str = ...) -> List[Union[str, Example]]: ... + def get_doctest(self, string: str, globs: Dict[str, Any], name: str, filename: Optional[str], lineno: Optional[str]) -> DocTest: ... + def get_examples(self, strin: str, name: str = ...) -> List[Example]: ... + +class DocTestFinder: + def __init__(self, verbose: bool = ..., parser: DocTestParser = ..., + recurse: bool = ..., exclude_empty: bool = ...) -> None: ... + def find(self, obj: object, name: Optional[str] = ..., module: Union[None, bool, types.ModuleType] = ..., + globs: Optional[Dict[str, Any]] = ..., extraglobs: Optional[Dict[str, Any]] = ...) -> List[DocTest]: ... + +_Out = Callable[[str], Any] +_ExcInfo = Tuple[Type[BaseException], BaseException, types.TracebackType] + +class DocTestRunner: + DIVIDER: str + optionflags: int + original_optionflags: int + tries: int + failures: int + test: DocTest + + def __init__(self, checker: Optional[OutputChecker] = ..., verbose: Optional[bool] = ..., optionflags: int = ...) -> None: ... + def report_start(self, out: _Out, test: DocTest, example: Example) -> None: ... + def report_success(self, out: _Out, test: DocTest, example: Example, got: str) -> None: ... + def report_failure(self, out: _Out, test: DocTest, example: Example, got: str) -> None: ... + def report_unexpected_exception(self, out: _Out, test: DocTest, example: Example, exc_info: _ExcInfo) -> None: ... + def run(self, test: DocTest, compileflags: Optional[int] = ..., out: Optional[_Out] = ..., clear_globs: bool = ...) -> TestResults: ... + def summarize(self, verbose: Optional[bool] = ...) -> TestResults: ... + def merge(self, other: DocTestRunner) -> None: ... + +class OutputChecker: + def check_output(self, want: str, got: str, optionflags: int) -> bool: ... + def output_difference(self, example: Example, got: str, optionflags: int) -> str: ... + +class DocTestFailure(Exception): + test: DocTest + example: Example + got: str + + def __init__(self, test: DocTest, example: Example, got: str) -> None: ... + +class UnexpectedException(Exception): + test: DocTest + example: Example + exc_info: _ExcInfo + + def __init__(self, test: DocTest, example: Example, exc_info: _ExcInfo) -> None: ... + +class DebugRunner(DocTestRunner): ... + +master: Optional[DocTestRunner] + +def testmod(m: Optional[types.ModuleType] = ..., name: Optional[str] = ..., globs: Dict[str, Any] = ..., verbose: Optional[bool] = ..., + report: bool = ..., optionflags: int = ..., extraglobs: Dict[str, Any] = ..., + raise_on_error: bool = ..., exclude_empty: bool = ...) -> TestResults: ... +def testfile(filename: str, module_relative: bool = ..., name: Optional[str] = ..., package: Union[None, str, types.ModuleType] = ..., + globs: Optional[Dict[str, Any]] = ..., verbose: Optional[bool] = ..., report: bool = ..., optionflags: int = ..., + extraglobs: Optional[Dict[str, Any]] = ..., raise_on_error: bool = ..., parser: DocTestParser = ..., + encoding: Optional[str] = ...) -> TestResults: ... +def run_docstring_examples(f: object, globs: Dict[str, Any], verbose: bool = ..., name: str = ..., + compileflags: Optional[int] = ..., optionflags: int = ...) -> None: ... +def set_unittest_reportflags(flags: int) -> int: ... + +class DocTestCase(unittest.TestCase): + def __init__(self, test: DocTest, optionflags: int = ..., setUp: Optional[Callable[[DocTest], Any]] = ..., + tearDown: Optional[Callable[[DocTest], Any]] = ..., + checker: Optional[OutputChecker] = ...) -> None: ... + def setUp(self) -> None: ... + def tearDown(self) -> None: ... + def runTest(self) -> None: ... + def format_failure(self, err: str) -> str: ... + def debug(self) -> None: ... + def id(self) -> str: ... + def __hash__(self) -> int: ... + def shortDescription(self) -> str: ... + +class SkipDocTestCase(DocTestCase): + def __init__(self, module: types.ModuleType) -> None: ... + def setUp(self) -> None: ... + def test_skip(self) -> None: ... + def shortDescription(self) -> str: ... + +if sys.version_info >= (3, 4): + class _DocTestSuite(unittest.TestSuite): ... +else: + _DocTestSuite = unittest.TestSuite + +def DocTestSuite(module: Union[None, str, types.ModuleType] = ..., globs: Optional[Dict[str, Any]] = ..., + extraglobs: Optional[Dict[str, Any]] = ..., test_finder: Optional[DocTestFinder] = ..., + **options: Any) -> _DocTestSuite: ... + +class DocFileCase(DocTestCase): + def id(self) -> str: ... + def format_failure(self, err: str) -> str: ... + +def DocFileTest(path: str, module_relative: bool = ..., package: Union[None, str, types.ModuleType] = ..., + globs: Optional[Dict[str, Any]] = ..., parser: DocTestParser = ..., + encoding: Optional[str] = ..., **options: Any) -> DocFileCase: ... +def DocFileSuite(*paths: str, **kw: Any) -> _DocTestSuite: ... +def script_from_examples(s: str) -> str: ... +def testsource(module: Union[None, str, types.ModuleType], name: str) -> str: ... +def debug_src(src: str, pm: bool = ..., globs: Optional[Dict[str, Any]] = ...) -> None: ... +def debug_script(src: str, pm: bool = ..., globs: Optional[Dict[str, Any]] = ...) -> None: ... +def debug(module: Union[None, str, types.ModuleType], name: str, pm: bool = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/fileinput.pyi b/python/helpers/typeshed/stdlib/2and3/fileinput.pyi new file mode 100644 index 000000000000..8a56ecaf6d20 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/fileinput.pyi @@ -0,0 +1,62 @@ +from typing import Iterable, Callable, IO, AnyStr, Generic, Any, Text, Union, Iterator, Optional + +import os +import sys + +if sys.version_info >= (3, 6): + _Path = Union[Text, bytes, os.PathLike[Any]] +else: + _Path = Union[Text, bytes] + + +def input( + files: Union[_Path, Iterable[_Path], None] = ..., + inplace: bool = ..., + backup: str = ..., + bufsize: int = ..., + mode: str = ..., + openhook: Callable[[_Path, str], IO[AnyStr]] = ...) -> Iterable[AnyStr]: ... + + +def close() -> None: ... +def nextfile() -> None: ... +def filename() -> str: ... +def lineno() -> int: ... +def filelineno() -> int: ... +def fileno() -> int: ... +def isfirstline() -> bool: ... +def isstdin() -> bool: ... + +class FileInput(Iterable[AnyStr], Generic[AnyStr]): + def __init__( + self, + files: Union[None, _Path, Iterable[_Path]] = ..., + inplace: bool = ..., + backup: str = ..., + bufsize: int = ..., + mode: str = ..., + openhook: Callable[[_Path, str], IO[AnyStr]] = ... + ) -> None: ... + + def __del__(self) -> None: ... + def close(self) -> None: ... + if sys.version_info >= (3, 2): + def __enter__(self) -> FileInput[AnyStr]: ... + def __exit__(self, type: Any, value: Any, traceback: Any) -> None: ... + def __iter__(self) -> Iterator[AnyStr]: ... + def __next__(self) -> AnyStr: ... + def __getitem__(self, i: int) -> AnyStr: ... + def nextfile(self) -> None: ... + def readline(self) -> AnyStr: ... + def filename(self) -> str: ... + def lineno(self) -> int: ... + def filelineno(self) -> int: ... + def fileno(self) -> int: ... + def isfirstline(self) -> bool: ... + def isstdin(self) -> bool: ... + +def hook_compressed(filename: _Path, mode: str) -> IO[Any]: ... +if sys.version_info >= (3, 6): + def hook_encoded(encoding: str, errors: Optional[str] = ...) -> Callable[[_Path, str], IO[Any]]: ... +else: + def hook_encoded(encoding: str) -> Callable[[_Path, str], IO[Any]]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/formatter.pyi b/python/helpers/typeshed/stdlib/2and3/formatter.pyi new file mode 100644 index 000000000000..9ad2978b5c8c --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/formatter.pyi @@ -0,0 +1,105 @@ +# Source: https://hg.python.org/cpython/file/2.7/Lib/formatter.py +# and https://github.com/python/cpython/blob/master/Lib/formatter.py +from typing import Any, IO, List, Optional, Tuple + +AS_IS = None +_FontType = Tuple[str, bool, bool, bool] +_StylesType = Tuple[Any, ...] + +class NullFormatter: + writer = ... # type: Optional[NullWriter] + def __init__(self, writer: Optional[NullWriter] = ...) -> None: ... + def end_paragraph(self, blankline: int) -> None: ... + def add_line_break(self) -> None: ... + def add_hor_rule(self, *args, **kw) -> None: ... + def add_label_data(self, format, counter: int, blankline: Optional[int] = ...) -> None: ... + def add_flowing_data(self, data: str) -> None: ... + def add_literal_data(self, data: str) -> None: ... + def flush_softspace(self) -> None: ... + def push_alignment(self, align: Optional[str]) -> None: ... + def pop_alignment(self) -> None: ... + def push_font(self, x: _FontType) -> None: ... + def pop_font(self) -> None: ... + def push_margin(self, margin: int) -> None: ... + def pop_margin(self) -> None: ... + def set_spacing(self, spacing: Optional[str]) -> None: ... + def push_style(self, *styles: _StylesType) -> None: ... + def pop_style(self, n: int = ...) -> None: ... + def assert_line_data(self, flag: int = ...) -> None: ... + +class AbstractFormatter: + writer = ... # type: NullWriter + align = ... # type: Optional[str] + align_stack = ... # type: List[Optional[str]] + font_stack = ... # type: List[_FontType] + margin_stack = ... # type: List[int] + spacing = ... # type: Optional[str] + style_stack = ... # type: Any + nospace = ... # type: int + softspace = ... # type: int + para_end = ... # type: int + parskip = ... # type: int + hard_break = ... # type: int + have_label = ... # type: int + def __init__(self, writer: NullWriter) -> None: ... + def end_paragraph(self, blankline: int) -> None: ... + def add_line_break(self) -> None: ... + def add_hor_rule(self, *args, **kw) -> None: ... + def add_label_data(self, format, counter: int, blankline: Optional[int] = ...) -> None: ... + def format_counter(self, format, counter: int) -> str: ... + def format_letter(self, case: str, counter: int) -> str: ... + def format_roman(self, case: str, counter: int) -> str: ... + def add_flowing_data(self, data: str) -> None: ... + def add_literal_data(self, data: str) -> None: ... + def flush_softspace(self) -> None: ... + def push_alignment(self, align: Optional[str]) -> None: ... + def pop_alignment(self) -> None: ... + def push_font(self, font: _FontType) -> None: ... + def pop_font(self) -> None: ... + def push_margin(self, margin: int) -> None: ... + def pop_margin(self) -> None: ... + def set_spacing(self, spacing: Optional[str]) -> None: ... + def push_style(self, *styles: _StylesType) -> None: ... + def pop_style(self, n: int = ...) -> None: ... + def assert_line_data(self, flag: int = ...) -> None: ... + +class NullWriter: + def __init__(self) -> None: ... + def flush(self) -> None: ... + def new_alignment(self, align: Optional[str]) -> None: ... + def new_font(self, font: _FontType) -> None: ... + def new_margin(self, margin: int, level: int) -> None: ... + def new_spacing(self, spacing: Optional[str]) -> None: ... + def new_styles(self, styles) -> None: ... + def send_paragraph(self, blankline: int) -> None: ... + def send_line_break(self) -> None: ... + def send_hor_rule(self, *args, **kw) -> None: ... + def send_label_data(self, data: str) -> None: ... + def send_flowing_data(self, data: str) -> None: ... + def send_literal_data(self, data: str) -> None: ... + +class AbstractWriter(NullWriter): + def new_alignment(self, align: Optional[str]) -> None: ... + def new_font(self, font: _FontType) -> None: ... + def new_margin(self, margin: int, level: int) -> None: ... + def new_spacing(self, spacing: Optional[str]) -> None: ... + def new_styles(self, styles) -> None: ... + def send_paragraph(self, blankline: int) -> None: ... + def send_line_break(self) -> None: ... + def send_hor_rule(self, *args, **kw) -> None: ... + def send_label_data(self, data: str) -> None: ... + def send_flowing_data(self, data: str) -> None: ... + def send_literal_data(self, data: str) -> None: ... + +class DumbWriter(NullWriter): + file = ... # type: IO + maxcol = ... # type: int + def __init__(self, file: Optional[IO] = ..., maxcol: int = ...) -> None: ... + def reset(self) -> None: ... + def send_paragraph(self, blankline: int) -> None: ... + def send_line_break(self) -> None: ... + def send_hor_rule(self, *args, **kw) -> None: ... + def send_literal_data(self, data: str) -> None: ... + def send_flowing_data(self, data: str) -> None: ... + +def test(file: Optional[str] = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/ftplib.pyi b/python/helpers/typeshed/stdlib/2and3/ftplib.pyi index 308544dcca82..128b91da99f1 100644 --- a/python/helpers/typeshed/stdlib/2and3/ftplib.pyi +++ b/python/helpers/typeshed/stdlib/2and3/ftplib.pyi @@ -1,6 +1,6 @@ # Stubs for ftplib (Python 2.7/3) import sys -from typing import Optional, BinaryIO, Tuple, TextIO, Iterable, Callable, List, Union, Iterator, Dict, Text, TypeVar, Generic +from typing import Optional, BinaryIO, Tuple, TextIO, Iterable, Callable, List, Union, Iterator, Dict, Text, TypeVar, Generic, Any from types import TracebackType from socket import socket from ssl import SSLContext @@ -82,11 +82,11 @@ class FTP: # In practice, `rest` rest can actually be anything whose str() is an integer sequence, so to make it simple we allow integers. def ntransfercmd(self, cmd: Text, rest: Optional[_IntOrStr] = ...) -> Tuple[socket, int]: ... def transfercmd(self, cmd: Text, rest: Optional[_IntOrStr] = ...) -> socket: ... - def retrbinary(self, cmd: Text, callback: Callable[[bytes], None], blocksize: int = ..., rest: Optional[_IntOrStr] = ...) -> str: ... - def storbinary(self, cmd: Text, fp: BinaryIO, blocksize: int = ..., callback: Optional[Callable[[bytes], None]] = ..., rest: Optional[_IntOrStr] = ...) -> str: ... + def retrbinary(self, cmd: Text, callback: Callable[[bytes], Any], blocksize: int = ..., rest: Optional[_IntOrStr] = ...) -> str: ... + def storbinary(self, cmd: Text, fp: BinaryIO, blocksize: int = ..., callback: Optional[Callable[[bytes], Any]] = ..., rest: Optional[_IntOrStr] = ...) -> str: ... - def retrlines(self, cmd: Text, callback: Optional[Callable[[str], None]] = ...) -> str: ... - def storlines(self, cmd: Text, fp: BinaryIO, callback: Optional[Callable[[bytes], None]] = ...) -> str: ... + def retrlines(self, cmd: Text, callback: Optional[Callable[[str], Any]] = ...) -> str: ... + def storlines(self, cmd: Text, fp: BinaryIO, callback: Optional[Callable[[bytes], Any]] = ...) -> str: ... def acct(self, password: Text) -> str: ... def nlst(self, *args: Text) -> List[str]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/grp.pyi b/python/helpers/typeshed/stdlib/2and3/grp.pyi new file mode 100644 index 000000000000..605472721b89 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/grp.pyi @@ -0,0 +1,10 @@ +from typing import List, NamedTuple, Optional + +struct_group = NamedTuple("struct_group", [("gr_name", str), + ("gr_passwd", Optional[str]), + ("gr_gid", int), + ("gr_mem", List[str])]) + +def getgrall() -> List[struct_group]: ... +def getgrgid(gid: int) -> struct_group: ... +def getgrnam(name: str) -> struct_group: ... diff --git a/python/helpers/typeshed/stdlib/2and3/hmac.pyi b/python/helpers/typeshed/stdlib/2and3/hmac.pyi index 59aaf3673385..9be9cf1c8547 100644 --- a/python/helpers/typeshed/stdlib/2and3/hmac.pyi +++ b/python/helpers/typeshed/stdlib/2and3/hmac.pyi @@ -9,6 +9,8 @@ _B = Union[bytes, bytearray] # TODO more precise type for object of hashlib _Hash = Any +digest_size: None + if sys.version_info >= (3, 4): def new(key: _B, msg: Optional[_B] = ..., digestmod: Optional[Union[str, Callable[[], _Hash], ModuleType]] = ...) -> HMAC: ... diff --git a/python/helpers/typeshed/stdlib/2and3/lib2to3/__init__.pyi b/python/helpers/typeshed/stdlib/2and3/lib2to3/__init__.pyi new file mode 100644 index 000000000000..145e31b1dec8 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/lib2to3/__init__.pyi @@ -0,0 +1 @@ +# Stubs for lib2to3 (Python 3.6) diff --git a/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/__init__.pyi b/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/__init__.pyi new file mode 100644 index 000000000000..1adc82a6ed06 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/__init__.pyi @@ -0,0 +1,10 @@ +# Stubs for lib2to3.pgen2 (Python 3.6) + +import os +import sys +from typing import Text, Union + +if sys.version_info >= (3, 6): + _Path = Union[Text, os.PathLike] +else: + _Path = Text diff --git a/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/driver.pyi b/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/driver.pyi new file mode 100644 index 000000000000..56785f087313 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/driver.pyi @@ -0,0 +1,24 @@ +# Stubs for lib2to3.pgen2.driver (Python 3.6) + +import os +import sys +from typing import Any, Callable, IO, Iterable, List, Optional, Text, Tuple, Union + +from logging import Logger +from lib2to3.pytree import _Convert, _NL +from lib2to3.pgen2 import _Path +from lib2to3.pgen2.grammar import Grammar + + +class Driver: + grammar: Grammar + logger: Logger + convert: _Convert + def __init__(self, grammar: Grammar, convert: Optional[_Convert] = ..., logger: Optional[Logger] = ...) -> None: ... + def parse_tokens(self, tokens: Iterable[Any], debug: bool = ...) -> _NL: ... + def parse_stream_raw(self, stream: IO[Text], debug: bool = ...) -> _NL: ... + def parse_stream(self, stream: IO[Text], debug: bool = ...) -> _NL: ... + def parse_file(self, filename: _Path, encoding: Optional[Text] = ..., debug: bool = ...) -> _NL: ... + def parse_string(self, text: Text, debug: bool = ...) -> _NL: ... + +def load_grammar(gt: Text = ..., gp: Optional[Text] = ..., save: bool = ..., force: bool = ..., logger: Optional[Logger] = ...) -> Grammar: ... diff --git a/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/grammar.pyi b/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/grammar.pyi new file mode 100644 index 000000000000..122d771dba00 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/grammar.pyi @@ -0,0 +1,29 @@ +# Stubs for lib2to3.pgen2.grammar (Python 3.6) + +from lib2to3.pgen2 import _Path + +from typing import Any, Dict, List, Optional, Text, Tuple, TypeVar + +_P = TypeVar('_P') +_Label = Tuple[int, Optional[Text]] +_DFA = List[List[Tuple[int, int]]] +_DFAS = Tuple[_DFA, Dict[int, int]] + +class Grammar: + symbol2number: Dict[Text, int] + number2symbol: Dict[int, Text] + states: List[_DFA] + dfas: Dict[int, _DFAS] + labels: List[_Label] + keywords: Dict[Text, int] + tokens: Dict[int, int] + symbol2label: Dict[Text, int] + start: int + def __init__(self) -> None: ... + def dump(self, filename: _Path) -> None: ... + def load(self, filename: _Path) -> None: ... + def copy(self: _P) -> _P: ... + def report(self) -> None: ... + +opmap_raw: Text +opmap: Dict[Text, Text] diff --git a/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/literals.pyi b/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/literals.pyi new file mode 100644 index 000000000000..8719500dadd0 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/literals.pyi @@ -0,0 +1,9 @@ +# Stubs for lib2to3.pgen2.literals (Python 3.6) + +from typing import Dict, Match, Text + +simple_escapes: Dict[Text, Text] + +def escape(m: Match) -> Text: ... +def evalString(s: Text) -> Text: ... +def test() -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/parse.pyi b/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/parse.pyi new file mode 100644 index 000000000000..101d4760a60c --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/parse.pyi @@ -0,0 +1,29 @@ +# Stubs for lib2to3.pgen2.parse (Python 3.6) + +from typing import Any, Dict, List, Optional, Sequence, Set, Text, Tuple + +from lib2to3.pgen2.grammar import Grammar, _DFAS +from lib2to3.pytree import _NL, _Convert, _RawNode + +_Context = Sequence[Any] + +class ParseError(Exception): + msg: Text + type: int + value: Optional[Text] + context: _Context + def __init__(self, msg: Text, type: int, value: Optional[Text], context: _Context) -> None: ... + +class Parser: + grammar: Grammar + convert: _Convert + stack: List[Tuple[_DFAS, int, _RawNode]] + rootnode: Optional[_NL] + used_names: Set[Text] + def __init__(self, grammar: Grammar, convert: Optional[_Convert] = ...) -> None: ... + def setup(self, start: Optional[int] = ...) -> None: ... + def addtoken(self, type: int, value: Optional[Text], context: _Context) -> bool: ... + def classify(self, type: int, value: Optional[Text], context: _Context) -> int: ... + def shift(self, type: int, value: Optional[Text], newstate: int, context: _Context) -> None: ... + def push(self, type: int, newdfa: _DFAS, newstate: int, context: _Context) -> None: ... + def pop(self) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/pgen.pyi b/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/pgen.pyi new file mode 100644 index 000000000000..4180a230aa1b --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/pgen.pyi @@ -0,0 +1,49 @@ +# Stubs for lib2to3.pgen2.pgen (Python 3.6) + +from typing import Any, Dict, IO, Iterable, Iterator, List, Optional, Text, Tuple +from mypy_extensions import NoReturn + +from lib2to3.pgen2 import _Path, grammar +from lib2to3.pgen2.tokenize import _TokenInfo + +class PgenGrammar(grammar.Grammar): ... + +class ParserGenerator: + filename: _Path + stream: IO[Text] + generator: Iterator[_TokenInfo] + first: Dict[Text, Dict[Text, int]] + def __init__(self, filename: _Path, stream: Optional[IO[Text]] = ...) -> None: ... + def make_grammar(self) -> PgenGrammar: ... + def make_first(self, c: PgenGrammar, name: Text) -> Dict[int, int]: ... + def make_label(self, c: PgenGrammar, label: Text) -> int: ... + def addfirstsets(self) -> None: ... + def calcfirst(self, name: Text) -> None: ... + def parse(self) -> Tuple[Dict[Text, List[DFAState]], Text]: ... + def make_dfa(self, start: NFAState, finish: NFAState) -> List[DFAState]: ... + def dump_nfa(self, name: Text, start: NFAState, finish: NFAState) -> List[DFAState]: ... + def dump_dfa(self, name: Text, dfa: Iterable[DFAState]) -> None: ... + def simplify_dfa(self, dfa: List[DFAState]) -> None: ... + def parse_rhs(self) -> Tuple[NFAState, NFAState]: ... + def parse_alt(self) -> Tuple[NFAState, NFAState]: ... + def parse_item(self) -> Tuple[NFAState, NFAState]: ... + def parse_atom(self) -> Tuple[NFAState, NFAState]: ... + def expect(self, type: int, value: Optional[Any] = ...) -> Text: ... + def gettoken(self) -> None: ... + def raise_error(self, msg: str, *args: Any) -> NoReturn: ... + +class NFAState: + arcs: List[Tuple[Optional[Text], NFAState]] + def __init__(self) -> None: ... + def addarc(self, next: NFAState, label: Optional[Text] = ...) -> None: ... + +class DFAState: + nfaset: Dict[NFAState, Any] + isfinal: bool + arcs: Dict[Text, DFAState] + def __init__(self, nfaset: Dict[NFAState, Any], final: NFAState) -> None: ... + def addarc(self, next: DFAState, label: Text) -> None: ... + def unifystate(self, old: DFAState, new: DFAState) -> None: ... + def __eq__(self, other: Any) -> bool: ... + +def generate_grammar(filename: _Path = ...) -> PgenGrammar: ... diff --git a/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/token.pyi b/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/token.pyi new file mode 100644 index 000000000000..c256af8f27fe --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/token.pyi @@ -0,0 +1,73 @@ +# Stubs for lib2to3.pgen2.token (Python 3.6) + +import sys +from typing import Dict, Text + +ENDMARKER: int +NAME: int +NUMBER: int +STRING: int +NEWLINE: int +INDENT: int +DEDENT: int +LPAR: int +RPAR: int +LSQB: int +RSQB: int +COLON: int +COMMA: int +SEMI: int +PLUS: int +MINUS: int +STAR: int +SLASH: int +VBAR: int +AMPER: int +LESS: int +GREATER: int +EQUAL: int +DOT: int +PERCENT: int +BACKQUOTE: int +LBRACE: int +RBRACE: int +EQEQUAL: int +NOTEQUAL: int +LESSEQUAL: int +GREATEREQUAL: int +TILDE: int +CIRCUMFLEX: int +LEFTSHIFT: int +RIGHTSHIFT: int +DOUBLESTAR: int +PLUSEQUAL: int +MINEQUAL: int +STAREQUAL: int +SLASHEQUAL: int +PERCENTEQUAL: int +AMPEREQUAL: int +VBAREQUAL: int +CIRCUMFLEXEQUAL: int +LEFTSHIFTEQUAL: int +RIGHTSHIFTEQUAL: int +DOUBLESTAREQUAL: int +DOUBLESLASH: int +DOUBLESLASHEQUAL: int +OP: int +COMMENT: int +NL: int +if sys.version_info >= (3,): + RARROW: int +if sys.version_info >= (3, 5): + AT: int + ATEQUAL: int + AWAIT: int + ASYNC: int +ERRORTOKEN: int +N_TOKENS: int +NT_OFFSET: int +tok_name: Dict[int, Text] + +def ISTERMINAL(x: int) -> bool: ... +def ISNONTERMINAL(x: int) -> bool: ... +def ISEOF(x: int) -> bool: ... diff --git a/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/tokenize.pyi b/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/tokenize.pyi new file mode 100644 index 000000000000..c10305ffdda0 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/lib2to3/pgen2/tokenize.pyi @@ -0,0 +1,30 @@ +# Stubs for lib2to3.pgen2.tokenize (Python 3.6) +# NOTE: Only elements from __all__ are present. + +from typing import Callable, Iterable, Iterator, List, Text, Tuple +from lib2to3.pgen2.token import * # noqa + + +_Coord = Tuple[int, int] +_TokenEater = Callable[[int, Text, _Coord, _Coord, Text], None] +_TokenInfo = Tuple[int, Text, _Coord, _Coord, Text] + + +class TokenError(Exception): ... +class StopTokenizing(Exception): ... + +def tokenize(readline: Callable[[], Text], tokeneater: _TokenEater = ...) -> None: ... + +class Untokenizer: + tokens: List[Text] + prev_row: int + prev_col: int + def __init__(self) -> None: ... + def add_whitespace(self, start: _Coord) -> None: ... + def untokenize(self, iterable: Iterable[_TokenInfo]) -> Text: ... + def compat(self, token: Tuple[int, Text], iterable: Iterable[_TokenInfo]) -> None: ... + +def untokenize(iterable: Iterable[_TokenInfo]) -> Text: ... +def generate_tokens( + readline: Callable[[], Text] +) -> Iterator[_TokenInfo]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/lib2to3/pygram.pyi b/python/helpers/typeshed/stdlib/2and3/lib2to3/pygram.pyi new file mode 100644 index 000000000000..aeb7b93bf870 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/lib2to3/pygram.pyi @@ -0,0 +1,116 @@ +# Stubs for lib2to3.pygram (Python 3.6) + +from typing import Any +from lib2to3.pgen2.grammar import Grammar + +class Symbols: + def __init__(self, grammar: Grammar) -> None: ... + +class python_symbols(Symbols): + and_expr: int + and_test: int + annassign: int + arglist: int + argument: int + arith_expr: int + assert_stmt: int + async_funcdef: int + async_stmt: int + atom: int + augassign: int + break_stmt: int + classdef: int + comp_for: int + comp_if: int + comp_iter: int + comp_op: int + comparison: int + compound_stmt: int + continue_stmt: int + decorated: int + decorator: int + decorators: int + del_stmt: int + dictsetmaker: int + dotted_as_name: int + dotted_as_names: int + dotted_name: int + encoding_decl: int + eval_input: int + except_clause: int + exec_stmt: int + expr: int + expr_stmt: int + exprlist: int + factor: int + file_input: int + flow_stmt: int + for_stmt: int + funcdef: int + global_stmt: int + if_stmt: int + import_as_name: int + import_as_names: int + import_from: int + import_name: int + import_stmt: int + lambdef: int + listmaker: int + not_test: int + old_lambdef: int + old_test: int + or_test: int + parameters: int + pass_stmt: int + power: int + print_stmt: int + raise_stmt: int + return_stmt: int + shift_expr: int + simple_stmt: int + single_input: int + sliceop: int + small_stmt: int + star_expr: int + stmt: int + subscript: int + subscriptlist: int + suite: int + term: int + test: int + testlist: int + testlist1: int + testlist_gexp: int + testlist_safe: int + testlist_star_expr: int + tfpdef: int + tfplist: int + tname: int + trailer: int + try_stmt: int + typedargslist: int + varargslist: int + vfpdef: int + vfplist: int + vname: int + while_stmt: int + with_item: int + with_stmt: int + with_var: int + xor_expr: int + yield_arg: int + yield_expr: int + yield_stmt: int + +class pattern_symbols(Symbols): + Alternative: int + Alternatives: int + Details: int + Matcher: int + NegatedUnit: int + Repeater: int + Unit: int + +python_grammar: Grammar +python_grammar_no_print_statement: Grammar +pattern_grammar: Grammar diff --git a/python/helpers/typeshed/stdlib/2and3/lib2to3/pytree.pyi b/python/helpers/typeshed/stdlib/2and3/lib2to3/pytree.pyi new file mode 100644 index 000000000000..06a7c1229c40 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/lib2to3/pytree.pyi @@ -0,0 +1,86 @@ +# Stubs for lib2to3.pytree (Python 3.6) + +import sys +from typing import Any, Callable, Dict, Iterator, List, Optional, Text, Tuple, TypeVar, Union + +from lib2to3.pgen2.grammar import Grammar + +_P = TypeVar('_P') +_NL = Union[Node, Leaf] +_Context = Tuple[Text, int, int] +_Results = Dict[Text, _NL] +_RawNode = Tuple[int, Text, _Context, Optional[List[_NL]]] +_Convert = Callable[[Grammar, _RawNode], Any] + +HUGE: int + +def type_repr(type_num: int) -> Text: ... + +class Base: + type: int + parent: Optional[Node] + prefix: Text + children: List[_NL] + was_changed: bool + was_checked: bool + def __eq__(self, other: Any) -> bool: ... + def _eq(self: _P, other: _P) -> bool: ... + def clone(self: _P) -> _P: ... + def post_order(self) -> Iterator[_NL]: ... + def pre_order(self) -> Iterator[_NL]: ... + def replace(self, new: Union[_NL, List[_NL]]) -> None: ... + def get_lineno(self) -> int: ... + def changed(self) -> None: ... + def remove(self) -> Optional[int]: ... + @property + def next_sibling(self) -> Optional[_NL]: ... + @property + def prev_sibling(self) -> Optional[_NL]: ... + def leaves(self) -> Iterator[Leaf]: ... + def depth(self) -> int: ... + def get_suffix(self) -> Text: ... + if sys.version_info < (3,): + def get_prefix(self) -> Text: ... + def set_prefix(self, prefix: Text) -> None: ... + +class Node(Base): + fixers_applied: List[Any] + def __init__(self, type: int, children: List[_NL], context: Optional[Any] = ..., prefix: Optional[Text] = ..., fixers_applied: Optional[List[Any]] = ...) -> None: ... + def set_child(self, i: int, child: _NL) -> None: ... + def insert_child(self, i: int, child: _NL) -> None: ... + def append_child(self, child: _NL) -> None: ... + +class Leaf(Base): + lineno: int + column: int + value: Text + fixers_applied: List[Any] + def __init__(self, type: int, value: Text, context: Optional[_Context] = ..., prefix: Optional[Text] = ..., fixers_applied: List[Any] = ...) -> None: ... + +def convert(gr: Grammar, raw_node: _RawNode) -> _NL: ... + +class BasePattern: + type: int + content: Optional[Text] + name: Optional[Text] + def optimize(self) -> BasePattern: ... # sic, subclasses are free to optimize themselves into different patterns + def match(self, node: _NL, results: Optional[_Results] = ...) -> bool: ... + def match_seq(self, nodes: List[_NL], results: Optional[_Results] = ...) -> bool: ... + def generate_matches(self, nodes: List[_NL]) -> Iterator[Tuple[int, _Results]]: ... + +class LeafPattern(BasePattern): + def __init__(self, type: Optional[int] = ..., content: Optional[Text] = ..., name: Optional[Text] = ...) -> None: ... + +class NodePattern(BasePattern): + wildcards: bool + def __init__(self, type: Optional[int] = ..., content: Optional[Text] = ..., name: Optional[Text] = ...) -> None: ... + +class WildcardPattern(BasePattern): + min: int + max: int + def __init__(self, content: Optional[Text] = ..., min: int = ..., max: int = ..., name: Optional[Text] = ...) -> None: ... + +class NegatedPattern(BasePattern): + def __init__(self, content: Optional[Text] = ...) -> None: ... + +def generate_matches(patterns: List[BasePattern], nodes: List[_NL]) -> Iterator[Tuple[int, _Results]]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/linecache.pyi b/python/helpers/typeshed/stdlib/2and3/linecache.pyi new file mode 100644 index 000000000000..9a152d6a0d83 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/linecache.pyi @@ -0,0 +1,12 @@ +import sys +from typing import Any, Dict, List, Optional, Text + +_ModuleGlobals = Dict[str, Any] + +def getline(filename: Text, lineno: int, module_globals: Optional[_ModuleGlobals] = ...) -> str: ... +def clearcache() -> None: ... +def getlines(filename: Text, module_globals: Optional[_ModuleGlobals] = ...) -> None: ... +def checkcache(filename: Optional[Text] = ...) -> None: ... +def updatecache(filename: Text, module_globals: Optional[_ModuleGlobals] = ...) -> List[str]: ... +if sys.version_info >= (3, 5): + def lazycache(filename: Text, module_globals: _ModuleGlobals) -> bool: ... diff --git a/python/helpers/typeshed/stdlib/2and3/locale.pyi b/python/helpers/typeshed/stdlib/2and3/locale.pyi index bb64666bb458..59ac3c45217c 100644 --- a/python/helpers/typeshed/stdlib/2and3/locale.pyi +++ b/python/helpers/typeshed/stdlib/2and3/locale.pyi @@ -1,5 +1,6 @@ # Stubs for locale +from decimal import Decimal from typing import Any, Iterable, List, Mapping, Optional, Sequence, Tuple, Union import sys @@ -91,7 +92,7 @@ def normalize(localename: _str) -> _str: ... def resetlocale(category: int = ...) -> None: ... def strcoll(string1: _str, string2: _str) -> int: ... def strxfrm(string: _str) -> _str: ... -def format(format: _str, val: int, grouping: bool = ..., +def format(format: _str, val: Union[float, Decimal], grouping: bool = ..., monetary: bool = ...) -> _str: ... def format_string(format: _str, val: Sequence[Any], grouping: bool = ...) -> _str: ... diff --git a/python/helpers/typeshed/stdlib/2and3/logging/__init__.pyi b/python/helpers/typeshed/stdlib/2and3/logging/__init__.pyi index 653ec2397c56..2b605032c60c 100644 --- a/python/helpers/typeshed/stdlib/2and3/logging/__init__.pyi +++ b/python/helpers/typeshed/stdlib/2and3/logging/__init__.pyi @@ -13,20 +13,36 @@ import threading _SysExcInfoType = Union[Tuple[type, BaseException, TracebackType], Tuple[None, None, None]] if sys.version_info >= (3, 5): - _ExcInfoType = Union[None, bool, _SysExcInfoType, Exception] + _ExcInfoType = Union[None, bool, _SysExcInfoType, BaseException] else: _ExcInfoType = Union[None, bool, _SysExcInfoType] _ArgsType = Union[Tuple[Any, ...], Dict[str, Any]] _FilterType = Union['Filter', Callable[['LogRecord'], int]] +_Level = Union[int, Text] +raiseExceptions: bool -class Logger: +if sys.version_info >= (3,): + _levelToName = ... # type: Dict[int, str] + _nameToLevel = ... # type: Dict[str, int] +else: + _levelNames = ... # type: dict + +class Filterer(object): + filters = ... # type: List[Filter] + def __init__(self) -> None: ... + def addFilter(self, filter: Filter) -> None: ... + def removeFilter(self, filter: Filter) -> None: ... + def filter(self, record: 'LogRecord') -> bool: ... + +class Logger(Filterer): name = ... # type: str level = ... # type: int parent = ... # type: Union[Logger, PlaceHolder] propagate = ... # type: bool handlers = ... # type: List[Handler] disabled = ... # type: int + def __init__(self, name: str, level: _Level = ...) -> None: ... def setLevel(self, lvl: Union[int, str]) -> None: ... def isEnabledFor(self, lvl: int) -> bool: ... def getEffectiveLevel(self) -> int: ... @@ -110,6 +126,7 @@ class Logger: CRITICAL = ... # type: int +FATAL = ... # type: int ERROR = ... # type: int WARNING = ... # type: int WARN = ... # type: int @@ -118,19 +135,11 @@ DEBUG = ... # type: int NOTSET = ... # type: int -class Filterer(object): - filters = ... # type: List[Filter] - def __init__(self) -> None: ... - def addFilter(self, filter: Filter) -> None: ... - def removeFilter(self, filter: Filter) -> None: ... - def filter(self, record: 'LogRecord') -> bool: ... - - class Handler(Filterer): level = ... # type: int formatter = ... # type: Optional[Formatter] lock = ... # type: Optional[threading.Lock] - def __init__(self, level: int = ...) -> None: ... + def __init__(self, level: _Level = ...) -> None: ... def createLock(self) -> None: ... def acquire(self) -> None: ... def release(self) -> None: ... @@ -322,6 +331,7 @@ else: extra: Optional[Dict[str, Any]] = ..., **kwargs: Any) -> None: ... def log(lvl: int, msg: Text, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any) -> None: ... +fatal = critical def disable(lvl: int) -> None: ... def addLevelName(lvl: int, levelName: str) -> None: ... @@ -332,7 +342,7 @@ def makeLogRecord(attrdict: Mapping[str, Any]) -> LogRecord: ... if sys.version_info >= (3,): def basicConfig(*, filename: str = ..., filemode: str = ..., format: str = ..., datefmt: str = ..., style: str = ..., - level: int = ..., stream: IO[str] = ..., + level: _Level = ..., stream: IO[str] = ..., handlers: Iterable[Handler] = ...) -> None: ... else: @overload @@ -340,10 +350,13 @@ else: @overload def basicConfig(*, filename: str = ..., filemode: str = ..., format: str = ..., datefmt: str = ..., - level: int = ..., stream: IO[str] = ...) -> None: ... + level: _Level = ..., stream: IO[str] = ...) -> None: ... def shutdown() -> None: ... def setLoggerClass(klass: type) -> None: ... + +def captureWarnings(capture: bool) -> None: ... + if sys.version_info >= (3,): def setLogRecordFactory(factory: Callable[..., LogRecord]) -> None: ... @@ -353,6 +366,9 @@ if sys.version_info >= (3,): class StreamHandler(Handler): + stream = ... # type IO[str] + if sys.version_info >= (3,): + terminator = ... # type: str def __init__(self, stream: Optional[IO[str]] = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/logging/config.pyi b/python/helpers/typeshed/stdlib/2and3/logging/config.pyi index 99f740659f6b..dc5e19e02945 100644 --- a/python/helpers/typeshed/stdlib/2and3/logging/config.pyi +++ b/python/helpers/typeshed/stdlib/2and3/logging/config.pyi @@ -3,9 +3,7 @@ from typing import Any, Callable, Dict, Optional, IO, Union import sys if sys.version_info >= (3,): - # from configparser import RawConfigParser - # TODO add RawConfigParser to configparser stubs - RawConfigParser = Any + from configparser import RawConfigParser else: from ConfigParser import RawConfigParser diff --git a/python/helpers/typeshed/stdlib/2and3/logging/handlers.pyi b/python/helpers/typeshed/stdlib/2and3/logging/handlers.pyi index 6041397305e0..0dcaee9c1c1d 100644 --- a/python/helpers/typeshed/stdlib/2and3/logging/handlers.pyi +++ b/python/helpers/typeshed/stdlib/2and3/logging/handlers.pyi @@ -11,7 +11,7 @@ if sys.version_info >= (3,): else: from Queue import Queue # TODO update socket stubs to add SocketKind -SocketKind = int +_SocketKind = int class WatchedFileHandler(Handler): @@ -29,7 +29,7 @@ class WatchedFileHandler(Handler): if sys.version_info >= (3,): class BaseRotatingHandler(FileHandler): - namer = ... # type: Optional[Callable[[str], None]] + namer = ... # type: Optional[Callable[[str], str]] rotator = ... # type: Optional[Callable[[str, str], None]] def __init__(self, filename: str, mode: str, encoding: Optional[str] = ..., @@ -122,7 +122,7 @@ class SysLogHandler(Handler): LOG_LOCAL6 = ... # type: int LOG_LOCAL7 = ... # type: int def __init__(self, address: Union[Tuple[str, int], str] = ..., - facility: int = ..., socktype: SocketKind = ...) -> None: ... + facility: int = ..., socktype: _SocketKind = ...) -> None: ... def encodePriority(self, facility: Union[int, str], priority: Union[int, str]) -> int: ... def mapPriority(self, levelName: int) -> str: ... diff --git a/python/helpers/typeshed/stdlib/2and3/mmap.pyi b/python/helpers/typeshed/stdlib/2and3/mmap.pyi index d0be9df5f95b..933723bdbea7 100644 --- a/python/helpers/typeshed/stdlib/2and3/mmap.pyi +++ b/python/helpers/typeshed/stdlib/2and3/mmap.pyi @@ -1,21 +1,6 @@ -# Stubs for mmap - import sys -from types import TracebackType -from typing import (Optional, Sequence, Union, Generic, TypeVar, overload, - Iterable, Container, Sized, Reversible, Type) - - -_T = TypeVar('_T', str, bytes) - -# TODO already in PEP, have to get added to mypy -_C = TypeVar('_C') -class _ContextManager(Generic[_C]): - def __enter__(self) -> _C: ... - def __exit__(self, exc_type: Optional[Type[BaseException]], - exc_val: Optional[Exception], - exc_tb: Optional[TracebackType]) -> bool: ... - +from typing import (Optional, Sequence, Union, Generic, overload, + Iterable, Iterator, Sized, ContextManager, AnyStr) ACCESS_READ = ... # type: int ACCESS_WRITE = ... # type: int @@ -31,7 +16,7 @@ if sys.platform != 'win32': PAGESIZE = ... # type: int -class _mmap(Generic[_T]): +class _mmap(Generic[AnyStr]): if sys.platform == 'win32': def __init__(self, fileno: int, length: int, tagname: Optional[str] = ..., access: int = ..., @@ -42,24 +27,23 @@ class _mmap(Generic[_T]): prot: int = ..., access: int = ..., offset: int = ...) -> None: ... def close(self) -> None: ... - def find(self, sub: _T, + def find(self, sub: AnyStr, start: int = ..., end: int = ...) -> int: ... def flush(self, offset: int = ..., size: int = ...) -> int: ... def move(self, dest: int, src: int, count: int) -> None: ... - def read(self, n: int = ...) -> _T: ... - def read_byte(self) -> _T: ... - def readline(self) -> _T: ... + def read(self, n: int = ...) -> AnyStr: ... + def read_byte(self) -> AnyStr: ... + def readline(self) -> AnyStr: ... def resize(self, newsize: int) -> None: ... def seek(self, pos: int, whence: int = ...) -> None: ... def size(self) -> int: ... def tell(self) -> int: ... - def write(self, bytes: _T) -> None: ... - def write_byte(self, byte: _T) -> None: ... + def write(self, bytes: AnyStr) -> None: ... + def write_byte(self, byte: AnyStr) -> None: ... def __len__(self) -> int: ... if sys.version_info >= (3,): - class mmap(_mmap, _ContextManager[mmap], Iterable[bytes], Container[bytes], - Sized, Reversible[bytes]): + class mmap(_mmap, ContextManager[mmap], Iterable[bytes], Sized): closed = ... # type: bool def rfind(self, sub: bytes, start: int = ..., stop: int = ...) -> int: ... @overload @@ -71,6 +55,9 @@ if sys.version_info >= (3,): def __setitem__(self, index: int, object: int) -> None: ... @overload def __setitem__(self, index: slice, object: bytes) -> None: ... + # Doesn't actually exist, but the object is actually iterable because it has __getitem__ and + # __len__, so we claim that there is also an __iter__ to help type checkers. + def __iter__(self) -> Iterator[bytes]: ... else: class mmap(_mmap, Sequence[bytes]): def rfind(self, string: bytes, start: int = ..., stop: int = ...) -> int: ... diff --git a/python/helpers/typeshed/stdlib/2and3/numbers.pyi b/python/helpers/typeshed/stdlib/2and3/numbers.pyi index e4f7603e62f8..2a3f493e229b 100644 --- a/python/helpers/typeshed/stdlib/2and3/numbers.pyi +++ b/python/helpers/typeshed/stdlib/2and3/numbers.pyi @@ -5,7 +5,7 @@ # Note: these stubs are incomplete. The more complex type # signatures are currently omitted. -from typing import Any, Optional, TypeVar +from typing import Any, Optional, TypeVar, SupportsFloat from abc import ABCMeta, abstractmethod import sys @@ -59,7 +59,7 @@ class Complex(Number): if sys.version_info < (3, 0): def __ne__(self, other: object) -> bool: ... -class Real(Complex): +class Real(Complex, SupportsFloat): @abstractmethod def __float__(self) -> float: ... @abstractmethod diff --git a/python/helpers/typeshed/stdlib/2and3/opcode.pyi b/python/helpers/typeshed/stdlib/2and3/opcode.pyi index 4e72eae7aaf1..4cc1ab03db6e 100644 --- a/python/helpers/typeshed/stdlib/2and3/opcode.pyi +++ b/python/helpers/typeshed/stdlib/2and3/opcode.pyi @@ -12,7 +12,7 @@ hascompare = ... # type: List[int] hasfree = ... # type: List[int] opname = ... # type: List[str] -opmap = ... # Dict[str, int] +opmap = ... # type: Dict[str, int] HAVE_ARGUMENT = ... # type: int EXTENDED_ARG = ... # type: int diff --git a/python/helpers/typeshed/stdlib/2and3/optparse.pyi b/python/helpers/typeshed/stdlib/2and3/optparse.pyi new file mode 100644 index 000000000000..2e52647f5ff0 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/optparse.pyi @@ -0,0 +1,226 @@ +# Generated by pytype, with only minor tweaks. Might be incomplete. +import sys +from typing import Any, Callable, Dict, IO, Iterable, List, Mapping, Optional, Sequence, Tuple, Union + +# See https://groups.google.com/forum/#!topic/python-ideas/gA1gdj3RZ5g +if sys.version_info >= (3,): + _Text = str +else: + _Text = Union[str, unicode] + +NO_DEFAULT = ... # type: Tuple[_Text, ...] +SUPPRESS_HELP = ... # type: _Text +SUPPRESS_USAGE = ... # type: _Text + +def check_builtin(option: Option, opt: Any, value: _Text) -> Any: ... +def check_choice(option: Option, opt: Any, value: _Text) -> Any: ... +if sys.version_info < (3,): + def isbasestring(x: Any) -> bool: ... + +class OptParseError(Exception): + msg = ... # type: _Text + def __init__(self, msg: _Text) -> None: ... + +class BadOptionError(OptParseError): + opt_str = ... # type: _Text + def __init__(self, opt_str: _Text) -> None: ... + +class AmbiguousOptionError(BadOptionError): + possibilities = ... # type: Iterable[_Text] + def __init__(self, opt_str: _Text, possibilities: Sequence[_Text]) -> None: ... + +class OptionError(OptParseError): + msg = ... # type: _Text + option_id = ... # type: _Text + def __init__(self, msg: _Text, option: Option) -> None: ... + +class OptionConflictError(OptionError): ... + +class OptionValueError(OptParseError): ... + + +class HelpFormatter: + NO_DEFAULT_VALUE = ... # type: _Text + _long_opt_fmt = ... # type: _Text + _short_opt_fmt = ... # type: _Text + current_indent = ... # type: int + default_tag = ... # type: _Text + help_position = ... # type: Any + help_width = ... # type: Any + indent_increment = ... # type: int + level = ... # type: int + max_help_position = ... # type: int + option_strings = ... # type: Dict[Option, _Text] + parser = ... # type: OptionParser + short_first = ... # type: Any + width = ... # type: int + def __init__(self, indent_increment: int, max_help_position: int, width: Optional[int], short_first: int) -> None: ... + def _format__Text(self, _Text: _Text) -> _Text: ... + def dedent(self) -> None: ... + def expand_default(self, option: Option) -> _Text: ... + def format_description(self, description: _Text) -> _Text: ... + def format_epilog(self, epilog) -> _Text: ... + def format_heading(self, heading: Any) -> _Text: ... + def format_option(self, option: OptionParser) -> _Text: ... + def format_option_strings(self, option: OptionParser) -> Any: ... + def format_usage(self, usage: Any) -> _Text: ... + def indent(self) -> None: ... + def set_long_opt_delimiter(self, delim: _Text) -> None: ... + def set_parser(self, parser: OptionParser) -> None: ... + def set_short_opt_delimiter(self, delim: _Text) -> None: ... + def store_option_strings(self, parser: OptionParser) -> None: ... + +class IndentedHelpFormatter(HelpFormatter): + def __init__(self, + indent_increment: int = ..., + max_help_position: int = ..., + width: Optional[int] = ..., + short_first: int = ...) -> None: ... + def format_heading(self, heading: _Text) -> _Text: ... + def format_usage(self, usage: _Text) -> _Text: ... + +class TitledHelpFormatter(HelpFormatter): + def __init__(self, + indent_increment: int = ..., + max_help_position: int = ..., + width: Optional[int] = ..., + short_first: int = ...) -> None: ... + def format_heading(self, heading: _Text) -> _Text: ... + def format_usage(self, usage: _Text) -> _Text: ... + +class Option: + ACTIONS = ... # type: Tuple[_Text, ...] + ALWAYS_TYPED_ACTIONS = ... # type: Tuple[_Text, ...] + ATTRS = ... # type: List[_Text] + CHECK_METHODS = ... # type: Optional[List[Callable]] + CONST_ACTIONS = ... # type: Tuple[_Text, ...] + STORE_ACTIONS = ... # type: Tuple[_Text, ...] + TYPED_ACTIONS = ... # type: Tuple[_Text, ...] + TYPES = ... # type: Tuple[_Text, ...] + TYPE_CHECKER = ... # type: Dict[_Text, Callable] + _long_opts = ... # type: List[_Text] + _short_opts = ... # type: List[_Text] + action = ... # type: _Text + dest = ... # type: Any + nargs = ... # type: int + type = ... # type: Any + def __init__(self, *opts, **attrs) -> None: ... + def _check_action(self) -> None: ... + def _check_callback(self) -> None: ... + def _check_choice(self) -> None: ... + def _check_const(self) -> None: ... + def _check_dest(self) -> None: ... + def _check_nargs(self) -> None: ... + def _check_opt_strings(self, opts: Optional[_Text]) -> Any: ... + def _check_type(self) -> None: ... + def _set_attrs(self, attrs: Dict[_Text, Any]) -> None: ... + def _set_opt_strings(self, opts: _Text) -> None: ... + def check_value(self, opt: Any, value: Any) -> Any: ... + def convert_value(self, opt: Any, value: Any) -> Any: ... + def get_opt_string(self) -> _Text: ... + def process(self, opt: Any, value: Any, values: Any, parser: OptionParser) -> int: ... + def take_action(self, action: _Text, dest: _Text, opt: Any, value: Any, values: Any, parser: OptionParser) -> int: ... + def takes_value(self) -> bool: ... + +make_option = Option + +class OptionContainer: + _long_opt = ... # type: Dict[_Text, Option] + _short_opt = ... # type: Dict[_Text, Option] + conflict_handler = ... # type: _Text + defaults = ... # type: Dict[_Text, Any] + description = ... # type: Any + option_class = ... # type: Any + def __init__(self, option_class: Option, conflict_handler: Any, description: Any) -> None: ... + def _check_conflict(self, option: Any) -> None: ... + def _create_option_mappings(self) -> None: ... + def _share_option_mappings(self, parser: OptionParser) -> None: ... + def add_option(self, *args, **kwargs) -> Any: ... + def add_options(self, option_list: Iterable[Option]) -> None: ... + def destroy(self) -> None: ... + def format_description(self, formatter: Optional[HelpFormatter]) -> Any: ... + def format_help(self, formatter: Optional[HelpFormatter]) -> _Text: ... + def format_option_help(self, formatter: Optional[HelpFormatter]) -> _Text: ... + def get_description(self) -> Any: ... + def get_option(self, opt_str: _Text) -> Optional[Option]: ... + def has_option(self, opt_str: _Text) -> bool: ... + def remove_option(self, opt_str: _Text) -> None: ... + def set_conflict_handler(self, handler: Any) -> None: ... + def set_description(self, description: Any) -> None: ... + +class OptionGroup(OptionContainer): + option_list = ... # type: List[Option] + parser = ... # type: OptionParser + title = ... # type: _Text + def __init__(self, parser: OptionParser, title: _Text, description: Optional[_Text] = ...) -> None: ... + def _create_option_list(self) -> None: ... + def set_title(self, title: _Text) -> None: ... + +class OptionParser(OptionContainer): + allow_interspersed_args = ... # type: bool + epilog = ... # type: Any + formatter = ... # type: HelpFormatter + largs = ... # type: Optional[List[_Text]] + option_groups = ... # type: List[OptionParser] + option_list = ... # type: List[Any] + process_default_values = ... # type: Any + prog = ... # type: Any + rargs = ... # type: Optional[List[Any]] + standard_option_list = ... # type: List + usage = ... # type: Optional[_Text] + values = ... # type: Any + version = ... # type: _Text + def __init__(self, usage: Optional[_Text] = ..., + option_list: Iterable[Option] = ..., + option_class: Option = ..., + version: Optional[_Text] = ..., + conflict_handler: _Text = ..., + description: Optional[_Text] = ..., + formatter: Optional[HelpFormatter] = ..., + add_help_option: bool = ..., + prog: Optional[_Text] = ..., + epilog: Optional[_Text] = ...) -> None: ... + def _add_help_option(self) -> None: ... + def _add_version_option(self) -> None: ... + def _create_option_list(self) -> None: ... + def _get_all_options(self) -> List[Any]: ... + def _get_args(self, args: Iterable) -> List[Any]: ... + def _init_parsing_state(self) -> None: ... + def _match_long_opt(self, opt: _Text) -> _Text: ... + def _populate_option_list(self, option_list: Iterable[Option], add_help: bool = ...) -> None: ... + def _process_args(self, largs: List, rargs: List, values: Values) -> None: ... + def _process_long_opt(self, rargs: List, values: Any) -> None: ... + def _process_short_opts(self, rargs: List, values: Any) -> None: ... + def add_option_group(self, *args, **kwargs) -> OptionParser: ... + def check_values(self, values: Any, args) -> Tuple[Any, ...]: ... + def disable_interspersed_args(self) -> None: ... + def enable_interspersed_args(self) -> None: ... + def error(self, msg: _Text) -> None: ... + def exit(self, status: int = ..., msg: Optional[str] = ...) -> None: ... + def expand_prog_name(self, s: Optional[_Text]) -> Any: ... + def format_epilog(self, formatter: HelpFormatter) -> Any: ... + def format_help(self, formatter: Optional[HelpFormatter] = ...) -> _Text: ... + def format_option_help(self, formatter: Optional[HelpFormatter] = ...) -> _Text: ... + def get_default_values(self) -> Values: ... + def get_option_group(self, opt_str: _Text) -> Any: ... + def get_prog_name(self) -> _Text: ... + def get_usage(self) -> _Text: ... + def get_version(self) -> _Text: ... + def parse_args(self, args: Optional[Sequence[_Text]] = ..., values: Optional[Values] = ...) -> Tuple[Any, ...]: ... + def print_usage(self, file: Optional[IO[str]] = ...) -> None: ... + def print_help(self, file: Optional[IO[str]] = ...) -> None: ... + def print_version(self, file: Optional[IO[str]] = ...) -> None: ... + def set_default(self, dest: Any, value: Any) -> None: ... + def set_defaults(self, **kwargs) -> None: ... + def set_process_default_values(self, process: Any) -> None: ... + def set_usage(self, usage: _Text) -> None: ... + + +class Values: + def __init__(self, defaults: Optional[Mapping[str, Any]] = ...) -> None: ... + def _update(self, dict: Dict[_Text, Any], mode: Any) -> None: ... + def _update_careful(self, dict: Dict[_Text, Any]) -> None: ... + def _update_loose(self, dict: Dict[_Text, Any]) -> None: ... + def ensure_value(self, attr: Any, value: Any) -> Any: ... + def read_file(self, filename: _Text, mode: _Text) -> None: ... + def read_module(self, modname: _Text, mode: _Text) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/pdb.pyi b/python/helpers/typeshed/stdlib/2and3/pdb.pyi new file mode 100644 index 000000000000..226436b6b561 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/pdb.pyi @@ -0,0 +1,30 @@ +# NOTE: This stub is incomplete - only contains some global functions + +from typing import Any, Dict, Optional + +def run(statement: str, + globals: Optional[Dict[str, Any]] = None, + locals: Optional[Dict[str, Any]] = None) -> None: + ... + +def runeval(expression: str, + globals: Optional[Dict[str, Any]] = None, + locals: Optional[Dict[str, Any]] = None) -> Any: + ... + +def runctx(statement: str, + globals: Dict[str, Any], + locals: Dict[str, Any]) -> None: + ... + +def runcall(*args: Any, **kwds: Any) -> Any: + ... + +def set_trace() -> None: + ... + +def post_mortem(t: Optional[Any] = None) -> None: + ... + +def pm() -> None: + ... diff --git a/python/helpers/typeshed/stdlib/2and3/pickle.pyi b/python/helpers/typeshed/stdlib/2and3/pickle.pyi new file mode 100644 index 000000000000..7bfad8f3bf1b --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/pickle.pyi @@ -0,0 +1,140 @@ +import sys +from typing import Any, IO, Mapping, Union, Tuple, Callable, Optional, Iterator + +HIGHEST_PROTOCOL: int +if sys.version_info >= (3, 0): + DEFAULT_PROTOCOL: int + + +if sys.version_info >= (3, 0): + def dump(obj: Any, file: IO[bytes], protocol: Optional[int] = ..., *, + fix_imports: bool = ...) -> None: ... + def dumps(obj: Any, protocol: Optional[int] = ..., *, + fix_imports: bool = ...) -> bytes: ... + def loads(bytes_object: bytes, *, fix_imports: bool = ..., + encoding: str = ..., errors: str = ...) -> Any: ... + def load(file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ..., + errors: str = ...) -> Any: ... +else: + def dump(obj: Any, file: IO[bytes], protocol: Optional[int] = ...) -> None: ... + def dumps(obj: Any, protocol: Optional[int] = ...) -> bytes: ... + def load(file: IO[bytes]) -> Any: ... + def loads(string: bytes) -> Any: ... + +class PickleError(Exception): ... +class PicklingError(PickleError): ... +class UnpicklingError(PickleError): ... + +_reducedtype = Union[str, + Tuple[Callable[..., Any], Tuple], + Tuple[Callable[..., Any], Tuple, Any], + Tuple[Callable[..., Any], Tuple, Any, + Optional[Iterator]], + Tuple[Callable[..., Any], Tuple, Any, + Optional[Iterator], Optional[Iterator]]] + + +class Pickler: + fast: bool + if sys.version_info >= (3, 3): + dispatch_table: Mapping[type, Callable[[Any], _reducedtype]] + + if sys.version_info >= (3, 0): + def __init__(self, file: IO[bytes], protocol: Optional[int] = ..., *, + fix_imports: bool = ...) -> None: ... + else: + def __init__(self, file: IO[bytes], protocol: Optional[int] = ...) -> None: ... + + def dump(self, obj: Any) -> None: ... + def clear_memo(self) -> None: ... + def persistent_id(self, obj: Any) -> Any: ... + + +class Unpickler: + if sys.version_info >= (3, 0): + def __init__(self, file: IO[bytes], *, fix_imports: bool = ..., + encoding: str = ..., errors: str = ...) -> None: ... + else: + def __init__(self, file: IO[bytes]) -> None: ... + + def load(self) -> Any: ... + def find_class(self, module: str, name: str) -> Any: ... + if sys.version_info >= (3, 0): + def persistent_load(self, pid: Any) -> Any: ... + +MARK: bytes +STOP: bytes +POP: bytes +POP_MARK: bytes +DUP: bytes +FLOAT: bytes +INT: bytes +BININT: bytes +BININT1: bytes +LONG: bytes +BININT2: bytes +NONE: bytes +PERSID: bytes +BINPERSID: bytes +REDUCE: bytes +STRING: bytes +BINSTRING: bytes +SHORT_BINSTRING: bytes +UNICODE: bytes +BINUNICODE: bytes +APPEND: bytes +BUILD: bytes +GLOBAL: bytes +DICT: bytes +EMPTY_DICT: bytes +APPENDS: bytes +GET: bytes +BINGET: bytes +INST: bytes +LONG_BINGET: bytes +LIST: bytes +EMPTY_LIST: bytes +OBJ: bytes +PUT: bytes +BINPUT: bytes +LONG_BINPUT: bytes +SETITEM: bytes +TUPLE: bytes +EMPTY_TUPLE: bytes +SETITEMS: bytes +BINFLOAT: bytes + +TRUE: bytes +FALSE: bytes + +# protocol 2 +PROTO: bytes +NEWOBJ: bytes +EXT1: bytes +EXT2: bytes +EXT4: bytes +TUPLE1: bytes +TUPLE2: bytes +TUPLE3: bytes +NEWTRUE: bytes +NEWFALSE: bytes +LONG1: bytes +LONG4: bytes + +if sys.version_info >= (3, 0): + # protocol 3 + BINBYTES: bytes + SHORT_BINBYTES: bytes + +if sys.version_info >= (3, 4): + # protocol 4 + SHORT_BINUNICODE: bytes + BINUNICODE8: bytes + BINBYTES8: bytes + EMPTY_SET: bytes + ADDITEMS: bytes + FROZENSET: bytes + NEWOBJ_EX: bytes + STACK_GLOBAL: bytes + MEMOIZE: bytes + FRAME: bytes diff --git a/python/helpers/typeshed/stdlib/2and3/pickletools.pyi b/python/helpers/typeshed/stdlib/2and3/pickletools.pyi new file mode 100644 index 000000000000..c03664697bab --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/pickletools.pyi @@ -0,0 +1,145 @@ +# Stubs for pickletools (Python 2 and 3) +import sys +from typing import Any, Callable, IO, Iterator, List, MutableMapping, Optional, Text, Tuple, Type, Union + +_Reader = Callable[[IO[bytes]], Any] + +if sys.version_info >= (3, 0): + bytes_types: Tuple[Type[Any], ...] + +UP_TO_NEWLINE: int +TAKEN_FROM_ARGUMENT1: int +TAKEN_FROM_ARGUMENT4: int +if sys.version_info >= (3, 3): + TAKEN_FROM_ARGUMENT4U: int +if sys.version_info >= (3, 4): + TAKEN_FROM_ARGUMENT8U: int + +class ArgumentDescriptor(object): + name: str + n: int + reader: _Reader + doc: str + def __init__(self, name: str, n: int, reader: _Reader, doc: str) -> None: ... + +def read_uint1(f: IO[bytes]) -> int: ... +uint1: ArgumentDescriptor + +def read_uint2(f: IO[bytes]) -> int: ... +uint2: ArgumentDescriptor + +def read_int4(f: IO[bytes]) -> int: ... +int4: ArgumentDescriptor + +if sys.version_info >= (3, 3): + def read_uint4(f: IO[bytes]) -> int: ... + uint4: ArgumentDescriptor + +if sys.version_info >= (3, 5): + def read_uint8(f: IO[bytes]) -> int: ... + uint8: ArgumentDescriptor + +def read_stringnl(f: IO[bytes], decode: bool = ..., stripquotes: bool = ...) -> Union[bytes, Text]: ... +stringnl: ArgumentDescriptor + +def read_stringnl_noescape(f: IO[bytes]) -> str: ... +stringnl_noescape: ArgumentDescriptor + +def read_stringnl_noescape_pair(f: IO[bytes]) -> Text: ... +stringnl_noescape_pair: ArgumentDescriptor + +def read_string1(f: IO[bytes]) -> str: ... +string1: ArgumentDescriptor + +def read_string4(f: IO[bytes]) -> str: ... +string4: ArgumentDescriptor + +if sys.version_info >= (3, 3): + def read_bytes1(f: IO[bytes]) -> bytes: ... + bytes1: ArgumentDescriptor + + def read_bytes4(f: IO[bytes]) -> bytes: ... + bytes4: ArgumentDescriptor + +if sys.version_info >= (3, 4): + def read_bytes8(f: IO[bytes]) -> bytes: ... + bytes8: ArgumentDescriptor + +def read_unicodestringnl(f: IO[bytes]) -> Text: ... +unicodestringnl: ArgumentDescriptor + +if sys.version_info >= (3, 4): + def read_unicodestring1(f: IO[bytes]) -> Text: ... + unicodestring1: ArgumentDescriptor + +def read_unicodestring4(f: IO[bytes]) -> Text: ... +unicodestring4: ArgumentDescriptor + +if sys.version_info >= (3, 4): + def read_unicodestring8(f: IO[bytes]) -> Text: ... + unicodestring8: ArgumentDescriptor + +def read_decimalnl_short(f: IO[bytes]) -> int: ... +def read_decimalnl_long(f: IO[bytes]) -> int: ... +decimalnl_short: ArgumentDescriptor +decimalnl_long: ArgumentDescriptor + +def read_floatnl(f: IO[bytes]) -> float: ... +floatnl: ArgumentDescriptor + +def read_float8(f: IO[bytes]) -> float: ... +float8: ArgumentDescriptor + +def read_long1(f: IO[bytes]) -> int: ... +long1: ArgumentDescriptor + +def read_long4(f: IO[bytes]) -> int: ... +long4: ArgumentDescriptor + +class StackObject(object): + name: str + obtype: Union[Type[Any], Tuple[Type[Any], ...]] + doc: str + def __init__(self, name: str, obtype: Union[Type[Any], Tuple[Type[Any], ...]], doc: str) -> None: ... + +pyint: StackObject +pylong: StackObject +pyinteger_or_bool: StackObject +pybool: StackObject +pyfloat: StackObject +if sys.version_info >= (3, 4): + pybytes_or_str: StackObject +pystring: StackObject +if sys.version_info >= (3, 0): + pybytes: StackObject +pyunicode: StackObject +pynone: StackObject +pytuple: StackObject +pylist: StackObject +pydict: StackObject +if sys.version_info >= (3, 4): + pyset: StackObject + pyfrozenset: StackObject +anyobject: StackObject +markobject: StackObject +stackslice: StackObject + +class OpcodeInfo(object): + name: str + code: str + arg: Optional[ArgumentDescriptor] + stack_before: List[StackObject] + stack_after: List[StackObject] + proto: int + doc: str + def __init__(self, name: str, code: str, arg: Optional[ArgumentDescriptor], + stack_before: List[StackObject], stack_after: List[StackObject], proto: int, doc: str) -> None: ... + +opcodes: List[OpcodeInfo] + +def genops(pickle: Union[bytes, IO[bytes]]) -> Iterator[Tuple[OpcodeInfo, Optional[Any], Optional[int]]]: ... +def optimize(p: Union[bytes, IO[bytes]]) -> bytes: ... +if sys.version_info >= (3, 2): + def dis(pickle: Union[bytes, IO[bytes]], out: Optional[IO[str]] = ..., memo: Optional[MutableMapping[int, Any]] = ..., indentlevel: int = ..., annotate: int = ...) -> None: ... +else: + def dis(pickle: Union[bytes, IO[bytes]], out: Optional[IO[str]] = ..., memo: Optional[MutableMapping[int, Any]] = ..., indentlevel: int = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/poplib.pyi b/python/helpers/typeshed/stdlib/2and3/poplib.pyi new file mode 100644 index 000000000000..e7e0c36e0dec --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/poplib.pyi @@ -0,0 +1,75 @@ +# Stubs for poplib (Python 2 and 3) + +from mypy_extensions import NoReturn +import socket +import ssl +import sys +from typing import Any, BinaryIO, Dict, List, Optional, overload, Pattern, Text, Tuple + +_LongResp = Tuple[bytes, List[bytes], int] + +class error_proto(Exception): pass + +POP3_PORT: int +POP3_SSL_PORT: int +CR: bytes +LF: bytes +CRLF: bytes + + +class POP3: + if sys.version_info >= (3, 0): + encoding: Text + + host: Text + port: int + sock: socket.socket + file: BinaryIO + welcome: bytes + + def __init__(self, host: Text, port: int = ..., timeout: float = ...) -> None: ... + def getwelcome(self) -> bytes: ... + def set_debuglevel(self, level: int) -> None: ... + def user(self, user: Text) -> bytes: ... + def pass_(self, pswd: Text) -> bytes: ... + def stat(self) -> Tuple[int, int]: ... + def list(self, which: Optional[Any] = ...) -> _LongResp: ... + def retr(self, which: Any) -> _LongResp: ... + def dele(self, which: Any) -> bytes: ... + def noop(self) -> bytes: ... + def rset(self) -> bytes: ... + def quit(self) -> bytes: ... + def close(self) -> None: ... + def rpop(self, user: Text) -> bytes: ... + + timestamp: Pattern[Text] + + if sys.version_info < (3, 0): + def apop(self, user: Text, secret: Text) -> bytes: ... + else: + def apop(self, user: Text, password: Text) -> bytes: ... + def top(self, which: Any, howmuch: int) -> _LongResp: ... + + @overload + def uidl(self) -> _LongResp: ... + @overload + def uidl(self, which: Any) -> bytes: ... + + if sys.version_info >= (3, 5): + def utf8(self) -> bytes: ... + if sys.version_info >= (3, 4): + def capa(self) -> Dict[Text, List[Text]]: ... + def stls(self, context: Optional[ssl.SSLContext] = ...) -> bytes: ... + + +class POP3_SSL(POP3): + if sys.version_info >= (3, 0): + def __init__(self, host: Text, port: int = ..., keyfile: Optional[Text] = ..., certfile: Optional[Text] = ..., + timeout: float = ..., context: Optional[ssl.SSLContext] = ...) -> None: ... + else: + def __init__(self, host: Text, port: int = ..., keyfile: Optional[Text] = ..., certfile: Optional[Text] = ..., + timeout: float = ...) -> None: ... + + if sys.version_info >= (3, 4): + # "context" is actually the last argument, but that breaks LSP and it doesn't really matter because all the arguments are ignored + def stls(self, context: Any = ..., keyfile: Any = ..., certfile: Any = ...) -> bytes: ... diff --git a/python/helpers/typeshed/stdlib/2and3/pprint.pyi b/python/helpers/typeshed/stdlib/2and3/pprint.pyi new file mode 100644 index 000000000000..35da3a3e90db --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/pprint.pyi @@ -0,0 +1,24 @@ +# Stubs for pprint + +# Based on http://docs.python.org/2/library/pprint.html +# Based on http://docs.python.org/3/library/pprint.html + +from typing import Any, Dict, Tuple, IO + +def pformat(o: object, indent: int = ..., width: int = ..., + depth: int = ...) -> str: ... +def pprint(o: object, stream: IO[str] = ..., indent: int = ..., width: int = ..., + depth: int = ...) -> None: ... +def isreadable(o: object) -> bool: ... +def isrecursive(o: object) -> bool: ... +def saferepr(o: object) -> str: ... + +class PrettyPrinter: + def __init__(self, indent: int = ..., width: int = ..., depth: int = ..., + stream: IO[str] = ...) -> None: ... + def pformat(self, o: object) -> str: ... + def pprint(self, o: object) -> None: ... + def isreadable(self, o: object) -> bool: ... + def isrecursive(self, o: object) -> bool: ... + def format(self, o: object, context: Dict[int, Any], maxlevels: int, + level: int) -> Tuple[str, bool, bool]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/pstats.pyi b/python/helpers/typeshed/stdlib/2and3/pstats.pyi index 2d70f88594fd..8bf1b0dae900 100644 --- a/python/helpers/typeshed/stdlib/2and3/pstats.pyi +++ b/python/helpers/typeshed/stdlib/2and3/pstats.pyi @@ -1,19 +1,25 @@ from profile import Profile -from cProfile import Profile as cProfile -from typing import Any, AnyStr, Dict, IO, Iterable, List, Text, Tuple, TypeVar, Union, overload +from cProfile import Profile as _cProfile +import os +import sys +from typing import Any, Dict, IO, Iterable, List, Text, Tuple, TypeVar, Union, overload _Selector = Union[str, float, int] _T = TypeVar('_T', bound='Stats') +if sys.version_info >= (3, 6): + _Path = Union[bytes, Text, os.PathLike[Any]] +else: + _Path = Union[bytes, Text] class Stats: - def __init__(self: _T, __arg: Union[None, str, Text, Profile, cProfile] = ..., - *args: Union[None, str, Text, Profile, cProfile, _T], + def __init__(self: _T, __arg: Union[None, str, Text, Profile, _cProfile] = ..., + *args: Union[None, str, Text, Profile, _cProfile, _T], 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 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: ... - def add(self: _T, *arg_list: Union[None, str, Text, Profile, cProfile, _T]) -> _T: ... - def dump_stats(self, filename: AnyStr) -> None: ... + def add(self: _T, *arg_list: Union[None, str, Text, Profile, _cProfile, _T]) -> _T: ... + def dump_stats(self, filename: _Path) -> None: ... def get_sort_arg_defs(self) -> Dict[str, Tuple[Tuple[Tuple[int, int], ...], str]]: ... @overload def sort_stats(self: _T, field: int) -> _T: ... diff --git a/python/helpers/typeshed/stdlib/2and3/pty.pyi b/python/helpers/typeshed/stdlib/2and3/pty.pyi new file mode 100644 index 000000000000..3931bb0a91e2 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/pty.pyi @@ -0,0 +1,20 @@ +# Stubs for pty (Python 2 and 3) +import sys +from typing import Callable, Iterable, Tuple, Union + +_Reader = Callable[[int], bytes] + +STDIN_FILENO: int +STDOUT_FILENO: int +STDERR_FILENO: int + +CHILD: int + +def openpty() -> Tuple[int, int]: ... +def master_open() -> Tuple[int, str]: ... +def slave_open(tty_name: str) -> int: ... +def fork() -> Tuple[int, int]: ... +if sys.version_info >= (3, 4): + def spawn(argv: Union[str, Iterable[str]], master_read: _Reader = ..., stdin_read: _Reader = ...) -> int: ... +else: + def spawn(argv: Union[str, Iterable[str]], master_read: _Reader = ..., stdin_read: _Reader = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/pwd.pyi b/python/helpers/typeshed/stdlib/2and3/pwd.pyi new file mode 100644 index 000000000000..5bd0bbb64193 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/pwd.pyi @@ -0,0 +1,13 @@ +from typing import List, NamedTuple + +struct_passwd = NamedTuple("struct_passwd", [("pw_name", str), + ("pw_passwd", str), + ("pw_uid", int), + ("pw_gid", int), + ("pw_gecos", str), + ("pw_dir", str), + ("pw_shell", str)]) + +def getpwall() -> List[struct_passwd]: ... +def getpwuid(uid: int) -> struct_passwd: ... +def getpwnam(name: str) -> struct_passwd: ... diff --git a/python/helpers/typeshed/stdlib/2and3/sched.pyi b/python/helpers/typeshed/stdlib/2and3/sched.pyi new file mode 100644 index 000000000000..b8e7b2b0ac1c --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/sched.pyi @@ -0,0 +1,27 @@ +import sys +from typing import Any, Callable, Dict, List, NamedTuple, Text, Tuple + +Event = NamedTuple('Event', [ + ('time', float), + ('priority', Any), + ('action', Callable[..., Any]), + ('argument', Tuple[Any, ...]), + ('kwargs', Dict[Text, Any]), +]) + +class scheduler: + if sys.version_info >= (3, 3): + def __init__(self, timefunc: Callable[[], float] = ..., delayfunc: Callable[[float], None] = ...) -> None: ... + def enterabs(self, time: float, priority: Any, action: Callable[..., Any], argument: Tuple[Any, ...] = ..., kwargs: Dict[str, Any] = ...) -> Event: ... + def enter(self, delay: float, priority: Any, action: Callable[..., Any], argument: Tuple[Any, ...] = ..., kwargs: Dict[str, Any] = ...) -> Event: ... + def run(self, blocking: bool = ...) -> float: ... + else: + def __init__(self, timefunc: Callable[[], float], delayfunc: Callable[[float], None]) -> None: ... + def enterabs(self, time: float, priority: Any, action: Callable[..., Any], argument: Tuple[Any, ...]) -> Event: ... + def enter(self, delay: float, priority: Any, action: Callable[..., Any], argument: Tuple[Any, ...]) -> Event: ... + def run(self) -> float: ... + + def cancel(self, event: Event) -> None: ... + def empty(self) -> bool: ... + @property + def queue(self) -> List[Event]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/select.pyi b/python/helpers/typeshed/stdlib/2and3/select.pyi new file mode 100644 index 000000000000..ab9ffc63603a --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/select.pyi @@ -0,0 +1,137 @@ +import sys +from typing import Any, Optional, Sequence, Tuple, Iterable, List, Union + +# When we have protocols, this should change to a protocol with a fileno method +# See https://docs.python.org/3/c-api/file.html#c.PyObject_AsFileDescriptor +_FileDescriptor = Union[int, Any] + +EPOLLERR: int +EPOLLET: int +EPOLLHUP: int +EPOLLIN: int +EPOLLMSG: int +EPOLLONESHOT: int +EPOLLOUT: int +EPOLLPRI: int +EPOLLRDBAND: int +EPOLLRDNORM: int +EPOLLWRBAND: int +EPOLLWRNORM: int +EPOLL_RDHUP: int +KQ_EV_ADD: int +KQ_EV_CLEAR: int +KQ_EV_DELETE: int +KQ_EV_DISABLE: int +KQ_EV_ENABLE: int +KQ_EV_EOF: int +KQ_EV_ERROR: int +KQ_EV_FLAG1: int +KQ_EV_ONESHOT: int +KQ_EV_SYSFLAGS: int +KQ_FILTER_AIO: int +KQ_FILTER_NETDEV: int +KQ_FILTER_PROC: int +KQ_FILTER_READ: int +KQ_FILTER_SIGNAL: int +KQ_FILTER_TIMER: int +KQ_FILTER_VNODE: int +KQ_FILTER_WRITE: int +KQ_NOTE_ATTRIB: int +KQ_NOTE_CHILD: int +KQ_NOTE_DELETE: int +KQ_NOTE_EXEC: int +KQ_NOTE_EXIT: int +KQ_NOTE_EXTEND: int +KQ_NOTE_FORK: int +KQ_NOTE_LINK: int +KQ_NOTE_LINKDOWN: int +KQ_NOTE_LINKINV: int +KQ_NOTE_LINKUP: int +KQ_NOTE_LOWAT: int +KQ_NOTE_PCTRLMASK: int +KQ_NOTE_PDATAMASK: int +KQ_NOTE_RENAME: int +KQ_NOTE_REVOKE: int +KQ_NOTE_TRACK: int +KQ_NOTE_TRACKERR: int +KQ_NOTE_WRITE: int +PIPE_BUF: int +POLLERR: int +POLLHUP: int +POLLIN: int +POLLMSG: int +POLLNVAL: int +POLLOUT: int +POLLPRI: int +POLLRDBAND: int +POLLRDNORM: int +POLLWRBAND: int +POLLWRNORM: int + +class poll: + def __init__(self) -> None: ... + def register(self, fd: _FileDescriptor, eventmask: int = ...) -> None: ... + def modify(self, fd: _FileDescriptor, eventmask: int) -> None: ... + def unregister(self, fd: _FileDescriptor) -> None: ... + def poll(self, timeout: Optional[float] = ...) -> List[Tuple[int, int]]: ... + +def select(rlist: Sequence[Any], wlist: Sequence[Any], xlist: Sequence[Any], + timeout: Optional[float] = ...) -> Tuple[List[Any], + List[Any], + List[Any]]: ... + +if sys.version_info >= (3, 3): + error = OSError +else: + class error(Exception): ... + +# BSD only +class kevent(object): + data: Any + fflags: int + filter: int + flags: int + ident: int + udata: Any + def __init__(self, ident: _FileDescriptor, filter: int = ..., flags: int = ..., fflags: int = ..., data: Any = ..., udata: Any = ...) -> None: ... + +# BSD only +class kqueue(object): + closed: bool + def __init__(self) -> None: ... + def close(self) -> None: ... + def control(self, changelist: Optional[Iterable[kevent]], max_events: int, timeout: float = ...) -> List[kevent]: ... + def fileno(self) -> int: ... + @classmethod + def fromfd(cls, fd: _FileDescriptor) -> kqueue: ... + +# Linux only +class epoll(object): + if sys.version_info >= (3, 3): + def __init__(self, sizehint: int = ..., flags: int = ...) -> None: ... + else: + def __init__(self, sizehint: int = ...) -> None: ... + if sys.version_info >= (3, 4): + def __enter__(self) -> epoll: ... + def __exit__(self, *args: Any) -> None: ... + def close(self) -> None: ... + closed: bool + def fileno(self) -> int: ... + def register(self, fd: _FileDescriptor, eventmask: int = ...) -> None: ... + def modify(self, fd: _FileDescriptor, eventmask: int) -> None: ... + def unregister(self, fd: _FileDescriptor) -> None: ... + def poll(self, timeout: float = ..., maxevents: int = ...) -> List[Tuple[int, int]]: ... + @classmethod + def fromfd(cls, fd: _FileDescriptor) -> epoll: ... + +if sys.version_info >= (3, 3): + # Solaris only + class devpoll: + if sys.version_info >= (3, 4): + def close(self) -> None: ... + closed: bool + def fileno(self) -> int: ... + def register(self, fd: _FileDescriptor, eventmask: int = ...) -> None: ... + def modify(self, fd: _FileDescriptor, eventmask: int = ...) -> None: ... + def unregister(self, fd: _FileDescriptor) -> None: ... + def poll(self, timeout: Optional[float] = ...) -> List[Tuple[int, int]]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/smtpd.pyi b/python/helpers/typeshed/stdlib/2and3/smtpd.pyi new file mode 100644 index 000000000000..923b8bc65df4 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/smtpd.pyi @@ -0,0 +1,87 @@ +# Stubs for smtpd (Python 2 and 3) +import sys +import socket +import asyncore +import asynchat + +from typing import Any, DefaultDict, List, Optional, Text, Tuple, Type + +_Address = Tuple[str, int] # (host, port) + + +class SMTPChannel(asynchat.async_chat): + COMMAND: int + DATA: int + + if sys.version_info >= (3, 3): + command_size_limits: DefaultDict[str, int] + + if sys.version_info >= (3,): + smtp_server: SMTPServer + conn: socket.socket + addr: Any + received_lines: List[Text] + smtp_state: int + seen_greeting: str + mailfrom: str + rcpttos: List[str] + received_data: str + fqdn: str + peer: str + + command_size_limit: int + data_size_limit: int + + if sys.version_info >= (3, 5): + enable_SMTPUTF8: bool + + if sys.version_info >= (3, 3): + @property + def max_command_size_limit(self) -> int: ... + + if sys.version_info >= (3, 5): + def __init__(self, server: SMTPServer, conn: socket.socket, addr: Any, data_size_limit: int = ..., + map: Optional[asyncore._maptype] = ..., enable_SMTPUTF8: bool = ..., decode_data: bool = ...) -> None: ... + elif sys.version_info >= (3, 4): + def __init__(self, server: SMTPServer, conn: socket.socket, addr: Any, data_size_limit: int = ..., + map: Optional[asyncore._maptype] = ...) -> None: ... + else: + def __init__(self, server: SMTPServer, conn: socket.socket, addr: Any, data_size_limit: int = ...) -> None: ... + def push(self, msg: bytes) -> None: ... + def collect_incoming_data(self, data: bytes) -> None: ... + def found_terminator(self) -> None: ... + def smtp_HELO(self, arg: str) -> None: ... + def smtp_NOOP(self, arg: str) -> None: ... + def smtp_QUIT(self, arg: str) -> None: ... + def smtp_MAIL(self, arg: str) -> None: ... + def smtp_RCPT(self, arg: str) -> None: ... + def smtp_RSET(self, arg: str) -> None: ... + def smtp_DATA(self, arg: str) -> None: ... + if sys.version_info >= (3, 3): + def smtp_EHLO(self, arg: str) -> None: ... + def smtp_HELP(self, arg: str) -> None: ... + def smtp_VRFY(self, arg: str) -> None: ... + def smtp_EXPN(self, arg: str) -> None: ... + +class SMTPServer(asyncore.dispatcher): + channel_class: Type[SMTPChannel] + + data_size_limit: int + enable_SMTPUTF8: bool + + if sys.version_info >= (3, 5): + def __init__(self, localaddr: _Address, remoteaddr: _Address, + data_size_limit: int = ..., map: Optional[asyncore._maptype] = ..., + enable_SMTPUTF8: bool = ..., decode_data: bool = ...) -> None: ... + elif sys.version_info >= (3, 4): + def __init__(self, localaddr: _Address, remoteaddr: _Address, + data_size_limit: int = ..., map: Optional[asyncore._maptype] = ...) -> None: ... + else: + def __init__(self, localaddr: _Address, remoteaddr: _Address, + data_size_limit: int = ...) -> None: ... + def handle_accepted(self, conn: socket.socket, addr: Any) -> None: ... + def process_message(self, peer: _Address, mailfrom: str, rcpttos: List[Text], data: str, **kwargs: Any) -> Optional[str]: ... + +class DebuggingServer(SMTPServer): ... +class PureProxy(SMTPServer): ... +class MailmanProxy(PureProxy): ... diff --git a/python/helpers/typeshed/stdlib/2and3/socket.pyi b/python/helpers/typeshed/stdlib/2and3/socket.pyi new file mode 100644 index 000000000000..34ed45206fa7 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/socket.pyi @@ -0,0 +1,599 @@ +# Stubs for socket +# Ron Murawski + +# based on: http://docs.python.org/3.2/library/socket.html +# see: http://hg.python.org/cpython/file/3d0686d90f55/Lib/socket.py +# see: http://nullege.com/codes/search/socket +# adapted for Python 2.7 by Michal Pokorny +import sys +from typing import Any, Tuple, List, Optional, Union, overload, TypeVar + + +# ----- variables and constants ----- + +AF_UNIX: int +AF_INET: int +AF_INET6: int +SOCK_STREAM: int +SOCK_DGRAM: int +SOCK_RAW: int +SOCK_RDM: int +SOCK_SEQPACKET: int +SOCK_CLOEXEC: int +SOCK_NONBLOCK: int +SOMAXCONN: int +has_ipv6: bool +_GLOBAL_DEFAULT_TIMEOUT: Any +SocketType: Any +SocketIO: Any + +# These are flags that may exist on Python 3.6. Many don't exist on all platforms. +AF_AAL5: int +AF_APPLETALK: int +AF_ASH: int +AF_ATMPVC: int +AF_ATMSVC: int +AF_AX25: int +AF_BLUETOOTH: int +AF_BRIDGE: int +AF_CAN: int +AF_DECnet: int +AF_ECONET: int +AF_IPX: int +AF_IRDA: int +AF_KEY: int +AF_LLC: int +AF_NETBEUI: int +AF_NETLINK: int +AF_NETROM: int +AF_PACKET: int +AF_PPPOX: int +AF_RDS: int +AF_ROSE: int +AF_ROUTE: int +AF_SECURITY: int +AF_SNA: int +AF_SYSTEM: int +AF_TIPC: int +AF_UNSPEC: int +AF_WANPIPE: int +AF_X25: int +AI_ADDRCONFIG: int +AI_ALL: int +AI_CANONNAME: int +AI_DEFAULT: int +AI_MASK: int +AI_NUMERICHOST: int +AI_NUMERICSERV: int +AI_PASSIVE: int +AI_V4MAPPED: int +AI_V4MAPPED_CFG: int +BDADDR_ANY: str +BDADDR_LOCAL: str +BTPROTO_HCI: int +BTPROTO_L2CAP: int +BTPROTO_RFCOMM: int +BTPROTO_SCO: int +CAN_EFF_FLAG: int +CAN_EFF_MASK: int +CAN_ERR_FLAG: int +CAN_ERR_MASK: int +CAN_RAW: int +CAN_RAW_ERR_FILTER: int +CAN_RAW_FILTER: int +CAN_RAW_LOOPBACK: int +CAN_RAW_RECV_OWN_MSGS: int +CAN_RTR_FLAG: int +CAN_SFF_MASK: int +CAPI: int +EAGAIN: int +EAI_ADDRFAMILY: int +EAI_AGAIN: int +EAI_BADFLAGS: int +EAI_BADHINTS: int +EAI_FAIL: int +EAI_FAMILY: int +EAI_MAX: int +EAI_MEMORY: int +EAI_NODATA: int +EAI_NONAME: int +EAI_OVERFLOW: int +EAI_PROTOCOL: int +EAI_SERVICE: int +EAI_SOCKTYPE: int +EAI_SYSTEM: int +EBADF: int +EINTR: int +EWOULDBLOCK: int +HCI_DATA_DIR: int +HCI_FILTER: int +HCI_TIME_STAMP: int +INADDR_ALLHOSTS_GROUP: int +INADDR_ANY: int +INADDR_BROADCAST: int +INADDR_LOOPBACK: int +INADDR_MAX_LOCAL_GROUP: int +INADDR_NONE: int +INADDR_UNSPEC_GROUP: int +IPPORT_RESERVED: int +IPPORT_USERRESERVED: int +IPPROTO_AH: int +IPPROTO_BIP: int +IPPROTO_DSTOPTS: int +IPPROTO_EGP: int +IPPROTO_EON: int +IPPROTO_ESP: int +IPPROTO_FRAGMENT: int +IPPROTO_GGP: int +IPPROTO_GRE: int +IPPROTO_HELLO: int +IPPROTO_HOPOPTS: int +IPPROTO_ICMP: int +IPPROTO_ICMPV6: int +IPPROTO_IDP: int +IPPROTO_IGMP: int +IPPROTO_IP: int +IPPROTO_IPCOMP: int +IPPROTO_IPIP: int +IPPROTO_IPV4: int +IPPROTO_IPV6: int +IPPROTO_MAX: int +IPPROTO_MOBILE: int +IPPROTO_ND: int +IPPROTO_NONE: int +IPPROTO_PIM: int +IPPROTO_PUP: int +IPPROTO_RAW: int +IPPROTO_ROUTING: int +IPPROTO_RSVP: int +IPPROTO_SCTP: int +IPPROTO_TCP: int +IPPROTO_TP: int +IPPROTO_UDP: int +IPPROTO_VRRP: int +IPPROTO_XTP: int +IPV6_CHECKSUM: int +IPV6_DONTFRAG: int +IPV6_DSTOPTS: int +IPV6_HOPLIMIT: int +IPV6_HOPOPTS: int +IPV6_JOIN_GROUP: int +IPV6_LEAVE_GROUP: int +IPV6_MULTICAST_HOPS: int +IPV6_MULTICAST_IF: int +IPV6_MULTICAST_LOOP: int +IPV6_NEXTHOP: int +IPV6_PATHMTU: int +IPV6_PKTINFO: int +IPV6_RECVDSTOPTS: int +IPV6_RECVHOPLIMIT: int +IPV6_RECVHOPOPTS: int +IPV6_RECVPATHMTU: int +IPV6_RECVPKTINFO: int +IPV6_RECVRTHDR: int +IPV6_RECVTCLASS: int +IPV6_RTHDR: int +IPV6_RTHDR_TYPE_0: int +IPV6_RTHDRDSTOPTS: int +IPV6_TCLASS: int +IPV6_UNICAST_HOPS: int +IPV6_USE_MIN_MTU: int +IPV6_V6ONLY: int +IP_ADD_MEMBERSHIP: int +IP_DEFAULT_MULTICAST_LOOP: int +IP_DEFAULT_MULTICAST_TTL: int +IP_DROP_MEMBERSHIP: int +IP_HDRINCL: int +IP_MAX_MEMBERSHIPS: int +IP_MULTICAST_IF: int +IP_MULTICAST_LOOP: int +IP_MULTICAST_TTL: int +IP_OPTIONS: int +IP_RECVDSTADDR: int +IP_RECVOPTS: int +IP_RECVRETOPTS: int +IP_RETOPTS: int +IP_TOS: int +IP_TRANSPARENT: int +IP_TTL: int +IPX_TYPE: int +LOCAL_PEERCRED: int +MSG_BCAST: int +MSG_BTAG: int +MSG_CMSG_CLOEXEC: int +MSG_CONFIRM: int +MSG_CTRUNC: int +MSG_DONTROUTE: int +MSG_DONTWAIT: int +MSG_EOF: int +MSG_EOR: int +MSG_ERRQUEUE: int +MSG_ETAG: int +MSG_FASTOPEN: int +MSG_MCAST: int +MSG_MORE: int +MSG_NOSIGNAL: int +MSG_NOTIFICATION: int +MSG_OOB: int +MSG_PEEK: int +MSG_TRUNC: int +MSG_WAITALL: int +NETLINK_ARPD: int +NETLINK_CRYPTO: int +NETLINK_DNRTMSG: int +NETLINK_FIREWALL: int +NETLINK_IP6_FW: int +NETLINK_NFLOG: int +NETLINK_ROUTE6: int +NETLINK_ROUTE: int +NETLINK_SKIP: int +NETLINK_TAPBASE: int +NETLINK_TCPDIAG: int +NETLINK_USERSOCK: int +NETLINK_W1: int +NETLINK_XFRM: int +NI_DGRAM: int +NI_MAXHOST: int +NI_MAXSERV: int +NI_NAMEREQD: int +NI_NOFQDN: int +NI_NUMERICHOST: int +NI_NUMERICSERV: int +PACKET_BROADCAST: int +PACKET_FASTROUTE: int +PACKET_HOST: int +PACKET_LOOPBACK: int +PACKET_MULTICAST: int +PACKET_OTHERHOST: int +PACKET_OUTGOING: int +PF_CAN: int +PF_PACKET: int +PF_RDS: int +PF_SYSTEM: int +SCM_CREDENTIALS: int +SCM_CREDS: int +SCM_RIGHTS: int +SHUT_RD: int +SHUT_RDWR: int +SHUT_WR: int +SOL_ATALK: int +SOL_AX25: int +SOL_CAN_BASE: int +SOL_CAN_RAW: int +SOL_HCI: int +SOL_IP: int +SOL_IPX: int +SOL_NETROM: int +SOL_RDS: int +SOL_ROSE: int +SOL_SOCKET: int +SOL_TCP: int +SOL_TIPC: int +SOL_UDP: int +SO_ACCEPTCONN: int +SO_BINDTODEVICE: int +SO_BROADCAST: int +SO_DEBUG: int +SO_DONTROUTE: int +SO_ERROR: int +SO_EXCLUSIVEADDRUSE: int +SO_KEEPALIVE: int +SO_LINGER: int +SO_MARK: int +SO_OOBINLINE: int +SO_PASSCRED: int +SO_PEERCRED: int +SO_PRIORITY: int +SO_RCVBUF: int +SO_RCVLOWAT: int +SO_RCVTIMEO: int +SO_REUSEADDR: int +SO_REUSEPORT: int +SO_SETFIB: int +SO_SNDBUF: int +SO_SNDLOWAT: int +SO_SNDTIMEO: int +SO_TYPE: int +SO_USELOOPBACK: int +SYSPROTO_CONTROL: int +TCP_CORK: int +TCP_DEFER_ACCEPT: int +TCP_FASTOPEN: int +TCP_INFO: int +TCP_KEEPCNT: int +TCP_KEEPIDLE: int +TCP_KEEPINTVL: int +TCP_LINGER2: int +TCP_MAXSEG: int +TCP_NODELAY: int +TCP_NOTSENT_LOWAT: int +TCP_QUICKACK: int +TCP_SYNCNT: int +TCP_WINDOW_CLAMP: int +TIPC_ADDR_ID: int +TIPC_ADDR_NAME: int +TIPC_ADDR_NAMESEQ: int +TIPC_CFG_SRV: int +TIPC_CLUSTER_SCOPE: int +TIPC_CONN_TIMEOUT: int +TIPC_CRITICAL_IMPORTANCE: int +TIPC_DEST_DROPPABLE: int +TIPC_HIGH_IMPORTANCE: int +TIPC_IMPORTANCE: int +TIPC_LOW_IMPORTANCE: int +TIPC_MEDIUM_IMPORTANCE: int +TIPC_NODE_SCOPE: int +TIPC_PUBLISHED: int +TIPC_SRC_DROPPABLE: int +TIPC_SUB_CANCEL: int +TIPC_SUB_PORTS: int +TIPC_SUB_SERVICE: int +TIPC_SUBSCR_TIMEOUT: int +TIPC_TOP_SRV: int +TIPC_WAIT_FOREVER: int +TIPC_WITHDRAWN: int +TIPC_ZONE_SCOPE: int + +if sys.version_info >= (3, 3): + RDS_CANCEL_SENT_TO: int + RDS_CMSG_RDMA_ARGS: int + RDS_CMSG_RDMA_DEST: int + RDS_CMSG_RDMA_MAP: int + RDS_CMSG_RDMA_STATUS: int + RDS_CMSG_RDMA_UPDATE: int + RDS_CONG_MONITOR: int + RDS_FREE_MR: int + RDS_GET_MR: int + RDS_GET_MR_FOR_DEST: int + RDS_RDMA_DONTWAIT: int + RDS_RDMA_FENCE: int + RDS_RDMA_INVALIDATE: int + RDS_RDMA_NOTIFY_ME: int + RDS_RDMA_READWRITE: int + RDS_RDMA_SILENT: int + RDS_RDMA_USE_ONCE: int + RDS_RECVERR: int + +if sys.version_info >= (3, 4): + CAN_BCM: int + CAN_BCM_TX_SETUP: int + CAN_BCM_TX_DELETE: int + CAN_BCM_TX_READ: int + CAN_BCM_TX_SEND: int + CAN_BCM_RX_SETUP: int + CAN_BCM_RX_DELETE: int + CAN_BCM_RX_READ: int + CAN_BCM_TX_STATUS: int + CAN_BCM_TX_EXPIRED: int + CAN_BCM_RX_STATUS: int + CAN_BCM_RX_TIMEOUT: int + CAN_BCM_RX_CHANGED: int + AF_LINK: int + +if sys.version_info >= (3, 5): + CAN_RAW_FD_FRAMES: int + +if sys.version_info >= (3, 6): + SO_DOMAIN: int + SO_PROTOCOL: int + SO_PEERSEC: int + SO_PASSSEC: int + TCP_USER_TIMEOUT: int + TCP_CONGESTION: int + AF_ALG: int + SOL_ALG: int + ALG_SET_KEY: int + ALG_SET_IV: int + ALG_SET_OP: int + ALG_SET_AEAD_ASSOCLEN: int + ALG_SET_AEAD_AUTHSIZE: int + ALG_SET_PUBKEY: int + ALG_OP_DECRYPT: int + ALG_OP_ENCRYPT: int + ALG_OP_SIGN: int + ALG_OP_VERIFY: int + +if sys.platform == 'win32': + SIO_RCVALL: int + SIO_KEEPALIVE_VALS: int + RCVALL_IPLEVEL: int + RCVALL_MAX: int + RCVALL_OFF: int + RCVALL_ON: int + RCVALL_SOCKETLEVELONLY: int + + if sys.version_info >= (3, 6): + SIO_LOOPBACK_FAST_PATH: int + +# enum versions of above flags py 3.4+ +if sys.version_info >= (3, 4): + from enum import IntEnum + + class AddressFamily(IntEnum): + AF_UNIX = ... + AF_INET = ... + AF_INET6 = ... + AF_APPLETALK = ... + AF_ASH = ... + AF_ATMPVC = ... + AF_ATMSVC = ... + AF_AX25 = ... + AF_BLUETOOTH = ... + AF_BRIDGE = ... + AF_DECnet = ... + AF_ECONET = ... + AF_IPX = ... + AF_IRDA = ... + AF_KEY = ... + AF_LLC = ... + AF_NETBEUI = ... + AF_NETLINK = ... + AF_NETROM = ... + AF_PACKET = ... + AF_PPPOX = ... + AF_ROSE = ... + AF_ROUTE = ... + AF_SECURITY = ... + AF_SNA = ... + AF_TIPC = ... + AF_UNSPEC = ... + AF_WANPIPE = ... + AF_X25 = ... + AF_LINK = ... + + class SocketKind(IntEnum): + SOCK_STREAM = ... + SOCK_DGRAM = ... + SOCK_RAW = ... + SOCK_RDM = ... + SOCK_SEQPACKET = ... + SOCK_CLOEXEC = ... + SOCK_NONBLOCK = ... + +if sys.version_info >= (3, 6): + from enum import IntFlag + + class AddressInfo(IntFlag): + AI_ADDRCONFIG = ... + AI_ALL = ... + AI_CANONNAME = ... + AI_NUMERICHOST = ... + AI_NUMERICSERV = ... + AI_PASSIVE = ... + AI_V4MAPPED = ... + + class MsgFlag(IntFlag): + MSG_CTRUNC = ... + MSG_DONTROUTE = ... + MSG_DONTWAIT = ... + MSG_EOR = ... + MSG_OOB = ... + MSG_PEEK = ... + MSG_TRUNC = ... + MSG_WAITALL = ... + + +# ----- exceptions ----- +class error(IOError): + ... + +class herror(error): + def __init__(self, herror: int, string: str) -> None: ... + +class gaierror(error): + def __init__(self, error: int, string: str) -> None: ... + +class timeout(error): + ... + + +# Addresses can be either tuples of varying lengths (AF_INET, AF_INET6, +# AF_NETLINK, AF_TIPC) or strings (AF_UNIX). + +# TODO AF_PACKET and AF_BLUETOOTH address objects + +_SelfT = TypeVar('_SelfT', bound=socket) + +# ----- classes ----- +class socket: + family: int + type: int + proto: int + + if sys.version_info < (3,): + def __init__(self, family: int = ..., type: int = ..., + proto: int = ...) -> None: ... + else: + def __init__(self, family: int = ..., type: int = ..., + proto: int = ..., fileno: Optional[int] = ...) -> None: ... + + if sys.version_info >= (3, 2): + def __enter__(self: _SelfT) -> _SelfT: ... + def __exit__(self, *args: Any) -> None: ... + + # --- methods --- + # second tuple item is an address + def accept(self) -> Tuple['socket', Any]: ... + def bind(self, address: Union[tuple, str]) -> None: ... + def close(self) -> None: ... + def connect(self, address: Union[tuple, str]) -> None: ... + def connect_ex(self, address: Union[tuple, str]) -> int: ... + def detach(self) -> int: ... + def fileno(self) -> int: ... + + # return value is an address + def getpeername(self) -> Any: ... + def getsockname(self) -> Any: ... + + @overload + def getsockopt(self, level: int, optname: int) -> int: ... + @overload + def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ... + + def gettimeout(self) -> float: ... + def ioctl(self, control: object, + option: Tuple[int, int, int]) -> None: ... + def listen(self, backlog: int) -> None: ... + # TODO the return value may be BinaryIO or TextIO, depending on mode + def makefile(self, mode: str = ..., buffering: int = ..., + encoding: str = ..., errors: str = ..., + newline: str = ...) -> Any: + ... + def recv(self, bufsize: int, flags: int = ...) -> bytes: ... + + # return type is an address + def recvfrom(self, bufsize: int, flags: int = ...) -> Any: ... + def recvfrom_into(self, buffer: bytes, nbytes: int, + flags: int = ...) -> Any: ... + def recv_into(self, buffer: bytes, nbytes: int, + flags: int = ...) -> Any: ... + def send(self, data: bytes, flags: int = ...) -> int: ... + def sendall(self, data: bytes, flags: int =...) -> None: + ... # return type: None on success + @overload + def sendto(self, data: bytes, address: Union[tuple, str]) -> int: ... + @overload + def sendto(self, data: bytes, flags: int, address: Union[tuple, str]) -> int: ... + def setblocking(self, flag: bool) -> None: ... + def settimeout(self, value: Optional[float]) -> None: ... + def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... + def shutdown(self, how: int) -> None: ... + + +# ----- functions ----- +def create_connection(address: Tuple[str, int], + timeout: float = ..., + source_address: Tuple[str, int] = ...) -> socket: ... + +# the 5th tuple item is an address +# TODO the "Tuple[Any, ...]" should be "Union[Tuple[str, int], Tuple[str, int, int, int]]" but that triggers +# https://github.com/python/mypy/issues/2509 +def getaddrinfo( + host: Optional[str], port: Union[str, int, None], family: int = ..., + socktype: int = ..., proto: int = ..., + flags: int = ...) -> List[Tuple[int, int, int, str, Tuple[Any, ...]]]: + ... + +def getfqdn(name: str = ...) -> str: ... +def gethostbyname(hostname: str) -> str: ... +def gethostbyname_ex(hostname: str) -> Tuple[str, List[str], List[str]]: ... +def gethostname() -> str: ... +def gethostbyaddr(ip_address: str) -> Tuple[str, List[str], List[str]]: ... +def getnameinfo(sockaddr: tuple, flags: int) -> Tuple[str, int]: ... +def getprotobyname(protocolname: str) -> int: ... +def getservbyname(servicename: str, protocolname: str = ...) -> int: ... +def getservbyport(port: int, protocolname: str = ...) -> str: ... +def socketpair(family: int = ..., + type: int = ..., + proto: int = ...) -> Tuple[socket, socket]: ... +def fromfd(fd: int, family: int, type: int, proto: int = ...) -> socket: ... +def ntohl(x: int) -> int: ... # param & ret val are 32-bit ints +def ntohs(x: int) -> int: ... # param & ret val are 16-bit ints +def htonl(x: int) -> int: ... # param & ret val are 32-bit ints +def htons(x: int) -> int: ... # param & ret val are 16-bit ints +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() -> Optional[float]: ... +def setdefaulttimeout(timeout: Optional[float]) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/struct.pyi b/python/helpers/typeshed/stdlib/2and3/struct.pyi new file mode 100644 index 000000000000..be4474ecdb80 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/struct.pyi @@ -0,0 +1,40 @@ +# Stubs for struct + +# Based on http://docs.python.org/3.2/library/struct.html +# Based on http://docs.python.org/2/library/struct.html + +import sys +from typing import Any, Tuple, Text, Union, Iterator +from array import array + +class error(Exception): ... + +_FmtType = Union[bytes, Text] +if sys.version_info >= (3,): + _BufferType = Union[bytes, bytearray, memoryview] + _WriteBufferType = Union[array, bytearray, memoryview] +else: + _BufferType = Union[bytes, bytearray, buffer, memoryview] + _WriteBufferType = Union[array[Any], bytearray, buffer, memoryview] + +def pack(fmt: _FmtType, *v: Any) -> bytes: ... +def pack_into(fmt: _FmtType, buffer: _WriteBufferType, offset: int, *v: Any) -> None: ... +def unpack(fmt: _FmtType, buffer: _BufferType) -> Tuple[Any, ...]: ... +def unpack_from(fmt: _FmtType, buffer: _BufferType, offset: int = ...) -> Tuple[Any, ...]: ... +if sys.version_info >= (3, 4): + def iter_unpack(fmt: _FmtType, buffer: _BufferType) -> Iterator[Tuple[Any, ...]]: ... + +def calcsize(fmt: _FmtType) -> int: ... + +class Struct: + format = ... # type: bytes + size = ... # type: int + + def __init__(self, format: _FmtType) -> None: ... + + def pack(self, *v: Any) -> bytes: ... + def pack_into(self, buffer: _WriteBufferType, offset: int, *v: Any) -> None: ... + def unpack(self, buffer: _BufferType) -> Tuple[Any, ...]: ... + def unpack_from(self, buffer: _BufferType, offset: int = ...) -> Tuple[Any, ...]: ... + if sys.version_info >= (3, 4): + def iter_unpack(self, buffer: _BufferType) -> Iterator[Tuple[Any, ...]]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/symtable.pyi b/python/helpers/typeshed/stdlib/2and3/symtable.pyi index 90872639d03a..fd8b9ad79bb8 100644 --- a/python/helpers/typeshed/stdlib/2and3/symtable.pyi +++ b/python/helpers/typeshed/stdlib/2and3/symtable.pyi @@ -1,7 +1,7 @@ -# Stubs for symtable (Python 2 and 3) - import sys -from typing import List, Sequence, Tuple +from typing import List, Sequence, Tuple, Text + +def symtable(code: Text, filename: Text, compile_type: Text) -> SymbolTable: ... class SymbolTable(object): def get_type(self) -> str: ... diff --git a/python/helpers/typeshed/stdlib/2and3/tarfile.pyi b/python/helpers/typeshed/stdlib/2and3/tarfile.pyi index 32a7ca4a0a77..22fa951b3f74 100644 --- a/python/helpers/typeshed/stdlib/2and3/tarfile.pyi +++ b/python/helpers/typeshed/stdlib/2and3/tarfile.pyi @@ -4,10 +4,18 @@ from typing import ( Callable, IO, Iterable, Iterator, List, Mapping, Optional, Type, Union, ) +import os import sys from types import TracebackType +if sys.version_info >= (3, 6): + _Path = Union[bytes, str, os.PathLike] +elif sys.version_info >= (3,): + _Path = Union[bytes, str] +else: + _Path = Union[str, unicode] + ENCODING = ... # type: str USTAR_FORMAT = ... # type: int @@ -30,7 +38,7 @@ if sys.version_info < (3,): TAR_PLAIN = ... # type: int TAR_GZIPPED = ... # type: int -def open(name: Optional[str] = ..., mode: str = ..., +def open(name: Optional[_Path] = ..., mode: str = ..., fileobj: Optional[IO[bytes]] = ..., bufsize: int = ..., *, format: Optional[int] = ..., tarinfo: Optional[TarInfo] = ..., dereference: Optional[bool] = ..., @@ -38,11 +46,12 @@ def open(name: Optional[str] = ..., mode: str = ..., encoding: Optional[str] = ..., errors: str = ..., pax_headers: Optional[Mapping[str, str]] = ..., debug: Optional[int] = ..., - errorlevel: Optional[int] = ...) -> TarFile: ... + errorlevel: Optional[int] = ..., + compresslevel: Optional[int] = ...) -> TarFile: ... class TarFile(Iterable[TarInfo]): - name = ... # type: Optional[str] + name = ... # type: Optional[_Path] mode = ... # type: str fileobj = ... # type: Optional[IO[bytes]] format = ... # type: Optional[int] @@ -56,7 +65,7 @@ class TarFile(Iterable[TarInfo]): errorlevel = ... # type: Optional[int] if sys.version_info < (3,): posix = ... # type: bool - def __init__(self, name: Optional[str] = ..., mode: str = ..., + def __init__(self, name: Optional[_Path] = ..., mode: str = ..., fileobj: Optional[IO[bytes]] = ..., format: Optional[int] = ..., tarinfo: Optional[TarInfo] = ..., dereference: Optional[bool] = ..., @@ -64,7 +73,8 @@ class TarFile(Iterable[TarInfo]): encoding: Optional[str] = ..., errors: str = ..., pax_headers: Optional[Mapping[str, str]] = ..., debug: Optional[int] = ..., - errorlevel: Optional[int] = ...) -> None: ... + errorlevel: Optional[int] = ..., + compresslevel: Optional[int] = ...) -> None: ... def __enter__(self) -> TarFile: ... def __exit__(self, exc_type: Optional[Type[BaseException]], @@ -72,7 +82,7 @@ class TarFile(Iterable[TarInfo]): exc_tb: Optional[TracebackType]) -> bool: ... def __iter__(self) -> Iterator[TarInfo]: ... @classmethod - def open(cls, name: Optional[str] = ..., mode: str = ..., + def open(cls, name: Optional[_Path] = ..., mode: str = ..., fileobj: Optional[IO[bytes]] = ..., bufsize: int = ..., *, format: Optional[int] = ..., tarinfo: Optional[TarInfo] = ..., dereference: Optional[bool] = ..., @@ -91,22 +101,22 @@ class TarFile(Iterable[TarInfo]): def list(self, verbose: bool = ...) -> None: ... def next(self) -> Optional[TarInfo]: ... if sys.version_info >= (3, 5): - def extractall(self, path: str = ..., + def extractall(self, path: _Path = ..., members: Optional[List[TarInfo]] = ..., *, numeric_owner: bool = ...) -> None: ... else: - def extractall(self, path: str = ..., + def extractall(self, path: _Path = ..., members: Optional[List[TarInfo]] = ...) -> None: ... if sys.version_info >= (3, 5): - def extract(self, member: Union[str, TarInfo], path: str = ..., + def extract(self, member: Union[str, TarInfo], path: _Path = ..., set_attrs: bool = ..., *, numeric_owner: bool = ...) -> None: ... elif sys.version_info >= (3,): - def extract(self, member: Union[str, TarInfo], path: str = ..., + def extract(self, member: Union[str, TarInfo], path: _Path = ..., set_attrs: bool = ...) -> None: ... else: def extract(self, member: Union[str, TarInfo], - path: str = ...) -> None: ... + path: _Path = ...) -> None: ... def extractfile(self, member: Union[str, TarInfo]) -> Optional[IO[bytes]]: ... if sys.version_info >= (3,): diff --git a/python/helpers/typeshed/stdlib/2and3/threading.pyi b/python/helpers/typeshed/stdlib/2and3/threading.pyi index 6d0e4a69d5f9..eb89a2749d13 100644 --- a/python/helpers/typeshed/stdlib/2and3/threading.pyi +++ b/python/helpers/typeshed/stdlib/2and3/threading.pyi @@ -37,8 +37,7 @@ def stack_size(size: int = ...) -> int: ... if sys.version_info >= (3,): TIMEOUT_MAX = ... # type: int -if sys.version_info < (3,): - class ThreadError(Exception): ... +class ThreadError(Exception): ... # TODO: Change to a class with __getattr__ and __setattr__ diff --git a/python/helpers/typeshed/stdlib/2and3/token.pyi b/python/helpers/typeshed/stdlib/2and3/token.pyi new file mode 100644 index 000000000000..8d044bdc2f04 --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/token.pyi @@ -0,0 +1,71 @@ +import sys +from typing import Dict + +ENDMARKER = ... # type: int +NAME = ... # type: int +NUMBER = ... # type: int +STRING = ... # type: int +NEWLINE = ... # type: int +INDENT = ... # type: int +DEDENT = ... # type: int +LPAR = ... # type: int +RPAR = ... # type: int +LSQB = ... # type: int +RSQB = ... # type: int +COLON = ... # type: int +COMMA = ... # type: int +SEMI = ... # type: int +PLUS = ... # type: int +MINUS = ... # type: int +STAR = ... # type: int +SLASH = ... # type: int +VBAR = ... # type: int +AMPER = ... # type: int +LESS = ... # type: int +GREATER = ... # type: int +EQUAL = ... # type: int +DOT = ... # type: int +PERCENT = ... # type: int +if sys.version_info < (3,): + BACKQUOTE = ... # type: int +LBRACE = ... # type: int +RBRACE = ... # type: int +EQEQUAL = ... # type: int +NOTEQUAL = ... # type: int +LESSEQUAL = ... # type: int +GREATEREQUAL = ... # type: int +TILDE = ... # type: int +CIRCUMFLEX = ... # type: int +LEFTSHIFT = ... # type: int +RIGHTSHIFT = ... # type: int +DOUBLESTAR = ... # type: int +PLUSEQUAL = ... # type: int +MINEQUAL = ... # type: int +STAREQUAL = ... # type: int +SLASHEQUAL = ... # type: int +PERCENTEQUAL = ... # type: int +AMPEREQUAL = ... # type: int +VBAREQUAL = ... # type: int +CIRCUMFLEXEQUAL = ... # type: int +LEFTSHIFTEQUAL = ... # type: int +RIGHTSHIFTEQUAL = ... # type: int +DOUBLESTAREQUAL = ... # type: int +DOUBLESLASH = ... # type: int +DOUBLESLASHEQUAL = ... # type: int +AT = ... # type: int +if sys.version_info >= (3,): + RARROW = ... # type: int + ELLIPSIS = ... # type: int +if sys.version_info >= (3, 5): + ATEQUAL = ... # type: int + AWAIT = ... # type: int + ASYNC = ... # type: int +OP = ... # type: int +ERRORTOKEN = ... # type: int +N_TOKENS = ... # type: int +NT_OFFSET = ... # type: int +tok_name = ... # type: Dict[int, str] + +def ISTERMINAL(x: int) -> bool: ... +def ISNONTERMINAL(x: int) -> bool: ... +def ISEOF(x: int) -> bool: ... diff --git a/python/helpers/typeshed/stdlib/2and3/traceback.pyi b/python/helpers/typeshed/stdlib/2and3/traceback.pyi index ff34ad4cd5e7..d53adfe9efa4 100644 --- a/python/helpers/typeshed/stdlib/2and3/traceback.pyi +++ b/python/helpers/typeshed/stdlib/2and3/traceback.pyi @@ -1,13 +1,13 @@ # Stubs for traceback -from typing import Generator, IO, Iterator, List, Mapping, Optional, Tuple, Type +from typing import Any, Dict, Generator, IO, Iterator, List, Mapping, Optional, Tuple, Type from types import FrameType, TracebackType import sys _PT = Tuple[str, int, str, Optional[str]] -def print_tb(tb: TracebackType, limit: Optional[int] = ..., +def print_tb(tb: Optional[TracebackType], limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... if sys.version_info >= (3,): def print_exception(etype: Type[BaseException], value: BaseException, @@ -19,7 +19,8 @@ if sys.version_info >= (3,): def print_last(limit: Optional[int] = ..., file: Optional[IO[str]] = ..., chain: bool = ...) -> None: ... else: - def print_exception(etype: Type[BaseException], value: BaseException, + def print_exception(etype: Optional[Type[BaseException]], + value: Optional[BaseException], tb: Optional[TracebackType], limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... def print_exc(limit: Optional[int] = ..., @@ -28,10 +29,17 @@ else: file: Optional[IO[str]] = ...) -> None: ... def print_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... -def extract_tb(tb: TracebackType, limit: Optional[int] = ...) -> List[_PT]: ... -def extract_stack(f: Optional[FrameType] = ..., - limit: Optional[int] = ...) -> List[_PT]: ... -def format_list(extracted_list: List[_PT]) -> List[str]: ... + +if sys.version_info >= (3, 5): + def extract_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> StackSummary: ... + def extract_stack(f: Optional[FrameType] = ..., + limit: Optional[int] = ...) -> StackSummary: ... + def format_list(extracted_list: List[FrameSummary]) -> List[str]: ... +else: + def extract_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> List[_PT]: ... + def extract_stack(f: Optional[FrameType] = ..., + limit: Optional[int] = ...) -> List[_PT]: ... + def format_list(extracted_list: List[_PT]) -> List[str]: ... def format_exception_only(etype: Type[BaseException], value: BaseException) -> List[str]: ... if sys.version_info >= (3,): @@ -40,18 +48,19 @@ if sys.version_info >= (3,): chain: bool = ...) -> List[str]: ... def format_exc(limit: Optional[int] = ..., chain: bool = ...) -> str: ... else: - def format_exception(etype: Type[BaseException], value: BaseException, - tb: TracebackType, + def format_exception(etype: Optional[Type[BaseException]], + value: Optional[BaseException], + tb: Optional[TracebackType], limit: Optional[int] = ...) -> List[str]: ... def format_exc(limit: Optional[int] = ...) -> str: ... -def format_tb(tb: TracebackType, limit: Optional[int] = ...) -> List[str]: ... +def format_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> List[str]: ... def format_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> List[str]: ... if sys.version_info >= (3, 4): def clear_frames(tb: TracebackType) -> None: ... if sys.version_info >= (3, 5): def walk_stack(f: Optional[FrameType]) -> Iterator[Tuple[FrameType, int]]: ... - def walk_tb(tb: TracebackType) -> Iterator[Tuple[FrameType, int]]: ... + def walk_tb(tb: Optional[TracebackType]) -> Iterator[Tuple[FrameType, int]]: ... if sys.version_info < (3,): def tb_lineno(tb: TracebackType) -> int: ... @@ -82,7 +91,22 @@ if sys.version_info >= (3, 5): if sys.version_info >= (3, 5): - class StackSummary: + class FrameSummary: + filename: str + lineno: int + name: str + line: str + locals: Optional[Dict[str, str]] + def __init__(self, filename: str, lineno: int, name: str, + lookup_line: bool = ..., + locals: Optional[Mapping[str, str]] = ..., + line: Optional[int] = ...) -> None: ... + # TODO: more precise typing for __getitem__ and __iter__, + # for a namedtuple-like view on (filename, lineno, name, str). + def __getitem__(self, i: int) -> Any: ... + def __iter__(self) -> Iterator[Any]: ... + + class StackSummary(List[FrameSummary]): @classmethod def extract(cls, frame_gen: Generator[Tuple[FrameType, int], None, None], @@ -90,11 +114,4 @@ if sys.version_info >= (3, 5): capture_locals: bool = ...) -> StackSummary: ... @classmethod def from_list(cls, a_list: List[_PT]) -> StackSummary: ... - - -if sys.version_info >= (3, 5): - class FrameSummary: - def __init__(self, filename: str, lineno: int, name: str, - lookup_line: bool = ..., - locals: Optional[Mapping[str, str]] = ..., - line: Optional[int] = ...) -> None: ... + def format(self) -> List[str]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/uuid.pyi b/python/helpers/typeshed/stdlib/2and3/uuid.pyi new file mode 100644 index 000000000000..f05ccf0c819a --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/uuid.pyi @@ -0,0 +1,87 @@ +# Stubs for uuid + +import sys +from typing import Tuple, Optional, Any + +# Because UUID has properties called int and bytes we need to rename these temporarily. +_Int = int +_Bytes = bytes +_FieldsType = Tuple[int, int, int, int, int, int] + +class UUID: + def __init__(self, hex: Optional[str] = ..., bytes: Optional[_Bytes] = ..., + bytes_le: Optional[_Bytes] = ..., + fields: Optional[_FieldsType] = ..., + int: Optional[_Int] = ..., + version: Optional[_Int] = ...) -> None: ... + @property + def bytes(self) -> _Bytes: ... + @property + def bytes_le(self) -> _Bytes: ... + @property + def clock_seq(self) -> _Int: ... + @property + def clock_seq_hi_variant(self) -> _Int: ... + @property + def clock_seq_low(self) -> _Int: ... + @property + def fields(self) -> _FieldsType: ... + @property + def hex(self) -> str: ... + @property + def int(self) -> _Int: ... + @property + def node(self) -> _Int: ... + @property + def time(self) -> _Int: ... + @property + def time_hi_version(self) -> _Int: ... + @property + def time_low(self) -> _Int: ... + @property + def time_mid(self) -> _Int: ... + @property + def urn(self) -> str: ... + @property + def variant(self) -> str: ... + @property + def version(self) -> Optional[_Int]: ... + + if sys.version_info >= (3,): + def __eq__(self, other: Any) -> bool: ... + def __lt__(self, other: Any) -> bool: ... + def __le__(self, other: Any) -> bool: ... + def __gt__(self, other: Any) -> bool: ... + def __ge__(self, other: Any) -> bool: ... + else: + def get_bytes(self) -> _Bytes: ... + def get_bytes_le(self) -> _Bytes: ... + def get_clock_seq(self) -> _Int: ... + def get_clock_seq_hi_variant(self) -> _Int: ... + def get_clock_seq_low(self) -> _Int: ... + def get_fields(self) -> _FieldsType: ... + def get_hex(self) -> str: ... + def get_node(self) -> _Int: ... + def get_time(self) -> _Int: ... + def get_time_hi_version(self) -> _Int: ... + def get_time_low(self) -> _Int: ... + def get_time_mid(self) -> _Int: ... + def get_urn(self) -> str: ... + def get_variant(self) -> str: ... + def get_version(self) -> Optional[_Int]: ... + def __cmp__(self, other: Any) -> _Int: ... + +def getnode() -> int: ... +def uuid1(node: Optional[_Int] = ..., clock_seq: Optional[_Int] = ...) -> UUID: ... +def uuid3(namespace: UUID, name: str) -> UUID: ... +def uuid4() -> UUID: ... +def uuid5(namespace: UUID, name: str) -> UUID: ... + +NAMESPACE_DNS = ... # type: UUID +NAMESPACE_URL = ... # type: UUID +NAMESPACE_OID = ... # type: UUID +NAMESPACE_X500 = ... # type: UUID +RESERVED_NCS = ... # type: str +RFC_4122 = ... # type: str +RESERVED_MICROSOFT = ... # type: str +RESERVED_FUTURE = ... # type: str diff --git a/python/helpers/typeshed/stdlib/2and3/weakref.pyi b/python/helpers/typeshed/stdlib/2and3/weakref.pyi new file mode 100644 index 000000000000..e3ddbf27845e --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/weakref.pyi @@ -0,0 +1,110 @@ +import sys +import types +from typing import ( + TypeVar, Generic, Any, Callable, overload, Mapping, Iterator, Tuple, + Iterable, Optional, Type, MutableMapping, Union, List, Dict +) + +from _weakref import ( + getweakrefcount as getweakrefcount, + getweakrefs as getweakrefs, + ref as ref, + proxy as proxy, + CallableProxyType as CallableProxyType, + ProxyType as ProxyType, + ReferenceType as ReferenceType) +from _weakrefset import WeakSet as WeakSet + +if sys.version_info < (3, 0): + from exceptions import ReferenceError as ReferenceError + +_S = TypeVar('_S') +_T = TypeVar('_T') +_KT = TypeVar('_KT') +_VT = TypeVar('_VT') + +ProxyTypes: Tuple[Type[Any], ...] + +if sys.version_info >= (3, 4): + class WeakMethod(ref[types.MethodType]): + def __new__(cls, meth: types.MethodType, callback: Optional[Callable[[types.MethodType], Any]] = ...) -> WeakMethod: ... + def __call__(self) -> Optional[types.MethodType]: ... + +class WeakValueDictionary(MutableMapping[_KT, _VT]): + @overload + def __init__(self) -> None: ... + @overload + def __init__(self, __map: Union[Mapping[_KT, _VT], Iterable[Tuple[_KT, _VT]]], **kwargs: _VT) -> None: ... + + def __len__(self) -> int: ... + def __getitem__(self, k: _KT) -> _VT: ... + def __setitem__(self, k: _KT, v: _VT) -> None: ... + def __delitem__(self, v: _KT) -> None: ... + if sys.version_info < (3, 0): + def has_key(self, key: object) -> bool: ... + def __contains__(self, o: object) -> bool: ... + def __iter__(self) -> Iterator[_KT]: ... + def __str__(self) -> str: ... + + def copy(self) -> WeakValueDictionary[_KT, _VT]: ... + + if sys.version_info < (3, 0): + def keys(self) -> List[_KT]: ... + def values(self) -> List[_VT]: ... + def items(self) -> List[Tuple[_KT, _VT]]: ... + def iterkeys(self) -> Iterator[_KT]: ... + def itervalues(self) -> Iterator[_VT]: ... + def iteritems(self) -> Iterator[Tuple[_KT, _VT]]: ... + else: + # These are incompatible with Mapping + def keys(self) -> Iterator[_KT]: ... # type: ignore + def values(self) -> Iterator[_VT]: ... # type: ignore + def items(self) -> Iterator[Tuple[_KT, _VT]]: ... # type: ignore + def itervaluerefs(self) -> Iterator[KeyedRef[_KT, _VT]]: ... + def valuerefs(self) -> List[KeyedRef[_KT, _VT]]: ... + +class KeyedRef(ref[_T], Generic[_KT, _T]): + key: _KT + def __init__(self, ob: _T, callback: Callable[[_T], Any], key: _KT) -> None: ... + +class WeakKeyDictionary(MutableMapping[_KT, _VT]): + @overload + def __init__(self) -> None: ... + @overload + def __init__(self, __map: Union[Mapping[_KT, _VT], Iterable[Tuple[_KT, _VT]]], **kwargs: _VT) -> None: ... + + def __len__(self) -> int: ... + def __getitem__(self, k: _KT) -> _VT: ... + def __setitem__(self, k: _KT, v: _VT) -> None: ... + def __delitem__(self, v: _KT) -> None: ... + if sys.version_info < (3, 0): + def has_key(self, key: object) -> bool: ... + def __contains__(self, o: object) -> bool: ... + def __iter__(self) -> Iterator[_KT]: ... + def __str__(self) -> str: ... + + def copy(self) -> WeakKeyDictionary[_KT, _VT]: ... + + if sys.version_info < (3, 0): + def keys(self) -> List[_KT]: ... + def values(self) -> List[_VT]: ... + def items(self) -> List[Tuple[_KT, _VT]]: ... + def iterkeys(self) -> Iterator[_KT]: ... + def itervalues(self) -> Iterator[_VT]: ... + def iteritems(self) -> Iterator[Tuple[_KT, _VT]]: ... + def iterkeyrefs(self) -> Iterator[ref[_KT]]: ... + else: + # These are incompatible with Mapping + def keys(self) -> Iterator[_KT]: ... # type: ignore + def values(self) -> Iterator[_VT]: ... # type: ignore + def items(self) -> Iterator[Tuple[_KT, _VT]]: ... # type: ignore + def keyrefs(self) -> List[ref[_KT]]: ... + +if sys.version_info >= (3, 4): + class finalize: + def __init__(self, obj: _S, func: Callable[..., _T], *args: Any, **kwargs: Any) -> None: ... + def __call__(self, _: Any = ...) -> Optional[_T]: ... + def detach(self) -> Optional[Tuple[_S, _T, Tuple[Any, ...], Dict[str, Any]]]: ... + def peek(self) -> Optional[Tuple[_S, _T, Tuple[Any, ...], Dict[str, Any]]]: ... + alive: bool + atexit: bool diff --git a/python/helpers/typeshed/stdlib/2and3/webbrowser.pyi b/python/helpers/typeshed/stdlib/2and3/webbrowser.pyi index a478edfd06c9..3d276c8c088d 100644 --- a/python/helpers/typeshed/stdlib/2and3/webbrowser.pyi +++ b/python/helpers/typeshed/stdlib/2and3/webbrowser.pyi @@ -1,36 +1,32 @@ -# Stubs for webbrowser (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - import sys -from typing import Any, Optional, Callable, List +from typing import Any, Optional, Callable, List, Text, Union, Sequence class Error(Exception): ... -def register(name: str, klass: Optional[Callable[[], BaseBrowser]], instance: BaseBrowser=..., update_tryorder: int=...) -> None: ... -def get(using: str=...) -> BaseBrowser: ... -def open(url: str, new: int=..., autoraise: bool=...) -> bool: ... -def open_new(url: str) -> bool: ... -def open_new_tab(url: str) -> bool: ... +def register(name: Text, klass: Optional[Callable[[], BaseBrowser]], instance: BaseBrowser = ..., update_tryorder: int = ...) -> None: ... +def get(using: Optional[Text] = ...) -> BaseBrowser: ... +def open(url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... +def open_new(url: Text) -> bool: ... +def open_new_tab(url: Text) -> bool: ... class BaseBrowser: args = ... # type: List[str] name = ... # type: str basename = ... # type: str - def __init__(self, name: str=...) -> None: ... - def open(self, url: str, new: int=..., autoraise: bool=...) -> bool: ... - def open_new(self, url: str) -> bool: ... - def open_new_tab(self, url: str) -> bool: ... + def __init__(self, name: Text = ...) -> None: ... + def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... + def open_new(self, url: Text) -> bool: ... + def open_new_tab(self, url: Text) -> bool: ... class GenericBrowser(BaseBrowser): args = ... # type: List[str] name = ... # type: str basename = ... # type: str - def __init__(self, name: str) -> None: ... - def open(self, url: str, new: int=..., autoraise: bool=...) -> bool: ... + def __init__(self, name: Union[Text, Sequence[Text]]) -> None: ... + def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... class BackgroundBrowser(GenericBrowser): - def open(self, url: str, new: int=..., autoraise: bool=...) -> bool: ... + def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... class UnixBrowser(BaseBrowser): raise_opts = ... # type: List[str] @@ -40,7 +36,7 @@ class UnixBrowser(BaseBrowser): remote_action = ... # type: str remote_action_newwin = ... # type: str remote_action_newtab = ... # type: str - def open(self, url: str, new: int=..., autoraise: bool=...) -> bool: ... + def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... class Mozilla(UnixBrowser): raise_opts = ... # type: List[str] @@ -82,19 +78,19 @@ class Elinks(UnixBrowser): redirect_stdout = ... # type: bool class Konqueror(BaseBrowser): - def open(self, url: str, new: int=..., autoraise: bool=...) -> bool: ... + def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... class Grail(BaseBrowser): - def open(self, url: str, new: int=..., autoraise: bool=...) -> bool: ... + def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... class WindowsDefault(BaseBrowser): - def open(self, url: str, new: int=..., autoraise: bool=...) -> bool: ... + def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... class MacOSX(BaseBrowser): name = ... # type: str - def __init__(self, name: str) -> None: ... - def open(self, url: str, new: int=..., autoraise: bool=...) -> bool: ... + def __init__(self, name: Text) -> None: ... + def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... class MacOSXOSAScript(BaseBrowser): - def __init__(self, name: str) -> None: ... - def open(self, url: str, new: int=..., autoraise: bool=...) -> bool: ... + def __init__(self, name: Text) -> None: ... + def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... diff --git a/python/helpers/typeshed/stdlib/2and3/xml/__init__.pyi b/python/helpers/typeshed/stdlib/2and3/xml/__init__.pyi index a0a0a89784ed..e69de29bb2d1 100644 --- a/python/helpers/typeshed/stdlib/2and3/xml/__init__.pyi +++ b/python/helpers/typeshed/stdlib/2and3/xml/__init__.pyi @@ -1,20 +0,0 @@ -# Stubs for xml.sax (Python 3) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -class SAXException(Exception): - def __init__(self, msg, exception=None): ... - def getMessage(self): ... - def getException(self): ... - def __getitem__(self, ix): ... - -class SAXParseException(SAXException): - def __init__(self, msg, exception, locator): ... - def getColumnNumber(self): ... - def getLineNumber(self): ... - def getPublicId(self): ... - def getSystemId(self): ... - -class SAXNotRecognizedException(SAXException): ... -class SAXNotSupportedException(SAXException): ... -class SAXReaderNotAvailable(SAXNotSupportedException): ... diff --git a/python/helpers/typeshed/stdlib/2and3/xml/sax/__init__.pyi b/python/helpers/typeshed/stdlib/2and3/xml/sax/__init__.pyi index 71534b00fc4b..93a0f9a8864c 100644 --- a/python/helpers/typeshed/stdlib/2and3/xml/sax/__init__.pyi +++ b/python/helpers/typeshed/stdlib/2and3/xml/sax/__init__.pyi @@ -1,19 +1,20 @@ -from typing import List +from typing import Any, List, Optional, Text, Union +from mypy_extensions import NoReturn import xml.sax -from xml.sax.xmlreader import InputSource +from xml.sax.xmlreader import InputSource, Locator from xml.sax.handler import ContentHandler, ErrorHandler class SAXException(Exception): - def __init__(self, msg, exception=None): ... - def getMessage(self): ... - def getException(self): ... - def __getitem__(self, ix): ... + def __init__(self, msg: str, exception: Optional[Exception] = ...) -> None: ... + def getMessage(self) -> str: ... + def getException(self) -> Exception: ... + def __getitem__(self, ix: Any) -> NoReturn: ... class SAXParseException(SAXException): - def __init__(self, msg, exception, locator): ... - def getColumnNumber(self): ... - def getLineNumber(self): ... + def __init__(self, msg: str, exception: Exception, locator: Locator) -> None: ... + def getColumnNumber(self) -> int: ... + def getLineNumber(self) -> int: ... def getPublicId(self): ... def getSystemId(self): ... @@ -23,12 +24,12 @@ class SAXReaderNotAvailable(SAXNotSupportedException): ... default_parser_list = ... # type: List[str] -def make_parser(parser_list: List[str]) -> xml.sax.xmlreader.XMLReader: ... +def make_parser(parser_list: List[str] = ...) -> xml.sax.xmlreader.XMLReader: ... def parse(source: str, handler: xml.sax.handler.ContentHandler, - errorHandler: xml.sax.handler.ErrorHandler=...): ... + errorHandler: xml.sax.handler.ErrorHandler = ...) -> None: ... -def parseString(string: str, handler: xml.sax.handler.ContentHandler, - errorHandler: xml.sax.handler.ErrorHandler=...): ... +def parseString(string: Union[bytes, Text], handler: xml.sax.handler.ContentHandler, + errorHandler: Optional[xml.sax.handler.ErrorHandler] = ...) -> None: ... def _create_parser(parser_name: str) -> xml.sax.xmlreader.XMLReader: ... diff --git a/python/helpers/typeshed/stdlib/2and3/xml/sax/handler.pyi b/python/helpers/typeshed/stdlib/2and3/xml/sax/handler.pyi index f3221b50103f..0b549b987526 100644 --- a/python/helpers/typeshed/stdlib/2and3/xml/sax/handler.pyi +++ b/python/helpers/typeshed/stdlib/2and3/xml/sax/handler.pyi @@ -1,7 +1,3 @@ -# Stubs for xml.sax.handler (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any version = ... # type: Any diff --git a/python/helpers/typeshed/stdlib/2and3/xml/sax/saxutils.pyi b/python/helpers/typeshed/stdlib/2and3/xml/sax/saxutils.pyi index 7ff053ad365d..80a497cd8385 100644 --- a/python/helpers/typeshed/stdlib/2and3/xml/sax/saxutils.pyi +++ b/python/helpers/typeshed/stdlib/2and3/xml/sax/saxutils.pyi @@ -1,18 +1,19 @@ -# Stubs for xml.sax.saxutils (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Mapping +import sys +from typing import AnyStr, Mapping from xml.sax import handler from xml.sax import xmlreader -def escape(data: str, entities: Mapping[str, str] = ...) -> str: ... -def unescape(data: str, entities: Mapping[str, str] = ...) -> str: ... -def quoteattr(data: str, entities: Mapping[str, str] = ...) -> str: ... +def escape(data: AnyStr, entities: Mapping[str, str] = ...) -> AnyStr: ... +def unescape(data: AnyStr, entities: Mapping[str, str] = ...) -> AnyStr: ... +def quoteattr(data: AnyStr, entities: Mapping[str, str] = ...) -> AnyStr: ... class XMLGenerator(handler.ContentHandler): - def __init__(self, out=..., encoding=...) -> None: ... + if sys.version_info >= (3, 0): + def __init__(self, out=..., encoding=..., + short_empty_elements: bool=...) -> None: ... + else: + def __init__(self, out=..., encoding=...) -> None: ... def startDocument(self): ... def endDocument(self): ... def startPrefixMapping(self, prefix, uri): ... diff --git a/python/helpers/typeshed/stdlib/2and3/xml/sax/xmlreader.pyi b/python/helpers/typeshed/stdlib/2and3/xml/sax/xmlreader.pyi index a5f555335615..fbc1ac1ef984 100644 --- a/python/helpers/typeshed/stdlib/2and3/xml/sax/xmlreader.pyi +++ b/python/helpers/typeshed/stdlib/2and3/xml/sax/xmlreader.pyi @@ -1,7 +1,3 @@ -# Stubs for xml.sax.xmlreader (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - class XMLReader: def __init__(self) -> None: ... def parse(self, source): ... diff --git a/python/helpers/typeshed/stdlib/2and3/zipfile.pyi b/python/helpers/typeshed/stdlib/2and3/zipfile.pyi index 5a504e35a622..f45472ee7526 100644 --- a/python/helpers/typeshed/stdlib/2and3/zipfile.pyi +++ b/python/helpers/typeshed/stdlib/2and3/zipfile.pyi @@ -14,6 +14,7 @@ if sys.version_info >= (3,): BadZipfile = BadZipFile else: class BadZipfile(Exception): ... +error = BadZipfile class LargeZipFile(Exception): ... diff --git a/python/helpers/typeshed/stdlib/2and3/zlib.pyi b/python/helpers/typeshed/stdlib/2and3/zlib.pyi new file mode 100644 index 000000000000..3300f5166eac --- /dev/null +++ b/python/helpers/typeshed/stdlib/2and3/zlib.pyi @@ -0,0 +1,55 @@ +# Stubs for zlib +import sys + +DEFLATED = ... # type: int +DEF_MEM_LEVEL = ... # type: int +MAX_WBITS = ... # type: int +ZLIB_VERSION = ... # type: str +Z_BEST_COMPRESSION = ... # type: int +Z_BEST_SPEED = ... # type: int +Z_DEFAULT_COMPRESSION = ... # type: int +Z_DEFAULT_STRATEGY = ... # type: int +Z_FILTERED = ... # type: int +Z_FINISH = ... # type: int +Z_FULL_FLUSH = ... # type: int +Z_HUFFMAN_ONLY = ... # type: int +Z_NO_FLUSH = ... # type: int +Z_SYNC_FLUSH = ... # type: int +if sys.version_info >= (3,): + DEF_BUF_SIZE = ... # type: int + ZLIB_RUNTIME_VERSION = ... # type: str + +class error(Exception): ... + + +class _Compress: + def compress(self, data: bytes) -> bytes: ... + def flush(self, mode: int = ...) -> bytes: ... + def copy(self) -> _Compress: ... + + +class _Decompress: + unused_data = ... # type: bytes + unconsumed_tail = ... # type: bytes + if sys.version_info >= (3,): + eof = ... # type: bool + def decompress(self, data: bytes, max_length: int = ...) -> bytes: ... + def flush(self, length: int = ...) -> bytes: ... + def copy(self) -> _Decompress: ... + + +def adler32(data: bytes, value: int = ...) -> int: ... +def compress(data: bytes, level: int = ...) -> bytes: ... +if sys.version_info >= (3,): + def compressobj(level: int = ..., method: int = ..., wbits: int = ..., + memLevel: int = ..., strategy: int = ..., + zdict: bytes = ...) -> _Compress: ... +else: + def compressobj(level: int = ..., method: int = ..., wbits: int = ..., + memlevel: int = ..., strategy: int = ...) -> _Compress: ... +def crc32(data: bytes, value: int = ...) -> int: ... +def decompress(data: bytes, wbits: int = ..., bufsize: int = ...) -> bytes: ... +if sys.version_info >= (3,): + def decompressobj(wbits: int = ..., zdict: bytes = ...) -> _Decompress: ... +else: + def decompressobj(wbits: int = ...) -> _Decompress: ... diff --git a/python/helpers/typeshed/stdlib/3.3/ipaddress.pyi b/python/helpers/typeshed/stdlib/3.3/ipaddress.pyi index 69c2454fdfed..7e61fec89e13 100644 --- a/python/helpers/typeshed/stdlib/3.3/ipaddress.pyi +++ b/python/helpers/typeshed/stdlib/3.3/ipaddress.pyi @@ -1,24 +1,11 @@ -# Stubs for ipaddress (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. +from typing import Any, Iterable, Iterator, Optional, SupportsInt, Tuple, TypeVar, Union -from typing import Any - -IPV4LENGTH = ... # type: Any -IPV6LENGTH = ... # type: Any +IPV4LENGTH = ... # type: int +IPV6LENGTH = ... # type: int class AddressValueError(ValueError): ... class NetmaskValueError(ValueError): ... -def ip_address(address): ... -def ip_network(address, strict=...): ... -def ip_interface(address): ... -def v4_int_to_packed(address): ... -def v6_int_to_packed(address): ... -def summarize_address_range(first, last): ... -def collapse_addresses(addresses): ... -def get_mixed_type_key(obj): ... - class _TotalOrderingMixin: def __eq__(self, other): ... def __ne__(self, other): ... @@ -35,9 +22,9 @@ class _IPAddressBase(_TotalOrderingMixin): @property def version(self): ... -class _BaseAddress(_IPAddressBase): +class _BaseAddress(_IPAddressBase, SupportsInt): def __init__(self, address) -> None: ... - def __int__(self): ... + def __int__(self) -> int: ... def __eq__(self, other): ... def __lt__(self, other): ... def __add__(self, other): ... @@ -95,46 +82,46 @@ class _BaseV4: def version(self): ... class IPv4Address(_BaseV4, _BaseAddress): - def __init__(self, address) -> None: ... + def __init__(self, address: object) -> None: ... @property - def packed(self): ... + def packed(self) -> bytes: ... @property - def is_reserved(self): ... + def is_reserved(self) -> bool: ... @property - def is_private(self): ... + def is_private(self) -> bool: ... @property - def is_multicast(self): ... + def is_multicast(self) -> bool: ... @property - def is_unspecified(self): ... + def is_unspecified(self) -> bool: ... @property - def is_loopback(self): ... + def is_loopback(self) -> bool: ... @property - def is_link_local(self): ... + def is_link_local(self) -> bool: ... class IPv4Interface(IPv4Address): - network = ... # type: Any - netmask = ... # type: Any - hostmask = ... # type: Any - def __init__(self, address) -> None: ... - def __eq__(self, other): ... - def __lt__(self, other): ... - def __hash__(self): ... + network = ... # type: IPv4Network + netmask = ... # type: IPv4Address + hostmask = ... # type: IPv4Address + def __init__(self, address: object) -> None: ... + def __eq__(self, other: Any) -> bool: ... + def __lt__(self, other: Any) -> bool: ... + def __hash__(self) -> int: ... @property - def ip(self): ... + def ip(self) -> IPv4Address: ... @property - def with_prefixlen(self): ... + def with_prefixlen(self) -> str: ... @property - def with_netmask(self): ... + def with_netmask(self) -> str: ... @property - def with_hostmask(self): ... + def with_hostmask(self) -> str: ... class IPv4Network(_BaseV4, _BaseNetwork): - network_address = ... # type: Any - netmask = ... # type: Any - hosts = ... # type: Any - def __init__(self, address, strict=...) -> None: ... + network_address = ... # type: IPv4Address + netmask = ... # type: IPv4Address + hosts = ... # type: Iterator[IPv4Address] + def __init__(self, address: object, strict: bool = ...) -> None: ... @property - def is_global(self): ... + def is_global(self) -> bool: ... class _BaseV6: def __init__(self, address) -> None: ... @@ -144,57 +131,71 @@ class _BaseV6: def version(self): ... class IPv6Address(_BaseV6, _BaseAddress): - def __init__(self, address) -> None: ... + def __init__(self, address: object) -> None: ... @property - def packed(self): ... + def packed(self) -> bytes: ... @property - def is_multicast(self): ... + def is_multicast(self) -> bool: ... @property - def is_reserved(self): ... + def is_reserved(self) -> bool: ... @property - def is_link_local(self): ... + def is_link_local(self) -> bool: ... @property - def is_site_local(self): ... + def is_site_local(self) -> bool: ... @property - def is_private(self): ... + def is_private(self) -> bool: ... @property - def is_global(self): ... + def is_global(self) -> bool: ... @property - def is_unspecified(self): ... + def is_unspecified(self) -> bool: ... @property - def is_loopback(self): ... + def is_loopback(self) -> bool: ... @property - def ipv4_mapped(self): ... + def ipv4_mapped(self) -> Optional[IPv4Address]: ... @property - def teredo(self): ... + def teredo(self) -> Optional[Tuple[IPv4Address, IPv4Address]]: ... @property - def sixtofour(self): ... + def sixtofour(self) -> Optional[IPv4Address]: ... class IPv6Interface(IPv6Address): - network = ... # type: Any - netmask = ... # type: Any - hostmask = ... # type: Any - def __init__(self, address) -> None: ... - def __eq__(self, other): ... - def __lt__(self, other): ... - def __hash__(self): ... + network = ... # type: IPv6Network + netmask = ... # type: IPv6Address + hostmask = ... # type: IPv6Address + def __init__(self, address: object) -> None: ... + def __eq__(self, other: Any) -> bool: ... + def __lt__(self, other: Any) -> bool: ... + def __hash__(self) -> int: ... @property - def ip(self): ... + def ip(self) -> IPv6Address: ... @property - def with_prefixlen(self): ... + def with_prefixlen(self) -> str: ... @property - def with_netmask(self): ... + def with_netmask(self) -> str: ... @property - def with_hostmask(self): ... + def with_hostmask(self) -> str: ... @property - def is_unspecified(self): ... + def is_unspecified(self) -> bool: ... @property - def is_loopback(self): ... + def is_loopback(self) -> bool: ... class IPv6Network(_BaseV6, _BaseNetwork): - network_address = ... # type: Any - netmask = ... # type: Any - def __init__(self, address, strict=...) -> None: ... - def hosts(self): ... + network_address = ... # type: IPv6Address + netmask = ... # type: IPv6Address + def __init__(self, address: object, strict: bool = ...) -> None: ... + def hosts(self) -> Iterator[IPv6Address]: ... @property - def is_site_local(self): ... + def is_site_local(self) -> bool: ... + +_ip_address = Union[IPv4Address, IPv6Address] +_ip_network = Union[IPv4Network, IPv6Network] +_ip_interface = Union[IPv4Interface, IPv6Interface] +_AnyIPAddress = TypeVar("_AnyIPAddress", IPv4Address, IPv6Address) + +def ip_address(address: object) -> _ip_address: ... +def ip_network(address: object, strict: bool = ...) -> _ip_network: ... +def ip_interface(address: object) -> _ip_interface: ... +def v4_int_to_packed(address: int) -> bytes: ... +def v6_int_to_packed(address: int) -> bytes: ... +def summarize_address_range(first: _AnyIPAddress, _AnyIPAddress) -> Iterator[_AnyIPAddress]: ... +def collapse_addresses(addresses: Iterable[_AnyIPAddress]) -> Iterator[_AnyIPAddress]: ... +def get_mixed_type_key(obj): ... diff --git a/python/helpers/typeshed/stdlib/3.4/asyncio/__init__.pyi b/python/helpers/typeshed/stdlib/3.4/asyncio/__init__.pyi index a25b6eec2790..ebd0bb289c01 100644 --- a/python/helpers/typeshed/stdlib/3.4/asyncio/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3.4/asyncio/__init__.pyi @@ -1,8 +1,5 @@ -"""The asyncio package, tracking PEP 3156.""" - -import socket import sys -from typing import Type +from typing import List, Type from asyncio.coroutines import ( coroutine as coroutine, @@ -41,6 +38,7 @@ from asyncio.futures import ( CancelledError as CancelledError, TimeoutError as TimeoutError, InvalidStateError as InvalidStateError, + wrap_future as wrap_future, ) from asyncio.tasks import ( FIRST_COMPLETED as FIRST_COMPLETED, @@ -48,7 +46,7 @@ from asyncio.tasks import ( ALL_COMPLETED as ALL_COMPLETED, as_completed as as_completed, ensure_future as ensure_future, - ensure_future as async, + async as async, gather as gather, run_coroutine_threadsafe as run_coroutine_threadsafe, shield as shield, @@ -62,6 +60,7 @@ from asyncio.events import ( AbstractEventLoop as AbstractEventLoop, AbstractServer as AbstractServer, Handle as Handle, + TimerHandle as TimerHandle, get_event_loop_policy as get_event_loop_policy, set_event_loop_policy as set_event_loop_policy, get_event_loop as get_event_loop, @@ -87,6 +86,12 @@ from asyncio.locks import ( if sys.version_info < (3, 5): from asyncio.queues import JoinableQueue as JoinableQueue +else: + from asyncio.futures import isfuture as isfuture + from asyncio.events import ( + _set_running_loop as _set_running_loop, + _get_running_loop as _get_running_loop, + ) if sys.platform != 'win32': from asyncio.streams import ( open_unix_connection as open_unix_connection, @@ -103,4 +108,4 @@ DefaultEventLoopPolicy = ... # type: Type[AbstractEventLoopPolicy] # TODO: AbstractChildWatcher (UNIX only) -__all__ = ... # type: str +__all__: List[str] diff --git a/python/helpers/typeshed/stdlib/3.4/asyncio/coroutines.pyi b/python/helpers/typeshed/stdlib/3.4/asyncio/coroutines.pyi index 9072dd7f8544..981ccd5a0018 100644 --- a/python/helpers/typeshed/stdlib/3.4/asyncio/coroutines.pyi +++ b/python/helpers/typeshed/stdlib/3.4/asyncio/coroutines.pyi @@ -1,6 +1,6 @@ -from typing import Any, Callable, Generator, TypeVar +from typing import Any, Callable, Generator, List, TypeVar -__all__ = ... # type: str +__all__: List[str] _F = TypeVar('_F', bound=Callable[..., Any]) diff --git a/python/helpers/typeshed/stdlib/3.4/asyncio/events.pyi b/python/helpers/typeshed/stdlib/3.4/asyncio/events.pyi index e20a0231848e..6a444ab2aff0 100644 --- a/python/helpers/typeshed/stdlib/3.4/asyncio/events.pyi +++ b/python/helpers/typeshed/stdlib/3.4/asyncio/events.pyi @@ -1,3 +1,4 @@ +import selectors from socket import socket import ssl import sys @@ -9,7 +10,7 @@ from asyncio.protocols import BaseProtocol from asyncio.tasks import Task from asyncio.transports import BaseTransport -__all__ = ... # type: str +__all__: List[str] _T = TypeVar('_T') _Context = Dict[str, Any] @@ -18,11 +19,6 @@ _ProtocolFactory = Callable[[], BaseProtocol] _SSLContext = Union[bool, None, ssl.SSLContext] _TransProtPair = Tuple[BaseTransport, BaseProtocol] -PIPE = ... # type: Any # from subprocess.PIPE - -AF_UNSPEC = 0 # from socket -AI_PASSIVE = 0 - class Handle: _cancelled = False _args = ... # type: List[Any] @@ -32,6 +28,11 @@ class Handle: def cancel(self) -> None: ... def _run(self) -> None: ... +class TimerHandle(Handle): + def __init__(self, when: float, callback: Callable[..., Any], args: List[Any], + loop: AbstractEventLoop) -> None: ... + def __hash__(self) -> int: ... + class AbstractServer: def close(self) -> None: ... @coroutine @@ -76,7 +77,7 @@ class AbstractEventLoop(metaclass=ABCMeta): def create_future(self) -> Future[Any]: ... # Tasks methods @abstractmethod - def create_task(self, coro: Union[Future[_T], Generator[Any, None, _T]]) -> Task[_T]: ... + def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]]) -> Task[_T]: ... @abstractmethod def set_task_factory(self, factory: Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]) -> None: ... @abstractmethod @@ -124,7 +125,7 @@ class AbstractEventLoop(metaclass=ABCMeta): @abstractmethod @coroutine def create_datagram_endpoint(self, protocol_factory: _ProtocolFactory, - local_addr: str = ..., remote_addr: str = ..., *, + local_addr: Optional[Tuple[str, int]] = ..., remote_addr: Optional[Tuple[str, int]] = ..., *, family: int = ..., proto: int = ..., flags: int = ..., reuse_address: Optional[bool] = ..., reuse_port: Optional[bool] = ..., allow_broadcast: Optional[bool] = ..., @@ -146,17 +147,17 @@ class AbstractEventLoop(metaclass=ABCMeta): **kwargs: Any) -> Generator[Any, None, _TransProtPair]: ... @abstractmethod @coroutine - def subprocess_exec(self, protocol_factory: _ProtocolFactory, *args: List[Any], stdin: Any = ..., + def subprocess_exec(self, protocol_factory: _ProtocolFactory, *args: Any, stdin: Any = ..., stdout: Any = ..., stderr: Any = ..., **kwargs: Any) -> Generator[Any, None, _TransProtPair]: ... @abstractmethod - def add_reader(self, fd: int, callback: Callable[..., Any], *args: List[Any]) -> None: ... + def add_reader(self, fd: selectors._FileObject, callback: Callable[..., Any], *args: Any) -> None: ... @abstractmethod - def remove_reader(self, fd: int) -> None: ... + def remove_reader(self, fd: selectors._FileObject) -> None: ... @abstractmethod - def add_writer(self, fd: int, callback: Callable[..., Any], *args: List[Any]) -> None: ... + def add_writer(self, fd: selectors._FileObject, callback: Callable[..., Any], *args: Any) -> None: ... @abstractmethod - def remove_writer(self, fd: int) -> None: ... + def remove_writer(self, fd: selectors._FileObject) -> None: ... # Completion based I/O methods returning Futures. @abstractmethod @coroutine @@ -172,7 +173,7 @@ class AbstractEventLoop(metaclass=ABCMeta): def sock_accept(self, sock: socket) -> Generator[Any, None, Tuple[socket, 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: Any) -> None: ... @abstractmethod def remove_signal_handler(self, sig: int) -> None: ... # Error handlers. @@ -194,7 +195,7 @@ class AbstractEventLoopPolicy(metaclass=ABCMeta): @abstractmethod def get_event_loop(self) -> AbstractEventLoop: ... @abstractmethod - def set_event_loop(self, loop: AbstractEventLoop): ... + def set_event_loop(self, loop: AbstractEventLoop) -> None: ... @abstractmethod def new_event_loop(self) -> AbstractEventLoop: ... # Child processes handling (Unix only). @@ -206,7 +207,7 @@ class AbstractEventLoopPolicy(metaclass=ABCMeta): class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy): def __init__(self) -> None: ... def get_event_loop(self) -> AbstractEventLoop: ... - def set_event_loop(self, loop: AbstractEventLoop): ... + def set_event_loop(self, loop: AbstractEventLoop) -> None: ... def new_event_loop(self) -> AbstractEventLoop: ... def get_event_loop_policy() -> AbstractEventLoopPolicy: ... @@ -218,3 +219,6 @@ def new_event_loop() -> AbstractEventLoop: ... def get_child_watcher() -> Any: ... # TODO: unix_events.AbstractChildWatcher def set_child_watcher(watcher: Any) -> None: ... # TODO: unix_events.AbstractChildWatcher + +def _set_running_loop(loop: AbstractEventLoop) -> None: ... +def _get_running_loop() -> AbstractEventLoop: ... diff --git a/python/helpers/typeshed/stdlib/3.4/asyncio/futures.pyi b/python/helpers/typeshed/stdlib/3.4/asyncio/futures.pyi index b88009324630..00086f45a786 100644 --- a/python/helpers/typeshed/stdlib/3.4/asyncio/futures.pyi +++ b/python/helpers/typeshed/stdlib/3.4/asyncio/futures.pyi @@ -1,14 +1,14 @@ +import sys from typing import Any, Union, Callable, TypeVar, List, Generic, Iterable, Generator, Awaitable from .events import AbstractEventLoop -from concurrent.futures._base import ( - Error as Error, -) from concurrent.futures import ( CancelledError as CancelledError, TimeoutError as TimeoutError, + Future as _ConcurrentFuture, + Error, ) -__all__ = ... # type: str +__all__: List[str] _T = TypeVar('_T') @@ -22,6 +22,9 @@ class _TracebackLogger: def clear(self) -> None: ... def __del__(self) -> None: ... +if sys.version_info >= (3, 5): + def isfuture(obj: object) -> bool: ... + class Future(Iterable[_T], Awaitable[_T], Generic[_T]): _state = ... # type: str _exception = ... # type: BaseException @@ -44,3 +47,5 @@ class Future(Iterable[_T], Awaitable[_T], Generic[_T]): def _copy_state(self, other: Any) -> None: ... def __iter__(self) -> Generator[Any, None, _T]: ... def __await__(self) -> Generator[Any, None, _T]: ... + +def wrap_future(f: Union[_ConcurrentFuture[_T], Future[_T]]) -> Future[_T]: ... diff --git a/python/helpers/typeshed/stdlib/3.4/asyncio/locks.pyi b/python/helpers/typeshed/stdlib/3.4/asyncio/locks.pyi index 559effd980d9..837c50c2d425 100644 --- a/python/helpers/typeshed/stdlib/3.4/asyncio/locks.pyi +++ b/python/helpers/typeshed/stdlib/3.4/asyncio/locks.pyi @@ -1,12 +1,13 @@ -from typing import Any, Callable, Generator, Iterable, Iterator, TypeVar, Union, Optional +from typing import Any, Callable, Generator, Iterable, Iterator, List, Type, TypeVar, Union, Optional, Awaitable from .coroutines import coroutine from .events import AbstractEventLoop from .futures import Future +from types import TracebackType _T = TypeVar('_T') -__all__ = ... # type: str +__all__: List[str] class _ContextManager: def __init__(self, lock: Union[Lock, Semaphore]) -> None: ... @@ -17,18 +18,18 @@ class _ContextManagerMixin(Future[_ContextManager]): # Apparently this exists to *prohibit* use as a context manager. def __enter__(self) -> object: ... def __exit__(self, *args: Any) -> None: ... - def __aenter__(self): ... - def __aexit__(self, exc_type, exc, tb): ... + def __aenter__(self) -> Awaitable[None]: ... + def __aexit__(self, exc_type: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType]) -> Awaitable[None]: ... class Lock(_ContextManagerMixin): - def __init__(self, *, loop: AbstractEventLoop = None) -> None: ... + def __init__(self, *, loop: Optional[AbstractEventLoop] = ...) -> None: ... def locked(self) -> bool: ... @coroutine def acquire(self) -> Generator[Any, None, bool]: ... def release(self) -> None: ... class Event: - def __init__(self, *, loop: AbstractEventLoop = None) -> None: ... + def __init__(self, *, loop: Optional[AbstractEventLoop] = ...) -> None: ... def is_set(self) -> bool: ... def set(self) -> None: ... def clear(self) -> None: ... @@ -36,7 +37,7 @@ class Event: def wait(self) -> Generator[Any, None, bool]: ... class Condition(_ContextManagerMixin): - def __init__(self, lock: Lock = None, *, loop: AbstractEventLoop = None) -> None: ... + def __init__(self, lock: Optional[Lock] = None, *, loop: Optional[AbstractEventLoop] = ...) -> None: ... def locked(self) -> bool: ... @coroutine def acquire(self) -> Generator[Any, None, bool]: ... diff --git a/python/helpers/typeshed/stdlib/3.4/asyncio/protocols.pyi b/python/helpers/typeshed/stdlib/3.4/asyncio/protocols.pyi index 91b7d94dd806..118659ce2451 100644 --- a/python/helpers/typeshed/stdlib/3.4/asyncio/protocols.pyi +++ b/python/helpers/typeshed/stdlib/3.4/asyncio/protocols.pyi @@ -1,7 +1,7 @@ from asyncio import transports -from typing import AnyStr +from typing import AnyStr, List -__all__ = ... # type: str +__all__: List[str] class BaseProtocol: diff --git a/python/helpers/typeshed/stdlib/3.4/asyncio/queues.pyi b/python/helpers/typeshed/stdlib/3.4/asyncio/queues.pyi index 847f02b7c9c2..38baf669bc9a 100644 --- a/python/helpers/typeshed/stdlib/3.4/asyncio/queues.pyi +++ b/python/helpers/typeshed/stdlib/3.4/asyncio/queues.pyi @@ -2,9 +2,9 @@ import sys from asyncio.events import AbstractEventLoop from .coroutines import coroutine from .futures import Future -from typing import Any, Generator, Generic, TypeVar +from typing import Any, Generator, Generic, List, TypeVar -__all__ = ... # type: str +__all__: List[str] class QueueEmpty(Exception): ... diff --git a/python/helpers/typeshed/stdlib/3.4/asyncio/streams.pyi b/python/helpers/typeshed/stdlib/3.4/asyncio/streams.pyi index fd677ab75a8b..922552b8c142 100644 --- a/python/helpers/typeshed/stdlib/3.4/asyncio/streams.pyi +++ b/python/helpers/typeshed/stdlib/3.4/asyncio/streams.pyi @@ -1,20 +1,23 @@ import sys -from typing import Any, Awaitable, Callable, Generator, Iterable, Optional, Tuple +from typing import Any, Awaitable, Callable, Generator, Iterable, List, Optional, Tuple from . import coroutines from . import events from . import protocols from . import transports -ClientConnectedCallback = Callable[[StreamReader, StreamWriter], Optional[Awaitable[None]]] +_ClientConnectedCallback = Callable[[StreamReader, StreamWriter], Optional[Awaitable[None]]] -__all__ = ... # type: str +__all__: List[str] class IncompleteReadError(EOFError): - def __init__(self, partial: str, expected: int) -> None: ... + expected = ... # type: Optional[int] + partial = ... # type: bytes + def __init__(self, partial: bytes, expected: Optional[int]) -> None: ... class LimitOverrunError(Exception): + consumed = ... # type: int def __init__(self, message: str, consumed: int) -> None: ... @coroutines.coroutine @@ -22,18 +25,18 @@ def open_connection( host: str = ..., port: int = ..., *, - loop: events.AbstractEventLoop = ..., + loop: Optional[events.AbstractEventLoop] = ..., limit: int = ..., **kwds: Any ) -> Generator[Any, None, Tuple[StreamReader, StreamWriter]]: ... @coroutines.coroutine def start_server( - client_connected_cb: ClientConnectedCallback, + client_connected_cb: _ClientConnectedCallback, host: str = ..., port: int = ..., *, - loop: events.AbstractEventLoop = ..., + loop: Optional[events.AbstractEventLoop] = ..., limit: int = ..., **kwds: Any ) -> Generator[Any, None, events.AbstractServer]: ... @@ -43,14 +46,14 @@ if sys.platform != 'win32': def open_unix_connection( path: str = ..., *, - loop: events.AbstractEventLoop = ..., + loop: Optional[events.AbstractEventLoop] = ..., limit: int = ..., **kwds: Any ) -> Generator[Any, None, Tuple[StreamReader, StreamWriter]]: ... @coroutines.coroutine def start_unix_server( - client_connected_cb: ClientConnectedCallback, + client_connected_cb: _ClientConnectedCallback, path: str = ..., *, loop: int = ..., @@ -62,8 +65,8 @@ class FlowControlMixin(protocols.Protocol): ... class StreamReaderProtocol(FlowControlMixin, protocols.Protocol): def __init__(self, stream_reader: StreamReader, - client_connected_cb: ClientConnectedCallback = ..., - loop: events.AbstractEventLoop = ...) -> None: ... + client_connected_cb: _ClientConnectedCallback = ..., + loop: Optional[events.AbstractEventLoop] = ...) -> None: ... def connection_made(self, transport: transports.BaseTransport) -> None: ... def connection_lost(self, exc: Exception) -> None: ... def data_received(self, data: bytes) -> None: ... @@ -89,18 +92,18 @@ class StreamWriter: class StreamReader: def __init__(self, limit: int = ..., - loop: events.AbstractEventLoop = ...) -> None: ... + loop: Optional[events.AbstractEventLoop] = ...) -> None: ... def exception(self) -> Exception: ... def set_exception(self, exc: Exception) -> None: ... def set_transport(self, transport: transports.BaseTransport) -> None: ... def feed_eof(self) -> None: ... def at_eof(self) -> bool: ... - def feed_data(self, data: bytes): ... + def feed_data(self, data: bytes) -> None: ... @coroutines.coroutine def readline(self) -> Generator[Any, None, bytes]: ... @coroutines.coroutine - def readuntil(self, separator=b'\n') -> Generator[Any, None, bytes]: ... + def readuntil(self, separator: bytes = ...) -> Generator[Any, None, bytes]: ... @coroutines.coroutine - def read(self, n=-1) -> Generator[Any, None, bytes]: ... + def read(self, n: int = ...) -> Generator[Any, None, bytes]: ... @coroutines.coroutine - def readexactly(self, n) -> Generator[Any, None, bytes]: ... + def readexactly(self, n: int) -> Generator[Any, None, bytes]: ... diff --git a/python/helpers/typeshed/stdlib/3.4/asyncio/subprocess.pyi b/python/helpers/typeshed/stdlib/3.4/asyncio/subprocess.pyi index 21a33a3ab60b..78feb8e20fb2 100644 --- a/python/helpers/typeshed/stdlib/3.4/asyncio/subprocess.pyi +++ b/python/helpers/typeshed/stdlib/3.4/asyncio/subprocess.pyi @@ -3,9 +3,9 @@ from asyncio import protocols from asyncio import streams from asyncio import transports from asyncio.coroutines import coroutine -from typing import Any, AnyStr, Generator, Optional, Tuple, Union +from typing import Any, AnyStr, Generator, List, Optional, Tuple, Union, IO -__all__ = ... # type: str +__all__: List[str] PIPE = ... # type: int STDOUT = ... # type: int @@ -13,14 +13,21 @@ DEVNULL = ... # type: int class SubprocessStreamProtocol(streams.FlowControlMixin, protocols.SubprocessProtocol): + stdin = ... # type: Optional[streams.StreamWriter] + stdout = ... # type: Optional[streams.StreamReader] + stderr = ... # type: Optional[streams.StreamReader] def __init__(self, limit: int, loop: events.AbstractEventLoop) -> None: ... def connection_made(self, transport: transports.BaseTransport) -> None: ... def pipe_data_received(self, fd: int, data: AnyStr) -> None: ... - def pipe_connection_lost(self, fd: int, exc: Exception): ... + def pipe_connection_lost(self, fd: int, exc: Exception) -> None: ... def process_exited(self) -> None: ... class Process: + stdin = ... # type: Optional[streams.StreamWriter] + stdout = ... # type: Optional[streams.StreamReader] + stderr = ... # type: Optional[streams.StreamReader] + pid = ... # type: int def __init__(self, transport: transports.BaseTransport, protocol: protocols.BaseProtocol, @@ -39,9 +46,9 @@ class Process: @coroutine def create_subprocess_shell( *Args: Union[str, bytes], # Union used instead of AnyStr due to mypy issue #1236 - stdin: int = ..., - stdout: int = ..., - stderr: int = ..., + stdin: Union[int, IO[Any], None] = ..., + stdout: Union[int, IO[Any], None] = ..., + stderr: Union[int, IO[Any], None] = ..., loop: events.AbstractEventLoop = ..., limit: int = ..., **kwds: Any @@ -51,9 +58,9 @@ def create_subprocess_shell( def create_subprocess_exec( program: Union[str, bytes], # Union used instead of AnyStr due to mypy issue #1236 *args: Any, - stdin: int = ..., - stdout: int = ..., - stderr: int = ..., + stdin: Union[int, IO[Any], None] = ..., + stdout: Union[int, IO[Any], None] = ..., + stderr: Union[int, IO[Any], None] = ..., loop: events.AbstractEventLoop = ..., limit: int = ..., **kwds: Any diff --git a/python/helpers/typeshed/stdlib/3.4/asyncio/tasks.pyi b/python/helpers/typeshed/stdlib/3.4/asyncio/tasks.pyi index bf69df8ea57e..65213e691f27 100644 --- a/python/helpers/typeshed/stdlib/3.4/asyncio/tasks.pyi +++ b/python/helpers/typeshed/stdlib/3.4/asyncio/tasks.pyi @@ -5,9 +5,14 @@ import concurrent.futures from .events import AbstractEventLoop from .futures import Future -__all__ = ... # type: str +__all__: List[str] _T = TypeVar('_T') +_T1 = TypeVar('_T1') +_T2 = TypeVar('_T2') +_T3 = TypeVar('_T3') +_T4 = TypeVar('_T4') +_T5 = TypeVar('_T5') _FutureT = Union[Future[_T], Generator[Any, None, _T], Awaitable[_T]] FIRST_EXCEPTION = 'FIRST_EXCEPTION' @@ -18,10 +23,26 @@ def as_completed(fs: Sequence[_FutureT[_T]], *, loop: AbstractEventLoop = ..., timeout: Optional[float] = ...) -> Iterator[Generator[Any, None, _T]]: ... def ensure_future(coro_or_future: _FutureT[_T], *, loop: AbstractEventLoop = ...) -> Future[_T]: ... -# TODO: gather() should use variadic type vars instead of _TAny. -_TAny = Any -def gather(*coros_or_futures: _FutureT[_TAny], - loop: AbstractEventLoop = ..., return_exceptions: bool = False) -> Future[List[_TAny]]: ... +async = ensure_future +@overload +def gather(coro_or_future1: _FutureT[_T1], + *, loop: AbstractEventLoop = ..., return_exceptions: bool = False) -> Future[Tuple[_T1]]: ... +@overload +def gather(coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], + *, loop: AbstractEventLoop = ..., return_exceptions: bool = False) -> Future[Tuple[_T1, _T2]]: ... +@overload +def gather(coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], coro_or_future3: _FutureT[_T3], + coro_or_future4: _FutureT[_T4], + *, loop: AbstractEventLoop = ..., return_exceptions: bool = False) -> Future[Tuple[_T1, _T2, _T3, _T4]]: ... +@overload +def gather(coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], coro_or_future3: _FutureT[_T3], + coro_or_future4: _FutureT[_T4], coro_or_future5: _FutureT[_T5], + *, loop: AbstractEventLoop = ..., return_exceptions: bool = False) -> Future[Tuple[_T1, _T2, _T3, _T4, _T5]]: ... +@overload +def gather(coro_or_future1: _FutureT[Any], coro_or_future2: _FutureT[Any], coro_or_future3: _FutureT[Any], + coro_or_future4: _FutureT[Any], coro_or_future5: _FutureT[Any], coro_or_future6: _FutureT[Any], + *coros_or_futures: _FutureT[Any], + loop: AbstractEventLoop = ..., return_exceptions: bool = False) -> Future[Tuple[Any, ...]]: ... def run_coroutine_threadsafe(coro: _FutureT[_T], loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ... def shield(arg: _FutureT[_T], *, loop: AbstractEventLoop = ...) -> Future[_T]: ... diff --git a/python/helpers/typeshed/stdlib/3.4/asyncio/transports.pyi b/python/helpers/typeshed/stdlib/3.4/asyncio/transports.pyi index 87320a1a39a1..9ea6688d7593 100644 --- a/python/helpers/typeshed/stdlib/3.4/asyncio/transports.pyi +++ b/python/helpers/typeshed/stdlib/3.4/asyncio/transports.pyi @@ -1,6 +1,6 @@ -from typing import Dict, Any, TypeVar, Mapping, List +from typing import Dict, Any, TypeVar, Mapping, List, Optional, Tuple -__all__ = ... # type: str +__all__: List[str] class BaseTransport: def __init__(self, extra: Mapping[Any, Any] = ...) -> None: ... @@ -18,7 +18,7 @@ class WriteTransport(BaseTransport): ) -> None: ... def get_write_buffer_size(self) -> int: ... def write(self, data: Any) -> None: ... - def writelines(self, list_of_data: List[Any]): ... + def writelines(self, list_of_data: List[Any]) -> None: ... def write_eof(self) -> None: ... def can_write_eof(self) -> bool: ... def abort(self) -> None: ... @@ -26,7 +26,7 @@ class WriteTransport(BaseTransport): class Transport(ReadTransport, WriteTransport): ... class DatagramTransport(BaseTransport): - def sendto(self, data: Any, addr: str = ...) -> None: ... + def sendto(self, data: Any, addr: Optional[Tuple[str, int]] = ...) -> None: ... def abort(self) -> None: ... class SubprocessTransport(BaseTransport): diff --git a/python/helpers/typeshed/stdlib/3.4/enum.pyi b/python/helpers/typeshed/stdlib/3.4/enum.pyi index 5eb09b2b4019..1501be27450e 100644 --- a/python/helpers/typeshed/stdlib/3.4/enum.pyi +++ b/python/helpers/typeshed/stdlib/3.4/enum.pyi @@ -1,12 +1,24 @@ -# FIXME: Stub incomplete, ommissions include: -# * the metaclass -# * _sunder_ methods with their transformations - import sys -from typing import List, Any, TypeVar, Union +from typing import List, Any, TypeVar, Union, Iterable, Iterator, TypeVar, Generic, Type, Sized, Reversible, Container, Mapping +from abc import ABCMeta -class Enum: - def __new__(cls, value: Any) -> None: ... +_T = TypeVar('_T', bound=Enum) +_S = TypeVar('_S', bound=Type[Enum]) + +# Note: EnumMeta actually subclasses type directly, not ABCMeta. +# This is a temporary workaround to allow multiple creation of enums with builtins +# such as str as mixins, which due to the handling of ABCs of builtin types, cause +# spurious inconsistent metaclass structure. See #1595. +class EnumMeta(ABCMeta, Iterable[Enum], Sized, Reversible[Enum], Container[Enum]): + def __iter__(self: Type[_T]) -> Iterator[_T]: ... + def __reversed__(self: Type[_T]) -> Iterator[_T]: ... + def __contains__(self, member: Any) -> bool: ... + def __getitem__(self: Type[_T], name: str) -> _T: ... + @property + def __members__(self: Type[_T]) -> Mapping[str, _T]: ... + +class Enum(metaclass=EnumMeta): + def __new__(cls: Type[_T], value: Any) -> _T: ... def __repr__(self) -> str: ... def __str__(self) -> str: ... def __dir__(self) -> List[str]: ... @@ -17,20 +29,16 @@ class Enum: name = ... # type: str value = ... # type: Any -_T1 = TypeVar('_T1') - -class IntEnum(int, Enum): # type: ignore +class IntEnum(int, Enum): value = ... # type: int - def __new__(cls: Type[_T1], value: Any) -> _T1: ... -_T = TypeVar('_T') - -def unique(enumeration: _T) -> _T: ... +def unique(enumeration: _S) -> _S: ... if sys.version_info >= (3, 6): _auto_null = ... # type: Any - class auto: + # subclassing IntFlag so it picks up all implemented base functions, best modeling behavior of enum.auto() + class auto(IntFlag): value = ... # type: Any class Flag(Enum): @@ -43,11 +51,12 @@ if sys.version_info >= (3, 6): def __xor__(self: _T, other: _T) -> _T: ... def __invert__(self: _T) -> _T: ... - # All `type: ignore` comments below due to IntFlag making the function signatures more permissive. + # The `type: ignore` comment is needed because mypy considers the type + # signatures of several methods defined in int and Flag to be incompatible. class IntFlag(int, Flag): # type: ignore - def __or__(self: _T, other: Union[int, _T]) -> _T: ... # type: ignore - def __and__(self: _T, other: Union[int, _T]) -> _T: ... # type: ignore - def __xor__(self: _T, other: Union[int, _T]) -> _T: ... # type: ignore + def __or__(self: _T, other: Union[int, _T]) -> _T: ... + def __and__(self: _T, other: Union[int, _T]) -> _T: ... + def __xor__(self: _T, other: Union[int, _T]) -> _T: ... __ror__ = __or__ __rand__ = __and__ __rxor__ = __xor__ diff --git a/python/helpers/typeshed/stdlib/3.4/selectors.pyi b/python/helpers/typeshed/stdlib/3.4/selectors.pyi index 832212b37a66..547ae02182a6 100644 --- a/python/helpers/typeshed/stdlib/3.4/selectors.pyi +++ b/python/helpers/typeshed/stdlib/3.4/selectors.pyi @@ -9,82 +9,82 @@ import socket # Type aliases added mainly to preserve some context # # See https://github.com/python/typeshed/issues/482 -# for details regarding how FileObject is typed. -FileObject = Union[int, socket.socket] -FileDescriptor = int -EventMask = int +# for details regarding how _FileObject is typed. +_FileObject = Union[int, socket.socket] +_FileDescriptor = int +_EventMask = int -EVENT_READ = ... # type: EventMask -EVENT_WRITE = ... # type: EventMask +EVENT_READ = ... # type: _EventMask +EVENT_WRITE = ... # type: _EventMask SelectorKey = NamedTuple('SelectorKey', [ - ('fileobj', FileObject), - ('fd', FileDescriptor), - ('events', EventMask), + ('fileobj', _FileObject), + ('fd', _FileDescriptor), + ('events', _EventMask), ('data', Any) ]) class BaseSelector(metaclass=ABCMeta): @abstractmethod - def register(self, fileobj: FileObject, events: EventMask, data: Any = None) -> SelectorKey: ... + def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ... @abstractmethod - def unregister(self, fileobj: FileObject) -> SelectorKey: ... + def unregister(self, fileobj: _FileObject) -> SelectorKey: ... - def modify(self, fileobj: FileObject, events: EventMask, data: Any = None) -> SelectorKey: ... + def modify(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ... @abstractmethod - def select(self, timeout: Optional[int] = None) -> List[Tuple[SelectorKey, EventMask]]: ... + def select(self, timeout: Optional[int] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... def close(self) -> None: ... - def get_key(self, fileobj: FileObject) -> SelectorKey: ... + def get_key(self, fileobj: _FileObject) -> SelectorKey: ... @abstractmethod - def get_map(self) -> Mapping[FileObject, SelectorKey]: ... + def get_map(self) -> Mapping[_FileObject, SelectorKey]: ... def __enter__(self) -> BaseSelector: ... def __exit__(self, *args: Any) -> None: ... class SelectSelector(BaseSelector): - def register(self, fileobj: FileObject, events: EventMask, data: Any = None) -> SelectorKey: ... - def unregister(self, fileobj: FileObject) -> SelectorKey: ... - def select(self, timeout: Optional[int] = None) -> List[Tuple[SelectorKey, EventMask]]: ... - def get_map(self) -> Mapping[FileObject, SelectorKey]: ... + def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ... + def unregister(self, fileobj: _FileObject) -> SelectorKey: ... + def select(self, timeout: Optional[int] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... + def get_map(self) -> Mapping[_FileObject, SelectorKey]: ... class PollSelector(BaseSelector): - def register(self, fileobj: FileObject, events: EventMask, data: Any = None) -> SelectorKey: ... - def unregister(self, fileobj: FileObject) -> SelectorKey: ... - def select(self, timeout: Optional[int] = None) -> List[Tuple[SelectorKey, EventMask]]: ... - def get_map(self) -> Mapping[FileObject, SelectorKey]: ... + def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ... + def unregister(self, fileobj: _FileObject) -> SelectorKey: ... + def select(self, timeout: Optional[int] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... + def get_map(self) -> Mapping[_FileObject, SelectorKey]: ... class EpollSelector(BaseSelector): def fileno(self) -> int: ... - def register(self, fileobj: FileObject, events: EventMask, data: Any = None) -> SelectorKey: ... - def unregister(self, fileobj: FileObject) -> SelectorKey: ... - def select(self, timeout: Optional[int] = None) -> List[Tuple[SelectorKey, EventMask]]: ... - def get_map(self) -> Mapping[FileObject, SelectorKey]: ... + def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ... + def unregister(self, fileobj: _FileObject) -> SelectorKey: ... + def select(self, timeout: Optional[int] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... + def get_map(self) -> Mapping[_FileObject, SelectorKey]: ... class DevpollSelector(BaseSelector): def fileno(self) -> int: ... - def register(self, fileobj: FileObject, events: EventMask, data: Any = None) -> SelectorKey: ... - def unregister(self, fileobj: FileObject) -> SelectorKey: ... - def select(self, timeout: Optional[int] = None) -> List[Tuple[SelectorKey, EventMask]]: ... - def get_map(self) -> Mapping[FileObject, SelectorKey]: ... + def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ... + def unregister(self, fileobj: _FileObject) -> SelectorKey: ... + def select(self, timeout: Optional[int] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... + def get_map(self) -> Mapping[_FileObject, SelectorKey]: ... class KqueueSelector(BaseSelector): def fileno(self) -> int: ... - def register(self, fileobj: FileObject, events: EventMask, data: Any = None) -> SelectorKey: ... - def unregister(self, fileobj: FileObject) -> SelectorKey: ... - def select(self, timeout: Optional[int] = None) -> List[Tuple[SelectorKey, EventMask]]: ... - def get_map(self) -> Mapping[FileObject, SelectorKey]: ... + def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ... + def unregister(self, fileobj: _FileObject) -> SelectorKey: ... + def select(self, timeout: Optional[int] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... + def get_map(self) -> Mapping[_FileObject, SelectorKey]: ... class DefaultSelector(BaseSelector): - def register(self, fileobj: FileObject, events: EventMask, data: Any = None) -> SelectorKey: ... - def unregister(self, fileobj: FileObject) -> SelectorKey: ... - def select(self, timeout: Optional[int] = None) -> List[Tuple[SelectorKey, EventMask]]: ... - def get_map(self) -> Mapping[FileObject, SelectorKey]: ... + def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ... + def unregister(self, fileobj: _FileObject) -> SelectorKey: ... + def select(self, timeout: Optional[int] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ... + def get_map(self) -> Mapping[_FileObject, SelectorKey]: ... diff --git a/python/helpers/typeshed/stdlib/3/_ast.pyi b/python/helpers/typeshed/stdlib/3/_ast.pyi index 67361810e157..ca75bcac5b35 100644 --- a/python/helpers/typeshed/stdlib/3/_ast.pyi +++ b/python/helpers/typeshed/stdlib/3/_ast.pyi @@ -4,7 +4,7 @@ from typing import Any, Optional, Union PyCF_ONLY_AST = ... # type: int -identifier = str +_identifier = str class AST: _attributes = ... # type: typing.Tuple[str, ...] @@ -32,21 +32,21 @@ class stmt(AST): col_offset = ... # type: int class FunctionDef(stmt): - name = ... # type: identifier + name = ... # type: _identifier args = ... # type: arguments body = ... # type: typing.List[stmt] decorator_list = ... # type: typing.List[expr] returns = ... # type: Optional[expr] class AsyncFunctionDef(stmt): - name = ... # type: identifier + name = ... # type: _identifier args = ... # type: arguments body = ... # type: typing.List[stmt] decorator_list = ... # type: typing.List[expr] returns = ... # type: Optional[expr] class ClassDef(stmt): - name = ... # type: identifier + name = ... # type: _identifier bases = ... # type: typing.List[expr] keywords = ... # type: typing.List[keyword] body = ... # type: typing.List[stmt] @@ -115,15 +115,15 @@ class Import(stmt): names = ... # type: typing.List[alias] class ImportFrom(stmt): - module = ... # type: Optional[identifier] + module = ... # type: Optional[_identifier] names = ... # type: typing.List[alias] level = ... # type: Optional[int] class Global(stmt): - names = ... # type: typing.List[identifier] + names = ... # type: typing.List[_identifier] class Nonlocal(stmt): - names = ... # type: typing.List[identifier] + names = ... # type: typing.List[_identifier] class Expr(stmt): value = ... # type: expr @@ -235,7 +235,7 @@ class Ellipsis(expr): ... class Attribute(expr): value = ... # type: expr - attr = ... # type: identifier + attr = ... # type: _identifier ctx = ... # type: expr_context class Subscript(expr): @@ -248,7 +248,7 @@ class Starred(expr): ctx = ... # type: expr_context class Name(expr): - id = ... # type: identifier + id = ... # type: _identifier ctx = ... # type: expr_context class List(expr): @@ -325,7 +325,7 @@ class comprehension(AST): class ExceptHandler(AST): type = ... # type: Optional[expr] - name = ... # type: Optional[identifier] + name = ... # type: Optional[_identifier] body = ... # type: typing.List[stmt] lineno = ... # type: int col_offset = ... # type: int @@ -340,18 +340,18 @@ class arguments(AST): defaults = ... # type: typing.List[expr] class arg(AST): - arg = ... # type: identifier + arg = ... # type: _identifier annotation = ... # type: Optional[expr] lineno = ... # type: int col_offset = ... # type: int class keyword(AST): - arg = ... # type: Optional[identifier] + arg = ... # type: Optional[_identifier] value = ... # type: expr class alias(AST): - name = ... # type: identifier - asname = ... # type: Optional[identifier] + name = ... # type: _identifier + asname = ... # type: Optional[_identifier] class withitem(AST): context_expr = ... # type: expr diff --git a/python/helpers/typeshed/stdlib/3/_compression.pyi b/python/helpers/typeshed/stdlib/3/_compression.pyi index 527d7952c403..d84a11a51039 100644 --- a/python/helpers/typeshed/stdlib/3/_compression.pyi +++ b/python/helpers/typeshed/stdlib/3/_compression.pyi @@ -1,7 +1,3 @@ -# Stubs for _compression (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any import io diff --git a/python/helpers/typeshed/stdlib/3/_curses.pyi b/python/helpers/typeshed/stdlib/3/_curses.pyi index 368dda2080f3..a6afa7bc771b 100644 --- a/python/helpers/typeshed/stdlib/3/_curses.pyi +++ b/python/helpers/typeshed/stdlib/3/_curses.pyi @@ -1,10 +1,6 @@ -# Stubs for _curses (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. +from typing import Any, BinaryIO, IO, Optional, Tuple, Union, overload -from typing import Any, BinaryIO, Tuple, Union - -chtype = Union[str, bytes, int] +_chtype = Union[str, bytes, int] ALL_MOUSE_EVENTS = ... # type: int A_ALTCHARSET = ... # type: int @@ -246,7 +242,7 @@ def has_il() -> bool: ... def has_key(ch: int) -> bool: ... def init_color(color_number: int, r: int, g: int, b: int) -> None: ... def init_pair(pair_number: int, fg: int, bg: int) -> None: ... -def initscr(): ... +def initscr() -> _CursesWindow: ... def intrflush(ch: bool) -> None: ... def is_term_resized(nlines: int, ncols: int) -> bool: ... def isendwin() -> bool: ... @@ -258,7 +254,7 @@ def mouseinterval(interval: int) -> None: ... def mousemask(mousemask: int) -> Tuple[int, int]: ... def napms(ms: int) -> int: ... def newpad(nlines: int, ncols: int): ... -def newwin(nlines: int, ncols: int, begin_y: int = ..., begin_x: int = ...): ... +def newwin(nlines: int, ncols: int, begin_y: int = ..., begin_x: int = ...) -> _CursesWindow: ... def nl(flag: bool = ...) -> None: ... def nocbreak() -> None: ... def noecho() -> None: ... @@ -286,12 +282,237 @@ def tigetnum(capname: str) -> int: ... def tigetstr(capname: str) -> bytes: ... def tparm(fmt: str, i1: int = ..., i2: int = ..., i3: int = ..., i4: int = ..., i5: int = ..., i6: int = ..., i7: int = ..., i8: int = ..., i9: int = ...) -> str: ... def typeahead(fd: int) -> None: ... -def unctrl(ch: chtype) -> bytes: ... -def unget_wch(ch: chtype) -> None: ... -def ungetch(ch: chtype) -> None: ... +def unctrl(ch: _chtype) -> bytes: ... +def unget_wch(ch: _chtype) -> None: ... +def ungetch(ch: _chtype) -> None: ... def ungetmouse(id: int, x: int, y: int, z: int, bstate: int) -> None: ... def update_lines_cols() -> int: ... def use_default_colors() -> None: ... def use_env(flag: bool) -> None: ... class error(Exception): ... + + +class _CursesWindow: + encoding = ... # type: str + + @overload + def addch(self, ch: _chtype, attr: Optional[int]) -> None: ... + + @overload + def addch(self, y: int, x: int, ch: _chtype, attr: Optional[int]) -> None: ... + + @overload + def addnstr(self, str: str, n: int, attr: Optional[int]) -> None: ... + + @overload + def addnstr(self, y: int, x: int, str: str, n: int, attr: Optional[int]) -> None: ... + + @overload + def addstr(self, str: str, attr: Optional[int]) -> None: ... + + @overload + def addstr(self, y: int, x: int, str: str, attr: Optional[int]) -> None: ... + + def attroff(self, attr: int) -> None: ... + + def attron(self, attr: int) -> None: ... + + def attrset(self, attr: int) -> None: ... + + def bkgd(self, ch: _chtype, attr: Optional[int]) -> None: ... + + def bkgset(self, ch: _chtype, attr: Optional[int]) -> None: ... + + def border(self, ls: Optional[int], rs: Optional[int], + ts: Optional[int], bs: Optional[int], + tl: Optional[int], tr: Optional[int], + bl: Optional[int], br: Optional[int]) -> None: ... + + def box(self, vertch: Optional[Tuple[int, int]], horch: Optional[Tuple[int, int]]) -> None: ... + + @overload + def chgat(self, attr: int) -> None: ... + + @overload + def chgat(self, num: int, attr: int) -> None: ... + + @overload + def chgat(self, y: int, x: int, attr: int) -> None: ... + + @overload + def chgat(self, y: int, x: int, num: int, attr: int) -> None: ... + + def clear(self) -> None: ... + + def clearok(self, yes: int): ... + + def clrtobot(self) -> None: ... + + def clrtoeol(self) -> None: ... + + def cursyncup(self) -> None: ... + + @overload + def delch(self) -> None: ... + + @overload + def delch(self, y: int, x: int) -> None: ... + + def deleteln(self) -> None: ... + + @overload + def derwin(self, begin_y: int, begin_x: int) -> '_CursesWindow': ... + + @overload + def derwin(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> '_CursesWindow': ... + + def echochar(self, ch: _chtype, attr: Optional[int]) -> None: ... + + def enclose(self, y: int, x: int) -> bool: ... + + def erase(self) -> None: ... + + def getbegyx(self) -> Tuple[int, int]: ... + + def getbkgd(self) -> Tuple[int, int]: ... + + def getch(self, y: Optional[int], x: Optional[int]) -> _chtype: ... + + def get_wch(self, y: Optional[int], x: Optional[int]) -> _chtype: ... + + def getkey(self, y: Optional[int], x: Optional[int]) -> str: ... + + def getmaxyx(self) -> Tuple['_CursesWindow', int, int]: ... + + def getparyx(self) -> Tuple[int, int]: ... + + def getstr(self, y: Optional[int], x: Optional[int]) -> None: ... + + def getyx(self) -> Tuple['_CursesWindow', int, int]: ... + + @overload + def hline(self, ch: _chtype, n: int) -> None: ... + + @overload + def hline(self, y: int, x: int, ch: _chtype, n: int) -> None: ... + + def idcok(self, flag: bool) -> None: ... + + def idlok(self, yes: bool) -> None: ... + + def immedok(self, flag: bool) -> None: ... + + def inch(self, y: Optional[int], x: Optional[int]) -> _chtype: ... + + @overload + def insch(self, ch: _chtype, attr: Optional[int]) -> None: ... + + @overload + def insch(self, y: int, x: int, ch: _chtype, attr: Optional[int]) -> None: ... + + def insdelln(self, nlines: int) -> None: ... + + def insertln(self) -> None: ... + + @overload + def insnstr(self, str: str, n: int, attr: Optional[int]) -> None: ... + + @overload + def insnstr(self, y: int, x: int, str: str, n: int, attr: Optional[int]) -> None: ... + + @overload + def insstr(self, str: str, attr: Optional[int]) -> None: ... + + @overload + def insstr(self, y: int, x: int, str: str, attr: Optional[int]) -> None: ... + + @overload + def instr(self, n: Optional[int]) -> str: ... + + @overload + def instr(self, y: int, x: int, n: Optional[int]) -> str: ... + + def is_linetouched(self, line: int) -> bool: ... + + def is_wintouched(self) -> bool: ... + + def keypad(self, yes: bool) -> None: ... + + def leaveok(self, yes: bool) -> None: ... + + def move(self, new_y: int, new_x: int) -> None: ... + + def mvderwin(self, y: int, x: int) -> None: ... + + def mvwin(self, new_y: int, new_x: int) -> None: ... + + def nodelay(self, yes: bool) -> None: ... + + def notimeout(self, yes: bool) -> None: ... + + def noutrefresh(self) -> None: ... + + def overlay(self, destwin: '_CursesWindow', + sminrow: Optional[int], smincol: Optional[int], + dminrow: Optional[int], dmincol: Optional[int], + dmaxrow: Optional[int], dmaxcol: Optional[int]) -> None: ... + + def overwrite(self, destwin: '_CursesWindow', + sminrow: Optional[int], smincol: Optional[int], + dminrow: Optional[int], dmincol: Optional[int], + dmaxrow: Optional[int], dmaxcol: Optional[int]) -> None: ... + + def putwin(self, file: IO[Any]) -> None: ... + + def redrawln(self, beg: int, num: int) -> None: ... + + def redrawwin(self) -> None: ... + + def refresh(self, pminrow: Optional[int], pmincol: Optional[int], + sminrow: Optional[int], smincol: Optional[int], + smaxrow: Optional[int], smaxcol: Optional[int]) -> None: ... + + def resize(self, nlines: int, ncols: int) -> None: ... + + def scroll(self, lines: int) -> None: ... + + def scrollok(self, flag: bool) -> None: ... + + def setscrreg(self, top: int, bottom: int) -> None: ... + + def standend(self) -> None: ... + + def standout(self) -> None: ... + + @overload + def subpad(self, begin_y: int, begin_x: int) -> '_CursesWindow': ... + + @overload + def subpad(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> '_CursesWindow': ... + + @overload + def subwin(self, begin_y: int, begin_x: int) -> '_CursesWindow': ... + + @overload + def subwin(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> '_CursesWindow': ... + + def syncdown(self) -> None: ... + + def syncok(self, flag: bool) -> None: ... + + def syncup(self) -> None: ... + + def timeout(self, delay: int) -> None: ... + + def touchline(self, start: int, count: int, changed: Optional[bool]) -> None: ... + + def touchwin(self) -> None: ... + + def untouchwin(self) -> None: ... + + @overload + def vline(self, ch: _chtype, n: int) -> None: ... + + @overload + def vline(self, y: int, x: int, ch: _chtype, n: int) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/_dummy_thread.pyi b/python/helpers/typeshed/stdlib/3/_dummy_thread.pyi index a4ff81c35587..d88d2488a2f4 100644 --- a/python/helpers/typeshed/stdlib/3/_dummy_thread.pyi +++ b/python/helpers/typeshed/stdlib/3/_dummy_thread.pyi @@ -1,11 +1,22 @@ -# Stubs for _dummy_thread +from mypy_extensions import NoReturn +from typing import Any, Callable, Dict, Optional, Tuple -# NOTE: These are incomplete! - -from typing import Any - -class LockType: - def acquire(self) -> None: ... - def release(self) -> None: ... +TIMEOUT_MAX: int +error = RuntimeError +def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs: Dict[str, Any] = ...) -> None: ... +def exit() -> NoReturn: ... +def get_ident() -> int: ... def allocate_lock() -> LockType: ... +def stack_size(size: Optional[int] = ...) -> int: ... + +class LockType(object): + locked_status: bool + def __init__(self) -> None: ... + def acquire(self, waitflag: Optional[bool] = ..., timeout: int = ...) -> bool: ... + def __enter__(self, waitflag: Optional[bool] = ..., timeout: int = ...) -> bool: ... + def __exit__(self, typ: Any, val: Any, tb: Any) -> None: ... + def release(self) -> bool: ... + def locked(self) -> bool: ... + +def interrupt_main() -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/_imp.pyi b/python/helpers/typeshed/stdlib/3/_imp.pyi new file mode 100644 index 000000000000..7015b3b0cb0e --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/_imp.pyi @@ -0,0 +1,22 @@ +# Stubs for _imp (Python 3.6) + +import sys +import types +from typing import Any, List + +if sys.version_info >= (3, 5): + from importlib.machinery import ModuleSpec + def create_builtin(spec: ModuleSpec) -> types.ModuleType: ... + def create_dynamic(spec: ModuleSpec, file: Any = ...) -> None: ... + +def acquire_lock() -> None: ... +def exec_builtin(mod: types.ModuleType) -> int: ... +def exec_dynamic(mod: types.ModuleType) -> int: ... +def extension_suffixes() -> List[str]: ... +def get_frozen_object(name: str) -> types.CodeType: ... +def init_frozen(name: str) -> types.ModuleType: ... +def is_builtin(name: str) -> int: ... +def is_frozen(name: str) -> bool: ... +def is_frozen_package(name: str) -> bool: ... +def lock_held() -> bool: ... +def release_lock() -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/_importlib_modulespec.pyi b/python/helpers/typeshed/stdlib/3/_importlib_modulespec.pyi index 6b80ab68c207..33c30d537ea2 100644 --- a/python/helpers/typeshed/stdlib/3/_importlib_modulespec.pyi +++ b/python/helpers/typeshed/stdlib/3/_importlib_modulespec.pyi @@ -7,13 +7,13 @@ from abc import ABCMeta import sys -from typing import Any, Optional +from typing import Dict, Any, Optional if sys.version_info >= (3, 4): class ModuleSpec: def __init__(self, name: str, loader: Optional['Loader'], *, - origin: str = None, loader_state: Any = None, - is_package: bool = None) -> None: ... + origin: Optional[str] = None, loader_state: Any = None, + is_package: Optional[bool] = None) -> None: ... name = ... # type: str loader = ... # type: Optional[Loader] origin = ... # type: Optional[str] @@ -26,6 +26,7 @@ if sys.version_info >= (3, 4): class ModuleType: __name__ = ... # type: str __file__ = ... # type: str + __dict__ = ... # type: Dict[str, Any] if sys.version_info >= (3, 4): __loader__ = ... # type: Optional[Loader] __package__ = ... # type: Optional[str] diff --git a/python/helpers/typeshed/stdlib/3/_operator.pyi b/python/helpers/typeshed/stdlib/3/_operator.pyi index 0f64f95b5cc2..99262e5e55af 100644 --- a/python/helpers/typeshed/stdlib/3/_operator.pyi +++ b/python/helpers/typeshed/stdlib/3/_operator.pyi @@ -1,71 +1,65 @@ # Stubs for _operator (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. -def _compare_digest(*args, **kwargs): ... -def abs(a): ... -def add(a, b): ... -def and_(a, b): ... -def concat(a, b): ... -def contains(a, b): ... -def countOf(a, b): ... -def delitem(a, b): ... -def eq(a, b): ... -def floordiv(a, b): ... -def ge(a, b): ... -def getitem(a, b): ... -def gt(a, b): ... -def iadd(*args, **kwargs): ... -def iand(*args, **kwargs): ... -def iconcat(*args, **kwargs): ... -def ifloordiv(*args, **kwargs): ... -def ilshift(*args, **kwargs): ... -def imatmul(*args, **kwargs): ... -def imod(*args, **kwargs): ... -def imul(*args, **kwargs): ... -def index(a): ... -def indexOf(a, b): ... -def inv(a): ... -def invert(a): ... -def ior(*args, **kwargs): ... -def ipow(*args, **kwargs): ... -def irshift(*args, **kwargs): ... -def is_(a, b): ... -def is_not(a, b): ... -def isub(*args, **kwargs): ... -def itruediv(*args, **kwargs): ... -def ixor(*args, **kwargs): ... -def le(a, b): ... -def length_hint(obj, default=0): ... -def lshift(a, b): ... -def lt(a, b): ... -def matmul(a, b): ... -def mod(a, b): ... -def mul(a, b): ... -def ne(a, b): ... -def neg(a): ... -def not_(a): ... -def or_(a, b): ... -def pos(a): ... -def pow(a, b): ... -def rshift(a, b): ... -def setitem(a, b, c): ... -def sub(a, b): ... -def truediv(a, b): ... -def truth(a): ... -def xor(a, b): ... +import sys +from typing import AnyStr -class attrgetter: - def __init__(self, *args, **kwargs): ... - def __call__(self, *args, **kwargs): ... - def __reduce__(self): ... +# In reality the import is the other way around, but this way we can keep the operator stub in 2and3 +from operator import ( + truth as truth, + contains as contains, + indexOf as indexOf, + countOf as countOf, + is_ as is_, + is_not as is_not, + index as index, + add as add, + sub as sub, + mul as mul, + floordiv as floordiv, + truediv as truediv, + mod as mod, + neg as neg, + pos as pos, + abs as abs, + inv as inv, + invert as invert, + lshift as lshift, + rshift as rshift, + not_ as not_, + and_ as and_, + xor as xor, + or_ as or_, + iadd as iadd, + isub as isub, + imul as imul, + ifloordiv as ifloordiv, + itruediv as itruediv, + imod as imod, + ilshift as ilshift, + irshift as irshift, + iand as iand, + ixor as ixor, + ior as ior, + concat as concat, + iconcat as iconcat, + getitem as getitem, + setitem as setitem, + delitem as delitem, + pow as pow, + ipow as ipow, + eq as eq, + ne as ne, + lt as lt, + le as le, + gt as gt, + ge as ge, + itemgetter as itemgetter, + attrgetter as attrgetter, + methodcaller as methodcaller, +) +if sys.version_info >= (3, 5): + from operator import matmul as matmul, imatmul as imatmul +if sys.version_info >= (3, 4): + from operator import length_hint as length_hint -class itemgetter: - def __init__(self, *args, **kwargs): ... - def __call__(self, *args, **kwargs): ... - def __reduce__(self): ... - -class methodcaller: - def __init__(self, *args, **kwargs): ... - def __call__(self, *args, **kwargs): ... - def __reduce__(self): ... +def _compare_digest(a: AnyStr, b: AnyStr) -> bool: ... diff --git a/python/helpers/typeshed/stdlib/3/_threading_local.pyi b/python/helpers/typeshed/stdlib/3/_threading_local.pyi new file mode 100644 index 000000000000..a286d2dd54cc --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/_threading_local.pyi @@ -0,0 +1,18 @@ +# Source: https://github.com/python/cpython/blob/master/Lib/_threading_local.py +from typing import Any, Dict, List, Tuple +from weakref import ReferenceType + +__all__: List[str] +localdict = Dict[Any, Any] + +class _localimpl: + key: str + dicts: Dict[int, Tuple[ReferenceType, localdict]] + def __init__(self) -> None: ... + def get_dict(self) -> localdict: ... + def create_dict(self) -> localdict: ... + +class local: + def __getattribute__(self, name: str) -> Any: ... + def __setattr__(self, name: str, value: Any) -> None: ... + def __delattr__(self, name: str) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/_warnings.pyi b/python/helpers/typeshed/stdlib/3/_warnings.pyi index b1f0431d330f..4d890e51cfe8 100644 --- a/python/helpers/typeshed/stdlib/3/_warnings.pyi +++ b/python/helpers/typeshed/stdlib/3/_warnings.pyi @@ -1,11 +1,11 @@ -from typing import Any, List +from typing import Any, List, Optional, Type _defaultaction = ... # type: str _onceregistry = ... # type: dict filters = ... # type: List[tuple] -def warn(message: Warning, category: type = ..., stacklevel: int = ...) -> None: ... -def warn_explicit(message: Warning, category: type, +def warn(message: Warning, category: Optional[Type[Warning]] = ..., stacklevel: int = ...) -> None: ... +def warn_explicit(message: Warning, category: Optional[Type[Warning]], filename: str, lineno: int, module: Any = ..., registry: dict = ..., module_globals: dict = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/abc.pyi b/python/helpers/typeshed/stdlib/3/abc.pyi index 86a97f00a033..f50f7908d1a0 100644 --- a/python/helpers/typeshed/stdlib/3/abc.pyi +++ b/python/helpers/typeshed/stdlib/3/abc.pyi @@ -1,18 +1,24 @@ -from typing import Any, Type, TypeVar +from typing import Any, Callable, Type, TypeVar import sys # Stubs for abc. _T = TypeVar('_T') +_FuncT = TypeVar('_FuncT', bound=Callable[..., Any]) -# Thesee definitions have special processing in type checker. +# Thesee definitions have special processing in mypy class ABCMeta(type): if sys.version_info >= (3, 3): def register(cls: "ABCMeta", subclass: Type[_T]) -> Type[_T]: ... else: def register(cls: "ABCMeta", subclass: Type[Any]) -> None: ... -abstractmethod = object() -abstractproperty = object() + +def abstractmethod(callable: _FuncT) -> _FuncT: ... +def abstractproperty(callable: _FuncT) -> _FuncT: ... +# These two are deprecated and not supported by mypy +def abstractstaticmethod(callable: _FuncT) -> _FuncT: ... +def abstractclassmethod(callable: _FuncT) -> _FuncT: ... if sys.version_info >= (3, 4): class ABC(metaclass=ABCMeta): pass + def get_cache_token() -> object: ... diff --git a/python/helpers/typeshed/stdlib/3/ast.pyi b/python/helpers/typeshed/stdlib/3/ast.pyi index 534567650854..241f874f140b 100644 --- a/python/helpers/typeshed/stdlib/3/ast.pyi +++ b/python/helpers/typeshed/stdlib/3/ast.pyi @@ -3,20 +3,7 @@ import typing from typing import Any, Union, Iterator -from _ast import ( - Add, alias, And, arg, arguments, Assert, Assign, AST, AsyncFor, - AsyncFunctionDef, AsyncWith, Attribute, AugAssign, AugLoad, AugStore, - Await, BinOp, BitAnd, BitOr, BitXor, BoolOp, boolop, Break, Bytes, Call, - ClassDef, cmpop, Compare, comprehension, Continue, Del, Delete, Dict, - DictComp, Div, Ellipsis, Eq, ExceptHandler, Expr, expr, Expression, - expr_context, ExtSlice, FloorDiv, For, FunctionDef, GeneratorExp, Global, - Gt, GtE, If, IfExp, Import, ImportFrom, In, Index, Interactive, Invert, Is, - IsNot, keyword, Lambda, List, ListComp, Load, LShift, Lt, LtE, MatMult, - Mod, mod, Module, Mult, Name, NameConstant, Nonlocal, Not, NotEq, NotIn, - Num, operator, Or, Param, Pass, Pow, Raise, Return, RShift, Set, SetComp, - Slice, slice, Starred, stmt, Store, Str, Sub, Subscript, Suite, Try, Tuple, - UAdd, UnaryOp, unaryop, USub, While, With, withitem, Yield, YieldFrom -) +from _ast import * class NodeVisitor(): def visit(self, node: AST) -> Any: ... diff --git a/python/helpers/typeshed/stdlib/3/builtins.pyi b/python/helpers/typeshed/stdlib/3/builtins.pyi index 7c46b8986c36..8d0dfb88319c 100644 --- a/python/helpers/typeshed/stdlib/3/builtins.pyi +++ b/python/helpers/typeshed/stdlib/3/builtins.pyi @@ -8,7 +8,7 @@ from typing import ( ByteString, Optional, AnyStr, Type, ) from abc import abstractmethod, ABCMeta -from types import TracebackType +from types import TracebackType, CodeType import sys from mypy_extensions import NoReturn @@ -50,6 +50,7 @@ class object: def __sizeof__(self) -> int: ... def __reduce__(self) -> tuple: ... def __reduce_ex__(self, protocol: int) -> tuple: ... + def __dir__(self) -> Iterable[str]: ... if sys.version_info >= (3, 6): def __init_subclass__(cls) -> None: ... @@ -104,14 +105,9 @@ class super: class int(SupportsInt, SupportsFloat, SupportsAbs[int]): @overload - def __init__(self, x: SupportsInt = ...) -> None: ... + def __init__(self, x: Union[str, bytes, SupportsInt] = ...) -> None: ... @overload - def __init__(self, x: Union[str, bytes], base: int = ...) -> None: ... - - @overload - def __new__(cls: Type[_T1], x: SupportsInt = ...) -> _T1: ... - @overload - def __new__(cls: Type[_T1], x: Union[str, bytes], base: int = ...) -> _T1: ... + def __init__(self, x: Union[str, bytes], base: int) -> None: ... def bit_length(self) -> int: ... def to_bytes(self, length: int, byteorder: str, *, signed: bool = ...) -> bytes: ... @@ -240,17 +236,13 @@ class str(Sequence[str]): @overload def __init__(self, o: bytes, encoding: str = ..., errors: str = ...) -> None: ... - @overload - def __new__(cls: Type[_T1], o: object = ...) -> _T1: ... - @overload - def __new__(cls: Type[_T1], o: bytes, encoding: str = ..., errors: str = ...) -> _T1: ... - def capitalize(self) -> str: ... + def casefold(self) -> str: ... def center(self, width: int, fillchar: str = ' ') -> str: ... def count(self, x: str, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def encode(self, encoding: str = 'utf-8', errors: str = 'strict') -> bytes: ... - def endswith(self, suffix: Union[str, Tuple[str, ...]], start: int = None, - end: int = None) -> bool: ... + def endswith(self, suffix: Union[str, Tuple[str, ...]], start: Optional[int] = None, + end: Optional[int] = None) -> bool: ... def expandtabs(self, tabsize: int = 8) -> str: ... def find(self, sub: str, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def format(self, *args: Any, **kwargs: Any) -> str: ... @@ -270,20 +262,20 @@ class str(Sequence[str]): def join(self, iterable: Iterable[str]) -> str: ... def ljust(self, width: int, fillchar: str = ' ') -> str: ... def lower(self) -> str: ... - def lstrip(self, chars: str = None) -> str: ... + def lstrip(self, chars: Optional[str] = None) -> str: ... def partition(self, sep: str) -> Tuple[str, str, str]: ... def replace(self, old: str, new: str, count: int = -1) -> str: ... def rfind(self, sub: str, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def rindex(self, sub: str, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def rjust(self, width: int, fillchar: str = ' ') -> str: ... def rpartition(self, sep: str) -> Tuple[str, str, str]: ... - def rsplit(self, sep: str = None, maxsplit: int = -1) -> List[str]: ... - def rstrip(self, chars: str = None) -> str: ... - def split(self, sep: str = None, maxsplit: int = -1) -> List[str]: ... + def rsplit(self, sep: Optional[str] = None, maxsplit: int = -1) -> List[str]: ... + def rstrip(self, chars: Optional[str] = None) -> str: ... + def split(self, sep: Optional[str] = None, maxsplit: int = -1) -> List[str]: ... def splitlines(self, keepends: bool = ...) -> List[str]: ... - def startswith(self, prefix: Union[str, Tuple[str, ...]], start: int = None, - end: int = None) -> bool: ... - def strip(self, chars: str = None) -> str: ... + def startswith(self, prefix: Union[str, Tuple[str, ...]], start: Optional[int] = None, + end: Optional[int] = None) -> bool: ... + def strip(self, chars: Optional[str] = None) -> str: ... def swapcase(self) -> str: ... def title(self) -> str: ... def translate(self, table: Dict[int, Any]) -> str: ... @@ -300,7 +292,7 @@ class str(Sequence[str]): def __add__(self, s: str) -> str: ... def __mul__(self, n: int) -> str: ... def __rmul__(self, n: int) -> str: ... - def __mod__(self, *args: Any) -> str: ... + def __mod__(self, value: Any) -> str: ... def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... def __lt__(self, x: str) -> bool: ... @@ -313,8 +305,6 @@ class str(Sequence[str]): def __iter__(self) -> Iterator[str]: ... def __str__(self) -> str: ... def __repr__(self) -> str: ... - def __int__(self) -> int: ... - def __float__(self) -> float: ... def __hash__(self) -> int: ... class bytes(ByteString): @@ -332,22 +322,22 @@ class bytes(ByteString): def capitalize(self) -> bytes: ... def center(self, width: int, fillchar: bytes = ...) -> bytes: ... if sys.version_info >= (3, 3): - def count(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ... + def count(self, sub: Union[bytes, int], start: Optional[int] = None, end: Optional[int] = None) -> int: ... else: - def count(self, sub: bytes, start: int = None, end: int = None) -> int: ... + def count(self, sub: bytes, start: Optional[int] = None, end: Optional[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: ... if sys.version_info >= (3, 3): - def find(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ... + def find(self, sub: Union[bytes, int], start: Optional[int] = None, end: Optional[int] = None) -> int: ... else: - def find(self, sub: bytes, start: int = None, end: int = None) -> int: ... + def find(self, sub: bytes, start: Optional[int] = None, end: Optional[int] = None) -> int: ... if sys.version_info >= (3, 5): def hex(self) -> str: ... if sys.version_info >= (3, 3): - def index(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ... + def index(self, sub: Union[bytes, int], start: Optional[int] = None, end: Optional[int] = None) -> int: ... else: - def index(self, sub: bytes, start: int = None, end: int = None) -> int: ... + def index(self, sub: bytes, start: Optional[int] = None, end: Optional[int] = None) -> int: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... def isdigit(self) -> bool: ... @@ -358,25 +348,25 @@ class bytes(ByteString): def join(self, iterable: Iterable[bytes]) -> bytes: ... def ljust(self, width: int, fillchar: bytes = ...) -> bytes: ... def lower(self) -> bytes: ... - def lstrip(self, chars: bytes = None) -> bytes: ... + def lstrip(self, chars: Optional[bytes] = None) -> bytes: ... def partition(self, sep: bytes) -> Tuple[bytes, bytes, bytes]: ... def replace(self, old: bytes, new: bytes, count: int = -1) -> bytes: ... if sys.version_info >= (3, 3): - def rfind(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ... + def rfind(self, sub: Union[bytes, int], start: Optional[int] = None, end: Optional[int] = None) -> int: ... else: - def rfind(self, sub: bytes, start: int = None, end: int = None) -> int: ... + def rfind(self, sub: bytes, start: Optional[int] = None, end: Optional[int] = None) -> int: ... if sys.version_info >= (3, 3): - def rindex(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ... + def rindex(self, sub: Union[bytes, int], start: Optional[int] = None, end: Optional[int] = None) -> int: ... else: - def rindex(self, sub: bytes, start: int = None, end: int = None) -> int: ... + def rindex(self, sub: bytes, start: Optional[int] = None, end: Optional[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]: ... - def rstrip(self, chars: bytes = None) -> bytes: ... - def split(self, sep: bytes = None, maxsplit: int = -1) -> List[bytes]: ... + def rsplit(self, sep: Optional[bytes] = None, maxsplit: int = -1) -> List[bytes]: ... + def rstrip(self, chars: Optional[bytes] = None) -> bytes: ... + def split(self, sep: Optional[bytes] = None, maxsplit: int = -1) -> List[bytes]: ... def splitlines(self, keepends: bool = ...) -> List[bytes]: ... def startswith(self, prefix: Union[bytes, Tuple[bytes, ...]]) -> bool: ... - def strip(self, chars: bytes = None) -> bytes: ... + def strip(self, chars: Optional[bytes] = None) -> bytes: ... def swapcase(self) -> bytes: ... def title(self) -> bytes: ... def translate(self, table: Optional[bytes], delete: bytes = ...) -> bytes: ... @@ -401,6 +391,8 @@ class bytes(ByteString): def __add__(self, s: bytes) -> bytes: ... def __mul__(self, n: int) -> bytes: ... def __rmul__(self, n: int) -> bytes: ... + if sys.version_info >= (3, 5): + def __mod__(self, value: Any) -> bytes: ... def __contains__(self, o: object) -> bool: ... def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... @@ -421,22 +413,22 @@ class bytearray(MutableSequence[int], ByteString): def capitalize(self) -> bytearray: ... def center(self, width: int, fillchar: bytes = ...) -> bytearray: ... if sys.version_info >= (3, 3): - def count(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ... + def count(self, sub: Union[bytes, int], start: Optional[int] = None, end: Optional[int] = None) -> int: ... else: - def count(self, sub: bytes, start: int = None, end: int = None) -> int: ... + def count(self, sub: bytes, start: Optional[int] = None, end: Optional[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: ... if sys.version_info >= (3, 3): - def find(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ... + def find(self, sub: Union[bytes, int], start: Optional[int] = None, end: Optional[int] = None) -> int: ... else: - def find(self, sub: bytes, start: int = None, end: int = None) -> int: ... + def find(self, sub: bytes, start: Optional[int] = None, end: Optional[int] = None) -> int: ... if sys.version_info >= (3, 5): def hex(self) -> str: ... if sys.version_info >= (3, 3): - def index(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ... + def index(self, sub: Union[bytes, int], start: Optional[int] = None, end: Optional[int] = None) -> int: ... else: - def index(self, sub: bytes, start: int = None, end: int = None) -> int: ... + def index(self, sub: bytes, start: Optional[int] = None, end: Optional[int] = None) -> int: ... def insert(self, index: int, object: int) -> None: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... @@ -448,25 +440,25 @@ class bytearray(MutableSequence[int], ByteString): def join(self, iterable: Iterable[bytes]) -> bytearray: ... def ljust(self, width: int, fillchar: bytes = ...) -> bytearray: ... def lower(self) -> bytearray: ... - def lstrip(self, chars: bytes = None) -> bytearray: ... + def lstrip(self, chars: Optional[bytes] = None) -> bytearray: ... def partition(self, sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... def replace(self, old: bytes, new: bytes, count: int = -1) -> bytearray: ... if sys.version_info >= (3, 3): - def rfind(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ... + def rfind(self, sub: Union[bytes, int], start: Optional[int] = None, end: Optional[int] = None) -> int: ... else: - def rfind(self, sub: bytes, start: int = None, end: int = None) -> int: ... + def rfind(self, sub: bytes, start: Optional[int] = None, end: Optional[int] = None) -> int: ... if sys.version_info >= (3, 3): - def rindex(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ... + def rindex(self, sub: Union[bytes, int], start: Optional[int] = None, end: Optional[int] = None) -> int: ... else: - def rindex(self, sub: bytes, start: int = None, end: int = None) -> int: ... + def rindex(self, sub: bytes, start: Optional[int] = None, end: Optional[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]: ... - def rstrip(self, chars: bytes = None) -> bytearray: ... - def split(self, sep: bytes = None, maxsplit: int = -1) -> List[bytearray]: ... + def rsplit(self, sep: Optional[bytes] = None, maxsplit: int = -1) -> List[bytearray]: ... + def rstrip(self, chars: Optional[bytes] = None) -> bytearray: ... + def split(self, sep: Optional[bytes] = None, maxsplit: int = -1) -> List[bytearray]: ... def splitlines(self, keepends: bool = ...) -> List[bytearray]: ... def startswith(self, prefix: bytes) -> bool: ... - def strip(self, chars: bytes = None) -> bytearray: ... + def strip(self, chars: Optional[bytes] = None) -> bytearray: ... def swapcase(self) -> bytearray: ... def title(self) -> bytearray: ... def translate(self, table: Optional[bytes], delete: bytes = ...) -> bytearray: ... @@ -498,6 +490,8 @@ class bytearray(MutableSequence[int], ByteString): def __mul__(self, n: int) -> bytearray: ... def __rmul__(self, n: int) -> bytearray: ... def __imul__(self, n: int) -> bytearray: ... + if sys.version_info >= (3, 5): + def __mod__(self, value: Any) -> bytes: ... def __contains__(self, o: object) -> bool: ... def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... @@ -551,7 +545,7 @@ class slice: @overload def __init__(self, stop: Optional[int]) -> None: ... @overload - def __init__(self, start: Optional[int], stop: Optional[int], step: int = None) -> None: ... + def __init__(self, start: Optional[int], stop: Optional[int], step: Optional[int] = None) -> None: ... def indices(self, len: int) -> Tuple[int, int, int]: ... class tuple(Sequence[_T_co], Generic[_T_co]): @@ -581,7 +575,7 @@ class function: __name__ = ... # type: str __qualname__ = ... # type: str __module__ = ... # type: str - __code__ = ... # type: Any + __code__ = ... # type: CodeType __annotations__ = ... # type: Dict[str, Any] class list(MutableSequence[_T], Generic[_T]): @@ -599,7 +593,7 @@ class list(MutableSequence[_T], Generic[_T]): def insert(self, index: int, object: _T) -> None: ... def remove(self, object: _T) -> None: ... def reverse(self) -> None: ... - def sort(self, *, key: Callable[[_T], Any] = None, reverse: bool = ...) -> None: ... + def sort(self, *, key: Optional[Callable[[_T], Any]] = None, reverse: bool = ...) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[_T]: ... @@ -641,7 +635,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): def clear(self) -> None: ... def copy(self) -> Dict[_KT, _VT]: ... def popitem(self) -> Tuple[_KT, _VT]: ... - def setdefault(self, k: _KT, default: _VT = None) -> _VT: ... + def setdefault(self, k: _KT, default: Optional[_VT] = None) -> _VT: ... @overload def update(self, __m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... @overload @@ -669,10 +663,10 @@ class set(MutableSet[_T], Generic[_T]): def add(self, element: _T) -> None: ... def clear(self) -> None: ... def copy(self) -> Set[_T]: ... - def difference(self, *s: Iterable[Any]) -> Set[_T]: ... - def difference_update(self, *s: Iterable[Any]) -> None: ... + def difference(self, *s: Iterable[object]) -> Set[_T]: ... + def difference_update(self, *s: Iterable[object]) -> None: ... def discard(self, element: _T) -> None: ... - def intersection(self, *s: Iterable[Any]) -> Set[_T]: ... + def intersection(self, *s: Iterable[object]) -> Set[_T]: ... def intersection_update(self, *s: Iterable[Any]) -> None: ... def isdisjoint(self, s: Iterable[Any]) -> bool: ... def issubset(self, s: Iterable[Any]) -> bool: ... @@ -687,28 +681,28 @@ class set(MutableSet[_T], Generic[_T]): def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[_T]: ... def __str__(self) -> str: ... - def __and__(self, s: AbstractSet[Any]) -> Set[_T]: ... - def __iand__(self, s: AbstractSet[Any]) -> Set[_T]: ... + def __and__(self, s: AbstractSet[object]) -> Set[_T]: ... + def __iand__(self, s: AbstractSet[object]) -> Set[_T]: ... def __or__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ... def __ior__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ... - def __sub__(self, s: AbstractSet[Any]) -> Set[_T]: ... - def __isub__(self, s: AbstractSet[Any]) -> Set[_T]: ... + def __sub__(self, s: AbstractSet[object]) -> Set[_T]: ... + def __isub__(self, s: AbstractSet[object]) -> Set[_T]: ... def __xor__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ... def __ixor__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ... - def __le__(self, s: AbstractSet[Any]) -> bool: ... - def __lt__(self, s: AbstractSet[Any]) -> bool: ... - def __ge__(self, s: AbstractSet[Any]) -> bool: ... - def __gt__(self, s: AbstractSet[Any]) -> bool: ... + def __le__(self, s: AbstractSet[object]) -> bool: ... + def __lt__(self, s: AbstractSet[object]) -> bool: ... + def __ge__(self, s: AbstractSet[object]) -> bool: ... + def __gt__(self, s: AbstractSet[object]) -> bool: ... # TODO more set operations class frozenset(AbstractSet[_T], Generic[_T]): def __init__(self, iterable: Iterable[_T] = ...) -> None: ... def copy(self) -> FrozenSet[_T]: ... - def difference(self, *s: Iterable[Any]) -> FrozenSet[_T]: ... - def intersection(self, *s: Iterable[Any]) -> FrozenSet[_T]: ... + def difference(self, *s: Iterable[object]) -> FrozenSet[_T]: ... + def intersection(self, *s: Iterable[object]) -> FrozenSet[_T]: ... def isdisjoint(self, s: Iterable[_T]) -> bool: ... - def issubset(self, s: Iterable[Any]) -> bool: ... - def issuperset(self, s: Iterable[Any]) -> bool: ... + def issubset(self, s: Iterable[object]) -> bool: ... + def issuperset(self, s: Iterable[object]) -> bool: ... def symmetric_difference(self, s: Iterable[_T]) -> FrozenSet[_T]: ... def union(self, *s: Iterable[_T]) -> FrozenSet[_T]: ... def __len__(self) -> int: ... @@ -719,10 +713,10 @@ class frozenset(AbstractSet[_T], Generic[_T]): def __or__(self, s: AbstractSet[_S]) -> FrozenSet[Union[_T, _S]]: ... def __sub__(self, s: AbstractSet[_T]) -> FrozenSet[_T]: ... def __xor__(self, s: AbstractSet[_S]) -> FrozenSet[Union[_T, _S]]: ... - def __le__(self, s: AbstractSet[Any]) -> bool: ... - def __lt__(self, s: AbstractSet[Any]) -> bool: ... - def __ge__(self, s: AbstractSet[Any]) -> bool: ... - def __gt__(self, s: AbstractSet[Any]) -> bool: ... + def __le__(self, s: AbstractSet[object]) -> bool: ... + def __lt__(self, s: AbstractSet[object]) -> bool: ... + def __ge__(self, s: AbstractSet[object]) -> bool: ... + def __gt__(self, s: AbstractSet[object]) -> bool: ... class enumerate(Iterator[Tuple[int, _T]], Generic[_T]): def __init__(self, iterable: Iterable[_T], start: int = 0) -> None: ... @@ -730,12 +724,15 @@ class enumerate(Iterator[Tuple[int, _T]], Generic[_T]): def __next__(self) -> Tuple[int, _T]: ... class range(Sequence[int]): + start = ... # type: int + stop = ... # type: int + step = ... # type: int @overload def __init__(self, stop: int) -> None: ... @overload def __init__(self, start: int, stop: int, step: int = 1) -> None: ... def count(self, value: int) -> int: ... - def index(self, value: int, start: int = 0, stop: int = None) -> int: ... + def index(self, value: int, start: int = 0, stop: Optional[int] = None) -> int: ... def __len__(self) -> int: ... def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[int]: ... @@ -746,20 +743,15 @@ class range(Sequence[int]): def __repr__(self) -> str: ... def __reversed__(self) -> Iterator[int]: ... -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, - fset: Callable[[Any, Any], None] = None, - fdel: Callable[[Any], None] = None, doc: str = None) -> None: ... + def __init__(self, fget: Optional[Callable[[Any], Any]] = None, + fset: Optional[Callable[[Any, Any], None]] = None, + fdel: Optional[Callable[[Any], None]] = None, + doc: Optional[str] = None) -> None: ... def getter(self, fget: Callable[[Any], Any]) -> property: ... def setter(self, fset: Callable[[Any, Any], None]) -> property: ... def deleter(self, fdel: Callable[[Any], None]) -> property: ... - def __get__(self, obj: Any, type: type=None) -> Any: ... + def __get__(self, obj: Any, type: Optional[type] = None) -> Any: ... def __set__(self, obj: Any, value: Any) -> None: ... def __delete__(self, obj: Any) -> None: ... def fget(self) -> Any: ... @@ -769,27 +761,25 @@ class property: NotImplemented = ... # type: Any def abs(n: SupportsAbs[_T]) -> _T: ... -def all(i: Iterable) -> bool: ... -def any(i: Iterable) -> bool: ... +def all(i: Iterable[object]) -> bool: ... +def any(i: Iterable[object]) -> bool: ... def ascii(o: object) -> str: ... def bin(number: int) -> str: ... def callable(o: object) -> bool: ... def chr(code: int) -> str: ... -def compile(source: Any, filename: Union[str, bytes], mode: str, flags: int = 0, - dont_inherit: int = 0) -> Any: ... +def compile(source: Any, filename: Union[str, bytes], mode: str, flags: int = 0, dont_inherit: int = 0) -> CodeType: ... def copyright() -> None: ... def credits() -> None: ... def delattr(o: Any, name: str) -> None: ... def dir(o: object = ...) -> List[str]: ... _N = TypeVar('_N', int, float) def divmod(a: _N, b: _N) -> Tuple[_N, _N]: ... -def eval(source: str, globals: Dict[str, Any] = None, - locals: Mapping[str, Any] = None) -> Any: ... # TODO code object as source -def exec(object: str, globals: Dict[str, Any] = None, - locals: Mapping[str, Any] = None) -> Any: ... # TODO code object as source +def eval(source: Union[str, bytes, CodeType], globals: Optional[Dict[str, Any]] = None, locals: Optional[Mapping[str, Any]] = None) -> Any: ... +def exec(object: Union[str, bytes, CodeType], globals: Optional[Dict[str, Any]] = None, locals: Optional[Mapping[str, Any]] = None) -> Any: ... def exit(code: Any = ...) -> NoReturn: ... @overload -def filter(function: Callable[[_T], Any], iterable: Iterable[_T]) -> Iterator[_T]: ... +def filter(function: Optional[Callable[[_T], Any]], + iterable: Iterable[_T]) -> Iterator[_T]: ... @overload def filter(function: None, iterable: Iterable[Optional[_T]]) -> Iterator[_T]: ... def format(o: object, format_spec: str = '') -> str: ... @@ -800,7 +790,7 @@ def hash(o: object) -> int: ... def help(*args: Any, **kwds: Any) -> None: ... def hex(i: int) -> str: ... # TODO __index__ def id(o: object) -> int: ... -def input(prompt: Any = None) -> str: ... +def input(prompt: Optional[Any] = None) -> str: ... @overload def iter(iterable: Iterable[_T]) -> Iterator[_T]: ... @overload @@ -836,15 +826,15 @@ if sys.version_info >= (3, 6): class _PathLike(Generic[AnyStr]): def __fspath__(self) -> AnyStr: ... - def open(file: Union[str, bytes, int, _PathLike], mode: str = 'r', buffering: int = -1, encoding: str = None, - errors: str = None, newline: str = None, closefd: bool = ...) -> IO[Any]: ... + def open(file: Union[str, bytes, int, _PathLike], mode: str = 'r', buffering: int = -1, encoding: Optional[str] = None, + errors: Optional[str] = None, newline: Optional[str] = None, closefd: bool = ...) -> IO[Any]: ... else: - def open(file: Union[str, bytes, int], mode: str = 'r', buffering: int = -1, encoding: str = None, - errors: str = None, newline: str = None, closefd: bool = ...) -> IO[Any]: ... + def open(file: Union[str, bytes, int], mode: str = 'r', buffering: int = -1, encoding: Optional[str] = None, + errors: Optional[str] = None, newline: Optional[str] = None, closefd: bool = ...) -> IO[Any]: ... def ord(c: Union[str, bytes, bytearray]) -> int: ... # TODO: in Python 3.2, print() does not support flush -def print(*values: Any, sep: str = ' ', end: str = '\n', file: IO[str] = None, flush: bool = False) -> None: ... +def print(*values: Any, sep: str = ' ', end: str = '\n', file: Optional[IO[str]] = None, flush: bool = False) -> None: ... @overload def pow(x: int, y: int) -> Any: ... # The return type can be int or float, depending on y @overload @@ -853,7 +843,7 @@ def pow(x: int, y: int, z: int) -> Any: ... def pow(x: float, y: float) -> float: ... @overload def pow(x: float, y: float, z: float) -> float: ... -def quit(code: int = None) -> None: ... +def quit(code: Optional[int] = None) -> None: ... @overload def reversed(object: Reversible[_T]) -> Iterator[_T]: ... @overload @@ -868,7 +858,8 @@ def round(number: SupportsRound[_T]) -> _T: ... @overload def round(number: SupportsRound[_T], ndigits: int) -> _T: ... def setattr(object: Any, name: str, value: Any) -> None: ... -def sorted(iterable: Iterable[_T], *, key: Callable[[_T], Any] = None, +def sorted(iterable: Iterable[_T], *, + key: Optional[Callable[[_T], Any]] = None, reverse: bool = False) -> List[_T]: ... def sum(iterable: Iterable[_T], start: _T = ...) -> _T: ... def vars(object: Any = ...) -> Dict[str, Any]: ... @@ -908,7 +899,7 @@ class BaseException: __cause__ = ... # type: BaseException __context__ = ... # type: BaseException __traceback__ = ... # type: TracebackType - def __init__(self, *args: Any) -> None: ... + def __init__(self, *args: object) -> None: ... def with_traceback(self, tb: Any) -> BaseException: ... class GeneratorExit(BaseException): ... @@ -971,6 +962,7 @@ class SyntaxError(Exception): lineno = ... # type: int offset = ... # type: int text = ... # type: str + filename = ... # type: str class IndentationError(SyntaxError): ... class TabError(IndentationError): ... class SystemError(Exception): ... diff --git a/python/helpers/typeshed/stdlib/3/collections/__init__.pyi b/python/helpers/typeshed/stdlib/3/collections/__init__.pyi index b8bfcf138590..5da5c47d8ff5 100644 --- a/python/helpers/typeshed/stdlib/3/collections/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/collections/__init__.pyi @@ -2,18 +2,18 @@ # Based on http://docs.python.org/3.2/library/collections.html -# TODO more abstract base classes (interfaces in mypy) - # These are not exported. import sys import typing from typing import ( TypeVar, Generic, Dict, overload, List, Tuple, - Callable, Any, Type, Optional, Union + Any, Type, Optional, Union ) # These are exported. -# TODO reexport more. +from . import abc + from typing import ( + Callable as Callable, Container as Container, Hashable as Hashable, Iterable as Iterable, @@ -21,10 +21,6 @@ from typing import ( Sized as Sized, Generator as Generator, ByteString as ByteString, - Awaitable as Awaitable, - Coroutine as Coroutine, - AsyncIterable as AsyncIterable, - AsyncIterator as AsyncIterator, Reversible as Reversible, Mapping as Mapping, MappingView as MappingView, @@ -38,7 +34,17 @@ from typing import ( AbstractSet as Set, ) if sys.version_info >= (3, 6): - from typing import AsyncGenerator as AsyncGenerator + from typing import ( + Collection as Collection, + AsyncGenerator as AsyncGenerator, + ) +if sys.version_info >= (3, 5): + from typing import ( + Awaitable as Awaitable, + Coroutine as Coroutine, + AsyncIterable as AsyncIterable, + AsyncIterator as AsyncIterator, + ) _T = TypeVar('_T') _KT = TypeVar('_KT') @@ -46,13 +52,135 @@ _VT = TypeVar('_VT') # namedtuple is special-cased in the type checker; the initializer is ignored. -def namedtuple(typename: str, field_names: Union[str, Iterable[Any]], *, - verbose: bool = ..., rename: bool = ..., module: str = None) -> Type[tuple]: ... +if sys.version_info >= (3, 6): + def namedtuple(typename: str, field_names: Union[str, Iterable[str]], *, + verbose: bool = ..., rename: bool = ..., module: Optional[str] = ...) -> Type[tuple]: ... +else: + def namedtuple(typename: str, field_names: Union[str, Iterable[str]], + verbose: bool = ..., rename: bool = ...) -> Type[tuple]: ... + +_UserDictT = TypeVar('_UserDictT', bound=UserDict) + +class UserDict(MutableMapping[_KT, _VT]): + def __len__(self) -> int: ... + def __getitem__(self, key: _KT) -> _VT: ... + def __setitem__(self, key: _KT, item: _VT) -> None: ... + def __delitem__(self, key: _KT) -> None: ... + def __iter__(self) -> Iterator[_KT]: ... + def __contains__(self, key: object) -> bool: ... + def copy(self: _UserDictT) -> _UserDictT: ... + @classmethod + def fromkeys(cls: Type[_UserDictT], iterable: Iterable[_KT], value: Optional[_VT] = ...) -> _UserDictT: ... + +_UserListT = TypeVar('_UserListT', bound=UserList) + +class UserList(MutableSequence[_T]): + def __init__(self, initlist: Optional[Iterable[_T]] = ...) -> None: ... + def __lt__(self, other: object) -> bool: ... + def __le__(self, other: object) -> bool: ... + def __gt__(self, other: object) -> bool: ... + def __ge__(self, other: object) -> bool: ... + def __contains__(self, item: object) -> bool: ... + def __len__(self) -> int: ... + @overload + def __getitem__(self, i: int) -> _T: ... + @overload + def __getitem__(self, i: slice) -> Sequence[_T]: ... + @overload + def __setitem__(self, i: int, o: _T) -> None: ... + @overload + def __setitem__(self, i: slice, o: Iterable[_T]) -> None: ... + def __delitem__(self, i: Union[int, slice]) -> None: ... + def __add__(self: _UserListT, other: Iterable[_T]) -> _UserListT: ... + def __iadd__(self: _UserListT, other: Iterable[_T]) -> _UserListT: ... + def __mul__(self: _UserListT, n: int) -> _UserListT: ... + def __imul__(self: _UserListT, n: int) -> _UserListT: ... + def append(self, item: _T) -> None: ... + def insert(self, i: int, item: _T) -> None: ... + def pop(self, i: int = ...) -> _T: ... + def remove(self, item: _T) -> None: ... + def clear(self) -> None: ... + def copy(self: _UserListT) -> _UserListT: ... + def count(self, item: _T) -> int: ... + def index(self, item: _T, *args: Any) -> int: ... + def reverse(self) -> None: ... + def sort(self, *args: Any, **kwds: Any) -> None: ... + def extend(self, other: Iterable[_T]) -> None: ... + +_UserStringT = TypeVar('_UserStringT', bound=UserString) + +class UserString(Sequence[str]): + def __init__(self, seq: object) -> None: ... + def __int__(self) -> int: ... + def __float__(self) -> float: ... + def __complex__(self) -> complex: ... + if sys.version_info >= (3, 5): + def __getnewargs__(self) -> Tuple[str]: ... + def __lt__(self, string: Union[str, UserString]) -> bool: ... + def __le__(self, string: Union[str, UserString]) -> bool: ... + def __gt__(self, string: Union[str, UserString]) -> bool: ... + def __ge__(self, string: Union[str, UserString]) -> bool: ... + def __contains__(self, char: object) -> bool: ... + def __len__(self) -> int: ... + # It should return a str to implement Sequence correctly, but it doesn't. + def __getitem__(self: _UserStringT, i: Union[int, slice]) -> _UserStringT: ... # type: ignore + def __add__(self: _UserStringT, other: object) -> _UserStringT: ... + def __mul__(self: _UserStringT, n: int) -> _UserStringT: ... + def __mod__(self: _UserStringT, args: Any) -> _UserStringT: ... + def capitalize(self: _UserStringT) -> _UserStringT: ... + if sys.version_info >= (3, 5): + def casefold(self: _UserStringT) -> _UserStringT: ... + def center(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ... + def count(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ... + def encode(self: _UserStringT, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> _UserStringT: ... + def endswith(self, suffix: Union[str, Tuple[str, ...]], start: int = ..., end: int = ...) -> bool: ... + def expandtabs(self: _UserStringT, tabsize: int = ...) -> _UserStringT: ... + def find(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ... + def format(self, *args: Any, **kwds: Any) -> str: ... + if sys.version_info >= (3, 5): + def format_map(self, mapping: Mapping[str, Any]) -> str: ... + def index(self, sub: str, start: int = ..., end: int = ...) -> int: ... + def isalpha(self) -> bool: ... + def isalnum(self) -> bool: ... + def isdecimal(self) -> bool: ... + def isdigit(self) -> bool: ... + def isidentifier(self) -> bool: ... + def islower(self) -> bool: ... + def isnumeric(self) -> bool: ... + if sys.version_info >= (3, 5): + def isprintable(self) -> bool: ... + def isspace(self) -> bool: ... + def istitle(self) -> bool: ... + def isupper(self) -> bool: ... + def join(self, seq: Iterable[str]) -> str: ... + def ljust(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ... + def lower(self: _UserStringT) -> _UserStringT: ... + def lstrip(self: _UserStringT, chars: Optional[str] = ...) -> _UserStringT: ... + if sys.version_info >= (3, 5): + @staticmethod + @overload + def maketrans(x: Union[Dict[int, Any], Dict[str, Any]]) -> Dict[int, Any]: ... + @staticmethod + @overload + def maketrans(x: str, y: str, z: str = ...) -> Dict[int, Any]: ... + def partition(self, sep: str) -> Tuple[str, str, str]: ... + def replace(self: _UserStringT, old: Union[str, UserString], new: Union[str, UserString], maxsplit: int = ...) -> _UserStringT: ... + def rfind(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ... + def rindex(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ... + def rjust(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ... + def rpartition(self, sep: str) -> Tuple[str, str, str]: ... + def rstrip(self: _UserStringT, chars: Optional[str] = ...) -> _UserStringT: ... + def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ... + def rsplit(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ... + def splitlines(self, keepends: bool = ...) -> List[str]: ... + def startswith(self, prefix: Union[str, Tuple[str, ...]], start: int = ..., end: int = ...) -> bool: ... + def strip(self: _UserStringT, chars: Optional[str] = ...) -> _UserStringT: ... + def swapcase(self: _UserStringT) -> _UserStringT: ... + def title(self: _UserStringT) -> _UserStringT: ... + def translate(self: _UserStringT, *args: Any) -> _UserStringT: ... + def upper(self: _UserStringT) -> _UserStringT: ... + def zfill(self: _UserStringT, width: int) -> _UserStringT: ... -class UserDict(MutableMapping): ... -class UserList(MutableSequence): ... -class UserString(Sequence): ... -class MutableString(UserString, MutableSequence): ... # Technically, deque only derives from MutableSequence in 3.5. # But in practice it's not worth losing sleep over. @@ -62,11 +190,15 @@ class deque(MutableSequence[_T], Generic[_T]): maxlen: int = ...) -> None: ... def append(self, x: _T) -> None: ... def appendleft(self, x: _T) -> None: ... - def insert(self, i: int, x: _T) -> None: ... def clear(self) -> None: ... + if sys.version_info >= (3, 5): + def copy(self) -> deque[_T]: ... def count(self, x: _T) -> int: ... def extend(self, iterable: Iterable[_T]) -> None: ... def extendleft(self, iterable: Iterable[_T]) -> None: ... + if sys.version_info >= (3, 5): + def insert(self, i: int, x: _T) -> None: ... + def index(self, x: _T, start: int = ..., stop: int = ...) -> int: ... def pop(self, i: int = ...) -> _T: ... def popleft(self) -> _T: ... def remove(self, value: _T) -> None: ... @@ -94,28 +226,28 @@ class deque(MutableSequence[_T], Generic[_T]): def __delitem__(self, s: slice) -> None: raise TypeError def __contains__(self, o: object) -> bool: ... + def __reversed__(self) -> Iterator[_T]: ... - # TODO __reversed__ + if sys.version_info >= (3, 5): + def __add__(self, other: deque[_T]) -> deque[_T]: ... + def __mul__(self, other: int) -> deque[_T]: ... + def __imul__(self, other: int) -> None: ... class Counter(Dict[_T, int], Generic[_T]): @overload - def __init__(self) -> None: ... + def __init__(self, **kwargs: int) -> None: ... @overload - def __init__(self, Mapping: Mapping[_T, int]) -> None: ... + def __init__(self, mapping: Mapping[_T, int]) -> None: ... @overload def __init__(self, iterable: Iterable[_T]) -> None: ... - # TODO keyword arguments def elements(self) -> Iterator[_T]: ... - @overload - def most_common(self) -> List[_T]: ... - @overload - def most_common(self, n: int) -> List[_T]: ... + def most_common(self, n: Optional[int] = ...) -> List[Tuple[_T, int]]: ... @overload - def subtract(self, Mapping: Mapping[_T, int]) -> None: ... + def subtract(self, __mapping: Mapping[_T, int]) -> None: ... @overload def subtract(self, iterable: Iterable[_T]) -> None: ... @@ -131,16 +263,16 @@ class Counter(Dict[_T, int], Generic[_T]): @overload def update(self, **kwargs: int) -> None: ... - def __add__(self, other: typing.Counter[_T]) -> typing.Counter[_T]: ... - def __sub__(self, other: typing.Counter[_T]) -> typing.Counter[_T]: ... - def __and__(self, other: typing.Counter[_T]) -> typing.Counter[_T]: ... - def __or__(self, other: typing.Counter[_T]) -> typing.Counter[_T]: ... - def __pos__(self) -> typing.Counter[_T]: ... - def __neg__(self) -> typing.Counter[_T]: ... - def __iadd__(self, other: typing.Counter[_T]) -> typing.Counter[_T]: ... - def __isub__(self, other: typing.Counter[_T]) -> typing.Counter[_T]: ... - def __iand__(self, other: typing.Counter[_T]) -> typing.Counter[_T]: ... - def __ior__(self, other: typing.Counter[_T]) -> typing.Counter[_T]: ... + def __add__(self, other: Counter[_T]) -> Counter[_T]: ... + def __sub__(self, other: Counter[_T]) -> Counter[_T]: ... + def __and__(self, other: Counter[_T]) -> Counter[_T]: ... + def __or__(self, other: Counter[_T]) -> Counter[_T]: ... + def __pos__(self) -> Counter[_T]: ... + def __neg__(self) -> Counter[_T]: ... + def __iadd__(self, other: Counter[_T]) -> Counter[_T]: ... + def __isub__(self, other: Counter[_T]) -> Counter[_T]: ... + def __iand__(self, other: Counter[_T]) -> Counter[_T]: ... + def __ior__(self, other: Counter[_T]) -> Counter[_T]: ... class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]): def popitem(self, last: bool = ...) -> Tuple[_KT, _VT]: ... @@ -151,29 +283,21 @@ class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]): default_factory = ... # type: Callable[[], _VT] @overload - def __init__(self) -> None: ... + def __init__(self, **kwargs: _VT) -> None: ... @overload - def __init__(self, map: Mapping[_KT, _VT]) -> None: ... + def __init__(self, default_factory: Optional[Callable[[], _VT]]) -> None: ... @overload - def __init__(self, iterable: Iterable[Tuple[_KT, _VT]]) -> None: ... - @overload - def __init__(self, default_factory: Callable[[], _VT]) -> None: ... - @overload - def __init__(self, default_factory: Callable[[], _VT], + def __init__(self, default_factory: Optional[Callable[[], _VT]], map: Mapping[_KT, _VT]) -> None: ... @overload - def __init__(self, default_factory: Callable[[], _VT], + def __init__(self, default_factory: Optional[Callable[[], _VT]], iterable: Iterable[Tuple[_KT, _VT]]) -> None: ... - # TODO __init__ keyword args def __missing__(self, key: _KT) -> _VT: ... # TODO __reversed__ if sys.version_info >= (3, 3): class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]): - @overload - def __init__(self) -> None: ... - @overload def __init__(self, *maps: Mapping[_KT, _VT]) -> None: ... @property diff --git a/python/helpers/typeshed/stdlib/3/collections/abc.pyi b/python/helpers/typeshed/stdlib/3/collections/abc.pyi index 5106ec5139ee..38db036d453e 100644 --- a/python/helpers/typeshed/stdlib/3/collections/abc.pyi +++ b/python/helpers/typeshed/stdlib/3/collections/abc.pyi @@ -10,6 +10,7 @@ if sys.version_info >= (3, 3): Iterable as Iterable, Iterator as Iterator, Sized as Sized, + Callable as Callable, Mapping as Mapping, MutableMapping as MutableMapping, Sequence as Sequence, @@ -34,6 +35,7 @@ if sys.version_info >= (3, 5): if sys.version_info >= (3, 6): from . import ( + Collection as Collection, Reversible as Reversible, AsyncGenerator as AsyncGenerator, ) diff --git a/python/helpers/typeshed/stdlib/3/compileall.pyi b/python/helpers/typeshed/stdlib/3/compileall.pyi index d8093bf626a1..8d2731c05ed9 100644 --- a/python/helpers/typeshed/stdlib/3/compileall.pyi +++ b/python/helpers/typeshed/stdlib/3/compileall.pyi @@ -6,13 +6,15 @@ from typing import Optional, Union, Pattern if sys.version_info < (3, 6): _Path = Union[str, bytes] + _SuccessType = bool else: _Path = Union[str, bytes, os.PathLike] + _SuccessType = int -# fx can be any object with a 'search' method; once we have Protocols we can change the type +# rx can be any object with a 'search' method; once we have Protocols we can change the type if sys.version_info < (3, 5): - def compile_dir(dir: _Path, maxlevels: int = ..., ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ...) -> None: ... + def compile_dir(dir: _Path, maxlevels: int = ..., ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ...) -> _SuccessType: ... else: - def compile_dir(dir: _Path, maxlevels: int = ..., ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ..., workers: int = ...) -> None: ... -def compile_file(fullname: _Path, ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ...) -> None: ... -def compile_path(skip_curdir: bool = ..., maxlevels: int = ..., force: bool = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ...) -> None: ... + def compile_dir(dir: _Path, maxlevels: int = ..., ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ..., workers: int = ...) -> _SuccessType: ... +def compile_file(fullname: _Path, ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ...) -> _SuccessType: ... +def compile_path(skip_curdir: bool = ..., maxlevels: int = ..., force: bool = ..., quiet: int = ..., legacy: bool = ..., optimize: int = ...) -> _SuccessType: ... diff --git a/python/helpers/typeshed/stdlib/3/concurrent/futures/_base.pyi b/python/helpers/typeshed/stdlib/3/concurrent/futures/_base.pyi index 00ef5b6c343c..510b7c0ff687 100644 --- a/python/helpers/typeshed/stdlib/3/concurrent/futures/_base.pyi +++ b/python/helpers/typeshed/stdlib/3/concurrent/futures/_base.pyi @@ -1,9 +1,9 @@ from typing import TypeVar, Generic, Any, Iterable, Iterator, Callable, Tuple, Optional, Set from collections import namedtuple -FIRST_COMPLETED = ... # type: Any -FIRST_EXCEPTION = ... # type: Any -ALL_COMPLETED = ... # type: Any +FIRST_COMPLETED = ... # type: str +FIRST_EXCEPTION = ... # type: str +ALL_COMPLETED = ... # type: str PENDING = ... # type: Any RUNNING = ... # type: Any CANCELLED = ... # type: Any @@ -25,20 +25,20 @@ class Future(Generic[_T]): def cancelled(self) -> bool: ... def running(self) -> bool: ... def done(self) -> bool: ... - def add_done_callback(self, fn: Callable[[Future], Any]) -> None: ... + def add_done_callback(self, fn: Callable[[Future[_T]], Any]) -> None: ... def result(self, timeout: Optional[float] = ...) -> _T: ... - def exception(self, timeout: Optional[float] = ...) -> BaseException: ... + def exception(self, timeout: Optional[float] = ...) -> Optional[BaseException]: ... def set_running_or_notify_cancel(self) -> None: ... def set_result(self, result: _T) -> None: ... - def set_exception(self, exception: BaseException) -> None: ... + def set_exception(self, exception: Optional[BaseException]) -> None: ... class Executor: def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ... - def map(self, func: Callable[..., _T], *iterables: Any, timeout: Optional[float] = ..., chunksize: int = ...) -> Iterable[_T]: ... + def map(self, func: Callable[..., _T], *iterables: Iterable[Any], timeout: Optional[float] = ..., chunksize: int = ...) -> Iterator[_T]: ... def shutdown(self, wait: bool = ...) -> None: ... def __enter__(self) -> Executor: ... def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool: ... -def as_completed(fs: Iterable[Future], timeout: Optional[float] = ...) -> Iterator[Future]: ... +def as_completed(fs: Iterable[Future[_T]], timeout: Optional[float] = ...) -> Iterator[Future[_T]]: ... -def wait(fs: Iterable[Future], timeout: Optional[float] = ..., return_when: str = ...) -> Tuple[Set[Future], Set[Future]]: ... +def wait(fs: Iterable[Future[_T]], timeout: Optional[float] = ..., return_when: str = ...) -> Tuple[Set[Future[_T]], Set[Future[_T]]]: ... diff --git a/python/helpers/typeshed/stdlib/3/concurrent/futures/process.pyi b/python/helpers/typeshed/stdlib/3/concurrent/futures/process.pyi index b157d2b3388e..8076c2d0588e 100644 --- a/python/helpers/typeshed/stdlib/3/concurrent/futures/process.pyi +++ b/python/helpers/typeshed/stdlib/3/concurrent/futures/process.pyi @@ -1,14 +1,9 @@ -from typing import Any, Callable, TypeVar, Iterable, Optional +from typing import Optional, Any from ._base import Future, Executor EXTRA_QUEUED_CALLS = ... # type: Any class BrokenProcessPool(RuntimeError): ... -_T = TypeVar('_T') - class ProcessPoolExecutor(Executor): def __init__(self, max_workers: Optional[int] = ...) -> None: ... - def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ... - def map(self, func: Callable[..., _T], *iterables: Any, timeout: Optional[float] = ..., chunksize: int = ...) -> Iterable[_T]: ... - def shutdown(self, wait: bool = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/concurrent/futures/thread.pyi b/python/helpers/typeshed/stdlib/3/concurrent/futures/thread.pyi index e366d4d3a90f..88a45a3e070a 100644 --- a/python/helpers/typeshed/stdlib/3/concurrent/futures/thread.pyi +++ b/python/helpers/typeshed/stdlib/3/concurrent/futures/thread.pyi @@ -1,10 +1,10 @@ -from typing import Any, TypeVar, Callable, Iterable, Optional +from typing import Optional from ._base import Executor, Future - -_T = TypeVar('_T') +import sys class ThreadPoolExecutor(Executor): - def __init__(self, max_workers: Optional[int] = ...) -> None: ... - def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ... - def map(self, func: Callable[..., _T], *iterables: Any, timeout: Optional[float] = ..., chunksize: int = ...) -> Iterable[_T]: ... - def shutdown(self, wait: bool = ...) -> None: ... + if sys.version_info >= (3, 6): + def __init__(self, max_workers: Optional[int] = ..., + thread_name_prefix: str = ...) -> None: ... + else: + def __init__(self, max_workers: Optional[int] = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/configparser.pyi b/python/helpers/typeshed/stdlib/3/configparser.pyi index 22a42a14c56d..33d6fce0f5a7 100644 --- a/python/helpers/typeshed/stdlib/3/configparser.pyi +++ b/python/helpers/typeshed/stdlib/3/configparser.pyi @@ -1,21 +1,30 @@ -# Stubs for configparser - # Based on http://docs.python.org/3.5/library/configparser.html and on # reading configparser.py. -from typing import (MutableMapping, Mapping, Dict, Sequence, List, Union, - Iterable, Iterator, Callable, Any, IO, overload, Optional) +import sys +from typing import (AbstractSet, MutableMapping, Mapping, Dict, Sequence, List, + Union, Iterable, Iterator, Callable, Any, IO, overload, + Optional, Pattern, Type, TypeVar) # Types only used in type comments only from typing import Optional, Tuple # noqa +if sys.version_info >= (3, 6): + from os import PathLike + # Internal type aliases -_section = Dict[str, str] +_section = Mapping[str, str] _parser = MutableMapping[str, _section] -_converters = Dict[str, Callable[[str], Any]] +_converter = Callable[[str], Any] +_converters = Dict[str, _converter] +_T = TypeVar('_T') +if sys.version_info >= (3, 6): + _Path = Union[str, PathLike[str]] +else: + _Path = str -DEFAULTSECT = ... # type: str - +DEFAULTSECT: str +MAX_INTERPOLATION_DEPTH: int class Interpolation: def before_get(self, parser: _parser, @@ -40,31 +49,28 @@ class Interpolation: value: str) -> str: ... -class BasicInterpolation(Interpolation): - pass - - -class ExtendedInterpolation(Interpolation): - pass +class BasicInterpolation(Interpolation): ... +class ExtendedInterpolation(Interpolation): ... +class LegacyInterpolation(Interpolation): ... class RawConfigParser(_parser): def __init__(self, - defaults: _section = None, - dict_type: Mapping[str, str] = ..., + defaults: Optional[_section] = ..., + dict_type: Type[Mapping[str, str]] = ..., allow_no_value: bool = ..., *, delimiters: Sequence[str] = ..., comment_prefixes: Sequence[str] = ..., - inline_comment_prefixes: Sequence[str] = None, + inline_comment_prefixes: Optional[Sequence[str]] = ..., strict: bool = ..., empty_lines_in_values: bool = ..., default_section: str = ..., - interpolation: Interpolation = None) -> None: ... + interpolation: Optional[Interpolation] = ...) -> None: ... def __len__(self) -> int: ... - def __getitem__(self, section: str) -> _section: ... + def __getitem__(self, section: str) -> SectionProxy: ... def __setitem__(self, section: str, options: _section) -> None: ... @@ -84,28 +90,35 @@ class RawConfigParser(_parser): def has_option(self, section: str, option: str) -> bool: ... - def read(self, filenames: Union[str, Sequence[str]], - encoding: str = None) -> List[str]: ... + def read(self, filenames: Union[_Path, Iterable[_Path]], + encoding: Optional[str] = None) -> List[str]: ... - def read_file(self, f: Iterable[str], source: str = None) -> None: ... + def read_file(self, f: Iterable[str], source: Optional[str] = None) -> None: ... def read_string(self, string: str, source: str = ...) -> None: ... def read_dict(self, dictionary: Mapping[str, Mapping[str, Any]], source: str = ...) -> None: ... + # These get* methods are partially applied (with the same names) in + # SectionProxy; the stubs should be kept updated together def getint(self, section: str, option: str, *, raw: bool = ..., vars: _section = ..., fallback: int = ...) -> int: ... def getfloat(self, section: str, option: str, *, raw: bool = ..., vars: _section = ..., fallback: float = ...) -> float: ... def getboolean(self, section: str, option: str, *, raw: bool = ..., vars: _section = ..., fallback: bool = ...) -> bool: ... + def _get_conv(self, section: str, option: str, conv: Callable[[str], _T], *, raw: bool = ..., vars: _section = ..., fallback: _T = ...) -> _T: ... + # This is incompatible with MutableMapping so we ignore the type def get(self, section: str, option: str, *, raw: bool = ..., vars: _section = ..., fallback: str = ...) -> str: # type: ignore ... - # This is incompatible with Mapping so we ignore the type. - def items(self, section: str = ..., raw: bool = ..., vars: _section = ...) -> Iterable[Tuple[str, _section]]: ... # type: ignore + @overload + def items(self, *, raw: bool = ..., vars: _section = ...) -> AbstractSet[Tuple[str, SectionProxy]]: ... + + @overload + def items(self, section: str, raw: bool = ..., vars: _section = ...) -> List[Tuple[str, str]]: ... def set(self, section: str, option: str, value: str) -> None: ... @@ -122,18 +135,52 @@ class RawConfigParser(_parser): class ConfigParser(RawConfigParser): def __init__(self, - defaults: _section = None, + defaults: Optional[_section] = None, dict_type: Mapping[str, str] = ..., allow_no_value: bool = ..., delimiters: Sequence[str] = ..., comment_prefixes: Sequence[str] = ..., - inline_comment_prefixes: Sequence[str] = None, + inline_comment_prefixes: Optional[Sequence[str]] = None, strict: bool = ..., empty_lines_in_values: bool = ..., default_section: str = ..., - interpolation: Interpolation = None, + interpolation: Optional[Interpolation] = None, converters: _converters = ...) -> None: ... +class SafeConfigParser(ConfigParser): ... + +class SectionProxy(MutableMapping[str, str]): + def __init__(self, parser: RawConfigParser, name: str) -> None: ... + def __getitem__(self, key: str) -> str: ... + def __setitem__(self, key: str, value: str) -> None: ... + def __delitem__(self, key: str) -> None: ... + def __contains__(self, key: object) -> bool: ... + def __len__(self) -> int: ... + def __iter__(self) -> Iterator[str]: ... + @property + def parser(self) -> RawConfigParser: ... + @property + def name(self) -> str: ... + def get(self, option: str, fallback: Optional[str] = ..., *, raw: bool = ..., vars: Optional[_section] = ..., **kwargs: Any) -> str: ... # type: ignore + + # These are partially-applied version of the methods with the same names in + # RawConfigParser; the stubs should be kept updated together + def getint(self, option: str, *, raw: bool = ..., vars: _section = ..., fallback: int = ...) -> int: ... + def getfloat(self, option: str, *, raw: bool = ..., vars: _section = ..., fallback: float = ...) -> float: ... + def getboolean(self, option: str, *, raw: bool = ..., vars: _section = ..., fallback: bool = ...) -> bool: ... + + # SectionProxy can have arbitrary attributes when custon converters are used + def __getattr__(self, key: str) -> Callable[..., Any]: ... + +class ConverterMapping(MutableMapping[str, Optional[_converter]]): + GETTERCRE: Pattern + def __init__(self, parser: RawConfigParser) -> None: ... + def __getitem__(self, key: str) -> _converter: ... + def __setitem__(self, key: str, value: Optional[_converter]) -> None: ... + def __delitem__(self, key: str) -> None: ... + def __iter__(self) -> Iterator[str]: ... + def __len__(self) -> int: ... + class Error(Exception): pass diff --git a/python/helpers/typeshed/stdlib/3/curses/__init__.pyi b/python/helpers/typeshed/stdlib/3/curses/__init__.pyi index 63a4bd9f07ea..078a6cd3ae40 100644 --- a/python/helpers/typeshed/stdlib/3/curses/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/curses/__init__.pyi @@ -1,12 +1,6 @@ -# Stubs for curses (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - +import _curses from _curses import * # noqa: F403 -# Stubgen imports a python version of has_key only if it's not present -# in _curses (which it is in this stub) -# from .has_key import has_key as has_key -def initscr(): ... +def initscr() -> _curses._CursesWindow: ... def start_color(): ... def wrapper(func, *args, **kwds): ... diff --git a/python/helpers/typeshed/stdlib/3/datetime.pyi b/python/helpers/typeshed/stdlib/3/datetime.pyi index e81f9c8da3e3..8b1b2e45a1b0 100644 --- a/python/helpers/typeshed/stdlib/3/datetime.pyi +++ b/python/helpers/typeshed/stdlib/3/datetime.pyi @@ -1,13 +1,10 @@ -# Stubs for datetime - -# NOTE: These are incomplete! import sys from typing import Optional, SupportsAbs, Tuple, overload MINYEAR = 0 MAXYEAR = 0 -TimeTuple = Tuple[int, int, int, int, int, int, int, int, int] +_TimeTuple = Tuple[int, int, int, int, int, int, int, int, int] class tzinfo: def tzname(self, dt: Optional[datetime]) -> str: ... @@ -191,9 +188,9 @@ class datetime: def strftime(self, fmt: str) -> str: ... def __format__(self, fmt: str) -> str: ... def toordinal(self) -> int: ... - def timetuple(self) -> TimeTuple: ... # TODO return type + def timetuple(self) -> _TimeTuple: ... def timestamp(self) -> float: ... - def utctimetuple(self) -> TimeTuple: ... # TODO return type + def utctimetuple(self) -> _TimeTuple: ... def date(self) -> _date: ... def time(self) -> _time: ... def timetz(self) -> _time: ... diff --git a/python/helpers/typeshed/stdlib/3/email/contentmanager.pyi b/python/helpers/typeshed/stdlib/3/email/contentmanager.pyi index 6f37fbabd11d..6b1f2d12fd87 100644 --- a/python/helpers/typeshed/stdlib/3/email/contentmanager.pyi +++ b/python/helpers/typeshed/stdlib/3/email/contentmanager.pyi @@ -2,14 +2,10 @@ from typing import Any, Callable import sys -import email.message from email.message import Message if sys.version_info >= (3, 4): - EmailMessage = email.message.EmailMessage - MIMEPart = email.message.MIMEPart - class ContentManager: def __init__(self) -> None: ... def get_content(self, msg: Message, *args: Any, **kw: Any) -> Any: ... diff --git a/python/helpers/typeshed/stdlib/3/email/headerregistry.pyi b/python/helpers/typeshed/stdlib/3/email/headerregistry.pyi index a39f0e21ad09..6f14cc0b972b 100644 --- a/python/helpers/typeshed/stdlib/3/email/headerregistry.pyi +++ b/python/helpers/typeshed/stdlib/3/email/headerregistry.pyi @@ -1,6 +1,6 @@ # Stubs for email.headerregistry (Python 3.4) -import datetime as dt +from datetime import datetime as _datetime import sys from typing import Dict, Tuple, Optional, Any, Union, Mapping from email.errors import MessageDefect @@ -27,9 +27,9 @@ if sys.version_info >= (3, 3): class UniqueUnstructuredHeader(UnstructuredHeader): ... class DateHeader: - datetime = ... # type: dt.datetime + datetime = ... # type: _datetime @classmethod - def parse(cls, string: Union[str, dt.datetime], + def parse(cls, string: Union[str, _datetime], kwds: Dict[str, Any]) -> None: ... class UniqueDateHeader(DateHeader): ... @@ -68,7 +68,7 @@ if sys.version_info >= (3, 3): class ContentDispositionHeader(ParameterizedMIMEHeader): content_disposition = ... # type: str - class ContentTransferEncoding: + class ContentTransferEncodingHeader: cte = ... # type: str @classmethod def parse(cls, string: str, kwds: Dict[str, Any]) -> None: ... @@ -97,6 +97,5 @@ if sys.version_info >= (3, 3): display_name = ... # type: Optional[str] addresses = ... # type: Tuple[Address, ...] def __init__(self, display_name: Optional[str] = ..., - addresses: Optional[Tuple[Address, ...]] = ...) \ - -> None: ... + addresses: Optional[Tuple[Address, ...]] = ...) -> None: ... def __str__(self) -> str: ... diff --git a/python/helpers/typeshed/stdlib/3/email/message.pyi b/python/helpers/typeshed/stdlib/3/email/message.pyi index 3acd111dd5c7..8244939688b4 100644 --- a/python/helpers/typeshed/stdlib/3/email/message.pyi +++ b/python/helpers/typeshed/stdlib/3/email/message.pyi @@ -29,8 +29,7 @@ class Message: def set_unixfrom(self, unixfrom: str) -> None: ... def get_unixfrom(self) -> Optional[str]: ... def attach(self, payload: 'Message') -> None: ... - def get_payload(self, i: int = ..., decode: bool = ...) \ - -> Optional[_PayloadType]: ... + def get_payload(self, i: int = ..., decode: bool = ...) -> Optional[_PayloadType]: ... def set_payload(self, payload: _PayloadType, charset: _CharsetType = ...) -> None: ... def set_charset(self, charset: _CharsetType) -> None: ... @@ -45,8 +44,7 @@ class Message: def items(self) -> List[Tuple[str, str]]: ... def get(self, name: str, failobj: _T = ...) -> Union[str, _T]: ... def get_all(self, name: str, failobj: _T = ...) -> Union[List[str], _T]: ... - def add_header(self, _name: str, _value: str, **_params: _ParamsType) \ - -> None: ... + def add_header(self, _name: str, _value: str, **_params: _ParamsType) -> None: ... def replace_header(self, _name: str, _value: str) -> None: ... def get_content_type(self) -> str: ... def get_content_maintype(self) -> str: ... diff --git a/python/helpers/typeshed/stdlib/3/email/mime/__init__.pyi b/python/helpers/typeshed/stdlib/3/email/mime/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/python/helpers/typeshed/stdlib/3/encodings/utf_8.pyi b/python/helpers/typeshed/stdlib/3/encodings/utf_8.pyi index 0111184b7fc7..d38bd58d0e43 100644 --- a/python/helpers/typeshed/stdlib/3/encodings/utf_8.pyi +++ b/python/helpers/typeshed/stdlib/3/encodings/utf_8.pyi @@ -1,14 +1,15 @@ import codecs +from typing import Text, Tuple class IncrementalEncoder(codecs.IncrementalEncoder): - pass + def encode(self, input: Text, final: bool = ...) -> bytes: ... + class IncrementalDecoder(codecs.BufferedIncrementalDecoder): - pass -class StreamWriter(codecs.StreamWriter): - pass -class StreamReader(codecs.StreamReader): - pass + def _buffer_decode(self, input: bytes, errors: str, final: bool) -> Tuple[Text, int]: ... + +class StreamWriter(codecs.StreamWriter): ... +class StreamReader(codecs.StreamReader): ... def getregentry() -> codecs.CodecInfo: ... -def encode(input: str, errors: str = ...) -> bytes: ... -def decode(input: bytes, errors: str = ...) -> str: ... +def encode(input: Text, errors: Text = ...) -> bytes: ... +def decode(input: bytes, errors: Text = ...) -> Text: ... diff --git a/python/helpers/typeshed/stdlib/3/fcntl.pyi b/python/helpers/typeshed/stdlib/3/fcntl.pyi index a50fa0d87e5c..1ff20d60d7c6 100644 --- a/python/helpers/typeshed/stdlib/3/fcntl.pyi +++ b/python/helpers/typeshed/stdlib/3/fcntl.pyi @@ -1,6 +1,6 @@ # Stubs for fcntl +from io import IOBase from typing import Any, IO, Union -import typing FASYNC = ... # type: int FD_CLOEXEC = ... # type: int @@ -75,7 +75,7 @@ LOCK_SH = ... # type: int LOCK_UN = ... # type: int LOCK_WRITE = ... # type: int -_AnyFile = Union[int, IO[Any]] +_AnyFile = Union[int, IO[Any], IOBase] # TODO All these return either int or bytes depending on the value of # cmd (not on the type of arg). diff --git a/python/helpers/typeshed/stdlib/3/functools.pyi b/python/helpers/typeshed/stdlib/3/functools.pyi index b4295c47646b..7f048dce2b15 100644 --- a/python/helpers/typeshed/stdlib/3/functools.pyi +++ b/python/helpers/typeshed/stdlib/3/functools.pyi @@ -1,11 +1,5 @@ -# Stubs for functools (Python 3) - -# NOTE: These are incomplete! - -from abc import ABCMeta, abstractmethod import sys -from typing import Any, Callable, Generic, Dict, Iterable, Mapping, Optional, Sequence, Tuple, TypeVar, NamedTuple, overload -from collections import namedtuple +from typing import Any, Callable, Generic, Dict, Iterable, Mapping, Optional, Sequence, Tuple, Type, TypeVar, NamedTuple, Union, overload _AnyCallable = Callable[..., Any] @@ -19,15 +13,17 @@ def reduce(function: Callable[[_T, _T], _T], sequence: Iterable[_T]) -> _T: ... -class CacheInfo(NamedTuple('CacheInfo', [ - ('hits', int), ('misses', int), ('maxsize', int), ('currsize', int)]) -): - ... +class _CacheInfo(NamedTuple('CacheInfo', [ + ('hits', int), + ('misses', int), + ('maxsize', int), + ('currsize', int) +])): ... class _lru_cache_wrapper(Generic[_T]): __wrapped__ = ... # type: Callable[..., _T] def __call__(self, *args: Any, **kwargs: Any) -> _T: ... - def cache_info(self) -> CacheInfo: ... + def cache_info(self) -> _CacheInfo: ... class lru_cache(): def __init__(self, maxsize: Optional[int] = ..., typed: bool = ...) -> None: ... @@ -38,7 +34,7 @@ WRAPPER_ASSIGNMENTS = ... # type: Sequence[str] WRAPPER_UPDATES = ... # type: Sequence[str] def update_wrapper(wrapper: _AnyCallable, wrapped: _AnyCallable, assigned: Sequence[str] = ..., - updated: Sequence[str] = ...) -> None: ... + updated: Sequence[str] = ...) -> _AnyCallable: ... def wraps(wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> Callable[[_AnyCallable], _AnyCallable]: ... def total_ordering(cls: type) -> type: ... def cmp_to_key(mycmp: Callable[[_T, _T], int]) -> Callable[[_T], Any]: ... @@ -51,6 +47,22 @@ class partial(Generic[_T]): def __call__(self, *args: Any, **kwargs: Any) -> _T: ... if sys.version_info >= (3, 4): + # With protocols, this could change into a generic protocol that defines __get__ and returns _T + _Descriptor = Any + + class partialmethod(Generic[_T]): + func: Union[Callable[..., _T], _Descriptor] + args: Tuple[Any, ...] + keywords: Dict[str, Any] + + @overload + def __init__(self, func: Callable[..., _T], *args: Any, **keywords: Any) -> None: ... + @overload + def __init__(self, func: _Descriptor, *args: Any, **keywords: Any) -> None: ... + def __get__(self, obj: Any, cls: Type[Any]) -> Callable[..., _T]: ... + @property + def __isabstractmethod__(self) -> bool: ... + class _SingleDispatchCallable(Generic[_T]): registry = ... # type: Mapping[Any, Callable[..., _T]] def dispatch(self, cls: Any) -> Callable[..., _T]: ... diff --git a/python/helpers/typeshed/stdlib/3/getpass.pyi b/python/helpers/typeshed/stdlib/3/getpass.pyi index 73c0cb91866c..f55023c95701 100644 --- a/python/helpers/typeshed/stdlib/3/getpass.pyi +++ b/python/helpers/typeshed/stdlib/3/getpass.pyi @@ -1,9 +1,9 @@ # Stubs for getpass -from typing import TextIO +from typing import Optional, TextIO -def getpass(prompt: str = ..., stream: TextIO = None) -> str: ... +def getpass(prompt: str = ..., stream: Optional[TextIO] = None) -> str: ... def getuser() -> str: ... diff --git a/python/helpers/typeshed/stdlib/3/glob.pyi b/python/helpers/typeshed/stdlib/3/glob.pyi index ab58e9acb53e..f36d26c641e3 100644 --- a/python/helpers/typeshed/stdlib/3/glob.pyi +++ b/python/helpers/typeshed/stdlib/3/glob.pyi @@ -4,6 +4,13 @@ from typing import List, Iterator, AnyStr import sys +if sys.version_info >= (3, 6): + def glob0(dirname: AnyStr, pattern: AnyStr) -> List[AnyStr]: ... +else: + def glob0(dirname: AnyStr, basename: AnyStr) -> List[AnyStr]: ... + +def glob1(dirname: AnyStr, pattern: AnyStr) -> List[AnyStr]: ... + if sys.version_info >= (3, 5): def glob(pathname: AnyStr, *, recursive: bool = ...) -> List[AnyStr]: ... def iglob(pathname: AnyStr, *, recursive: bool = ...) -> Iterator[AnyStr]: ... diff --git a/python/helpers/typeshed/stdlib/3/gzip.pyi b/python/helpers/typeshed/stdlib/3/gzip.pyi index 44d806424c86..c4420fb1c1a1 100644 --- a/python/helpers/typeshed/stdlib/3/gzip.pyi +++ b/python/helpers/typeshed/stdlib/3/gzip.pyi @@ -1,7 +1,3 @@ -# Stubs for gzip (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any import _compression diff --git a/python/helpers/typeshed/stdlib/3/hashlib.pyi b/python/helpers/typeshed/stdlib/3/hashlib.pyi index fd47015d5b98..64ef70739c9d 100644 --- a/python/helpers/typeshed/stdlib/3/hashlib.pyi +++ b/python/helpers/typeshed/stdlib/3/hashlib.pyi @@ -1,11 +1,12 @@ # Stubs for hashlib +import sys from abc import abstractmethod, ABCMeta -from typing import AbstractSet, Union +from typing import AbstractSet, Optional, Union _DataType = Union[bytes, bytearray, memoryview] -class Hash(metaclass=ABCMeta): +class _Hash(metaclass=ABCMeta): digest_size = ... # type: int block_size = ... # type: int @@ -21,20 +22,57 @@ class Hash(metaclass=ABCMeta): @abstractmethod def hexdigest(self) -> str: ... @abstractmethod - def copy(self) -> 'Hash': ... + def copy(self) -> _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 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: _DataType = ...) -> 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 -def pbkdf2_hmac(name: str, password: _DataType, salt: _DataType, rounds: int, dklen: int = ...) -> bytes: ... +if sys.version_info >= (3, 4): + def pbkdf2_hmac(hash_name: str, password: _DataType, salt: _DataType, iterations: int, dklen: Optional[int] = ...) -> bytes: ... + +if sys.version_info >= (3, 6): + class _VarLenHash(metaclass=ABCMeta): + digest_size = ... # type: int + block_size = ... # type: int + name = ... # type: str + + @abstractmethod + def digest(self, length: int) -> bytes: ... + @abstractmethod + def hexdigest(self, length: int) -> str: ... + @abstractmethod + def update(self, arg: _DataType) -> None: ... + @abstractmethod + def copy(self) -> _VarLenHash: ... + + def sha3_224(arg: _DataType = ...) -> _Hash: ... + def sha3_256(arg: _DataType = ...) -> _Hash: ... + def sha3_384(arg: _DataType = ...) -> _Hash: ... + def sha3_512(arg: _DataType = ...) -> _Hash: ... + + def shake_128(arg: _DataType = ...) -> _VarLenHash: ... + def shake_256(arg: _DataType = ...) -> _VarLenHash: ... + + def scrypt(password: _DataType, *, salt: _DataType, n: int, r: int, p: int, maxmem: int = ..., dklen: int = ...) -> bytes: ... + + class _BlakeHash(_Hash): + MAX_DIGEST_SIZE = ... # type: int + MAX_KEY_SIZE = ... # type: int + PERSON_SIZE = ... # type: int + SALT_SIZE = ... # type: int + + def __init__(self, data: _DataType, digest_size: int = ..., key: _DataType = ..., salt: _DataType = ..., person: _DataType = ..., fanout: int = ..., depth: int = ..., leaf_size: int = ..., node_offset: int = ..., node_depth: int = ..., inner_size: int = ..., last_node: bool = ...) -> None: ... + + blake2b = _BlakeHash + blake2s = _BlakeHash diff --git a/python/helpers/typeshed/stdlib/3/heapq.pyi b/python/helpers/typeshed/stdlib/3/heapq.pyi index f56ae72043ad..5c49dfac1e98 100644 --- a/python/helpers/typeshed/stdlib/3/heapq.pyi +++ b/python/helpers/typeshed/stdlib/3/heapq.pyi @@ -3,7 +3,7 @@ # Based on http://docs.python.org/3.2/library/heapq.html import sys -from typing import TypeVar, List, Iterable, Any, Callable +from typing import TypeVar, List, Iterable, Any, Callable, Optional _T = TypeVar('_T') @@ -18,6 +18,6 @@ if sys.version_info >= (3, 5): else: def merge(*iterables: Iterable[_T]) -> Iterable[_T]: ... def nlargest(n: int, iterable: Iterable[_T], - key: Callable[[_T], Any] = ...) -> List[_T]: ... + key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ... def nsmallest(n: int, iterable: Iterable[_T], key: Callable[[_T], Any] = ...) -> List[_T]: ... diff --git a/python/helpers/typeshed/stdlib/3/html/entities.pyi b/python/helpers/typeshed/stdlib/3/html/entities.pyi index b3fa66bc9421..470217b0f40a 100644 --- a/python/helpers/typeshed/stdlib/3/html/entities.pyi +++ b/python/helpers/typeshed/stdlib/3/html/entities.pyi @@ -1,7 +1,3 @@ -# Stubs for html.entities (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any name2codepoint = ... # type: Any diff --git a/python/helpers/typeshed/stdlib/3/http/client.pyi b/python/helpers/typeshed/stdlib/3/http/client.pyi index 340f090332e2..30f45d845cdd 100644 --- a/python/helpers/typeshed/stdlib/3/http/client.pyi +++ b/python/helpers/typeshed/stdlib/3/http/client.pyi @@ -1,5 +1,3 @@ -# Stubs for http.client (Python 3.4) - from typing import ( Any, Dict, IO, Iterable, List, Iterator, Mapping, Optional, Tuple, TypeVar, Union, @@ -178,6 +176,7 @@ class HTTPSConnection(HTTPConnection): check_hostname: Optional[bool] = ...) -> None: ... class HTTPException(Exception): ... +error = HTTPException class NotConnected(HTTPException): ... class InvalidURL(HTTPException): ... diff --git a/python/helpers/typeshed/stdlib/3/http/cookiejar.pyi b/python/helpers/typeshed/stdlib/3/http/cookiejar.pyi index 38de5a33c3b9..3cacc27c4a36 100644 --- a/python/helpers/typeshed/stdlib/3/http/cookiejar.pyi +++ b/python/helpers/typeshed/stdlib/3/http/cookiejar.pyi @@ -1,5 +1,3 @@ -# Stubs for http.cookiejar (Python 3.4) - from typing import Iterable, Iterator, Optional, Sequence, Tuple, TypeVar, Union, overload from http.client import HTTPResponse import sys @@ -28,6 +26,7 @@ class CookieJar(Iterable['Cookie']): name: str = ...) -> None: ... def clear_session_cookies(self) -> None: ... def __iter__(self) -> Iterator['Cookie']: ... + def __len__(self) -> int: ... class FileCookieJar(CookieJar): filename = ... # type: str @@ -83,8 +82,7 @@ class DefaultCookiePolicy(CookiePolicy): def set_blocked_domains(self, blocked_domains: Sequence[str]) -> None: ... def is_blocked(self, domain: str) -> bool: ... def allowed_domains(self) -> Optional[Tuple[str, ...]]: ... - def set_allowed_domains(self, allowed_domains: Optional[Sequence[str]]) \ - -> None: ... + def set_allowed_domains(self, allowed_domains: Optional[Sequence[str]]) -> None: ... def is_not_allowed(self, domain: str) -> bool: ... diff --git a/python/helpers/typeshed/stdlib/3/imp.pyi b/python/helpers/typeshed/stdlib/3/imp.pyi index 3abe628cdb03..33440910a1c0 100644 --- a/python/helpers/typeshed/stdlib/3/imp.pyi +++ b/python/helpers/typeshed/stdlib/3/imp.pyi @@ -1,10 +1,55 @@ -# Stubs for imp +# Stubs for imp (Python 3.6) -# NOTE: These are incomplete! +import os +import sys +import types +from typing import Any, IO, List, Optional, Tuple, TypeVar, Union -from typing import TypeVar +from _imp import (lock_held as lock_held, acquire_lock as acquire_lock, release_lock as release_lock, + get_frozen_object as get_frozen_object, is_frozen_package as is_frozen_package, + init_frozen as init_frozen, is_builtin as is_builtin, is_frozen as is_frozen) + +if sys.version_info >= (3, 5): + from _imp import create_dynamic as create_dynamic _T = TypeVar('_T') -def cache_from_source(path: str, debug_override: bool = ...) -> str: ... -def reload(module: _T) -> _T: ... # TODO imprecise signature +if sys.version_info >= (3, 6): + _Path = Union[str, os.PathLike[str]] +else: + _Path = str + +SEARCH_ERROR: int +PY_SOURCE: int +PY_COMPILED: int +C_EXTENSION: int +PY_RESOURCE: int +PKG_DIRECTORY: int +C_BUILTIN: int +PY_FROZEN: int +PY_CODERESOURCE: int +IMP_HOOK: int + +def new_module(name: str) -> types.ModuleType: ... +def get_magic() -> bytes: ... +def get_tag() -> str: ... +def cache_from_source(path: _Path, debug_override: Optional[bool] = ...) -> str: ... +def source_from_cache(path: _Path) -> str: ... +def get_suffixes() -> List[Tuple[str, str, int]]: ... + +class NullImporter: + def __init__(self, path: _Path) -> None: ... + def find_module(self, fullname: Any) -> None: ... + +# PathLike doesn't work for the pathname argument here +def load_source(name: str, pathname: str, file: Optional[IO[Any]] = ...) -> types.ModuleType: ... +def load_compiled(name: str, pathname: str, file: Optional[IO[Any]] = ...) -> types.ModuleType: ... +def load_package(name: str, path: _Path) -> types.ModuleType: ... +def load_module(name: str, file: IO[Any], filename: str, details: Tuple[str, str, int]) -> types.ModuleType: ... +if sys.version_info >= (3, 6): + def find_module(name: str, path: Union[None, List[str], List[os.PathLike[str]], List[_Path]] = ...) -> Tuple[str, str, Tuple[IO[Any], str, int]]: ... +else: + def find_module(name: str, path: Optional[List[str]] = ...) -> Tuple[str, str, Tuple[IO[Any], str, int]]: ... +def reload(module: types.ModuleType) -> types.ModuleType: ... +def init_builtin(name: str) -> Optional[types.ModuleType]: ... +def load_dynamic(name: str, path: str, file: Optional[IO[Any]] = ...) -> types.ModuleType: ... diff --git a/python/helpers/typeshed/stdlib/3/importlib/__init__.pyi b/python/helpers/typeshed/stdlib/3/importlib/__init__.pyi index 7969a3cfe2ce..08b3a818853f 100644 --- a/python/helpers/typeshed/stdlib/3/importlib/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/importlib/__init__.pyi @@ -1,16 +1,18 @@ +from importlib import util from importlib.abc import Loader import sys import types from typing import Any, Mapping, Optional, Sequence -def __import__(name: str, globals: Mapping[str, Any] = None, - locals: Mapping[str, Any] = None, fromlist: Sequence[str] = (), - level: int = 0) -> types.ModuleType: ... +def __import__(name: str, globals: Optional[Mapping[str, Any]] = None, + locals: Optional[Mapping[str, Any]] = None, + fromlist: Sequence[str] = ..., + level: int = ...) -> types.ModuleType: ... -def import_module(name: str, package: str = None) -> types.ModuleType: ... +def import_module(name: str, package: Optional[str] = None) -> types.ModuleType: ... if sys.version_info >= (3, 3): - def find_loader(name: str, path: str = None) -> Optional[Loader]: ... + def find_loader(name: str, path: Optional[str] = None) -> Optional[Loader]: ... def invalidate_caches() -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/importlib/abc.pyi b/python/helpers/typeshed/stdlib/3/importlib/abc.pyi index 6ae74d6f7120..f7cd81d21f43 100644 --- a/python/helpers/typeshed/stdlib/3/importlib/abc.pyi +++ b/python/helpers/typeshed/stdlib/3/importlib/abc.pyi @@ -19,7 +19,7 @@ class Finder(metaclass=ABCMeta): # easier to simply ignore that this method exists. # @abstractmethod # def find_module(self, fullname: str, - # path: Sequence[_Path] = None) -> Optional[Loader]: ... + # path: Optional[Sequence[_Path]] = None) -> Optional[Loader]: ... class ResourceLoader(Loader): @abstractmethod @@ -35,11 +35,11 @@ class InspectLoader(Loader): def exec_module(self, module: types.ModuleType) -> None: ... if sys.version_info[:2] == (3, 4): def source_to_code(self, data: Union[bytes, str], - path: str = '') -> types.CodeType: ... + path: str = ...) -> types.CodeType: ... elif sys.version_info >= (3, 5): @staticmethod def source_to_code(data: Union[bytes, str], - path: str = '') -> types.CodeType: ... + path: str = ...) -> types.CodeType: ... class ExecutionLoader(InspectLoader): @abstractmethod @@ -64,7 +64,7 @@ if sys.version_info >= (3, 3): # Not defined on the actual class, but expected to exist. def find_spec( self, fullname: str, path: Optional[Sequence[_Path]], - target: types.ModuleType = None + target: Optional[types.ModuleType] = None ) -> Optional[ModuleSpec]: ... @@ -78,7 +78,7 @@ if sys.version_info >= (3, 3): # Not defined on the actual class, but expected to exist. def find_spec( self, fullname: str, - target: types.ModuleType = None + target: Optional[types.ModuleType] = None ) -> Optional[ModuleSpec]: ... class FileLoader(ResourceLoader, ExecutionLoader): diff --git a/python/helpers/typeshed/stdlib/3/importlib/machinery.pyi b/python/helpers/typeshed/stdlib/3/importlib/machinery.pyi index 78aaf80aa681..f9e1907bd7ff 100644 --- a/python/helpers/typeshed/stdlib/3/importlib/machinery.pyi +++ b/python/helpers/typeshed/stdlib/3/importlib/machinery.pyi @@ -22,7 +22,7 @@ if sys.version_info >= (3, 3): @classmethod def find_spec(cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]], - target: types.ModuleType = None) -> Optional[ModuleSpec]: + target: Optional[types.ModuleType] = None) -> Optional[ModuleSpec]: ... # InspectLoader @classmethod @@ -30,9 +30,9 @@ if sys.version_info >= (3, 3): @classmethod def load_module(cls, fullname: str) -> types.ModuleType: ... @classmethod - def get_code(cls, fullname: str) -> None: ... # type: ignore + def get_code(cls, fullname: str) -> None: ... @classmethod - def get_source(cls, fullname: str) -> None: ... # type: ignore + def get_source(cls, fullname: str) -> None: ... # Loader @classmethod def load_module(cls, fullname: str) -> types.ModuleType: ... @@ -59,9 +59,9 @@ else: @classmethod def load_module(cls, fullname: str) -> types.ModuleType: ... @classmethod - def get_code(cls, fullname: str) -> None: ... # type: ignore + def get_code(cls, fullname: str) -> None: ... @classmethod - def get_source(cls, fullname: str) -> None: ... # type: ignore + def get_source(cls, fullname: str) -> None: ... # Loader @classmethod def load_module(cls, fullname: str) -> types.ModuleType: ... @@ -79,7 +79,7 @@ if sys.version_info >= (3, 3): @classmethod def find_spec(cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]], - target: types.ModuleType = None) -> Optional[ModuleSpec]: + target: Optional[types.ModuleType] = None) -> Optional[ModuleSpec]: ... # InspectLoader @classmethod @@ -87,9 +87,9 @@ if sys.version_info >= (3, 3): @classmethod def load_module(cls, fullname: str) -> types.ModuleType: ... @classmethod - def get_code(cls, fullname: str) -> None: ... # type: ignore + def get_code(cls, fullname: str) -> None: ... @classmethod - def get_source(cls, fullname: str) -> None: ... # type: ignore + def get_source(cls, fullname: str) -> None: ... # Loader @classmethod def load_module(cls, fullname: str) -> types.ModuleType: ... @@ -125,7 +125,7 @@ else: def load_module(cls, fullname: str) -> types.ModuleType: ... if sys.version_info >= (3, 3): - class WindowsRegisteryFinder(importlib.abc.MetaPathFinder): + class WindowsRegistryFinder(importlib.abc.MetaPathFinder): @classmethod def find_module( cls, fullname: str, @@ -136,7 +136,7 @@ if sys.version_info >= (3, 3): @classmethod def find_spec(cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]], - target: types.ModuleType = None) -> Optional[ModuleSpec]: + target: Optional[types.ModuleType] = None) -> Optional[ModuleSpec]: ... else: class WindowsRegisteryFinder: diff --git a/python/helpers/typeshed/stdlib/3/importlib/util.pyi b/python/helpers/typeshed/stdlib/3/importlib/util.pyi index 6f0232b00553..0a56b9ca7b71 100644 --- a/python/helpers/typeshed/stdlib/3/importlib/util.pyi +++ b/python/helpers/typeshed/stdlib/3/importlib/util.pyi @@ -20,22 +20,22 @@ if sys.version_info >= (3, 3): if sys.version_info >= (3, 4): MAGIC_NUMBER = ... # type: bytes - def cache_from_source(path: str, debug_override: bool = None, *, - optimization: Any = None) -> str: ... + def cache_from_source(path: str, debug_override: Optional[bool] = None, *, + optimization: Optional[Any] = None) -> str: ... def source_from_cache(path: str) -> str: ... def decode_source(source_bytes: bytes) -> str: ... def find_spec( - name: str, package: str = None + name: str, package: Optional[str] = None ) -> importlib.machinery.ModuleSpec: ... def spec_from_loader( name: str, loader: Optional[importlib.abc.Loader], *, - origin: str = None, loader_state: Any = None, - is_package: bool = None + origin: Optional[str] = None, loader_state: Optional[Any] = None, + is_package: Optional[bool] = None ) -> importlib.machinery.ModuleSpec: ... def spec_from_file_location( name: str, location: str, *, - loader: importlib.abc.Loader = None, - submodule_search_locations: List[str]=None + loader: Optional[importlib.abc.Loader] = None, + submodule_search_locations: Optional[List[str]] = None ) -> importlib.machinery.ModuleSpec: ... if sys.version_info >= (3, 5): diff --git a/python/helpers/typeshed/stdlib/3/inspect.pyi b/python/helpers/typeshed/stdlib/3/inspect.pyi index ddf28b9e200f..6b90ad9516da 100644 --- a/python/helpers/typeshed/stdlib/3/inspect.pyi +++ b/python/helpers/typeshed/stdlib/3/inspect.pyi @@ -1,5 +1,4 @@ -# Stubs for inspect - +import sys from typing import (AbstractSet, Any, Tuple, List, Dict, Callable, Generator, Mapping, MutableMapping, NamedTuple, Optional, Sequence, Union, ) @@ -8,15 +7,17 @@ from types import FrameType, ModuleType, TracebackType # # Types and members # -ModuleInfo = NamedTuple('ModuleInfo', [('name', str), - ('suffix', str), - ('mode', str), - ('module_type', int), - ]) +if sys.version_info < (3, 6): + ModuleInfo = NamedTuple('ModuleInfo', [('name', str), + ('suffix', str), + ('mode', str), + ('module_type', int), + ]) + def getmoduleinfo(path: str) -> Optional[ModuleInfo]: ... + def getmembers(object: object, predicate: Callable[[Any], bool] = ..., ) -> List[Tuple[str, Any]]: ... -def getmoduleinfo(path: str) -> Optional[ModuleInfo]: ... def getmodulename(path: str) -> Optional[str]: ... def ismodule(object: object) -> bool: ... diff --git a/python/helpers/typeshed/stdlib/3/io.pyi b/python/helpers/typeshed/stdlib/3/io.pyi index 167385318ebc..20c63efa5d21 100644 --- a/python/helpers/typeshed/stdlib/3/io.pyi +++ b/python/helpers/typeshed/stdlib/3/io.pyi @@ -1,5 +1,3 @@ -# Stubs for io - from typing import ( List, BinaryIO, TextIO, Iterator, Union, Optional, Callable, Tuple, Any, IO, Iterable ) @@ -7,6 +5,7 @@ import builtins import codecs import sys from types import TracebackType +from typing import TypeVar DEFAULT_BUFFER_SIZE = ... # type: int @@ -14,26 +13,22 @@ SEEK_SET = ... # type: int SEEK_CUR = ... # type: int SEEK_END = ... # type: int +_T = TypeVar('_T', bound='IOBase') + open = builtins.open -# FIXME when mypy handle condtional, we can uncomment the next block and remove -# the temporary fix -# if sys.version_info >= (3, 3): -# BlockingIOError = BlockingIOError -# class UnsupportedOperation(OSError, ValueError): ... -# else: -# class BlockingIOError(IOError): -# characters_written = ... # type: int -# class UnsupportedOperation(IOError, ValueError): ... -class BlockingIOError(OSError): - characters_written = ... # type: int -class UnsupportedOperation(OSError, ValueError): ... - +if sys.version_info >= (3, 3): + BlockingIOError = builtins.BlockingIOError + class UnsupportedOperation(OSError, ValueError): ... +else: + class BlockingIOError(IOError): + characters_written: int + class UnsupportedOperation(IOError, ValueError): ... class IOBase: def __iter__(self) -> Iterator[bytes]: ... def __next__(self) -> bytes: ... - def __enter__(self) -> 'IOBase': ... + def __enter__(self: _T) -> _T: ... def __exit__(self, exc_type: Optional[type], exc_val: Optional[Exception], exc_tb: Optional[TracebackType]) -> bool: ... def close(self) -> None: ... @@ -106,8 +101,8 @@ class BytesIO(BinaryIO): def __iter__(self) -> Iterator[bytes]: ... def __next__(self) -> bytes: ... def __enter__(self) -> 'BytesIO': ... - def __exit__(self, t: type = None, value: BaseException = None, - traceback: Any = None) -> bool: ... + def __exit__(self, t: Optional[type] = None, value: Optional[BaseException] = None, + traceback: Optional[Any] = None) -> bool: ... def close(self) -> None: ... def fileno(self) -> int: ... def flush(self) -> None: ... @@ -172,7 +167,6 @@ class TextIOBase(IOBase): newlines = ... # type: Union[str, Tuple[str, ...], None] def __iter__(self) -> Iterator[str]: ... # type: ignore def __next__(self) -> str: ... # type: ignore - def __enter__(self) -> 'TextIOBase': ... def detach(self) -> IOBase: ... def write(self, s: str) -> int: ... if sys.version_info >= (3, 4): @@ -210,8 +204,8 @@ class TextIOWrapper(TextIO): write_through: bool = ... ) -> None: ... # copied from IOBase - def __exit__(self, t: type = None, value: BaseException = None, - traceback: Any = None) -> bool: ... + def __exit__(self, t: Optional[type] = None, value: Optional[BaseException] = None, + traceback: Optional[Any] = None) -> bool: ... def close(self) -> None: ... def fileno(self) -> int: ... def flush(self) -> None: ... @@ -255,5 +249,7 @@ class StringIO(TextIOWrapper): newline: Optional[str] = ...) -> None: ... name = ... # type: str def getvalue(self) -> str: ... + def __enter__(self) -> 'StringIO': ... -class IncrementalNewlineDecoder(codecs.IncrementalDecoder): ... +class IncrementalNewlineDecoder(codecs.IncrementalDecoder): + def decode(self, input: codecs._encoded, final: bool = ...) -> codecs._decoded: ... diff --git a/python/helpers/typeshed/stdlib/3/itertools.pyi b/python/helpers/typeshed/stdlib/3/itertools.pyi index 889d583c5dd0..1f79cd2570f0 100644 --- a/python/helpers/typeshed/stdlib/3/itertools.pyi +++ b/python/helpers/typeshed/stdlib/3/itertools.pyi @@ -3,7 +3,7 @@ # Based on http://docs.python.org/3.2/library/itertools.html from typing import (Iterator, TypeVar, Iterable, overload, Any, Callable, Tuple, - Union, Sequence, Generic, Optional) + Generic, Optional) _T = TypeVar('_T') _S = TypeVar('_S') @@ -29,7 +29,7 @@ class chain(Iterator[_T], Generic[_T]): def compress(data: Iterable[_T], selectors: Iterable[Any]) -> Iterator[_T]: ... def dropwhile(predicate: Callable[[_T], Any], iterable: Iterable[_T]) -> Iterator[_T]: ... -def filterfalse(predicate: Callable[[_T], Any], +def filterfalse(predicate: Optional[Callable[[_T], Any]], iterable: Iterable[_T]) -> Iterator[_T]: ... @overload @@ -44,20 +44,66 @@ def islice(iterable: Iterable[_T], stop: int) -> Iterator[_T]: ... def islice(iterable: Iterable[_T], start: int, stop: Optional[int], step: int = ...) -> Iterator[_T]: ... -def starmap(func: Any, iterable: Iterable[Any]) -> Iterator[Any]: ... +def starmap(func: Callable[..., _S], iterable: Iterable[Iterable[Any]]) -> Iterator[_S]: ... def takewhile(predicate: Callable[[_T], Any], iterable: Iterable[_T]) -> Iterator[_T]: ... -def tee(iterable: Iterable[Any], n: int = ...) -> Iterator[Any]: ... +def tee(iterable: Iterable[_T], n: int = ...) -> Tuple[Iterator[_T], ...]: ... def zip_longest(*p: Iterable[Any], fillvalue: Any = ...) -> Iterator[Any]: ... -# TODO: Return type should be Iterator[Tuple[..]], but unknown tuple shape. -# Iterator[Sequence[_T]] loses this type information. -def product(*p: Iterable[_T], repeat: int = ...) -> Iterator[Sequence[_T]]: ... +_T1 = TypeVar('_T1') +_T2 = TypeVar('_T2') +_T3 = TypeVar('_T3') +_T4 = TypeVar('_T4') +_T5 = TypeVar('_T5') +_T6 = TypeVar('_T6') + +@overload +def product(iter1: Iterable[_T1], *, + repeat: int = ...) -> Iterator[Tuple[_T1]]: ... +@overload +def product(iter1: Iterable[_T1], + iter2: Iterable[_T2], *, + repeat: int = ...) -> Iterator[Tuple[_T1, _T2]]: ... +@overload +def product(iter1: Iterable[_T1], + iter2: Iterable[_T2], + iter3: Iterable[_T3], *, + repeat: int = ...) -> Iterator[Tuple[_T1, _T2, _T3]]: ... +@overload +def product(iter1: Iterable[_T1], + iter2: Iterable[_T2], + iter3: Iterable[_T3], + iter4: Iterable[_T4], *, + repeat: int = ...) -> Iterator[Tuple[_T1, _T2, _T3, _T4]]: ... +@overload +def product(iter1: Iterable[_T1], + iter2: Iterable[_T2], + iter3: Iterable[_T3], + iter4: Iterable[_T4], + iter5: Iterable[_T5], *, + repeat: int = ...) -> Iterator[Tuple[_T1, _T2, _T3, _T4, _T5]]: ... +@overload +def product(iter1: Iterable[_T1], + iter2: Iterable[_T2], + iter3: Iterable[_T3], + iter4: Iterable[_T4], + iter5: Iterable[_T5], + iter6: Iterable[_T6], *, + repeat: int = ...) -> Iterator[Tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ... +@overload +def product(iter1: Iterable[Any], + iter2: Iterable[Any], + iter3: Iterable[Any], + iter4: Iterable[Any], + iter5: Iterable[Any], + iter6: Iterable[Any], + iter7: Iterable[Any], *iterables: Iterable, + repeat: int = ...) -> Iterator[Tuple]: ... def permutations(iterable: Iterable[_T], - r: Union[int, None] = ...) -> Iterator[Sequence[_T]]: ... + r: Optional[int] = ...) -> Iterator[Tuple[_T, ...]]: ... def combinations(iterable: Iterable[_T], - r: int) -> Iterable[Sequence[_T]]: ... + r: int) -> Iterable[Tuple[_T, ...]]: ... def combinations_with_replacement(iterable: Iterable[_T], - r: int) -> Iterable[Sequence[_T]]: ... + r: int) -> Iterable[Tuple[_T, ...]]: ... diff --git a/python/helpers/typeshed/stdlib/3/json/__init__.pyi b/python/helpers/typeshed/stdlib/3/json/__init__.pyi new file mode 100644 index 000000000000..c68705d672f9 --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/json/__init__.pyi @@ -0,0 +1,51 @@ +import sys +from typing import Any, IO, Optional, Tuple, Callable, Dict, List, Union + +from .decoder import JSONDecoder as JSONDecoder +from .encoder import JSONEncoder as JSONEncoder +if sys.version_info >= (3, 5): + from .decoder import JSONDecodeError as JSONDecodeError + +def dumps(obj: Any, + skipkeys: bool = ..., + ensure_ascii: bool = ..., + check_circular: bool = ..., + allow_nan: bool = ..., + cls: Any = ..., + indent: Union[None, int, str] = ..., + separators: Optional[Tuple[str, str]] = ..., + default: Optional[Callable[[Any], Any]] = ..., + sort_keys: bool = ..., + **kwds: Any) -> str: ... + +def dump(obj: Any, + fp: IO[str], + skipkeys: bool = ..., + ensure_ascii: bool = ..., + check_circular: bool = ..., + allow_nan: bool = ..., + cls: Any = ..., + indent: Union[None, int, str] = ..., + separators: Optional[Tuple[str, str]] = ..., + default: Optional[Callable[[Any], Any]] = ..., + sort_keys: bool = ..., + **kwds: Any) -> None: ... + +def loads(s: Union[str, bytes, bytearray], + encoding: Any = ..., # ignored and deprecated + cls: Any = ..., + object_hook: Optional[Callable[[Dict], Any]] = ..., + parse_float: Optional[Callable[[str], Any]] = ..., + parse_int: Optional[Callable[[str], Any]] = ..., + parse_constant: Optional[Callable[[str], Any]] = ..., + object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ..., + **kwds: Any) -> Any: ... + +def load(fp: IO[str], + cls: Any = ..., + object_hook: Optional[Callable[[Dict], Any]] = ..., + parse_float: Optional[Callable[[str], Any]] = ..., + parse_int: Optional[Callable[[str], Any]] = ..., + parse_constant: Optional[Callable[[str], Any]] = ..., + object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ..., + **kwds: Any) -> Any: ... diff --git a/python/helpers/typeshed/stdlib/3/json/decoder.pyi b/python/helpers/typeshed/stdlib/3/json/decoder.pyi new file mode 100644 index 000000000000..1c3e9a05b05b --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/json/decoder.pyi @@ -0,0 +1,28 @@ +import sys +from typing import Any, Callable, Dict, List, Optional, Tuple + +if sys.version_info >= (3, 5): + class JSONDecodeError(ValueError): + msg: str + doc: str + pos: int + lineno: int + colno: int + def __init__(self, msg: str, doc: str, pos: int) -> None: ... + +class JSONDecoder: + object_hook = None # type: Callable[[Dict[str, Any]], Any] + parse_float = ... # Callable[[str], Any] + parse_int = ... # Callable[[str], Any] + parse_constant = ... # Callable[[str], Any] + strict = ... # type: bool + object_pairs_hook = None # type: Callable[[List[Tuple[str, Any]]], Any] + + def __init__(self, object_hook: Optional[Callable[[Dict[str, Any]], Any]] = None, + parse_float: Optional[Callable[[str], Any]] = None, + parse_int: Optional[Callable[[str], Any]] = None, + parse_constant: Optional[Callable[[str], Any]] = None, + strict: bool = True, + object_pairs_hook: Optional[Callable[[List[Tuple[str, Any]]], Any]] = None) -> None: ... + def decode(self, s: str) -> Any: ... + def raw_decode(self, s: str, idx: int = ...) -> Tuple[Any, int]: ... diff --git a/python/helpers/typeshed/stdlib/3/json/encoder.pyi b/python/helpers/typeshed/stdlib/3/json/encoder.pyi new file mode 100644 index 000000000000..c423c182ab50 --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/json/encoder.pyi @@ -0,0 +1,20 @@ +from typing import Any, Callable, Iterator, Optional, Tuple + +class JSONEncoder: + item_separator = ... # type: str + key_separator = ... # type: str + + skipkeys = ... # type: bool + ensure_ascii = ... # type: bool + check_circular = ... # type: bool + allow_nan = ... # type: bool + sort_keys = ... # type: bool + indent = None # type: int + + def __init__(self, skipkeys: bool = ..., ensure_ascii: bool = ..., + check_circular: bool = ..., allow_nan: bool = ..., sort_keys: bool = ..., + indent: Optional[int] = None, separators: Optional[Tuple[str, str]] = None, default: Optional[Callable] = None) -> None: ... + + def default(self, o: Any) -> Any: ... + def encode(self, o: Any) -> str: ... + def iterencode(self, o: Any, _one_shot: bool = False) -> Iterator[str]: ... diff --git a/python/helpers/typeshed/stdlib/3/macpath.pyi b/python/helpers/typeshed/stdlib/3/macpath.pyi new file mode 120000 index 000000000000..d2d185799bcc --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/macpath.pyi @@ -0,0 +1 @@ +posixpath.pyi \ No newline at end of file diff --git a/python/helpers/typeshed/stdlib/3/multiprocessing/__init__.pyi b/python/helpers/typeshed/stdlib/3/multiprocessing/__init__.pyi index 8ab505ee0696..59b82daf3b46 100644 --- a/python/helpers/typeshed/stdlib/3/multiprocessing/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/multiprocessing/__init__.pyi @@ -1,99 +1,92 @@ # Stubs for multiprocessing -from typing import Any, Callable, Iterable, Mapping, Optional, Dict, List +from typing import ( + Any, Callable, ContextManager, Iterable, Mapping, Optional, Dict, List, + Union, TypeVar, +) +from logging import Logger +from multiprocessing import pool +from multiprocessing.context import BaseContext +from multiprocessing.managers import SyncManager +from multiprocessing.pool import AsyncResult from multiprocessing.process import current_process as current_process +import sys +import queue -class Lock(): +_T = TypeVar('_T') + +class Lock(ContextManager[Lock]): def acquire(self, block: bool = ..., timeout: int = ...) -> None: ... def release(self) -> None: ... -class AsyncResult(): - def get(self, timeout: float = -1) -> Any: ... - def wait(self, timeout: float = -1) -> None: ... - def ready(self) -> bool: ... - def successful(self) -> bool: ... +class Event(object): + def __init__(self, *, ctx: BaseContext) -> None: ... + def is_set(self) -> bool: ... + def set(self) -> None: ... + def clear(self) -> None: ... + def wait(self, timeout: Optional[int] = ...) -> bool: ... -class Pool(): - def __init__(self, processes: Optional[int] = None, - initializer: Optional[Callable[..., None]] = None, - initargs: Iterable[Any] = (), - maxtasksperchild: Optional[int] = None, - context: Any = None) -> None: ... - def apply(self, - func: Callable[..., Any], - args: Iterable[Any]=(), - kwds: Dict[str, Any]=...) -> Any: ... - def apply_async(self, - func: Callable[..., Any], - args: Iterable[Any]=(), - kwds: Dict[str, Any]=..., - callback: Callable[..., None] = None, - error_callback: Callable[[BaseException], None] = None) -> AsyncResult: ... - def map(self, - func: Callable[..., Any], - iterable: Iterable[Any]=(), - chunksize: Optional[int] = None) -> List[Any]: ... - def map_async(self, func: Callable[..., Any], - iterable: Iterable[Any] = (), - chunksize: Optional[int] = None, - callback: Callable[..., None] = None, - error_callback: Callable[[BaseException], None] = None) -> AsyncResult: ... - def imap(self, - func: Callable[..., Any], - iterable: Iterable[Any]=(), - chunksize: Optional[int] = None) -> Iterable[Any]: ... - def imap_unordered(self, - func: Callable[..., Any], - iterable: Iterable[Any]=(), - chunksize: Optional[int] = None) -> Iterable[Any]: ... - def starmap(self, - func: Callable[..., Any], - iterable: Iterable[Iterable[Any]]=(), - chunksize: Optional[int] = None) -> List[Any]: ... - def starmap_async(self, - func: Callable[..., Any], - iterable: Iterable[Iterable[Any]] = (), - chunksize: Optional[int] = None, - callback: Callable[..., None] = None, - error_callback: Callable[[BaseException], None] = None) -> AsyncResult: ... - def close(self) -> None: ... - def terminate(self) -> None: ... - def join(self) -> None: ... - def __enter__(self) -> 'Pool': ... - def __exit__(self, exc_type, exc_val, exc_tb) -> None: ... +# N.B. This is generated at runtime by partially applying +# multiprocessing.context.BaseContext.Pool, so the two signatures should be +# identical (modulo self). +def Pool(processes: Optional[int] = ..., + initializer: Optional[Callable[..., Any]] = ..., + initargs: Iterable[Any] = ..., + maxtasksperchild: Optional[int] = ...) -> pool.Pool: ... class Process(): + name: str + daemon: bool + pid: Optional[int] + exitcode: Optional[int] + authkey: bytes + sentinel: int # TODO: set type of group to None def __init__(self, group: Any = ..., - target: Callable = ..., - name: str = ..., + target: Optional[Callable] = ..., + name: Optional[str] = ..., args: Iterable[Any] = ..., kwargs: Mapping[Any, Any] = ..., - daemon: bool = ...) -> None: ... + *, + daemon: Optional[bool] = ...) -> None: ... def start(self) -> None: ... def run(self) -> None: ... def terminate(self) -> None: ... def is_alive(self) -> bool: ... - def join(self, timeout: float = ...) -> None: ... + def join(self, timeout: Optional[float] = ...) -> None: ... -class Queue(): +class Queue(queue.Queue[_T]): def __init__(self, maxsize: int = ...) -> None: ... - def get(self, block: bool = ..., timeout: float = ...) -> Any: ... - def put(self, item: Any, block: bool = ..., timeout: float = ...) -> None: ... + def get(self, block: bool = ..., timeout: Optional[float] = ...) -> _T: ... + def put(self, item: _T, block: bool = ..., timeout: Optional[float] = ...) -> None: ... def qsize(self) -> int: ... def empty(self) -> bool: ... def full(self) -> bool: ... - def put_nowait(self, item: Any) -> None: ... - def get_nowait(self) -> Any: ... + def put_nowait(self, item: _T) -> None: ... + def get_nowait(self) -> _T: ... def close(self) -> None: ... def join_thread(self) -> None: ... def cancel_join_thread(self) -> None: ... class Value(): + value: Any = ... def __init__(self, typecode_or_type: str, *args: Any, lock: bool = ...) -> None: ... # ----- multiprocessing function stubs ----- +def active_children() -> List[Process]: ... +def allow_connection_pickling() -> None: ... def cpu_count() -> int: ... def freeze_support() -> None: ... +def get_logger() -> Logger: ... +def log_to_stderr(level: Optional[Union[str, int]] = ...) -> Logger: ... +def Manager() -> SyncManager: ... +def set_forkserver_preload(module_names: List[str]) -> None: ... +if sys.platform == 'win32' or sys.version_info >= (3, 4): + def set_executable(executable: str) -> None: ... +if sys.version_info >= (3, 4): + def get_all_start_methods() -> List[str]: ... + def get_context(method: Optional[str] = ...) -> BaseContext: ... + def get_start_method(allow_none: Optional[bool]) -> Optional[str]: ... + def set_start_method(method: str, force: Optional[bool] = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/multiprocessing/context.pyi b/python/helpers/typeshed/stdlib/3/multiprocessing/context.pyi new file mode 100644 index 000000000000..ab095c99d268 --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/multiprocessing/context.pyi @@ -0,0 +1,178 @@ +# Stubs for multiprocessing.context + +from logging import Logger +import multiprocessing +import sys +from typing import ( + Any, Callable, Iterable, Optional, List, Mapping, Sequence, Tuple, Type, Union, +) + +class ProcessError(Exception): ... + +class BufferTooShort(ProcessError): ... + +class TimeoutError(ProcessError): ... + +class AuthenticationError(ProcessError): ... + +class BaseContext(object): + ProcessError = ... # type: Type[Exception] + BufferTooShort = ... # type: Type[Exception] + TimeoutError = ... # type: Type[Exception] + AuthenticationError = ... # type: Type[Exception] + + @staticmethod + def current_process() -> multiprocessing.Process: ... + @staticmethod + def active_children() -> List[multiprocessing.Process]: ... + def cpu_count(self) -> int: ... + # TODO: change return to SyncManager once a stub exists in multiprocessing.managers + def Manager(self) -> Any: ... + # TODO: change return to Pipe once a stub exists in multiprocessing.connection + def Pipe(self, duplex: bool) -> Any: ... + # TODO: change return to Lock once a stub exists in multiprocessing.synchronize + def Lock(self) -> Any: ... + # TODO: change return to RLock once a stub exists in multiprocessing.synchronize + def RLock(self) -> Any: ... + # TODO: change lock param to Optional[Union[Lock, RLock]] when stubs exists in multiprocessing.synchronize + # TODO: change return to Condition once a stub exists in multiprocessing.synchronize + def Condition(self, lock: Optional[Any] = ...) -> Any: ... + # TODO: change return to Semaphore once a stub exists in multiprocessing.synchronize + def Semaphore(self, value: int = ...) -> Any: ... + # TODO: change return to BoundedSemaphore once a stub exists in multiprocessing.synchronize + def BoundedSemaphore(self, value: int = ...) -> Any: ... + # TODO: change return to Event once a stub exists in multiprocessing.synchronize + def Event(self) -> Any: ... + # TODO: change return to Barrier once a stub exists in multiprocessing.synchronize + def Barrier(self, parties: int, action: Optional[Callable[..., Any]] = ..., timeout: Optional[int] = ...) -> Any: ... + # TODO: change return to Queue once a stub exists in multiprocessing.queues + def Queue(self, maxsize: int = ...) -> Any: ... + # TODO: change return to Queue once a stub exists in multiprocessing.queues + def JoinableQueue(self, maxsize: int = ...) -> Any: ... + # TODO: change return to SimpleQueue once a stub exists in multiprocessing.queues + def SimpleQueue(self) -> Any: ... + # N.B. This method is partially applied at runtime to generate + # multiprocessing.Pool, so the two signatures should be identical (modulo + # self). + def Pool( + self, + processes: Optional[int] = ..., + initializer: Optional[Callable[..., Any]] = ..., + initargs: Iterable[Any] = ..., + maxtasksperchild: Optional[int] = ... + ) -> multiprocessing.pool.Pool: ... + def Process( + self, + group: Any = ..., + target: Optional[Callable] = ..., + name: Optional[str] = ..., + args: Iterable[Any] = ..., + kwargs: Mapping[Any, Any] = ..., + *, + daemon: Optional[bool] = ... + ) -> multiprocessing.Process: ... + # TODO: typecode_or_type param is a ctype with a base class of _SimpleCData or array.typecode Need to figure out + # how to handle the ctype + # TODO: change return to RawValue once a stub exists in multiprocessing.sharedctypes + def RawValue(self, typecode_or_type: Any, *args: Any) -> Any: ... + # TODO: typecode_or_type param is a ctype with a base class of _SimpleCData or array.typecode Need to figure out + # how to handle the ctype + # TODO: change return to RawArray once a stub exists in multiprocessing.sharedctypes + def RawArray(self, typecode_or_type: Any, size_or_initializer: Union[int, Sequence[Any]]) -> Any: ... + # TODO: typecode_or_type param is a ctype with a base class of _SimpleCData or array.typecode Need to figure out + # how to handle the ctype + # TODO: change return to Value once a stub exists in multiprocessing.sharedctypes + def Value( + self, + typecode_or_type: Any, + *args: Any, + lock: bool = ... + ) -> Any: ... + # TODO: typecode_or_type param is a ctype with a base class of _SimpleCData or array.typecode Need to figure out + # how to handle the ctype + # TODO: change return to Array once a stub exists in multiprocessing.sharedctypes + def Array( + self, + typecode_or_type: Any, + size_or_initializer: Union[int, Sequence[Any]], + *, + lock: bool = ... + ) -> Any: ... + def freeze_support(self) -> None: ... + def get_logger(self) -> Logger: ... + def log_to_stderr(self, level: Optional[str] = ...) -> Logger: ... + def allow_connection_pickling(self) -> None: ... + def set_executable(self, executable: str) -> None: ... + def set_forkserver_preload(self, module_names: List[str]) -> None: ... + def get_context(self, method: Optional[str] = ...) -> BaseContext: ... + def get_start_method(self, allow_none: bool = ...) -> str: ... + def set_start_method(self, method: Optional[str] = ...) -> None: ... + @property + def reducer(self) -> str: ... + @reducer.setter + def reducer(self, reduction: str) -> None: ... + def _check_available(self) -> None: ... + +class Process(object): + _start_method: Optional[str] + @staticmethod + # TODO: type should be BaseProcess once a stub in multiprocessing.process exists + def _Popen(process_obj: Any) -> DefaultContext: ... + +class DefaultContext(object): + Process = ... # type: Type[multiprocessing.Process] + + def __init__(self, context: BaseContext) -> None: ... + def get_context(self, method: Optional[str] = ...) -> BaseContext: ... + def set_start_method(self, method: str, force: bool = ...) -> None: ... + def get_start_method(self, allow_none: bool = ...) -> str: ... + def get_all_start_methods(self) -> List[str]: ... + +if sys.platform != 'win32': + # TODO: type should be BaseProcess once a stub in multiprocessing.process exists + class ForkProcess(Any): # type: ignore + _start_method: str + @staticmethod + def _Popen(process_obj: Any) -> Any: ... + + # TODO: type should be BaseProcess once a stub in multiprocessing.process exists + class SpawnProcess(Any): # type: ignore + _start_method: str + @staticmethod + def _Popen(process_obj: Any) -> SpawnProcess: ... + + # TODO: type should be BaseProcess once a stub in multiprocessing.process exists + class ForkServerProcess(Any): # type: ignore + _start_method: str + @staticmethod + def _Popen(process_obj: Any) -> Any: ... + + class ForkContext(BaseContext): + _name: str + Process = ... # type: Type[ForkProcess] + + class SpawnContext(BaseContext): + _name: str + Process = ... # type: Type[SpawnProcess] + + class ForkServerContext(BaseContext): + _name: str + Process = ... # type: Type[ForkServerProcess] +else: + # TODO: type should be BaseProcess once a stub in multiprocessing.process exists + class SpawnProcess(Any): # type: ignore + _start_method: str + @staticmethod + # TODO: type should be BaseProcess once a stub in multiprocessing.process exists + def _Popen(process_obj: Process) -> Any: ... + + class SpawnContext(BaseContext): + _name: str + Process = ... # type: Type[SpawnProcess] + +def _force_start_method(method: str) -> None: ... +# TODO: type should be BaseProcess once a stub in multiprocessing.process exists +def get_spawning_popen() -> Optional[Any]: ... +# TODO: type should be BaseProcess once a stub in multiprocessing.process exists +def set_spawning_popen(popen: Any) -> None: ... +def assert_spawning(obj: Any) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/multiprocessing/managers.pyi b/python/helpers/typeshed/stdlib/3/multiprocessing/managers.pyi index c5d053e01e69..74634e3aafbc 100644 --- a/python/helpers/typeshed/stdlib/3/multiprocessing/managers.pyi +++ b/python/helpers/typeshed/stdlib/3/multiprocessing/managers.pyi @@ -2,9 +2,39 @@ # NOTE: These are incomplete! -from typing import Any +import queue +import threading +from typing import ( + Any, Callable, ContextManager, Dict, Iterable, List, Mapping, Optional, + Sequence, TypeVar, +) -class BaseManager: +_T = TypeVar('_T') +_KT = TypeVar('_KT') +_VT = TypeVar('_VT') + +class Namespace: ... + +_Namespace = Namespace + +class BaseManager(ContextManager[BaseManager]): def register(self, typeid: str, callable: Any = ...) -> None: ... + def shutdown(self) -> None: ... + def start(self, initializer: Optional[Callable[..., Any]] = ..., + initargs: Iterable[Any] = ...) -> None: ... + +class SyncManager(BaseManager): + def BoundedSemaphore(self, value: Any = ...) -> threading.BoundedSemaphore: ... + def Condition(self, lock: Any = ...) -> threading.Condition: ... + def Event(self) -> threading.Event: ... + def Lock(self) -> threading.Lock: ... + def Namespace(self) -> _Namespace: ... + def Queue(self, maxsize: int = ...) -> queue.Queue: ... + def RLock(self) -> threading.RLock: ... + def Semaphore(self, value: Any = ...) -> threading.Semaphore: ... + def Array(self, typecode: Any, sequence: Sequence[_T]) -> Sequence[_T]: ... + def Value(self, typecode: Any, value: _T) -> _T: ... + def dict(self, sequence: Mapping[_KT, _VT] = ...) -> Dict[_KT, _VT]: ... + def list(self, sequence: Sequence[_T] = ...) -> List[_T]: ... class RemoteError(Exception): ... diff --git a/python/helpers/typeshed/stdlib/3/multiprocessing/pool.pyi b/python/helpers/typeshed/stdlib/3/multiprocessing/pool.pyi index ed917490da07..bdfd476f9167 100644 --- a/python/helpers/typeshed/stdlib/3/multiprocessing/pool.pyi +++ b/python/helpers/typeshed/stdlib/3/multiprocessing/pool.pyi @@ -2,57 +2,70 @@ # NOTE: These are incomplete! -from typing import Any, Callable, Iterable, Mapping, Optional, Dict, List +from typing import ( + Any, Callable, ContextManager, Iterable, Mapping, Optional, Dict, List, + TypeVar, +) + +_T = TypeVar('_T', bound='Pool') class AsyncResult(): - def get(self, timeout: float = -1) -> Any: ... - def wait(self, timeout: float = -1) -> None: ... + def get(self, timeout: float = ...) -> Any: ... + def wait(self, timeout: float = ...) -> None: ... def ready(self) -> bool: ... def successful(self) -> bool: ... -class ThreadPool(): - def __init__(self, processes: Optional[int] = None, - initializer: Optional[Callable[..., None]] = None, - initargs: Iterable[Any] = ()) -> None: ... +class Pool(ContextManager[Pool]): + def __init__(self, processes: Optional[int] = ..., + initializer: Optional[Callable[..., None]] = ..., + initargs: Iterable[Any] = ..., + maxtasksperchild: Optional[int] = ..., + context: Optional[Any] = None) -> None: ... def apply(self, func: Callable[..., Any], - args: Iterable[Any]=(), - kwds: Dict[str, Any]=...) -> Any: ... + args: Iterable[Any] = ..., + kwds: Dict[str, Any] = ...) -> Any: ... def apply_async(self, func: Callable[..., Any], - args: Iterable[Any]=(), - kwds: Dict[str, Any]=..., - callback: Callable[..., None] = None, - error_callback: Callable[[BaseException], None] = None) -> AsyncResult: ... + args: Iterable[Any] = ..., + kwds: Dict[str, Any] = ..., + callback: Optional[Callable[..., None]] = None, + error_callback: Optional[Callable[[BaseException], None]] = None) -> AsyncResult: ... def map(self, func: Callable[..., Any], - iterable: Iterable[Any]=(), + iterable: Iterable[Any] = ..., chunksize: Optional[int] = None) -> List[Any]: ... def map_async(self, func: Callable[..., Any], - iterable: Iterable[Any] = (), + iterable: Iterable[Any] = ..., chunksize: Optional[int] = None, - callback: Callable[..., None] = None, - error_callback: Callable[[BaseException], None] = None) -> AsyncResult: ... + callback: Optional[Callable[..., None]] = None, + error_callback: Optional[Callable[[BaseException], None]] = None) -> AsyncResult: ... def imap(self, func: Callable[..., Any], - iterable: Iterable[Any]=(), + iterable: Iterable[Any] = ..., chunksize: Optional[int] = None) -> Iterable[Any]: ... def imap_unordered(self, func: Callable[..., Any], - iterable: Iterable[Any]=(), + iterable: Iterable[Any] = ..., chunksize: Optional[int] = None) -> Iterable[Any]: ... def starmap(self, func: Callable[..., Any], - iterable: Iterable[Iterable[Any]]=(), + iterable: Iterable[Iterable[Any]] = ..., chunksize: Optional[int] = None) -> List[Any]: ... def starmap_async(self, func: Callable[..., Any], - iterable: Iterable[Iterable[Any]] = (), + iterable: Iterable[Iterable[Any]] = ..., chunksize: Optional[int] = None, - callback: Callable[..., None] = None, - error_callback: Callable[[BaseException], None] = None) -> AsyncResult: ... + callback: Optional[Callable[..., None]] = None, + error_callback: Optional[Callable[[BaseException], None]] = None) -> AsyncResult: ... def close(self) -> None: ... def terminate(self) -> None: ... def join(self) -> None: ... - def __enter__(self) -> 'ThreadPool': ... - def __exit__(self, exc_type, exc_val, exc_tb) -> None: ... + def __enter__(self: _T) -> _T: ... + + +class ThreadPool(Pool, ContextManager[ThreadPool]): + + def __init__(self, processes: Optional[int] = None, + initializer: Optional[Callable[..., Any]] = None, + initargs: Iterable[Any] = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/nntplib.pyi b/python/helpers/typeshed/stdlib/3/nntplib.pyi new file mode 100644 index 000000000000..1bf2f41968da --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/nntplib.pyi @@ -0,0 +1,104 @@ +# Stubs for nntplib (Python 3) + +import datetime +import socket +import ssl +import sys +from typing import Any, Dict, IO, Iterable, List, NamedTuple, Optional, Tuple, TypeVar, Union + +_SelfT = TypeVar('_SelfT', bound=_NNTPBase) +_File = Union[IO[bytes], bytes, str, None] + + +class NNTPError(Exception): + response: str +class NNTPReplyError(NNTPError): ... +class NNTPTemporaryError(NNTPError): ... +class NNTPPermanentError(NNTPError): ... +class NNTPProtocolError(NNTPError): ... +class NNTPDataError(NNTPError): ... + +NNTP_PORT: int +NNTP_SSL_PORT: int + +GroupInfo = NamedTuple('GroupInfo', [ + ('group', str), + ('last', str), + ('first', str), + ('flag', str), +]) +ArticleInfo = NamedTuple('ArticleInfo', [ + ('number', int), + ('message_id', str), + ('lines', List[bytes]), +]) + +def decode_header(header_str: str) -> str: ... + +class _NNTPBase: + encoding: str + errors: str + + host: str + file: IO[bytes] + debugging: int + welcome: str + readermode_afterauth: bool + tls_on: bool + authenticated: bool + nntp_implementation: str + nntp_version: int + + def __init__(self, file: IO[bytes], host: str, + readermode: Optional[bool] = ..., timeout: float = ...) -> None: ... + if sys.version_info >= (3, 3): + def __enter__(self: _SelfT) -> _SelfT: ... + def __exit__(self, *args: Any) -> None: ... + def getwelcome(self) -> str: ... + def getcapabilities(self) -> Dict[str, List[str]]: ... + def set_debuglevel(self, level: int) -> None: ... + def debug(self, level: int) -> None: ... + def capabilities(self) -> Tuple[str, Dict[str, List[str]]]: ... + def newgroups(self, date: Union[datetime.date, datetime.datetime], *, file: _File = ...) -> Tuple[str, List[str]]: ... + def newnews(self, group: str, date: Union[datetime.date, datetime.datetime], *, file: _File = ...) -> Tuple[str, List[str]]: ... + def list(self, group_pattern: Optional[str] = ..., *, file: _File = ...) -> Tuple[str, List[str]]: ... + def description(self, group: str) -> str: ... + def descriptions(self, group_pattern: str) -> Tuple[str, Dict[str, str]]: ... + def group(self, name: str) -> Tuple[str, int, int, int, str]: ... + def help(self, *, file: _File = ...) -> Tuple[str, List[str]]: ... + def stat(self, message_spec: Any = ...) -> Tuple[str, int, str]: ... + def next(self) -> Tuple[str, int, str]: ... + def last(self) -> Tuple[str, int, str]: ... + def head(self, message_spec: Any = ..., *, file: _File = ...) -> Tuple[str, ArticleInfo]: ... + def body(self, message_spec: Any = ..., *, file: _File = ...) -> Tuple[str, ArticleInfo]: ... + def article(self, message_spec: Any = ..., *, file: _File = ...) -> Tuple[str, ArticleInfo]: ... + def slave(self) -> str: ... + def xhdr(self, hdr: str, str: Any, *, file: _File = ...) -> Tuple[str, List[str]]: ... + def xover(self, start: int, end: int, *, file: _File = ...) -> Tuple[str, List[Tuple[int, Dict[str, str]]]]: ... + def over(self, message_spec: Union[None, str, List[Any], Tuple[Any, ...]], *, file: _File = ...) -> Tuple[str, List[Tuple[int, Dict[str, str]]]]: ... + def xgtitle(self, group: str, *, file: _File = ...) -> Tuple[str, List[Tuple[str, str]]]: ... + def xpath(self, id: Any) -> Tuple[str, str]: ... + def date(self) -> Tuple[str, datetime.datetime]: ... + def post(self, data: Union[bytes, Iterable[bytes]]) -> str: ... + def ihave(self, message_id: Any, data: Union[bytes, Iterable[bytes]]) -> str: ... + def quit(self) -> str: ... + def login(self, user: Optional[str] = ..., password: Optional[str] = ..., usenetrc: bool = ...) -> None: ... + def starttls(self, ssl_context: Optional[ssl.SSLContext] = ...) -> None: ... + + +class NNTP(_NNTPBase): + port: int + sock: socket.socket + + def __init__(self, host: str, port: int = ..., user: Optional[str] = ..., password: Optional[str] = ..., + readermode: Optional[bool] = ..., usenetrc: bool = ..., + timeout: float = ...) -> None: ... + + +class NNTP_SSL(_NNTPBase): + sock: socket.socket + + def __init__(self, host: str, port: int = ..., user: Optional[str] = ..., password: Optional[str] = ..., + ssl_context: Optional[ssl.SSLContext] = ..., + readermode: Optional[bool] = ..., usenetrc: bool = ..., + timeout: float = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/ntpath.pyi b/python/helpers/typeshed/stdlib/3/ntpath.pyi new file mode 120000 index 000000000000..d2d185799bcc --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/ntpath.pyi @@ -0,0 +1 @@ +posixpath.pyi \ No newline at end of file diff --git a/python/helpers/typeshed/stdlib/3/nturl2path.pyi b/python/helpers/typeshed/stdlib/3/nturl2path.pyi new file mode 100644 index 000000000000..b8ad8d682155 --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/nturl2path.pyi @@ -0,0 +1,2 @@ +def url2pathname(url: str) -> str: ... +def pathname2url(p: str) -> str: ... diff --git a/python/helpers/typeshed/stdlib/3/os/__init__.pyi b/python/helpers/typeshed/stdlib/3/os/__init__.pyi index 2324a93432a0..c9e8e7a40f87 100644 --- a/python/helpers/typeshed/stdlib/3/os/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/os/__init__.pyi @@ -1,130 +1,134 @@ # Stubs for os # Ron Murawski -# based on http: //docs.python.org/3.2/library/os.html - from builtins import OSError as error from io import TextIOWrapper as _TextIOWrapper import sys from typing import ( Mapping, MutableMapping, Dict, List, Any, Tuple, Iterator, overload, Union, AnyStr, - Optional, Generic, Set, Callable, Text, Sequence + Optional, Generic, Set, Callable, Text, Sequence, IO, NamedTuple, TypeVar ) -from . import path +from . import path as path from mypy_extensions import NoReturn +_T = TypeVar('_T') + # ----- os variables ----- -supports_bytes_environ = False # TODO: True when bytes implemented? +if sys.version_info >= (3, 2): + supports_bytes_environ: bool if sys.version_info >= (3, 3): - supports_dir_fd = ... # type: Set[Callable[..., Any]] - supports_fd = ... # type: Set[Callable[..., Any]] - supports_effective_ids = ... # type: Set[Callable[..., Any]] - supports_follow_symlinks = ... # type: Set[Callable[..., Any]] + supports_dir_fd: Set[Callable[..., Any]] + supports_fd: Set[Callable[..., Any]] + supports_effective_ids: Set[Callable[..., Any]] + supports_follow_symlinks: Set[Callable[..., Any]] -SEEK_SET = 0 -SEEK_CUR = 0 -SEEK_END = 0 +SEEK_SET: int +SEEK_CUR: int +SEEK_END: int -O_RDONLY = 0 -O_WRONLY = 0 -O_RDWR = 0 -O_APPEND = 0 -O_CREAT = 0 -O_EXCL = 0 -O_TRUNC = 0 -O_DSYNC = 0 # Unix only -O_RSYNC = 0 # Unix only -O_SYNC = 0 # Unix only -O_NDELAY = 0 # Unix only -O_NONBLOCK = 0 # Unix only -O_NOCTTY = 0 # Unix only -O_SHLOCK = 0 # Unix only -O_EXLOCK = 0 # Unix only -O_BINARY = 0 # Windows only -O_NOINHERIT = 0 # Windows only -O_SHORT_LIVED = 0 # Windows only -O_TEMPORARY = 0 # Windows only -O_RANDOM = 0 # Windows only -O_SEQUENTIAL = 0 # Windows only -O_TEXT = 0 # Windows only -O_ASYNC = 0 # Gnu extension if in C library -O_DIRECT = 0 # Gnu extension if in C library -O_DIRECTORY = 0 # Gnu extension if in C library -O_NOFOLLOW = 0 # Gnu extension if in C library -O_NOATIME = 0 # Gnu extension if in C library +O_RDONLY: int +O_WRONLY: int +O_RDWR: int +O_APPEND: int +O_CREAT: int +O_EXCL: int +O_TRUNC: int +O_DSYNC: int # Unix only +O_RSYNC: int # Unix only +O_SYNC: int # Unix only +O_NDELAY: int # Unix only +O_NONBLOCK: int # Unix only +O_NOCTTY: int # Unix only +O_SHLOCK: int # Unix only +O_EXLOCK: int # Unix only +O_BINARY: int # Windows only +O_NOINHERIT: int # Windows only +O_SHORT_LIVED: int # Windows only +O_TEMPORARY: int # Windows only +O_RANDOM: int # Windows only +O_SEQUENTIAL: int # Windows only +O_TEXT: int # Windows only +O_ASYNC: int # Gnu extension if in C library +O_DIRECT: int # Gnu extension if in C library +O_DIRECTORY: int # Gnu extension if in C library +O_NOFOLLOW: int # Gnu extension if in C library +O_NOATIME: int # Gnu extension if in C library +O_LARGEFILE: int # Gnu extension if in C library -curdir = ... # type: str -pardir = ... # type: str -sep = ... # type: str -altsep = ... # type: str -extsep = ... # type: str -pathsep = ... # type: str -defpath = ... # type: str -linesep = ... # type: str -devnull = ... # type: str -name = ... # type: str +curdir: str +pardir: str +sep: str +altsep: str +extsep: str +pathsep: str +defpath: str +linesep: str +devnull: str +name: str -F_OK = 0 -R_OK = 0 -W_OK = 0 -X_OK = 0 +F_OK: int +R_OK: int +W_OK: int +X_OK: int class _Environ(MutableMapping[AnyStr, AnyStr], Generic[AnyStr]): def copy(self) -> Dict[AnyStr, AnyStr]: ... -environ = ... # type: _Environ[str] -environb = ... # type: _Environ[bytes] +environ: _Environ[str] +if sys.version_info >= (3, 2): + environb: _Environ[bytes] -confstr_names = ... # type: Dict[str, int] # Unix only -pathconf_names = ... # type: Dict[str, int] # Unix only -sysconf_names = ... # type: Dict[str, int] # Unix only +confstr_names: Dict[str, int] # Unix only +pathconf_names: Dict[str, int] # Unix only +sysconf_names: Dict[str, int] # Unix only -EX_OK = 0 # Unix only -EX_USAGE = 0 # Unix only -EX_DATAERR = 0 # Unix only -EX_NOINPUT = 0 # Unix only -EX_NOUSER = 0 # Unix only -EX_NOHOST = 0 # Unix only -EX_UNAVAILABLE = 0 # Unix only -EX_SOFTWARE = 0 # Unix only -EX_OSERR = 0 # Unix only -EX_OSFILE = 0 # Unix only -EX_CANTCREAT = 0 # Unix only -EX_IOERR = 0 # Unix only -EX_TEMPFAIL = 0 # Unix only -EX_PROTOCOL = 0 # Unix only -EX_NOPERM = 0 # Unix only -EX_CONFIG = 0 # Unix only -EX_NOTFOUND = 0 # Unix only +EX_OK: int # Unix only +EX_USAGE: int # Unix only +EX_DATAERR: int # Unix only +EX_NOINPUT: int # Unix only +EX_NOUSER: int # Unix only +EX_NOHOST: int # Unix only +EX_UNAVAILABLE: int # Unix only +EX_SOFTWARE: int # Unix only +EX_OSERR: int # Unix only +EX_OSFILE: int # Unix only +EX_CANTCREAT: int # Unix only +EX_IOERR: int # Unix only +EX_TEMPFAIL: int # Unix only +EX_PROTOCOL: int # Unix only +EX_NOPERM: int # Unix only +EX_CONFIG: int # Unix only +EX_NOTFOUND: int # Unix only -P_NOWAIT = 0 -P_NOWAITO = 0 -P_WAIT = 0 -# P_DETACH = 0 # Windows only -# P_OVERLAY = 0 # Windows only +P_NOWAIT: int +P_NOWAITO: int +P_WAIT: int +if sys.platform == 'win32': + P_DETACH: int # Windows only + P_OVERLAY: int # Windows only # wait()/waitpid() options -WNOHANG = 0 # Unix only -# WCONTINUED = 0 # some Unix systems -# WUNTRACED = 0 # Unix only +WNOHANG: int # Unix only +WCONTINUED: int # some Unix systems +WUNTRACED: int # Unix only -TMP_MAX = 0 # Undocumented, but used by tempfile +TMP_MAX: int # Undocumented, but used by tempfile # ----- os classes (structures) ----- if sys.version_info >= (3, 6): from builtins import _PathLike as PathLike # See comment in builtins -_PathType = Union[bytes, Text] +_PathType = path._PathType if sys.version_info >= (3, 6): class DirEntry(PathLike[AnyStr]): # This is what the scandir interator yields # The constructor is hidden - name = ... # type: AnyStr - path = ... # type: AnyStr + name: AnyStr + path: AnyStr def inode(self) -> int: ... def is_dir(self, follow_symlinks: bool = ...) -> bool: ... def is_file(self, follow_symlinks: bool = ...) -> bool: ... @@ -137,8 +141,8 @@ elif sys.version_info >= (3, 5): # This is what the scandir interator yields # The constructor is hidden - name = ... # type: AnyStr - path = ... # type: AnyStr + name: AnyStr + path: AnyStr def inode(self) -> int: ... def is_dir(self, follow_symlinks: bool = ...) -> bool: ... def is_file(self, follow_symlinks: bool = ...) -> bool: ... @@ -153,53 +157,53 @@ class stat_result: # st_ino, st_dev, st_nlink, st_uid, st_gid, st_size, st_atime, st_mtime, # st_ctime. More items may be added at the end by some implementations. - st_mode = 0 # protection bits, - st_ino = 0 # inode number, - st_dev = 0 # device, - st_nlink = 0 # number of hard links, - st_uid = 0 # user id of owner, - st_gid = 0 # group id of owner, - st_size = 0 # size of file, in bytes, - st_atime = 0.0 # time of most recent access, - st_mtime = 0.0 # time of most recent content modification, - st_ctime = 0.0 # platform dependent (time of most recent metadata change on Unix, or the time of creation on Windows) + st_mode: int # protection bits, + st_ino: int # inode number, + st_dev: int # device, + st_nlink: int # number of hard links, + st_uid: int # user id of owner, + st_gid: int # group id of owner, + st_size: int # size of file, in bytes, + st_atime: float # time of most recent access, + st_mtime: float # time of most recent content modification, + st_ctime: float # platform dependent (time of most recent metadata change on Unix, or the time of creation on Windows) if sys.version_info >= (3, 3): - st_atime_ns = 0 # time of most recent access, in nanoseconds - st_mtime_ns = 0 # time of most recent content modification in nanoseconds - st_ctime_ns = 0 # platform dependent (time of most recent metadata change on Unix, or the time of creation on Windows) in nanoseconds + st_atime_ns: int # time of most recent access, in nanoseconds + st_mtime_ns: int # time of most recent content modification in nanoseconds + st_ctime_ns: int # platform dependent (time of most recent metadata change on Unix, or the time of creation on Windows) in nanoseconds # not documented def __init__(self, tuple: Tuple[int, ...]) -> None: ... # On some Unix systems (such as Linux), the following attributes may also # be available: - st_blocks = 0 # number of blocks allocated for file - st_blksize = 0 # filesystem blocksize - st_rdev = 0 # type of device if an inode device - st_flags = 0 # user defined flags for file + st_blocks: int # number of blocks allocated for file + st_blksize: int # filesystem blocksize + st_rdev: int # type of device if an inode device + st_flags: int # user defined flags for file # On other Unix systems (such as FreeBSD), the following attributes may be # available (but may be only filled out if root tries to use them): - st_gen = 0 # file generation number - st_birthtime = 0 # time of file creation + st_gen: int # file generation number + st_birthtime: int # time of file creation # On Mac OS systems, the following attributes may also be available: - st_rsize = 0 - st_creator = 0 - st_type = 0 + st_rsize: int + st_creator: int + st_type: int class statvfs_result: # Unix only - f_bsize = 0 - f_frsize = 0 - f_blocks = 0 - f_bfree = 0 - f_bavail = 0 - f_files = 0 - f_ffree = 0 - f_favail = 0 - f_flag = 0 - f_namemax = 0 + f_bsize: int + f_frsize: int + f_blocks: int + f_bfree: int + f_bavail: int + f_files: int + f_ffree: int + f_favail: int + f_flag: int + f_namemax: int # ----- os function stubs ----- if sys.version_info >= (3, 6): @@ -236,10 +240,6 @@ def getppid() -> int: ... def getresuid() -> Tuple[int, int, int]: ... # Unix only def getresgid() -> Tuple[int, int, int]: ... # Unix only def getuid() -> int: ... # Unix only -def getenv(key: str, default: str = ...) -> str: ... -def getenvb(key: bytes, default: bytes = ...) -> bytes: ... -# TODO mixed str/bytes putenv arguments -def putenv(key: AnyStr, value: AnyStr) -> None: ... def setegid(egid: int) -> None: ... # Unix only def seteuid(euid: int) -> None: ... # Unix only def setgid(gid: int) -> None: ... # Unix only @@ -255,8 +255,20 @@ def setsid() -> None: ... # Unix only def setuid(uid: int) -> None: ... # Unix only def strerror(code: int) -> str: ... def umask(mask: int) -> int: ... -def uname() -> Tuple[str, str, str, str, str]: ... # Unix only -def unsetenv(key: _PathType) -> None: ... +if sys.version_info >= (3, 3): + from posix import uname_result + def uname() -> uname_result: ... # Unix only +else: + def uname() -> Tuple[str, str, str, str, str]: ... # Unix only + +@overload +def getenv(key: Text) -> Optional[str]: ... +@overload +def getenv(key: Text, default: _T) -> Union[str, _T]: ... +def getenvb(key: bytes, default: bytes = ...) -> bytes: ... +def putenv(key: Union[bytes, Text], value: Union[bytes, Text]) -> None: ... +def unsetenv(key: Union[bytes, Text]) -> None: ... + # Return IO or TextIO def fdopen(fd: int, mode: str = ..., buffering: int = ..., encoding: str = ..., errors: str = ..., newline: str = ..., closefd: bool = ...) -> Any: ... @@ -309,22 +321,37 @@ def major(device: int) -> int: ... def minor(device: int) -> int: ... def makedev(major: int, minor: int) -> int: ... def mkdir(path: _PathType, mode: int = ...) -> None: ... -def makedirs(path: _PathType, mode: int = ..., - exist_ok: bool = ...) -> None: ... +if sys.version_info >= (3, 4): + def makedirs(name: _PathType, mode: int = ..., + exist_ok: bool = ...) -> None: ... +else: + def makedirs(path: _PathType, mode: int = ..., + exist_ok: bool = ...) -> None: ... def pathconf(path: _PathType, name: Union[str, int]) -> int: ... # Unix only -def readlink(path: AnyStr) -> AnyStr: ... +if sys.version_info >= (3, 6): + def readlink(path: Union[AnyStr, PathLike[AnyStr]]) -> AnyStr: ... +else: + def readlink(path: AnyStr) -> AnyStr: ... def remove(path: _PathType) -> None: ... -def removedirs(path: _PathType) -> None: ... +if sys.version_info >= (3, 4): + def removedirs(name: _PathType) -> None: ... +else: + def removedirs(path: _PathType) -> None: ... def rename(src: _PathType, dst: _PathType) -> None: ... def renames(old: _PathType, new: _PathType) -> None: ... if sys.version_info >= (3, 3): def replace(src: _PathType, dst: _PathType) -> None: ... def rmdir(path: _PathType) -> None: ... -if sys.version_info >= (3, 5): +if sys.version_info >= (3, 6): @overload - def scandir(path: str = ...) -> Iterator[DirEntry[str]]: ... + def scandir() -> Iterator[DirEntry[str]]: ... @overload - def scandir(path: bytes) -> Iterator[DirEntry[bytes]]: ... + def scandir(path: Union[AnyStr, PathLike[AnyStr]]) -> Iterator[DirEntry[AnyStr]]: ... +elif sys.version_info >= (3, 5): + @overload + def scandir() -> Iterator[DirEntry[str]]: ... + @overload + def scandir(path: AnyStr) -> Iterator[DirEntry[AnyStr]]: ... def stat(path: _PathType) -> stat_result: ... def stat_float_times(newvalue: Union[bool, None] = ...) -> bool: ... def statvfs(path: _PathType) -> statvfs_result: ... # Unix only @@ -332,12 +359,22 @@ def symlink(source: _PathType, link_name: _PathType, target_is_directory: bool = ...) -> None: ... # final argument in Windows only def unlink(path: _PathType) -> None: ... -def utime(path: _PathType, times: Optional[Tuple[float, float]] = ...) -> None: ... +if sys.version_info >= (3, 0): + def utime(path: _PathType, times: Optional[Union[Tuple[int, int], Tuple[float, float]]] = ..., + ns: Optional[Tuple[int, int]] = ..., dir_fd: Optional[int] = ..., + follow_symlinks: bool = ...) -> None: ... +else: + def utime(path: _PathType, times: Optional[Tuple[float, float]]) -> None: ... -# TODO onerror: function from OSError to void -def walk(top: AnyStr, topdown: bool = ..., onerror: Any = ..., - followlinks: bool = ...) -> Iterator[Tuple[AnyStr, List[AnyStr], - List[AnyStr]]]: ... +if sys.version_info >= (3, 6): + def walk(top: Union[AnyStr, PathLike[AnyStr]], topdown: bool = ..., + onerror: Optional[Callable[[OSError], Any]] = ..., + followlinks: bool = ...) -> Iterator[Tuple[AnyStr, List[AnyStr], + List[AnyStr]]]: ... +else: + def walk(top: AnyStr, topdown: bool = ..., onerror: Optional[Callable[[OSError], Any]] = ..., + followlinks: bool = ...) -> Iterator[Tuple[AnyStr, List[AnyStr], + List[AnyStr]]]: ... def abort() -> NoReturn: ... # These are defined as execl(file, *args) but the first *arg is mandatory. @@ -364,11 +401,17 @@ def killpg(pgid: int, sig: int) -> None: ... # Unix only def nice(increment: int) -> int: ... # Unix only def plock(op: int) -> None: ... # Unix only ???op is int? -class popen(_TextIOWrapper): - # TODO 'b' modes or bytes command not accepted? - def __init__(self, command: str, mode: str = ..., - bufsize: int = ...) -> None: ... - def close(self) -> Any: ... # may return int +if sys.version_info >= (3, 0): + class popen(_TextIOWrapper): + # TODO 'b' modes or bytes command not accepted? + def __init__(self, command: str, mode: str = ..., + bufsize: int = ...) -> None: ... + def close(self) -> Any: ... # may return int +else: + def popen(command: str, *args, **kwargs) -> Optional[IO[Any]]: ... + def popen2(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any]]: ... + def popen3(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any], IO[Any]]: ... + def popen4(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any]]: ... def spawnl(mode: int, path: _PathType, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ... def spawnle(mode: int, path: _PathType, arg0: Union[bytes, Text], @@ -404,13 +447,21 @@ def getloadavg() -> Tuple[float, float, float]: ... # Unix only def sysconf(name: Union[str, int]) -> int: ... # Unix only def urandom(n: int) -> bytes: ... -def sched_getaffinity(id: int) -> Set[int]: ... -class waitresult: - si_pid = 0 -def waitid(idtype: int, id: int, options: int) -> waitresult: ... -P_ALL = 0 -WEXITED = 0 -WNOWAIT = 0 +if sys.version_info >= (3, 0): + def sched_getaffinity(id: int) -> Set[int]: ... +if sys.version_info >= (3, 3): + class waitresult: + si_pid: int + def waitid(idtype: int, id: int, options: int) -> waitresult: ... + +if sys.version_info < (3, 0): + def tmpfile() -> IO[Any]: ... + def tmpnam() -> str: ... + def tempnam(dir: str = ..., prefix: str = ...) -> str: ... + +P_ALL: int +WEXITED: int +WNOWAIT: int if sys.version_info >= (3, 3): def sync() -> None: ... # Unix only @@ -422,7 +473,8 @@ if sys.version_info >= (3, 3): dir_fd: int = ...) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr], int]]: ... # Unix only - def get_terminal_size(fd: int = ...) -> Tuple[int, int]: ... + terminal_size = NamedTuple('terminal_size', [('columns', int), ('lines', int)]) + def get_terminal_size(fd: int = ...) -> terminal_size: ... if sys.version_info >= (3, 4): def cpu_count() -> Optional[int]: ... diff --git a/python/helpers/typeshed/stdlib/3/os/path.pyi b/python/helpers/typeshed/stdlib/3/os/path.pyi index c695c5738ac4..993d3aa1aaf0 100644 --- a/python/helpers/typeshed/stdlib/3/os/path.pyi +++ b/python/helpers/typeshed/stdlib/3/os/path.pyi @@ -2,9 +2,20 @@ # Ron Murawski # based on http://docs.python.org/3.2/library/os.path.html - +# adapted for 2.7 by Michal Pokorny import sys -from typing import overload, List, Any, AnyStr, Sequence, Tuple, BinaryIO, TextIO +from typing import ( + overload, List, Any, AnyStr, Sequence, Tuple, BinaryIO, TextIO, + TypeVar, Union, Text, Callable +) + +_T = TypeVar('_T') + +if sys.version_info >= (3, 6): + from builtins import _PathLike + _PathType = Union[bytes, Text, _PathLike] +else: + _PathType = Union[bytes, Text] # ----- os.path variables ----- supports_unicode_filenames = False @@ -25,41 +36,70 @@ def basename(path: AnyStr) -> AnyStr: ... if sys.version_info >= (3, 5): def commonpath(paths: Sequence[AnyStr]) -> AnyStr: ... -# NOTE: Empty List[bytes] results in '' (str) => fall back to Any return type. -def commonprefix(list: List[AnyStr]) -> Any: ... +# NOTE: Empty lists results in '' (str) regardless of contained type. +# Also, in Python 2 mixed sequences of Text and bytes results in either Text or bytes +# So, fall back to Any +def commonprefix(list: Sequence[AnyStr]) -> Any: ... + def dirname(path: AnyStr) -> AnyStr: ... -def exists(path: AnyStr) -> bool: ... -def lexists(path: AnyStr) -> bool: ... +def exists(path: _PathType) -> bool: ... +def lexists(path: _PathType) -> bool: ... def expanduser(path: AnyStr) -> AnyStr: ... def expandvars(path: AnyStr) -> AnyStr: ... +# These return float if os.stat_float_times() == True, +# but int is a subclass of float. +def getatime(path: _PathType) -> float: ... +def getmtime(path: _PathType) -> float: ... +def getctime(path: _PathType) -> float: ... -# These return float if os.stat_float_times() == True -def getatime(path: AnyStr) -> Any: ... -def getmtime(path: AnyStr) -> Any: ... -def getctime(path: AnyStr) -> Any: ... +def getsize(path: _PathType) -> int: ... +def isabs(path: _PathType) -> bool: ... +def isfile(path: _PathType) -> bool: ... +def isdir(path: _PathType) -> bool: ... +def islink(path: _PathType) -> bool: ... +def ismount(path: _PathType) -> bool: ... -def getsize(path: AnyStr) -> int: ... -def isabs(path: AnyStr) -> bool: ... -def isfile(path: AnyStr) -> bool: ... -def isdir(path: AnyStr) -> bool: ... -def islink(path: AnyStr) -> bool: ... -def ismount(path: AnyStr) -> bool: ... - -def join(path: AnyStr, *paths: AnyStr) -> AnyStr: ... +if sys.version_info < (3, 0): + # Make sure signatures are disjunct, and allow combinations of bytes and unicode. + # (Since Python 2 allows that, too) + # Note that e.g. os.path.join("a", "b", "c", "d", u"e") will still result in + # a type error. + @overload + def join(__p1: bytes, *p: bytes) -> bytes: ... + @overload + def join(__p1: Text, *p: _PathType) -> Text: ... + @overload + def join(__p1: bytes, __p2: Text, *p: _PathType) -> Text: ... + @overload + def join(__p1: bytes, __p2: bytes, __p3: Text, *p: _PathType) -> Text: ... + @overload + def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: _PathType) -> Text: ... +else: + def join(path: AnyStr, *paths: AnyStr) -> AnyStr: ... def normcase(path: AnyStr) -> AnyStr: ... def normpath(path: AnyStr) -> AnyStr: ... -def realpath(path: AnyStr) -> AnyStr: ... -def relpath(path: AnyStr, start: AnyStr = ...) -> AnyStr: ... +if sys.platform == 'win32': + def realpath(path: AnyStr) -> AnyStr: ... +else: + def realpath(filename: AnyStr) -> AnyStr: ... +def relpath(path: AnyStr, start: _PathType = ...) -> AnyStr: ... -def samefile(path1: AnyStr, path2: AnyStr) -> bool: ... +def samefile(path1: _PathType, path2: _PathType) -> bool: ... def sameopenfile(fp1: int, fp2: int) -> bool: ... +# TODO # def samestat(stat1: stat_result, # stat2: stat_result) -> bool: ... # Unix only -def split(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... +if sys.version_info >= (3, 6): + def split(path: Union[AnyStr, _PathLike[AnyStr]]) -> Tuple[AnyStr, AnyStr]: ... +else: + def split(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... def splitdrive(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... def splitext(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... -# def splitunc(path: str) -> Tuple[str, str]: ... # Windows only, deprecated +def splitunc(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... # Windows only, deprecated + +if sys.version_info < (3,): + def walk(path: AnyStr, visit: Callable[[_T, AnyStr, List[AnyStr]], Any], arg: _T) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/posix.pyi b/python/helpers/typeshed/stdlib/3/posix.pyi index 03e452351a2c..09e2e4f196f9 100644 --- a/python/helpers/typeshed/stdlib/3/posix.pyi +++ b/python/helpers/typeshed/stdlib/3/posix.pyi @@ -2,5 +2,11 @@ # NOTE: These are incomplete! +import sys import typing from os import stat_result +from typing import NamedTuple + +if sys.version_info >= (3, 3): + uname_result = NamedTuple('uname_result', [('sysname', str), ('nodename', str), + ('release', str), ('version', str), ('machine', str)]) diff --git a/python/helpers/typeshed/stdlib/3/queue.pyi b/python/helpers/typeshed/stdlib/3/queue.pyi index 9827bc7d39b8..1eb7360fa9a4 100644 --- a/python/helpers/typeshed/stdlib/3/queue.pyi +++ b/python/helpers/typeshed/stdlib/3/queue.pyi @@ -10,15 +10,21 @@ class Empty(Exception): ... class Full(Exception): ... class Queue(Generic[_T]): + maxsize = ... # type: int def __init__(self, maxsize: int = ...) -> None: ... + def _init(self, maxsize: int) -> None: ... + def empty(self) -> bool: ... def full(self) -> bool: ... def get(self, block: bool = ..., timeout: Optional[float] = ...) -> _T: ... def get_nowait(self) -> _T: ... + def _get(self) -> _T: ... def put(self, item: _T, block: bool = ..., timeout: Optional[float] = ...) -> None: ... def put_nowait(self, item: _T) -> None: ... + def _put(self, item: _T) -> None: ... def join(self) -> None: ... def qsize(self) -> int: ... + def _qsize(self) -> int: ... def task_done(self) -> None: ... -class PriorityQueue(Queue): ... -class LifoQueue(Queue): ... +class PriorityQueue(Queue[_T]): ... +class LifoQueue(Queue[_T]): ... diff --git a/python/helpers/typeshed/stdlib/3/random.pyi b/python/helpers/typeshed/stdlib/3/random.pyi index f40d973205b5..e32f1bb6e930 100644 --- a/python/helpers/typeshed/stdlib/3/random.pyi +++ b/python/helpers/typeshed/stdlib/3/random.pyi @@ -7,8 +7,9 @@ # ----- random classes ----- import _random +import sys from typing import ( - Any, TypeVar, Sequence, List, Callable, AbstractSet, Union + Any, TypeVar, Sequence, List, Callable, AbstractSet, Union, Optional ) _T = TypeVar('_T') @@ -50,6 +51,8 @@ def getrandbits(k: int) -> int: ... def randrange(start: int, stop: Union[None, int] = ..., step: int = ...) -> int: ... def randint(a: int, b: int) -> int: ... def choice(seq: Sequence[_T]) -> _T: ... +if sys.version_info >= (3, 6): + def choices(population: Sequence[_T], weights: Optional[Sequence[float]] = ..., *, cum_weights: Optional[Sequence[float]] = ..., k: int = ...) -> List[_T]: ... def shuffle(x: List[Any], random: Union[Callable[[], float], None] = ...) -> None: ... def sample(population: Union[Sequence[_T], AbstractSet[_T]], k: int) -> List[_T]: ... def random() -> float: ... diff --git a/python/helpers/typeshed/stdlib/3/re.pyi b/python/helpers/typeshed/stdlib/3/re.pyi index 5bdd0833e42c..451774f1ed16 100644 --- a/python/helpers/typeshed/stdlib/3/re.pyi +++ b/python/helpers/typeshed/stdlib/3/re.pyi @@ -5,62 +5,106 @@ # based on: http://docs.python.org/3.2/library/re.html # and http://hg.python.org/cpython/file/618ea5612e83/Lib/re.py +import sys from typing import ( List, Iterator, overload, Callable, Tuple, Sequence, Dict, - Generic, AnyStr, Match, Pattern, Any, Optional + Generic, AnyStr, Match, Pattern, Any, Optional, Union ) # ----- re variables and constants ----- -A = 0 -ASCII = 0 -DEBUG = 0 -I = 0 -IGNORECASE = 0 -L = 0 -LOCALE = 0 -M = 0 -MULTILINE = 0 -S = 0 -DOTALL = 0 -X = 0 -VERBOSE = 0 -U = 0 -UNICODE = 0 +if sys.version_info >= (3, 6): + import enum + class RegexFlag(enum.IntFlag): + A = 0 + ASCII = 0 + DEBUG = 0 + I = 0 + IGNORECASE = 0 + L = 0 + LOCALE = 0 + M = 0 + MULTILINE = 0 + S = 0 + DOTALL = 0 + X = 0 + VERBOSE = 0 + U = 0 + UNICODE = 0 + T = 0 + TEMPLATE = 0 + + A = RegexFlag.A + ASCII = RegexFlag.ASCII + DEBUG = RegexFlag.DEBUG + I = RegexFlag.I + IGNORECASE = RegexFlag.IGNORECASE + L = RegexFlag.L + LOCALE = RegexFlag.LOCALE + M = RegexFlag.M + MULTILINE = RegexFlag.MULTILINE + S = RegexFlag.S + DOTALL = RegexFlag.DOTALL + X = RegexFlag.X + VERBOSE = RegexFlag.VERBOSE + U = RegexFlag.U + UNICODE = RegexFlag.UNICODE + T = RegexFlag.T + TEMPLATE = RegexFlag.TEMPLATE + _FlagsType = Union[int, RegexFlag] +else: + A = 0 + ASCII = 0 + DEBUG = 0 + I = 0 + IGNORECASE = 0 + L = 0 + LOCALE = 0 + M = 0 + MULTILINE = 0 + S = 0 + DOTALL = 0 + X = 0 + VERBOSE = 0 + U = 0 + UNICODE = 0 + T = 0 + TEMPLATE = 0 + _FlagsType = int class error(Exception): ... @overload -def compile(pattern: AnyStr, flags: int = ...) -> Pattern[AnyStr]: ... +def compile(pattern: AnyStr, flags: _FlagsType = ...) -> Pattern[AnyStr]: ... @overload -def compile(pattern: Pattern[AnyStr], flags: int = ...) -> Pattern[AnyStr]: ... +def compile(pattern: Pattern[AnyStr], flags: _FlagsType = ...) -> Pattern[AnyStr]: ... @overload -def search(pattern: AnyStr, string: AnyStr, flags: int = ...) -> Match[AnyStr]: ... +def search(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr]: ... @overload -def search(pattern: Pattern[AnyStr], string: AnyStr, flags: int = ...) -> Match[AnyStr]: ... +def search(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr]: ... @overload -def match(pattern: AnyStr, string: AnyStr, flags: int = ...) -> Match[AnyStr]: ... +def match(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr]: ... @overload -def match(pattern: Pattern[AnyStr], string: AnyStr, flags: int = ...) -> Match[AnyStr]: ... +def match(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> Match[AnyStr]: ... # New in Python 3.4 @overload -def fullmatch(pattern: AnyStr, string: AnyStr, flags: int = ...) -> Optional[Match[AnyStr]]: ... +def fullmatch(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> Optional[Match[AnyStr]]: ... @overload -def fullmatch(pattern: Pattern[AnyStr], string: AnyStr, flags: int = ...) -> Optional[Match[AnyStr]]: ... +def fullmatch(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> Optional[Match[AnyStr]]: ... @overload def split(pattern: AnyStr, string: AnyStr, - maxsplit: int = ..., flags: int = ...) -> List[AnyStr]: ... + maxsplit: int = ..., flags: _FlagsType = ...) -> List[AnyStr]: ... @overload def split(pattern: Pattern[AnyStr], string: AnyStr, - maxsplit: int = ..., flags: int = ...) -> List[AnyStr]: ... + maxsplit: int = ..., flags: _FlagsType = ...) -> List[AnyStr]: ... @overload -def findall(pattern: AnyStr, string: AnyStr, flags: int = ...) -> List[Any]: ... +def findall(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> List[Any]: ... @overload -def findall(pattern: Pattern[AnyStr], string: AnyStr, flags: int = ...) -> List[Any]: ... +def findall(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> List[Any]: ... # Return an iterator yielding match objects over all non-overlapping matches # for the RE pattern in string. The string is scanned left-to-right, and @@ -68,39 +112,40 @@ def findall(pattern: Pattern[AnyStr], string: AnyStr, flags: int = ...) -> List[ # result unless they touch the beginning of another match. @overload def finditer(pattern: AnyStr, string: AnyStr, - flags: int = ...) -> Iterator[Match[AnyStr]]: ... + flags: _FlagsType = ...) -> Iterator[Match[AnyStr]]: ... @overload def finditer(pattern: Pattern[AnyStr], string: AnyStr, - flags: int = ...) -> Iterator[Match[AnyStr]]: ... + flags: _FlagsType = ...) -> Iterator[Match[AnyStr]]: ... @overload def sub(pattern: AnyStr, repl: AnyStr, string: AnyStr, count: int = ..., - flags: int = ...) -> AnyStr: ... + flags: _FlagsType = ...) -> AnyStr: ... @overload def sub(pattern: AnyStr, repl: Callable[[Match[AnyStr]], AnyStr], - string: AnyStr, count: int = ..., flags: int = ...) -> AnyStr: ... + string: AnyStr, count: int = ..., flags: _FlagsType = ...) -> AnyStr: ... @overload def sub(pattern: Pattern[AnyStr], repl: AnyStr, string: AnyStr, count: int = ..., - flags: int = ...) -> AnyStr: ... + flags: _FlagsType = ...) -> AnyStr: ... @overload def sub(pattern: Pattern[AnyStr], repl: Callable[[Match[AnyStr]], AnyStr], - string: AnyStr, count: int = ..., flags: int = ...) -> AnyStr: ... + string: AnyStr, count: int = ..., flags: _FlagsType = ...) -> AnyStr: ... @overload def subn(pattern: AnyStr, repl: AnyStr, string: AnyStr, count: int = ..., - flags: int = ...) -> Tuple[AnyStr, int]: ... + flags: _FlagsType = ...) -> Tuple[AnyStr, int]: ... @overload def subn(pattern: AnyStr, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., - flags: int = ...) -> Tuple[AnyStr, int]: ... + flags: _FlagsType = ...) -> Tuple[AnyStr, int]: ... @overload def subn(pattern: Pattern[AnyStr], repl: AnyStr, string: AnyStr, count: int = ..., - flags: int = ...) -> Tuple[AnyStr, int]: ... + flags: _FlagsType = ...) -> Tuple[AnyStr, int]: ... @overload def subn(pattern: Pattern[AnyStr], repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., - flags: int = ...) -> Tuple[AnyStr, int]: ... + flags: _FlagsType = ...) -> Tuple[AnyStr, int]: ... def escape(string: AnyStr) -> AnyStr: ... def purge() -> None: ... +def template(pattern: Union[AnyStr, Pattern[AnyStr]], flags: _FlagsType = ...) -> Pattern[AnyStr]: ... diff --git a/python/helpers/typeshed/stdlib/3/reprlib.pyi b/python/helpers/typeshed/stdlib/3/reprlib.pyi new file mode 100644 index 000000000000..462251875f39 --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/reprlib.pyi @@ -0,0 +1,37 @@ +# Stubs for reprlib (Python 3) + +from array import array +from typing import Any, Callable, Deque, Dict, FrozenSet, List, Set, Tuple + +_ReprFunc = Callable[[Any], str] + +def recursive_repr(fillvalue: str = ...) -> Callable[[_ReprFunc], _ReprFunc]: ... + +class Repr: + maxlevel: int + maxdict: int + maxlist: int + maxtuple: int + maxset: int + maxfrozenset: int + maxdeque: int + maxarray: int + maxlong: int + maxstring: int + maxother: int + def __init__(self) -> None: ... + def repr(self, x: Any) -> str: ... + def repr1(self, x: Any, level: int) -> str: ... + def repr_tuple(self, x: Tuple[Any, ...], level: int) -> str: ... + def repr_list(self, x: List[Any], level: int) -> str: ... + def repr_array(self, x: array, level: int) -> str: ... + def repr_set(self, x: Set[Any], level: int) -> str: ... + def repr_frozenset(self, x: FrozenSet[Any], level: int) -> str: ... + def repr_deque(self, x: Deque[Any], level: int) -> str: ... + def repr_dict(self, x: Dict[Any, Any], level: int) -> str: ... + def repr_str(self, x: str, level: int) -> str: ... + def repr_int(self, x: int, level: int) -> str: ... + def repr_instance(self, x: Any, level: int) -> str: ... + +aRepr: Repr +def repr(x: object) -> str: ... diff --git a/python/helpers/typeshed/stdlib/3/resource.pyi b/python/helpers/typeshed/stdlib/3/resource.pyi index 2dcb9137e05c..b4c74d62098a 100644 --- a/python/helpers/typeshed/stdlib/3/resource.pyi +++ b/python/helpers/typeshed/stdlib/3/resource.pyi @@ -2,7 +2,7 @@ # NOTE: These are incomplete! -from typing import Tuple +from typing import Tuple, Optional, NamedTuple RLIMIT_AS = ... # type: int RLIMIT_CORE = ... # type: int @@ -25,7 +25,17 @@ RUSAGE_CHILDREN = ... # type: int RUSAGE_SELF = ... # type: int RUSAGE_THREAD = ... # type: int +_RUsage = NamedTuple('_RUsage', [('ru_utime', float), ('ru_stime', float), ('ru_maxrss', int), + ('ru_ixrss', int), ('ru_idrss', int), ('ru_isrss', int), + ('ru_minflt', int), ('ru_majflt', int), ('ru_nswap', int), + ('ru_inblock', int), ('ru_oublock', int), ('ru_msgsnd', int), + ('ru_msgrcv', int), ('ru_nsignals', int), ('ru_nvcsw', int), + ('ru_nivcsw', int)]) + +def getpagesize() -> int: ... def getrlimit(resource: int) -> Tuple[int, int]: ... +def getrusage(who: int) -> _RUsage: ... +def prlimit(pid: int, resource: int, limits: Optional[Tuple[int, int]]) -> Tuple[int, int]: ... def setrlimit(resource: int, limits: Tuple[int, int]) -> None: ... # NOTE: This is an alias of OSError in Python 3.3. diff --git a/python/helpers/typeshed/stdlib/3/runpy.pyi b/python/helpers/typeshed/stdlib/3/runpy.pyi index 5768a4c726a0..193a320eb9e6 100644 --- a/python/helpers/typeshed/stdlib/3/runpy.pyi +++ b/python/helpers/typeshed/stdlib/3/runpy.pyi @@ -1,7 +1,3 @@ -# Stubs for runpy (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class _TempModule: diff --git a/python/helpers/typeshed/stdlib/3/shlex.pyi b/python/helpers/typeshed/stdlib/3/shlex.pyi index ed23d5aa3eb6..6936d61d19b8 100644 --- a/python/helpers/typeshed/stdlib/3/shlex.pyi +++ b/python/helpers/typeshed/stdlib/3/shlex.pyi @@ -2,7 +2,8 @@ # Based on http://docs.python.org/3.2/library/shlex.html -from typing import List, Tuple, Any, TextIO, Union, Optional +from typing import List, Tuple, Any, TextIO, Union, Optional, Iterator +import sys def split(s: str, comments: bool = ..., posix: bool = ...) -> List[str]: ... @@ -10,7 +11,7 @@ def split(s: str, comments: bool = ..., # Added in 3.3, use (undocumented) pipes.quote in previous versions. def quote(s: str) -> str: ... -class shlex: +class shlex(Iterator[str]): commenters = ... # type: str wordchars = ... # type: str whitespace = ... # type: str @@ -25,9 +26,15 @@ class shlex: lineno = 0 token = ... # type: str eof = ... # type: str + if sys.version_info >= (3, 6): + punctuation_chars = ... # type: str - def __init__(self, instream: Union[str, TextIO] = ..., infile: Optional[str] = ..., - posix: bool = ...) -> None: ... + if sys.version_info >= (3, 6): + def __init__(self, instream: Union[str, TextIO] = ..., infile: Optional[str] = ..., + posix: bool = ..., punctuation_chars: Union[bool, str] = ...) -> None: ... + else: + def __init__(self, instream: Union[str, TextIO] = ..., infile: Optional[str] = ..., + posix: bool = ...) -> None: ... def get_token(self) -> str: ... def push_token(self, tok: str) -> None: ... def read_token(self) -> str: ... diff --git a/python/helpers/typeshed/stdlib/3/shutil.pyi b/python/helpers/typeshed/stdlib/3/shutil.pyi index c2865c831618..afb2e8e4f84b 100644 --- a/python/helpers/typeshed/stdlib/3/shutil.pyi +++ b/python/helpers/typeshed/stdlib/3/shutil.pyi @@ -1,4 +1,5 @@ # Stubs for shutil +import os import sys # Based on http://docs.python.org/3.2/library/shutil.html @@ -9,80 +10,103 @@ import sys from typing import ( List, Iterable, Callable, Any, Tuple, Sequence, NamedTuple, IO, - AnyStr, Optional + AnyStr, Optional, Union ) +if sys.version_info >= (3, 6): + _Path = Union[str, os.PathLike[str]] + # Return value of some functions that may either return a path-like object that was passed in or + # a string + _PathReturn = Any +else: + _Path = str + _PathReturn = str + def copyfileobj(fsrc: IO[AnyStr], fdst: IO[AnyStr], length: int = ...) -> None: ... -def copyfile(src: str, dst: str) -> None: ... if sys.version_info >= (3, 3): - def copymode(src: str, dst: str, *, + def copyfile(src: _Path, dst: _Path, *, + follow_symlinks: bool = ...) -> _PathReturn: ... + def copymode(src: _Path, dst: _Path, *, follow_symlinks: bool = ...) -> None: ... - def copystat(src: str, dst: str, *, + def copystat(src: _Path, dst: _Path, *, follow_symlinks: bool = ...) -> None: ... - def copy(src: str, dst: str, *, - follow_symlinks: bool = ...) -> None: ... - def copy2(src: str, dst: str, *, - follow_symlinks: bool = ...) -> None: ... + def copy(src: _Path, dst: _Path, *, + follow_symlinks: bool = ...) -> _PathReturn: ... + def copy2(src: _Path, dst: _Path, *, + follow_symlinks: bool = ...) -> _PathReturn: ... 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 copyfile(src: _Path, dst: _Path) -> None: ... + def copymode(src: _Path, dst: _Path) -> None: ... + def copystat(src: _Path, dst: _Path) -> None: ... + def copy(src: _Path, dst: _Path) -> None: ... + def copy2(src: _Path, dst: _Path) -> None: ... -def ignore_patterns(*patterns: str) -> Callable[[str, List[str]], - Iterable[str]]: ... +def ignore_patterns(*patterns: _Path) -> Callable[[_Path, List[str]], + Iterable[str]]: ... +_IgnoreFn = Union[None, Callable[[str, List[str]], Iterable[str]], Callable[[_Path, List[str]], Iterable[str]]] if sys.version_info >= (3, 3): - def copytree(src: str, dst: str, symlinks: bool = ..., - ignore: Optional[Callable[[str, List[str]], - Iterable[str]]] = ..., + def copytree(src: _Path, dst: _Path, symlinks: bool = ..., + ignore: _IgnoreFn = ..., copy_function: Callable[[str, str], None] = ..., - ignore_dangling_symlinks: bool = ...) -> str: ... + ignore_dangling_symlinks: bool = ...) -> _PathReturn: ... else: def copytree(src: str, dst: str, symlinks: bool = ..., - ignore: Optional[Callable[[str, List[str]], - Iterable[str]]] = ..., + ignore: _IgnoreFn = ..., 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 rmtree(path: _Path, ignore_errors: bool = ..., + onerror: Callable[[Any, Any, Any], None] = ...) -> None: ... if sys.version_info >= (3, 5): - def move(src: str, dst: str, - copy_function: Callable[[str, str], None] = ...) -> str: ... + def move(src: _Path, dst: _Path, + copy_function: Union[Callable[[str, str], None], Callable[[_Path, _Path], None]] = ...) -> _PathReturn: ... elif sys.version_info >= (3, 3): - def move(src: str, dst: str) -> str: ... + def move(src: _Path, dst: _Path) -> str: ... else: - def move(src: str, dst: str) -> None: ... + def move(src: _Path, dst: _Path) -> 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] = ..., + def disk_usage(path: _Path) -> _ntuple_diskusage: ... + def chown(path: _Path, user: Optional[str] = ..., group: Optional[str] = ...) -> None: ... - def which(cmd: str, mode: int = ..., - path: Optional[str] = ...) -> Optional[str]: ... + def which(cmd: _Path, mode: int = ..., + path: Optional[_Path] = ...) -> Optional[str]: ... -class Error(Exception): ... if sys.version_info >= (3, 4): + class Error(OSError): ... class SameFileError(Error): ... + class SpecialFileError(OSError): ... + class ExecError(OSError): ... + class ReadError(OSError): ... +else: + class Error(EnvironmentError): ... + class SpecialFileError(EnvironmentError): ... + class ExecError(EnvironmentError): ... + class ReadError(EnvironmentError): ... +class RegistryError(Exception): ... -def make_archive(base_name: str, format: str, root_dir: str = ..., - base_dir: str = ..., verbose: bool = ..., +def make_archive(base_name: str, format: str, root_dir: _Path = ..., + base_dir: _Path = ..., verbose: bool = ..., dry_run: bool = ..., owner: str = ..., group: str = ..., logger: Any = ...) -> str: ... def get_archive_formats() -> List[Tuple[str, str]]: ... + +# TODO function is a callback that receives keyword arguments; should make it not use Any +# once we have support for callable types with keyword args def register_archive_format(name: str, function: Any, extra_args: Sequence[Tuple[str, Any]] = ..., description: str = ...) -> None: ... def unregister_archive_format(name: str) -> None: ... -def unpack_archive(filename: str, extract_dir: str = ..., +# Should be _Path once http://bugs.python.org/issue30218 is fixed +def unpack_archive(filename: str, extract_dir: _Path = ..., format: str = ...) -> None: ... def register_unpack_format(name: str, extensions: List[str], function: Any, extra_args: Sequence[Tuple[str, Any]] = ..., @@ -91,4 +115,4 @@ def unregister_unpack_format(name: str) -> None: ... def get_unpack_formats() -> List[Tuple[str, List[str], str]]: ... if sys.version_info >= (3, 3): - def get_terminal_size(fallback: Tuple[int, int] = ...) -> Tuple[int, int]: ... + def get_terminal_size(fallback: Tuple[int, int] = ...) -> os.terminal_size: ... diff --git a/python/helpers/typeshed/stdlib/3/smtplib.pyi b/python/helpers/typeshed/stdlib/3/smtplib.pyi index 56a4729fd033..982238229da8 100644 --- a/python/helpers/typeshed/stdlib/3/smtplib.pyi +++ b/python/helpers/typeshed/stdlib/3/smtplib.pyi @@ -1,29 +1,30 @@ -# Stubs for smtplib (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. +from email.message import Message as _Message +from typing import ( + Any, AnyStr, Dict, Generic, List, Optional, Sequence, Tuple, Union) -from typing import Any +_Reply = Tuple[int, bytes] +_SendErrs = Dict[str, _Reply] class SMTPException(OSError): ... class SMTPServerDisconnected(SMTPException): ... class SMTPResponseException(SMTPException): - smtp_code = ... # type: Any - smtp_error = ... # type: Any - args = ... # type: Any - def __init__(self, code, msg) -> None: ... + smtp_code = ... # type: int + smtp_error = ... # type: Union[bytes, str] + args = ... # type: Union[Tuple[int, Union[bytes, str]], Tuple[int, bytes, str]] + def __init__(self, code: int, msg: Union[bytes, str]) -> None: ... class SMTPSenderRefused(SMTPResponseException): - smtp_code = ... # type: Any - smtp_error = ... # type: Any - sender = ... # type: Any - args = ... # type: Any - def __init__(self, code, msg, sender) -> None: ... + smtp_code = ... # type: int + smtp_error = ... # type: bytes + sender = ... # type: str + args = ... # type: Tuple[int, bytes, str] + def __init__(self, code: int, msg: bytes, sender: str) -> None: ... class SMTPRecipientsRefused(SMTPException): - recipients = ... # type: Any - args = ... # type: Any - def __init__(self, recipients) -> None: ... + recipients = ... # type: _SendErrs + args = ... # type: Tuple[_SendErrs] + def __init__(self, recipients: _SendErrs) -> None: ... class SMTPDataError(SMTPResponseException): ... class SMTPConnectError(SMTPResponseException): ... @@ -34,36 +35,37 @@ def quoteaddr(addrstring): ... def quotedata(data): ... class SMTP: - debuglevel = ... # type: Any + debuglevel = ... # type: int file = ... # type: Any helo_resp = ... # type: Any ehlo_msg = ... # type: Any ehlo_resp = ... # type: Any does_esmtp = ... # type: Any default_port = ... # type: Any - timeout = ... # type: Any + timeout = ... # type: float esmtp_features = ... # type: Any source_address = ... # type: Any local_hostname = ... # type: Any - def __init__(self, host=..., port=..., local_hostname=..., timeout=..., - source_address=...): ... + def __init__(self, host: str = ..., port: int = ..., + local_hostname: Optional[str] = ..., timeout: float = ..., + source_address: Tuple[str, int] = ...) -> None: ... def __enter__(self): ... def __exit__(self, *args): ... - def set_debuglevel(self, debuglevel): ... + def set_debuglevel(self, debuglevel: int) -> None: ... sock = ... # type: Any def connect(self, host=..., port=..., source_address=...): ... def send(self, s): ... def putcmd(self, cmd, args=...): ... - def getreply(self): ... + def getreply(self) -> _Reply: ... def docmd(self, cmd, args=...): ... def helo(self, name=...): ... def ehlo(self, name=...): ... def has_extn(self, opt): ... def help(self, args=...): ... - def rset(self): ... - def noop(self): ... - def mail(self, sender, options=...): ... - def rcpt(self, recip, options=...): ... + def rset(self) -> _Reply: ... + def noop(self) -> _Reply: ... + def mail(self, sender: str, options: Sequence[str] = ...) -> _Reply: ... + def rcpt(self, recip: str, options: Sequence[str] = ...) -> _Reply: ... def data(self, msg): ... def verify(self, address): ... vrfy = ... # type: Any @@ -71,12 +73,15 @@ class SMTP: def ehlo_or_helo_if_needed(self): ... def login(self, user, password): ... def starttls(self, keyfile=..., certfile=..., context=...): ... - def sendmail(self, from_addr, to_addrs, msg, mail_options=..., - rcpt_options=...): ... - def send_message(self, msg, from_addr=..., to_addrs=..., mail_options=..., - rcpt_options=...): ... + def sendmail(self, from_addr: str, to_addrs: Union[str, Sequence[str]], + msg: Union[bytes, str], mail_options: Sequence[str] = ..., + rcpt_options: List[str] = ...) -> _SendErrs: ... + def send_message(self, msg: _Message, from_addr: Optional[str] = ..., + to_addrs: Optional[Union[str, Sequence[str]]] = ..., + mail_options: List[str] = ..., + rcpt_options: Sequence[str] = ...) -> _SendErrs: ... def close(self): ... - def quit(self): ... + def quit(self) -> _Reply: ... class SMTP_SSL(SMTP): default_port = ... # type: Any @@ -88,7 +93,9 @@ class SMTP_SSL(SMTP): class LMTP(SMTP): ehlo_msg = ... # type: Any - def __init__(self, host=..., port=..., local_hostname=..., source_address=...) -> None: ... + def __init__(self, host: str = ..., port: int = ..., + local_hostname: Optional[str] = ..., + source_address: Optional[Tuple[str, int]] = ...) -> None: ... sock = ... # type: Any file = ... # type: Any def connect(self, host=..., port=..., source_address=...): ... diff --git a/python/helpers/typeshed/stdlib/3/socketserver.pyi b/python/helpers/typeshed/stdlib/3/socketserver.pyi index 14a739b80586..8d03b8f7df8d 100644 --- a/python/helpers/typeshed/stdlib/3/socketserver.pyi +++ b/python/helpers/typeshed/stdlib/3/socketserver.pyi @@ -50,15 +50,16 @@ class UDPServer(BaseServer): RequestHandlerClass: type, bind_and_activate: bool = ...) -> None: ... -class UnixStreamServer(BaseServer): - def __init__(self, server_address: Tuple[str, int], - RequestHandlerClass: type, - bind_and_activate: bool = ...) -> None: ... +if sys.platform != 'win32': + class UnixStreamServer(BaseServer): + def __init__(self, server_address: Tuple[str, int], + RequestHandlerClass: type, + bind_and_activate: bool = ...) -> None: ... -class UnixDatagramServer(BaseServer): - def __init__(self, server_address: Tuple[str, int], - RequestHandlerClass: type, - bind_and_activate: bool = ...) -> None: ... + class UnixDatagramServer(BaseServer): + def __init__(self, server_address: Tuple[str, int], + RequestHandlerClass: type, + bind_and_activate: bool = ...) -> None: ... class ForkingMixIn: ... class ThreadingMixIn: ... @@ -67,6 +68,9 @@ class ForkingTCPServer(ForkingMixIn, TCPServer): ... class ForkingUDPServer(ForkingMixIn, UDPServer): ... class ThreadingTCPServer(ThreadingMixIn, TCPServer): ... class ThreadingUDPServer(ThreadingMixIn, UDPServer): ... +if sys.platform != 'win32': + class ThreadingUnixStreamServer(ThreadingMixIn, UnixStreamServer): ... + class ThreadingUnixDatagramServer(ThreadingMixIn, UnixDatagramServer): ... class BaseRequestHandler: diff --git a/python/helpers/typeshed/stdlib/3/spwd.pyi b/python/helpers/typeshed/stdlib/3/spwd.pyi new file mode 100644 index 000000000000..0e55d74215ef --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/spwd.pyi @@ -0,0 +1,14 @@ +from typing import List, NamedTuple + +struct_spwd = NamedTuple("struct_spwd", [("sp_namp", str), + ("sp_pwdp", str), + ("sp_lstchg", int), + ("sp_min", int), + ("sp_max", int), + ("sp_warn", int), + ("sp_inact", int), + ("sp_expire", int), + ("sp_flag", int)]) + +def getspall() -> List[struct_spwd]: ... +def getspnam(name: str) -> struct_spwd: ... diff --git a/python/helpers/typeshed/stdlib/3/sqlite3/__init__.pyi b/python/helpers/typeshed/stdlib/3/sqlite3/__init__.pyi index fc22e5d50e0a..d5d20d67b58e 100644 --- a/python/helpers/typeshed/stdlib/3/sqlite3/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/sqlite3/__init__.pyi @@ -1,5 +1 @@ -# Stubs for sqlite3 (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from sqlite3.dbapi2 import * # noqa: F403 diff --git a/python/helpers/typeshed/stdlib/3/sqlite3/dbapi2.pyi b/python/helpers/typeshed/stdlib/3/sqlite3/dbapi2.pyi index ef46085cb7af..fc748e2da9df 100644 --- a/python/helpers/typeshed/stdlib/3/sqlite3/dbapi2.pyi +++ b/python/helpers/typeshed/stdlib/3/sqlite3/dbapi2.pyi @@ -1,11 +1,13 @@ # Filip Hron # based heavily on Andrey Vlasovskikh's python-skeletons https://github.com/JetBrains/python-skeletons/blob/master/sqlite3.py -from typing import Any, Union, List, AnyStr, Iterator, Optional -from numbers import Integral +import sys +from typing import Any, Union, List, Iterator, Optional, TypeVar, Callable from datetime import time, datetime from collections import Iterable +_T = TypeVar('_T') + paramstyle = ... # type: str threadsafety = ... # type: int apilevel = ... # type: str @@ -66,18 +68,15 @@ version = ... # type: str # TODO: adapt needs to get probed def adapt(obj, protocol, alternate): ... def complete_statement(sql: str) -> bool: ... -def connect(database: Union[bytes, AnyStr], - timeout: float = ..., - detect_types: int = ..., - isolation_level: Union[str, None] = ..., - check_same_thread: bool = ..., - factory: Union[Connection, None] = ..., - cached_statements: int = ...) -> Connection: ... +if sys.version_info >= (3, 4): + def connect(database: Union[bytes, str], timeout: float = ..., detect_types: int = ..., isolation_level: Union[str, None] = ..., check_same_thread: bool = ..., factory: Union[Connection, None] = ..., cached_statements: int = ..., uri: bool = ...) -> Connection: ... +else: + def connect(database: Union[bytes, str], timeout: float = ..., detect_types: int = ..., isolation_level: Union[str, None] = ..., check_same_thread: bool = ..., factory: Union[Connection, None] = ..., cached_statements: int = ...) -> Connection: ... def enable_callback_tracebacks(flag: bool) -> None: ... def enable_shared_cache(do_enable: int) -> None: ... -def register_adapter(type: type, callable: Any) -> None: ... +def register_adapter(type: _T, callable: Callable[[_T], Union[int, float, str, bytes]]) -> None: ... # TODO: sqlite3.register_converter.__doc__ specifies callable as unknown -def register_converter(typename: str, callable: bytes) -> None: ... +def register_converter(typename: str, callable: Callable[[bytes], Any]) -> None: ... class Cache: def __init__(self, *args, **kwargs) -> None: ... @@ -110,7 +109,7 @@ class Connection: def execute(self, sql: str, parameters: Iterable = ...) -> Cursor: ... # TODO: please check in executemany() if seq_of_parameters type is possible like this def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable]) -> Cursor: ... - def executescript(self, sql_script: Union[bytes, AnyStr]) -> Cursor: ... + def executescript(self, sql_script: Union[bytes, str]) -> Cursor: ... def interrupt(self, *args, **kwargs) -> None: ... def iterdump(self, *args, **kwargs) -> None: ... def rollback(self, *args, **kwargs) -> None: ... @@ -139,9 +138,9 @@ class Cursor(Iterator[Any]): def close(self, *args, **kwargs): ... def execute(self, sql: str, parameters: Iterable = ...) -> Cursor: ... def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable]): ... - def executescript(self, sql_script: Union[bytes, AnyStr]) -> Cursor: ... + def executescript(self, sql_script: Union[bytes, str]) -> Cursor: ... def fetchall(self) -> List[Any]: ... - def fetchmany(self, size: Integral = ...) -> List[Any]: ... + def fetchmany(self, size: Optional[int] = ...) -> List[Any]: ... def fetchone(self) -> Any: ... def setinputsizes(self, *args, **kwargs): ... def setoutputsize(self, *args, **kwargs): ... diff --git a/python/helpers/typeshed/stdlib/3/sre_constants.pyi b/python/helpers/typeshed/stdlib/3/sre_constants.pyi new file mode 100644 index 000000000000..c1dba3a05ca8 --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/sre_constants.pyi @@ -0,0 +1,40 @@ +# Source: https://github.com/python/cpython/blob/master/Lib/sre_constants.py + +from typing import Any, Dict, List, Optional, Union + +MAGIC = ... # type: int + +class error(Exception): + msg = ... # type: str + pattern = ... # type: Optional[Union[str, bytes]] + pos = ... # type: Optional[int] + lineno = ... # type: int + colno = ... # type: int + def __init__(self, msg: str, pattern: Union[str, bytes] = ..., pos: int = ...) -> None: ... + +class _NamedIntConstant(int): + name = ... # type: Any + def __new__(cls, value: int, name: str): ... + +MAXREPEAT = ... # type: _NamedIntConstant +OPCODES = ... # type: List[_NamedIntConstant] +ATCODES = ... # type: List[_NamedIntConstant] +CHCODES = ... # type: List[_NamedIntConstant] +OP_IGNORE = ... # type: Dict[_NamedIntConstant, _NamedIntConstant] +AT_MULTILINE = ... # type: Dict[_NamedIntConstant, _NamedIntConstant] +AT_LOCALE = ... # type: Dict[_NamedIntConstant, _NamedIntConstant] +AT_UNICODE = ... # type: Dict[_NamedIntConstant, _NamedIntConstant] +CH_LOCALE = ... # type: Dict[_NamedIntConstant, _NamedIntConstant] +CH_UNICODE = ... # type: Dict[_NamedIntConstant, _NamedIntConstant] +SRE_FLAG_TEMPLATE = ... # type: int +SRE_FLAG_IGNORECASE = ... # type: int +SRE_FLAG_LOCALE = ... # type: int +SRE_FLAG_MULTILINE = ... # type: int +SRE_FLAG_DOTALL = ... # type: int +SRE_FLAG_UNICODE = ... # type: int +SRE_FLAG_VERBOSE = ... # type: int +SRE_FLAG_DEBUG = ... # type: int +SRE_FLAG_ASCII = ... # type: int +SRE_INFO_PREFIX = ... # type: int +SRE_INFO_LITERAL = ... # type: int +SRE_INFO_CHARSET = ... # type: int diff --git a/python/helpers/typeshed/stdlib/3/sre_parse.pyi b/python/helpers/typeshed/stdlib/3/sre_parse.pyi new file mode 100644 index 000000000000..0c9859d26a8a --- /dev/null +++ b/python/helpers/typeshed/stdlib/3/sre_parse.pyi @@ -0,0 +1,81 @@ +# Source: https://github.com/python/cpython/blob/master/Lib/sre_parse.py + +from typing import ( + Any, Dict, FrozenSet, Iterable, List, Match, + Optional, Pattern as _Pattern, Tuple, Union +) +from sre_constants import _NamedIntConstant as NIC, error as _Error + +SPECIAL_CHARS = ... # type: str +REPEAT_CHARS = ... # type: str +DIGITS = ... # type: FrozenSet[str] +OCTDIGITS = ... # type: FrozenSet[str] +HEXDIGITS = ... # type: FrozenSet[str] +ASCIILETTERS = ... # type: FrozenSet[str] +WHITESPACE = ... # type: FrozenSet[str] +ESCAPES = ... # type: Dict[str, Tuple[NIC, int]] +CATEGORIES = ... # type: Dict[str, Union[Tuple[NIC, NIC], Tuple[NIC, List[Tuple[NIC, NIC]]]]] +FLAGS = ... # type: Dict[str, int] +GLOBAL_FLAGS = ... # type: int + +class Verbose(Exception): ... + +class Pattern: + flags = ... # type: int + groupdict = ... # type: Dict[str, int] + groupwidths = ... # type: List[Optional[int]] + lookbehindgroups = ... # type: Optional[int] + def __init__(self) -> None: ... + @property + def groups(self) -> int: ... + def opengroup(self, name: str = ...) -> int: ... + def closegroup(self, gid: int, p: SubPattern) -> None: ... + def checkgroup(self, gid: int) -> bool: ... + def checklookbehindgroup(self, gid: int, source: Tokenizer) -> None: ... + + +_OpSubpatternType = Tuple[Optional[int], int, int, SubPattern] +_OpGroupRefExistsType = Tuple[int, SubPattern, SubPattern] +_OpInType = List[Tuple[NIC, int]] +_OpBranchType = Tuple[None, List[SubPattern]] +_AvType = Union[_OpInType, _OpBranchType, Iterable[SubPattern], _OpGroupRefExistsType, _OpSubpatternType] +_CodeType = Tuple[NIC, _AvType] + + +class SubPattern: + pattern = ... # type: Pattern + data = ... # type: List[_CodeType] + width = ... # type: Optional[int] + def __init__(self, pattern: Pattern, data: List[_CodeType] = ...) -> None: ... + def dump(self, level: int = ...) -> None: ... + def __len__(self) -> int: ... + def __delitem__(self, index: Union[int, slice]) -> None: ... + def __getitem__(self, index: Union[int, slice]) -> Union[SubPattern, _CodeType]: ... + def __setitem__(self, index: Union[int, slice], code: _CodeType) -> None: ... + def insert(self, index: int, code: _CodeType) -> None: ... + def append(self, code: _CodeType) -> None: ... + def getwidth(self) -> int: ... + + +class Tokenizer: + istext = ... # type: bool + string = ... # type: Any + decoded_string = ... # type: str + index = ... # type: int + next = ... # type: Optional[str] + def __init__(self, string: Any) -> None: ... + def match(self, char: str) -> bool: ... + def get(self) -> Optional[str]: ... + def getwhile(self, n: int, charset: Iterable[str]) -> str: ... + def getuntil(self, terminator: str) -> str: ... + @property + def pos(self) -> int: ... + def tell(self) -> int: ... + def seek(self, index: int) -> None: ... + def error(self, msg: str, offset: int = ...) -> _Error: ... + +def fix_flags(src: Union[str, bytes], flag: int) -> int: ... +def parse(str: str, flags: int = ..., pattern: Pattern = ...) -> SubPattern: ... +_TemplateType = Tuple[List[Tuple[int, int]], List[str]] +def parse_template(source: str, pattern: _Pattern) -> _TemplateType: ... +def expand_template(template: _TemplateType, match: Match) -> str: ... diff --git a/python/helpers/typeshed/stdlib/3/ssl.pyi b/python/helpers/typeshed/stdlib/3/ssl.pyi index 87ddd659ec9b..060bccdcd471 100644 --- a/python/helpers/typeshed/stdlib/3/ssl.pyi +++ b/python/helpers/typeshed/stdlib/3/ssl.pyi @@ -102,6 +102,11 @@ PROTOCOL_TLSv1 = ... # type: int if sys.version_info >= (3, 4): PROTOCOL_TLSv1_1 = ... # type: int PROTOCOL_TLSv1_2 = ... # type: int +if sys.version_info >= (3, 5): + PROTOCOL_TLS = ... # type: int +if sys.version_info >= (3, 6): + PROTOCOL_TLS_CLIENT = ... # type: int + PROTOCOL_TLS_SERVER = ... # type: int OP_ALL = ... # type: int OP_NO_SSLv2 = ... # type: int @@ -114,6 +119,8 @@ OP_CIPHER_SERVER_PREFERENCE = ... # type: int OP_SINGLE_DH_USE = ... # type: int OP_SINGLE_ECDH_USE = ... # type: int OP_NO_COMPRESSION = ... # type: int +if sys.version_info >= (3, 6): + OP_NO_TICKET = ... # type: int if sys.version_info >= (3, 5): HAS_ALPN = ... # type: int @@ -168,6 +175,10 @@ class SSLSocket(socket.socket): context = ... # type: SSLContext server_side = ... # type: bool server_hostname = ... # type: Optional[str] + if sys.version_info >= (3, 6): + session = ... # type: Optional[SSLSession] + session_reused = ... # type: Optional[bool] + def read(self, len: int = ..., buffer: Optional[bytearray] = ...) -> bytes: ... def write(self, buf: bytes) -> int: ... @@ -205,11 +216,9 @@ class SSLContext: def load_default_certs(self, purpose: _PurposeType = ...) -> None: ... def load_verify_locations(self, cafile: Optional[str] = ..., capath: Optional[str] = ..., - cadata: Union[str, bytes, None] = ...) \ - -> None: ... + cadata: Union[str, bytes, None] = ...) -> None: ... def get_ca_certs(self, - binary_form: bool = ...) \ - -> Union[List[_PeerCertRetDictType], List[bytes]]: ... + binary_form: bool = ...) -> Union[List[_PeerCertRetDictType], List[bytes]]: ... else: def load_verify_locations(self, cafile: Optional[str] = ..., @@ -220,8 +229,7 @@ class SSLContext: def set_alpn_protocols(self, protocols: List[str]) -> None: ... def set_npn_protocols(self, protocols: List[str]) -> None: ... def set_servername_callback(self, - server_name_callback: Optional[_SrvnmeCbType]) \ - -> None: ... + server_name_callback: Optional[_SrvnmeCbType]) -> None: ... def load_dh_params(self, dhfile: str) -> None: ... def set_ecdh_curve(self, curve_name: str) -> None: ... def wrap_socket(self, sock: socket.socket, server_side: bool = ..., @@ -240,6 +248,9 @@ if sys.version_info >= (3, 5): context = ... # type: SSLContext server_side = ... # type: bool server_hostname = ... # type: Optional[str] + if sys.version_info >= (3, 6): + session = ... # type: Optional[SSLSession] + session_reused = ... # type: bool def read(self, len: int = ..., buffer: Optional[bytearray] = ...) -> bytes: ... def write(self, buf: bytes) -> int: ... @@ -260,6 +271,14 @@ if sys.version_info >= (3, 5): def write(self, buf: bytes) -> int: ... def write_eof(self) -> None: ... +if sys.version_info >= (3, 6): + class SSLSession: + id = ... # type: bytes + time = ... # type: int + timeout = ... # type: int + ticket_lifetime_hint = ... # type: int + has_ticket = ... # type: bool + # TODO below documented in cpython but not in docs.python.org # taken from python 3.4 diff --git a/python/helpers/typeshed/stdlib/3/string.pyi b/python/helpers/typeshed/stdlib/3/string.pyi index cff0336230ee..c07c186d1b1c 100644 --- a/python/helpers/typeshed/stdlib/3/string.pyi +++ b/python/helpers/typeshed/stdlib/3/string.pyi @@ -2,7 +2,7 @@ # Based on http://docs.python.org/3.2/library/string.html -from typing import Mapping, Sequence, Any, Optional, Union, List, Tuple, Iterable, AnyStr +from typing import Mapping, Sequence, Any, Optional, Union, List, Tuple, Iterable ascii_letters = ... # type: str ascii_lowercase = ... # type: str diff --git a/python/helpers/typeshed/stdlib/3/subprocess.pyi b/python/helpers/typeshed/stdlib/3/subprocess.pyi index a64162105c39..c0a861333886 100644 --- a/python/helpers/typeshed/stdlib/3/subprocess.pyi +++ b/python/helpers/typeshed/stdlib/3/subprocess.pyi @@ -2,10 +2,10 @@ # Based on http://docs.python.org/3.6/library/subprocess.html import sys -from typing import Sequence, Any, AnyStr, Mapping, Callable, Tuple, IO, Optional, Union, List, Type, Text +from typing import Sequence, Any, Mapping, Callable, Tuple, IO, Optional, Union, List, Type, Text from types import TracebackType -_FILE = Union[int, IO[Any]] +_FILE = Union[None, int, IO[Any]] _TXT = Union[bytes, Text] _CMD = Union[_TXT, Sequence[_TXT]] _ENV = Union[Mapping[bytes, _TXT], Mapping[Text, _TXT]] @@ -27,8 +27,8 @@ if sys.version_info >= (3, 5): if sys.version_info >= (3, 6): # Nearly same args as Popen.__init__ except for timeout, input, and check def run(args: _CMD, - timeout: float = ..., - input: _TXT = ..., + timeout: Optional[float] = ..., + input: Optional[_TXT] = ..., check: bool = ..., bufsize: int = ..., executable: _TXT = ..., @@ -38,8 +38,8 @@ if sys.version_info >= (3, 5): preexec_fn: Callable[[], Any] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: _TXT = ..., - env: _ENV = ..., + cwd: Optional[_TXT] = ..., + env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -52,8 +52,8 @@ if sys.version_info >= (3, 5): else: # Nearly same args as Popen.__init__ except for timeout, input, and check def run(args: _CMD, - timeout: float = ..., - input: _TXT = ..., + timeout: Optional[float] = ..., + input: Optional[_TXT] = ..., check: bool = ..., bufsize: int = ..., executable: _TXT = ..., @@ -63,8 +63,8 @@ if sys.version_info >= (3, 5): preexec_fn: Callable[[], Any] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: _TXT = ..., - env: _ENV = ..., + cwd: Optional[_TXT] = ..., + env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -84,8 +84,8 @@ if sys.version_info >= (3, 3): preexec_fn: Callable[[], Any] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: _TXT = ..., - env: _ENV = ..., + cwd: Optional[_TXT] = ..., + env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -103,8 +103,8 @@ else: preexec_fn: Callable[[], Any] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: _TXT = ..., - env: _ENV = ..., + cwd: Optional[_TXT] = ..., + env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -124,8 +124,8 @@ if sys.version_info >= (3, 3): preexec_fn: Callable[[], Any] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: _TXT = ..., - env: _ENV = ..., + cwd: Optional[_TXT] = ..., + env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -143,8 +143,8 @@ else: preexec_fn: Callable[[], Any] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: _TXT = ..., - env: _ENV = ..., + cwd: Optional[_TXT] = ..., + env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -162,8 +162,8 @@ if sys.version_info >= (3, 6): preexec_fn: Callable[[], Any] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: _TXT = ..., - env: _ENV = ..., + cwd: Optional[_TXT] = ..., + env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -186,8 +186,8 @@ elif sys.version_info >= (3, 4): preexec_fn: Callable[[], Any] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: _TXT = ..., - env: _ENV = ..., + cwd: Optional[_TXT] = ..., + env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -207,8 +207,8 @@ elif sys.version_info >= (3, 3): preexec_fn: Callable[[], Any] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: _TXT = ..., - env: _ENV = ..., + cwd: Optional[_TXT] = ..., + env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -227,8 +227,8 @@ else: preexec_fn: Callable[[], Any] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: _TXT = ..., - env: _ENV = ..., + cwd: Optional[_TXT] = ..., + env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -238,11 +238,10 @@ else: ) -> Any: ... # morally: -> _TXT -# TODO types -PIPE = ... # type: Any -STDOUT = ... # type: Any +PIPE = ... # type: int +STDOUT = ... # type: int if sys.version_info >= (3, 3): - DEVNULL = ... # type: Any + DEVNULL = ... # type: int class SubprocessError(Exception): ... class TimeoutExpired(SubprocessError): ... @@ -266,6 +265,8 @@ class CalledProcessError(Exception): stderr: Optional[_TXT] = ...) -> None: ... class Popen: + if sys.version_info >= (3, 3): + args = ... # type: _CMD stdin = ... # type: IO[Any] stdout = ... # type: IO[Any] stderr = ... # type: IO[Any] diff --git a/python/helpers/typeshed/stdlib/3/sys.pyi b/python/helpers/typeshed/stdlib/3/sys.pyi index b3042e2ec058..76e4cd65fa72 100644 --- a/python/helpers/typeshed/stdlib/3/sys.pyi +++ b/python/helpers/typeshed/stdlib/3/sys.pyi @@ -8,7 +8,7 @@ from typing import ( TypeVar, Callable, Type, ) import sys -from types import TracebackType +from types import FrameType, TracebackType from mypy_extensions import NoReturn _T = TypeVar('_T') @@ -20,18 +20,18 @@ byteorder = ... # type: str builtin_module_names = ... # type: Sequence[str] # actually a tuple of strings copyright = ... # type: str # dllhandle = 0 # Windows only -dont_write_bytecode = False +dont_write_bytecode: bool __displayhook__ = ... # type: Any # contains the original value of displayhook __excepthook__ = ... # type: Any # contains the original value of excepthook exec_prefix = ... # type: str executable = ... # type: str float_repr_style = ... # type: str -hexversion = 0 # this is a 32-bit int +hexversion: int last_type = ... # type: Any last_value = ... # type: Any last_traceback = ... # type: Any -maxsize = 0 -maxunicode = 0 +maxsize: int +maxunicode: int meta_path = ... # type: List[Any] modules = ... # type: Dict[str, Any] path = ... # type: List[str] @@ -90,16 +90,16 @@ class _float_info: hash_info = ... # type: _hash_info class _hash_info: - width = 0 # width in bits used for hash values - modulus = 0 # prime modulus P used for numeric hash scheme - inf = 0 # hash value returned for a positive infinity - nan = 0 # hash value returned for a nan - imag = 0 # multiplier used for the imaginary part of a complex number + width = 0 + modulus = 0 + inf = 0 + nan = 0 + imag = 0 int_info = ... # type: _int_info class _int_info: - bits_per_digit = 0 # number of bits held in each digit. Python integers are stored internally in base 2**int_info.bits_per_digit - sizeof_digit = 0 # size in bytes of C type used to represent a digit + bits_per_digit = 0 + sizeof_digit = 0 class _version_info(Tuple[int, int, int, str, int]): major = 0 @@ -109,8 +109,6 @@ class _version_info(Tuple[int, int, int, str, int]): serial = 0 version_info = ... # type: _version_info - -# ----- sys function stubs ----- def call_tracing(fn: Callable[..., _T], args: Any) -> _T: ... def _clear_type_cache() -> None: ... def _current_frames() -> Dict[int, Any]: ... @@ -122,12 +120,12 @@ def exc_info() -> Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]]: ... # sys.exit() accepts an optional argument of anything printable -def exit(arg: Any = ...) -> NoReturn: +def exit(arg: object = ...) -> NoReturn: raise SystemExit() def getcheckinterval() -> int: ... # deprecated def getdefaultencoding() -> str: ... def getdlopenflags() -> int: ... # Unix only -def getfilesystemencoding() -> str: ... # cannot return None +def getfilesystemencoding() -> str: ... def getrefcount(arg: Any) -> int: ... def getrecursionlimit() -> int: ... @@ -139,12 +137,18 @@ def getsizeof(obj: object, default: int) -> int: ... def getswitchinterval() -> float: ... @overload -def _getframe() -> Any: ... +def _getframe() -> FrameType: ... @overload -def _getframe(depth: int) -> Any: ... +def _getframe(depth: int) -> FrameType: ... + +_ProfileFunc = Callable[[FrameType, str, Any], Any] +def getprofile() -> Optional[_ProfileFunc]: ... +def setprofile(profilefunc: _ProfileFunc) -> None: ... + +_TraceFunc = Callable[[FrameType, str, Any], Optional[Callable[[FrameType, str, Any], Any]]] +def gettrace() -> Optional[_TraceFunc]: ... +def settrace(tracefunc: _TraceFunc) -> None: ... -def getprofile() -> Any: ... # TODO return type -def gettrace() -> Any: ... # TODO return def getwindowsversion() -> Any: ... # Windows only, TODO return type def intern(string: str) -> str: ... @@ -153,14 +157,8 @@ if sys.version_info >= (3, 5): def setcheckinterval(interval: int) -> None: ... # deprecated def setdlopenflags(n: int) -> None: ... # Linux only -def setprofile(profilefunc: Any) -> None: ... # TODO type def setrecursionlimit(limit: int) -> None: ... def setswitchinterval(interval: float) -> None: ... -def settrace(tracefunc: Any) -> None: ... # TODO type -# Trace functions should have three arguments: frame, event, and arg. frame -# is the current stack frame. event is a string: 'call', 'line', 'return', -# 'exception', 'c_call', 'c_return', or 'c_exception'. arg depends on the -# event type. def settscdump(on_flag: bool) -> None: ... def gettotalrefcount() -> int: ... # Debug builds only diff --git a/python/helpers/typeshed/stdlib/3/tempfile.pyi b/python/helpers/typeshed/stdlib/3/tempfile.pyi index ab8c380992b0..7c9626087933 100644 --- a/python/helpers/typeshed/stdlib/3/tempfile.pyi +++ b/python/helpers/typeshed/stdlib/3/tempfile.pyi @@ -8,6 +8,7 @@ from types import TracebackType from typing import Any, AnyStr, Generic, IO, Optional, Tuple, Type # global variables +TMP_MAX: int tempdir = ... # type: Optional[str] template = ... # type: str diff --git a/python/helpers/typeshed/stdlib/3/time.pyi b/python/helpers/typeshed/stdlib/3/time.pyi index 57884b2a92d1..597fb8e53d2c 100644 --- a/python/helpers/typeshed/stdlib/3/time.pyi +++ b/python/helpers/typeshed/stdlib/3/time.pyi @@ -45,6 +45,15 @@ if sys.version_info >= (3, 3): ], _arg: Any = ..., ) -> None: ... + def __new__( + cls, + o: Union[ + Tuple[int, int, int, int, int, int, int, int, int], + Tuple[int, int, int, int, int, int, int, int, int, str], + Tuple[int, int, int, int, int, int, int, int, int, str, int] + ], + _arg: Any = ..., + ) -> struct_time: ... else: class struct_time( NamedTuple( @@ -55,6 +64,7 @@ else: ) ): def __init__(self, o: TimeTuple, _arg: Any = ...) -> None: ... + def __new__(cls, o: TimeTuple, _arg: Any = ...) -> struct_time: ... # ----- functions ----- diff --git a/python/helpers/typeshed/stdlib/3/tkinter/__init__.pyi b/python/helpers/typeshed/stdlib/3/tkinter/__init__.pyi index ec61243926fc..4ef707930fa8 100644 --- a/python/helpers/typeshed/stdlib/3/tkinter/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/tkinter/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for tkinter (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from tkinter.constants import * # noqa: F403 diff --git a/python/helpers/typeshed/stdlib/3/tkinter/constants.pyi b/python/helpers/typeshed/stdlib/3/tkinter/constants.pyi index 77645efd18f5..d613dc628f41 100644 --- a/python/helpers/typeshed/stdlib/3/tkinter/constants.pyi +++ b/python/helpers/typeshed/stdlib/3/tkinter/constants.pyi @@ -1,7 +1,3 @@ -# Stubs for tkinter.constants (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any NO = ... # type: Any diff --git a/python/helpers/typeshed/stdlib/3/tkinter/ttk.pyi b/python/helpers/typeshed/stdlib/3/tkinter/ttk.pyi index 099f308aeccc..2ce9dc0c898e 100644 --- a/python/helpers/typeshed/stdlib/3/tkinter/ttk.pyi +++ b/python/helpers/typeshed/stdlib/3/tkinter/ttk.pyi @@ -1,7 +1,3 @@ -# Stubs for tkinter.ttk (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any import tkinter diff --git a/python/helpers/typeshed/stdlib/3/tokenize.pyi b/python/helpers/typeshed/stdlib/3/tokenize.pyi index 8e8fc13240fe..bf1339f0c22f 100644 --- a/python/helpers/typeshed/stdlib/3/tokenize.pyi +++ b/python/helpers/typeshed/stdlib/3/tokenize.pyi @@ -1,7 +1,3 @@ -# Stubs for tokenize (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Callable, Generator, Iterable, List, NamedTuple, Optional, Union, Sequence, TextIO, Tuple from builtins import open as _builtin_open from token import * # noqa: F403 @@ -43,6 +39,7 @@ class Untokenizer: def untokenize(iterable: Iterable[_Token]) -> Any: ... def detect_encoding(readline: Callable[[], bytes]) -> Tuple[str, Sequence[bytes]]: ... def tokenize(readline: Callable[[], bytes]) -> Generator[TokenInfo, None, None]: ... +def generate_tokens(readline: Callable[[], str]) -> Generator[TokenInfo, None, None]: ... def open(filename: Union[str, bytes, int]) -> TextIO: ... diff --git a/python/helpers/typeshed/stdlib/3/types.pyi b/python/helpers/typeshed/stdlib/3/types.pyi index ae923a200e4b..f9f46c5fdf91 100644 --- a/python/helpers/typeshed/stdlib/3/types.pyi +++ b/python/helpers/typeshed/stdlib/3/types.pyi @@ -5,8 +5,8 @@ import sys from typing import ( - Any, Callable, Dict, Generic, Iterator, Mapping, Optional, Tuple, TypeVar, - Union, overload + Any, Awaitable, Callable, Dict, Generic, Iterator, Mapping, Optional, Tuple, TypeVar, + Union, overload, Type ) # ModuleType is exported from this module, but for circular import @@ -14,6 +14,8 @@ from typing import ( from _importlib_modulespec import ModuleType as ModuleType # Exported _T = TypeVar('_T') +_T_co = TypeVar('_T_co', covariant=True) +_T_contra = TypeVar('_T_contra', contravariant=True) _KT = TypeVar('_KT') _VT = TypeVar('_VT') @@ -92,6 +94,21 @@ class GeneratorType: @overload def throw(self, typ: type, val: BaseException = ..., tb: 'TracebackType' = ...) -> Any: ... +if sys.version_info >= (3, 6): + class AsyncGeneratorType(Generic[_T_co, _T_contra]): + ag_await: Optional[Awaitable[Any]] + ag_frame: FrameType + ag_running: bool + ag_code: CodeType + def __aiter__(self) -> Awaitable[AsyncGeneratorType[_T_co, _T_contra]]: ... + def __anext__(self) -> Awaitable[_T_co]: ... + def asend(self, val: _T_contra) -> Awaitable[_T_co]: ... + @overload + def athrow(self, val: BaseException) -> Awaitable[_T_co]: ... + @overload + def athrow(self, typ: Type[BaseException], val: BaseException, tb: TracebackType = ...) -> Awaitable[_T_co]: ... + def aclose(self) -> Awaitable[_T_co]: ... + class CoroutineType: cr_await = ... # type: Optional[Any] cr_code = ... # type: CodeType @@ -104,9 +121,25 @@ class CoroutineType: @overload def throw(self, typ: type, val: BaseException = ..., tb: 'TracebackType' = ...) -> Any: ... +class _StaticFunctionType: + """Fictional type to correct the type of MethodType.__func__. + + FunctionType is a descriptor, so mypy follows the descriptor protocol and + converts MethodType.__func__ back to MethodType (the return type of + FunctionType.__get__). But this is actually a special case; MethodType is + implemented in C and its attribute access doesn't go through + __getattribute__. + + By wrapping FunctionType in _StaticFunctionType, we get the right result; + similar to wrapping a function in staticmethod() at runtime to prevent it + being bound as a method. + """ + def __get__(self, obj: Optional[object], type: Optional[type]) -> 'FunctionType': ... + class MethodType: - __func__ = ... # type: FunctionType + __func__ = ... # type: _StaticFunctionType __self__ = ... # type: object + __name__ = ... # type: str def __init__(self, func: Callable, obj: object) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... class BuiltinFunctionType: diff --git a/python/helpers/typeshed/stdlib/3/typing.pyi b/python/helpers/typeshed/stdlib/3/typing.pyi index b1c630264820..71f97ce4cfb3 100644 --- a/python/helpers/typeshed/stdlib/3/typing.pyi +++ b/python/helpers/typeshed/stdlib/3/typing.pyi @@ -2,7 +2,8 @@ import sys from abc import abstractmethod, ABCMeta -from types import CodeType, FrameType +from types import CodeType, FrameType, TracebackType +import collections # Needed by aliases like DefaultDict, see mypy issue 2986 # Definitions of special type checking related constructs. Their definition # are not used, so their value does not matter. @@ -10,16 +11,25 @@ from types import CodeType, FrameType overload = object() Any = object() TypeVar = object() -Generic = object() -Tuple = object() -Callable = object() -Type = object() _promote = object() no_type_check = object() -ClassVar = object() + +class _SpecialForm: + def __getitem__(self, typeargs: Any) -> Any: ... + +Tuple: _SpecialForm = ... +Generic: _SpecialForm = ... +Callable: _SpecialForm = ... +Type: _SpecialForm = ... +ClassVar: _SpecialForm = ... class GenericMeta(type): ... +# Return type that indicates a function does not return. +# This type is equivalent to the None type, but the no-op Union is necessary to +# distinguish the None type from the None value. +NoReturn = Union[None] + # Type aliases and type constructors class TypeAlias: @@ -111,9 +121,8 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]): def send(self, value: _T_contra) -> _T_co: ... @abstractmethod - def throw(self, typ: Type[BaseException], val: Optional[BaseException] = None, - # TODO: tb should be TracebackType but that's defined in types - tb: Any = None) -> None: ... + def throw(self, typ: Type[BaseException], val: Optional[BaseException] = ..., + tb: Optional[TracebackType] = ...) -> None: ... @abstractmethod def close(self) -> None: ... @@ -127,7 +136,7 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]): gi_yieldfrom = ... # type: Optional[Generator] # TODO: Several types should only be defined if sys.python_version >= (3, 5): -# Awaitable, AsyncIterator, AsyncIterable, Coroutine, Collection, ContextManager. +# Awaitable, AsyncIterator, AsyncIterable, Coroutine, Collection. # See https: //github.com/python/typeshed/issues/655 for why this is not easy. class Awaitable(Generic[_T_co]): @@ -139,9 +148,8 @@ class Coroutine(Awaitable[_V_co], Generic[_T_co, _T_contra, _V_co]): def send(self, value: _T_contra) -> _T_co: ... @abstractmethod - def throw(self, typ: Type[BaseException], val: Optional[BaseException] = None, - # TODO: tb should be TracebackType but that's defined in types - tb: Any = None) -> None: ... + def throw(self, typ: Type[BaseException], val: Optional[BaseException] = ..., + tb: Optional[TracebackType] = ...) -> None: ... @abstractmethod def close(self) -> None: ... @@ -155,7 +163,7 @@ class AwaitableGenerator(Generator[_T_co, _T_contra, _V_co], Awaitable[_V_co], class AsyncIterable(Generic[_T_co]): @abstractmethod - def __anext__(self) -> Awaitable[_T_co]: ... + def __aiter__(self) -> 'AsyncIterator[_T_co]': ... class AsyncIterator(AsyncIterable[_T_co], Generic[_T_co]): @@ -281,7 +289,18 @@ class ValuesView(MappingView, Iterable[_VT_co], Generic[_VT_co]): def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[_VT_co]: ... -# TODO: ContextManager (only if contextlib.AbstractContextManager exists) +class ContextManager(Generic[_T_co]): + def __enter__(self) -> _T_co: ... + def __exit__(self, exc_type: Optional[Type[BaseException]], + exc_value: Optional[BaseException], + traceback: Optional[TracebackType]) -> Optional[bool]: ... + +if sys.version_info >= (3, 5): + class AsyncContextManager(Generic[_T_co]): + def __aenter__(self) -> Awaitable[_T_co]: ... + def __aexit__(self, exc_type: Optional[Type[BaseException]], + exc_value: Optional[BaseException], + traceback: Optional[TracebackType]) -> Awaitable[Optional[bool]]: ... class Mapping(_Collection[_KT], Generic[_KT, _VT_co]): # TODO: We wish the key type could also be covariant, but that doesn't work, @@ -290,9 +309,9 @@ class Mapping(_Collection[_KT], Generic[_KT, _VT_co]): def __getitem__(self, k: _KT) -> _VT_co: ... # Mixin methods - @overload # type: ignore + @overload def get(self, k: _KT) -> Optional[_VT_co]: ... - @overload # type: ignore + @overload def get(self, k: _KT, default: Union[_VT_co, _T]) -> Union[_VT_co, _T]: ... def items(self) -> AbstractSet[Tuple[_KT, _VT_co]]: ... def keys(self) -> AbstractSet[_KT]: ... @@ -383,8 +402,7 @@ class IO(Iterator[AnyStr], Generic[AnyStr]): def __enter__(self) -> 'IO[AnyStr]': ... @abstractmethod def __exit__(self, t: Optional[Type[BaseException]], value: Optional[BaseException], - # TODO: traceback should be TracebackType but that's defined in types - traceback: Optional[Any]) -> bool: ... + traceback: Optional[TracebackType]) -> bool: ... class BinaryIO(IO[bytes]): # TODO readinto @@ -484,7 +502,8 @@ class Pattern(Generic[AnyStr]): # Functions -def get_type_hints(obj: Callable) -> dict[str, Any]: ... +def get_type_hints(obj: Callable, globalns: Optional[dict[str, Any]] = ..., + localns: Optional[dict[str, Any]] = ...) -> dict[str, Any]: ... def cast(tp: Type[_T], obj: Any) -> _T: ... @@ -493,6 +512,7 @@ def cast(tp: Type[_T], obj: Any) -> _T: ... # NamedTuple is special-cased in the type checker class NamedTuple(tuple): _fields = ... # type: Tuple[str, ...] + _source = ... # type: str def __init__(self, typename: str, fields: Iterable[Tuple[str, Any]] = ..., *, verbose: bool = ..., rename: bool = ..., **kwargs: Any) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/unittest/__init__.pyi b/python/helpers/typeshed/stdlib/3/unittest/__init__.pyi index f27ee66a272c..6c0e409d9c7c 100644 --- a/python/helpers/typeshed/stdlib/3/unittest/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/unittest/__init__.pyi @@ -3,24 +3,22 @@ from typing import ( Any, Callable, Dict, Iterable, Iterator, List, Optional, Pattern, Sequence, Set, FrozenSet, TextIO, Tuple, Type, TypeVar, Union, Generic, - overload, + overload, ContextManager ) import logging import sys from types import ModuleType, TracebackType -from contextlib import ContextManager _T = TypeVar('_T') -_FT = TypeVar('_FT', bound=Callable[[Any], Any]) +_FT = TypeVar('_FT', bound=Callable[..., Any]) _E = TypeVar('_E', bound=Exception) def expectedFailure(func: _FT) -> _FT: ... -# TODO: Once python/mypy#1551 is fixed, the following need _FT instead of Any -def skip(reason: str) -> Callable[[Any], Any]: ... -def skipIf(condition: object, reason: str) -> Callable[[Any], Any]: ... -def skipUnless(condition: object, reason: str) -> Callable[[Any], Any]: ... +def skip(reason: str) -> Callable[[_FT], _FT]: ... +def skipIf(condition: object, reason: str) -> Callable[[_FT], _FT]: ... +def skipUnless(condition: object, reason: str) -> Callable[[_FT], _FT]: ... class SkipTest(Exception): def __init__(self, reason: str) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/unittest/mock.pyi b/python/helpers/typeshed/stdlib/3/unittest/mock.pyi index 5a3f6b00f0c7..4c78a0f83d7b 100644 --- a/python/helpers/typeshed/stdlib/3/unittest/mock.pyi +++ b/python/helpers/typeshed/stdlib/3/unittest/mock.pyi @@ -1,7 +1,7 @@ # Stubs for unittest.mock import sys -from typing import Any +from typing import Any, Optional if sys.version_info >= (3, 3): FILTER_DIR = ... # type: Any @@ -31,9 +31,14 @@ if sys.version_info >= (3, 3): class Base: def __init__(self, *args: Any, **kwargs: Any) -> None: ... - class NonCallableMock(Any): + # TODO: Get rid of the # type: ignore below. + # It is currently required to shut up mypy when run with `--strict` + # or `--disallow-subclassing-any`. The `Any` base class is currently + # the only way to allow passing an instance of `Mock` to functions + # expecting other classes (as is Mock's purpose) + class NonCallableMock(Any): # type: ignore def __new__(cls, *args: Any, **kw: Any) -> Any: ... - def __init__(self, spec: Any = None, wraps: Any = None, name: Any = None, spec_set: Any = None, parent: Any = None, _spec_state: Any = None, _new_name: Any ='', _new_parent: Any = None, _spec_as_instance: Any = False, _eat_self: Any = None, unsafe: Any = False, **kwargs: Any) -> None: ... + def __init__(self, spec: Optional[Any] = None, wraps: Optional[Any] = None, name: Optional[Any] = None, spec_set: Optional[Any] = None, parent: Optional[Any] = None, _spec_state: Optional[Any] = None, _new_name: Any ='', _new_parent: Optional[Any] = None, _spec_as_instance: Any = False, _eat_self: Optional[Any] = None, unsafe: Any = False, **kwargs: Any) -> None: ... def attach_mock(self, mock: Any, attribute: Any) -> Any: ... def mock_add_spec(self, spec: Any, spec_set: Any = False) -> Any: ... return_value = ... # type: Any @@ -45,7 +50,7 @@ if sys.version_info >= (3, 3): mock_calls = ... # type: Any side_effect = ... # type: Any method_calls = ... # type: Any - def reset_mock(self, visited: bool = None) -> None: ... + def reset_mock(self, visited: Optional[bool] = None) -> None: ... def configure_mock(self, **kwargs: Any) -> None: ... def __getattr__(self, name: Any) -> Any: ... def __dir__(self) -> Any: ... @@ -59,11 +64,11 @@ if sys.version_info >= (3, 3): class CallableMixin(Base): side_effect = ... # type: Any - def __init__(self, spec: Any = None, side_effect: Any = None, return_value: Any = ..., wraps: Any = None, name: Any = None, spec_set: Any = None, parent: Any = None, _spec_state: Any = None, _new_name: Any = '', _new_parent: Any = None, **kwargs: Any) -> None: ... + def __init__(self, spec: Optional[Any] = None, side_effect: Optional[Any] = None, return_value: Any = ..., wraps: Optional[Any] = None, name: Optional[Any] = None, spec_set: Optional[Any] = None, parent: Optional[Any] = None, _spec_state: Optional[Any] = None, _new_name: Any = '', _new_parent: Optional[Any] = None, **kwargs: Any) -> None: ... def __call__(_mock_self, *args: Any, **kwargs: Any) -> Any: ... class Mock(CallableMixin, NonCallableMock): - def __init__(self) -> None: ... + def __init__(self, spec: Any = ..., spec_set: Any = ..., side_effect: Any = ..., return_value: Any = ..., wraps: Any = ..., name: Any = ..., **kwargs: Any) -> None: ... class _patch: attribute_name = ... # type: Any @@ -92,7 +97,11 @@ if sys.version_info >= (3, 3): def start(self) -> Any: ... def stop(self) -> Any: ... - def patch(target: Any, new: Any =..., spec: Any = None, create: Any = False, spec_set: Any = None, autospec: Any = None, new_callable: Any = None, **kwargs: Any) -> Any: ... + class _patcher: + def __call__(self, target: Any, new: Optional[Any] = None, spec: Optional[Any] = None, create: Any = False, spec_set: Optional[Any] = None, autospec: Optional[Any] = None, new_callable: Optional[Any] = None, **kwargs: Any) -> Any: ... + def object(self, target: Any, attribute: str, new: Optional[Any] = None, spec: Optional[Any] = None, create: Any = False, spec_set: Optional[Any] = None, autospec: Optional[Any] = None, new_callable: Optional[Any] = None, **kwargs: Any) -> _patch: ... + + patch = ... # type: _patcher class _patch_dict: in_dict = ... # type: Any @@ -114,7 +123,7 @@ if sys.version_info >= (3, 3): def mock_add_spec(self, spec: Any, spec_set: Any = False) -> Any: ... class MagicMock(MagicMixin, Mock): - def __init__(self) -> None: ... + def __init__(self, spec: Any = ..., spec_set: Any = ..., side_effect: Any = ..., return_value: Any = ..., wraps: Any = ..., name: Any = ..., **kwargs: Any) -> None: ... def mock_add_spec(self, spec: Any, spec_set: Any = False) -> Any: ... class MagicProxy: @@ -123,7 +132,7 @@ if sys.version_info >= (3, 3): def __init__(self, name: Any, parent: Any) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... def create_mock(self) -> Any: ... - def __get__(self, obj: Any, _type: Any = None) -> Any: ... + def __get__(self, obj: Any, _type: Optional[Any] = None) -> Any: ... class _ANY: def __eq__(self, other: Any) -> bool: ... @@ -132,11 +141,11 @@ if sys.version_info >= (3, 3): ANY = ... # type: Any class _Call(tuple): - def __new__(cls, value: Any = ..., name: Any = None, parent: Any = None, two: bool = False, from_kall: bool = True) -> Any: ... + def __new__(cls, value: Any = ..., name: Optional[Any] = None, parent: Optional[Any] = None, two: bool = False, from_kall: bool = True) -> Any: ... name = ... # type: Any parent = ... # type: Any from_kall = ... # type: Any - def __init__(self, value: Any = ..., name: Any = None, parent: Any = None, two: bool = False, from_kall: bool = True) -> None: ... + def __init__(self, value: Any = ..., name: Optional[Any] = None, parent: Optional[Any] = None, two: bool = False, from_kall: bool = True) -> None: ... def __eq__(self, other: Any) -> bool: ... __ne__ = ... # type: Any def __call__(self, *args: Any, **kwargs: Any) -> Any: ... @@ -147,7 +156,7 @@ if sys.version_info >= (3, 3): call = ... # type: Any - def create_autospec(spec: Any, spec_set: Any = False, instance: Any = False, _parent: Any = None, _name: Any = None, **kwargs: Any) -> Any: ... + def create_autospec(spec: Any, spec_set: Any = False, instance: Any = False, _parent: Optional[Any] = None, _name: Optional[Any] = None, **kwargs: Any) -> Any: ... class _SpecState: spec = ... # type: Any @@ -156,9 +165,9 @@ if sys.version_info >= (3, 3): parent = ... # type: Any instance = ... # type: Any name = ... # type: Any - def __init__(self, spec: Any, spec_set: Any = False, parent: Any = None, name: Any = None, ids: Any = None, instance: Any = False) -> None: ... + def __init__(self, spec: Any, spec_set: Any = False, parent: Optional[Any] = None, name: Optional[Any] = None, ids: Optional[Any] = None, instance: Any = False) -> None: ... - def mock_open(mock: Any = None, read_data: Any = '') -> Any: ... + def mock_open(mock: Optional[Any] = None, read_data: Any = '') -> Any: ... class PropertyMock(Mock): def __get__(self, obj: Any, obj_type: Any) -> Any: ... diff --git a/python/helpers/typeshed/stdlib/3/urllib/parse.pyi b/python/helpers/typeshed/stdlib/3/urllib/parse.pyi index 05565e652a90..637fa5fa66dc 100644 --- a/python/helpers/typeshed/stdlib/3/urllib/parse.pyi +++ b/python/helpers/typeshed/stdlib/3/urllib/parse.pyi @@ -2,6 +2,8 @@ from typing import Any, List, Dict, Tuple, AnyStr, Generic, overload, Sequence, Mapping, Union, NamedTuple, Callable import sys +_Str = Union[bytes, str] + __all__ = ( 'urlparse', 'urlunparse', @@ -103,20 +105,20 @@ def parse_qsl(qs: AnyStr, keep_blank_values: bool = ..., strict_parsing: bool = @overload -def quote(string: str, safe: AnyStr = ..., encoding: str = ..., errors: str = ...) -> str: ... +def quote(string: str, safe: _Str = ..., encoding: str = ..., errors: str = ...) -> str: ... @overload -def quote(string: bytes, safe: AnyStr = ...) -> str: ... +def quote(string: bytes, safe: _Str = ...) -> str: ... -def quote_from_bytes(bs: bytes, safe: AnyStr = ...) -> str: ... +def quote_from_bytes(bs: bytes, safe: _Str = ...) -> str: ... @overload -def quote_plus(string: str, safe: AnyStr = ..., encoding: str = ..., errors: str = ...) -> str: ... +def quote_plus(string: str, safe: _Str = ..., encoding: str = ..., errors: str = ...) -> str: ... @overload -def quote_plus(string: bytes, safe: AnyStr = ...) -> str: ... +def quote_plus(string: bytes, safe: _Str = ...) -> str: ... def unquote(string: str, encoding: str = ..., errors: str = ...) -> str: ... -def unquote_to_bytes(string: AnyStr) -> bytes: ... +def unquote_to_bytes(string: _Str) -> bytes: ... def unquote_plus(string: str, encoding: str = ..., errors: str = ...) -> str: ... diff --git a/python/helpers/typeshed/stdlib/3/urllib/request.pyi b/python/helpers/typeshed/stdlib/3/urllib/request.pyi index dca209fc6bdb..8548a889c2f8 100644 --- a/python/helpers/typeshed/stdlib/3/urllib/request.pyi +++ b/python/helpers/typeshed/stdlib/3/urllib/request.pyi @@ -106,14 +106,12 @@ class ProxyHandler(BaseHandler): class HTTPPasswordMgr: def add_password(self, realm: str, uri: Union[str, Sequence[str]], user: str, passwd: str) -> None: ... - def find_user_password(self, realm: str, authuri: str) \ - -> Tuple[Optional[str], Optional[str]]: ... + def find_user_password(self, realm: str, authuri: str) -> Tuple[Optional[str], Optional[str]]: ... class HTTPPasswordMgrWithDefaultRealm(HTTPPasswordMgr): def add_password(self, realm: str, uri: Union[str, Sequence[str]], user: str, passwd: str) -> None: ... - def find_user_password(self, realm: str, authuri: str) \ - -> Tuple[Optional[str], Optional[str]]: ... + def find_user_password(self, realm: str, authuri: str) -> Tuple[Optional[str], Optional[str]]: ... if sys.version_info >= (3, 5): class HTTPPasswordMgrWithPriorAuth(HTTPPasswordMgrWithDefaultRealm): diff --git a/python/helpers/typeshed/stdlib/3/wsgiref/validate.pyi b/python/helpers/typeshed/stdlib/3/wsgiref/validate.pyi index bd7fd161eea4..c8b9b2944adc 100644 --- a/python/helpers/typeshed/stdlib/3/wsgiref/validate.pyi +++ b/python/helpers/typeshed/stdlib/3/wsgiref/validate.pyi @@ -1,7 +1,3 @@ -# Stubs for wsgiref.validate (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class WSGIWarning(Warning): ... diff --git a/python/helpers/typeshed/tests/mypy_selftest.py b/python/helpers/typeshed/tests/mypy_selftest.py new file mode 100755 index 000000000000..edc158732f2c --- /dev/null +++ b/python/helpers/typeshed/tests/mypy_selftest.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +"""Script to run mypy's test suite against this version of typeshed.""" + +from pathlib import Path +import shutil +import subprocess +import sys +import tempfile + + +if __name__ == '__main__': + with tempfile.TemporaryDirectory() as tempdir: + dirpath = Path(tempdir) + subprocess.run(['python2.7', '-m', 'pip', 'install', '--user', 'typing'], check=True) + subprocess.run(['git', 'clone', '--depth', '1', 'git://github.com/python/mypy', + str(dirpath / 'mypy')], check=True) + subprocess.run([sys.executable, '-m', 'pip', 'install', '-U', '-r', + str(dirpath / 'mypy/test-requirements.txt')], check=True) + shutil.copytree('stdlib', str(dirpath / 'mypy/typeshed/stdlib')) + shutil.copytree('third_party', str(dirpath / 'mypy/typeshed/third_party')) + try: + subprocess.run(['./runtests.py', '-j12'], cwd=str(dirpath / 'mypy'), check=True) + except subprocess.CalledProcessError as e: + print('mypy tests failed', file=sys.stderr) + sys.exit(e.returncode) + else: + print('mypy tests succeeded', file=sys.stderr) + sys.exit(0) diff --git a/python/helpers/typeshed/tests/mypy_test.py b/python/helpers/typeshed/tests/mypy_test.py index c4b081854bb5..cb4dace4aa8a 100755 --- a/python/helpers/typeshed/tests/mypy_test.py +++ b/python/helpers/typeshed/tests/mypy_test.py @@ -24,6 +24,13 @@ parser.add_argument('-n', '--dry-run', action='store_true', help="Don't actually parser.add_argument('-x', '--exclude', type=str, nargs='*', help="Exclude pattern") parser.add_argument('-p', '--python-version', type=str, nargs='*', help="These versions only (major[.minor])") +parser.add_argument('--no-implicit-optional', action='store_true', + help="Run mypy with --no-implicit-optional (causes lots of errors)") +parser.add_argument('--warn-unused-ignores', action='store_true', + help="Run mypy with --warn-unused-ignores " + "(hint: only git rid of warnings that are " + "unused for all platforms and Python versions)") + parser.add_argument('filter', type=str, nargs='*', help="Include pattern (default all)") @@ -83,7 +90,7 @@ def main(): print("Cannot import mypy. Did you install it?") sys.exit(1) - versions = [(3, 6), (3, 5), (3, 4), (3, 3), (3, 2), (2, 7)] + versions = [(3, 6), (3, 5), (3, 4), (3, 3), (2, 7)] if args.python_version: versions = [v for v in versions if any(('%d.%d' % v).startswith(av) for av in args.python_version)] @@ -124,7 +131,10 @@ def main(): runs += 1 flags = ['--python-version', '%d.%d' % (major, minor)] flags.append('--strict-optional') - # flags.append('--warn-unused-ignores') # Fast parser and regular parser disagree. + if args.no_implicit_optional: + flags.append('--no-implicit-optional') + if args.warn_unused_ignores: + flags.append('--warn-unused-ignores') sys.argv = ['mypy'] + flags + files if args.verbose: print("running", ' '.join(sys.argv)) diff --git a/python/helpers/typeshed/tests/pytype_blacklist.txt b/python/helpers/typeshed/tests/pytype_blacklist.txt index cbf3b7bde36e..53377dbe809d 100644 --- a/python/helpers/typeshed/tests/pytype_blacklist.txt +++ b/python/helpers/typeshed/tests/pytype_blacklist.txt @@ -1,10 +1,53 @@ # Pytype blacklist. Files will not be tested with pytype. +# pytype has its own version of these files, and thus doesn't mind if it +# can't parse the typeshed version: stdlib/2/__builtin__.pyi stdlib/2/builtins.pyi -stdlib/2/types.pyi stdlib/2/typing.pyi +stdlib/3/builtins.pyi +stdlib/3/typing.pyi + +# Because of 'class ForkProcess(Any): # type: ignore' +stdlib/3/multiprocessing/context.pyi # Because of 'from . import path': stdlib/2/os/__init__.pyi stdlib/3/os/__init__.pyi + +# We've not been running the pytype tests under Python 3, for quite a while. +# The below are files that have regressed and need fixing: +stdlib/3/collections/__init__.pyi +stdlib/3/collections/abc.pyi +stdlib/3/concurrent/futures/__init__.pyi +stdlib/3/concurrent/futures/_base.pyi +stdlib/3/concurrent/futures/process.pyi +stdlib/3/concurrent/futures/thread.pyi +stdlib/3/email/policy.pyi +stdlib/3/fileinput.pyi +stdlib/3/gzip.pyi +stdlib/3/http/__init__.pyi +stdlib/3/http/cookiejar.pyi +stdlib/3/inspect.pyi +stdlib/3/json/__init__.pyi +stdlib/3/json/decoder.pyi +stdlib/3/json/encoder.pyi +stdlib/3/ssl.pyi +stdlib/3/subprocess.pyi +stdlib/3/sys.pyi +stdlib/3/textwrap.pyi +stdlib/3/time.pyi +stdlib/3/tkinter/__init__.pyi +stdlib/3/types.pyi +stdlib/3/unittest/__init__.pyi +stdlib/3/unittest/mock.pyi +stdlib/3/urllib/parse.pyi +stdlib/3/wsgiref/types.pyi +stdlib/3.4/asyncio/events.pyi +stdlib/3.4/asyncio/futures.pyi +stdlib/3.4/asyncio/locks.pyi +stdlib/3.4/asyncio/queues.pyi +stdlib/3.4/asyncio/streams.pyi +stdlib/3.4/asyncio/subprocess.pyi +stdlib/3.4/asyncio/tasks.pyi +stdlib/3.4/enum.pyi diff --git a/python/helpers/typeshed/tests/pytype_test.py b/python/helpers/typeshed/tests/pytype_test.py index e7475c0be115..3d6f3639793a 100755 --- a/python/helpers/typeshed/tests/pytype_test.py +++ b/python/helpers/typeshed/tests/pytype_test.py @@ -70,7 +70,7 @@ def pytype_test(args): print("Cannot run pytd. Did you install pytype?") return 0, 0 - wanted = re.compile(r"stdlib/(2|2\.7|2and3)/.*\.pyi$") + wanted = re.compile(r"stdlib/.*\.pyi$") skipped = re.compile("(%s)$" % "|".join(load_blacklist())) files = [] 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 49c0de6e2d51..4604830ed722 100644 --- a/python/helpers/typeshed/third_party/2/concurrent/futures/__init__.pyi +++ b/python/helpers/typeshed/third_party/2/concurrent/futures/__init__.pyi @@ -1,4 +1,7 @@ +# Stubs for concurrent.futures (Python 2) + from typing import TypeVar, Generic, Any, Iterable, Iterator, Callable, Optional, Set, Tuple, Union +from types import TracebackType _T = TypeVar('_T') @@ -11,26 +14,28 @@ class Future(Generic[_T]): def cancelled(self) -> bool: ... def running(self) -> bool: ... def done(self) -> bool: ... - def result(self, timeout: float = ...) -> _T: ... - def exception(self, timeout: float = ...) -> Any: ... + def result(self, timeout: Optional[float] = ...) -> _T: ... + def exception(self, timeout: Optional[float] = ...) -> Any: ... + def exception_info(self, timeout: Optional[float] = ...) -> Tuple[Any, Optional[TracebackType]]: ... def add_done_callback(self, fn: Callable[[Future], Any]) -> None: ... def set_running_or_notify_cancel(self) -> bool: ... def set_result(self, result: _T) -> None: ... def set_exception(self, exception: Any) -> None: ... + def set_exception_info(self, exception: Any, traceback: TracebackType) -> None: ... class Executor: def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ... - def map(self, func: Callable[..., _T], *iterables: Any, timeout: float = ...) -> Iterable[_T]: ... + def map(self, func: Callable[..., _T], *iterables: Iterable[Any], timeout: Optional[float] = ...) -> Iterator[_T]: ... def shutdown(self, wait: bool = ...) -> None: ... def __enter__(self) -> Executor: ... def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool: ... class ThreadPoolExecutor(Executor): - def __init__(self, max_workers: int) -> None: ... + def __init__(self, max_workers: Optional[int] = ...) -> None: ... class ProcessPoolExecutor(Executor): - def __init__(self, max_workers: Union[int, None] = ...) -> None: ... + def __init__(self, max_workers: Optional[int] = ...) -> None: ... def wait(fs: Iterable[Future], timeout: Optional[float] = ..., return_when: str = ...) -> Tuple[Set[Future], Set[Future]]: ... @@ -38,4 +43,4 @@ FIRST_COMPLETED = ... # type: str FIRST_EXCEPTION = ... # type: str ALL_COMPLETED = ... # type: str -def as_completed(fs: Iterable[Future], timeout: float = ...) -> Iterator[Future]: ... +def as_completed(fs: Iterable[Future], timeout: Optional[float] = ...) -> Iterator[Future]: ... diff --git a/python/helpers/typeshed/third_party/2/croniter.pyi b/python/helpers/typeshed/third_party/2/croniter.pyi index 2495495dcc54..c164213d7df5 100644 --- a/python/helpers/typeshed/third_party/2/croniter.pyi +++ b/python/helpers/typeshed/third_party/2/croniter.pyi @@ -1,7 +1,3 @@ -# Stubs for croniter.croniter (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class croniter: diff --git a/python/helpers/typeshed/third_party/2/cryptography/hazmat/primitives/serialization.pyi b/python/helpers/typeshed/third_party/2/cryptography/hazmat/primitives/serialization.pyi index 57ff681bd809..e2c506b0ea9b 100644 --- a/python/helpers/typeshed/third_party/2/cryptography/hazmat/primitives/serialization.pyi +++ b/python/helpers/typeshed/third_party/2/cryptography/hazmat/primitives/serialization.pyi @@ -1,7 +1,3 @@ -# Stubs for cryptography.hazmat.primitives.serialization (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from enum import Enum diff --git a/python/helpers/typeshed/third_party/2/dateutil/parser.pyi b/python/helpers/typeshed/third_party/2/dateutil/parser.pyi index d2927e87b25f..855538b2179b 100644 --- a/python/helpers/typeshed/third_party/2/dateutil/parser.pyi +++ b/python/helpers/typeshed/third_party/2/dateutil/parser.pyi @@ -27,13 +27,13 @@ class parserinfo(object): def validate(self, res: datetime) -> bool: ... class parser(object): - def __init__(self, info: parserinfo = None) -> None: ... + def __init__(self, info: Optional[parserinfo] = None) -> None: ... def parse(self, timestr: Union[str, unicode, IO[unicode]], - default: datetime = None, - ignoretz: bool = ..., tzinfos: Dict[Union[str, unicode], tzinfo] = None, + default: Optional[datetime] = None, + ignoretz: bool = ..., tzinfos: Optional[Dict[Union[str, unicode], tzinfo]] = None, **kwargs: Any) -> datetime: ... DEFAULTPARSER = ... # type: parser def parse(timestr: Union[str, unicode, IO[unicode]], - parserinfo: parserinfo = None, + parserinfo: Optional[parserinfo] = None, **kwargs: Any) -> datetime: ... diff --git a/python/helpers/typeshed/third_party/2/dateutil/relativedelta.pyi b/python/helpers/typeshed/third_party/2/dateutil/relativedelta.pyi index f910e9005b4a..ea6592b1bba6 100644 --- a/python/helpers/typeshed/third_party/2/dateutil/relativedelta.pyi +++ b/python/helpers/typeshed/third_party/2/dateutil/relativedelta.pyi @@ -1,8 +1,11 @@ -from typing import Any, List, Optional, Union +from typing import overload, Any, List, Optional, SupportsFloat, TypeVar, Union from datetime import date, datetime, timedelta __all__ = ... # type: List[str] +_SelfT = TypeVar('_SelfT', bound=relativedelta) +_DateT = TypeVar('_DateT', date, datetime) + class weekday(object): def __init__(self, weekday: int, n: Optional[int]=...) -> None: ... @@ -49,38 +52,40 @@ class relativedelta(object): @weeks.setter def weeks(self, value: int) -> None: ... - def normalized(self) -> 'relativedelta': ... + def normalized(self: _SelfT) -> _SelfT: ... - def __add__( - self, - other: Union['relativedelta', timedelta, date, datetime]) -> 'relativedelta': ... + @overload + def __add__(self: _SelfT, other: relativedelta) -> _SelfT: ... + @overload + def __add__(self: _SelfT, other: timedelta) -> _SelfT: ... + @overload + def __add__(self, other: _DateT) -> _DateT: ... + @overload + def __radd__(self: _SelfT, other: timedelta) -> _SelfT: ... + @overload + def __radd__(self, other: _DateT) -> _DateT: ... + @overload + def __rsub__(self: _SelfT, other: timedelta) -> _SelfT: ... + @overload + def __rsub__(self, other: _DateT) -> _DateT: ... + def __sub__(self: _SelfT, other: relativedelta) -> _SelfT: ... - def __radd__( - self, - other: Any) -> 'relativedelta': ... - - def __rsub__( - self, - other: Any) -> 'relativedelta': ... - - def __sub__(self, other: 'relativedelta') -> 'relativedelta': ... - - def __neg__(self) -> 'relativedelta': ... + def __neg__(self: _SelfT) -> _SelfT: ... def __bool__(self) -> bool: ... def __nonzero__(self) -> bool: ... - def __mul__(self, other: float) -> 'relativedelta': ... + def __mul__(self: _SelfT, other: SupportsFloat) -> _SelfT: ... - def __rmul__(self, other: float) -> 'relativedelta': ... + def __rmul__(self: _SelfT, other: SupportsFloat) -> _SelfT: ... def __eq__(self, other) -> bool: ... def __ne__(self, other: object) -> bool: ... - def __div__(self, other: float) -> 'relativedelta': ... + def __div__(self: _SelfT, other: SupportsFloat) -> _SelfT: ... - def __truediv__(self, other: float) -> 'relativedelta': ... + def __truediv__(self: _SelfT, other: SupportsFloat) -> _SelfT: ... def __repr__(self) -> str: ... diff --git a/python/helpers/typeshed/third_party/2/dateutil/tz/__init__.pyi b/python/helpers/typeshed/third_party/2/dateutil/tz/__init__.pyi index 30a7ab3391c3..4c8a6d2d1b25 100644 --- a/python/helpers/typeshed/third_party/2/dateutil/tz/__init__.pyi +++ b/python/helpers/typeshed/third_party/2/dateutil/tz/__init__.pyi @@ -1,5 +1 @@ -# Stubs for dateutil.tz (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from .tz import tzutc, tzoffset, tzlocal, tzfile, tzrange, tzstr, tzical, gettz, datetime_exists, datetime_ambiguous diff --git a/python/helpers/typeshed/third_party/2/dateutil/tz/_common.pyi b/python/helpers/typeshed/third_party/2/dateutil/tz/_common.pyi index e0856d2a9869..8a684e39a87a 100644 --- a/python/helpers/typeshed/third_party/2/dateutil/tz/_common.pyi +++ b/python/helpers/typeshed/third_party/2/dateutil/tz/_common.pyi @@ -1,7 +1,3 @@ -# Stubs for dateutil.tz._common (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional from datetime import datetime, tzinfo, timedelta 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 5027e62eb4ee..5fcd6d80a84f 100644 --- a/python/helpers/typeshed/third_party/2/dateutil/tz/tz.pyi +++ b/python/helpers/typeshed/third_party/2/dateutil/tz/tz.pyi @@ -1,7 +1,3 @@ -# Stubs for dateutil.tz.tz (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, IO, List, Optional, Tuple, Union import datetime from ._common import tzname_in_python2 as tzname_in_python2, _tzinfo as _tzinfo diff --git a/python/helpers/typeshed/third_party/2/enum.pyi b/python/helpers/typeshed/third_party/2/enum.pyi index 47f89900f8a9..ae8a91c62094 100644 --- a/python/helpers/typeshed/third_party/2/enum.pyi +++ b/python/helpers/typeshed/third_party/2/enum.pyi @@ -1,7 +1,11 @@ -from typing import List, Any, TypeVar, Type +from typing import List, Any, TypeVar, Type, Iterable, Iterator -class Enum: - def __new__(cls, value: Any) -> None: ... +_T = TypeVar('_T', bound=Enum) +class EnumMeta(type, Iterable[Enum]): + def __iter__(self: Type[_T]) -> Iterator[_T]: ... # type: ignore + +class Enum(metaclass=EnumMeta): + def __new__(cls: Type[_T], value: Any) -> _T: ... def __repr__(self) -> str: ... def __str__(self) -> str: ... def __dir__(self) -> List[str]: ... @@ -12,9 +16,6 @@ class Enum: name = ... # type: str value = ... # type: Any -_T = TypeVar('_T') - -class IntEnum(int, Enum): # type: ignore - def __new__(cls: Type[_T], value: Any) -> _T: ... +class IntEnum(int, Enum): ... def unique(enumeration: _T) -> _T: ... diff --git a/python/helpers/typeshed/third_party/2/fb303/FacebookService.pyi b/python/helpers/typeshed/third_party/2/fb303/FacebookService.pyi index 09c6ef18b931..c863f2853fa9 100644 --- a/python/helpers/typeshed/third_party/2/fb303/FacebookService.pyi +++ b/python/helpers/typeshed/third_party/2/fb303/FacebookService.pyi @@ -1,7 +1,3 @@ -# Stubs for fb303.FacebookService (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from thrift.Thrift import TProcessor diff --git a/python/helpers/typeshed/third_party/2/google/protobuf/descriptor.pyi b/python/helpers/typeshed/third_party/2/google/protobuf/descriptor.pyi index 1d26f98efb3b..a11c9683cb4d 100644 --- a/python/helpers/typeshed/third_party/2/google/protobuf/descriptor.pyi +++ b/python/helpers/typeshed/third_party/2/google/protobuf/descriptor.pyi @@ -1,7 +1,3 @@ -# Stubs for google.protobuf.descriptor (Python 2.7) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from .message import Message diff --git a/python/helpers/typeshed/third_party/2/google/protobuf/descriptor_pool.pyi b/python/helpers/typeshed/third_party/2/google/protobuf/descriptor_pool.pyi index f22ea5742842..f1ade5261afa 100644 --- a/python/helpers/typeshed/third_party/2/google/protobuf/descriptor_pool.pyi +++ b/python/helpers/typeshed/third_party/2/google/protobuf/descriptor_pool.pyi @@ -1,7 +1,3 @@ -# Stubs for google.protobuf.descriptor_pool (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional class DescriptorPool: diff --git a/python/helpers/typeshed/third_party/2/google/protobuf/internal/decoder.pyi b/python/helpers/typeshed/third_party/2/google/protobuf/internal/decoder.pyi index e7737eeb2f84..24918b25179c 100644 --- a/python/helpers/typeshed/third_party/2/google/protobuf/internal/decoder.pyi +++ b/python/helpers/typeshed/third_party/2/google/protobuf/internal/decoder.pyi @@ -1,7 +1,3 @@ -# Stubs for google.protobuf.internal.decoder (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any def ReadTag(buffer, pos): ... diff --git a/python/helpers/typeshed/third_party/2/google/protobuf/internal/encoder.pyi b/python/helpers/typeshed/third_party/2/google/protobuf/internal/encoder.pyi index c3ab6ff23a0c..a29caf4d56fa 100644 --- a/python/helpers/typeshed/third_party/2/google/protobuf/internal/encoder.pyi +++ b/python/helpers/typeshed/third_party/2/google/protobuf/internal/encoder.pyi @@ -1,7 +1,3 @@ -# Stubs for google.protobuf.internal.encoder (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any Int32Sizer = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2/google/protobuf/internal/wire_format.pyi b/python/helpers/typeshed/third_party/2/google/protobuf/internal/wire_format.pyi index 19b7c3f3bb4b..0025a2ce91cb 100644 --- a/python/helpers/typeshed/third_party/2/google/protobuf/internal/wire_format.pyi +++ b/python/helpers/typeshed/third_party/2/google/protobuf/internal/wire_format.pyi @@ -1,7 +1,3 @@ -# Stubs for google.protobuf.internal.wire_format (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any TAG_TYPE_BITS = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2/google/protobuf/message.pyi b/python/helpers/typeshed/third_party/2/google/protobuf/message.pyi index 09c771607263..b13821f0d94e 100644 --- a/python/helpers/typeshed/third_party/2/google/protobuf/message.pyi +++ b/python/helpers/typeshed/third_party/2/google/protobuf/message.pyi @@ -1,8 +1,4 @@ -# Stubs for google.protobuf.message (Python 2.7) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any, Sequence, Optional, Tuple +from typing import Any, Sequence, Optional, Text, Tuple from .descriptor import FieldDescriptor @@ -25,8 +21,8 @@ class Message: def SerializeToString(self) -> str: ... def SerializePartialToString(self) -> str: ... def ListFields(self) -> Sequence[Tuple[FieldDescriptor, Any]]: ... - def HasField(self, field_name: str) -> bool: ... - def ClearField(self, field_name: str) -> None: ... + def HasField(self, field_name: Text) -> bool: ... + def ClearField(self, field_name: Text) -> None: ... def WhichOneof(self, oneof_group) -> Optional[str]: ... def HasExtension(self, extension_handle): ... def ClearExtension(self, extension_handle): ... diff --git a/python/helpers/typeshed/third_party/2/google/protobuf/message_factory.pyi b/python/helpers/typeshed/third_party/2/google/protobuf/message_factory.pyi index a76333dfaf25..24758ff01b8b 100644 --- a/python/helpers/typeshed/third_party/2/google/protobuf/message_factory.pyi +++ b/python/helpers/typeshed/third_party/2/google/protobuf/message_factory.pyi @@ -1,7 +1,3 @@ -# Stubs for google.protobuf.message_factory (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Dict, Iterable, Optional, Type from .message import Message @@ -10,7 +6,7 @@ from .descriptor_pool import DescriptorPool class MessageFactory: pool = ... # type: Any - def __init__(self, pool: DescriptorPool=None) -> None: ... + def __init__(self, pool: Optional[DescriptorPool] = None) -> None: ... def GetPrototype(self, descriptor: Descriptor) -> Type[Message]: ... def GetMessages(self, files: Iterable[str]) -> Dict[str, Type[Message]]: ... diff --git a/python/helpers/typeshed/third_party/2/google/protobuf/reflection.pyi b/python/helpers/typeshed/third_party/2/google/protobuf/reflection.pyi index 3d3e76bafdfb..d32a93dc0875 100644 --- a/python/helpers/typeshed/third_party/2/google/protobuf/reflection.pyi +++ b/python/helpers/typeshed/third_party/2/google/protobuf/reflection.pyi @@ -1,7 +1,3 @@ -# Stubs for google.protobuf.reflection (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - class GeneratedProtocolMessageType(type): def __new__(cls, name, bases, dictionary): ... def __init__(cls, name, bases, dictionary) -> None: ... diff --git a/python/helpers/typeshed/third_party/2/google/protobuf/symbol_database.pyi b/python/helpers/typeshed/third_party/2/google/protobuf/symbol_database.pyi index e29070cf59a9..df8300f50a62 100644 --- a/python/helpers/typeshed/third_party/2/google/protobuf/symbol_database.pyi +++ b/python/helpers/typeshed/third_party/2/google/protobuf/symbol_database.pyi @@ -1,7 +1,3 @@ -# Stubs for google.protobuf.symbol_database -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Dict, Iterable, Type from .descriptor import EnumDescriptor, FileDescriptor diff --git a/python/helpers/typeshed/third_party/2/itsdangerous.pyi b/python/helpers/typeshed/third_party/2/itsdangerous.pyi index 0efb3d696ee1..075a2e402dfd 100644 --- a/python/helpers/typeshed/third_party/2/itsdangerous.pyi +++ b/python/helpers/typeshed/third_party/2/itsdangerous.pyi @@ -1,7 +1,3 @@ -# Stubs for itsdangerous (Python 2.7) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from datetime import datetime from itertools import izip from typing import Any, Callable, IO, MutableMapping, Optional, Text, Tuple, Union diff --git a/python/helpers/typeshed/third_party/2/kazoo/__init__.pyi b/python/helpers/typeshed/third_party/2/kazoo/__init__.pyi index 1aae9a518fe2..e69de29bb2d1 100644 --- a/python/helpers/typeshed/third_party/2/kazoo/__init__.pyi +++ b/python/helpers/typeshed/third_party/2/kazoo/__init__.pyi @@ -1,3 +0,0 @@ -# Stubs for kazoo (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. diff --git a/python/helpers/typeshed/third_party/2/kazoo/client.pyi b/python/helpers/typeshed/third_party/2/kazoo/client.pyi index 8db0eda432ba..3fd79a388378 100644 --- a/python/helpers/typeshed/third_party/2/kazoo/client.pyi +++ b/python/helpers/typeshed/third_party/2/kazoo/client.pyi @@ -1,7 +1,3 @@ -# Stubs for kazoo.client (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any string_types = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2/kazoo/exceptions.pyi b/python/helpers/typeshed/third_party/2/kazoo/exceptions.pyi index ed632ba1cf3f..dcec322a32a9 100644 --- a/python/helpers/typeshed/third_party/2/kazoo/exceptions.pyi +++ b/python/helpers/typeshed/third_party/2/kazoo/exceptions.pyi @@ -1,7 +1,3 @@ -# Stubs for kazoo.exceptions (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class KazooException(Exception): ... diff --git a/python/helpers/typeshed/third_party/2/kazoo/recipe/__init__.pyi b/python/helpers/typeshed/third_party/2/kazoo/recipe/__init__.pyi index 44bc4cb0e75a..e69de29bb2d1 100644 --- a/python/helpers/typeshed/third_party/2/kazoo/recipe/__init__.pyi +++ b/python/helpers/typeshed/third_party/2/kazoo/recipe/__init__.pyi @@ -1,3 +0,0 @@ -# Stubs for kazoo.recipe (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. diff --git a/python/helpers/typeshed/third_party/2/kazoo/recipe/watchers.pyi b/python/helpers/typeshed/third_party/2/kazoo/recipe/watchers.pyi index f9421631a6e8..545f5018ccf0 100644 --- a/python/helpers/typeshed/third_party/2/kazoo/recipe/watchers.pyi +++ b/python/helpers/typeshed/third_party/2/kazoo/recipe/watchers.pyi @@ -1,7 +1,3 @@ -# Stubs for kazoo.recipe.watchers (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any log = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2/pymssql.pyi b/python/helpers/typeshed/third_party/2/pymssql.pyi index 3f75b313dc39..a35b050c9ea2 100644 --- a/python/helpers/typeshed/third_party/2/pymssql.pyi +++ b/python/helpers/typeshed/third_party/2/pymssql.pyi @@ -26,7 +26,7 @@ class Cursor(object): def executemany(self, stmt: str, params: Optional[Sequence[Tuple[Scalar, ...]]]) -> None: ... def fetchall(self) -> List[Result]: ... - def fetchmany(self, size: Optional[Union[int, None]]) -> List[Result]: ... + def fetchmany(self, size: Optional[int]) -> List[Result]: ... def fetchone(self) -> Result: ... def connect(server: Optional[str], diff --git a/python/helpers/typeshed/third_party/2/redis/__init__.pyi b/python/helpers/typeshed/third_party/2/redis/__init__.pyi index 53ec8186b545..333de49b0805 100644 --- a/python/helpers/typeshed/third_party/2/redis/__init__.pyi +++ b/python/helpers/typeshed/third_party/2/redis/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for redis (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from . import client from . import connection from . import utils diff --git a/python/helpers/typeshed/third_party/2/redis/client.pyi b/python/helpers/typeshed/third_party/2/redis/client.pyi index 43693ec4ff27..99f2adf9db5c 100644 --- a/python/helpers/typeshed/third_party/2/redis/client.pyi +++ b/python/helpers/typeshed/third_party/2/redis/client.pyi @@ -1,7 +1,3 @@ -# Stubs for redis.client (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any SYM_EMPTY = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2/redis/connection.pyi b/python/helpers/typeshed/third_party/2/redis/connection.pyi index 214cd8dd4d21..9756477123bc 100644 --- a/python/helpers/typeshed/third_party/2/redis/connection.pyi +++ b/python/helpers/typeshed/third_party/2/redis/connection.pyi @@ -1,7 +1,3 @@ -# Stubs for redis.connection (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any ssl_available = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2/redis/exceptions.pyi b/python/helpers/typeshed/third_party/2/redis/exceptions.pyi index 97a11f512eaf..e0cd08a83c5b 100644 --- a/python/helpers/typeshed/third_party/2/redis/exceptions.pyi +++ b/python/helpers/typeshed/third_party/2/redis/exceptions.pyi @@ -1,7 +1,3 @@ -# Stubs for redis.exceptions (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - class RedisError(Exception): ... def __unicode__(self): ... diff --git a/python/helpers/typeshed/third_party/2/redis/utils.pyi b/python/helpers/typeshed/third_party/2/redis/utils.pyi index fe1388cc61e9..5e32010bf7c4 100644 --- a/python/helpers/typeshed/third_party/2/redis/utils.pyi +++ b/python/helpers/typeshed/third_party/2/redis/utils.pyi @@ -1,7 +1,3 @@ -# Stubs for redis.utils (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any HIREDIS_AVAILABLE = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2/routes/__init__.pyi b/python/helpers/typeshed/third_party/2/routes/__init__.pyi index 5d7864db5512..8a1261f5599c 100644 --- a/python/helpers/typeshed/third_party/2/routes/__init__.pyi +++ b/python/helpers/typeshed/third_party/2/routes/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for routes (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from . import mapper from . import util diff --git a/python/helpers/typeshed/third_party/2/routes/mapper.pyi b/python/helpers/typeshed/third_party/2/routes/mapper.pyi index 573a2ef2df5d..074c4ffd1256 100644 --- a/python/helpers/typeshed/third_party/2/routes/mapper.pyi +++ b/python/helpers/typeshed/third_party/2/routes/mapper.pyi @@ -1,7 +1,3 @@ -# Stubs for routes.mapper (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any COLLECTION_ACTIONS = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2/routes/util.pyi b/python/helpers/typeshed/third_party/2/routes/util.pyi index e5210e37a515..aeb97f3d4cfe 100644 --- a/python/helpers/typeshed/third_party/2/routes/util.pyi +++ b/python/helpers/typeshed/third_party/2/routes/util.pyi @@ -1,7 +1,3 @@ -# Stubs for routes.util (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class RoutesException(Exception): ... diff --git a/python/helpers/typeshed/third_party/2/scribe/scribe.pyi b/python/helpers/typeshed/third_party/2/scribe/scribe.pyi index ec2a71f72dfa..4d9a2866a8fc 100644 --- a/python/helpers/typeshed/third_party/2/scribe/scribe.pyi +++ b/python/helpers/typeshed/third_party/2/scribe/scribe.pyi @@ -1,7 +1,3 @@ -# Stubs for scribe.scribe (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any import fb303.FacebookService diff --git a/python/helpers/typeshed/third_party/2/scribe/ttypes.pyi b/python/helpers/typeshed/third_party/2/scribe/ttypes.pyi index 32f01bd70acf..69ec920c1666 100644 --- a/python/helpers/typeshed/third_party/2/scribe/ttypes.pyi +++ b/python/helpers/typeshed/third_party/2/scribe/ttypes.pyi @@ -1,7 +1,3 @@ -# Stubs for scribe.ttypes (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any fastbinary = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2/selenium/webdriver/remote/webdriver.pyi b/python/helpers/typeshed/third_party/2/selenium/webdriver/remote/webdriver.pyi index 9e0f24c42b98..c8e565cfb44d 100644 --- a/python/helpers/typeshed/third_party/2/selenium/webdriver/remote/webdriver.pyi +++ b/python/helpers/typeshed/third_party/2/selenium/webdriver/remote/webdriver.pyi @@ -1,7 +1,3 @@ -# Stubs for selenium.webdriver.remote.webdriver (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Dict, List, Optional from .mobile import Mobile as Mobile from selenium.webdriver.remote.webelement import WebElement diff --git a/python/helpers/typeshed/third_party/2/selenium/webdriver/remote/webelement.pyi b/python/helpers/typeshed/third_party/2/selenium/webdriver/remote/webelement.pyi index 057703642ee9..fd94c56f13c9 100644 --- a/python/helpers/typeshed/third_party/2/selenium/webdriver/remote/webelement.pyi +++ b/python/helpers/typeshed/third_party/2/selenium/webdriver/remote/webelement.pyi @@ -1,7 +1,3 @@ -# Stubs for selenium.webdriver.remote.webelement (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from selenium.webdriver.remote.webdriver import WebDriver from typing import Any, Optional, Dict, List diff --git a/python/helpers/typeshed/third_party/2/simplejson/__init__.pyi b/python/helpers/typeshed/third_party/2/simplejson/__init__.pyi index 5f94eb9696f6..4565543b17b4 100644 --- a/python/helpers/typeshed/third_party/2/simplejson/__init__.pyi +++ b/python/helpers/typeshed/third_party/2/simplejson/__init__.pyi @@ -1,8 +1,8 @@ from typing import Any, IO -from simplejson.scanner import JSONDecodeError -from simplejson.decoder import JSONDecoder -from simplejson.encoder import JSONEncoder, JSONEncoderForHTML +from simplejson.scanner import JSONDecodeError as JSONDecodeError +from simplejson.decoder import JSONDecoder as JSONDecoder +from simplejson.encoder import JSONEncoder as JSONEncoder, JSONEncoderForHTML as JSONEncoderForHTML def dumps(obj: Any, *args: Any, **kwds: Any) -> str: ... def dump(obj: Any, fp: IO[str], *args: Any, **kwds: Any) -> None: ... diff --git a/python/helpers/typeshed/third_party/2/six/__init__.pyi b/python/helpers/typeshed/third_party/2/six/__init__.pyi index c4c4723f868b..bd8d97a3704e 100644 --- a/python/helpers/typeshed/third_party/2/six/__init__.pyi +++ b/python/helpers/typeshed/third_party/2/six/__init__.pyi @@ -82,7 +82,7 @@ def assertRegex(self: unittest.TestCase, text: AnyStr, expected_regex: Union[Any def reraise(tp: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType] = ...) -> NoReturn: ... def exec_(_code_: Union[unicode, types.CodeType], _globs_: Dict[str, Any] = ..., _locs_: Dict[str, Any] = ...): ... -def raise_from(value: BaseException, from_value: BaseException) -> None: ... +def raise_from(value: BaseException, from_value: Optional[BaseException]) -> NoReturn: ... print_ = print diff --git a/python/helpers/typeshed/third_party/2/six/moves/__init__.pyi b/python/helpers/typeshed/third_party/2/six/moves/__init__.pyi index a59fe7f4ea25..574717245c60 100644 --- a/python/helpers/typeshed/third_party/2/six/moves/__init__.pyi +++ b/python/helpers/typeshed/third_party/2/six/moves/__init__.pyi @@ -1,6 +1,7 @@ -# Provisional stubs for six.moves (Python 2.7) - -import Cookie as http_cookies +# Stubs for six.moves +# +# Note: Commented out items means they weren't implemented at the time. +# Uncomment them when the modules have been added to the typeshed. from cStringIO import StringIO as cStringIO from itertools import ifilter as filter from itertools import ifilterfalse as filterfalse @@ -20,14 +21,46 @@ from UserString import UserString as UserString from __builtin__ import xrange as xrange from itertools import izip as zip from itertools import izip_longest as zip_longest -import six.moves.cPickle as cPickle -import HTMLParser as html_parser -import htmlentitydefs as html_entities -import httplib as http_client -import ConfigParser as configparser import __builtin__ as builtins - -import six.moves.urllib_parse as urllib_parse -import six.moves.urllib_error as urllib_error +import ConfigParser as configparser +# import copy_reg as copyreg +# import gdbm as dbm_gnu +# import dummy_thread as _dummy_thread +import cookielib as http_cookiejar +import Cookie as http_cookies +import htmlentitydefs as html_entities +import HTMLParser as html_parser +import httplib as http_client +# import email.MIMEMultipart as email_mime_multipart +# import email.MIMENonMultipart as email_mime_nonmultipart +import email.MIMEText as email_mime_text +# import email.MIMEBase as email_mime_base +import BaseHTTPServer as BaseHTTPServer +# import CGIHTTPServer as CGIHTTPServer +# import SimpleHTTPServer as SimpleHTTPServer +import cPickle as cPickle +import Queue as queue +import repr as reprlib +import SocketServer as socketserver +import thread as _thread +# import Tkinter as tkinter +# import Dialog as tkinter_dialog +# import FileDialog as tkinter_filedialog +# import ScrolledText as tkinter_scrolledtext +# import SimpleDialog as tkinter_simpledialog +# import Tix as tkinter_tix +# import ttk as tkinter_ttk +# import Tkconstants as tkinter_constants +# import Tkdnd as tkinter_dnd +# import tkColorChooser as tkinter_colorchooser +# import tkCommonDialog as tkinter_commondialog +# import tkFileDialog as tkinter_tkfiledialog +# import tkFont as tkinter_font +# import tkMessageBox as tkinter_messagebox +# import tkSimpleDialog as tkinter_tksimpledialog +import six.moves.urllib.parse as urllib_parse +import six.moves.urllib.error as urllib_error import six.moves.urllib as urllib -import six.moves.urllib_robotparser as urllib_robotparser +import robotparser as urllib_robotparser +# import xmlrpclib as xmlrpc_client +# import SimpleXMLRPCServer as xmlrpc_server diff --git a/python/helpers/typeshed/third_party/2/six/moves/urllib/__init__.pyi b/python/helpers/typeshed/third_party/2/six/moves/urllib/__init__.pyi index 71523cda7825..d08209c51cc1 100644 --- a/python/helpers/typeshed/third_party/2/six/moves/urllib/__init__.pyi +++ b/python/helpers/typeshed/third_party/2/six/moves/urllib/__init__.pyi @@ -1,8 +1,3 @@ -# Generated by stubtool 0.1, DO NOT EDIT -# See https://github.com/o11c/stubtool -# -# Stubs for six.moves.urllib (Python 2.7) - import six.moves.urllib.error as error import six.moves.urllib.parse as parse import six.moves.urllib.request as request diff --git a/python/helpers/typeshed/third_party/2/six/moves/urllib/error.pyi b/python/helpers/typeshed/third_party/2/six/moves/urllib/error.pyi index 05eda84a7a82..044327ee4fb4 100644 --- a/python/helpers/typeshed/third_party/2/six/moves/urllib/error.pyi +++ b/python/helpers/typeshed/third_party/2/six/moves/urllib/error.pyi @@ -1,8 +1,3 @@ -# Generated by stubtool 0.1, DO NOT EDIT -# See https://github.com/o11c/stubtool -# -# Stubs for six.moves.urllib.error (Python 2.7) - from urllib2 import URLError as URLError from urllib2 import HTTPError as HTTPError from urllib import ContentTooShortError as ContentTooShortError diff --git a/python/helpers/typeshed/third_party/2/six/moves/urllib/parse.pyi b/python/helpers/typeshed/third_party/2/six/moves/urllib/parse.pyi index 25351fb86860..4096c27fae9b 100644 --- a/python/helpers/typeshed/third_party/2/six/moves/urllib/parse.pyi +++ b/python/helpers/typeshed/third_party/2/six/moves/urllib/parse.pyi @@ -1,30 +1,24 @@ -# Generated by stubtool 0.1, DO NOT EDIT -# See https://github.com/o11c/stubtool -# -# Stubs for six.moves.urllib.parse (Python 2.7) - -from six.moves.urllib_parse import ( - ParseResult as ParseResult, - SplitResult as SplitResult, - parse_qs as parse_qs, - parse_qsl as parse_qsl, - urldefrag as urldefrag, - urljoin as urljoin, - urlparse as urlparse, - urlsplit as urlsplit, - urlunparse as urlunparse, - urlunsplit as urlunsplit, - quote as quote, - quote_plus as quote_plus, - unquote as unquote, - unquote_plus as unquote_plus, - urlencode as urlencode, - splitquery as splitquery, - splittag as splittag, - splituser as splituser, - uses_fragment as uses_fragment, - uses_netloc as uses_netloc, - uses_params as uses_params, - uses_query as uses_query, - uses_relative as uses_relative, -) +# Stubs for six.moves.urllib.parse +from urlparse import ParseResult as ParseResult +from urlparse import SplitResult as SplitResult +from urlparse import parse_qs as parse_qs +from urlparse import parse_qsl as parse_qsl +from urlparse import urldefrag as urldefrag +from urlparse import urljoin as urljoin +from urlparse import urlparse as urlparse +from urlparse import urlsplit as urlsplit +from urlparse import urlunparse as urlunparse +from urlparse import urlunsplit as urlunsplit +from urllib import quote as quote +from urllib import quote_plus as quote_plus +from urllib import unquote as unquote +from urllib import unquote_plus as unquote_plus +from urllib import urlencode as urlencode +from urllib import splitquery as splitquery +from urllib import splittag as splittag +from urllib import splituser as splituser +from urlparse import uses_fragment as uses_fragment +from urlparse import uses_netloc as uses_netloc +from urlparse import uses_params as uses_params +from urlparse import uses_query as uses_query +from urlparse import uses_relative as uses_relative diff --git a/python/helpers/typeshed/third_party/2/six/moves/urllib/request.pyi b/python/helpers/typeshed/third_party/2/six/moves/urllib/request.pyi index 109cda88f4cb..0b8ad8cff553 100644 --- a/python/helpers/typeshed/third_party/2/six/moves/urllib/request.pyi +++ b/python/helpers/typeshed/third_party/2/six/moves/urllib/request.pyi @@ -1,8 +1,4 @@ -# Generated by stubtool 0.1, DO NOT EDIT -# See https://github.com/o11c/stubtool -# -# Stubs for six.moves.urllib.request (Python 2.7) - +# Stubs for six.moves.urllib.request from urllib2 import urlopen as urlopen from urllib2 import install_opener as install_opener from urllib2 import build_opener as build_opener diff --git a/python/helpers/typeshed/third_party/2/six/moves/urllib/response.pyi b/python/helpers/typeshed/third_party/2/six/moves/urllib/response.pyi index d778514d02fd..83e117fb6267 100644 --- a/python/helpers/typeshed/third_party/2/six/moves/urllib/response.pyi +++ b/python/helpers/typeshed/third_party/2/six/moves/urllib/response.pyi @@ -1,8 +1,4 @@ -# Generated by stubtool 0.1, DO NOT EDIT -# See https://github.com/o11c/stubtool -# -# Stubs for six.moves.urllib.response (Python 2.7) - +# Stubs for six.moves.urllib.response from urllib import addbase as addbase from urllib import addclosehook as addclosehook from urllib import addinfo as addinfo diff --git a/python/helpers/typeshed/third_party/2/six/moves/urllib/robotparser.pyi b/python/helpers/typeshed/third_party/2/six/moves/urllib/robotparser.pyi index 3b337585f4c3..11eef5040766 100644 --- a/python/helpers/typeshed/third_party/2/six/moves/urllib/robotparser.pyi +++ b/python/helpers/typeshed/third_party/2/six/moves/urllib/robotparser.pyi @@ -1,6 +1 @@ -# Generated by stubtool 0.1, DO NOT EDIT -# See https://github.com/o11c/stubtool -# -# Stubs for six.moves.urllib.robotparser (Python 2.7) - from robotparser import RobotFileParser as RobotFileParser diff --git a/python/helpers/typeshed/third_party/2/thrift/Thrift.pyi b/python/helpers/typeshed/third_party/2/thrift/Thrift.pyi index 4397fb69ce70..7d5a28fa4f9e 100644 --- a/python/helpers/typeshed/third_party/2/thrift/Thrift.pyi +++ b/python/helpers/typeshed/third_party/2/thrift/Thrift.pyi @@ -1,7 +1,3 @@ -# Stubs for thrift.Thrift (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class TType: diff --git a/python/helpers/typeshed/third_party/2/thrift/protocol/TBinaryProtocol.pyi b/python/helpers/typeshed/third_party/2/thrift/protocol/TBinaryProtocol.pyi index a1e5e71e2579..21a729daeaaa 100644 --- a/python/helpers/typeshed/third_party/2/thrift/protocol/TBinaryProtocol.pyi +++ b/python/helpers/typeshed/third_party/2/thrift/protocol/TBinaryProtocol.pyi @@ -1,7 +1,3 @@ -# Stubs for thrift.protocol.TBinaryProtocol (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from .TProtocol import TProtocolBase diff --git a/python/helpers/typeshed/third_party/2/thrift/protocol/TProtocol.pyi b/python/helpers/typeshed/third_party/2/thrift/protocol/TProtocol.pyi index e59765a0e877..cf5d3565ebce 100644 --- a/python/helpers/typeshed/third_party/2/thrift/protocol/TProtocol.pyi +++ b/python/helpers/typeshed/third_party/2/thrift/protocol/TProtocol.pyi @@ -1,7 +1,3 @@ -# Stubs for thrift.protocol.TProtocol (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from thrift.Thrift import TException diff --git a/python/helpers/typeshed/third_party/2/thrift/protocol/__init__.pyi b/python/helpers/typeshed/third_party/2/thrift/protocol/__init__.pyi index f98118b70cab..4a5b650bed70 100644 --- a/python/helpers/typeshed/third_party/2/thrift/protocol/__init__.pyi +++ b/python/helpers/typeshed/third_party/2/thrift/protocol/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for thrift.protocol (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - # Names in __all__ with no definition: # TBase # TBinaryProtocol diff --git a/python/helpers/typeshed/third_party/2/thrift/transport/TSocket.pyi b/python/helpers/typeshed/third_party/2/thrift/transport/TSocket.pyi index 6148117f39e8..9e0fef47c599 100644 --- a/python/helpers/typeshed/third_party/2/thrift/transport/TSocket.pyi +++ b/python/helpers/typeshed/third_party/2/thrift/transport/TSocket.pyi @@ -1,7 +1,3 @@ -# Stubs for thrift.transport.TSocket (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from .TTransport import TTransportBase, TServerTransportBase diff --git a/python/helpers/typeshed/third_party/2/thrift/transport/TTransport.pyi b/python/helpers/typeshed/third_party/2/thrift/transport/TTransport.pyi index d46cca0eddeb..18d2eab0f77f 100644 --- a/python/helpers/typeshed/third_party/2/thrift/transport/TTransport.pyi +++ b/python/helpers/typeshed/third_party/2/thrift/transport/TTransport.pyi @@ -1,7 +1,3 @@ -# Stubs for thrift.transport.TTransport (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from thrift.Thrift import TException diff --git a/python/helpers/typeshed/third_party/2/thrift/transport/__init__.pyi b/python/helpers/typeshed/third_party/2/thrift/transport/__init__.pyi index ce02c619474f..fd3f5f5a2b58 100644 --- a/python/helpers/typeshed/third_party/2/thrift/transport/__init__.pyi +++ b/python/helpers/typeshed/third_party/2/thrift/transport/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for thrift.transport (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - # Names in __all__ with no definition: # THttpClient # TSocket diff --git a/python/helpers/typeshed/third_party/2/tornado/concurrent.pyi b/python/helpers/typeshed/third_party/2/tornado/concurrent.pyi index 46f39a3c779e..82c29dac56d5 100644 --- a/python/helpers/typeshed/third_party/2/tornado/concurrent.pyi +++ b/python/helpers/typeshed/third_party/2/tornado/concurrent.pyi @@ -1,7 +1,3 @@ -# Stubs for tornado.concurrent (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any futures = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2/tornado/gen.pyi b/python/helpers/typeshed/third_party/2/tornado/gen.pyi index fbde2dac0e62..4ec96b5aff03 100644 --- a/python/helpers/typeshed/third_party/2/tornado/gen.pyi +++ b/python/helpers/typeshed/third_party/2/tornado/gen.pyi @@ -1,7 +1,3 @@ -# Stubs for tornado.gen (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from collections import namedtuple diff --git a/python/helpers/typeshed/third_party/2/tornado/httpclient.pyi b/python/helpers/typeshed/third_party/2/tornado/httpclient.pyi index fa41d16d9827..d3c7127cd97f 100644 --- a/python/helpers/typeshed/third_party/2/tornado/httpclient.pyi +++ b/python/helpers/typeshed/third_party/2/tornado/httpclient.pyi @@ -1,7 +1,3 @@ -# Stubs for tornado.httpclient (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from tornado.util import Configurable diff --git a/python/helpers/typeshed/third_party/2/tornado/httpserver.pyi b/python/helpers/typeshed/third_party/2/tornado/httpserver.pyi index f4b2aa9fff58..3738c85b4db3 100644 --- a/python/helpers/typeshed/third_party/2/tornado/httpserver.pyi +++ b/python/helpers/typeshed/third_party/2/tornado/httpserver.pyi @@ -1,7 +1,3 @@ -# Stubs for tornado.httpserver (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from tornado import httputil from tornado.tcpserver import TCPServer diff --git a/python/helpers/typeshed/third_party/2/tornado/httputil.pyi b/python/helpers/typeshed/third_party/2/tornado/httputil.pyi index f8fefb523313..bdcbfa5b2eea 100644 --- a/python/helpers/typeshed/third_party/2/tornado/httputil.pyi +++ b/python/helpers/typeshed/third_party/2/tornado/httputil.pyi @@ -1,7 +1,3 @@ -# Stubs for tornado.httputil (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from tornado.util import ObjectDict from collections import namedtuple diff --git a/python/helpers/typeshed/third_party/2/tornado/ioloop.pyi b/python/helpers/typeshed/third_party/2/tornado/ioloop.pyi index 38624c5dbfad..e4f97e7eeb69 100644 --- a/python/helpers/typeshed/third_party/2/tornado/ioloop.pyi +++ b/python/helpers/typeshed/third_party/2/tornado/ioloop.pyi @@ -1,7 +1,3 @@ -# Stubs for tornado.ioloop (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from tornado.util import Configurable diff --git a/python/helpers/typeshed/third_party/2/tornado/locks.pyi b/python/helpers/typeshed/third_party/2/tornado/locks.pyi index ea61761d3005..eaeba24f8c87 100644 --- a/python/helpers/typeshed/third_party/2/tornado/locks.pyi +++ b/python/helpers/typeshed/third_party/2/tornado/locks.pyi @@ -1,7 +1,3 @@ -# Stubs for tornado.locks (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class _TimeoutGarbageCollector: diff --git a/python/helpers/typeshed/third_party/2/tornado/netutil.pyi b/python/helpers/typeshed/third_party/2/tornado/netutil.pyi index bfbc6b1c7275..b12154b6bf12 100644 --- a/python/helpers/typeshed/third_party/2/tornado/netutil.pyi +++ b/python/helpers/typeshed/third_party/2/tornado/netutil.pyi @@ -1,7 +1,3 @@ -# Stubs for tornado.netutil (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from tornado.util import Configurable diff --git a/python/helpers/typeshed/third_party/2/tornado/tcpserver.pyi b/python/helpers/typeshed/third_party/2/tornado/tcpserver.pyi index 9fa7a094c50e..489e4d4ec1c3 100644 --- a/python/helpers/typeshed/third_party/2/tornado/tcpserver.pyi +++ b/python/helpers/typeshed/third_party/2/tornado/tcpserver.pyi @@ -1,7 +1,3 @@ -# Stubs for tornado.tcpserver (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any ssl = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2/tornado/testing.pyi b/python/helpers/typeshed/third_party/2/tornado/testing.pyi index c6fde570563a..5b8c6626d09f 100644 --- a/python/helpers/typeshed/third_party/2/tornado/testing.pyi +++ b/python/helpers/typeshed/third_party/2/tornado/testing.pyi @@ -1,7 +1,3 @@ -# Stubs for tornado.testing (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any import unittest import logging diff --git a/python/helpers/typeshed/third_party/2/tornado/util.pyi b/python/helpers/typeshed/third_party/2/tornado/util.pyi index 3b0713187df9..cf535c402baa 100644 --- a/python/helpers/typeshed/third_party/2/tornado/util.pyi +++ b/python/helpers/typeshed/third_party/2/tornado/util.pyi @@ -1,7 +1,3 @@ -# Stubs for tornado.util (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any xrange = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2/tornado/web.pyi b/python/helpers/typeshed/third_party/2/tornado/web.pyi index ca0c7c09cda1..69e5a37261e5 100644 --- a/python/helpers/typeshed/third_party/2/tornado/web.pyi +++ b/python/helpers/typeshed/third_party/2/tornado/web.pyi @@ -1,7 +1,3 @@ -# Stubs for tornado.web (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from tornado import httputil diff --git a/python/helpers/typeshed/third_party/2/werkzeug/__init__.pyi b/python/helpers/typeshed/third_party/2/werkzeug/__init__.pyi index 5bb4845f0f3f..c375f411b5c2 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/__init__.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from types import ModuleType from typing import Any diff --git a/python/helpers/typeshed/third_party/2/werkzeug/_compat.pyi b/python/helpers/typeshed/third_party/2/werkzeug/_compat.pyi index 801bddaebda2..5779bc84bf8b 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/_compat.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/_compat.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug._compat (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any import StringIO as BytesIO diff --git a/python/helpers/typeshed/third_party/2/werkzeug/_internal.pyi b/python/helpers/typeshed/third_party/2/werkzeug/_internal.pyi index 1a1bbd5555f6..6fddbdd77ce3 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/_internal.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/_internal.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug._internal (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class _Missing: diff --git a/python/helpers/typeshed/third_party/2/werkzeug/_reloader.pyi b/python/helpers/typeshed/third_party/2/werkzeug/_reloader.pyi index 9bfea1fca67e..55a560d2f504 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/_reloader.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/_reloader.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug._reloader (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class ReloaderLoop: diff --git a/python/helpers/typeshed/third_party/2/werkzeug/contrib/__init__.pyi b/python/helpers/typeshed/third_party/2/werkzeug/contrib/__init__.pyi index 4b77b01773ed..e69de29bb2d1 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/contrib/__init__.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/contrib/__init__.pyi @@ -1,3 +0,0 @@ -# Stubs for werkzeug.contrib (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. diff --git a/python/helpers/typeshed/third_party/2/werkzeug/contrib/atom.pyi b/python/helpers/typeshed/third_party/2/werkzeug/contrib/atom.pyi index 98f994db61eb..1e27873630cc 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/contrib/atom.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/contrib/atom.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.atom (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any XHTML_NAMESPACE = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2/werkzeug/contrib/cache.pyi b/python/helpers/typeshed/third_party/2/werkzeug/contrib/cache.pyi index 1c9fcbe1c372..23e78997c65a 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/contrib/cache.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/contrib/cache.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.cache (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class BaseCache: diff --git a/python/helpers/typeshed/third_party/2/werkzeug/contrib/fixers.pyi b/python/helpers/typeshed/third_party/2/werkzeug/contrib/fixers.pyi index 147456eef83a..a45c661c9cb8 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/contrib/fixers.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/contrib/fixers.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.fixers (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class CGIRootFix: diff --git a/python/helpers/typeshed/third_party/2/werkzeug/contrib/iterio.pyi b/python/helpers/typeshed/third_party/2/werkzeug/contrib/iterio.pyi index fd2c2a2a2001..33da95600a9b 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/contrib/iterio.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/contrib/iterio.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.iterio (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any greenlet = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2/werkzeug/contrib/jsrouting.pyi b/python/helpers/typeshed/third_party/2/werkzeug/contrib/jsrouting.pyi index 6fdd6150db38..a9cc8c2a153a 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/contrib/jsrouting.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/contrib/jsrouting.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.jsrouting (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any def dumps(*args): ... diff --git a/python/helpers/typeshed/third_party/2/werkzeug/contrib/limiter.pyi b/python/helpers/typeshed/third_party/2/werkzeug/contrib/limiter.pyi index d51038effcdb..52501c6eea51 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/contrib/limiter.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/contrib/limiter.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.limiter (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class StreamLimitMiddleware: diff --git a/python/helpers/typeshed/third_party/2/werkzeug/contrib/lint.pyi b/python/helpers/typeshed/third_party/2/werkzeug/contrib/lint.pyi index a0c2295991ec..f89c120927f9 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/contrib/lint.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/contrib/lint.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.lint (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class WSGIWarning(Warning): ... diff --git a/python/helpers/typeshed/third_party/2/werkzeug/contrib/profiler.pyi b/python/helpers/typeshed/third_party/2/werkzeug/contrib/profiler.pyi index b41c1c8ba8cc..db1eacbf69ac 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/contrib/profiler.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/contrib/profiler.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.profiler (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any available = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2/werkzeug/contrib/securecookie.pyi b/python/helpers/typeshed/third_party/2/werkzeug/contrib/securecookie.pyi index c262bed6f430..219356f64378 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/contrib/securecookie.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/contrib/securecookie.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.securecookie (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from hmac import new as hmac from hashlib import sha1 as _default_hash diff --git a/python/helpers/typeshed/third_party/2/werkzeug/contrib/sessions.pyi b/python/helpers/typeshed/third_party/2/werkzeug/contrib/sessions.pyi index 5b84ede4e995..aa3f8fc2769e 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/contrib/sessions.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/contrib/sessions.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.sessions (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from werkzeug.datastructures import CallbackDict diff --git a/python/helpers/typeshed/third_party/2/werkzeug/contrib/testtools.pyi b/python/helpers/typeshed/third_party/2/werkzeug/contrib/testtools.pyi index c304f390ed5b..860ebb7afb0f 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/contrib/testtools.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/contrib/testtools.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.testtools (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from werkzeug.wrappers import Response diff --git a/python/helpers/typeshed/third_party/2/werkzeug/contrib/wrappers.pyi b/python/helpers/typeshed/third_party/2/werkzeug/contrib/wrappers.pyi index b5384620c2ba..4ebc7e80d765 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/contrib/wrappers.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/contrib/wrappers.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.wrappers (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any def is_known_charset(charset): ... diff --git a/python/helpers/typeshed/third_party/2/werkzeug/datastructures.pyi b/python/helpers/typeshed/third_party/2/werkzeug/datastructures.pyi index cbbddf9409f2..72e789952ad6 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/datastructures.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/datastructures.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.datastructures (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from collections import Container, Iterable, Mapping, MutableSet diff --git a/python/helpers/typeshed/third_party/2/werkzeug/debug/__init__.pyi b/python/helpers/typeshed/third_party/2/werkzeug/debug/__init__.pyi index abe6495a8e8d..a806edd37d9a 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/debug/__init__.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/debug/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.debug (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from werkzeug.wrappers import BaseRequest as Request, BaseResponse as Response diff --git a/python/helpers/typeshed/third_party/2/werkzeug/debug/console.pyi b/python/helpers/typeshed/third_party/2/werkzeug/debug/console.pyi index ddc1a334374d..5046a519cda0 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/debug/console.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/debug/console.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.debug.console (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any import code diff --git a/python/helpers/typeshed/third_party/2/werkzeug/debug/repr.pyi b/python/helpers/typeshed/third_party/2/werkzeug/debug/repr.pyi index 6889a27fdadb..fe3faef8e109 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/debug/repr.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/debug/repr.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.debug.repr (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any deque = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2/werkzeug/debug/tbtools.pyi b/python/helpers/typeshed/third_party/2/werkzeug/debug/tbtools.pyi index 1279409f33e9..7c0cd584ba04 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/debug/tbtools.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/debug/tbtools.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.debug.tbtools (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any UTF8_COOKIE = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2/werkzeug/exceptions.pyi b/python/helpers/typeshed/third_party/2/werkzeug/exceptions.pyi index d520518b4efd..f7017e5752fe 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/exceptions.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/exceptions.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.exceptions (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class HTTPException(Exception): diff --git a/python/helpers/typeshed/third_party/2/werkzeug/filesystem.pyi b/python/helpers/typeshed/third_party/2/werkzeug/filesystem.pyi index 9f1b0bbcb2c1..80913ca669a6 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/filesystem.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/filesystem.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.filesystem (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any has_likely_buggy_unicode_filesystem = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2/werkzeug/formparser.pyi b/python/helpers/typeshed/third_party/2/werkzeug/formparser.pyi index 4b61d276fa52..842c40568d4b 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/formparser.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/formparser.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.formparser (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any def default_stream_factory(total_content_length, filename, content_type, content_length=None): ... diff --git a/python/helpers/typeshed/third_party/2/werkzeug/http.pyi b/python/helpers/typeshed/third_party/2/werkzeug/http.pyi index 1c6e3e8cc8c1..8d6c15f9a895 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/http.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/http.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.http (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from urllib2 import parse_http_list as _parse_list_header diff --git a/python/helpers/typeshed/third_party/2/werkzeug/local.pyi b/python/helpers/typeshed/third_party/2/werkzeug/local.pyi index 8b32367e18c9..f1d167ac74b0 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/local.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/local.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.local (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any def release_local(local): ... diff --git a/python/helpers/typeshed/third_party/2/werkzeug/posixemulation.pyi b/python/helpers/typeshed/third_party/2/werkzeug/posixemulation.pyi index 52349990d55f..b490ab42b173 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/posixemulation.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/posixemulation.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.posixemulation (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from ._compat import to_unicode as to_unicode from .filesystem import get_filesystem_encoding as get_filesystem_encoding diff --git a/python/helpers/typeshed/third_party/2/werkzeug/routing.pyi b/python/helpers/typeshed/third_party/2/werkzeug/routing.pyi index ab9406014b69..22f493e36090 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/routing.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/routing.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.routing (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from werkzeug.exceptions import HTTPException diff --git a/python/helpers/typeshed/third_party/2/werkzeug/script.pyi b/python/helpers/typeshed/third_party/2/werkzeug/script.pyi index e84180e79bd7..758378d3b9ff 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/script.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/script.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.script (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any argument_types = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2/werkzeug/security.pyi b/python/helpers/typeshed/third_party/2/werkzeug/security.pyi index c3752c16acf1..dde9fe1df362 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/security.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/security.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.security (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any SALT_CHARS = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2/werkzeug/serving.pyi b/python/helpers/typeshed/third_party/2/werkzeug/serving.pyi index 752e3e70c833..81b288b411a9 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/serving.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/serving.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.serving (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from ._compat import PY2 as PY2 from SocketServer import ThreadingMixIn, ForkingMixIn diff --git a/python/helpers/typeshed/third_party/2/werkzeug/test.pyi b/python/helpers/typeshed/third_party/2/werkzeug/test.pyi index 89315ca887d2..fd692f1b6d56 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/test.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/test.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.test (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from urllib2 import Request as U2Request from cookielib import CookieJar diff --git a/python/helpers/typeshed/third_party/2/werkzeug/testapp.pyi b/python/helpers/typeshed/third_party/2/werkzeug/testapp.pyi index 3a858434ee24..4e1763385d10 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/testapp.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/testapp.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.testapp (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from werkzeug.wrappers import BaseRequest as Request, BaseResponse as Response diff --git a/python/helpers/typeshed/third_party/2/werkzeug/urls.pyi b/python/helpers/typeshed/third_party/2/werkzeug/urls.pyi index 5f55e12855b3..0c3cefa678fb 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/urls.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/urls.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.urls (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from collections import namedtuple from typing import Any diff --git a/python/helpers/typeshed/third_party/2/werkzeug/useragents.pyi b/python/helpers/typeshed/third_party/2/werkzeug/useragents.pyi index 96b262a7d209..2ca2705e4c46 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/useragents.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/useragents.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.useragents (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class UserAgentParser: diff --git a/python/helpers/typeshed/third_party/2/werkzeug/utils.pyi b/python/helpers/typeshed/third_party/2/werkzeug/utils.pyi index ff7fd3902835..8e2e6b9e723d 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/utils.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/utils.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.utils (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from werkzeug._internal import _DictAccessorProperty diff --git a/python/helpers/typeshed/third_party/2/werkzeug/wrappers.pyi b/python/helpers/typeshed/third_party/2/werkzeug/wrappers.pyi index 982650c626e9..1fb566824bc0 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/wrappers.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/wrappers.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.wrappers (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import ( Any, Iterable, Mapping, Optional, Sequence, Tuple, Type, Union, ) @@ -80,7 +76,15 @@ class BaseResponse: status = ... # type: str direct_passthrough = ... # type: bool response = ... # type: Iterable[str] - def __init__(self, response: Union[Iterable[str], str]=None, status=Union[basestring, int], headers: Union[Headers, Mapping[basestring, basestring], Sequence[Tuple[basestring, basestring]]]=None, mimetype: basestring=None, content_type: basestring=None, direct_passthrough: bool=False) -> None: ... + def __init__(self, + response: Optional[Union[Iterable[str], str]] = None, + status: Optional[Union[basestring, int]] = None, + headers: Optional[Union[Headers, + Mapping[basestring, basestring], + Sequence[Tuple[basestring, basestring]]]] = None, + mimetype: Optional[basestring] = None, + content_type: Optional[basestring] = None, + direct_passthrough: Optional[bool] = False) -> None: ... def call_on_close(self, func): ... @classmethod def force_type(cls, response, environ=None): ... diff --git a/python/helpers/typeshed/third_party/2/werkzeug/wsgi.pyi b/python/helpers/typeshed/third_party/2/werkzeug/wsgi.pyi index 9c4d005b5a0e..77722edf4af7 100644 --- a/python/helpers/typeshed/third_party/2/werkzeug/wsgi.pyi +++ b/python/helpers/typeshed/third_party/2/werkzeug/wsgi.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.wsgi (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any def responder(f): ... diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/AES.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/AES.pyi index 45b13aba2304..b23eacc4ab18 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/AES.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/AES.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Cipher.AES (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Union, Text from .blockalgo import BlockAlgo diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/ARC2.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/ARC2.pyi index 08aec54d9ae6..93aea85ac692 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/ARC2.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/ARC2.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Cipher.ARC2 (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Union, Text from .blockalgo import BlockAlgo diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/ARC4.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/ARC4.pyi index 3a5253943e1b..c5c17ea3d772 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/ARC4.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/ARC4.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Cipher.ARC4 (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Union, Text __revision__ = ... # type: str diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/Blowfish.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/Blowfish.pyi index 546eac2ff4e3..87240131a324 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/Blowfish.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/Blowfish.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Cipher.Blowfish (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Union, Text from .blockalgo import BlockAlgo diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/CAST.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/CAST.pyi index f63a43b61bea..0a8c115b1f9d 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/CAST.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/CAST.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Cipher.CAST (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Union, Text from .blockalgo import BlockAlgo diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/DES.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/DES.pyi index c2b2f5c5d1be..a3fcf2e732de 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/DES.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/DES.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Cipher.DES (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Union, Text from .blockalgo import BlockAlgo diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/DES3.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/DES3.pyi index f8684b784e77..3a7f479c46f5 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/DES3.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/DES3.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Cipher.DES3 (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Union, Text from .blockalgo import BlockAlgo diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/PKCS1_OAEP.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/PKCS1_OAEP.pyi index 4f57f48a2a29..50980a46b931 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/PKCS1_OAEP.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/PKCS1_OAEP.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Cipher.PKCS1_OAEP (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional, Union, Text from Crypto.PublicKey.RSA import _RSAobj diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/PKCS1_v1_5.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/PKCS1_v1_5.pyi index 5d1028297ca2..7a4eddf1afa4 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/PKCS1_v1_5.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/PKCS1_v1_5.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Cipher.PKCS1_v1_5 (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Union, Text from Crypto.PublicKey.RSA import _RSAobj diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/XOR.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/XOR.pyi index c131867cf515..2d631c57896c 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/XOR.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/XOR.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Cipher.XOR (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Union, Text __revision__ = ... # type: str diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/__init__.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/__init__.pyi index 3d42ce3dc9a1..309f2746d93d 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Cipher (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - # Names in __all__ with no definition: # AES # ARC2 diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/blockalgo.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/blockalgo.pyi index fa713774d45c..7c205189ac93 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/blockalgo.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Cipher/blockalgo.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Cipher.blockalgo (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Union, Text MODE_ECB = ... # type: int diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/HMAC.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/HMAC.pyi index 3a71ac4fb3e1..afc005b9cbee 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/HMAC.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/HMAC.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Hash.HMAC (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional digest_size = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/MD2.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/MD2.pyi index 4449c71f6ab8..75e382d44b88 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/MD2.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/MD2.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Hash.MD2 (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional from Crypto.Hash.hashalgo import HashAlgo diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/MD4.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/MD4.pyi index b2e7ee085b53..6644f23cbf83 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/MD4.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/MD4.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Hash.MD4 (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional from Crypto.Hash.hashalgo import HashAlgo diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/MD5.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/MD5.pyi index 15f7ce4fc17f..e8e9eb39fbd5 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/MD5.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/MD5.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Hash.MD5 (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional from Crypto.Hash.hashalgo import HashAlgo diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/RIPEMD.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/RIPEMD.pyi index ba965de254cd..6919ec95c063 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/RIPEMD.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/RIPEMD.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Hash.RIPEMD (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional from Crypto.Hash.hashalgo import HashAlgo diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/SHA.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/SHA.pyi index 16965f7e4a48..03c722b9ce1f 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/SHA.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/SHA.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Hash.SHA (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional from Crypto.Hash.hashalgo import HashAlgo diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/SHA224.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/SHA224.pyi index e9b68d2dc32a..85d6cb7d08a0 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/SHA224.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/SHA224.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Hash.SHA224 (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional from Crypto.Hash.hashalgo import HashAlgo diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/SHA256.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/SHA256.pyi index ca21b6f6c4a6..252d25e23154 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/SHA256.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/SHA256.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Hash.SHA256 (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional from Crypto.Hash.hashalgo import HashAlgo diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/SHA384.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/SHA384.pyi index c318eed3d71c..3a61a63919f2 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/SHA384.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/SHA384.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Hash.SHA384 (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional from Crypto.Hash.hashalgo import HashAlgo diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/SHA512.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/SHA512.pyi index 623951198231..10cedb0609a0 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/SHA512.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/SHA512.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Hash.SHA512 (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional from Crypto.Hash.hashalgo import HashAlgo diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/__init__.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/__init__.pyi index 63859117be6f..9af06f41e72e 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Hash (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - # Names in __all__ with no definition: # HMAC # MD2 diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/hashalgo.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/hashalgo.pyi index e76245373311..e7c84f075e88 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Hash/hashalgo.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Hash/hashalgo.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Hash.hashalgo (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional class HashAlgo: diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Protocol/AllOrNothing.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Protocol/AllOrNothing.pyi index 300e1bfbd54c..5d3e426f1718 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Protocol/AllOrNothing.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Protocol/AllOrNothing.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Protocol.AllOrNothing (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional __revision__ = ... # type: str diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Protocol/Chaffing.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Protocol/Chaffing.pyi index 73c1d56eee77..eec11bd3303e 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Protocol/Chaffing.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Protocol/Chaffing.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Protocol.Chaffing (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - __revision__ = ... # type: str class Chaff: diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Protocol/KDF.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Protocol/KDF.pyi index a14b351c4d9c..20cedb01709c 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Protocol/KDF.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Protocol/KDF.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Protocol.KDF (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional from Crypto.Hash import SHA as SHA1 diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Protocol/__init__.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Protocol/__init__.pyi index afcab98f17fd..e3744e5ee643 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Protocol/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Protocol/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Protocol (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - # Names in __all__ with no definition: # AllOrNothing # Chaffing diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/PublicKey/DSA.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/PublicKey/DSA.pyi index 30b7b1ca1193..f0e6dd202822 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/PublicKey/DSA.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/PublicKey/DSA.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.PublicKey.DSA (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional from .pubkey import pubkey diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/PublicKey/ElGamal.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/PublicKey/ElGamal.pyi index 4ed2c5ba504b..5bc238d1bb9d 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/PublicKey/ElGamal.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/PublicKey/ElGamal.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.PublicKey.ElGamal (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional from Crypto.PublicKey.pubkey import pubkey diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/PublicKey/RSA.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/PublicKey/RSA.pyi index 1fbd6ff22125..cd10d748cded 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/PublicKey/RSA.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/PublicKey/RSA.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.PublicKey.RSA (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional, Union, Text from .pubkey import pubkey diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/PublicKey/__init__.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/PublicKey/__init__.pyi index 84bc3bc5f7a5..36d9e9434093 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/PublicKey/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/PublicKey/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.PublicKey (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - # Names in __all__ with no definition: # DSA # ElGamal diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/PublicKey/pubkey.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/PublicKey/pubkey.pyi index dd34d695aa34..cbaf5f39a2e0 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/PublicKey/pubkey.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/PublicKey/pubkey.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.PublicKey.pubkey (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from Crypto.Util.number import * # noqa: F403 __revision__ = ... # type: str diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Random/Fortuna/FortunaAccumulator.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Random/Fortuna/FortunaAccumulator.pyi index e8430709c279..bb898b204299 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Random/Fortuna/FortunaAccumulator.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Random/Fortuna/FortunaAccumulator.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Random.Fortuna.FortunaAccumulator (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any __revision__ = ... # type: str diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Random/Fortuna/FortunaGenerator.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Random/Fortuna/FortunaGenerator.pyi index 89d13abd7b5e..1d69094c53d8 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Random/Fortuna/FortunaGenerator.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Random/Fortuna/FortunaGenerator.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Random.Fortuna.FortunaGenerator (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any __revision__ = ... # type: str diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Random/Fortuna/SHAd256.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Random/Fortuna/SHAd256.pyi index 5a83fd9d5901..0dfb6916786a 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Random/Fortuna/SHAd256.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Random/Fortuna/SHAd256.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Random.Fortuna.SHAd256 (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional class _SHAd256: diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Random/Fortuna/__init__.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Random/Fortuna/__init__.pyi index fd03fb295e83..e69de29bb2d1 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Random/Fortuna/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Random/Fortuna/__init__.pyi @@ -1,3 +0,0 @@ -# Stubs for Crypto.Random.Fortuna (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Random/OSRNG/__init__.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Random/OSRNG/__init__.pyi index e73ed2e1cbc6..a9c47e6e633e 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Random/OSRNG/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Random/OSRNG/__init__.pyi @@ -1,5 +1 @@ -# Stubs for Crypto.Random.OSRNG (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - __revision__ = ... # type: str diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Random/OSRNG/fallback.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Random/OSRNG/fallback.pyi index fafc388528d3..d25d8590a3ef 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Random/OSRNG/fallback.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Random/OSRNG/fallback.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Random.OSRNG.fallback (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from .rng_base import BaseRNG class PythonOSURandomRNG(BaseRNG): diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Random/OSRNG/posix.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Random/OSRNG/posix.pyi index c7d4613a6fcd..0506ffab0d55 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Random/OSRNG/posix.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Random/OSRNG/posix.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Random.OSRNG.posix (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional from .rng_base import BaseRNG diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Random/OSRNG/rng_base.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Random/OSRNG/rng_base.pyi index 4fa634a92c9b..46ac79c9534b 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Random/OSRNG/rng_base.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Random/OSRNG/rng_base.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Random.OSRNG.rng_base (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - __revision__ = ... # type: str class BaseRNG: diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Random/__init__.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Random/__init__.pyi index d9872cb3be56..f30acfd3aae4 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Random/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Random/__init__.pyi @@ -1,5 +1 @@ -# Stubs for Crypto.Random (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - def new(*args, **kwargs): ... diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Random/random.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Random/random.pyi index 12a2e6fbbd64..4178db7f66f5 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Random/random.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Random/random.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Random.random (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional class StrongRandom: diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Signature/PKCS1_PSS.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Signature/PKCS1_PSS.pyi index 12edf26454dd..8341c2b4ec75 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Signature/PKCS1_PSS.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Signature/PKCS1_PSS.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Signature.PKCS1_PSS (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional class PSS_SigScheme: diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Signature/PKCS1_v1_5.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Signature/PKCS1_v1_5.pyi index d48d3a345b96..4a2b2253135a 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Signature/PKCS1_v1_5.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Signature/PKCS1_v1_5.pyi @@ -1,8 +1,3 @@ -# Stubs for Crypto.Signature.PKCS1_v1_5 (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - - class PKCS115_SigScheme: def __init__(self, key) -> None: ... def can_sign(self): ... diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Signature/__init__.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Signature/__init__.pyi index 710372a43fda..560f06fd9b56 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Signature/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Signature/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Signature (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - # Names in __all__ with no definition: # PKCS1_PSS # PKCS1_v1_5 diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Util/Counter.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Util/Counter.pyi index 620c1be5a73e..4aae7f269ff8 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Util/Counter.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Util/Counter.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Util.Counter (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any def new(nbits, prefix: Any = ..., suffix: Any = ..., initial_value: int = ..., overflow: int = ..., little_endian: bool = ..., allow_wraparound: bool = ..., disable_shortcut: bool = ...): ... diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Util/RFC1751.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Util/RFC1751.pyi index abd7444e5efb..273204b24bab 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Util/RFC1751.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Util/RFC1751.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Util.RFC1751 (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any __revision__ = ... # type: str diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Util/__init__.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Util/__init__.pyi index 26f6576ca07e..174729952f1d 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Util/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Util/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Util (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - # Names in __all__ with no definition: # RFC1751 # asn1 diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Util/asn1.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Util/asn1.pyi index b9227af167f6..036a3034fa21 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Util/asn1.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Util/asn1.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Util.asn1 (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional class DerObject: diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Util/number.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Util/number.pyi index 265f14265209..796e487eabc1 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Util/number.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Util/number.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Util.number (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional from warnings import warn as _warn diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Util/randpool.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Util/randpool.pyi index 4a5f2ac6325a..2b05706daa9a 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Util/randpool.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Util/randpool.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.Util.randpool (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional __revision__ = ... # type: str diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/Util/strxor.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/Util/strxor.pyi index 8ba57b53c496..cb6269bbb5e9 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/Util/strxor.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/Util/strxor.pyi @@ -1,6 +1,2 @@ -# Stubs for Crypto.Util.strxor (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - def strxor(*args, **kwargs): ... def strxor_c(*args, **kwargs): ... diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/__init__.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/__init__.pyi index 7b99b04148e3..6d8e1248dbe4 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - # Names in __all__ with no definition: # Cipher # Hash diff --git a/python/helpers/typeshed/third_party/2and3/Crypto/pct_warnings.pyi b/python/helpers/typeshed/third_party/2and3/Crypto/pct_warnings.pyi index 6fb4fc8555d1..b77e975b2b18 100644 --- a/python/helpers/typeshed/third_party/2and3/Crypto/pct_warnings.pyi +++ b/python/helpers/typeshed/third_party/2and3/Crypto/pct_warnings.pyi @@ -1,7 +1,3 @@ -# Stubs for Crypto.pct_warnings (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - class CryptoWarning(Warning): ... class CryptoDeprecationWarning(DeprecationWarning, CryptoWarning): ... class CryptoRuntimeWarning(RuntimeWarning, CryptoWarning): ... diff --git a/python/helpers/typeshed/third_party/2and3/atomicwrites/__init__.pyi b/python/helpers/typeshed/third_party/2and3/atomicwrites/__init__.pyi index 34d74fb8bde3..ba6ae22f0fb5 100644 --- a/python/helpers/typeshed/third_party/2and3/atomicwrites/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/atomicwrites/__init__.pyi @@ -1,16 +1,16 @@ -import contextlib import os import sys import tempfile -from typing import Any, AnyStr, Callable, IO, Iterator, Text +from typing import Any, AnyStr, Callable, ContextManager, IO, Iterator, Optional, Text + def replace_atomic(src: AnyStr, dst: AnyStr) -> None: ... def move_atomic(src: AnyStr, dst: AnyStr) -> None: ... class AtomicWriter(object): def __init__(self, path: AnyStr, mode: Text='w', overwrite: bool=False) -> None: ... - def open(self) -> contextlib.ContextManager[IO]: ... - def _open(self, get_fileobject: Callable) -> contextlib.ContextManager[IO]: ... - def get_fileobject(self, dir: AnyStr=None, **kwargs) -> IO: ... + def open(self) -> ContextManager[IO]: ... + def _open(self, get_fileobject: Callable) -> ContextManager[IO]: ... + def get_fileobject(self, dir: Optional[AnyStr] = None, **kwargs) -> IO: ... def sync(self, f: IO) -> None: ... def commit(self, f: IO) -> None: ... def rollback(self, f: IO) -> None: ... -def atomic_write(path: AnyStr, writer_cls: type=AtomicWriter, **cls_kwargs) -> contextlib.ContextManager[IO]: ... +def atomic_write(path: AnyStr, writer_cls: type=AtomicWriter, **cls_kwargs) -> ContextManager[IO]: ... diff --git a/python/helpers/typeshed/third_party/2and3/backports_abc.pyi b/python/helpers/typeshed/third_party/2and3/backports_abc.pyi index 1b4c3a2bb8f5..8deebc0ccb1c 100644 --- a/python/helpers/typeshed/third_party/2and3/backports_abc.pyi +++ b/python/helpers/typeshed/third_party/2and3/backports_abc.pyi @@ -1,7 +1,3 @@ -# Stubs for backports_abc (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any def mk_gen(): ... diff --git a/python/helpers/typeshed/third_party/2and3/boto/__init__.pyi b/python/helpers/typeshed/third_party/2and3/boto/__init__.pyi index a95c1df0f12c..d7b30c81c59b 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for boto (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional, Text import logging diff --git a/python/helpers/typeshed/third_party/2and3/boto/auth.pyi b/python/helpers/typeshed/third_party/2and3/boto/auth.pyi index 8fdf6ae021ca..57127ad02874 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/auth.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/auth.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.auth (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional from boto.auth_handler import AuthHandler diff --git a/python/helpers/typeshed/third_party/2and3/boto/auth_handler.pyi b/python/helpers/typeshed/third_party/2and3/boto/auth_handler.pyi index 097f762c993e..b9a0400a88af 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/auth_handler.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/auth_handler.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.auth_handler (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from boto.plugin import Plugin diff --git a/python/helpers/typeshed/third_party/2and3/boto/compat.pyi b/python/helpers/typeshed/third_party/2and3/boto/compat.pyi index 85539f88be9b..b0534a42476d 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/compat.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/compat.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.compat (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from base64 import encodestring as encodebytes diff --git a/python/helpers/typeshed/third_party/2and3/boto/connection.pyi b/python/helpers/typeshed/third_party/2and3/boto/connection.pyi index c8275b87a4cb..d8c40cbf804b 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/connection.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/connection.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.connection (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Dict, Optional, Text from six.moves import http_client diff --git a/python/helpers/typeshed/third_party/2and3/boto/ec2/__init__.pyi b/python/helpers/typeshed/third_party/2and3/boto/ec2/__init__.pyi index 64fa781f36e3..edb9359ec2f9 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/ec2/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/ec2/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.ec2 (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any RegionData = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2and3/boto/elb/__init__.pyi b/python/helpers/typeshed/third_party/2and3/boto/elb/__init__.pyi index 82e17fa1c17f..1d6c43ff3988 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/elb/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/elb/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.ec2.elb (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from boto.connection import AWSQueryConnection diff --git a/python/helpers/typeshed/third_party/2and3/boto/exception.pyi b/python/helpers/typeshed/third_party/2and3/boto/exception.pyi index 83778af0300d..bf11522b76cf 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/exception.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/exception.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.exception (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional from boto.compat import StandardError diff --git a/python/helpers/typeshed/third_party/2and3/boto/kms/__init__.pyi b/python/helpers/typeshed/third_party/2and3/boto/kms/__init__.pyi new file mode 100644 index 000000000000..0640e392fe58 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/boto/kms/__init__.pyi @@ -0,0 +1,5 @@ +from typing import List +import boto + +def regions() -> List[boto.regioninfo.RegionInfo]: ... +def connect_to_region(region_name, **kw_params): ... diff --git a/python/helpers/typeshed/third_party/2and3/boto/kms/exceptions.pyi b/python/helpers/typeshed/third_party/2and3/boto/kms/exceptions.pyi new file mode 100644 index 000000000000..5ac2ecd2061f --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/boto/kms/exceptions.pyi @@ -0,0 +1,17 @@ +from boto.exception import BotoServerError + +class InvalidGrantTokenException(BotoServerError): ... +class DisabledException(BotoServerError): ... +class LimitExceededException(BotoServerError): ... +class DependencyTimeoutException(BotoServerError): ... +class InvalidMarkerException(BotoServerError): ... +class AlreadyExistsException(BotoServerError): ... +class InvalidCiphertextException(BotoServerError): ... +class KeyUnavailableException(BotoServerError): ... +class InvalidAliasNameException(BotoServerError): ... +class UnsupportedOperationException(BotoServerError): ... +class InvalidArnException(BotoServerError): ... +class KMSInternalException(BotoServerError): ... +class InvalidKeyUsageException(BotoServerError): ... +class MalformedPolicyDocumentException(BotoServerError): ... +class NotFoundException(BotoServerError): ... diff --git a/python/helpers/typeshed/third_party/2and3/boto/kms/layer1.pyi b/python/helpers/typeshed/third_party/2and3/boto/kms/layer1.pyi new file mode 100644 index 000000000000..558b02a12ed4 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/boto/kms/layer1.pyi @@ -0,0 +1,37 @@ +from typing import Any, Dict, List, Mapping, Optional, Type +from boto.connection import AWSQueryConnection + +class KMSConnection(AWSQueryConnection): + APIVersion = ... # type: str + DefaultRegionName = ... # type: str + DefaultRegionEndpoint = ... # type: str + ServiceName = ... # type: str + TargetPrefix = ... # type: str + ResponseError = ... # type: Type[Exception] + region = ... # type: Any + def __init__(self, **kwargs) -> None: ... + def create_alias(self, alias_name: str, target_key_id: str) -> Optional[Dict[str, Any]]: ... + def create_grant(self, key_id: str, grantee_principal: str, retiring_principal: Optional[str] = ..., operations: Optional[List[str]] = ..., constraints: Optional[Dict[str, Dict[str, str]]] = ..., grant_tokens: Optional[List[str]] = ...) -> Optional[Dict[str, Any]]: ... + def create_key(self, policy: Optional[str] = ..., description: Optional[str] = ..., key_usage: Optional[str] = ...) -> Optional[Dict[str, Any]]: ... + def decrypt(self, ciphertext_blob: bytes, encryption_context: Optional[Mapping[str, Any]] = ..., grant_tokens: Optional[List[str]] = ...) -> Optional[Dict[str, Any]]: ... + def delete_alias(self, alias_name: str) -> Optional[Dict[str, Any]]: ... + def describe_key(self, key_id: str) -> Optional[Dict[str, Any]]: ... + def disable_key(self, key_id: str) -> Optional[Dict[str, Any]]: ... + def disable_key_rotation(self, key_id: str) -> Optional[Dict[str, Any]]: ... + def enable_key(self, key_id: str) -> Optional[Dict[str, Any]]: ... + def enable_key_rotation(self, key_id: str) -> Optional[Dict[str, Any]]: ... + def encrypt(self, key_id: str, plaintext: bytes, encryption_context: Optional[Mapping[str, Any]] = ..., grant_tokens: Optional[List[str]] = ...) -> Optional[Dict[str, Any]]: ... + def generate_data_key(self, key_id: str, encryption_context: Optional[Mapping[str, Any]] = ..., number_of_bytes: Optional[int] = ..., key_spec: Optional[str] = ..., grant_tokens: Optional[List[str]] = ...) -> Optional[Dict[str, Any]]: ... + def generate_data_key_without_plaintext(self, key_id: str, encryption_context: Optional[Mapping[str, Any]] = ..., key_spec: Optional[str] = ..., number_of_bytes: Optional[int] = ..., grant_tokens: Optional[List[str]] = ...) -> Optional[Dict[str, Any]]: ... + def generate_random(self, number_of_bytes: Optional[int] = ...) -> Optional[Dict[str, Any]]: ... + def get_key_policy(self, key_id: str, policy_name: str) -> Optional[Dict[str, Any]]: ... + def get_key_rotation_status(self, key_id: str) -> Optional[Dict[str, Any]]: ... + def list_aliases(self, limit: Optional[int] = ..., marker: Optional[str] = ...) -> Optional[Dict[str, Any]]: ... + def list_grants(self, key_id: str, limit: Optional[int] = ..., marker: Optional[str] = ...) -> Optional[Dict[str, Any]]: ... + def list_key_policies(self, key_id: str, limit: Optional[int] = ..., marker: Optional[str] = ...) -> Optional[Dict[str, Any]]: ... + def list_keys(self, limit: Optional[int] = ..., marker: Optional[str] = ...) -> Optional[Dict[str, Any]]: ... + def put_key_policy(self, key_id: str, policy_name: str, policy: str) -> Optional[Dict[str, Any]]: ... + def re_encrypt(self, ciphertext_blob: bytes, destination_key_id: str, source_encryption_context: Optional[Mapping[str, Any]] = ..., destination_encryption_context: Optional[Mapping[str, Any]] = ..., grant_tokens: Optional[List[str]] = ...) -> Optional[Dict[str, Any]]: ... + def retire_grant(self, grant_token: str) -> Optional[Dict[str, Any]]: ... + def revoke_grant(self, key_id: str, grant_id: str) -> Optional[Dict[str, Any]]: ... + def update_key_description(self, key_id: str, description: str) -> Optional[Dict[str, Any]]: ... diff --git a/python/helpers/typeshed/third_party/2and3/boto/plugin.pyi b/python/helpers/typeshed/third_party/2and3/boto/plugin.pyi index 37b972197e90..c40c6c4e435a 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/plugin.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/plugin.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.plugin (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional class Plugin: diff --git a/python/helpers/typeshed/third_party/2and3/boto/regioninfo.pyi b/python/helpers/typeshed/third_party/2and3/boto/regioninfo.pyi index 9dbb46f43538..37726096d024 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/regioninfo.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/regioninfo.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.regioninfo (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional def load_endpoint_json(path): ... diff --git a/python/helpers/typeshed/third_party/2and3/boto/s3/__init__.pyi b/python/helpers/typeshed/third_party/2and3/boto/s3/__init__.pyi index b359694a4e68..2dcb33341bbb 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/s3/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/s3/__init__.pyi @@ -1,6 +1,4 @@ -# Stubs for boto.s3 (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. +from typing import Optional from .connection import S3Connection @@ -10,7 +8,7 @@ from boto.regioninfo import RegionInfo from typing import List, Type, Text class S3RegionInfo(RegionInfo): - def connect(self, name: Text=None, endpoint: str=None, connection_cls: Type[AWSAuthConnection]=None, **kw_params) -> S3Connection: ... + def connect(self, name: Optional[Text] = None, endpoint: Optional[str] = None, connection_cls: Optional[Type[AWSAuthConnection]] = None, **kw_params) -> S3Connection: ... def regions() -> List[S3RegionInfo]: ... def connect_to_region(region_name: Text, **kw_params): ... diff --git a/python/helpers/typeshed/third_party/2and3/boto/s3/acl.pyi b/python/helpers/typeshed/third_party/2and3/boto/s3/acl.pyi index 8813009223dd..fccf21226ab1 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/s3/acl.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/s3/acl.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.s3.acl (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from .connection import S3Connection from .user import User from typing import Any, Dict, Optional, List, Text, Union 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 beb1d27cd17d..031c55aef929 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/s3/bucket.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/s3/bucket.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.s3.bucket (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from .bucketlistresultset import BucketListResultSet from .connection import S3Connection from .key import Key diff --git a/python/helpers/typeshed/third_party/2and3/boto/s3/bucketlistresultset.pyi b/python/helpers/typeshed/third_party/2and3/boto/s3/bucketlistresultset.pyi index 97e79b0fd153..e219faaa67fe 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/s3/bucketlistresultset.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/s3/bucketlistresultset.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.s3.bucketlistresultset (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from .bucket import Bucket from .key import Key diff --git a/python/helpers/typeshed/third_party/2and3/boto/s3/bucketlogging.pyi b/python/helpers/typeshed/third_party/2and3/boto/s3/bucketlogging.pyi index a3f83a58b820..5c53f2a933f5 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/s3/bucketlogging.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/s3/bucketlogging.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.s3.bucketlogging (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional class BucketLogging: diff --git a/python/helpers/typeshed/third_party/2and3/boto/s3/connection.pyi b/python/helpers/typeshed/third_party/2and3/boto/s3/connection.pyi index 73661f05797f..c84f20dc6e9c 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/s3/connection.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/s3/connection.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.s3.connection (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from .bucket import Bucket from typing import Any, Dict, Optional, Text, Type diff --git a/python/helpers/typeshed/third_party/2and3/boto/s3/cors.pyi b/python/helpers/typeshed/third_party/2and3/boto/s3/cors.pyi index 07f49b09cdeb..9ae263db840e 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/s3/cors.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/s3/cors.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.s3.cors (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional class CORSRule: diff --git a/python/helpers/typeshed/third_party/2and3/boto/s3/deletemarker.pyi b/python/helpers/typeshed/third_party/2and3/boto/s3/deletemarker.pyi index cf7bc64d597f..b2ad36a44fbe 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/s3/deletemarker.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/s3/deletemarker.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.s3.deletemarker (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional class DeleteMarker: diff --git a/python/helpers/typeshed/third_party/2and3/boto/s3/key.pyi b/python/helpers/typeshed/third_party/2and3/boto/s3/key.pyi index f7232b7811b6..ed44009b1812 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/s3/key.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/s3/key.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.s3.key (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Callable, Dict, Optional, Text class Key: diff --git a/python/helpers/typeshed/third_party/2and3/boto/s3/keyfile.pyi b/python/helpers/typeshed/third_party/2and3/boto/s3/keyfile.pyi index 2fe5faa835f5..447ab1667cd7 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/s3/keyfile.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/s3/keyfile.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.s3.keyfile (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class KeyFile: diff --git a/python/helpers/typeshed/third_party/2and3/boto/s3/lifecycle.pyi b/python/helpers/typeshed/third_party/2and3/boto/s3/lifecycle.pyi index c15048e96a99..18a7533e6d88 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/s3/lifecycle.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/s3/lifecycle.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.s3.lifecycle (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional class Rule: diff --git a/python/helpers/typeshed/third_party/2and3/boto/s3/multidelete.pyi b/python/helpers/typeshed/third_party/2and3/boto/s3/multidelete.pyi index 46449c44fee4..fa19cadd3e88 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/s3/multidelete.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/s3/multidelete.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.s3.multidelete (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional class Deleted: diff --git a/python/helpers/typeshed/third_party/2and3/boto/s3/multipart.pyi b/python/helpers/typeshed/third_party/2and3/boto/s3/multipart.pyi index 2bc738f3abc7..81a9452ca9cc 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/s3/multipart.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/s3/multipart.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.s3.multipart (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional class CompleteMultiPartUpload: diff --git a/python/helpers/typeshed/third_party/2and3/boto/s3/prefix.pyi b/python/helpers/typeshed/third_party/2and3/boto/s3/prefix.pyi index 12501b2f46ff..0d7b61a58f1b 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/s3/prefix.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/s3/prefix.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.s3.prefix (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional class Prefix: diff --git a/python/helpers/typeshed/third_party/2and3/boto/s3/tagging.pyi b/python/helpers/typeshed/third_party/2and3/boto/s3/tagging.pyi index 07c1fca46a73..4f4ad0496816 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/s3/tagging.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/s3/tagging.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.s3.tagging (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional class Tag: diff --git a/python/helpers/typeshed/third_party/2and3/boto/s3/user.pyi b/python/helpers/typeshed/third_party/2and3/boto/s3/user.pyi index 21832e9b1302..73d93428e76b 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/s3/user.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/s3/user.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.s3.user (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional class User: diff --git a/python/helpers/typeshed/third_party/2and3/boto/s3/website.pyi b/python/helpers/typeshed/third_party/2and3/boto/s3/website.pyi index f83207727ad2..b410b82d18e2 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/s3/website.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/s3/website.pyi @@ -1,7 +1,3 @@ -# Stubs for boto.s3.website (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional def tag(key, value): ... diff --git a/python/helpers/typeshed/third_party/2and3/click/README.md b/python/helpers/typeshed/third_party/2and3/click/README.md new file mode 100644 index 000000000000..d7410e3fc774 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/click/README.md @@ -0,0 +1,11 @@ +# click 6.6, Python 3 + +`__init__.pyi` is literally a copy of click/__init__.py. It's a shortcut module +anyway in the actual sources so it works well without additional changes. + +The types are pretty complete but they were created mostly for public API use +so some internal modules (`_compat`) or functions (`core._bashcomplete`) are +deliberately missing. If you feel the need to add those, pull requests accepted. + +Speaking of pull requests, it would be great if the option decorators informed +the type checker on what types the command callback should accept. diff --git a/python/helpers/typeshed/third_party/2and3/click/__init__.pyi b/python/helpers/typeshed/third_party/2and3/click/__init__.pyi new file mode 100644 index 000000000000..2ac61bef4dc5 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/click/__init__.pyi @@ -0,0 +1,156 @@ +# -*- coding: utf-8 -*- +""" + click + ~~~~~ + + Click is a simple Python module that wraps the stdlib's optparse to make + writing command line scripts fun. Unlike other modules, it's based around + a simple API that does not come with too much magic and is composable. + + In case optparse ever gets removed from the stdlib, it will be shipped by + this module. + + :copyright: (c) 2014 by Armin Ronacher. + :license: BSD, see LICENSE for more details. +""" + +# Core classes +from .core import ( + Context as Context, + BaseCommand as BaseCommand, + Command as Command, + MultiCommand as MultiCommand, + Group as Group, + CommandCollection as CommandCollection, + Parameter as Parameter, + Option as Option, + Argument as Argument, +) + +# Globals +from .globals import get_current_context as get_current_context + +# Decorators +from .decorators import ( + pass_context as pass_context, + pass_obj as pass_obj, + make_pass_decorator as make_pass_decorator, + command as command, + group as group, + argument as argument, + option as option, + confirmation_option as confirmation_option, + password_option as password_option, + version_option as version_option, + help_option as help_option, +) + +# Types +from .types import ( + ParamType as ParamType, + File as File, + Path as Path, + Choice as Choice, + IntRange as IntRange, + Tuple as Tuple, + STRING as STRING, + INT as INT, + FLOAT as FLOAT, + BOOL as BOOL, + UUID as UUID, + UNPROCESSED as UNPROCESSED, +) + +# Utilities +from .utils import ( + echo as echo, + get_binary_stream as get_binary_stream, + get_text_stream as get_text_stream, + open_file as open_file, + format_filename as format_filename, + get_app_dir as get_app_dir, + get_os_args as get_os_args, +) + +# Terminal functions +from .termui import ( + prompt as prompt, + confirm as confirm, + get_terminal_size as get_terminal_size, + echo_via_pager as echo_via_pager, + progressbar as progressbar, + clear as clear, + style as style, + unstyle as unstyle, + secho as secho, + edit as edit, + launch as launch, + getchar as getchar, + pause as pause, +) + +# Exceptions +from .exceptions import ( + ClickException as ClickException, + UsageError as UsageError, + BadParameter as BadParameter, + FileError as FileError, + Abort as Abort, + NoSuchOption as NoSuchOption, + BadOptionUsage as BadOptionUsage, + BadArgumentUsage as BadArgumentUsage, + MissingParameter as MissingParameter, +) + +# Formatting +from .formatting import HelpFormatter as HelpFormatter, wrap_text as wrap_text + +# Parsing +from .parser import OptionParser as OptionParser + + +__all__ = [ + # Core classes + 'Context', 'BaseCommand', 'Command', 'MultiCommand', 'Group', + 'CommandCollection', 'Parameter', 'Option', 'Argument', + + # Globals + 'get_current_context', + + # Decorators + 'pass_context', 'pass_obj', 'make_pass_decorator', 'command', 'group', + 'argument', 'option', 'confirmation_option', 'password_option', + 'version_option', 'help_option', + + # Types + 'ParamType', 'File', 'Path', 'Choice', 'IntRange', 'Tuple', 'STRING', + 'INT', 'FLOAT', 'BOOL', 'UUID', 'UNPROCESSED', + + # Utilities + 'echo', 'get_binary_stream', 'get_text_stream', 'open_file', + 'format_filename', 'get_app_dir', 'get_os_args', + + # Terminal functions + 'prompt', 'confirm', 'get_terminal_size', 'echo_via_pager', + 'progressbar', 'clear', 'style', 'unstyle', 'secho', 'edit', 'launch', + 'getchar', 'pause', + + # Exceptions + 'ClickException', 'UsageError', 'BadParameter', 'FileError', + 'Abort', 'NoSuchOption', 'BadOptionUsage', 'BadArgumentUsage', + 'MissingParameter', + + # Formatting + 'HelpFormatter', 'wrap_text', + + # Parsing + 'OptionParser', +] + + +# Controls if click should emit the warning about the use of unicode +# literals. +disable_unicode_literals_warning = False + + +__version__ = '6.6' diff --git a/python/helpers/typeshed/third_party/2and3/click/core.pyi b/python/helpers/typeshed/third_party/2and3/click/core.pyi new file mode 100644 index 000000000000..c0e054dbea7d --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/click/core.pyi @@ -0,0 +1,435 @@ +from contextlib import contextmanager +from typing import ( + Any, + Callable, + Dict, + Generator, + Iterable, + List, + Mapping, + Optional, + Sequence, + Set, + Tuple, + TypeVar, + Union, +) + +from click.formatting import HelpFormatter +from click.parser import OptionParser + + +def invoke_param_callback( + callback: Callable[['Context', 'Parameter', Optional[str]], Any], + ctx: 'Context', + param: 'Parameter', + value: Optional[str] +) -> Any: + ... + + +@contextmanager +def augment_usage_errors( + ctx: 'Context', param: Optional['Parameter'] = None +) -> Generator[None, None, None]: + ... + + +def iter_params_for_processing( + invocation_order: Sequence['Parameter'], + declaration_order: Iterable['Parameter'], +) -> Iterable['Parameter']: + ... + + +class Context: + parent: Optional['Context'] + command: 'Command' + info_name: Optional[str] + params: Dict + args: List[str] + protected_args: List[str] + obj: Any + default_map: Mapping[str, Any] + invoked_subcommand: Optional[str] + terminal_width: Optional[int] + max_content_width: Optional[int] + allow_extra_args: bool + allow_interspersed_args: bool + ignore_unknown_options: bool + help_option_names: List[str] + token_normalize_func: Optional[Callable[[str], str]] + resilient_parsing: bool + auto_envvar_prefix: Optional[str] + color: Optional[bool] + _meta: Dict[str, Any] + _close_callbacks: List + _depth: int + + # properties + meta: Dict[str, Any] + command_path: str + + def __init__( + self, + command: 'Command', + parent: Optional['Context'] = None, + info_name: Optional[str] = None, + obj: Optional[Any] = None, + auto_envvar_prefix: Optional[str] = None, + default_map: Optional[Mapping[str, Any]] = None, + terminal_width: Optional[int] = None, + max_content_width: Optional[int] = None, + resilient_parsing: bool = False, + allow_extra_args: Optional[bool] = None, + allow_interspersed_args: Optional[bool] = None, + ignore_unknown_options: Optional[bool] = None, + help_option_names: Optional[List[str]] = None, + token_normalize_func: Optional[Callable[[str], str]] = None, + color: Optional[bool] = None + ) -> None: + ... + + @contextmanager + def scope(self, cleanup: bool = True) -> Generator['Context', None, None]: + ... + + def make_formatter(self) -> HelpFormatter: + ... + + def call_on_close(self, f: Callable) -> Callable: + ... + + def close(self) -> None: + ... + + def find_root(self) -> 'Context': + ... + + def find_object(self, object_type: type) -> Any: + ... + + def ensure_object(self, object_type: type) -> Any: + ... + + def lookup_default(self, name: str) -> Any: + ... + + def fail(self, message: str) -> None: + ... + + def abort(self) -> None: + ... + + def exit(self, code: Union[int, str] = 0) -> None: + ... + + def get_usage(self) -> str: + ... + + def get_help(self) -> str: + ... + + def invoke( + self, callback: Union['Command', Callable], *args, **kwargs + ) -> Any: + ... + + def forward( + self, callback: Union['Command', Callable], *args, **kwargs + ) -> Any: + ... + +class BaseCommand: + allow_extra_args: bool + allow_interspersed_args: bool + ignore_unknown_options: bool + name: str + context_settings: Dict + + def __init__(self, name: str, context_settings: Optional[Dict] = None) -> None: + ... + + def get_usage(self, ctx: Context) -> str: + ... + + def get_help(self, ctx: Context) -> str: + ... + + def make_context( + self, info_name: str, args: List[str], parent: Optional[Context] = None, **extra + ) -> Context: + ... + + def parse_args(self, ctx: Context, args: List[str]) -> List[str]: + ... + + def invoke(self, ctx: Context) -> Any: + ... + + def main( + self, + args: Optional[List[str]] = None, + prog_name: Optional[str] = None, + complete_var: Optional[str] = None, + standalone_mode: bool = True, + **extra + ) -> Any: + ... + + def __call__(self, *args, **kwargs) -> Any: + ... + + +class Command(BaseCommand): + callback: Optional[Callable] + params: List['Parameter'] + help: Optional[str] + epilog: Optional[str] + short_help: Optional[str] + options_metavar: str + add_help_option: bool + + def __init__( + self, + name: str, + context_settings: Optional[Dict] = None, + callback: Optional[Callable] = None, + params: Optional[List['Parameter']] = None, + help: Optional[str] = None, + epilog: Optional[str] = None, + short_help: Optional[str] = None, + options_metavar: str = '[OPTIONS]', + add_help_option: bool = True + ) -> None: + ... + + def get_params(self, ctx: Context) -> List['Parameter']: + ... + + def format_usage( + self, + ctx: Context, + formatter: HelpFormatter + ) -> None: + ... + + def collect_usage_pieces(self, ctx: Context) -> List[str]: + ... + + def get_help_option_names(self, ctx: Context) -> Set[str]: + ... + + def get_help_option(self, ctx: Context) -> Optional['Option']: + ... + + def make_parser(self, ctx: Context) -> OptionParser: + ... + + def format_help(self, ctx: Context, formatter: HelpFormatter) -> None: + ... + + def format_help_text(self, ctx: Context, formatter: HelpFormatter) -> None: + ... + + def format_options(self, ctx: Context, formatter: HelpFormatter) -> None: + ... + + def format_epilog(self, ctx: Context, formatter: HelpFormatter) -> None: + ... + + +_T = TypeVar('_T') +_Decorator = Callable[[_T], _T] + + +class MultiCommand(Command): + no_args_is_help: bool + invoke_without_command: bool + subcommand_metavar: str + chain: bool + result_callback: Callable + + def __init__( + self, + name: Optional[str] = None, + invoke_without_command: bool = False, + no_args_is_help: Optional[bool] = None, + subcommand_metavar: Optional[str] = None, + chain: bool = False, + result_callback: Optional[Callable] = None, + **attrs + ) -> None: + ... + + def resultcallback( + self, replace: bool = False + ) -> _Decorator: + ... + + def format_commands(self, ctx: Context, formatter: HelpFormatter) -> None: + ... + + def resolve_command( + self, ctx: Context, args: List[str] + ) -> Tuple[str, Command, List[str]]: + ... + + def get_command(self, ctx: Context, cmd_name: str) -> Optional[Command]: + ... + + def list_commands(self, ctx: Context) -> Iterable[Command]: + ... + + +class Group(MultiCommand): + commands: Dict[str, Command] + + def __init__( + self, name: Optional[str] = None, commands: Optional[Dict[str, Command]] = None, **attrs + ) -> None: + ... + + def add_command(self, cmd: Command, name: Optional[str] = None): + ... + + def command(self, *args, **kwargs) -> _Decorator: + ... + + def group(self, *args, **kwargs) -> _Decorator: + ... + + +class CommandCollection(MultiCommand): + sources: List[MultiCommand] + + def __init__( + self, name: Optional[str] = None, sources: Optional[List[MultiCommand]] = None, **attrs + ) -> None: + ... + + def add_source(self, multi_cmd: MultiCommand) -> None: + ... + + +class Parameter: + param_type_name: str + name: str + opts: List[str] + secondary_opts: List[str] + type: 'ParamType' + required: bool + callback: Optional[Callable[[Context, 'Parameter', str], Any]] + nargs: int + multiple: bool + expose_value: bool + default: Any + is_eager: bool + metavar: Optional[str] + envvar: Union[str, List[str], None] + # properties + human_readable_name: str + + def __init__( + self, + param_decls: Optional[List[str]] = None, + type: Optional[Union[type, 'ParamType']] = None, + required: bool = False, + default: Optional[Any] = None, + callback: Optional[Callable[[Context, 'Parameter', str], Any]] = None, + nargs: Optional[int] = None, + metavar: Optional[str] = None, + expose_value: bool = True, + is_eager: bool = False, + envvar: Optional[Union[str, List[str]]] = None + ) -> None: + ... + + def make_metavar(self) -> str: + ... + + def get_default(self, ctx: Context) -> Any: + ... + + def add_to_parser(self, parser: OptionParser, ctx: Context) -> None: + ... + + def consume_value(self, ctx: Context, opts: Dict[str, Any]) -> Any: + ... + + def type_cast_value(self, ctx: Context, value: Any) -> Any: + ... + + def process_value(self, ctx: Context, value: Any) -> Any: + ... + + def value_is_missing(self, value: Any) -> bool: + ... + + def full_process_value(self, ctx: Context, value: Any) -> Any: + ... + + def resolve_envvar_value(self, ctx: Context) -> str: + ... + + def value_from_envvar(self, ctx: Context) -> Union[str, List[str]]: + ... + + def handle_parse_result( + self, ctx: Context, opts: Dict[str, Any], args: List[str] + ) -> Tuple[Any, List[str]]: + ... + + def get_help_record(self, ctx: Context) -> Tuple[str, str]: + ... + + def get_usage_pieces(self, ctx: Context) -> List[str]: + ... + + +class Option(Parameter): + prompt: str # sic + confirmation_prompt: bool + hide_input: bool + is_flag: bool + flag_value: Any + is_bool_flag: bool + count: bool + multiple: bool + allow_from_autoenv: bool + help: Optional[str] + show_default: bool + + def __init__( + self, + param_decls: Optional[List[str]] = None, + show_default: bool = False, + prompt: Union[bool, str] = False, + confirmation_prompt: bool = False, + hide_input: bool = False, + is_flag: Optional[bool] = None, + flag_value: Optional[Any] = None, + multiple: bool = False, + count: bool = False, + allow_from_autoenv: bool = True, + type: Optional[Union[type, 'ParamType']] = None, + help: Optional[str] = None, + **attrs + ) -> None: + ... + + def prompt_for_value(self, ctx: Context) -> Any: + ... + + +class Argument(Parameter): + def __init__( + self, + param_decls: Optional[List[str]] = None, + required: Optional[bool] = None, + **attrs + ) -> None: + ... + +# cyclic dependency +from click.types import ParamType # noqa: E402 diff --git a/python/helpers/typeshed/third_party/2and3/click/decorators.pyi b/python/helpers/typeshed/third_party/2and3/click/decorators.pyi new file mode 100644 index 000000000000..b9d6faf40e79 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/click/decorators.pyi @@ -0,0 +1,228 @@ +from distutils.version import Version +from typing import Any, Callable, Dict, List, Optional, TypeVar, Union + +from click.core import Command, Group, Argument, Option, Parameter, Context +from click.types import ParamType + +_T = TypeVar('_T') +_Decorator = Callable[[_T], _T] + +_Callback = Callable[ + [Context, Union[Option, Parameter], Union[bool, int, str]], + Any +] + +def pass_context(_T) -> _T: + ... + + +def pass_obj(_T) -> _T: + ... + + +def make_pass_decorator( + object_type: type, ensure: bool = False +) -> Callable[[_T], _T]: + ... + + +# NOTE: Decorators below have **attrs converted to concrete constructor +# arguments from core.pyi to help with type checking. + +def command( + name: Optional[str] = None, + cls: type = Command, + # Command + context_settings: Optional[Dict] = ..., + help: Optional[str] = None, + epilog: Optional[str] = None, + short_help: Optional[str] = None, + options_metavar: str = '[OPTIONS]', + add_help_option: bool = True, +) -> _Decorator: + ... + + +# This inherits attrs from Group, MultiCommand and Command. + +def group( + name: Optional[str] = None, + cls: type = Group, + # Group + commands: Optional[Dict[str, Command]] = None, + # MultiCommand + invoke_without_command: bool = False, + no_args_is_help: Optional[bool] = None, + subcommand_metavar: Optional[str] = None, + chain: bool = False, + result_callback: Optional[Callable] = None, + # Command + help: Optional[str] = None, + epilog: Optional[str] = None, + short_help: Optional[str] = None, + options_metavar: str = '[OPTIONS]', + add_help_option: bool = True, + # User-defined + **kwargs: Any, +) -> _Decorator: + ... + + +def argument( + *param_decls: str, + cls: type = Argument, + # Argument + required: Optional[bool] = None, + # Parameter + type: Optional[Union[type, ParamType]] = None, + default: Optional[Any] = None, + callback: Optional[_Callback] = ..., + nargs: Optional[int] = None, + metavar: Optional[str] = None, + expose_value: bool = True, + is_eager: bool = False, + envvar: Optional[Union[str, List[str]]] = None +) -> _Decorator: + ... + + +def option( + *param_decls: str, + cls: type = Option, + # Option + show_default: bool = False, + prompt: bool = False, + confirmation_prompt: bool = False, + hide_input: bool = False, + is_flag: Optional[bool] = None, + flag_value: Optional[Any] = None, + multiple: bool = False, + count: bool = False, + allow_from_autoenv: bool = True, + type: Optional[Union[type, ParamType]] = None, + help: Optional[str] = None, + # Parameter + default: Optional[Any] = None, + required: bool = False, + callback: Optional[_Callback] = ..., + nargs: Optional[int] = None, + metavar: Optional[str] = None, + expose_value: bool = True, + is_eager: bool = False, + envvar: Optional[Union[str, List[str]]] = None +) -> _Decorator: + ... + + +# Defaults copied from the decorator body. +def confirmation_option( + *param_decls: str, + cls: type = Option, + # Option + show_default: bool = False, + prompt: str = 'Do you want to continue?', + confirmation_prompt: bool = False, + hide_input: bool = False, + is_flag: bool = True, + flag_value: Optional[Any] = None, + multiple: bool = False, + count: bool = False, + allow_from_autoenv: bool = True, + type: Optional[Union[type, ParamType]] = None, + help: str = 'Confirm the action without prompting.', + # Parameter + default: Optional[Any] = None, + callback: Optional[_Callback] = ..., + nargs: Optional[int] = None, + metavar: Optional[str] = None, + expose_value: bool = False, + is_eager: bool = False, + envvar: Optional[Union[str, List[str]]] = None +) -> _Decorator: + ... + + +# Defaults copied from the decorator body. +def password_option( + *param_decls: str, + cls: type = Option, + # Option + show_default: bool = False, + prompt: bool = True, + confirmation_prompt: bool = True, + hide_input: bool = True, + is_flag: Optional[bool] = None, + flag_value: Optional[Any] = None, + multiple: bool = False, + count: bool = False, + allow_from_autoenv: bool = True, + type: Optional[Union[type, ParamType]] = None, + help: Optional[str] = None, + # Parameter + default: Optional[Any] = None, + callback: Optional[_Callback] = ..., + nargs: Optional[int] = None, + metavar: Optional[str] = None, + expose_value: bool = True, + is_eager: bool = False, + envvar: Optional[Union[str, List[str]]] = None +) -> _Decorator: + ... + + +# Defaults copied from the decorator body. +def version_option( + version: Optional[Union[str, Version]] = None, + *param_decls: str, + cls: type = Option, + # Option + prog_name: Optional[str] = None, + show_default: bool = False, + prompt: bool = False, + confirmation_prompt: bool = False, + hide_input: bool = False, + is_flag: bool = True, + flag_value: Optional[Any] = None, + multiple: bool = False, + count: bool = False, + allow_from_autoenv: bool = True, + type: Optional[Union[type, ParamType]] = None, + help: str = 'Show the version and exit.', + # Parameter + default: Optional[Any] = None, + callback: Optional[_Callback] = ..., + nargs: Optional[int] = None, + metavar: Optional[str] = None, + expose_value: bool = False, + is_eager: bool = True, + envvar: Optional[Union[str, List[str]]] = None +) -> _Decorator: + ... + + +# Defaults copied from the decorator body. +def help_option( + *param_decls: str, + cls: type = Option, + # Option + show_default: bool = False, + prompt: bool = False, + confirmation_prompt: bool = False, + hide_input: bool = False, + is_flag: bool = True, + flag_value: Optional[Any] = None, + multiple: bool = False, + count: bool = False, + allow_from_autoenv: bool = True, + type: Optional[Union[type, ParamType]] = None, + help: str = 'Show this message and exit.', + # Parameter + default: Optional[Any] = None, + callback: Optional[_Callback] = ..., + nargs: Optional[int] = None, + metavar: Optional[str] = None, + expose_value: bool = False, + is_eager: bool = True, + envvar: Optional[Union[str, List[str]]] = None +) -> _Decorator: + ... diff --git a/python/helpers/typeshed/third_party/2and3/click/exceptions.pyi b/python/helpers/typeshed/third_party/2and3/click/exceptions.pyi new file mode 100644 index 000000000000..351762411cef --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/click/exceptions.pyi @@ -0,0 +1,91 @@ +from typing import IO, List, Optional + +from click.core import Context, Parameter + + +class ClickException(Exception): + exit_code: int + message: str + + def __init__(self, message: str) -> None: + ... + + def format_message(self) -> str: + ... + + def show(self, file=None) -> None: + ... + + +class UsageError(ClickException): + ctx: Optional[Context] + + def __init__(self, message: str, ctx: Optional[Context] = None) -> None: + ... + + def show(self, file: Optional[IO] = None) -> None: + ... + + +class BadParameter(UsageError): + param: Optional[Parameter] + param_hint: Optional[str] + + def __init__( + self, + message: str, + ctx: Optional[Context] = None, + param: Optional[Parameter] = None, + param_hint: Optional[str] = None + ) -> None: + ... + + +class MissingParameter(BadParameter): + param_type: str # valid values: 'parameter', 'option', 'argument' + + def __init__( + self, + message: Optional[str] = None, + ctx: Optional[Context] = None, + param: Optional[Parameter] = None, + param_hint: Optional[str] = None, + param_type: Optional[str] = None + ) -> None: + ... + + +class NoSuchOption(UsageError): + option_name: str + possibilities: Optional[List[str]] + + def __init__( + self, + option_name: str, + message: Optional[str] = None, + possibilities: Optional[List[str]] = None, + ctx: Optional[Context] = None + ) -> None: + ... + + +class BadOptionUsage(UsageError): + def __init__(self, message: str, ctx: Optional[Context] = None) -> None: + ... + + +class BadArgumentUsage(UsageError): + def __init__(self, message: str, ctx: Optional[Context] = None) -> None: + ... + + +class FileError(ClickException): + ui_filename: str + filename: str + + def __init__(self, filename: str, hint: Optional[str] = None) -> None: + ... + + +class Abort(RuntimeError): + ... diff --git a/python/helpers/typeshed/third_party/2and3/click/formatting.pyi b/python/helpers/typeshed/third_party/2and3/click/formatting.pyi new file mode 100644 index 000000000000..52b81ce0229a --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/click/formatting.pyi @@ -0,0 +1,89 @@ +from contextlib import contextmanager +from typing import Generator, Iterable, List, Optional, Tuple + + +FORCED_WIDTH: Optional[int] + + +def measure_table(rows: Iterable[Iterable[str]]) -> Tuple[int, ...]: + ... + + +def iter_rows( + rows: Iterable[Iterable[str]], col_count: int +) -> Generator[Tuple[str, ...], None, None]: + ... + + +def wrap_text( + text: str, + width: int = 78, + initial_indent: str = '', + subsequent_indent: str = '', + preserve_paragraphs: bool = False +) -> str: + ... + + +class HelpFormatter: + indent_increment: int + width: Optional[int] + current_indent: int + buffer: List[str] + + def __init__( + self, + indent_increment: int = 2, + width: Optional[int] = None, + max_width: Optional[int] = None, + ) -> None: + ... + + def write(self, string: str) -> None: + ... + + def indent(self) -> None: + ... + + def dedent(self) -> None: + ... + + def write_usage( + self, + prog: str, + args: str = '', + prefix: str = 'Usage: ', + ): + ... + + def write_heading(self, heading: str) -> None: + ... + + def write_paragraph(self) -> None: + ... + + def write_text(self, text: str) -> None: + ... + + def write_dl( + self, + rows: Iterable[Iterable[str]], + col_max: int = 30, + col_spacing: int = 2, + ) -> None: + ... + + @contextmanager + def section(self, name) -> Generator[None, None, None]: + ... + + @contextmanager + def indentation(self) -> Generator[None, None, None]: + ... + + def getvalue(self) -> str: + ... + + +def join_options(options: List[str]) -> Tuple[str, bool]: + ... diff --git a/python/helpers/typeshed/third_party/2and3/click/globals.pyi b/python/helpers/typeshed/third_party/2and3/click/globals.pyi new file mode 100644 index 000000000000..816d393d8f2f --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/click/globals.pyi @@ -0,0 +1,18 @@ +from click.core import Context +from typing import Optional + + +def get_current_context(silent: bool = False) -> Context: + ... + + +def push_context(ctx: Context) -> None: + ... + + +def pop_context() -> None: + ... + + +def resolve_color_default(color: Optional[bool] = None) -> Optional[bool]: + ... diff --git a/python/helpers/typeshed/third_party/2and3/click/parser.pyi b/python/helpers/typeshed/third_party/2and3/click/parser.pyi new file mode 100644 index 000000000000..21833d66a704 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/click/parser.pyi @@ -0,0 +1,102 @@ +from typing import Any, Dict, Iterable, List, Optional, Set, Tuple + +from click.core import Context + + +def _unpack_args( + args: Iterable[str], nargs_spec: Iterable[int] +) -> Tuple[Tuple[Optional[Tuple[str, ...]], ...], List[str]]: + ... + + +def split_opt(opt: str) -> Tuple[str, str]: + ... + + +def normalize_opt(opt: str, ctx: Context) -> str: + ... + + +def split_arg_string(string: str) -> List[str]: + ... + + +class Option: + dest: str + action: str + nargs: int + const: Any + obj: Any + prefixes: Set[str] + _short_opts: List[str] + _long_opts: List[str] + # properties + takes_value: bool + + def __init__( + self, + opts: Iterable[str], + dest: str, + action: Optional[str] = None, + nargs: int = 1, + const: Optional[Any] = None, + obj: Optional[Any] = None + ) -> None: + ... + + def process(self, value: Any, state: 'ParsingState') -> None: + ... + + +class Argument: + dest: str + nargs: int + obj: Any + + def __init__(self, dest: str, nargs: int = 1, obj: Optional[Any] = None) -> None: + ... + + def process(self, value: Any, state: 'ParsingState') -> None: + ... + + +class ParsingState: + opts: Dict[str, Any] + largs: List[str] + rargs: List[str] + order: List[Any] + + def __init__(self, rargs: List[str]) -> None: + ... + + +class OptionParser: + ctx: Optional[Context] + allow_interspersed_args: bool + ignore_unknown_options: bool + _short_opt: Dict[str, Option] + _long_opt: Dict[str, Option] + _opt_prefixes: Set[str] + _args: List[Argument] + + def __init__(self, ctx: Optional[Context] = None) -> None: + ... + + def add_option( + self, + opts: Iterable[str], + dest: str, + action: Optional[str] = None, + nargs: int = 1, + const: Optional[Any] = None, + obj: Optional[Any] = None + ) -> None: + ... + + def add_argument(self, dest: str, nargs: int = 1, obj: Optional[Any] = None) -> None: + ... + + def parse_args( + self, args: List[str] + ) -> Tuple[Dict[str, Any], List[str], List[Any]]: + ... diff --git a/python/helpers/typeshed/third_party/2and3/click/termui.pyi b/python/helpers/typeshed/third_party/2and3/click/termui.pyi new file mode 100644 index 000000000000..bffb3fa44296 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/click/termui.pyi @@ -0,0 +1,147 @@ +from contextlib import contextmanager +from typing import ( + Any, + Callable, + Generator, + Iterable, + IO, + List, + Optional, + Tuple, + TypeVar, +) + + +def hidden_prompt_func(prompt: str) -> str: + ... + + +def _build_prompt( + text: str, + suffix: str, + show_default: bool = False, + default: Optional[str] = None, +) -> str: + ... + + +def prompt( + text: str, + default: Optional[str] = None, + hide_input: bool = False, + confirmation_prompt: bool = False, + type: Optional[Any] = None, + value_proc: Optional[Callable[[Optional[str]], Any]] = None, + prompt_suffix: str = ': ', + show_default: bool = True, + err: bool = False, +) -> Any: + ... + + +def confirm( + text: str, + default: bool = False, + abort: bool = False, + prompt_suffix: str = ': ', + show_default: bool = True, + err: bool = False, +) -> bool: + ... + + +def get_terminal_size() -> Tuple[int, int]: + ... + + +def echo_via_pager(text: str, color: Optional[bool] = None) -> None: + ... + + +_T = TypeVar('_T') + + +@contextmanager +def progressbar( + iterable: Optional[Iterable[_T]] = None, + length: Optional[int] = None, + label: Optional[str] = None, + show_eta: bool = True, + show_percent: Optional[bool] = None, + show_pos: bool = False, + item_show_func: Optional[Callable[[_T], str]] = None, + fill_char: str = '#', + empty_char: str = '-', + bar_template: str = '%(label)s [%(bar)s] %(info)s', + info_sep: str = ' ', + width: int = 36, + file: Optional[IO] = None, + color: Optional[bool] = None, +) -> Generator[_T, None, None]: + ... + + +def clear() -> None: + ... + + +def style( + text: str, + fg: Optional[str] = None, + bg: Optional[str] = None, + bold: Optional[bool] = None, + dim: Optional[bool] = None, + underline: Optional[bool] = None, + blink: Optional[bool] = None, + reverse: Optional[bool] = None, + reset: bool = True, +): + ... + + +def unstyle(text: str) -> str: + ... + + +# Styling options copied from style() for nicer type checking. +def secho( + text: str, + file: Optional[IO] = None, + nl: bool =True, + err: bool = False, + color: Optional[bool] = None, + fg: Optional[str] = None, + bg: Optional[str] = None, + bold: Optional[bool] = None, + dim: Optional[bool] = None, + underline: Optional[bool] = None, + blink: Optional[bool] = None, + reverse: Optional[bool] = None, + reset: bool = True, +): + ... + + +def edit( + text: Optional[str] = None, + editor: Optional[str] = None, + env: Optional[str] = None, + require_save: bool = True, + extension: str = '.txt', + filename: Optional[str] = None, +) -> str: + ... + + +def launch(url: str, wait: bool = False, locate: bool = False) -> int: + ... + + +def getchar(echo: bool = False) -> str: + ... + + +def pause( + info: str ='Press any key to continue ...', err: bool = False +) -> None: + ... diff --git a/python/helpers/typeshed/third_party/2and3/click/types.pyi b/python/helpers/typeshed/third_party/2and3/click/types.pyi new file mode 100644 index 000000000000..7b6431e31661 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/click/types.pyi @@ -0,0 +1,283 @@ +from typing import Any, Callable, IO, Iterable, List, Optional, TypeVar, Union +import uuid + +from click.core import Context, Parameter + + +class ParamType: + name: str + is_composite: bool + envvar_list_splitter: Optional[str] + + def __call__( + self, + value: Optional[str], + param: Optional[Parameter] = None, + ctx: Optional[Context] = None, + ) -> Any: + ... + + def get_metavar(self, param: Parameter) -> str: + ... + + def get_missing_message(self, param: Parameter) -> str: + ... + + def convert( + self, + value: str, + param: Optional[Parameter], + ctx: Optional[Context], + ) -> Any: + ... + + def split_envvar_value(self, rv: str) -> List[str]: + ... + + def fail(self, message: str, param: Optional[Parameter] = None, ctx: Optional[Context] = None) -> None: + ... + + +class BoolParamType(ParamType): + def __call__( + self, + value: Optional[str], + param: Optional[Parameter] = None, + ctx: Optional[Context] = None, + ) -> bool: + ... + + def convert( + self, + value: str, + param: Optional[Parameter], + ctx: Optional[Context], + ) -> bool: + ... + + +class CompositeParamType(ParamType): + arity: int + + +class Choice(ParamType): + choices: Iterable[str] + def __init__(self, choices: Iterable[str]) -> None: + ... + + +class FloatParamType(ParamType): + def __call__( + self, + value: Optional[str], + param: Optional[Parameter] = None, + ctx: Optional[Context] = None, + ) -> float: + ... + + def convert( + self, + value: str, + param: Optional[Parameter], + ctx: Optional[Context], + ) -> float: + ... + + +class FloatRange(FloatParamType): + ... + + +class File(ParamType): + def __init__( + self, + mode: str = 'r', + encoding: Optional[str] = None, + errors: Optional[str] = None, + lazy: Optional[bool] = None, + atomic: Optional[bool] = None, + ) -> None: + ... + + def __call__( + self, + value: Optional[str], + param: Optional[Parameter] = None, + ctx: Optional[Context] = None, + ) -> IO: + ... + + def convert( + self, + value: str, + param: Optional[Parameter], + ctx: Optional[Context], + ) -> IO: + ... + + def resolve_lazy_flag(self, value: str) -> bool: + ... + + +_F = TypeVar('_F') # result of the function +_Func = Callable[[Optional[str]], _F] + + +class FuncParamType(ParamType): + func: _Func + + def __init__(self, func: _Func) -> None: + ... + + def __call__( + self, + value: Optional[str], + param: Optional[Parameter] = None, + ctx: Optional[Context] = None, + ) -> _F: + ... + + def convert( + self, + value: str, + param: Optional[Parameter], + ctx: Optional[Context], + ) -> _F: + ... + + +class IntParamType(ParamType): + def __call__( + self, + value: Optional[str], + param: Optional[Parameter] = None, + ctx: Optional[Context] = None, + ) -> int: + ... + + def convert( + self, + value: str, + param: Optional[Parameter], + ctx: Optional[Context], + ) -> int: + ... + + +class IntRange(IntParamType): + def __init__( + self, min: Optional[int] = None, max: Optional[int] = None, clamp: bool = False + ) -> None: + ... + + +_PathType = TypeVar('_PathType', str, bytes) + + +class Path(ParamType): + def __init__( + self, + exists: bool = False, + file_okay: bool = True, + dir_okay: bool = True, + writable: bool = False, + readable: bool = True, + resolve_path: bool = False, + allow_dash: bool = False, + path_type: Optional[_PathType] = None, + ) -> None: + ... + + def coerce_path_result(self, rv: Union[str, bytes]) -> _PathType: + ... + + def __call__( + self, + value: Optional[str], + param: Optional[Parameter] = None, + ctx: Optional[Context] = None, + ) -> _PathType: + ... + + def convert( + self, + value: str, + param: Optional[Parameter], + ctx: Optional[Context], + ) -> _PathType: + ... + +class StringParamType(ParamType): + def __call__( + self, + value: Optional[str], + param: Optional[Parameter] = None, + ctx: Optional[Context] = None, + ) -> str: + ... + + def convert( + self, + value: str, + param: Optional[Parameter], + ctx: Optional[Context], + ) -> str: + ... + + +class Tuple(CompositeParamType): + types: List[ParamType] + + def __init__(self, types: Iterable[Any]) -> None: + ... + + def __call__( + self, + value: Optional[str], + param: Optional[Parameter] = None, + ctx: Optional[Context] = None, + ) -> Tuple: + ... + + def convert( + self, + value: str, + param: Optional[Parameter], + ctx: Optional[Context], + ) -> Tuple: + ... + + +class UnprocessedParamType(ParamType): + ... + + +class UUIDParameterType(ParamType): + def __call__( + self, + value: Optional[str], + param: Optional[Parameter] = None, + ctx: Optional[Context] = None, + ) -> uuid.UUID: + ... + + def convert( + self, + value: str, + param: Optional[Parameter], + ctx: Optional[Context], + ) -> uuid.UUID: + ... + + +def convert_type(ty: Any, default: Optional[Any] = None) -> ParamType: + ... + +# parameter type shortcuts + +BOOL = BoolParamType() +FLOAT = FloatParamType() +INT = IntParamType() +STRING = StringParamType() +UNPROCESSED = UnprocessedParamType() +UUID = UUIDParameterType() diff --git a/python/helpers/typeshed/third_party/2and3/click/utils.pyi b/python/helpers/typeshed/third_party/2and3/click/utils.pyi new file mode 100644 index 000000000000..cce7f20b5ba8 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/click/utils.pyi @@ -0,0 +1,118 @@ +from typing import Any, Callable, Iterator, IO, List, Optional, TypeVar, Union + + +_T = TypeVar('_T') +_Decorator = Callable[[_T], _T] + + +def _posixify(name: str) -> str: + ... + + +def safecall(func: _T) -> _T: + ... + + +def make_str(value: Any) -> str: + ... + + +def make_default_short_help(help: str, max_length: int = 45): + ... + + +class LazyFile: + name: str + mode: str + encoding: Optional[str] + errors: str + atomic: bool + + def __init__( + self, + filename: str, + mode: str = 'r', + encoding: Optional[str] = None, + errors: str = 'strict', + atomic: bool = False + ) -> None: + ... + + def open(self) -> IO: + ... + + def close(self) -> None: + ... + + def close_intelligently(self) -> None: + ... + + def __enter__(self) -> 'LazyFile': + ... + + def __exit__(self, exc_type, exc_value, tb): + ... + + def __iter__(self) -> Iterator: + ... + + +class KeepOpenFile: + _file: IO + + def __init__(self, file: IO) -> None: + ... + + def __enter__(self) -> 'KeepOpenFile': + ... + + def __exit__(self, exc_type, exc_value, tb): + ... + + def __iter__(self) -> Iterator: + ... + + +def echo( + message: Optional[str] = None, + file: Optional[IO] = None, + nl: bool = True, + err: bool = False, + color: Optional[bool] = None, +) -> None: + ... + + +def get_binary_stream(name: str) -> IO[bytes]: + ... + + +def get_text_stream( + name: str, encoding: Optional[str] = None, errors: str = 'strict' +) -> IO[str]: + ... + + +def open_file( + filename: str, + mode: str = 'r', + encoding: Optional[str] = None, + errors: str = 'strict', + lazy: bool = False, + atomic: bool = False +) -> Union[IO, LazyFile, KeepOpenFile]: + ... + + +def get_os_args() -> List[str]: + ... + + +def format_filename(filename: str, shorten: bool = False) -> str: + ... + + +def get_app_dir( + app_name: str, roaming: bool = True, force_posix: bool = False +) -> str: + ... diff --git a/python/helpers/typeshed/third_party/2and3/emoji.pyi b/python/helpers/typeshed/third_party/2and3/emoji.pyi new file mode 100644 index 000000000000..53fb5793ca62 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/emoji.pyi @@ -0,0 +1,18 @@ +from typing import Tuple, Pattern, List, Dict, Union + +_DEFAULT_DELIMITER = ... # type: str + +def emojize( + string: str, + use_aliases: bool=..., + delimiters: Tuple[str, str]=... +) -> str: ... + +def demojize( + string: str, + delimiters: Tuple[str, str]=... +) -> str: ... + +def get_emoji_regexp() -> Pattern: ... + +def emoji_lis(string: str) -> List[Dict[str, Union[int, str]]]: ... diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/__init__.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/__init__.pyi index e77f4fd84675..063f73d8d540 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/__init__.pyi @@ -1,11 +1,7 @@ -# Stubs for jinja2 (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from jinja2.environment import Environment as Environment, Template as Template from jinja2.loaders import BaseLoader as BaseLoader, FileSystemLoader as FileSystemLoader, PackageLoader as PackageLoader, DictLoader as DictLoader, FunctionLoader as FunctionLoader, PrefixLoader as PrefixLoader, ChoiceLoader as ChoiceLoader, ModuleLoader as ModuleLoader from jinja2.bccache import BytecodeCache as BytecodeCache, FileSystemBytecodeCache as FileSystemBytecodeCache, MemcachedBytecodeCache as MemcachedBytecodeCache from jinja2.runtime import Undefined as Undefined, DebugUndefined as DebugUndefined, StrictUndefined as StrictUndefined, make_logging_undefined as make_logging_undefined from jinja2.exceptions import TemplateError as TemplateError, UndefinedError as UndefinedError, TemplateNotFound as TemplateNotFound, TemplatesNotFound as TemplatesNotFound, TemplateSyntaxError as TemplateSyntaxError, TemplateAssertionError as TemplateAssertionError from jinja2.filters import environmentfilter as environmentfilter, contextfilter as contextfilter, evalcontextfilter as evalcontextfilter -from jinja2.utils import Markup as Markup, escape as escape, clear_caches as clear_caches, environmentfunction as environmentfunction, evalcontextfunction as evalcontextfunction, contextfunction as contextfunction, is_undefined as is_undefined +from jinja2.utils import Markup as Markup, escape as escape, clear_caches as clear_caches, environmentfunction as environmentfunction, evalcontextfunction as evalcontextfunction, contextfunction as contextfunction, is_undefined as is_undefined, select_autoescape as select_autoescape diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/_compat.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/_compat.pyi index 1c83f445b3fd..86283185ea71 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/_compat.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/_compat.pyi @@ -1,7 +1,3 @@ -# Stubs for jinja2._compat (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional import sys diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/_stringdefs.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/_stringdefs.pyi index d09bdbcc3c48..26f798b2c79a 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/_stringdefs.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/_stringdefs.pyi @@ -1,7 +1,3 @@ -# Stubs for jinja2._stringdefs (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any Cc = ... # type: str diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/bccache.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/bccache.pyi index ef037016b660..58a6ea39aab9 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/bccache.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/bccache.pyi @@ -1,7 +1,3 @@ -# Stubs for jinja2.bccache (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional marshal_dump = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/compiler.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/compiler.pyi index 44e001cfbdfe..09883e82c09a 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/compiler.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/compiler.pyi @@ -1,7 +1,3 @@ -# Stubs for jinja2.compiler (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional from keyword import iskeyword as is_python_keyword from jinja2.visitor import NodeVisitor diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/constants.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/constants.pyi index ca47cb0d7862..dfb7539edb57 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/constants.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/constants.pyi @@ -1,5 +1 @@ -# Stubs for jinja2.constants (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - LOREM_IPSUM_WORDS = ... # type: str diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/debug.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/debug.pyi index 270acf54082a..db0af463705d 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/debug.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/debug.pyi @@ -1,7 +1,3 @@ -# Stubs for jinja2.debug (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional tproxy = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/defaults.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/defaults.pyi index 0788c7c64a72..3f440066c253 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/defaults.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/defaults.pyi @@ -1,7 +1,3 @@ -# Stubs for jinja2.defaults (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from jinja2.filters import FILTERS as DEFAULT_FILTERS from jinja2.tests import TESTS as DEFAULT_TESTS diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/environment.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/environment.pyi index b3ea1d740a5b..909211ca8400 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/environment.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/environment.pyi @@ -1,7 +1,3 @@ -# Stubs for jinja2.environment (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Callable, Dict, Iterator, List, Optional, Text, Type, Union from .bccache import BytecodeCache @@ -46,7 +42,7 @@ class Environment: bytecode_cache = ... # type: BytecodeCache auto_reload = ... # type: bool extensions = ... # type: List - def __init__(self, block_start_string: Text = ..., block_end_string: Text = ..., variable_start_string: Text = ..., variable_end_string: Text = ..., comment_start_string: Any = ..., comment_end_string: Text = ..., line_statement_prefix: Text = ..., line_comment_prefix: Text = ..., trim_blocks: bool = ..., lstrip_blocks: bool = ..., newline_sequence: Text = ..., keep_trailing_newline: bool = ..., extensions: List = ..., optimized: bool = ..., undefined: Type[Undefined] = ..., finalize: Optional[Callable] = ..., autoescape: bool = ..., loader: Optional[BaseLoader] = ..., cache_size: int = ..., auto_reload: bool = ..., bytecode_cache: Optional[BytecodeCache] = ...) -> None: ... + def __init__(self, block_start_string: Text = ..., block_end_string: Text = ..., variable_start_string: Text = ..., variable_end_string: Text = ..., comment_start_string: Any = ..., comment_end_string: Text = ..., line_statement_prefix: Text = ..., line_comment_prefix: Text = ..., trim_blocks: bool = ..., lstrip_blocks: bool = ..., newline_sequence: Text = ..., keep_trailing_newline: bool = ..., extensions: List = ..., optimized: bool = ..., undefined: Type[Undefined] = ..., finalize: Optional[Callable] = ..., autoescape: Union[bool, Callable[[str], bool]] = ..., loader: Optional[BaseLoader] = ..., cache_size: int = ..., auto_reload: bool = ..., bytecode_cache: Optional[BytecodeCache] = ...) -> None: ... def add_extension(self, extension): ... def extend(self, **attributes): ... def overlay(self, block_start_string: Text = ..., block_end_string: Text = ..., variable_start_string: Text = ..., variable_end_string: Text = ..., comment_start_string: Any = ..., comment_end_string: Text = ..., line_statement_prefix: Text = ..., line_comment_prefix: Text = ..., trim_blocks: bool = ..., lstrip_blocks: bool = ..., extensions: List = ..., optimized: bool = ..., undefined: Type[Undefined] = ..., finalize: Callable = ..., autoescape: bool = ..., loader: Optional[BaseLoader] = ..., cache_size: int = ..., auto_reload: bool = ..., bytecode_cache: Optional[BytecodeCache] = ...): ... diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/exceptions.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/exceptions.pyi index 1008167f45ce..861e6bc41bc5 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/exceptions.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/exceptions.pyi @@ -1,7 +1,3 @@ -# Stubs for jinja2.exceptions (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional, Text class TemplateError(Exception): diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/ext.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/ext.pyi index 51592424dc3e..4fa28c7c0d0b 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/ext.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/ext.pyi @@ -1,7 +1,3 @@ -# Stubs for jinja2.ext (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional GETTEXT_FUNCTIONS = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/filters.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/filters.pyi index 7da165f2fbd6..d77fc22a57e1 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/filters.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/filters.pyi @@ -1,7 +1,3 @@ -# Stubs for jinja2.filters (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional def contextfilter(f): ... diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/lexer.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/lexer.pyi index b571a48ee17e..89bf20d61c14 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/lexer.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/lexer.pyi @@ -1,7 +1,3 @@ -# Stubs for jinja2.lexer (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional whitespace_re = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/loaders.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/loaders.pyi index 7de950ebb929..9c74ec2cf98c 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/loaders.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/loaders.pyi @@ -1,7 +1,3 @@ -# Stubs for jinja2.loaders (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Callable, List, Optional, Text, Tuple from types import ModuleType diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/meta.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/meta.pyi index 998cc809df46..0e0b8499a72c 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/meta.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/meta.pyi @@ -1,7 +1,3 @@ -# Stubs for jinja2.meta (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from jinja2.compiler import CodeGenerator diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/nodes.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/nodes.pyi index ce43bb3fd550..bbc315bbf745 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/nodes.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/nodes.pyi @@ -1,7 +1,3 @@ -# Stubs for jinja2.nodes (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional class Impossible(Exception): ... diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/optimizer.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/optimizer.pyi index 2c3067111b37..dc23f728ba0e 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/optimizer.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/optimizer.pyi @@ -1,7 +1,3 @@ -# Stubs for jinja2.optimizer (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from jinja2.visitor import NodeTransformer diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/parser.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/parser.pyi index 20d19fcd3d28..f698085a1247 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/parser.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/parser.pyi @@ -1,7 +1,3 @@ -# Stubs for jinja2.parser (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional class Parser: diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/runtime.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/runtime.pyi index cfef911b1620..34d06f4cd517 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/runtime.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/runtime.pyi @@ -1,7 +1,3 @@ -# Stubs for jinja2.runtime (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Dict, Optional, Text, Union from jinja2.utils import Markup as Markup, escape as escape, missing as missing, concat as concat from jinja2.exceptions import TemplateRuntimeError as TemplateRuntimeError, TemplateNotFound as TemplateNotFound diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/sandbox.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/sandbox.pyi index f61142068d46..3c8a18896264 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/sandbox.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/sandbox.pyi @@ -1,7 +1,3 @@ -# Stubs for jinja2.sandbox (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from jinja2.environment import Environment diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/tests.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/tests.pyi index fb31db772a71..db67c2563f46 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/tests.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/tests.pyi @@ -1,7 +1,3 @@ -# Stubs for jinja2.tests (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any number_re = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/utils.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/utils.pyi index 1368299722a2..196bab32cb1a 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/utils.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/utils.pyi @@ -1,10 +1,6 @@ -# Stubs for jinja2.utils (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. +from typing import Any, Callable, Iterable, Optional -from typing import Any, Optional - -from markupsafe import Markup, escape, soft_unicode +from markupsafe import Markup as Markup, escape as escape, soft_unicode as soft_unicode missing = ... # type: Any internal_code = ... # type: Any @@ -15,6 +11,7 @@ def evalcontextfunction(f): ... def environmentfunction(f): ... def internalcode(f): ... def is_undefined(obj): ... +def select_autoescape(enabled_extensions: Iterable[str] = ..., disabled_extensions: Iterable[str] = ..., default_for_string: bool = ..., default: bool = ...) -> Callable[[str], bool]: ... def consume(iterable): ... def clear_caches(): ... def import_string(import_name, silent: bool = ...): ... diff --git a/python/helpers/typeshed/third_party/2and3/jinja2/visitor.pyi b/python/helpers/typeshed/third_party/2and3/jinja2/visitor.pyi index 201750caed3c..ef34328dfe16 100644 --- a/python/helpers/typeshed/third_party/2and3/jinja2/visitor.pyi +++ b/python/helpers/typeshed/third_party/2and3/jinja2/visitor.pyi @@ -1,7 +1,3 @@ -# Stubs for jinja2.visitor (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - class NodeVisitor: def get_visitor(self, node): ... def visit(self, node, *args, **kwargs): ... diff --git a/python/helpers/typeshed/third_party/2and3/markupsafe/__init__.pyi b/python/helpers/typeshed/third_party/2and3/markupsafe/__init__.pyi index 723d329b3478..7961654b8e9b 100644 --- a/python/helpers/typeshed/third_party/2and3/markupsafe/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/markupsafe/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for markupsafe (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - import sys from typing import Any, Callable, Dict, Iterable, List, Optional, Text, Tuple, Union @@ -20,8 +16,8 @@ class Markup(text_type): def __rmul__(self, num: int) -> Markup: ... def __mod__(self, *args: Any) -> Markup: ... def join(self, seq: Iterable[text_type]): ... - def split(self, sep: text_type = None, maxsplit: int = -1) -> List[text_type]: ... - def rsplit(self, sep: text_type = None, maxsplit: int = -1) -> List[text_type]: ... + def split(self, sep: Optional[text_type] = None, maxsplit: int = -1) -> List[text_type]: ... + def rsplit(self, sep: Optional[text_type] = None, maxsplit: int = -1) -> List[text_type]: ... def splitlines(self, keepends: bool = ...) -> List[text_type]: ... def unescape(self) -> Text: ... def striptags(self) -> Text: ... @@ -41,9 +37,9 @@ class Markup(text_type): def replace(self, old: text_type, new: text_type, count: int = -1) -> Markup: ... def ljust(self, width: int, fillchar: text_type = ...) -> Markup: ... def rjust(self, width: int, fillchar: text_type = ...) -> Markup: ... - def lstrip(self, chars: text_type = None) -> Markup: ... - def rstrip(self, chars: text_type = None) -> Markup: ... - def strip(self, chars: text_type = None) -> Markup: ... + def lstrip(self, chars: Optional[text_type] = None) -> Markup: ... + def rstrip(self, chars: Optional[text_type] = None) -> Markup: ... + def strip(self, chars: Optional[text_type] = None) -> Markup: ... def center(self, width: int, fillchar: text_type = ...) -> Markup: ... def zfill(self, width: int) -> Markup: ... def translate(self, table: Union[Dict[int, Any], text_type]) -> Markup: ... diff --git a/python/helpers/typeshed/third_party/2and3/markupsafe/_compat.pyi b/python/helpers/typeshed/third_party/2and3/markupsafe/_compat.pyi index 72b6f606ed0b..bb9a860a910f 100644 --- a/python/helpers/typeshed/third_party/2and3/markupsafe/_compat.pyi +++ b/python/helpers/typeshed/third_party/2and3/markupsafe/_compat.pyi @@ -1,7 +1,3 @@ -# Stubs for markupsafe._compat (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - import sys from typing import Any, Iterator, Mapping, Text, Tuple, TypeVar diff --git a/python/helpers/typeshed/third_party/2and3/markupsafe/_constants.pyi b/python/helpers/typeshed/third_party/2and3/markupsafe/_constants.pyi index 677b46c49564..65ace32e5ef5 100644 --- a/python/helpers/typeshed/third_party/2and3/markupsafe/_constants.pyi +++ b/python/helpers/typeshed/third_party/2and3/markupsafe/_constants.pyi @@ -1,7 +1,3 @@ -# Stubs for markupsafe._constants (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Dict, Text HTML_ENTITIES = ... # type: Dict[Text, int] diff --git a/python/helpers/typeshed/third_party/2and3/markupsafe/_native.pyi b/python/helpers/typeshed/third_party/2and3/markupsafe/_native.pyi index 13d6fec89cfd..ecf20c607ef0 100644 --- a/python/helpers/typeshed/third_party/2and3/markupsafe/_native.pyi +++ b/python/helpers/typeshed/third_party/2and3/markupsafe/_native.pyi @@ -1,7 +1,3 @@ -# Stubs for markupsafe._native (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from . import Markup from ._compat import text_type, string_types from typing import Union, Text diff --git a/python/helpers/typeshed/third_party/2and3/markupsafe/_speedups.pyi b/python/helpers/typeshed/third_party/2and3/markupsafe/_speedups.pyi index 379e11e6b654..ecf20c607ef0 100644 --- a/python/helpers/typeshed/third_party/2and3/markupsafe/_speedups.pyi +++ b/python/helpers/typeshed/third_party/2and3/markupsafe/_speedups.pyi @@ -1,7 +1,3 @@ -# Stubs for markupsafe._speedups (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from . import Markup from ._compat import text_type, string_types from typing import Union, Text diff --git a/python/helpers/typeshed/third_party/2and3/mypy_extensions.pyi b/python/helpers/typeshed/third_party/2and3/mypy_extensions.pyi index 48bdac21fedd..2c4be007b815 100644 --- a/python/helpers/typeshed/third_party/2and3/mypy_extensions.pyi +++ b/python/helpers/typeshed/third_party/2and3/mypy_extensions.pyi @@ -1,9 +1,15 @@ -from typing import Dict, Type, TypeVar, Union +from typing import Dict, Type, TypeVar, Optional, Union _T = TypeVar('_T') +def TypedDict(typename: str, fields: Dict[str, Type[_T]], total: bool = ...) -> Type[dict]: ... -def TypedDict(typename: str, fields: Dict[str, Type[_T]]) -> Type[dict]: ... +def Arg(type: _T = ..., name: Optional[str] = ...) -> _T: ... +def DefaultArg(type: _T = ..., name: Optional[str] = ...) -> _T: ... +def NamedArg(type: _T = ..., name: Optional[str] = ...) -> _T: ... +def DefaultNamedArg(type: _T = ..., name: Optional[str] = ...) -> _T: ... +def VarArg(type: _T = ...) -> _T: ... +def KwArg(type: _T = ...) -> _T: ... # Return type that indicates a function does not return. # This type is equivalent to the None type, but the no-op Union is necessary to diff --git a/python/helpers/typeshed/third_party/2and3/pymysql/__init__.pyi b/python/helpers/typeshed/third_party/2and3/pymysql/__init__.pyi index d1161e8c68f3..dd58ff9d0928 100644 --- a/python/helpers/typeshed/third_party/2and3/pymysql/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/pymysql/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for pymysql (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Union, Tuple, Callable from .connections import Connection from .constants import FIELD_TYPE as FIELD_TYPE diff --git a/python/helpers/typeshed/third_party/2and3/pymysql/charset.pyi b/python/helpers/typeshed/third_party/2and3/pymysql/charset.pyi index 4fc0df540f6c..916e6a3665c6 100644 --- a/python/helpers/typeshed/third_party/2and3/pymysql/charset.pyi +++ b/python/helpers/typeshed/third_party/2and3/pymysql/charset.pyi @@ -1,7 +1,3 @@ -# Stubs for pymysql.charset (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any MBLENGTH = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2and3/pymysql/connections.pyi b/python/helpers/typeshed/third_party/2and3/pymysql/connections.pyi index 2eff7be60db6..62109ba60044 100644 --- a/python/helpers/typeshed/third_party/2and3/pymysql/connections.pyi +++ b/python/helpers/typeshed/third_party/2and3/pymysql/connections.pyi @@ -1,7 +1,3 @@ -# Stubs for pymysql.connections (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional, Type from .charset import MBLENGTH as MBLENGTH, charset_by_name as charset_by_name, charset_by_id as charset_by_id from .cursors import Cursor as Cursor diff --git a/python/helpers/typeshed/third_party/2and3/pymysql/constants/CLIENT.pyi b/python/helpers/typeshed/third_party/2and3/pymysql/constants/CLIENT.pyi index 30d9dfcfc939..cdb11b32d7ce 100644 --- a/python/helpers/typeshed/third_party/2and3/pymysql/constants/CLIENT.pyi +++ b/python/helpers/typeshed/third_party/2and3/pymysql/constants/CLIENT.pyi @@ -1,7 +1,3 @@ -# Stubs for pymysql.constants.CLIENT (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any LONG_PASSWORD = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2and3/pymysql/constants/COMMAND.pyi b/python/helpers/typeshed/third_party/2and3/pymysql/constants/COMMAND.pyi index 4ec68d5aae1f..0cfa0c2601f3 100644 --- a/python/helpers/typeshed/third_party/2and3/pymysql/constants/COMMAND.pyi +++ b/python/helpers/typeshed/third_party/2and3/pymysql/constants/COMMAND.pyi @@ -1,7 +1,3 @@ -# Stubs for pymysql.constants.COMMAND (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any COM_SLEEP = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2and3/pymysql/constants/ER.pyi b/python/helpers/typeshed/third_party/2and3/pymysql/constants/ER.pyi index 0ab17b26f6df..811f6a2140b7 100644 --- a/python/helpers/typeshed/third_party/2and3/pymysql/constants/ER.pyi +++ b/python/helpers/typeshed/third_party/2and3/pymysql/constants/ER.pyi @@ -1,7 +1,3 @@ -# Stubs for pymysql.constants.ER (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any ERROR_FIRST = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2and3/pymysql/constants/FIELD_TYPE.pyi b/python/helpers/typeshed/third_party/2and3/pymysql/constants/FIELD_TYPE.pyi index e9987b2397ee..e05bd6c2bae4 100644 --- a/python/helpers/typeshed/third_party/2and3/pymysql/constants/FIELD_TYPE.pyi +++ b/python/helpers/typeshed/third_party/2and3/pymysql/constants/FIELD_TYPE.pyi @@ -1,7 +1,3 @@ -# Stubs for pymysql.constants.FIELD_TYPE (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any DECIMAL = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2and3/pymysql/constants/FLAG.pyi b/python/helpers/typeshed/third_party/2and3/pymysql/constants/FLAG.pyi index 792df90317e6..869a987d35a3 100644 --- a/python/helpers/typeshed/third_party/2and3/pymysql/constants/FLAG.pyi +++ b/python/helpers/typeshed/third_party/2and3/pymysql/constants/FLAG.pyi @@ -1,7 +1,3 @@ -# Stubs for pymysql.constants.FLAG (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any NOT_NULL = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2and3/pymysql/constants/SERVER_STATUS.pyi b/python/helpers/typeshed/third_party/2and3/pymysql/constants/SERVER_STATUS.pyi index 6e4db8d02260..ae81f046c674 100644 --- a/python/helpers/typeshed/third_party/2and3/pymysql/constants/SERVER_STATUS.pyi +++ b/python/helpers/typeshed/third_party/2and3/pymysql/constants/SERVER_STATUS.pyi @@ -1,7 +1,3 @@ -# Stubs for pymysql.constants.SERVER_STATUS (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any SERVER_STATUS_IN_TRANS = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2and3/pymysql/constants/__init__.pyi b/python/helpers/typeshed/third_party/2and3/pymysql/constants/__init__.pyi index 19336fea6bc1..e69de29bb2d1 100644 --- a/python/helpers/typeshed/third_party/2and3/pymysql/constants/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/pymysql/constants/__init__.pyi @@ -1,3 +0,0 @@ -# Stubs for pymysql.constants (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. diff --git a/python/helpers/typeshed/third_party/2and3/pymysql/converters.pyi b/python/helpers/typeshed/third_party/2and3/pymysql/converters.pyi index d9c8d293052c..94ba99a064ee 100644 --- a/python/helpers/typeshed/third_party/2and3/pymysql/converters.pyi +++ b/python/helpers/typeshed/third_party/2and3/pymysql/converters.pyi @@ -1,7 +1,3 @@ -# Stubs for pymysql.converters (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from .constants import FIELD_TYPE as FIELD_TYPE, FLAG as FLAG from .charset import charset_by_id as charset_by_id diff --git a/python/helpers/typeshed/third_party/2and3/pymysql/cursors.pyi b/python/helpers/typeshed/third_party/2and3/pymysql/cursors.pyi index a06ac233bfbe..357f205614e6 100644 --- a/python/helpers/typeshed/third_party/2and3/pymysql/cursors.pyi +++ b/python/helpers/typeshed/third_party/2and3/pymysql/cursors.pyi @@ -1,7 +1,3 @@ -# Stubs for pymysql.cursors (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Union, Tuple, Any, Dict, Optional, Text from .connections import Connection @@ -26,7 +22,7 @@ class Cursor: def executemany(self, query: str, args) -> int: ... def callproc(self, procname, args=...): ... def fetchone(self) -> Optional[Gen]: ... - def fetchmany(self, size: int = None) -> Optional[Gen]: ... + def fetchmany(self, size: Optional[int] = None) -> Optional[Gen]: ... def fetchall(self) -> Optional[Tuple[Gen, ...]]: ... def scroll(self, value, mode=''): ... def __iter__(self): ... diff --git a/python/helpers/typeshed/third_party/2and3/pymysql/err.pyi b/python/helpers/typeshed/third_party/2and3/pymysql/err.pyi index 81f88032d86c..c0320a62e857 100644 --- a/python/helpers/typeshed/third_party/2and3/pymysql/err.pyi +++ b/python/helpers/typeshed/third_party/2and3/pymysql/err.pyi @@ -1,7 +1,3 @@ -# Stubs for pymysql.err (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Dict from .constants import ER as ER diff --git a/python/helpers/typeshed/third_party/2and3/pymysql/times.pyi b/python/helpers/typeshed/third_party/2and3/pymysql/times.pyi index e96c99057acc..4cc207af5751 100644 --- a/python/helpers/typeshed/third_party/2and3/pymysql/times.pyi +++ b/python/helpers/typeshed/third_party/2and3/pymysql/times.pyi @@ -1,7 +1,3 @@ -# Stubs for pymysql.times (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any Date = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2and3/pymysql/util.pyi b/python/helpers/typeshed/third_party/2and3/pymysql/util.pyi index 2c2f7c0372d6..3d9a65b4b2d3 100644 --- a/python/helpers/typeshed/third_party/2and3/pymysql/util.pyi +++ b/python/helpers/typeshed/third_party/2and3/pymysql/util.pyi @@ -1,7 +1,3 @@ -# Stubs for pymysql.util (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - def byte2int(b): ... def int2byte(i): ... def join_bytes(bs): ... diff --git a/python/helpers/typeshed/third_party/2and3/pynamodb/__init__.pyi b/python/helpers/typeshed/third_party/2and3/pynamodb/__init__.pyi new file mode 100644 index 000000000000..83e691d7ac3b --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/pynamodb/__init__.pyi @@ -0,0 +1 @@ +__license__: str diff --git a/python/helpers/typeshed/third_party/2and3/pynamodb/attributes.pyi b/python/helpers/typeshed/third_party/2and3/pynamodb/attributes.pyi new file mode 100644 index 000000000000..d450d0e5d489 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/pynamodb/attributes.pyi @@ -0,0 +1,84 @@ +from typing import Any, Callable, Dict, Generic, Iterable, List, Mapping, Optional, Text, Type, TypeVar, Union, Set + +from datetime import datetime + +_T = TypeVar('_T') +_KT = TypeVar('_KT') +_VT = TypeVar('_VT') +_MT = TypeVar('_MT', bound='MapAttribute') +Number = Union[int, float] + +class Attribute(Generic[_T]): + attr_name: Optional[Text] + attr_type: Text + null: bool + default: Any + is_hash_key: bool + is_range_key: bool + def __init__(self, hash_key: bool = ..., range_key: bool = ..., null: Optional[bool] = ..., default: Optional[Union[_T, Callable[..., _T]]] = ..., attr_name: Optional[Text] = ...) -> None: ... + def __set__(self, instance: Any, value: Optional[_T]) -> None: ... + def serialize(self, value: Any) -> Any: ... + def deserialize(self, value: Any) -> Any: ... + def get_value(self, value: Any) -> Any: ... + +class SetMixin(object): + def serialize(self, value): ... + def deserialize(self, value): ... + +class BinaryAttribute(Attribute[bytes]): + def __get__(self, instance: Any, owner: Any) -> bytes: ... + +class BinarySetAttribute(SetMixin, Attribute[Set[bytes]]): + def __get__(self, instance: Any, owner: Any) -> Set[bytes]: ... + +class UnicodeSetAttribute(SetMixin, Attribute[Set[Text]]): + def element_serialize(self, value: Any) -> Any: ... + def element_deserialize(self, value: Any) -> Any: ... + def __get__(self, instance: Any, owner: Any) -> Set[Text]: ... + +class UnicodeAttribute(Attribute[Text]): + def __get__(self, instance: Any, owner: Any) -> Text: ... + +class JSONAttribute(Attribute[Any]): + def __get__(self, instance: Any, owner: Any) -> Any: ... + +class LegacyBooleanAttribute(Attribute[bool]): + def __get__(self, instance: Any, owner: Any) -> bool: ... + +class BooleanAttribute(Attribute[bool]): + def __get__(self, instance: Any, owner: Any) -> bool: ... + +class NumberSetAttribute(SetMixin, Attribute[Set[Number]]): + def __get__(self, instance: Any, owner: Any) -> Set[Number]: ... + +class NumberAttribute(Attribute[Number]): + def __get__(self, instance: Any, owner: Any) -> Number: ... + +class UTCDateTimeAttribute(Attribute[datetime]): + def __get__(self, instance: Any, owner: Any) -> datetime: ... + +class NullAttribute(Attribute[None]): + def __get__(self, instance: Any, owner: Any) -> None: ... + +class MapAttributeMeta(type): + def __init__(cls, name, bases, attrs) -> None: ... + +class MapAttribute(Generic[_KT, _VT], Attribute[Mapping[_KT, _VT]], metaclass=MapAttributeMeta): + attribute_values: Any + def __init__(self, hash_key: bool = ..., range_key: bool = ..., null: Optional[bool] = ..., default: Optional[Union[Any, Callable[..., Any]]] = ..., attr_name: Optional[Text] = ..., **attrs) -> None: ... + def __iter__(self) -> Iterable[_VT]: ... + def __getattr__(self, attr: str) -> _VT: ... + def __getitem__(self, item: _KT) -> _VT: ... + def __set__(self, instance: Any, value: Union[None, MapAttribute[_KT, _VT], Mapping[_KT, _VT]]) -> None: ... + def __get__(self: _MT, instance: Any, owner: Any) -> _MT: ... + def is_type_safe(self, key: Any, value: Any) -> bool: ... + def validate(self) -> bool: ... + +class ListAttribute(Generic[_T], Attribute[List[_T]]): + element_type: Any + def __init__(self, hash_key: bool = ..., range_key: bool = ..., null: Optional[bool] = ..., default: Optional[Union[Any, Callable[..., Any]]] = ..., attr_name: Optional[Text] = ..., of: Optional[Type[_T]] = ...) -> None: ... + def __get__(self, instance: Any, owner: Any) -> List[_T]: ... + +DESERIALIZE_CLASS_MAP: Dict[Text, Attribute] +SERIALIZE_CLASS_MAP: Dict[Type, Attribute] +SERIALIZE_KEY_MAP: Dict[Type, Text] diff --git a/python/helpers/typeshed/third_party/2and3/pynamodb/connection/__init__.pyi b/python/helpers/typeshed/third_party/2and3/pynamodb/connection/__init__.pyi new file mode 100644 index 000000000000..8ecfdaf53fb4 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/pynamodb/connection/__init__.pyi @@ -0,0 +1,2 @@ +from pynamodb.connection.base import Connection +from pynamodb.connection.table import TableConnection diff --git a/python/helpers/typeshed/third_party/2and3/pynamodb/connection/base.pyi b/python/helpers/typeshed/third_party/2and3/pynamodb/connection/base.pyi new file mode 100644 index 000000000000..b0f023c71522 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/pynamodb/connection/base.pyi @@ -0,0 +1,55 @@ +from typing import Any, Dict, Optional, Text + +BOTOCORE_EXCEPTIONS: Any +log: Any + +class MetaTable: + data: Dict + def __init__(self, data: Dict) -> None: ... + @property + def range_keyname(self) -> Optional[Text]: ... + @property + def hash_keyname(self) -> Text: ... + def get_index_hash_keyname(self, index_name: Text) -> Optional[Text]: ... + def get_item_attribute_map(self, attributes, item_key: Any = ..., pythonic_key: bool = ...): ... + def get_attribute_type(self, attribute_name, value: Optional[Any] = ...): ... + def get_identifier_map(self, hash_key, range_key: Optional[Any] = ..., key: Any = ...): ... + def get_exclusive_start_key_map(self, exclusive_start_key): ... + +class Connection: + host: Any + region: Any + session_cls: Any + def __init__(self, region: Optional[Any] = ..., host: Optional[Any] = ..., session_cls: Optional[Any] = ..., request_timeout_seconds: Optional[Any] = ..., max_retry_attempts: Optional[Any] = ..., base_backoff_ms: Optional[Any] = ...) -> None: ... + def dispatch(self, operation_name, operation_kwargs): ... + @property + def session(self): ... + @property + def requests_session(self): ... + @property + def client(self): ... + def get_meta_table(self, table_name: Text, refresh: bool = ...): ... + def create_table(self, table_name: Text, attribute_definitions: Optional[Any] = ..., key_schema: Optional[Any] = ..., read_capacity_units: Optional[Any] = ..., write_capacity_units: Optional[Any] = ..., global_secondary_indexes: Optional[Any] = ..., local_secondary_indexes: Optional[Any] = ..., stream_specification: Optional[Any] = ...): ... + def delete_table(self, table_name: Text): ... + def update_table(self, table_name: Text, read_capacity_units: Optional[Any] = ..., write_capacity_units: Optional[Any] = ..., global_secondary_index_updates: Optional[Any] = ...): ... + def list_tables(self, exclusive_start_table_name: Optional[Any] = ..., limit: Optional[Any] = ...): ... + def describe_table(self, table_name: Text): ... + def get_conditional_operator(self, operator): ... + def get_item_attribute_map(self, table_name: Text, attributes, item_key: Any = ..., pythonic_key: bool = ...): ... + def get_expected_map(self, table_name: Text, expected): ... + def parse_attribute(self, attribute, return_type: bool = ...): ... + def get_attribute_type(self, table_name: Text, attribute_name, value: Optional[Any] = ...): ... + def get_identifier_map(self, table_name: Text, hash_key, range_key: Optional[Any] = ..., key: Any = ...): ... + def get_query_filter_map(self, table_name: Text, query_filters): ... + def get_consumed_capacity_map(self, return_consumed_capacity): ... + def get_return_values_map(self, return_values): ... + def get_item_collection_map(self, return_item_collection_metrics): ... + def get_exclusive_start_key_map(self, table_name: Text, exclusive_start_key): ... + def delete_item(self, table_name: Text, hash_key, range_key: Optional[Any] = ..., expected: Optional[Any] = ..., conditional_operator: Optional[Any] = ..., return_values: Optional[Any] = ..., return_consumed_capacity: Optional[Any] = ..., return_item_collection_metrics: Optional[Any] = ...): ... + def update_item(self, table_name: Text, hash_key, range_key: Optional[Any] = ..., attribute_updates: Optional[Any] = ..., expected: Optional[Any] = ..., return_consumed_capacity: Optional[Any] = ..., conditional_operator: Optional[Any] = ..., return_item_collection_metrics: Optional[Any] = ..., return_values: Optional[Any] = ...): ... + def put_item(self, table_name: Text, hash_key, range_key: Optional[Any] = ..., attributes: Optional[Any] = ..., expected: Optional[Any] = ..., conditional_operator: Optional[Any] = ..., return_values: Optional[Any] = ..., return_consumed_capacity: Optional[Any] = ..., return_item_collection_metrics: Optional[Any] = ...): ... + def batch_write_item(self, table_name: Text, put_items: Optional[Any] = ..., delete_items: Optional[Any] = ..., return_consumed_capacity: Optional[Any] = ..., return_item_collection_metrics: Optional[Any] = ...): ... + def batch_get_item(self, table_name: Text, keys, consistent_read: Optional[Any] = ..., return_consumed_capacity: Optional[Any] = ..., attributes_to_get: Optional[Any] = ...): ... + def get_item(self, table_name: Text, hash_key, range_key: Optional[Any] = ..., consistent_read: bool = ..., attributes_to_get: Optional[Any] = ...): ... + def scan(self, table_name: Text, attributes_to_get: Optional[Any] = ..., limit: Optional[Any] = ..., conditional_operator: Optional[Any] = ..., scan_filter: Optional[Any] = ..., return_consumed_capacity: Optional[Any] = ..., exclusive_start_key: Optional[Any] = ..., segment: Optional[Any] = ..., total_segments: Optional[Any] = ...): ... + def query(self, table_name: Text, hash_key, attributes_to_get: Optional[Any] = ..., consistent_read: bool = ..., exclusive_start_key: Optional[Any] = ..., index_name: Optional[Any] = ..., key_conditions: Optional[Any] = ..., query_filters: Optional[Any] = ..., conditional_operator: Optional[Any] = ..., limit: Optional[Any] = ..., return_consumed_capacity: Optional[Any] = ..., scan_index_forward: Optional[Any] = ..., select: Optional[Any] = ...): ... diff --git a/python/helpers/typeshed/third_party/2and3/pynamodb/connection/table.pyi b/python/helpers/typeshed/third_party/2and3/pynamodb/connection/table.pyi new file mode 100644 index 000000000000..0f820af9db56 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/pynamodb/connection/table.pyi @@ -0,0 +1,18 @@ +from typing import Any, Optional + +class TableConnection: + table_name: Any + connection: Any + def __init__(self, table_name, region: Optional[Any] = ..., host: Optional[Any] = ..., session_cls: Optional[Any] = ..., request_timeout_seconds: Optional[Any] = ..., max_retry_attempts: Optional[Any] = ..., base_backoff_ms: Optional[Any] = ...) -> None: ... + def delete_item(self, hash_key, range_key: Optional[Any] = ..., expected: Optional[Any] = ..., conditional_operator: Optional[Any] = ..., return_values: Optional[Any] = ..., return_consumed_capacity: Optional[Any] = ..., return_item_collection_metrics: Optional[Any] = ...): ... + def update_item(self, hash_key, range_key: Optional[Any] = ..., attribute_updates: Optional[Any] = ..., expected: Optional[Any] = ..., conditional_operator: Optional[Any] = ..., return_consumed_capacity: Optional[Any] = ..., return_item_collection_metrics: Optional[Any] = ..., return_values: Optional[Any] = ...): ... + def put_item(self, hash_key, range_key: Optional[Any] = ..., attributes: Optional[Any] = ..., expected: Optional[Any] = ..., conditional_operator: Optional[Any] = ..., return_values: Optional[Any] = ..., return_consumed_capacity: Optional[Any] = ..., return_item_collection_metrics: Optional[Any] = ...): ... + def batch_write_item(self, put_items: Optional[Any] = ..., delete_items: Optional[Any] = ..., return_consumed_capacity: Optional[Any] = ..., return_item_collection_metrics: Optional[Any] = ...): ... + def batch_get_item(self, keys, consistent_read: Optional[Any] = ..., return_consumed_capacity: Optional[Any] = ..., attributes_to_get: Optional[Any] = ...): ... + def get_item(self, hash_key, range_key: Optional[Any] = ..., consistent_read: bool = ..., attributes_to_get: Optional[Any] = ...): ... + def scan(self, attributes_to_get: Optional[Any] = ..., limit: Optional[Any] = ..., conditional_operator: Optional[Any] = ..., scan_filter: Optional[Any] = ..., return_consumed_capacity: Optional[Any] = ..., segment: Optional[Any] = ..., total_segments: Optional[Any] = ..., exclusive_start_key: Optional[Any] = ...): ... + def query(self, hash_key, attributes_to_get: Optional[Any] = ..., consistent_read: bool = ..., exclusive_start_key: Optional[Any] = ..., index_name: Optional[Any] = ..., key_conditions: Optional[Any] = ..., query_filters: Optional[Any] = ..., limit: Optional[Any] = ..., return_consumed_capacity: Optional[Any] = ..., scan_index_forward: Optional[Any] = ..., conditional_operator: Optional[Any] = ..., select: Optional[Any] = ...): ... + def describe_table(self): ... + def delete_table(self): ... + def update_table(self, read_capacity_units: Optional[Any] = ..., write_capacity_units: Optional[Any] = ..., global_secondary_index_updates: Optional[Any] = ...): ... + def create_table(self, attribute_definitions: Optional[Any] = ..., key_schema: Optional[Any] = ..., read_capacity_units: Optional[Any] = ..., write_capacity_units: Optional[Any] = ..., global_secondary_indexes: Optional[Any] = ..., local_secondary_indexes: Optional[Any] = ..., stream_specification: Optional[Any] = ...): ... diff --git a/python/helpers/typeshed/third_party/2and3/pynamodb/connection/util.pyi b/python/helpers/typeshed/third_party/2and3/pynamodb/connection/util.pyi new file mode 100644 index 000000000000..20635c69f494 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/pynamodb/connection/util.pyi @@ -0,0 +1,3 @@ +from typing import Text + +def pythonic(var_name: Text) -> Text: ... diff --git a/python/helpers/typeshed/third_party/2and3/pynamodb/constants.pyi b/python/helpers/typeshed/third_party/2and3/pynamodb/constants.pyi new file mode 100644 index 000000000000..7c26cd619bb9 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/pynamodb/constants.pyi @@ -0,0 +1,166 @@ +from typing import Any + +BATCH_WRITE_ITEM: str +DESCRIBE_TABLE: str +BATCH_GET_ITEM: str +CREATE_TABLE: str +UPDATE_TABLE: str +DELETE_TABLE: str +LIST_TABLES: str +UPDATE_ITEM: str +DELETE_ITEM: str +GET_ITEM: str +PUT_ITEM: str +QUERY: str +SCAN: str +GLOBAL_SECONDARY_INDEX_UPDATES: str +RETURN_ITEM_COLL_METRICS: str +EXCLUSIVE_START_TABLE_NAME: str +RETURN_CONSUMED_CAPACITY: str +COMPARISON_OPERATOR: str +SCAN_INDEX_FORWARD: str +ATTR_DEFINITIONS: str +ATTR_VALUE_LIST: str +TABLE_DESCRIPTION: str +UNPROCESSED_KEYS: str +UNPROCESSED_ITEMS: str +CONSISTENT_READ: str +DELETE_REQUEST: str +RETURN_VALUES: str +REQUEST_ITEMS: str +ATTRS_TO_GET: str +ATTR_UPDATES: str +TABLE_STATUS: str +SCAN_FILTER: str +TABLE_NAME: str +KEY_SCHEMA: str +ATTR_NAME: str +ATTR_TYPE: str +ITEM_COUNT: str +CAMEL_COUNT: str +PUT_REQUEST: str +INDEX_NAME: str +ATTRIBUTES: str +TABLE_KEY: str +RESPONSES: str +RANGE_KEY: str +KEY_TYPE: str +ACTION: str +UPDATE: str +EXISTS: str +SELECT: str +ACTIVE: str +LIMIT: str +ITEMS: str +ITEM: str +KEYS: str +UTC: str +KEY: str +DEFAULT_ENCODING: str +DEFAULT_REGION: str +DATETIME_FORMAT: str +SERVICE_NAME: str +HTTP_OK: int +HTTP_BAD_REQUEST: int +PROVISIONED_THROUGHPUT: str +READ_CAPACITY_UNITS: str +WRITE_CAPACITY_UNITS: str +STRING_SHORT: str +STRING_SET_SHORT: str +NUMBER_SHORT: str +NUMBER_SET_SHORT: str +BINARY_SHORT: str +BINARY_SET_SHORT: str +MAP_SHORT: str +LIST_SHORT: str +BOOLEAN: str +BOOLEAN_SHORT: str +STRING: str +STRING_SET: str +NUMBER: str +NUMBER_SET: str +BINARY: str +BINARY_SET: str +MAP: str +LIST: str +SHORT_ATTR_TYPES: Any +ATTR_TYPE_MAP: Any +LOCAL_SECONDARY_INDEX: str +LOCAL_SECONDARY_INDEXES: str +GLOBAL_SECONDARY_INDEX: str +GLOBAL_SECONDARY_INDEXES: str +PROJECTION: str +PROJECTION_TYPE: str +NON_KEY_ATTRIBUTES: str +KEYS_ONLY: str +ALL: str +INCLUDE: str +STREAM_VIEW_TYPE: str +STREAM_SPECIFICATION: str +STREAM_ENABLED: str +STREAM_NEW_IMAGE: str +STREAM_OLD_IMAGE: str +STREAM_NEW_AND_OLD_IMAGE: str +STREAM_KEYS_ONLY: str +EXCLUSIVE_START_KEY: str +LAST_EVALUATED_KEY: str +QUERY_FILTER: str +BEGINS_WITH: str +BETWEEN: str +EQ: str +NE: str +LE: str +LT: str +GE: str +GT: str +IN: str +KEY_CONDITIONS: str +COMPARISON_OPERATOR_VALUES: Any +QUERY_OPERATOR_MAP: Any +NOT_NULL: str +NULL: str +CONTAINS: str +NOT_CONTAINS: str +ALL_ATTRIBUTES: str +ALL_PROJECTED_ATTRIBUTES: str +SPECIFIC_ATTRIBUTES: str +COUNT: str +SELECT_VALUES: Any +SCAN_OPERATOR_MAP: Any +QUERY_FILTER_OPERATOR_MAP: Any +DELETE_FILTER_OPERATOR_MAP: Any +UPDATE_FILTER_OPERATOR_MAP: Any +PUT_FILTER_OPERATOR_MAP: Any +SEGMENT: str +TOTAL_SEGMENTS: str +SCAN_FILTER_VALUES: Any +QUERY_FILTER_VALUES: Any +DELETE_FILTER_VALUES: Any +VALUE: str +EXPECTED: str +CONSUMED_CAPACITY: str +CAPACITY_UNITS: str +INDEXES: str +TOTAL: str +NONE: str +RETURN_CONSUMED_CAPACITY_VALUES: Any +SIZE: str +RETURN_ITEM_COLL_METRICS_VALUES: Any +ALL_OLD: str +UPDATED_OLD: str +ALL_NEW: str +UPDATED_NEW: str +RETURN_VALUES_VALUES: Any +PUT: str +DELETE: str +ADD: str +ATTR_UPDATE_ACTIONS: Any +BATCH_GET_PAGE_LIMIT: int +BATCH_WRITE_PAGE_LIMIT: int +META_CLASS_NAME: str +REGION: str +HOST: str +CONDITIONAL_OPERATOR: str +AND: str +OR: str +CONDITIONAL_OPERATORS: Any diff --git a/python/helpers/typeshed/third_party/2and3/pynamodb/exceptions.pyi b/python/helpers/typeshed/third_party/2and3/pynamodb/exceptions.pyi new file mode 100644 index 000000000000..cfd17ac659c6 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/pynamodb/exceptions.pyi @@ -0,0 +1,40 @@ +from typing import Any, Optional, Text + +class PynamoDBException(Exception): + msg: str + cause: Any + def __init__(self, msg: Optional[Text] = ..., cause: Optional[Exception] = ...) -> None: ... + +class PynamoDBConnectionError(PynamoDBException): + pass + +class DeleteError(PynamoDBConnectionError): + pass + +class QueryError(PynamoDBConnectionError): + pass + +class ScanError(PynamoDBConnectionError): + pass + +class PutError(PynamoDBConnectionError): + pass + +class UpdateError(PynamoDBConnectionError): + pass + +class GetError(PynamoDBConnectionError): + pass + +class TableError(PynamoDBConnectionError): + pass + +class DoesNotExist(PynamoDBException): + pass + +class TableDoesNotExist(PynamoDBException): + def __init__(self, table_name) -> None: ... + +class VerboseClientError(Exception): + MSG_TEMPLATE: Any + def __init__(self, error_response, operation_name, verbose_properties: Optional[Any] = ...) -> None: ... diff --git a/python/helpers/typeshed/third_party/2and3/pynamodb/indexes.pyi b/python/helpers/typeshed/third_party/2and3/pynamodb/indexes.pyi new file mode 100644 index 000000000000..35506d097bf3 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/pynamodb/indexes.pyi @@ -0,0 +1,30 @@ +from typing import Any, Optional + +class IndexMeta(type): + def __init__(cls, name, bases, attrs) -> None: ... + +class Index(metaclass=IndexMeta): + Meta: Any + def __init__(self) -> None: ... + @classmethod + def count(cls, hash_key, consistent_read: bool = ..., **filters) -> int: ... + @classmethod + def query(self, hash_key, scan_index_forward: Optional[Any] = ..., consistent_read: bool = ..., limit: Optional[Any] = ..., last_evaluated_key: Optional[Any] = ..., attributes_to_get: Optional[Any] = ..., **filters): ... + +class GlobalSecondaryIndex(Index): ... +class LocalSecondaryIndex(Index): ... + +class Projection(object): + projection_type: Any + non_key_attributes: Any + +class KeysOnlyProjection(Projection): + projection_type: Any + +class IncludeProjection(Projection): + projection_type: Any + non_key_attributes: Any + def __init__(self, non_attr_keys: Optional[Any] = ...) -> None: ... + +class AllProjection(Projection): + projection_type: Any diff --git a/python/helpers/typeshed/third_party/2and3/pynamodb/models.pyi b/python/helpers/typeshed/third_party/2and3/pynamodb/models.pyi new file mode 100644 index 000000000000..56010a1f276b --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/pynamodb/models.pyi @@ -0,0 +1,85 @@ +from .exceptions import DoesNotExist +from typing import Any, Dict, Generic, Iterable, Iterator, List, Optional, Sequence, Tuple, Type, TypeVar, Text, Union + +log: Any + +class DefaultMeta: ... + +class ResultSet(Iterable): + results: Any + operation: Any + arguments: Any + def __init__(self, results, operation, arguments) -> None: ... + def __iter__(self): ... + +class MetaModel(type): + def __init__(self, name: Text, bases: Tuple[type, ...], attrs: Dict[Any, Any]) -> None: ... + +_T = TypeVar('_T', bound='Model') +KeyType = Union[Text, bytes, float, int, Tuple] + +class Model(metaclass=MetaModel): + DoesNotExist = DoesNotExist + attribute_values: Dict[Text, Any] + def __init__(self, hash_key: Optional[KeyType] = ..., range_key: Optional[Any] = ..., **attrs) -> None: ... + @classmethod + def has_map_or_list_attributes(cls: Type[_T]) -> bool: ... + @classmethod + def batch_get(cls: Type[_T], items: Iterable[Union[KeyType, Iterable[KeyType]]], consistent_read: Optional[bool] = ..., attributes_to_get: Optional[Sequence[Text]] = ...) -> Iterator[_T]: ... + @classmethod + def batch_write(cls: Type[_T], auto_commit: bool = ...) -> BatchWrite[_T]: ... + def delete(self, conditional_operator: Optional[Text] = ..., **expected_values) -> Any: ... + def update(self, attributes: Dict[Text, Dict[Text, Any]], conditional_operator: Optional[Text] = ..., **expected_values) -> Any: ... + def update_item(self, attribute: Text, value: Optional[Any] = ..., action: Optional[Text] = ..., conditional_operator: Optional[Text] = ..., **expected_values): ... + def save(self, conditional_operator: Optional[Text] = ..., **expected_values) -> Dict[str, Any]: ... + def refresh(self, consistent_read: bool = ...): ... + @classmethod + def get(cls: Type[_T], hash_key: KeyType, range_key: Optional[KeyType] = ..., consistent_read: bool = ...) -> _T: ... + @classmethod + def from_raw_data(cls: Type[_T], data) -> _T: ... + @classmethod + def count(cls: Type[_T], hash_key: Optional[KeyType] = ..., consistent_read: bool = ..., index_name: Optional[Text] = ..., limit: Optional[int] = ..., **filters) -> int: ... + @classmethod + def query(cls: Type[_T], hash_key: KeyType, consistent_read: bool = ..., index_name: Optional[Text] = ..., scan_index_forward: Optional[Any] = ..., conditional_operator: Optional[Text] = ..., limit: Optional[int] = ..., last_evaluated_key: Optional[Any] = ..., attributes_to_get: Optional[Iterable[Text]] = ..., page_size: Optional[int] = ..., **filters) -> Iterator[_T]: ... + @classmethod + def rate_limited_scan(cls: Type[_T], attributes_to_get: Optional[Sequence[Text]], segment: Optional[int] = ..., total_segments: Optional[int] = ..., limit: Optional[int] = ..., conditional_operator: Optional[Text] = ..., last_evaluated_key: Optional[Any] = ..., page_size: Optional[int] = ..., timeout_seconds: Optional[int] = ..., read_capacity_to_consume_per_second: int = ..., max_sleep_between_retry: int = ..., max_consecutive_exceptions: int = ..., **filters: Any): ... + @classmethod + def scan(cls: Type[_T], segment: Optional[int] = ..., total_segments: Optional[int] = ..., limit: Optional[int] = ..., conditional_operator: Optional[Text] = ..., last_evaluated_key: Optional[Any] = ..., page_size: Optional[int] = ..., **filters) -> Iterator[_T]: ... + @classmethod + def exists(cls: Type[_T]) -> bool: ... + @classmethod + def delete_table(cls): ... + @classmethod + def describe_table(cls): ... + @classmethod + def create_table(cls: Type[_T], wait: bool = ..., read_capacity_units: Optional[Any] = ..., write_capacity_units: Optional[Any] = ...): ... + @classmethod + def dumps(cls): ... + @classmethod + def dump(cls, filename): ... + @classmethod + def loads(cls, data): ... + @classmethod + def load(cls, filename): ... + @classmethod + def add_throttle_record(cls, records): ... + @classmethod + def get_throttle(cls): ... + @classmethod + def _get_attributes(cls) -> Dict[str, Any]: ... + +class ModelContextManager(Generic[_T]): + model: Type[_T] + auto_commit: bool + max_operations: int + pending_operations: List[Dict[Text, Any]] + def __init__(self, model: Type[_T], auto_commit: bool = ...) -> None: ... + def __enter__(self) -> ModelContextManager[_T]: ... + +class BatchWrite(Generic[_T], ModelContextManager[_T]): + def save(self, put_item: _T) -> None: ... + def delete(self, del_item: _T) -> None: ... + def __enter__(self) -> BatchWrite[_T]: ... + def __exit__(self, exc_type, exc_val, exc_tb) -> None: ... + pending_operations: Any + def commit(self) -> None: ... diff --git a/python/helpers/typeshed/third_party/2and3/pynamodb/settings.pyi b/python/helpers/typeshed/third_party/2and3/pynamodb/settings.pyi new file mode 100644 index 000000000000..76fc4172f073 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/pynamodb/settings.pyi @@ -0,0 +1,8 @@ +from typing import Any + +log: Any +default_settings_dict: Any +OVERRIDE_SETTINGS_PATH: Any +override_settings: Any + +def get_settings_value(key): ... diff --git a/python/helpers/typeshed/third_party/2and3/pynamodb/throttle.pyi b/python/helpers/typeshed/third_party/2and3/pynamodb/throttle.pyi new file mode 100644 index 000000000000..6948b6896ed9 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/pynamodb/throttle.pyi @@ -0,0 +1,19 @@ +from typing import Any, Optional + +log: Any + +class ThrottleBase: + capacity: Any + window: Any + records: Any + sleep_interval: Any + def __init__(self, capacity, window: int = ..., initial_sleep: Optional[Any] = ...) -> None: ... + def add_record(self, record): ... + def throttle(self): ... + +class NoThrottle(ThrottleBase): + def __init__(self) -> None: ... + def add_record(self, record): ... + +class Throttle(ThrottleBase): + def throttle(self): ... diff --git a/python/helpers/typeshed/third_party/2and3/pynamodb/types.pyi b/python/helpers/typeshed/third_party/2and3/pynamodb/types.pyi new file mode 100644 index 000000000000..14195f04f569 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/pynamodb/types.pyi @@ -0,0 +1,5 @@ +STRING: str +NUMBER: str +BINARY: str +HASH: str +RANGE: str diff --git a/python/helpers/typeshed/third_party/2and3/pytz/__init__.pyi b/python/helpers/typeshed/third_party/2and3/pytz/__init__.pyi index 2c2accd67559..e47caeac0755 100644 --- a/python/helpers/typeshed/third_party/2and3/pytz/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/pytz/__init__.pyi @@ -14,9 +14,9 @@ country_names = ... # type: Dict class _UTCclass(datetime.tzinfo): zone = ... # type: str def fromutc(self, dt: datetime.datetime) -> datetime.datetime: ... - def utcoffset(self, dt: Optional[datetime.datetime]) -> datetime.timedelta: ... # type: ignore + def utcoffset(self, dt: Optional[datetime.datetime]) -> datetime.timedelta: ... def tzname(self, dt: Optional[datetime.datetime]) -> str: ... - def dst(self, dt: Optional[datetime.datetime]) -> datetime.timedelta: ... # type: ignore + def dst(self, dt: Optional[datetime.datetime]) -> datetime.timedelta: ... def localize(self, dt: datetime.datetime, is_dst: bool = ...) -> datetime.datetime: ... def normalize(self, dt: datetime.datetime, is_dst: bool = ...) -> datetime.datetime: ... diff --git a/python/helpers/typeshed/third_party/2and3/pytz/lazy.pyi b/python/helpers/typeshed/third_party/2and3/pytz/lazy.pyi index 3618333e0ecc..795ed0427dfb 100644 --- a/python/helpers/typeshed/third_party/2and3/pytz/lazy.pyi +++ b/python/helpers/typeshed/third_party/2and3/pytz/lazy.pyi @@ -1,13 +1,14 @@ -# Stubs for pytz.lazy (Python 3.5) - -from typing import Any, Iterable, List, Set, Dict # NOQA +from typing import Iterator, List, Set, TypeVar from collections import Mapping -class LazyDict(Mapping): - pass +_T = TypeVar('_T') +_KT = TypeVar('_KT') +_VT = TypeVar('_VT') -class LazyList(List): - pass +class LazyDict(Mapping[_KT, _VT]): + def __getitem__(self, key: _KT) -> _VT: ... + def __iter__(self) -> Iterator[_KT]: ... + def __len__(self) -> int: ... -class LazySet(Set): - pass +class LazyList(List[_T]): ... +class LazySet(Set[_T]): ... diff --git a/python/helpers/typeshed/third_party/2and3/requests/adapters.pyi b/python/helpers/typeshed/third_party/2and3/requests/adapters.pyi index 81d021281960..7e6167c383af 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/adapters.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/adapters.pyi @@ -56,7 +56,7 @@ class HTTPAdapter(BaseAdapter): config = ... # type: Any proxy_manager = ... # type: Any def __init__(self, pool_connections=..., pool_maxsize=..., max_retries=..., - pool_block=...): ... + pool_block=...) -> None: ... poolmanager = ... # type: Any def init_poolmanager(self, connections, maxsize, block=..., **pool_kwargs): ... def proxy_manager_for(self, proxy, **proxy_kwargs): ... diff --git a/python/helpers/typeshed/third_party/2and3/requests/api.pyi b/python/helpers/typeshed/third_party/2and3/requests/api.pyi index 85afdc536f2c..865b4816899b 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/api.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/api.pyi @@ -20,7 +20,7 @@ def get(url: Union[Text, bytes], **kwargs) -> Response: ... def options(url: Union[str, Text], **kwargs) -> Response: ... def head(url: Union[str, Text], **kwargs) -> Response: ... -def post(url: Union[str, Text], data: _Data = ..., json: Optional[MutableMapping] = ..., **kwargs) -> Response: ... -def put(url: Union[str, Text], data: _Data = ..., **kwargs) -> Response: ... -def patch(url: Union[str, Text], data: _Data = ..., **kwargs) -> Response: ... +def post(url: Union[str, Text], data: _Data=..., json=..., **kwargs) -> Response: ... +def put(url: Union[str, Text], data: _Data=..., json=..., **kwargs) -> Response: ... +def patch(url: Union[str, Text], data: _Data=..., json=..., **kwargs) -> Response: ... def delete(url: Union[str, Text], **kwargs) -> Response: ... diff --git a/python/helpers/typeshed/third_party/2and3/requests/auth.pyi b/python/helpers/typeshed/third_party/2and3/requests/auth.pyi index 8eea2b0e0e49..b73aa7047ce1 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/auth.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/auth.pyi @@ -1,6 +1,6 @@ # Stubs for requests.auth (Python 3) -from typing import Any +from typing import Any, Text, Union from . import compat from . import cookies from . import utils @@ -14,6 +14,8 @@ codes = status_codes.codes CONTENT_TYPE_FORM_URLENCODED = ... # type: Any CONTENT_TYPE_MULTI_PART = ... # type: Any +def _basic_auth_str(username: Union[bytes, Text], password: Union[bytes, Text]) -> str: ... + class AuthBase: def __call__(self, r): ... diff --git a/python/helpers/typeshed/third_party/2and3/requests/models.pyi b/python/helpers/typeshed/third_party/2and3/requests/models.pyi index 265670fe8e42..18b16894c199 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/models.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/models.pyi @@ -76,7 +76,7 @@ class Request(RequestHooksMixin): auth = ... # type: Any cookies = ... # type: Any def __init__(self, method=..., url=..., headers=..., files=..., data=..., params=..., - auth=..., cookies=..., hooks=..., json=...): ... + auth=..., cookies=..., hooks=..., json=...) -> None: ... def prepare(self): ... class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/__init__.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/__init__.pyi index 2b1bff828132..b50dba35e4ae 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for requests.packages (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - class VendorAlias: def __init__(self, package_names) -> None: ... def find_module(self, fullname, path=...): ... diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/__init__.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/__init__.pyi index 61a1c5fe662e..185752789cae 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for requests.packages.urllib3 (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from . import connectionpool from . import filepost diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/_collections.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/_collections.pyi index 58aa944226ef..25d3f4d71db6 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/_collections.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/_collections.pyi @@ -1,7 +1,3 @@ -# Stubs for requests.packages.urllib3._collections (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from collections import MutableMapping diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/connectionpool.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/connectionpool.pyi index 778bb7cf9c04..c88ef2ea90a3 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/connectionpool.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/connectionpool.pyi @@ -1,7 +1,3 @@ -# Stubs for requests.packages.urllib3.connectionpool (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from . import exceptions from .packages import ssl_match_hostname diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/contrib/__init__.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/contrib/__init__.pyi index 69e47f704486..e69de29bb2d1 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/contrib/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/contrib/__init__.pyi @@ -1,3 +0,0 @@ -# Stubs for requests.packages.urllib3.contrib (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/exceptions.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/exceptions.pyi index 3e7d0f6c9882..8789e2ed2912 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/exceptions.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/exceptions.pyi @@ -1,7 +1,3 @@ -# Stubs for requests.packages.urllib3.exceptions (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class HTTPError(Exception): ... diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/filepost.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/filepost.pyi index f1ce51735679..2fab4169d5fb 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/filepost.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/filepost.pyi @@ -1,7 +1,3 @@ -# Stubs for requests.packages.urllib3.filepost (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from . import packages # from .packages import six diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/packages/__init__.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/packages/__init__.pyi index 67507f9a9869..e69de29bb2d1 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/packages/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/packages/__init__.pyi @@ -1,3 +0,0 @@ -# Stubs for requests.packages.urllib3.packages (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyi index 9efeac09e4b2..1915c0e5d00c 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for requests.packages.urllib3.packages.ssl_match_hostname (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - import ssl CertificateError = ssl.CertificateError diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.pyi index 5abbc9dd5c52..c21998013cf2 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.pyi @@ -1,7 +1,3 @@ -# Stubs for requests.packages.urllib3.packages.ssl_match_hostname._implementation (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - class CertificateError(ValueError): ... def match_hostname(cert, hostname): ... diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/poolmanager.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/poolmanager.pyi index a65f664973c3..21dbb4f4d7f9 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/poolmanager.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/poolmanager.pyi @@ -1,7 +1,3 @@ -# Stubs for requests.packages.urllib3.poolmanager (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from .request import RequestMethods diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/request.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/request.pyi index 788c759c5d51..a644c4e0f5b0 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/request.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/request.pyi @@ -1,7 +1,3 @@ -# Stubs for requests.packages.urllib3.request (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class RequestMethods: diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/response.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/response.pyi index b6f418a94cb3..aca950711120 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/response.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/response.pyi @@ -1,7 +1,3 @@ -# Stubs for requests.packages.urllib3.response (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, IO from . import _collections from . import exceptions diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/__init__.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/__init__.pyi index e4a0e138d1cc..53bdac9b9275 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for requests.packages.urllib3.util (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from . import connection from . import request from . import response diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/connection.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/connection.pyi index cd673098c1d4..5068a2270651 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/connection.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/connection.pyi @@ -1,11 +1,8 @@ -# Stubs for requests.packages.urllib3.util.connection (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any poll = ... # type: Any select = ... # type: Any +HAS_IPV6 = ... # type: bool def is_connection_dropped(conn): ... def create_connection(address, timeout=..., source_address=..., socket_options=...): ... diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/request.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/request.pyi index 0be64df25e72..0aeb5a8b1787 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/request.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/request.pyi @@ -1,7 +1,3 @@ -# Stubs for requests.packages.urllib3.util.request (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any # from ..packages import six diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/response.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/response.pyi index 761a00679554..30463da4e4de 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/response.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/response.pyi @@ -1,5 +1 @@ -# Stubs for requests.packages.urllib3.util.response (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - def is_fp_closed(obj): ... diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/retry.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/retry.pyi index e958d9061b06..e0793f8325fd 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/retry.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/retry.pyi @@ -1,7 +1,3 @@ -# Stubs for requests.packages.urllib3.util.retry (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from .. import exceptions from .. import packages diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/ssl_.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/ssl_.pyi index c7db0ace71a4..3d75f710974f 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/ssl_.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/ssl_.pyi @@ -1,7 +1,3 @@ -# Stubs for requests.packages.urllib3.util.ssl_ (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from .. import exceptions import ssl diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/timeout.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/timeout.pyi index 0a7653c5f0bb..760060d5bd8b 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/timeout.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/timeout.pyi @@ -1,7 +1,3 @@ -# Stubs for requests.packages.urllib3.util.timeout (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from .. import exceptions diff --git a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/url.pyi b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/url.pyi index 9877b4a17334..08f307aac408 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/url.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/packages/urllib3/util/url.pyi @@ -1,7 +1,3 @@ -# Stubs for requests.packages.urllib3.util.url (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from .. import exceptions diff --git a/python/helpers/typeshed/third_party/2and3/requests/status_codes.pyi b/python/helpers/typeshed/third_party/2and3/requests/status_codes.pyi index e3035eb9163a..02d5c62e9cd1 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/status_codes.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/status_codes.pyi @@ -1,7 +1,3 @@ -# Stubs for requests.status_codes (Python 3) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from .structures import LookupDict diff --git a/python/helpers/typeshed/third_party/2and3/requests/structures.pyi b/python/helpers/typeshed/third_party/2and3/requests/structures.pyi index 53af72d8f9a5..ad9044f2b544 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/structures.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/structures.pyi @@ -1,9 +1,12 @@ -# Stubs for requests.structures (Python 3) - from typing import Any, Iterator, MutableMapping, Text, Tuple, Union class CaseInsensitiveDict(MutableMapping[str, Union[Text, bytes]]): def lower_items(self) -> Iterator[Tuple[str, Union[Text, bytes]]]: ... + def __setitem__(self, key: str, value: Union[Text, bytes]) -> None: ... + def __getitem__(self, key: str) -> Union[Text, bytes]: ... + def __delitem__(self, key: str) -> None: ... + def __iter__(self) -> Iterator[str]: ... + def __len__(self) -> int: ... class LookupDict(dict): name = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2and3/typing_extensions.pyi b/python/helpers/typeshed/third_party/2and3/typing_extensions.pyi new file mode 100644 index 000000000000..23cb4af45a46 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/typing_extensions.pyi @@ -0,0 +1,33 @@ +import sys +import typing +from typing import ClassVar as ClassVar +from typing import ContextManager as ContextManager +from typing import Counter as Counter +from typing import DefaultDict as DefaultDict +from typing import Deque as Deque +from typing import NewType as NewType +from typing import NoReturn as NoReturn +from typing import overload as overload +from typing import Text as Text +from typing import Type as Type +from typing import TYPE_CHECKING as TYPE_CHECKING +from typing import TypeVar, Any + +_TC = TypeVar('_TC', bound=Type[object]) +class _SpecialForm: + def __getitem__(self, typeargs: Any) -> Any: ... +def runtime(cls: _TC) -> _TC: ... +Protocol: _SpecialForm = ... + +if sys.version_info >= (3, 3): + from typing import ChainMap as ChainMap + +if sys.version_info >= (3, 5): + from typing import AsyncIterable as AsyncIterable + from typing import AsyncIterator as AsyncIterator + from typing import AsyncContextManager as AsyncContextManager + from typing import Awaitable as Awaitable + from typing import Coroutine as Coroutine + +if sys.version_info >= (3, 6): + from typing import AsyncGenerator as AsyncGenerator diff --git a/python/helpers/typeshed/third_party/2and3/ujson.pyi b/python/helpers/typeshed/third_party/2and3/ujson.pyi index a982c8b7c1a3..4c8540d19581 100644 --- a/python/helpers/typeshed/third_party/2and3/ujson.pyi +++ b/python/helpers/typeshed/third_party/2and3/ujson.pyi @@ -7,7 +7,7 @@ __version__ = ... # type: str def encode( obj: Any, ensure_ascii: bool = ..., - double_precision: bool = ..., + double_precision: int = ..., encode_html_chars: bool = ..., escape_forward_slashes: bool = ..., sort_keys: bool = ..., @@ -17,7 +17,7 @@ def encode( def dumps( obj: Any, ensure_ascii: bool = ..., - double_precision: bool = ..., + double_precision: int = ..., encode_html_chars: bool = ..., escape_forward_slashes: bool = ..., sort_keys: bool = ..., @@ -28,7 +28,7 @@ def dump( obj: Any, fp: IO[str], ensure_ascii: bool = ..., - double_precision: bool = ..., + double_precision: int = ..., encode_html_chars: bool = ..., escape_forward_slashes: bool = ..., sort_keys: bool = ..., diff --git a/python/helpers/typeshed/third_party/2and3/yaml/__init__.pyi b/python/helpers/typeshed/third_party/2and3/yaml/__init__.pyi new file mode 100644 index 000000000000..8f2edec5804f --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/yaml/__init__.pyi @@ -0,0 +1,47 @@ +from typing import Any +from yaml.error import * # noqa: F403 +from yaml.tokens import * # noqa: F403 +from yaml.events import * # noqa: F403 +from yaml.nodes import * # noqa: F403 +from yaml.loader import * # noqa: F403 +from yaml.dumper import * # noqa: F403 +# TODO: stubs for cyaml? +# from cyaml import * + +__with_libyaml__ = ... # type: Any + +def scan(stream, Loader=...): ... +def parse(stream, Loader=...): ... +def compose(stream, Loader=...): ... +def compose_all(stream, Loader=...): ... +def load(stream, Loader=...): ... +def load_all(stream, Loader=...): ... +def safe_load(stream): ... +def safe_load_all(stream): ... +def emit(events, stream=..., Dumper=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=...): ... +def serialize_all(nodes, stream=..., Dumper=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=...): ... +def serialize(node, stream=..., Dumper=..., **kwds): ... +def dump_all(documents, stream=..., Dumper=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=...): ... +def dump(data, stream=..., Dumper=..., **kwds): ... +def safe_dump_all(documents, stream=..., **kwds): ... +def safe_dump(data, stream=..., **kwds): ... +def add_implicit_resolver(tag, regexp, first=..., Loader=..., Dumper=...): ... +def add_path_resolver(tag, path, kind=..., Loader=..., Dumper=...): ... +def add_constructor(tag, constructor, Loader=...): ... +def add_multi_constructor(tag_prefix, multi_constructor, Loader=...): ... +def add_representer(data_type, representer, Dumper=...): ... +def add_multi_representer(data_type, multi_representer, Dumper=...): ... + +class YAMLObjectMetaclass(type): + def __init__(cls, name, bases, kwds) -> None: ... + +class YAMLObject: + __metaclass__ = YAMLObjectMetaclass + yaml_loader = ... # type: Any + yaml_dumper = ... # type: Any + yaml_tag = ... # type: Any + yaml_flow_style = ... # type: Any + @classmethod + def from_yaml(cls, loader, node): ... + @classmethod + def to_yaml(cls, dumper, data): ... diff --git a/python/helpers/typeshed/third_party/2and3/yaml/composer.pyi b/python/helpers/typeshed/third_party/2and3/yaml/composer.pyi new file mode 100644 index 000000000000..20719e053c97 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/yaml/composer.pyi @@ -0,0 +1,17 @@ +from typing import Any +from yaml.error import Mark, YAMLError, MarkedYAMLError +from yaml.nodes import Node, ScalarNode, CollectionNode, SequenceNode, MappingNode + +class ComposerError(MarkedYAMLError): ... + +class Composer: + anchors = ... # type: Any + def __init__(self) -> None: ... + def check_node(self): ... + def get_node(self): ... + def get_single_node(self): ... + def compose_document(self): ... + def compose_node(self, parent, index): ... + def compose_scalar_node(self, anchor): ... + def compose_sequence_node(self, anchor): ... + def compose_mapping_node(self, anchor): ... diff --git a/python/helpers/typeshed/third_party/2and3/yaml/constructor.pyi b/python/helpers/typeshed/third_party/2and3/yaml/constructor.pyi new file mode 100644 index 000000000000..40e9ea2f859c --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/yaml/constructor.pyi @@ -0,0 +1,68 @@ +from yaml.error import Mark, YAMLError, MarkedYAMLError +from yaml.nodes import Node, ScalarNode, CollectionNode, SequenceNode, MappingNode + +from typing import Any + +class ConstructorError(MarkedYAMLError): ... + +class BaseConstructor: + yaml_constructors = ... # type: Any + yaml_multi_constructors = ... # type: Any + constructed_objects = ... # type: Any + recursive_objects = ... # type: Any + state_generators = ... # type: Any + deep_construct = ... # type: Any + def __init__(self) -> None: ... + def check_data(self): ... + def get_data(self): ... + def get_single_data(self): ... + def construct_document(self, node): ... + def construct_object(self, node, deep=...): ... + def construct_scalar(self, node): ... + def construct_sequence(self, node, deep=...): ... + def construct_mapping(self, node, deep=...): ... + def construct_pairs(self, node, deep=...): ... + @classmethod + def add_constructor(cls, tag, constructor): ... + @classmethod + def add_multi_constructor(cls, tag_prefix, multi_constructor): ... + +class SafeConstructor(BaseConstructor): + def construct_scalar(self, node): ... + def flatten_mapping(self, node): ... + def construct_mapping(self, node, deep=...): ... + def construct_yaml_null(self, node): ... + bool_values = ... # type: Any + def construct_yaml_bool(self, node): ... + def construct_yaml_int(self, node): ... + inf_value = ... # type: Any + nan_value = ... # type: Any + def construct_yaml_float(self, node): ... + def construct_yaml_binary(self, node): ... + timestamp_regexp = ... # type: Any + def construct_yaml_timestamp(self, node): ... + def construct_yaml_omap(self, node): ... + def construct_yaml_pairs(self, node): ... + def construct_yaml_set(self, node): ... + def construct_yaml_str(self, node): ... + def construct_yaml_seq(self, node): ... + def construct_yaml_map(self, node): ... + def construct_yaml_object(self, node, cls): ... + def construct_undefined(self, node): ... + +class Constructor(SafeConstructor): + def construct_python_str(self, node): ... + def construct_python_unicode(self, node): ... + def construct_python_long(self, node): ... + def construct_python_complex(self, node): ... + def construct_python_tuple(self, node): ... + def find_python_module(self, name, mark): ... + def find_python_name(self, name, mark): ... + def construct_python_name(self, suffix, node): ... + def construct_python_module(self, suffix, node): ... + class classobj: ... + def make_python_instance(self, suffix, node, args=..., kwds=..., newobj=...): ... + def set_python_instance_state(self, instance, state): ... + def construct_python_object(self, suffix, node): ... + def construct_python_object_apply(self, suffix, node, newobj=...): ... + def construct_python_object_new(self, suffix, node): ... diff --git a/python/helpers/typeshed/third_party/2and3/yaml/dumper.pyi b/python/helpers/typeshed/third_party/2and3/yaml/dumper.pyi new file mode 100644 index 000000000000..0586f1313ef1 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/yaml/dumper.pyi @@ -0,0 +1,13 @@ +from yaml.emitter import Emitter +from yaml.serializer import Serializer +from yaml.representer import BaseRepresenter, Representer, SafeRepresenter +from yaml.resolver import BaseResolver, Resolver + +class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): + def __init__(self, stream, default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> None: ... + +class SafeDumper(Emitter, Serializer, SafeRepresenter, Resolver): + def __init__(self, stream, default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> None: ... + +class Dumper(Emitter, Serializer, Representer, Resolver): + def __init__(self, stream, default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> None: ... diff --git a/python/helpers/typeshed/third_party/2and3/yaml/emitter.pyi b/python/helpers/typeshed/third_party/2and3/yaml/emitter.pyi new file mode 100644 index 000000000000..a090c6d87306 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/yaml/emitter.pyi @@ -0,0 +1,106 @@ +from typing import Any +from yaml.error import YAMLError + +class EmitterError(YAMLError): ... + +class ScalarAnalysis: + scalar = ... # type: Any + empty = ... # type: Any + multiline = ... # type: Any + allow_flow_plain = ... # type: Any + allow_block_plain = ... # type: Any + allow_single_quoted = ... # type: Any + allow_double_quoted = ... # type: Any + allow_block = ... # type: Any + def __init__(self, scalar, empty, multiline, allow_flow_plain, allow_block_plain, allow_single_quoted, allow_double_quoted, allow_block) -> None: ... + +class Emitter: + DEFAULT_TAG_PREFIXES = ... # type: Any + stream = ... # type: Any + encoding = ... # type: Any + states = ... # type: Any + state = ... # type: Any + events = ... # type: Any + event = ... # type: Any + indents = ... # type: Any + indent = ... # type: Any + flow_level = ... # type: Any + root_context = ... # type: Any + sequence_context = ... # type: Any + mapping_context = ... # type: Any + simple_key_context = ... # type: Any + line = ... # type: Any + column = ... # type: Any + whitespace = ... # type: Any + indention = ... # type: Any + open_ended = ... # type: Any + canonical = ... # type: Any + allow_unicode = ... # type: Any + best_indent = ... # type: Any + best_width = ... # type: Any + best_line_break = ... # type: Any + tag_prefixes = ... # type: Any + prepared_anchor = ... # type: Any + prepared_tag = ... # type: Any + analysis = ... # type: Any + style = ... # type: Any + def __init__(self, stream, canonical=..., indent=..., width=..., allow_unicode=..., line_break=...) -> None: ... + def dispose(self): ... + def emit(self, event): ... + def need_more_events(self): ... + def need_events(self, count): ... + def increase_indent(self, flow=..., indentless=...): ... + def expect_stream_start(self): ... + def expect_nothing(self): ... + def expect_first_document_start(self): ... + def expect_document_start(self, first=...): ... + def expect_document_end(self): ... + def expect_document_root(self): ... + def expect_node(self, root=..., sequence=..., mapping=..., simple_key=...): ... + def expect_alias(self): ... + def expect_scalar(self): ... + def expect_flow_sequence(self): ... + def expect_first_flow_sequence_item(self): ... + def expect_flow_sequence_item(self): ... + def expect_flow_mapping(self): ... + def expect_first_flow_mapping_key(self): ... + def expect_flow_mapping_key(self): ... + def expect_flow_mapping_simple_value(self): ... + def expect_flow_mapping_value(self): ... + def expect_block_sequence(self): ... + def expect_first_block_sequence_item(self): ... + def expect_block_sequence_item(self, first=...): ... + def expect_block_mapping(self): ... + def expect_first_block_mapping_key(self): ... + def expect_block_mapping_key(self, first=...): ... + def expect_block_mapping_simple_value(self): ... + def expect_block_mapping_value(self): ... + def check_empty_sequence(self): ... + def check_empty_mapping(self): ... + def check_empty_document(self): ... + def check_simple_key(self): ... + def process_anchor(self, indicator): ... + def process_tag(self): ... + def choose_scalar_style(self): ... + def process_scalar(self): ... + def prepare_version(self, version): ... + def prepare_tag_handle(self, handle): ... + def prepare_tag_prefix(self, prefix): ... + def prepare_tag(self, tag): ... + def prepare_anchor(self, anchor): ... + def analyze_scalar(self, scalar): ... + def flush_stream(self): ... + def write_stream_start(self): ... + def write_stream_end(self): ... + def write_indicator(self, indicator, need_whitespace, whitespace=..., indention=...): ... + def write_indent(self): ... + def write_line_break(self, data=...): ... + def write_version_directive(self, version_text): ... + def write_tag_directive(self, handle_text, prefix_text): ... + def write_single_quoted(self, text, split=...): ... + ESCAPE_REPLACEMENTS = ... # type: Any + def write_double_quoted(self, text, split=...): ... + def determine_block_hints(self, text): ... + def write_folded(self, text): ... + def write_literal(self, text): ... + def write_plain(self, text, split=...): ... diff --git a/python/helpers/typeshed/third_party/2and3/yaml/error.pyi b/python/helpers/typeshed/third_party/2and3/yaml/error.pyi new file mode 100644 index 000000000000..4e799df4889b --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/yaml/error.pyi @@ -0,0 +1,21 @@ +from typing import Any + +class Mark: + name = ... # type: Any + index = ... # type: Any + line = ... # type: Any + column = ... # type: Any + buffer = ... # type: Any + pointer = ... # type: Any + def __init__(self, name, index, line, column, buffer, pointer) -> None: ... + def get_snippet(self, indent=..., max_length=...): ... + +class YAMLError(Exception): ... + +class MarkedYAMLError(YAMLError): + context = ... # type: Any + context_mark = ... # type: Any + problem = ... # type: Any + problem_mark = ... # type: Any + note = ... # type: Any + def __init__(self, context=..., context_mark=..., problem=..., problem_mark=..., note=...) -> None: ... diff --git a/python/helpers/typeshed/third_party/2and3/yaml/events.pyi b/python/helpers/typeshed/third_party/2and3/yaml/events.pyi new file mode 100644 index 000000000000..4c055c7757ea --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/yaml/events.pyi @@ -0,0 +1,62 @@ +from typing import Any + +class Event: + start_mark = ... # type: Any + end_mark = ... # type: Any + def __init__(self, start_mark=..., end_mark=...) -> None: ... + +class NodeEvent(Event): + anchor = ... # type: Any + start_mark = ... # type: Any + end_mark = ... # type: Any + def __init__(self, anchor, start_mark=..., end_mark=...) -> None: ... + +class CollectionStartEvent(NodeEvent): + anchor = ... # type: Any + tag = ... # type: Any + implicit = ... # type: Any + start_mark = ... # type: Any + end_mark = ... # type: Any + flow_style = ... # type: Any + def __init__(self, anchor, tag, implicit, start_mark=..., end_mark=..., flow_style=...) -> None: ... + +class CollectionEndEvent(Event): ... + +class StreamStartEvent(Event): + start_mark = ... # type: Any + end_mark = ... # type: Any + encoding = ... # type: Any + def __init__(self, start_mark=..., end_mark=..., encoding=...) -> None: ... + +class StreamEndEvent(Event): ... + +class DocumentStartEvent(Event): + start_mark = ... # type: Any + end_mark = ... # type: Any + explicit = ... # type: Any + version = ... # type: Any + tags = ... # type: Any + def __init__(self, start_mark=..., end_mark=..., explicit=..., version=..., tags=...) -> None: ... + +class DocumentEndEvent(Event): + start_mark = ... # type: Any + end_mark = ... # type: Any + explicit = ... # type: Any + def __init__(self, start_mark=..., end_mark=..., explicit=...) -> None: ... + +class AliasEvent(NodeEvent): ... + +class ScalarEvent(NodeEvent): + anchor = ... # type: Any + tag = ... # type: Any + implicit = ... # type: Any + value = ... # type: Any + start_mark = ... # type: Any + end_mark = ... # type: Any + style = ... # type: Any + def __init__(self, anchor, tag, implicit, value, start_mark=..., end_mark=..., style=...) -> None: ... + +class SequenceStartEvent(CollectionStartEvent): ... +class SequenceEndEvent(CollectionEndEvent): ... +class MappingStartEvent(CollectionStartEvent): ... +class MappingEndEvent(CollectionEndEvent): ... diff --git a/python/helpers/typeshed/third_party/2and3/yaml/loader.pyi b/python/helpers/typeshed/third_party/2and3/yaml/loader.pyi new file mode 100644 index 000000000000..0e9afeac1b81 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/yaml/loader.pyi @@ -0,0 +1,15 @@ +from yaml.reader import Reader +from yaml.scanner import Scanner +from yaml.parser import Parser +from yaml.composer import Composer +from yaml.constructor import BaseConstructor, SafeConstructor, Constructor +from yaml.resolver import BaseResolver, Resolver + +class BaseLoader(Reader, Scanner, Parser, Composer, BaseConstructor, BaseResolver): + def __init__(self, stream) -> None: ... + +class SafeLoader(Reader, Scanner, Parser, Composer, SafeConstructor, Resolver): + def __init__(self, stream) -> None: ... + +class Loader(Reader, Scanner, Parser, Composer, Constructor, Resolver): + def __init__(self, stream) -> None: ... diff --git a/python/helpers/typeshed/third_party/2and3/yaml/nodes.pyi b/python/helpers/typeshed/third_party/2and3/yaml/nodes.pyi new file mode 100644 index 000000000000..6e3836e79853 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/yaml/nodes.pyi @@ -0,0 +1,31 @@ +from typing import Any + +class Node: + tag = ... # type: Any + value = ... # type: Any + start_mark = ... # type: Any + end_mark = ... # type: Any + def __init__(self, tag, value, start_mark, end_mark) -> None: ... + +class ScalarNode(Node): + id = ... # type: Any + tag = ... # type: Any + value = ... # type: Any + start_mark = ... # type: Any + end_mark = ... # type: Any + style = ... # type: Any + def __init__(self, tag, value, start_mark=..., end_mark=..., style=...) -> None: ... + +class CollectionNode(Node): + tag = ... # type: Any + value = ... # type: Any + start_mark = ... # type: Any + end_mark = ... # type: Any + flow_style = ... # type: Any + def __init__(self, tag, value, start_mark=..., end_mark=..., flow_style=...) -> None: ... + +class SequenceNode(CollectionNode): + id = ... # type: Any + +class MappingNode(CollectionNode): + id = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2and3/yaml/parser.pyi b/python/helpers/typeshed/third_party/2and3/yaml/parser.pyi new file mode 100644 index 000000000000..094a4ea943a5 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/yaml/parser.pyi @@ -0,0 +1,44 @@ +from typing import Any +from yaml.error import MarkedYAMLError + +class ParserError(MarkedYAMLError): ... + +class Parser: + DEFAULT_TAGS = ... # type: Any + current_event = ... # type: Any + yaml_version = ... # type: Any + tag_handles = ... # type: Any + states = ... # type: Any + marks = ... # type: Any + state = ... # type: Any + def __init__(self) -> None: ... + def dispose(self): ... + def check_event(self, *choices): ... + def peek_event(self): ... + def get_event(self): ... + def parse_stream_start(self): ... + def parse_implicit_document_start(self): ... + def parse_document_start(self): ... + def parse_document_end(self): ... + def parse_document_content(self): ... + def process_directives(self): ... + def parse_block_node(self): ... + def parse_flow_node(self): ... + def parse_block_node_or_indentless_sequence(self): ... + def parse_node(self, block=..., indentless_sequence=...): ... + def parse_block_sequence_first_entry(self): ... + def parse_block_sequence_entry(self): ... + def parse_indentless_sequence_entry(self): ... + def parse_block_mapping_first_key(self): ... + def parse_block_mapping_key(self): ... + def parse_block_mapping_value(self): ... + def parse_flow_sequence_first_entry(self): ... + def parse_flow_sequence_entry(self, first=...): ... + def parse_flow_sequence_entry_mapping_key(self): ... + def parse_flow_sequence_entry_mapping_value(self): ... + def parse_flow_sequence_entry_mapping_end(self): ... + def parse_flow_mapping_first_key(self): ... + def parse_flow_mapping_key(self, first=...): ... + def parse_flow_mapping_value(self): ... + def parse_flow_mapping_empty_value(self): ... + def process_empty_scalar(self, mark): ... diff --git a/python/helpers/typeshed/third_party/2and3/yaml/reader.pyi b/python/helpers/typeshed/third_party/2and3/yaml/reader.pyi new file mode 100644 index 000000000000..9b08631ec09b --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/yaml/reader.pyi @@ -0,0 +1,34 @@ +from typing import Any +from yaml.error import YAMLError + +class ReaderError(YAMLError): + name = ... # type: Any + character = ... # type: Any + position = ... # type: Any + encoding = ... # type: Any + reason = ... # type: Any + def __init__(self, name, position, character, encoding, reason) -> None: ... + +class Reader: + name = ... # type: Any + stream = ... # type: Any + stream_pointer = ... # type: Any + eof = ... # type: Any + buffer = ... # type: Any + pointer = ... # type: Any + raw_buffer = ... # type: Any + raw_decode = ... # type: Any + encoding = ... # type: Any + index = ... # type: Any + line = ... # type: Any + column = ... # type: Any + def __init__(self, stream) -> None: ... + def peek(self, index=...): ... + def prefix(self, length=...): ... + def forward(self, length=...): ... + def get_mark(self): ... + def determine_encoding(self): ... + NON_PRINTABLE = ... # type: Any + def check_printable(self, data): ... + def update(self, length): ... + def update_raw(self, size=...): ... diff --git a/python/helpers/typeshed/third_party/2and3/yaml/representer.pyi b/python/helpers/typeshed/third_party/2and3/yaml/representer.pyi new file mode 100644 index 000000000000..b10f36de7e08 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/yaml/representer.pyi @@ -0,0 +1,54 @@ +from typing import Any +from yaml.error import YAMLError + +class RepresenterError(YAMLError): ... + +class BaseRepresenter: + yaml_representers = ... # type: Any + yaml_multi_representers = ... # type: Any + default_style = ... # type: Any + default_flow_style = ... # type: Any + represented_objects = ... # type: Any + object_keeper = ... # type: Any + alias_key = ... # type: Any + def __init__(self, default_style=..., default_flow_style=...) -> None: ... + def represent(self, data): ... + def get_classobj_bases(self, cls): ... + def represent_data(self, data): ... + @classmethod + def add_representer(cls, data_type, representer): ... + @classmethod + def add_multi_representer(cls, data_type, representer): ... + def represent_scalar(self, tag, value, style=...): ... + def represent_sequence(self, tag, sequence, flow_style=...): ... + def represent_mapping(self, tag, mapping, flow_style=...): ... + def ignore_aliases(self, data): ... + +class SafeRepresenter(BaseRepresenter): + def ignore_aliases(self, data): ... + def represent_none(self, data): ... + def represent_str(self, data): ... + def represent_unicode(self, data): ... + def represent_bool(self, data): ... + def represent_int(self, data): ... + def represent_long(self, data): ... + inf_value = ... # type: Any + def represent_float(self, data): ... + def represent_list(self, data): ... + def represent_dict(self, data): ... + def represent_set(self, data): ... + def represent_date(self, data): ... + def represent_datetime(self, data): ... + def represent_yaml_object(self, tag, data, cls, flow_style=...): ... + def represent_undefined(self, data): ... + +class Representer(SafeRepresenter): + def represent_str(self, data): ... + def represent_unicode(self, data): ... + def represent_long(self, data): ... + def represent_complex(self, data): ... + def represent_tuple(self, data): ... + def represent_name(self, data): ... + def represent_module(self, data): ... + def represent_instance(self, data): ... + def represent_object(self, data): ... diff --git a/python/helpers/typeshed/third_party/2and3/yaml/resolver.pyi b/python/helpers/typeshed/third_party/2and3/yaml/resolver.pyi new file mode 100644 index 000000000000..0b5641e20ec6 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/yaml/resolver.pyi @@ -0,0 +1,24 @@ +from typing import Any +from yaml.error import YAMLError + +class ResolverError(YAMLError): ... + +class BaseResolver: + DEFAULT_SCALAR_TAG = ... # type: Any + DEFAULT_SEQUENCE_TAG = ... # type: Any + DEFAULT_MAPPING_TAG = ... # type: Any + yaml_implicit_resolvers = ... # type: Any + yaml_path_resolvers = ... # type: Any + resolver_exact_paths = ... # type: Any + resolver_prefix_paths = ... # type: Any + def __init__(self) -> None: ... + @classmethod + def add_implicit_resolver(cls, tag, regexp, first): ... + @classmethod + def add_path_resolver(cls, tag, path, kind=...): ... + def descend_resolver(self, current_node, current_index): ... + def ascend_resolver(self): ... + def check_resolver_prefix(self, depth, path, kind, current_node, current_index): ... + def resolve(self, kind, value, implicit): ... + +class Resolver(BaseResolver): ... diff --git a/python/helpers/typeshed/third_party/2and3/yaml/scanner.pyi b/python/helpers/typeshed/third_party/2and3/yaml/scanner.pyi new file mode 100644 index 000000000000..81acb5863281 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/yaml/scanner.pyi @@ -0,0 +1,96 @@ +from typing import Any +from yaml.error import MarkedYAMLError + +class ScannerError(MarkedYAMLError): ... + +class SimpleKey: + token_number = ... # type: Any + required = ... # type: Any + index = ... # type: Any + line = ... # type: Any + column = ... # type: Any + mark = ... # type: Any + def __init__(self, token_number, required, index, line, column, mark) -> None: ... + +class Scanner: + done = ... # type: Any + flow_level = ... # type: Any + tokens = ... # type: Any + tokens_taken = ... # type: Any + indent = ... # type: Any + indents = ... # type: Any + allow_simple_key = ... # type: Any + possible_simple_keys = ... # type: Any + def __init__(self) -> None: ... + def check_token(self, *choices): ... + def peek_token(self): ... + def get_token(self): ... + def need_more_tokens(self): ... + def fetch_more_tokens(self): ... + def next_possible_simple_key(self): ... + def stale_possible_simple_keys(self): ... + def save_possible_simple_key(self): ... + def remove_possible_simple_key(self): ... + def unwind_indent(self, column): ... + def add_indent(self, column): ... + def fetch_stream_start(self): ... + def fetch_stream_end(self): ... + def fetch_directive(self): ... + def fetch_document_start(self): ... + def fetch_document_end(self): ... + def fetch_document_indicator(self, TokenClass): ... + def fetch_flow_sequence_start(self): ... + def fetch_flow_mapping_start(self): ... + def fetch_flow_collection_start(self, TokenClass): ... + def fetch_flow_sequence_end(self): ... + def fetch_flow_mapping_end(self): ... + def fetch_flow_collection_end(self, TokenClass): ... + def fetch_flow_entry(self): ... + def fetch_block_entry(self): ... + def fetch_key(self): ... + def fetch_value(self): ... + def fetch_alias(self): ... + def fetch_anchor(self): ... + def fetch_tag(self): ... + def fetch_literal(self): ... + def fetch_folded(self): ... + def fetch_block_scalar(self, style): ... + def fetch_single(self): ... + def fetch_double(self): ... + def fetch_flow_scalar(self, style): ... + def fetch_plain(self): ... + def check_directive(self): ... + def check_document_start(self): ... + def check_document_end(self): ... + def check_block_entry(self): ... + def check_key(self): ... + def check_value(self): ... + def check_plain(self): ... + def scan_to_next_token(self): ... + def scan_directive(self): ... + def scan_directive_name(self, start_mark): ... + def scan_yaml_directive_value(self, start_mark): ... + def scan_yaml_directive_number(self, start_mark): ... + def scan_tag_directive_value(self, start_mark): ... + def scan_tag_directive_handle(self, start_mark): ... + def scan_tag_directive_prefix(self, start_mark): ... + def scan_directive_ignored_line(self, start_mark): ... + def scan_anchor(self, TokenClass): ... + def scan_tag(self): ... + def scan_block_scalar(self, style): ... + def scan_block_scalar_indicators(self, start_mark): ... + def scan_block_scalar_ignored_line(self, start_mark): ... + def scan_block_scalar_indentation(self): ... + def scan_block_scalar_breaks(self, indent): ... + def scan_flow_scalar(self, style): ... + ESCAPE_REPLACEMENTS = ... # type: Any + ESCAPE_CODES = ... # type: Any + def scan_flow_scalar_non_spaces(self, double, start_mark): ... + def scan_flow_scalar_spaces(self, double, start_mark): ... + def scan_flow_scalar_breaks(self, double, start_mark): ... + def scan_plain(self): ... + def scan_plain_spaces(self, indent, start_mark): ... + def scan_tag_handle(self, name, start_mark): ... + def scan_tag_uri(self, name, start_mark): ... + def scan_uri_escapes(self, name, start_mark): ... + def scan_line_break(self): ... diff --git a/python/helpers/typeshed/third_party/2and3/yaml/serializer.pyi b/python/helpers/typeshed/third_party/2and3/yaml/serializer.pyi new file mode 100644 index 000000000000..c6cdb4985a10 --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/yaml/serializer.pyi @@ -0,0 +1,23 @@ +from typing import Any +from yaml.error import YAMLError + +class SerializerError(YAMLError): ... + +class Serializer: + ANCHOR_TEMPLATE = ... # type: Any + use_encoding = ... # type: Any + use_explicit_start = ... # type: Any + use_explicit_end = ... # type: Any + use_version = ... # type: Any + use_tags = ... # type: Any + serialized_nodes = ... # type: Any + anchors = ... # type: Any + last_anchor_id = ... # type: Any + closed = ... # type: Any + def __init__(self, encoding=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> None: ... + def open(self): ... + def close(self): ... + def serialize(self, node): ... + def anchor_node(self, node): ... + def generate_anchor(self, node): ... + def serialize_node(self, node, parent, index): ... diff --git a/python/helpers/typeshed/third_party/2and3/yaml/tokens.pyi b/python/helpers/typeshed/third_party/2and3/yaml/tokens.pyi new file mode 100644 index 000000000000..a25cbe53035d --- /dev/null +++ b/python/helpers/typeshed/third_party/2and3/yaml/tokens.pyi @@ -0,0 +1,93 @@ +from typing import Any + +class Token: + start_mark = ... # type: Any + end_mark = ... # type: Any + def __init__(self, start_mark, end_mark) -> None: ... + +class DirectiveToken(Token): + id = ... # type: Any + name = ... # type: Any + value = ... # type: Any + start_mark = ... # type: Any + end_mark = ... # type: Any + def __init__(self, name, value, start_mark, end_mark) -> None: ... + +class DocumentStartToken(Token): + id = ... # type: Any + +class DocumentEndToken(Token): + id = ... # type: Any + +class StreamStartToken(Token): + id = ... # type: Any + start_mark = ... # type: Any + end_mark = ... # type: Any + encoding = ... # type: Any + def __init__(self, start_mark=..., end_mark=..., encoding=...) -> None: ... + +class StreamEndToken(Token): + id = ... # type: Any + +class BlockSequenceStartToken(Token): + id = ... # type: Any + +class BlockMappingStartToken(Token): + id = ... # type: Any + +class BlockEndToken(Token): + id = ... # type: Any + +class FlowSequenceStartToken(Token): + id = ... # type: Any + +class FlowMappingStartToken(Token): + id = ... # type: Any + +class FlowSequenceEndToken(Token): + id = ... # type: Any + +class FlowMappingEndToken(Token): + id = ... # type: Any + +class KeyToken(Token): + id = ... # type: Any + +class ValueToken(Token): + id = ... # type: Any + +class BlockEntryToken(Token): + id = ... # type: Any + +class FlowEntryToken(Token): + id = ... # type: Any + +class AliasToken(Token): + id = ... # type: Any + value = ... # type: Any + start_mark = ... # type: Any + end_mark = ... # type: Any + def __init__(self, value, start_mark, end_mark) -> None: ... + +class AnchorToken(Token): + id = ... # type: Any + value = ... # type: Any + start_mark = ... # type: Any + end_mark = ... # type: Any + def __init__(self, value, start_mark, end_mark) -> None: ... + +class TagToken(Token): + id = ... # type: Any + value = ... # type: Any + start_mark = ... # type: Any + end_mark = ... # type: Any + def __init__(self, value, start_mark, end_mark) -> None: ... + +class ScalarToken(Token): + id = ... # type: Any + value = ... # type: Any + plain = ... # type: Any + start_mark = ... # type: Any + end_mark = ... # type: Any + style = ... # type: Any + def __init__(self, value, plain, start_mark, end_mark, style=...) -> None: ... diff --git a/python/helpers/typeshed/third_party/3/dateutil/tz/__init__.pyi b/python/helpers/typeshed/third_party/3/dateutil/tz/__init__.pyi index 30a7ab3391c3..4c8a6d2d1b25 100644 --- a/python/helpers/typeshed/third_party/3/dateutil/tz/__init__.pyi +++ b/python/helpers/typeshed/third_party/3/dateutil/tz/__init__.pyi @@ -1,5 +1 @@ -# Stubs for dateutil.tz (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from .tz import tzutc, tzoffset, tzlocal, tzfile, tzrange, tzstr, tzical, gettz, datetime_exists, datetime_ambiguous diff --git a/python/helpers/typeshed/third_party/3/dateutil/tz/_common.pyi b/python/helpers/typeshed/third_party/3/dateutil/tz/_common.pyi index a190c54fde0d..383218d602ac 100644 --- a/python/helpers/typeshed/third_party/3/dateutil/tz/_common.pyi +++ b/python/helpers/typeshed/third_party/3/dateutil/tz/_common.pyi @@ -1,7 +1,3 @@ -# Stubs for dateutil.tz._common (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional from datetime import datetime, tzinfo, timedelta 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 8564270e1a61..e693db3bd967 100644 --- a/python/helpers/typeshed/third_party/3/dateutil/tz/tz.pyi +++ b/python/helpers/typeshed/third_party/3/dateutil/tz/tz.pyi @@ -1,7 +1,3 @@ -# Stubs for dateutil.tz.tz (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any, Optional, Union, IO, Tuple, List import datetime from ._common import tzname_in_python2 as tzname_in_python2, _tzinfo as _tzinfo diff --git a/python/helpers/typeshed/third_party/3/itsdangerous.pyi b/python/helpers/typeshed/third_party/3/itsdangerous.pyi index f90e4630a411..4ed0402e9805 100644 --- a/python/helpers/typeshed/third_party/3/itsdangerous.pyi +++ b/python/helpers/typeshed/third_party/3/itsdangerous.pyi @@ -1,7 +1,3 @@ -# Stubs for itsdangerous (Python 3) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from datetime import datetime from typing import Any, Callable, IO, MutableMapping, Optional, Text, Tuple, TypeVar, Union @@ -128,7 +124,7 @@ class JSONWebSignatureSerializer(Serializer): algorithm_name = ... # type: str algorithm = ... # type: Any def __init__(self, secret_key: _can_become_bytes, salt: Optional[_can_become_bytes]=None, serializer: _serializer=None, signer: Optional[Callable[..., Signer]]=None, signer_kwargs: Optional[MutableMapping]=None, algorithm_name: Optional[str]=None) -> None: ... - def load_payload(self, payload: Any, return_header: bool=False) -> Any: ... + def load_payload(self, payload: Any, serializer: _serializer = None, return_header: bool=False) -> Any: ... def dump_payload(self, *args, **kwargs) -> bytes: ... def make_algorithm(self, algorithm_name: str) -> SigningAlgorithm: ... def make_signer(self, salt: Optional[_can_become_bytes]=None, algorithm_name: Optional[str]=None) -> Signer: ... diff --git a/python/helpers/typeshed/third_party/3/jwt/__init__.pyi b/python/helpers/typeshed/third_party/3/jwt/__init__.pyi new file mode 100644 index 000000000000..3161c91425f8 --- /dev/null +++ b/python/helpers/typeshed/third_party/3/jwt/__init__.pyi @@ -0,0 +1,41 @@ +from typing import Mapping, Any, Optional, Union + +from . import algorithms + +def decode(jwt: Union[str, bytes], key: Union[str, bytes] = ..., + verify: bool = ..., algorithms: Optional[Any] = ..., + options: Optional[Mapping[Any, Any]] = ..., + **kwargs: Any) -> Mapping[str, Any]: ... + +def encode(payload: Mapping[str, Any], key: Union[str, bytes], + algorithm: str = ..., headers: Optional[Mapping[str, Any]] = ..., + json_encoder: Optional[Any] = ...) -> bytes: ... + +def register_algorithm(alg_id: str, + alg_obj: algorithms.Algorithm) -> None: ... + +def unregister_algorithm(alg_id: str) -> None: ... + +class InvalidTokenError(Exception): pass +class DecodeError(InvalidTokenError): pass +class ExpiredSignatureError(InvalidTokenError): pass +class InvalidAudienceError(InvalidTokenError): pass +class InvalidIssuerError(InvalidTokenError): pass +class InvalidIssuedAtError(InvalidTokenError): pass +class ImmatureSignatureError(InvalidTokenError): pass +class InvalidKeyError(Exception): pass +class InvalidAlgorithmError(InvalidTokenError): pass +class MissingRequiredClaimError(InvalidTokenError): ... + +# Compatibility aliases (deprecated) +ExpiredSignature = ExpiredSignatureError +InvalidAudience = InvalidAudienceError +InvalidIssuer = InvalidIssuerError + +# These aren't actually documented, but the package +# exports them in __init__.py, so we should at least +# make sure that mypy doesn't raise spurious errors +# if they're used. +get_unverified_header = ... # type: Any +PyJWT = ... # type: Any +PyJWS = ... # type: Any diff --git a/python/helpers/typeshed/third_party/3/jwt/algorithms.pyi b/python/helpers/typeshed/third_party/3/jwt/algorithms.pyi new file mode 100644 index 000000000000..4576b4169354 --- /dev/null +++ b/python/helpers/typeshed/third_party/3/jwt/algorithms.pyi @@ -0,0 +1,3 @@ +from typing import Any + +class Algorithm(Any): ... # type: ignore diff --git a/python/helpers/typeshed/third_party/3/jwt/contrib/__init__.pyi b/python/helpers/typeshed/third_party/3/jwt/contrib/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/python/helpers/typeshed/third_party/3/jwt/contrib/algorithms/__init__.pyi b/python/helpers/typeshed/third_party/3/jwt/contrib/algorithms/__init__.pyi new file mode 100644 index 000000000000..b2bb1f643a3e --- /dev/null +++ b/python/helpers/typeshed/third_party/3/jwt/contrib/algorithms/__init__.pyi @@ -0,0 +1 @@ +from hashlib import _Hash as _HashAlg diff --git a/python/helpers/typeshed/third_party/3/jwt/contrib/algorithms/py_ecdsa.pyi b/python/helpers/typeshed/third_party/3/jwt/contrib/algorithms/py_ecdsa.pyi new file mode 100644 index 000000000000..cd2926f4235c --- /dev/null +++ b/python/helpers/typeshed/third_party/3/jwt/contrib/algorithms/py_ecdsa.pyi @@ -0,0 +1,10 @@ +from typing import Any +from jwt.algorithms import Algorithm + +from . import _HashAlg + +class ECAlgorithm(Algorithm): + SHA256 = ... # type: _HashAlg + SHA384 = ... # type: _HashAlg + SHA512 = ... # type: _HashAlg + def __init__(self, hash_alg: _HashAlg) -> None: ... diff --git a/python/helpers/typeshed/third_party/3/jwt/contrib/algorithms/pycrypto.pyi b/python/helpers/typeshed/third_party/3/jwt/contrib/algorithms/pycrypto.pyi new file mode 100644 index 000000000000..08ae8ba2d00a --- /dev/null +++ b/python/helpers/typeshed/third_party/3/jwt/contrib/algorithms/pycrypto.pyi @@ -0,0 +1,10 @@ +from typing import Any +from jwt.algorithms import Algorithm + +from . import _HashAlg + +class RSAAlgorithm(Algorithm): + SHA256 = ... # type: _HashAlg + SHA384 = ... # type: _HashAlg + SHA512 = ... # type: _HashAlg + def __init__(self, hash_alg: _HashAlg) -> None: ... diff --git a/python/helpers/typeshed/third_party/3/lxml/etree.pyi b/python/helpers/typeshed/third_party/3/lxml/etree.pyi index 6421a35b9fe8..958c82a1d7a9 100644 --- a/python/helpers/typeshed/third_party/3/lxml/etree.pyi +++ b/python/helpers/typeshed/third_party/3/lxml/etree.pyi @@ -3,7 +3,7 @@ # Any use of `Any` below means I couldn't figure out the type. import typing -from typing import Any, Dict, List, MutableMapping, Tuple, Union +from typing import Any, Dict, List, MutableMapping, Tuple, Union, Optional from typing import Iterable, Iterator, SupportsBytes @@ -11,10 +11,10 @@ from typing import Iterable, Iterator, SupportsBytes # unnecessary constraint. It seems reasonable to constrain each # List/Dict argument to use one type consistently, though, and it is # necessary in order to keep these brief. -AnyStr = Union[str, bytes] -ListAnyStr = Union[List[str], List[bytes]] -DictAnyStr = Union[Dict[str, str], Dict[bytes, bytes]] -Dict_Tuple2AnyStr_Any = Union[Dict[Tuple[str, str], Any], Tuple[bytes, bytes], Any] +_AnyStr = Union[str, bytes] +_ListAnyStr = Union[List[str], List[bytes]] +_DictAnyStr = Union[Dict[str, str], Dict[bytes, bytes]] +_Dict_Tuple2AnyStr_Any = Union[Dict[Tuple[str, str], Any], Tuple[bytes, bytes], Any] class ElementChildIterator(Iterator['_Element']): @@ -22,23 +22,26 @@ class ElementChildIterator(Iterator['_Element']): def __next__(self) -> '_Element': ... class _Element(Iterable['_Element']): - def addprevious(self, element: '_Element') -> None: - ... - + def addprevious(self, element: '_Element') -> None: ... + def addnext(self, element: '_Element') -> None: ... + def clear(self) -> None: ... + def get(self, key: _AnyStr, default: Optional[_AnyStr] = ...) -> _AnyStr: ... + def xpath(self, _path: _AnyStr, namespaces: Optional[_DictAnyStr] = ..., extensions: Any = ..., smart_strings: bool = ..., **_variables: Any) -> Any: ... + # indeed returns a Union[bool, float, _AnyStr, List[Union[ElementBase, _AnyStr, Tuple[]]]]: ... + # http://lxml.de/xpathxslt.html#xpath-return-values attrib = ... # type: MutableMapping[str, str] - text = ... # type: AnyStr + text = ... # type: _AnyStr tag = ... # type: str def append(self, element: '_Element') -> '_Element': ... def __iter__(self) -> ElementChildIterator: ... -class ElementBase(_Element): - ... +class ElementBase(_Element): ... class _ElementTree: def write(self, - file: Union[AnyStr, typing.IO], - encoding: AnyStr = ..., - method: AnyStr = ..., + file: Union[_AnyStr, typing.IO], + encoding: _AnyStr = ..., + method: _AnyStr = ..., pretty_print: bool = ..., xml_declaration: Any = ..., with_tail: Any = ..., @@ -46,80 +49,55 @@ class _ElementTree: compression: int = ..., exclusive: bool = ..., with_comments: bool = ..., - inclusive_ns_prefixes: ListAnyStr = ...) -> None: - ... + inclusive_ns_prefixes: _ListAnyStr = ...) -> None: ... + def xpath(self, _path: _AnyStr, namespaces: Optional[_DictAnyStr] = ..., extensions: Any = ..., smart_strings: bool = ..., **_variables: Any) -> Any: ... -class _XSLTResultTree(SupportsBytes): - ... +class _XSLTResultTree(SupportsBytes): ... -class _XSLTQuotedStringParam: - ... +class _XSLTQuotedStringParam: ... -class XMLParser: - ... +class XMLParser: ... class XMLSchema: def __init__(self, etree: Union[_Element, _ElementTree] = ..., - file: Union[AnyStr, typing.IO] = ...) -> None: - ... + file: Union[_AnyStr, typing.IO] = ...) -> None: ... + def assertValid(self, etree: Union[_Element, _ElementTree]) -> None: ... - def assertValid(self, - etree: Union[_Element, _ElementTree]) -> None: - ... - -class XSLTAccessControl: - ... +class XSLTAccessControl: ... class XSLT: def __init__(self, xslt_input: Union[_Element, _ElementTree], - extensions: Dict_Tuple2AnyStr_Any = ..., + extensions: _Dict_Tuple2AnyStr_Any = ..., regexp: bool = ..., - access_control: XSLTAccessControl = ...) -> None: - ... - + access_control: XSLTAccessControl = ...) -> None: ... def __call__(self, _input: Union[_Element, _ElementTree], profile_run: bool = ..., - **kwargs: Union[AnyStr, _XSLTQuotedStringParam]) -> _XSLTResultTree: - ... - + **kwargs: Union[_AnyStr, _XSLTQuotedStringParam]) -> _XSLTResultTree: ... @staticmethod - def strparam(s: AnyStr) -> _XSLTQuotedStringParam: - ... - -def Element(_tag: AnyStr, - attrib: DictAnyStr = ..., - nsmap: DictAnyStr = ..., - **extra: AnyStr) -> _Element: - ... - -def SubElement(_parent: _Element, _tag: AnyStr, - attrib: DictAnyStr = ..., - nsmap: DictAnyStr = ..., - **extra: AnyStr) -> _Element: - ... + def strparam(s: _AnyStr) -> _XSLTQuotedStringParam: ... +def Element(_tag: _AnyStr, + attrib: _DictAnyStr = ..., + nsmap: _DictAnyStr = ..., + **extra: _AnyStr) -> _Element: ... +def SubElement(_parent: _Element, _tag: _AnyStr, + attrib: _DictAnyStr = ..., + nsmap: _DictAnyStr = ..., + **extra: _AnyStr) -> _Element: ... def ElementTree(element: _Element = ..., - file: Union[AnyStr, typing.IO] = ..., - parser: XMLParser = ...) -> _ElementTree: - ... - -def ProcessingInstruction(target: AnyStr, text: AnyStr = ...) -> _Element: - ... - -def parse(source: Union[AnyStr, typing.IO], + file: Union[_AnyStr, typing.IO] = ..., + parser: XMLParser = ...) -> _ElementTree: ... +def ProcessingInstruction(target: _AnyStr, text: _AnyStr = ...) -> _Element: ... +def parse(source: Union[_AnyStr, typing.IO], parser: XMLParser = ..., - base_url: AnyStr = ...) -> _ElementTree: - ... - - -def fromstring(text: AnyStr, + base_url: _AnyStr = ...) -> _ElementTree: ... +def fromstring(text: _AnyStr, parser: XMLParser = ..., *, - base_url: AnyStr = ...) -> _Element: ... - + base_url: _AnyStr = ...) -> _Element: ... def tostring(element_or_tree: Union[_Element, _ElementTree], encoding: Union[str, type] = ..., method: str = ..., @@ -130,39 +108,26 @@ def tostring(element_or_tree: Union[_Element, _ElementTree], doctype: str = ..., exclusive: bool = ..., with_comments: bool = ..., - inclusive_ns_prefixes: Any = ...) -> AnyStr: ... + inclusive_ns_prefixes: Any = ...) -> _AnyStr: ... +class _ErrorLog: ... -class _ErrorLog: - ... - - -class Error(Exception): - ... +class Error(Exception): ... class LxmlError(Error): def __init__(self, message: Any, error_log: _ErrorLog = ...) -> None: ... error_log = ... # type: _ErrorLog -class DocumentInvalid(LxmlError): - ... +class DocumentInvalid(LxmlError): ... +class LxmlSyntaxError(LxmlError, SyntaxError): ... +class ParseError(LxmlSyntaxError): ... +class XMLSyntaxError(ParseError): ... -class LxmlSyntaxError(LxmlError, SyntaxError): - ... - -class ParseError(LxmlSyntaxError): - ... - -class XMLSyntaxError(ParseError): - ... - - -class _Validator: - ... +class _Validator: ... class DTD(_Validator): def __init__(self, - file: Union[AnyStr, typing.IO] = ..., + file: Union[_AnyStr, typing.IO] = ..., *, external_id: Any = ...) -> None: ... diff --git a/python/helpers/typeshed/third_party/3/six/__init__.pyi b/python/helpers/typeshed/third_party/3/six/__init__.pyi index 333bd27ce3a2..0631a6924025 100644 --- a/python/helpers/typeshed/third_party/3/six/__init__.pyi +++ b/python/helpers/typeshed/third_party/3/six/__init__.pyi @@ -84,17 +84,17 @@ def byte2int(bs: binary_type) -> int: ... def indexbytes(buf: binary_type, i: int) -> int: ... def iterbytes(buf: binary_type) -> typing.Iterator[int]: ... -def assertCountEqual(self: unittest.TestCase, first: Iterable[_T], second: Iterable[_T], msg: str = None) -> None: ... +def assertCountEqual(self: unittest.TestCase, first: Iterable[_T], second: Iterable[_T], msg: Optional[str] = None) -> None: ... @overload -def assertRaisesRegex(self: unittest.TestCase, msg: str = None) -> Any: ... +def assertRaisesRegex(self: unittest.TestCase, msg: Optional[str] = None) -> Any: ... @overload def assertRaisesRegex(self: unittest.TestCase, callable_obj: Callable[..., Any], *args: Any, **kwargs: Any) -> Any: ... -def assertRegex(self: unittest.TestCase, text: AnyStr, expected_regex: Union[AnyStr, Pattern[AnyStr]], msg: str = None) -> None: ... +def assertRegex(self: unittest.TestCase, text: AnyStr, expected_regex: Union[AnyStr, Pattern[AnyStr]], msg: Optional[str] = None) -> None: ... exec_ = exec def reraise(tp: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType] = None) -> NoReturn: ... -def raise_from(value: BaseException, from_value: BaseException) -> None: ... +def raise_from(value: BaseException, from_value: Optional[BaseException]) -> NoReturn: ... print_ = print diff --git a/python/helpers/typeshed/third_party/3/six/moves/__init__.pyi b/python/helpers/typeshed/third_party/3/six/moves/__init__.pyi index adce50116c18..744c95dd455f 100644 --- a/python/helpers/typeshed/third_party/3/six/moves/__init__.pyi +++ b/python/helpers/typeshed/third_party/3/six/moves/__init__.pyi @@ -1,9 +1,9 @@ -# Generated by stubtool 0.1, DO NOT EDIT -# See https://github.com/o11c/stubtool +# Stubs for six.moves # -# Stubs for six.moves (Python 3.2) +# Note: Commented out items means they weren't implemented at the time. +# Uncomment them when the modules have been added to the typeshed. +import sys -from http import cookies as http_cookies from io import StringIO as cStringIO from builtins import filter as filter from itertools import filterfalse as filterfalse @@ -13,7 +13,6 @@ from builtins import map as map from os import getcwd as getcwd from os import getcwdb as getcwdb from builtins import range as range -from imp import reload as reload_module from functools import reduce as reduce from shlex import quote as shlex_quote from io import StringIO as StringIO @@ -23,14 +22,51 @@ from collections import UserString as UserString from builtins import range as xrange from builtins import zip as zip from itertools import zip_longest as zip_longest -import six.moves.cPickle as cPickle -import html.parser as html_parser -import html.entities as html_entities -import http.client as http_client -import configparser as configparser import builtins as builtins - -import six.moves.urllib_parse as urllib_parse -import six.moves.urllib_error as urllib_error +import configparser as configparser +# import copyreg as copyreg +# import dbm.gnu as dbm_gnu +import _dummy_thread as _dummy_thread +import http.cookiejar as http_cookiejar +import http.cookies as http_cookies +import html.entities as html_entities +import html.parser as html_parser +import http.client as http_client +import email.mime.multipart as email_mime_multipart +import email.mime.nonmultipart as email_mime_nonmultipart +import email.mime.text as email_mime_text +import email.mime.base as email_mime_base +import http.server as BaseHTTPServer +import http.server as CGIHTTPServer +import http.server as SimpleHTTPServer +import pickle as cPickle +import queue as queue +# import reprlib as reprlib +import socketserver as socketserver +import _thread as _thread +import tkinter as tkinter +# import tkinter.dialog as tkinter_dialog +# import tkinter.filedialog as tkinter_filedialog +# import tkinter.scrolledtext as tkinter_scrolledtext +# import tkinter.simpledialog as tkinter_simpledialog +# import tkinter.tix as tkinter_tix +import tkinter.ttk as tkinter_ttk +import tkinter.constants as tkinter_constants +# import tkinter.dnd as tkinter_dnd +# import tkinter.colorchooser as tkinter_colorchooser +# import tkinter.commondialog as tkinter_commondialog +# import tkinter.filedialog as tkinter_tkfiledialog +# import tkinter.font as tkinter_font +# import tkinter.messagebox as tkinter_messagebox +# import tkinter.simpledialog as tkinter_tksimpledialog +import urllib.parse as urllib_parse +import urllib.error as urllib_error import six.moves.urllib as urllib -import six.moves.urllib_robotparser as urllib_robotparser +import urllib.robotparser as urllib_robotparser +# import xmlrpc.client as xmlrpc_client +# import xmlrpc.server as xmlrpc_server + +if sys.version_info >= (3, 4): + from importlib import reload as reload_module +else: + from imp import reload as reload_module diff --git a/python/helpers/typeshed/third_party/3/six/moves/urllib/__init__.pyi b/python/helpers/typeshed/third_party/3/six/moves/urllib/__init__.pyi index 298b0495efe3..d08209c51cc1 100644 --- a/python/helpers/typeshed/third_party/3/six/moves/urllib/__init__.pyi +++ b/python/helpers/typeshed/third_party/3/six/moves/urllib/__init__.pyi @@ -1,8 +1,3 @@ -# Generated by stubtool 0.1, DO NOT EDIT -# See https://github.com/o11c/stubtool -# -# Stubs for six.moves.urllib (Python 3.2) - import six.moves.urllib.error as error import six.moves.urllib.parse as parse import six.moves.urllib.request as request diff --git a/python/helpers/typeshed/third_party/3/six/moves/urllib/error.pyi b/python/helpers/typeshed/third_party/3/six/moves/urllib/error.pyi index a45b0f71e0f9..83f0d22d4b9f 100644 --- a/python/helpers/typeshed/third_party/3/six/moves/urllib/error.pyi +++ b/python/helpers/typeshed/third_party/3/six/moves/urllib/error.pyi @@ -1,8 +1,3 @@ -# Generated by stubtool 0.1, DO NOT EDIT -# See https://github.com/o11c/stubtool -# -# Stubs for six.moves.urllib.error (Python 3.2) - from urllib.error import URLError as URLError from urllib.error import HTTPError as HTTPError from urllib.error import ContentTooShortError as ContentTooShortError diff --git a/python/helpers/typeshed/third_party/3/six/moves/urllib/parse.pyi b/python/helpers/typeshed/third_party/3/six/moves/urllib/parse.pyi index c640af2581b0..8b4310a4e7c6 100644 --- a/python/helpers/typeshed/third_party/3/six/moves/urllib/parse.pyi +++ b/python/helpers/typeshed/third_party/3/six/moves/urllib/parse.pyi @@ -1,22 +1,27 @@ -# Generated by stubtool 0.1, DO NOT EDIT -# See https://github.com/o11c/stubtool +# Stubs for six.moves.urllib.parse # -# Stubs for six.moves.urllib.parse (Python 3.2) - -from six.moves.urllib_parse import ( - ParseResult as ParseResult, - SplitResult as SplitResult, - parse_qs as parse_qs, - parse_qsl as parse_qsl, - urldefrag as urldefrag, - urljoin as urljoin, - urlparse as urlparse, - urlsplit as urlsplit, - urlunparse as urlunparse, - urlunsplit as urlunsplit, - quote as quote, - quote_plus as quote_plus, - unquote as unquote, - unquote_plus as unquote_plus, - urlencode as urlencode, -) +# Note: Commented out items means they weren't implemented at the time. +# Uncomment them when the modules have been added to the typeshed. +from urllib.parse import ParseResult as ParseResult +from urllib.parse import SplitResult as SplitResult +from urllib.parse import parse_qs as parse_qs +from urllib.parse import parse_qsl as parse_qsl +from urllib.parse import urldefrag as urldefrag +from urllib.parse import urljoin as urljoin +from urllib.parse import urlparse as urlparse +from urllib.parse import urlsplit as urlsplit +from urllib.parse import urlunparse as urlunparse +from urllib.parse import urlunsplit as urlunsplit +from urllib.parse import quote as quote +from urllib.parse import quote_plus as quote_plus +from urllib.parse import unquote as unquote +from urllib.parse import unquote_plus as unquote_plus +from urllib.parse import urlencode as urlencode +# from urllib.parse import splitquery as splitquery +# from urllib.parse import splittag as splittag +# from urllib.parse import splituser as splituser +from urllib.parse import uses_fragment as uses_fragment +from urllib.parse import uses_netloc as uses_netloc +from urllib.parse import uses_params as uses_params +from urllib.parse import uses_query as uses_query +from urllib.parse import uses_relative as uses_relative diff --git a/python/helpers/typeshed/third_party/3/six/moves/urllib/request.pyi b/python/helpers/typeshed/third_party/3/six/moves/urllib/request.pyi index b15ced7ea3ec..718a819cd6b4 100644 --- a/python/helpers/typeshed/third_party/3/six/moves/urllib/request.pyi +++ b/python/helpers/typeshed/third_party/3/six/moves/urllib/request.pyi @@ -1,40 +1,37 @@ -# Generated by stubtool 0.1, DO NOT EDIT -# See https://github.com/o11c/stubtool +# Stubs for six.moves.urllib.request # -# Stubs for six.moves.urllib.request (Python 3.2) - -from urllib.request import BaseHandler as BaseHandler -from urllib.request import HTTPRedirectHandler as HTTPRedirectHandler -from urllib.request import OpenerDirector as OpenerDirector - +# Note: Commented out items means they weren't implemented at the time. +# Uncomment them when the modules have been added to the typeshed. +from urllib.request import urlopen as urlopen from urllib.request import install_opener as install_opener from urllib.request import build_opener as build_opener - -# from urllib.request import urlopen as urlopen -# from urllib.request import pathname2url as pathname2url -# from urllib.request import url2pathname as url2pathname -# from urllib.request import getproxies as getproxies -# from urllib.request import Request as Request -# from urllib.request import HTTPDefaultErrorHandler as HTTPDefaultErrorHandler -# from urllib.request import HTTPCookieProcessor as HTTPCookieProcessor -# from urllib.request import ProxyHandler as ProxyHandler -# from urllib.request import HTTPPasswordMgr as HTTPPasswordMgr -# from urllib.request import HTTPPasswordMgrWithDefaultRealm as HTTPPasswordMgrWithDefaultRealm -# from urllib.request import AbstractBasicAuthHandler as AbstractBasicAuthHandler -# from urllib.request import HTTPBasicAuthHandler as HTTPBasicAuthHandler -# from urllib.request import ProxyBasicAuthHandler as ProxyBasicAuthHandler -# from urllib.request import AbstractDigestAuthHandler as AbstractDigestAuthHandler -# from urllib.request import HTTPDigestAuthHandler as HTTPDigestAuthHandler -# from urllib.request import ProxyDigestAuthHandler as ProxyDigestAuthHandler -# from urllib.request import HTTPHandler as HTTPHandler -# from urllib.request import HTTPSHandler as HTTPSHandler -# from urllib.request import FileHandler as FileHandler -# from urllib.request import FTPHandler as FTPHandler -# from urllib.request import CacheFTPHandler as CacheFTPHandler -# from urllib.request import UnknownHandler as UnknownHandler -# from urllib.request import HTTPErrorProcessor as HTTPErrorProcessor -# from urllib.request import urlretrieve as urlretrieve -# from urllib.request import urlcleanup as urlcleanup -# from urllib.request import URLopener as URLopener -# from urllib.request import FancyURLopener as FancyURLopener +from urllib.request import pathname2url as pathname2url +from urllib.request import url2pathname as url2pathname +from urllib.request import getproxies as getproxies +from urllib.request import Request as Request +from urllib.request import OpenerDirector as OpenerDirector +from urllib.request import HTTPDefaultErrorHandler as HTTPDefaultErrorHandler +from urllib.request import HTTPRedirectHandler as HTTPRedirectHandler +from urllib.request import HTTPCookieProcessor as HTTPCookieProcessor +from urllib.request import ProxyHandler as ProxyHandler +from urllib.request import BaseHandler as BaseHandler +from urllib.request import HTTPPasswordMgr as HTTPPasswordMgr +from urllib.request import HTTPPasswordMgrWithDefaultRealm as HTTPPasswordMgrWithDefaultRealm +from urllib.request import AbstractBasicAuthHandler as AbstractBasicAuthHandler +from urllib.request import HTTPBasicAuthHandler as HTTPBasicAuthHandler +from urllib.request import ProxyBasicAuthHandler as ProxyBasicAuthHandler +from urllib.request import AbstractDigestAuthHandler as AbstractDigestAuthHandler +from urllib.request import HTTPDigestAuthHandler as HTTPDigestAuthHandler +from urllib.request import ProxyDigestAuthHandler as ProxyDigestAuthHandler +from urllib.request import HTTPHandler as HTTPHandler +from urllib.request import HTTPSHandler as HTTPSHandler +from urllib.request import FileHandler as FileHandler +from urllib.request import FTPHandler as FTPHandler +from urllib.request import CacheFTPHandler as CacheFTPHandler +from urllib.request import UnknownHandler as UnknownHandler +from urllib.request import HTTPErrorProcessor as HTTPErrorProcessor +from urllib.request import urlretrieve as urlretrieve +from urllib.request import urlcleanup as urlcleanup +from urllib.request import URLopener as URLopener +from urllib.request import FancyURLopener as FancyURLopener # from urllib.request import proxy_bypass as proxy_bypass diff --git a/python/helpers/typeshed/third_party/3/six/moves/urllib/response.pyi b/python/helpers/typeshed/third_party/3/six/moves/urllib/response.pyi index c3b34a839b52..9f681ea33cad 100644 --- a/python/helpers/typeshed/third_party/3/six/moves/urllib/response.pyi +++ b/python/helpers/typeshed/third_party/3/six/moves/urllib/response.pyi @@ -1 +1,8 @@ +# Stubs for six.moves.urllib.response +# +# Note: Commented out items means they weren't implemented at the time. +# Uncomment them when the modules have been added to the typeshed. +# from urllib.response import addbase as addbase +# from urllib.response import addclosehook as addclosehook +# from urllib.response import addinfo as addinfo from urllib.response import addinfourl as addinfourl diff --git a/python/helpers/typeshed/third_party/3/six/moves/urllib/robotparser.pyi b/python/helpers/typeshed/third_party/3/six/moves/urllib/robotparser.pyi index 6690355236ae..bccda14b4342 100644 --- a/python/helpers/typeshed/third_party/3/six/moves/urllib/robotparser.pyi +++ b/python/helpers/typeshed/third_party/3/six/moves/urllib/robotparser.pyi @@ -1,6 +1 @@ -# Generated by stubtool 0.1, DO NOT EDIT -# See https://github.com/o11c/stubtool -# -# Stubs for six.moves.urllib.robotparser (Python 3.2) - from urllib.robotparser import RobotFileParser as RobotFileParser diff --git a/python/helpers/typeshed/third_party/3/typed_ast/ast27.pyi b/python/helpers/typeshed/third_party/3/typed_ast/ast27.pyi index 28e0dfee3c1c..c4bf4f6b8c35 100644 --- a/python/helpers/typeshed/third_party/3/typed_ast/ast27.pyi +++ b/python/helpers/typeshed/third_party/3/typed_ast/ast27.pyi @@ -242,7 +242,7 @@ class Repr(expr): value = ... # type: expr class Num(expr): - n = ... # type: Union[int, float] + n = ... # type: Union[int, float, complex] class Str(expr): s = ... # type: bytes diff --git a/python/helpers/typeshed/third_party/3/werkzeug/__init__.pyi b/python/helpers/typeshed/third_party/3/werkzeug/__init__.pyi index 806f96414f31..fc27b0902f52 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/__init__.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from types import ModuleType from typing import Any diff --git a/python/helpers/typeshed/third_party/3/werkzeug/_compat.pyi b/python/helpers/typeshed/third_party/3/werkzeug/_compat.pyi index 1b0f55bc59d8..4a5fa322b2e0 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/_compat.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/_compat.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug._compat (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from io import StringIO as BytesIO diff --git a/python/helpers/typeshed/third_party/3/werkzeug/_internal.pyi b/python/helpers/typeshed/third_party/3/werkzeug/_internal.pyi index d16a33df3a61..6fddbdd77ce3 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/_internal.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/_internal.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug._internal (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class _Missing: diff --git a/python/helpers/typeshed/third_party/3/werkzeug/_reloader.pyi b/python/helpers/typeshed/third_party/3/werkzeug/_reloader.pyi index 669065e2d12a..55a560d2f504 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/_reloader.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/_reloader.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug._reloader (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class ReloaderLoop: diff --git a/python/helpers/typeshed/third_party/3/werkzeug/contrib/__init__.pyi b/python/helpers/typeshed/third_party/3/werkzeug/contrib/__init__.pyi index 3fb41165b2f9..e69de29bb2d1 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/contrib/__init__.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/contrib/__init__.pyi @@ -1,3 +0,0 @@ -# Stubs for werkzeug.contrib (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. diff --git a/python/helpers/typeshed/third_party/3/werkzeug/contrib/atom.pyi b/python/helpers/typeshed/third_party/3/werkzeug/contrib/atom.pyi index cfb535d780f5..1e27873630cc 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/contrib/atom.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/contrib/atom.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.atom (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any XHTML_NAMESPACE = ... # type: Any diff --git a/python/helpers/typeshed/third_party/3/werkzeug/contrib/cache.pyi b/python/helpers/typeshed/third_party/3/werkzeug/contrib/cache.pyi index 7b071ea0ca65..2b8abb7671a8 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/contrib/cache.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/contrib/cache.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.cache (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class BaseCache: diff --git a/python/helpers/typeshed/third_party/3/werkzeug/contrib/fixers.pyi b/python/helpers/typeshed/third_party/3/werkzeug/contrib/fixers.pyi index d6602635fd40..a45c661c9cb8 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/contrib/fixers.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/contrib/fixers.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.fixers (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class CGIRootFix: diff --git a/python/helpers/typeshed/third_party/3/werkzeug/contrib/iterio.pyi b/python/helpers/typeshed/third_party/3/werkzeug/contrib/iterio.pyi index b65323a6ae42..33da95600a9b 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/contrib/iterio.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/contrib/iterio.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.iterio (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any greenlet = ... # type: Any diff --git a/python/helpers/typeshed/third_party/3/werkzeug/contrib/jsrouting.pyi b/python/helpers/typeshed/third_party/3/werkzeug/contrib/jsrouting.pyi index 9ba5cffe58e5..a9cc8c2a153a 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/contrib/jsrouting.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/contrib/jsrouting.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.jsrouting (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any def dumps(*args): ... diff --git a/python/helpers/typeshed/third_party/3/werkzeug/contrib/limiter.pyi b/python/helpers/typeshed/third_party/3/werkzeug/contrib/limiter.pyi index d27776f890ef..52501c6eea51 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/contrib/limiter.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/contrib/limiter.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.limiter (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class StreamLimitMiddleware: diff --git a/python/helpers/typeshed/third_party/3/werkzeug/contrib/lint.pyi b/python/helpers/typeshed/third_party/3/werkzeug/contrib/lint.pyi index ccaecf50f8e2..f89c120927f9 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/contrib/lint.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/contrib/lint.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.lint (Python 3) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class WSGIWarning(Warning): ... diff --git a/python/helpers/typeshed/third_party/3/werkzeug/contrib/profiler.pyi b/python/helpers/typeshed/third_party/3/werkzeug/contrib/profiler.pyi index d3daf6d5ceb4..db1eacbf69ac 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/contrib/profiler.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/contrib/profiler.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.profiler (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any available = ... # type: Any diff --git a/python/helpers/typeshed/third_party/3/werkzeug/contrib/securecookie.pyi b/python/helpers/typeshed/third_party/3/werkzeug/contrib/securecookie.pyi index 36ed6b74fa4c..219356f64378 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/contrib/securecookie.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/contrib/securecookie.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.securecookie (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from hmac import new as hmac from hashlib import sha1 as _default_hash diff --git a/python/helpers/typeshed/third_party/3/werkzeug/contrib/sessions.pyi b/python/helpers/typeshed/third_party/3/werkzeug/contrib/sessions.pyi index 69cb4f5af7c3..aa3f8fc2769e 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/contrib/sessions.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/contrib/sessions.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.sessions (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from werkzeug.datastructures import CallbackDict diff --git a/python/helpers/typeshed/third_party/3/werkzeug/contrib/testtools.pyi b/python/helpers/typeshed/third_party/3/werkzeug/contrib/testtools.pyi index 3c21524a7081..860ebb7afb0f 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/contrib/testtools.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/contrib/testtools.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.testtools (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from werkzeug.wrappers import Response diff --git a/python/helpers/typeshed/third_party/3/werkzeug/contrib/wrappers.pyi b/python/helpers/typeshed/third_party/3/werkzeug/contrib/wrappers.pyi index 2e43f6a48d4e..4ebc7e80d765 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/contrib/wrappers.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/contrib/wrappers.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.contrib.wrappers (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any def is_known_charset(charset): ... diff --git a/python/helpers/typeshed/third_party/3/werkzeug/datastructures.pyi b/python/helpers/typeshed/third_party/3/werkzeug/datastructures.pyi index 0204b34e21c7..64a9c9cc594f 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/datastructures.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/datastructures.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.datastructures (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from collections import Container, Iterable, Mapping, MutableSet diff --git a/python/helpers/typeshed/third_party/3/werkzeug/debug/__init__.pyi b/python/helpers/typeshed/third_party/3/werkzeug/debug/__init__.pyi index e02bc3ccafe6..0c949f91da79 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/debug/__init__.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/debug/__init__.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.debug (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from werkzeug.wrappers import BaseRequest as Request, BaseResponse as Response diff --git a/python/helpers/typeshed/third_party/3/werkzeug/debug/console.pyi b/python/helpers/typeshed/third_party/3/werkzeug/debug/console.pyi index 9fdf0b599b53..5046a519cda0 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/debug/console.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/debug/console.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.debug.console (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any import code diff --git a/python/helpers/typeshed/third_party/3/werkzeug/debug/repr.pyi b/python/helpers/typeshed/third_party/3/werkzeug/debug/repr.pyi index 063c4213e2bf..fe3faef8e109 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/debug/repr.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/debug/repr.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.debug.repr (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any deque = ... # type: Any diff --git a/python/helpers/typeshed/third_party/3/werkzeug/debug/tbtools.pyi b/python/helpers/typeshed/third_party/3/werkzeug/debug/tbtools.pyi index 1107c627c7db..7c0cd584ba04 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/debug/tbtools.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/debug/tbtools.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.debug.tbtools (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any UTF8_COOKIE = ... # type: Any diff --git a/python/helpers/typeshed/third_party/3/werkzeug/exceptions.pyi b/python/helpers/typeshed/third_party/3/werkzeug/exceptions.pyi index 7e715977e488..a91abba92b2f 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/exceptions.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/exceptions.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.exceptions (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class HTTPException(Exception): diff --git a/python/helpers/typeshed/third_party/3/werkzeug/filesystem.pyi b/python/helpers/typeshed/third_party/3/werkzeug/filesystem.pyi index 5ebc566d497f..80913ca669a6 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/filesystem.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/filesystem.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.filesystem (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any has_likely_buggy_unicode_filesystem = ... # type: Any diff --git a/python/helpers/typeshed/third_party/3/werkzeug/formparser.pyi b/python/helpers/typeshed/third_party/3/werkzeug/formparser.pyi index 1b63dcaac3fa..96c7f22dc3e9 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/formparser.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/formparser.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.formparser (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any def default_stream_factory(total_content_length, filename, content_type, content_length=None): ... diff --git a/python/helpers/typeshed/third_party/3/werkzeug/http.pyi b/python/helpers/typeshed/third_party/3/werkzeug/http.pyi index 61202eababd8..5cc38b7f1629 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/http.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/http.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.http (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from urllib.request import parse_http_list as _parse_list_header from urllib.parse import unquote_to_bytes as _unquote diff --git a/python/helpers/typeshed/third_party/3/werkzeug/local.pyi b/python/helpers/typeshed/third_party/3/werkzeug/local.pyi index 1ed310266174..f1d167ac74b0 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/local.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/local.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.local (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any def release_local(local): ... diff --git a/python/helpers/typeshed/third_party/3/werkzeug/posixemulation.pyi b/python/helpers/typeshed/third_party/3/werkzeug/posixemulation.pyi index a2838fc9f33c..b490ab42b173 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/posixemulation.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/posixemulation.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.posixemulation (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from ._compat import to_unicode as to_unicode from .filesystem import get_filesystem_encoding as get_filesystem_encoding diff --git a/python/helpers/typeshed/third_party/3/werkzeug/routing.pyi b/python/helpers/typeshed/third_party/3/werkzeug/routing.pyi index ff0bbdae6dcd..027454294a2a 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/routing.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/routing.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.routing (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from werkzeug.exceptions import HTTPException diff --git a/python/helpers/typeshed/third_party/3/werkzeug/script.pyi b/python/helpers/typeshed/third_party/3/werkzeug/script.pyi index a01ffde0cc1f..758378d3b9ff 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/script.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/script.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.script (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any argument_types = ... # type: Any diff --git a/python/helpers/typeshed/third_party/3/werkzeug/security.pyi b/python/helpers/typeshed/third_party/3/werkzeug/security.pyi index b28d68a948fc..dde9fe1df362 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/security.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/security.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.security (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any SALT_CHARS = ... # type: Any diff --git a/python/helpers/typeshed/third_party/3/werkzeug/serving.pyi b/python/helpers/typeshed/third_party/3/werkzeug/serving.pyi index db347d2317f8..241f6e287fae 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/serving.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/serving.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.serving (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from socketserver import ThreadingMixIn, ForkingMixIn from http.server import HTTPServer, BaseHTTPRequestHandler diff --git a/python/helpers/typeshed/third_party/3/werkzeug/test.pyi b/python/helpers/typeshed/third_party/3/werkzeug/test.pyi index 1def65831f26..71dc6a69e322 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/test.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/test.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.test (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from urllib.request import Request as U2Request from http.cookiejar import CookieJar diff --git a/python/helpers/typeshed/third_party/3/werkzeug/testapp.pyi b/python/helpers/typeshed/third_party/3/werkzeug/testapp.pyi index cee939b64d33..4e1763385d10 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/testapp.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/testapp.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.testapp (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from werkzeug.wrappers import BaseRequest as Request, BaseResponse as Response diff --git a/python/helpers/typeshed/third_party/3/werkzeug/urls.pyi b/python/helpers/typeshed/third_party/3/werkzeug/urls.pyi index be248d2a6fc3..2976af09e9b3 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/urls.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/urls.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.urls (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from collections import namedtuple from typing import Any diff --git a/python/helpers/typeshed/third_party/3/werkzeug/useragents.pyi b/python/helpers/typeshed/third_party/3/werkzeug/useragents.pyi index 2471a243ae2b..2ca2705e4c46 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/useragents.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/useragents.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.useragents (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any class UserAgentParser: diff --git a/python/helpers/typeshed/third_party/3/werkzeug/utils.pyi b/python/helpers/typeshed/third_party/3/werkzeug/utils.pyi index b26f3167cf0b..8e2e6b9e723d 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/utils.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/utils.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.utils (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any from werkzeug._internal import _DictAccessorProperty diff --git a/python/helpers/typeshed/third_party/3/werkzeug/wrappers.pyi b/python/helpers/typeshed/third_party/3/werkzeug/wrappers.pyi index f6b67700b4da..031e37766d6d 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/wrappers.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/wrappers.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.wrappers (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import ( Any, Iterable, Mapping, Optional, Sequence, Tuple, Type, Union, ) @@ -80,7 +76,14 @@ class BaseResponse: status = ... # type: str direct_passthrough = ... # type: bool response = ... # type: Iterable[bytes] - def __init__(self, response: Union[Iterable[bytes], bytes]=None, status: Union[str, int]=None, headers: Union[Headers, Mapping[str, str], Sequence[Tuple[str, str]]]=None, mimetype: str=None, content_type: str=None, direct_passthrough: bool=False) -> None: ... + def __init__(self, response: Optional[Union[Iterable[bytes], bytes]]=None, + status: Optional[Union[str, int]]=None, + headers: Optional[Union[Headers, + Mapping[str, str], + Sequence[Tuple[str, str]]]]=None, + mimetype: Optional[str] = None, + content_type: Optional[str] = None, + direct_passthrough: bool=False) -> None: ... def call_on_close(self, func): ... @classmethod def force_type(cls, response, environ=None): ... diff --git a/python/helpers/typeshed/third_party/3/werkzeug/wsgi.pyi b/python/helpers/typeshed/third_party/3/werkzeug/wsgi.pyi index 4a0e6813667c..77722edf4af7 100644 --- a/python/helpers/typeshed/third_party/3/werkzeug/wsgi.pyi +++ b/python/helpers/typeshed/third_party/3/werkzeug/wsgi.pyi @@ -1,7 +1,3 @@ -# Stubs for werkzeug.wsgi (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - from typing import Any def responder(f): ... diff --git a/python/psi-api/src/com/jetbrains/python/PyNames.java b/python/psi-api/src/com/jetbrains/python/PyNames.java index d42eedb7648d..32ee3c1aca36 100644 --- a/python/psi-api/src/com/jetbrains/python/PyNames.java +++ b/python/psi-api/src/com/jetbrains/python/PyNames.java @@ -652,7 +652,7 @@ public class PyNames { public static final ImmutableSet PY3_ONLY_FUNCTION_SPECIAL_ATTRIBUTES = ImmutableSet.of("__annotations__", "__kwdefaults__"); - public static final ImmutableSet METHOD_SPECIAL_ATTRIBUTES = ImmutableSet.of("__func__", "__self__"); + public static final ImmutableSet METHOD_SPECIAL_ATTRIBUTES = ImmutableSet.of("__func__", "__self__", "__name__"); public static final ImmutableSet LEGACY_METHOD_SPECIAL_ATTRIBUTES = ImmutableSet.of("im_func", "im_self", "im_class"); diff --git a/python/testData/inspections/PyArgumentListInspection/floatConstructor.py b/python/testData/inspections/PyArgumentListInspection/floatConstructor.py index 7cdcb1ea6e49..db2d50352138 100644 --- a/python/testData/inspections/PyArgumentListInspection/floatConstructor.py +++ b/python/testData/inspections/PyArgumentListInspection/floatConstructor.py @@ -1,2 +1,2 @@ float() -float(1, 2) +float(1, 2) diff --git a/python/testSrc/com/jetbrains/python/PythonCompletionTest.java b/python/testSrc/com/jetbrains/python/PythonCompletionTest.java index 8f6ebd66527a..b717b7d94bf7 100644 --- a/python/testSrc/com/jetbrains/python/PythonCompletionTest.java +++ b/python/testSrc/com/jetbrains/python/PythonCompletionTest.java @@ -23,7 +23,6 @@ import com.intellij.codeInsight.lookup.Lookup; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.testFramework.PsiTestUtil; -import com.jetbrains.python.documentation.PyDocumentationSettings; import com.jetbrains.python.documentation.docstrings.DocStringFormat; import com.jetbrains.python.fixtures.PyTestCase; import com.jetbrains.python.psi.LanguageLevel; @@ -33,6 +32,7 @@ import org.jetbrains.annotations.Nullable; import java.util.Arrays; import java.util.HashSet; import java.util.List; +import java.util.Set; public class PythonCompletionTest extends PyTestCase { @@ -726,7 +726,9 @@ public class PythonCompletionTest extends PyTestCase { "C().f.__"); assertNotNull(suggested); assertContainsElements(suggested, PyNames.METHOD_SPECIAL_ATTRIBUTES); - assertDoesntContain(suggested, PyNames.FUNCTION_SPECIAL_ATTRIBUTES); + final Set functionAttributes = new HashSet<>(PyNames.FUNCTION_SPECIAL_ATTRIBUTES); + functionAttributes.removeAll(PyNames.METHOD_SPECIAL_ATTRIBUTES); + assertDoesntContain(suggested, functionAttributes); } // PY-9342 @@ -738,7 +740,9 @@ public class PythonCompletionTest extends PyTestCase { final List suggested = doTestByFile(); assertNotNull(suggested); assertContainsElements(suggested, PyNames.METHOD_SPECIAL_ATTRIBUTES); - assertDoesntContain(suggested, PyNames.FUNCTION_SPECIAL_ATTRIBUTES); + final Set functionAttributes = new HashSet<>(PyNames.FUNCTION_SPECIAL_ATTRIBUTES); + functionAttributes.removeAll(PyNames.METHOD_SPECIAL_ATTRIBUTES); + assertDoesntContain(suggested, functionAttributes); } // PY-9342 @@ -771,7 +775,9 @@ public class PythonCompletionTest extends PyTestCase { final List suggested = doTestByFile(); assertNotNull(suggested); assertContainsElements(suggested, PyNames.FUNCTION_SPECIAL_ATTRIBUTES); - assertDoesntContain(suggested, PyNames.METHOD_SPECIAL_ATTRIBUTES); + final Set methodAttributes = new HashSet<>(PyNames.METHOD_SPECIAL_ATTRIBUTES); + methodAttributes.removeAll(PyNames.FUNCTION_SPECIAL_ATTRIBUTES); + assertDoesntContain(suggested, methodAttributes); } public void testSmartFromUsedMethodsOfString() {