1 Commits

Author SHA1 Message Date
Dave Halter 3319cadf85 Make builtins work
One change is a Jedi issue, Jedi cannot really deal with __new__.
The other is a typeshed issue. "function" should not be defined in the stubs.
2019-05-19 13:12:18 +02:00
1254 changed files with 29073 additions and 48063 deletions
+17 -18
View File
@@ -1,26 +1,25 @@
# Some PEP8 deviations are considered irrelevant to stub files:
# E301 expected 1 blank line
# E302 expected 2 blank lines
# E305 expected 2 blank lines
# E701 multiple statements on one line (colon)
# E741 ambiguous variable name
# F401 imported but unused
# F403 import *' used; unable to detect undefined names
# F405 defined from star imports
# F822 undefined name in __all__
# (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
# 1463 F401 imported but unused
# 967 E701 multiple statements on one line (colon)
# 457 F811 redefinition
# 390 E305 expected 2 blank lines
# 4 E741 ambiguous variable name
# Nice-to-haves ignored for now
# E501 line too long
# 2307 E501 line too long
# Other ignored warnings
# W504 line break after binary operator
[flake8]
per-file-ignores =
*.py: E203, W503
*.pyi: E301, E302, E305, E501, E701, E741, F401, F403, F405, F822
# Since typing.pyi defines "overload" this is not recognized by flake8 as typing.overload.
# Unfortunately, flake8 does not allow to "noqa" just a specific error inside the file itself.
typing.pyi: E301, E302, E305, E501, E701, E741, F401, F403, F405, F811, F822
ignore = F401, F403, F405, F811, E301, E302, E305, E501, E701, E704, E741, B303, W504
# 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*,@*,.git,*_pb2.pyi
exclude = .venv*,@*,.git
max-line-length = 130
-53
View File
@@ -1,53 +0,0 @@
name: Run mypy_primer
on:
# Only run on PR, since we diff against master
pull_request:
jobs:
mypy_primer:
name: Run
runs-on: ubuntu-latest
strategy:
matrix:
shard-index: [0, 1]
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
path: typeshed_to_test
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install -U pip
pip install git+https://github.com/hauntsaninja/mypy_primer.git
- name: Run mypy_primer
shell: bash
run: |
cd typeshed_to_test
echo "new commit"
git rev-list --format=%s --max-count=1 $GITHUB_SHA
git checkout -b upstream_master origin/master
echo "base commit"
git rev-list --format=%s --max-count=1 upstream_master
echo ''
cd ..
# fail action if exit code isn't zero or one
(
mypy_primer \
--new 0.790 --old 0.790 \
--custom-typeshed-repo typeshed_to_test \
--new-typeshed $GITHUB_SHA --old-typeshed upstream_master \
--num-shards 2 --shard-index ${{ matrix.shard-index }} \
--debug \
--output concise \
| tee diff.txt
) || [ $? -eq 1 ]
- name: Upload mypy_primer diff
uses: actions/upload-artifact@v2
with:
name: mypy_primer_diff_${{ matrix.shard-index }}
path: diff.txt
-103
View File
@@ -1,103 +0,0 @@
name: Comment with mypy_primer diff
on:
# pull_request_target gives us access to a write token which we need to post a comment
# The presence of a write token means that we can't run any untrusted code (i.e. malicious PRs),
# which is why this its own workflow. Github Actions doesn't make it easy for workflows to talk to
# each other, so the approach here is to poll for workflow runs, find the mypy_primer run for our
# commit, wait till it's completed, and download and post the diff.
pull_request_target:
jobs:
mypy_primer:
name: Comment
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: npm install adm-zip
- name: Post comment
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const AdmZip = require(`${process.env.GITHUB_WORKSPACE}/node_modules/adm-zip`)
// Because of pull_request_target, context.sha is the PR base branch
// So we need to ask Github for the SHA of the PR's head commit
const pull_request = await github.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
})
const pr_commit_sha = pull_request.data.head.sha
console.log("Looking for mypy_primer run for commit:", pr_commit_sha)
// Find the mypy_primer run for our commit and wait till it's completed
// We wait up to an hour before timing out
async function check_mypy_primer() {
// We're only looking at the first page, so in theory if we open enough PRs around
// the same time, this will fail to find the run.
const response = await github.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "mypy_primer.yml",
})
if (response) {
return response.data.workflow_runs.find(run => run.head_sha == pr_commit_sha)
}
return undefined
}
const end_time = Number(new Date()) + 60 * 60 * 1000
let primer_run = await check_mypy_primer()
while (!primer_run || primer_run.status != "completed") {
if (Number(new Date()) > end_time) {
throw Error("Timed out waiting for mypy_primer")
}
console.log("Waiting for mypy_primer to complete...")
await new Promise(r => setTimeout(r, 10000))
primer_run = await check_mypy_primer()
}
console.log("Found mypy_primer run!")
console.log(primer_run)
// Download artifact(s) from the run
const artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: primer_run.id,
})
const filtered_artifacts = artifacts.data.artifacts.filter(
a => a.name.startsWith("mypy_primer_diff")
)
console.log("Artifacts from mypy_primer:")
console.log(filtered_artifacts)
async function get_artifact_data(artifact) {
const zip = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
archive_format: "zip",
})
const adm = new AdmZip(Buffer.from(zip.data))
return adm.readAsText(adm.getEntry("diff.txt"))
}
const all_data = await Promise.all(filtered_artifacts.map(get_artifact_data))
const data = all_data.join("\n")
console.log("Diff from mypy_primer:")
console.log(data)
try {
if (data.trim()) {
await github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Diff from [mypy_primer](https://github.com/hauntsaninja/mypy_primer), showing the effect of this PR on open source code:\n```diff\n' + data + '```'
})
}
} catch (error) {
console.log(error)
}
@@ -1,56 +0,0 @@
name: Remove unused stubtest whitelist entries
on:
workflow_dispatch:
schedule:
- cron: '0 4 * * SAT'
jobs:
stubtest:
if: github.repository == 'python/typeshed'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest"]
python-version: [3.6, 3.7, 3.8, 3.9]
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install -U pip
pip install -U git+git://github.com/python/mypy@24fdf343
- name: Run stubtest
shell: bash
run: ./tests/stubtest_unused.py | tee stubtest-output-${{ matrix.os }}-${{ matrix.python-version }} || true
- name: Store output
uses: actions/upload-artifact@v2
with:
name: stubtest-output
path: stubtest-output-${{ matrix.os }}-${{ matrix.python-version }}
collate:
if: github.repository == 'python/typeshed'
runs-on: ubuntu-latest
needs: stubtest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Get stubtest outputs
uses: actions/download-artifact@v2
with:
name: stubtest-output
- name: Collate duplicates
run: cat stubtest-output-* | sort -u | tee stubtest-output
- name: Remove entries from whitelists
run: python scripts/update-stubtest-whitelist.py stubtest-output
- name: Create pull request
uses: peter-evans/create-pull-request@v3
with:
commit-message: Remove unused stubtest whitelist entries
title: "[gh-action] Remove unused stubtest whitelist entries"
-106
View File
@@ -1,106 +0,0 @@
name: Check stubs
on:
push:
pull_request:
jobs:
file-consistency:
name: Check file consistency
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: ./tests/check_consistent.py
flake8:
name: Lint with flake8
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: |
pip install $(grep flake8 requirements-tests-py3.txt)
flake8
black:
name: Check formatting with black
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: |
pip install $(grep black requirements-tests-py3.txt)
black --check --diff stdlib third_party
isort:
name: Check imports with isort
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: |
pip install $(grep isort requirements-tests-py3.txt)
isort --check-only --diff stdlib third_party
pytype:
name: Run pytype against the stubs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.6
- run: pip install -r requirements-tests-py3.txt
- run: ./tests/pytype_test.py
mypy:
name: Run mypy against the stubs
runs-on: ubuntu-latest
strategy:
matrix:
platform: ["linux", "win32", "darwin"]
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: pip install -U git+git://github.com/python/mypy
- run: ./tests/mypy_test.py --platform=${{ matrix.platform }}
mypy-self-check:
name: Check mypy source with itself
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: ./tests/mypy_self_check.py
mypy-test-suite:
name: Run the mypy test suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: ./tests/mypy_test_suite.py
stubtest:
name: Check stubs with stubtest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest"]
python-version: [3.6, 3.7, 3.8, 3.9]
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install -U pip
pip install -U git+git://github.com/python/mypy@24fdf343
- name: Run stubtest
run: python tests/stubtest_test.py --ignore-unused-whitelist
-1
View File
@@ -39,7 +39,6 @@ htmlcov/
.cache
nosetests.xml
coverage.xml
stubtest-output*
# Translations
*.mo
+30
View File
@@ -0,0 +1,30 @@
dist: xenial
language: python
python: 3.7
matrix:
include:
- name: "pytype"
python: 3.6
env:
- TEST_CMD="./tests/pytype_test.py"
- INSTALL="test"
- name: "mypy"
env:
- TEST_CMD="./tests/mypy_test.py"
- INSTALL="mypy"
- name: "mypy self test"
env: TEST_CMD="./tests/mypy_selftest.py"
- name: "check file consistency"
env: TEST_CMD="./tests/check_consistent.py"
- name: "flake8"
env:
- TEST_CMD="flake8"
- INSTALL="test"
install:
- if [[ $INSTALL == 'test' ]]; then pip install -r requirements-tests-py3.txt; fi
- if [[ $INSTALL == 'mypy' ]]; then pip install -U git+git://github.com/python/mypy git+git://github.com/python/typed_ast; fi
script:
- $TEST_CMD
+32 -54
View File
@@ -11,12 +11,13 @@ are important to the project's success.
1. Read the [README.md file](README.md).
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):
* Small fixes and additions can be submitted directly as pull requests,
but [contact us](#discussion) before starting significant work.
* [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 your tests pass cleanly on `mypy`, `pytype`, and `flake8`.
* Reformat your stubs with `black` and `isort`.
4. [Submit your changes](#submitting-changes) by opening a pull request.
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)
5. You can expect a reply within a few days:
* Diffs are merged when considered ready by the core team.
* Feel free to ping the core team if your pull request goes without
@@ -86,8 +87,6 @@ At present the core developers are (alphabetically):
* Greg Price (@gnprice)
* Sebastian Rittau (@srittau)
* Guido van Rossum (@gvanrossum)
* Shantanu (@hauntsaninja)
* Rune Tynan (@CraftSpider)
* Jelle Zijlstra (@JelleZijlstra)
NOTE: the process for preparing and submitting changes also applies to
@@ -104,6 +103,21 @@ recommend starting by opening an issue laying out what you want to do.
That lets a conversation happen early in case other contributors disagree
with what you'd like to do or have ideas that will help you do it.
### Adding a new library
If you want to submit type stubs for a new library, you need to
**contact the maintainers of the original library** first to let them
know and **get their permission**. Do it by opening an issue on their
project's bug tracker. This gives them the opportunity to
consider adopting type hints directly in their codebase (which you
should prefer to external type stubs). When the project owners agree
for you to submit stubs here or you do not receive a reply within
one month, open a pull request **referencing the
issue where you asked for permission**.
Make sure your changes pass the tests (the [README](README.md#running-the-tests)
has more information).
### What to include
Stubs should include the complete interface (classes, functions,
@@ -159,7 +173,7 @@ annotated function `bar()`:
def __getattr__(name: str) -> Any: ... # incomplete
class Foo:
def __getattr__(self, name: str) -> Any: ... # incomplete
def __getattr__(self, name: str) -> Any: # incomplete
x: int
y: str
@@ -223,14 +237,8 @@ rule is that they should be as concise as possible. Specifically:
* use variable annotations instead of type comments, even for stubs
that target older versions of Python;
* for arguments with a type and a default, use spaces around the `=`.
Stubs should be reformatted with the formatters
[black](https://github.com/psf/black) and
[isort](https://github.com/PyCQA/isort) before submission.
These formatters are included in typeshed's `requirements-tests-py3.txt` file.
A sample `pre-commit` file is included in the typeshed repository. Copy it
to `.git/hooks` and adjust the path to your virtual environment's `bin`
directory to automatically reformat stubs before commit.
The code formatter [black](https://github.com/python/black) will format
stubs according to this standard.
Stub files should only contain information necessary for the type
checker, and leave out unnecessary detail:
@@ -283,25 +291,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.
When adding type annotations for context manager classes, annotate
the return type of `__exit__` as bool only if the context manager
sometimes suppresses exceptions -- if it sometimes returns `True`
at runtime. If the context manager never suppresses exceptions,
have the return type be either `None` or `Optional[bool]`. If you
are not sure whether exceptions are suppressed or not or if the
context manager is meant to be subclassed, pick `Optional[bool]`.
See https://github.com/python/mypy/issues/7214 for more details.
A few guidelines for protocol names below. In cases that don't fall
into any of those categories, use your best judgement.
* Use plain names for protocols that represent a clear concept
(e.g. `Iterator`, `Container`).
* Use `SupportsX` for protocols that provide callable methods (e.g.
`SupportsInt`, `SupportsRead`, `SupportsReadSeek`).
* Use `HasX` for protocols that have readable and/or writable attributes
or getter/setter methods (e.g. `HasItems`, `HasFileno`).
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.
@@ -317,8 +306,8 @@ 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.7` directory will only be applied to versions
3.7 and above. However, stubs in the `2` directory will not be applied to
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
@@ -328,7 +317,7 @@ 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, 8):` to denote new
You can use checks like `if sys.version_info >= (3, 4):` to denote new
functionality introduced in a given Python version or solve type
differences. When doing so, only use one-tuples or two-tuples. This is
because:
@@ -341,17 +330,17 @@ because:
regardless of the micro version used.
Because of this, if a given functionality was introduced in, say, Python
3.7.4, your check:
3.4.4, your check:
* should be expressed as `if sys.version_info >= (3, 7):`
* should NOT be expressed as `if sys.version_info >= (3, 7, 4):`
* should NOT be expressed as `if sys.version_info >= (3, 8):`
* should be expressed as `if sys.version_info >= (3, 4):`
* should NOT be expressed as `if sys.version_info >= (3, 4, 4):`
* should NOT be expressed as `if sys.version_info >= (3, 5):`
This makes the type checker assume the functionality was also available
in 3.7.0 - 3.7.3, which while *technically* incorrect is relatively
in 3.4.0 - 3.4.3, which while *technically* incorrect is relatively
harmless. This is a strictly better compromise than using the latter
two forms, which would generate false positive errors for correct use
under Python 3.7.4.
under Python 3.4.4.
Note: in its current implementation, typeshed cannot contain stubs for
multiple versions of the same third-party library. Prefer to generate
@@ -391,14 +380,3 @@ Core developers should follow these rules when processing pull requests:
* 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.
* If stubs for a new library are submitted, notify the library's maintainers.
When reviewing PRs, follow these guidelines:
* Typing is hard. Try to be helpful and explain issues with the PR,
especially to new contributors.
* When reviewing auto-generated stubs, just scan for red flags and obvious
errors. Leave possible manual improvements for separate PRs.
* When reviewing large, hand-crafted PRs, you only need to look for red flags
and general issues, and do a few spot checks.
* Review smaller, hand-crafted PRs thoroughly.
+53 -113
View File
@@ -1,23 +1,20 @@
# typeshed
[![Build status](https://github.com/python/typeshed/workflows/Check%20stubs/badge.svg)](https://github.com/python/typeshed/actions?query=workflow%3A%22Check+stubs%22)
[![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)
[![Pull Requests Welcome](https://img.shields.io/badge/pull%20requests-welcome-brightgreen.svg)](https://github.com/python/typeshed/blob/master/CONTRIBUTING.md)
## About
Typeshed contains external type annotations for the Python standard library
and Python builtins, as well as third party packages as contributed by
people external to those projects.
and Python builtins, as well as third party packages.
This data can e.g. be used for static analysis, type checking or type inference.
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; do not report issues with annotations to
the project the stubs are for, but instead report them here to typeshed.**
it before submitting pull requests.**
Typeshed supports Python versions 2.7 and 3.6 and up.
Typeshed supports Python versions 2.7 and 3.4 and up.
## Using
@@ -47,13 +44,10 @@ pytype repo.
## Format
Each Python module is represented by a `.pyi` "stub file". This is a
syntactically valid Python file, although it usually cannot be run by
Python 3 (since forward references don't require string quotes). All
the methods are empty.
Each Python module is represented by a `.pyi` "stub". This is a normal Python
file (i.e., it can be interpreted by Python 3), except all the methods are empty.
Python function annotations ([PEP 3107](https://www.python.org/dev/peps/pep-3107/))
are used to describe the signature of each function or method.
are used to describe the types the function has.
See [PEP 484](http://www.python.org/dev/peps/pep-0484/) for the exact
syntax of the stub files and [CONTRIBUTING.md](CONTRIBUTING.md) for the
@@ -74,17 +68,18 @@ go into `third_party`. Since these modules can behave differently for different
versions of Python, `third_party` has version subdirectories, just like
`stdlib`.
NOTE: When you're contributing a new stub for a package that you did
not develop, please obtain consent of the package owner (this is
specified in [PEP
484](https://www.python.org/dev/peps/pep-0484/#the-typeshed-repo)).
The best way to obtain consent is to file an issue in the third-party
package's tracker and include the link to a positive response in your PR
for typeshed.
For more information on directory structure and stub versioning, see
[the relevant section of CONTRIBUTING.md](
https://github.com/python/typeshed/blob/master/CONTRIBUTING.md#stub-versioning).
Third-party packages are generally removed from typeshed when one of the
following criteria is met:
* The upstream package ships a py.typed file for at least 6-12 months, or
* the package does not support any of the Python versions supported by
typeshed.
## Contributing
Please read [CONTRIBUTING.md](CONTRIBUTING.md) before submitting pull
@@ -92,113 +87,58 @@ requests. If you have questions related to contributing, drop by the [typing Git
## Running the tests
The tests are automatically run on every PR and push to
the repo.
There are several tests:
- `tests/mypy_test.py`
tests typeshed with [mypy](https://github.com/python/mypy/)
- `tests/pytype_test.py` tests typeshed with
The tests are automatically run by Travis CI on every PR and push to
the repo. There are several sets of tests: `tests/mypy_test.py`
runs tests against [mypy](https://github.com/python/mypy/), while
`tests/pytype_test.py` runs tests against
[pytype](https://github.com/google/pytype/).
- `tests/mypy_self_check.py` checks mypy's code base using this version of
typeshed.
- `tests/mypy_test_suite.py` runs a subset of mypy's test suite using this version of
typeshed.
- `tests/check_consistent.py` checks certain files in typeshed remain
consistent with each other.
- `tests/stubtest_test.py` checks stubs against the objects at runtime.
- `flake8` enforces a style guide.
### Setup
Both sets of tests are shallow -- they verify that all stubs can be
imported but they don't check whether stubs match their implementation
(in the Python standard library or a third-party package). Also note
that each set of tests has a blacklist of modules that are not tested
at all. The blacklists also live in the tests directory.
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.6 -m venv .venv3
$ source .venv3/bin/activate
(.venv3)$ pip install -U pip
(.venv3)$ pip install -r requirements-tests-py3.txt
(.venv3)$ pip3 install -r requirements-tests-py3.txt
```
This will install mypy (you need the latest master branch from GitHub),
typed-ast, flake8 (and plugins), pytype, black and isort.
typed-ast, flake8, and pytype. You can then run mypy, flake8, and pytype tests
by invoking:
```
(.venv3)$ python3 tests/mypy_test.py
...
(.venv3)$ python3 tests/mypy_selftest.py
...
(.venv3)$ flake8
...
(.venv3)$ python3 tests/pytype_test.py
...
```
Note that flake8 only works with Python 3.6 or higher, and that to run the
pytype tests, you will need Python 2.7 and Python 3.6 interpreters. Pytype will
find these automatically if they're in `PATH`, but otherwise you must point to
them with the `--python27-exe` and `--python36-exe` arguments, respectively.
### mypy_test.py
This test requires Python 3.6 or higher; Python 3.6.1 or higher is recommended.
Run using:`(.venv3)$ python3 tests/mypy_test.py`
This test is shallow — it verifies that all stubs can be
imported but doesn't check whether stubs match their implementation
(in the Python standard library or a third-party package). It has an exclude list of
modules that are not tested at all, which also lives in the tests directory.
If you are in the typeshed repo that is submodule of the
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:
```bash
$ PYTHONPATH=../.. python3 tests/mypy_test.py
```
You can restrict mypy tests to a single version by passing `-p2` or `-p3.9`:
You can mypy tests to a single version by passing `-p2` or `-p3.5` e.g.
```bash
$ PYTHONPATH=../.. python3 tests/mypy_test.py -p3.9
running mypy --python-version 3.9 --strict-optional # with 342 files
$ PYTHONPATH=../.. python3 tests/mypy_test.py -p3.5
running mypy --python-version 3.5 --strict-optional # with 342 files
```
### pytype_test.py
This test requires Python 2.7 and Python 3.6. Pytype will
find these automatically if they're in `PATH`, but otherwise you must point to
them with the `--python27-exe` and `--python36-exe` arguments, respectively.
Run using: `(.venv3)$ python3 tests/pytype_test.py`
This test works similarly to `mypy_test.py`, except it uses `pytype`.
### mypy_self_check.py
This test requires Python 3.6 or higher; Python 3.6.1 or higher is recommended.
Run using: `(.venv3)$ python3 tests/mypy_self_check.py`
This test checks mypy's code base using mypy and typeshed code in this repo.
### mypy_test_suite.py
This test requires Python 3.5 or higher; Python 3.6.1 or higher is recommended.
Run using: `(.venv3)$ python3 tests/mypy_test_suite.py`
This test runs 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.
### check_consistent.py
Run using: `python3 tests/check_consistent.py`
### stubtest_test.py
This test requires Python 3.6 or higher.
Run using `(.venv3)$ python3 tests/stubtest_test.py`
This test compares the stdlib stubs against the objects at runtime. Because of
this, the output depends on which version of Python and on what kind of system
it is run.
Thus the easiest way to run this test is via Github Actions on your fork;
if you run it locally, it'll likely complain about system-specific
differences (in e.g, `socket`) that the type system cannot capture.
If you need a specific version of Python to repro a CI failure,
[pyenv](https://github.com/pyenv/pyenv) can help.
Due to its dynamic nature, you may run into false positives. In this case, you
can add to the whitelists for each affected Python version in
`tests/stubtest_whitelists`. Please file issues for stubtest false positives
at [mypy](https://github.com/python/mypy/issues).
To run stubtest against third party stubs, it's easiest to use stubtest
directly, with `(.venv3)$ python3 -m mypy.stubtest --custom-typeshed-dir
<path-to-typeshed> <third-party-module>`.
stubtest can also help you find things missing from the stubs.
### flake8
flake8 requires Python 3.6 or higher. Run using: `(.venv3)$ flake8`
Note typeshed uses the `flake8-pyi` and `flake8-bugbear` plugins.
-28
View File
@@ -1,28 +0,0 @@
#!/bin/sh
#
# An example hook script that will run flake8, black, and isort
# prior to committing and will stop the commit if there are any
# warnings. Adjust BIN_DIR to the virtual environment where flake8,
# black, and isort are installed.
#
# To enable this hook, copy this file to ".git/hooks".
BIN_DIR=./.venv/bin
CHANGED_FILES=$(git diff --cached --name-only --diff-filter=AM | grep .pyi || true)
if test -n "${CHANGED_FILES}" -a -d "${BIN_DIR}"; then
${BIN_DIR}/flake8 ${CHANGED_FILES}
${BIN_DIR}/black --check ${CHANGED_FILES}
${BIN_DIR}/isort --check-only ${CHANGED_FILES}
# Replace the last two lines with the following lines
# if you want to reformat changed files automatically
# before committing. Please note that partial commits
# (git add -p) will not work and will commit the whole
# file!
#
# ${BIN_DIR}/black ${CHANGED_FILES} || true
# ${BIN_DIR}/isort -y ${CHANGED_FILES} || true
# git add ${CHANGED_FILES}
fi
-43
View File
@@ -1,43 +0,0 @@
[tool.black]
line_length = 130
target_version = ["py37"]
exclude = ".*_pb2.pyi"
[tool.isort]
profile = "black"
combine_as_imports = true
line_length = 130
skip_glob = "*_pb2.pyi"
extra_standard_library = [
"typing_extensions",
"_typeshed",
# Extra modules not recognized by isort
"_compression",
"_csv",
"_curses",
"_markupbase",
"_random",
"_tkinter",
"_weakrefset",
"genericpath",
"opcode",
"pyexpat",
# Python 2 modules
"__builtin__",
"cookielib",
"cStringIO",
"httplib",
"mimetools",
"rfc822",
"thread",
"urllib2",
"urlparse",
"BaseHTTPServer",
"Queue",
"SimpleHTTPServer",
"SocketServer",
"StringIO",
"UserDict",
"UserList",
"UserString",
]
+4 -6
View File
@@ -1,8 +1,6 @@
git+https://github.com/python/mypy.git@master
typed-ast>=1.0.4
black==20.8b1
flake8==3.8.4
flake8-bugbear==20.1.4
flake8-pyi==20.10.0
isort[pyproject]==5.5.3
pytype>=2020.09.16
flake8==3.6.0
flake8-bugbear==18.8.0
flake8-pyi==18.3.1
pytype>=2019.5.15
-68
View File
@@ -1,68 +0,0 @@
#!/bin/bash
# Some of the proto .pyi stubs in third_party/2and3/google/protobuf/
# are autogenerated using the mypy-protobuf project on the
# latest `.proto` files shipped with protoc.
#
# When run, this script will autogenerate the _pb2.pyi stubs to
# third_party/2and3/google/protobuf. It should be run any time there's
# a meaningful update to either PROTOBUF_VERSION or MYPY_PROTOBUF_VERSION,
# followed by committing the changes to typeshed
#
# Update these two variables when rerunning script
PROTOBUF_VERSION=3.14.0
MYPY_PROTOBUF_VERSION=8639282dae3bb64b2e1db9928d72fc374f7fa831 # Update to 1.24 when it releases
set -ex
if uname -a | grep Darwin; then
PLAT=osx
else
PLAT=linux
fi
REPO_ROOT=$(realpath $(dirname "${BASH_SOURCE[0]}")/..)
TMP_DIR=$(mktemp -d)
PYTHON_PROTOBUF_FILENAME=protobuf-python-${PROTOBUF_VERSION}.zip
PROTOC_FILENAME=protoc-${PROTOBUF_VERSION}-${PLAT}-x86_64.zip
PROTOC_URL=https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/${PROTOC_FILENAME}
PYTHON_PROTOBUF_URL=https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/${PYTHON_PROTOBUF_FILENAME}
cd $TMP_DIR
echo "Working in $TMP_DIR"
# Install protoc
wget $PROTOC_URL
mkdir protoc_install
unzip $PROTOC_FILENAME -d protoc_install
# Fetch protoc-python (which contains all the .proto files)
wget $PYTHON_PROTOBUF_URL
unzip $PYTHON_PROTOBUF_FILENAME
PYTHON_PROTOBUF_DIR=protobuf-$PROTOBUF_VERSION
# Install mypy-protobuf
VENV=venv
python3 -m virtualenv $VENV
source $VENV/bin/activate
python3 -m pip install git+https://github.com/dropbox/mypy-protobuf@${MYPY_PROTOBUF_VERSION}#subdirectory=python
# Remove existing pyi
find $REPO_ROOT/third_party/2and3/ -name "*_pb2.pyi" -delete
# Roughly reproduce the subset of .proto files on the public interface as described
# by find_package_modules in the protobuf setup.py.
# The logic (as of 3.14.0) can roughly be described as a whitelist of .proto files
# further limited to exclude *test* and internal/
# https://github.com/protocolbuffers/protobuf/blob/master/python/setup.py
PROTO_FILES=$(grep "generate_proto.*google" $PYTHON_PROTOBUF_DIR/python/setup.py | \
cut -d\" -f2 | \
grep -v "test" | \
grep -v google/protobuf/internal/ | \
grep -v google/protobuf/pyext/python.proto | \
grep -v src/google/protobuf/util/json_format.proto | \
grep -v src/google/protobuf/util/json_format_proto3.proto | \
sed "s:^:$PYTHON_PROTOBUF_DIR/python/:" | \
xargs -L1 realpath --relative-to=. \
)
# And regenerate!
protoc_install/bin/protoc --proto_path=$PYTHON_PROTOBUF_DIR/src --mypy_out=$REPO_ROOT/third_party/2and3 $PROTO_FILES
-337
View File
@@ -1,337 +0,0 @@
"""
Ad-hoc script to migrate typeshed to a new directory structure proposed in
https://github.com/python/typeshed/issues/2491#issuecomment-611607557
"""
import ast
import os
import os.path
import shutil
from dataclasses import dataclass
from typing import List, Optional, Set, Tuple
# These names may be still discussed so I make them constants.
STDLIB_NAMESPACE = "stdlib"
THIRD_PARTY_NAMESPACE = "stubs"
DEFAULT_VERSION = "0.1"
DEFAULT_PY3_VERSION = "3.6"
PY2_NAMESPACE = "python2"
OUTPUT_DIR = "out"
# Third party imports (type ignored) of missing stubs.
MISSING_WHITELIST = {
"thrift",
}
# Manually collected special cases where distribution name and
# package name are different.
package_to_distribution = {
"_pytest": "pytest",
"yaml": "PyYAML",
"typing_extensions": "typing-extensions",
"mypy_extensions": "mypy-extensions",
"pyre_extensions": "pyre-extensions",
"attr": "attrs",
"concurrent": "futures",
"Crypto": "pycrypto",
"datetimerange": "DateTimeRange",
"dateutil": "python-dateutil",
"enum": "enum34",
"flask": "Flask",
"gflags": "python-gflags",
"google": "protobuf",
"jinja2": "Jinja2",
"markupsafe": "MarkupSafe",
"OpenSSL": "openssl-python",
"pymysql": "PyMySQL",
"pyVmomi": "pyvmomi",
"routes": "Routes",
"typed_ast": "typed-ast",
"werkzeug": "Werkzeug",
}
known_versions = {
"mypy-extensions": "0.4",
"typing-extensions": "3.7",
"typed-ast": "1.4",
}
# Classes with "Package" in name represent both packages and modules.
# The latter two are distinguished by is_dir flag.
class PackageBase:
"""Common attributes for packages/modules"""
path: str # full initial path like stdlib/2and3/argparse.pyi
is_dir: bool
@property
def name(self) -> str:
_, tail = os.path.split(self.path)
if self.is_dir:
assert not tail.endswith(".pyi")
return tail
assert tail.endswith(".pyi")
name, _ = os.path.splitext(tail)
return name
@dataclass
class StdLibPackage(PackageBase):
"""Package/module in standard library."""
path: str
py_version: Optional[str] # Can be omitted for Python 2 only packages.
is_dir: bool
@dataclass
class ThirdPartyPackage(PackageBase):
path: str
py2_compatible: bool
py3_compatible: bool
is_dir: bool
requires: List[str] # distributions this depends on
def add_stdlib_packages_from(subdir: str, packages: List[StdLibPackage], py_version: Optional[str]) -> None:
"""Add standard library packages/modules from a given stdlib/xxx subdirectory.
Append to packages list in-place, use py_version as the minimal supported version.
"""
for name in os.listdir(subdir):
path = os.path.join(subdir, name)
packages.append(StdLibPackage(path, py_version, is_dir=os.path.isdir(path)))
def collect_stdlib_packages() -> Tuple[List[StdLibPackage], List[StdLibPackage]]:
"""Collect standard library packages/modules from all current stdlib/xxx sub-directories."""
stdlib: List[StdLibPackage] = []
py2_stdlib: List[StdLibPackage] = []
# These will go to a separate subdirectory.
add_stdlib_packages_from("stdlib/2", py2_stdlib, None)
add_stdlib_packages_from("stdlib/2and3", stdlib, "2.7")
# Use oldest currently supported version for Python 3 packages/modules.
add_stdlib_packages_from("stdlib/3", stdlib, DEFAULT_PY3_VERSION)
for version in ("3.7", "3.8", "3.9"):
subdir = os.path.join("stdlib", version)
if os.path.isdir(subdir):
add_stdlib_packages_from(subdir, stdlib, version)
return stdlib, py2_stdlib
def add_third_party_packages_from(
subdir: str, packages: List[ThirdPartyPackage], py2_compatible: bool, py3_compatible: bool
) -> None:
"""Add third party packages/modules from a given third_party/xxx subdirectory."""
for name in os.listdir(subdir):
path = os.path.join(subdir, name)
packages.append(ThirdPartyPackage(path, py2_compatible, py3_compatible, requires=[], is_dir=os.path.isdir(path)))
def collect_third_party_packages() -> Tuple[List[ThirdPartyPackage], List[ThirdPartyPackage]]:
"""Collect third party packages/modules from all current third_party/xxx sub-directories."""
third_party: List[ThirdPartyPackage] = []
py2_third_party: List[ThirdPartyPackage] = []
add_third_party_packages_from("third_party/3", third_party, py2_compatible=False, py3_compatible=True)
add_third_party_packages_from("third_party/2and3", third_party, py2_compatible=True, py3_compatible=True)
# We special-case Python 2 for third party packages like six.
subdir = "third_party/2"
py3_packages = os.listdir("third_party/3")
for name in os.listdir(subdir):
path = os.path.join(subdir, name)
package = ThirdPartyPackage(path, py2_compatible=True, py3_compatible=False, requires=[], is_dir=os.path.isdir(path))
if name in py3_packages:
# If there is a package with the same name in /2 and /3, we add the former to
# a separate list, packages from there will be put into /python2 sub-directories.
py2_third_party.append(package)
else:
third_party.append(package)
return third_party, py2_third_party
def get_top_imported_names(file: str) -> Set[str]:
"""Collect names imported in given file.
We only collect top-level names, i.e. `from foo.bar import baz`
will only add `foo` to the list.
"""
if not file.endswith(".pyi"):
return set()
with open(os.path.join(file), "rb") as f:
content = f.read()
parsed = ast.parse(content)
top_imported = set()
for node in ast.walk(parsed):
if isinstance(node, ast.Import):
for name in node.names:
top_imported.add(name.name.split(".")[0])
elif isinstance(node, ast.ImportFrom):
if node.level > 0:
# Relative imports always refer to the current package.
continue
assert node.module
top_imported.add(node.module.split(".")[0])
return top_imported
def populate_requirements(
package: ThirdPartyPackage, stdlib: List[str], py2_stdlib: List[str], known_distributions: Set[str]
) -> None:
"""Generate requirements using imports found in a package."""
assert not package.requires, "Populate must be called once"
if not package.is_dir:
all_top_imports = get_top_imported_names(package.path)
else:
all_top_imports = set()
for dir_path, _, file_names in os.walk(package.path):
for file_name in file_names:
all_top_imports |= get_top_imported_names(os.path.join(dir_path, file_name))
# Generate dependencies using collected imports.
requirements = set()
for name in all_top_imports:
# Note: dependencies are between distributions, not packages.
distribution = package_to_distribution.get(name, name)
if package.py3_compatible and name not in stdlib:
if distribution in known_distributions:
requirements.add(distribution)
else:
# Likely a conditional import.
assert distribution in py2_stdlib or distribution in MISSING_WHITELIST
if package.py2_compatible and name not in py2_stdlib:
if distribution in known_distributions:
requirements.add(distribution)
else:
# Likely a conditional import.
assert distribution in stdlib or distribution in MISSING_WHITELIST
# Remove dependency to itself generated by absolute imports.
current_distribution = package_to_distribution.get(package.name, package.name)
package.requires = sorted(requirements - {current_distribution})
def generate_versions(packages: List[StdLibPackage]) -> str:
"""Generate the stdlib/VERSIONS file for packages/modules."""
lines = []
for package in packages:
assert package.py_version is not None
lines.append(f"{package.name}: {package.py_version}")
return "\n".join(sorted(lines))
def copy_stdlib(packages: List[StdLibPackage], py2_packages: List[StdLibPackage]) -> None:
"""Refactor the standard library part using collected metadata."""
stdlib_dir = os.path.join(OUTPUT_DIR, STDLIB_NAMESPACE)
os.makedirs(stdlib_dir, exist_ok=True)
# Write version metadata.
with open(os.path.join(stdlib_dir, "VERSIONS"), "w") as f:
f.write(generate_versions(packages))
f.write("\n")
# Copy stdlib/2and3 and stdlib/3 packages/modules.
for package in packages:
if not package.is_dir:
shutil.copy(package.path, stdlib_dir)
else:
shutil.copytree(package.path, os.path.join(stdlib_dir, package.name))
# Copy stdlib/2 packages/modules to a nested /python namespace.
if py2_packages:
py2_stdlib_dir = os.path.join(stdlib_dir, PY2_NAMESPACE)
os.makedirs(py2_stdlib_dir, exist_ok=True)
for package in py2_packages:
if not package.is_dir:
shutil.copy(package.path, py2_stdlib_dir)
else:
shutil.copytree(package.path, os.path.join(py2_stdlib_dir, package.name))
def generate_metadata(package: ThirdPartyPackage, py2_packages: List[str]) -> str:
"""Generate METADATA.toml for a given package.
Only add compatibility flags if they are different from default values:
python2 = false, python3 = true.
Note: the metadata should be generated per distribution, but we just use
an arbitrary package to populate it, since it should be the same for all
packages.
"""
version = known_versions.get(
package_to_distribution.get(package.name, package.name),
DEFAULT_VERSION,
)
lines = [f'version = "{version}"']
if package.py2_compatible or package.name in py2_packages:
# Note: for packages like six that appear in both normal and Python 2 only
# lists we force set python2 = true.
lines.append("python2 = true")
if not package.py3_compatible:
lines.append("python3 = false")
if package.requires:
distributions = [f'"types-{package_to_distribution.get(dep, dep)}"' for dep in package.requires]
lines.append(f"requires = [{', '.join(distributions)}]")
return "\n".join(lines)
def copy_third_party(packages: List[ThirdPartyPackage], py2_packages: List[ThirdPartyPackage]) -> None:
"""Refactor the third party part using collected metadata."""
third_party_dir = os.path.join(OUTPUT_DIR, THIRD_PARTY_NAMESPACE)
os.makedirs(third_party_dir, exist_ok=True)
# Note: these include Python 3 versions of packages like six.
for package in packages:
distribution = package_to_distribution.get(package.name, package.name)
distribution_dir = os.path.join(third_party_dir, distribution)
os.makedirs(distribution_dir, exist_ok=True)
metadata_file = os.path.join(distribution_dir, "METADATA.toml")
if not os.path.isfile(metadata_file):
# Write metadata once.
# TODO: check consistency between different packages in same distribution?
with open(metadata_file, "w") as f:
f.write(generate_metadata(package, [package.name for package in py2_packages]))
f.write("\n")
if not package.is_dir:
shutil.copy(package.path, distribution_dir)
else:
shutil.copytree(package.path, os.path.join(distribution_dir, package.name))
# Add Python 2 counterparts of packages like six (with different stubs) to nested
# namespaces like six/python2/six.
for package in py2_packages:
distribution = package_to_distribution.get(package.name, package.name)
distribution_dir = os.path.join(third_party_dir, distribution, PY2_NAMESPACE)
os.makedirs(distribution_dir, exist_ok=True)
if not package.is_dir:
shutil.copy(package.path, distribution_dir)
else:
shutil.copytree(package.path, os.path.join(distribution_dir, package.name))
def main() -> None:
# Collect metadata for Python 2 and 3, and Python 2 only standard library
# packages/modules. The latter will go to a separate nested namespace.
stdlib, py2_stdlib = collect_stdlib_packages()
third_party, py2_third_party = collect_third_party_packages()
# Collect standard library names to filter out from dependencies.
stdlib_names = [package.name for package in stdlib]
py2_stdlib_names = [package.name for package in py2_stdlib]
py2_stdlib_names += [package.name for package in stdlib if package.py_version == "2.7"]
# Collect all known distributions (for sanity checks).
known_distributions = {package_to_distribution.get(package.name, package.name) for package in third_party + py2_third_party}
# Compute dependencies between third party packages/modules to populate metadata.
for package in third_party + py2_third_party:
populate_requirements(package, stdlib_names, py2_stdlib_names, known_distributions)
# Copy the files to a separate location (to not clobber the root directory).
if not os.path.isdir(OUTPUT_DIR):
os.mkdir(OUTPUT_DIR)
copy_stdlib(stdlib, py2_stdlib)
copy_third_party(third_party, py2_third_party)
if __name__ == "__main__":
main()
-59
View File
@@ -1,59 +0,0 @@
#!/usr/bin/env python3
# This script removes lines from stubtest whitelists, according to
# an input file. The input file has one entry to remove per line.
# Each line consists of a whitelist filename and an entry, separated
# by a colon.
# This script is used by the workflow to remove unused whitelist entries.
import sys
from collections import defaultdict
from typing import Dict, List, Set, Tuple
def main() -> None:
if len(sys.argv) != 2:
print(f"Usage: {sys.argv[0]} FILENAME", file=sys.stderr)
sys.exit(1)
to_remove = parse_input_file(sys.argv[1])
for filename, entries in to_remove.items():
remove_entries_from_whitelist(filename, entries)
def parse_input_file(input_file: str) -> Dict[str, Set[str]]:
to_remove = defaultdict(set)
with open(input_file) as f:
for filename, wl_entry in [parse_input_line(li) for li in f if li.strip()]:
to_remove[filename].add(wl_entry)
return to_remove
# Returns a (filename, entry) tuple.
def parse_input_line(line: str) -> Tuple[str, str]:
line = line.strip()
filename, entry = line.split(":", maxsplit=1)
return filename, entry
def remove_entries_from_whitelist(filename: str, entries: Set[str]) -> None:
new_lines: List[str] = []
with open(filename) as f:
for line in f:
entry = line.strip().split(" #")[0]
if entry in entries:
entries.remove(entry)
else:
new_lines.append(line)
if entries:
print(f"WARNING: The following entries were not found in '{filename}':", file=sys.stderr)
for entry in entries:
print(f" * {entry}")
with open(filename, "w") as f:
for line in new_lines:
f.write(line)
if __name__ == "__main__":
main()
+13 -7
View File
@@ -1,13 +1,16 @@
import mimetools
# Stubs for BaseHTTPServer (Python 2.7)
from typing import Any, BinaryIO, Mapping, Optional, Tuple, Union
import SocketServer
from typing import Any, BinaryIO, Callable, Mapping, Optional, Tuple, Union
import mimetools
class HTTPServer(SocketServer.TCPServer):
server_name: str
server_port: int
def __init__(self, server_address: Tuple[str, int], RequestHandlerClass: Callable[..., BaseHTTPRequestHandler]) -> None: ...
def __init__(self, server_address: Tuple[str, int],
RequestHandlerClass: type) -> None: ...
class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
class BaseHTTPRequestHandler:
client_address: Tuple[str, int]
server: SocketServer.BaseServer
close_connection: bool
@@ -24,15 +27,18 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
protocol_version: str
MessageClass: type
responses: Mapping[int, Tuple[str, str]]
def __init__(self, request: bytes, client_address: Tuple[str, int], server: SocketServer.BaseServer) -> None: ...
def __init__(self, request: bytes, client_address: Tuple[str, int],
server: SocketServer.BaseServer) -> None: ...
def handle(self) -> None: ...
def handle_one_request(self) -> None: ...
def send_error(self, code: int, message: Optional[str] = ...) -> None: ...
def send_response(self, code: int, message: Optional[str] = ...) -> None: ...
def send_response(self, code: int,
message: Optional[str] = ...) -> None: ...
def send_header(self, keyword: str, value: str) -> None: ...
def end_headers(self) -> None: ...
def flush_headers(self) -> None: ...
def log_request(self, code: Union[int, str] = ..., size: Union[int, str] = ...) -> None: ...
def log_request(self, code: Union[int, str] = ...,
size: Union[int, str] = ...) -> None: ...
def log_error(self, format: str, *args: Any) -> None: ...
def log_message(self, format: str, *args: Any) -> None: ...
def version_string(self) -> str: ...
-6
View File
@@ -1,6 +0,0 @@
import SimpleHTTPServer
from typing import List
class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
cgi_directories: List[str]
def do_POST(self) -> None: ...
+10 -10
View File
@@ -1,5 +1,4 @@
from _typeshed import SupportsNoArgReadline
from typing import IO, Any, Dict, List, Optional, Sequence, Tuple, Union
from typing import Any, IO, Sequence, Tuple, Union, List, Dict, Protocol, Optional
DEFAULTSECT: str
MAX_INTERPOLATION_DEPTH: int
@@ -51,10 +50,13 @@ class MissingSectionHeaderError(ParsingError):
line: Any
def __init__(self, filename: str, lineno: Any, line: Any) -> None: ...
class _Readable(Protocol):
def readline(self) -> str: ...
class RawConfigParser:
_dict: Any
_sections: Dict[Any, Any]
_defaults: Dict[Any, Any]
_sections: dict
_defaults: dict
_optcre: Any
SECTCRE: Any
OPTCRE: Any
@@ -66,7 +68,7 @@ class RawConfigParser:
def has_section(self, section: str) -> bool: ...
def options(self, section: str) -> List[str]: ...
def read(self, filenames: Union[str, Sequence[str]]) -> List[str]: ...
def readfp(self, fp: SupportsNoArgReadline[str], filename: str = ...) -> None: ...
def readfp(self, fp: _Readable, filename: str = ...) -> None: ...
def get(self, section: str, option: str) -> str: ...
def items(self, section: str) -> List[Tuple[Any, Any]]: ...
def _get(self, section: str, conv: type, option: str) -> Any: ...
@@ -84,14 +86,12 @@ class RawConfigParser:
class ConfigParser(RawConfigParser):
_KEYCRE: Any
def get(self, section: str, option: str, raw: bool = ..., vars: Optional[Dict[Any, Any]] = ...) -> Any: ...
def items(self, section: str, raw: bool = ..., vars: Optional[Dict[Any, Any]] = ...) -> List[Tuple[str, Any]]: ...
def get(self, section: str, option: str, raw: bool = ..., vars: Optional[dict] = ...) -> Any: ...
def items(self, section: str, raw: bool = ..., vars: Optional[dict] = ...) -> List[Tuple[str, Any]]: ...
def _interpolate(self, section: str, option: str, rawval: Any, vars: Any) -> str: ...
def _interpolation_replace(self, match: Any) -> str: ...
class SafeConfigParser(ConfigParser):
_interpvar_re: Any
def _interpolate(self, section: str, option: str, rawval: Any, vars: Any) -> str: ...
def _interpolate_some(
self, option: str, accum: List[Any], rest: str, section: str, map: Dict[Any, Any], depth: int
) -> None: ...
def _interpolate_some(self, option: str, accum: list, rest: str, section: str, map: dict, depth: int) -> None: ...
+3 -3
View File
@@ -1,8 +1,8 @@
from typing import Any, Dict, Optional
from typing import Any, Optional
class CookieError(Exception): ...
class Morsel(Dict[Any, Any]):
class Morsel(dict):
key: Any
def __init__(self): ...
def __setitem__(self, K, V): ...
@@ -14,7 +14,7 @@ class Morsel(Dict[Any, Any]):
def js_output(self, attrs: Optional[Any] = ...): ...
def OutputString(self, attrs: Optional[Any] = ...): ...
class BaseCookie(Dict[Any, Any]):
class BaseCookie(dict):
def value_decode(self, val): ...
def value_encode(self, val): ...
def __init__(self, input: Optional[Any] = ...): ...
+5 -2
View File
@@ -1,5 +1,4 @@
from typing import AnyStr, List, Tuple
from typing import List, Tuple, AnyStr
from markupbase import ParserBase
class HTMLParser(ParserBase):
@@ -7,9 +6,11 @@ class HTMLParser(ParserBase):
def feed(self, feed: AnyStr) -> None: ...
def close(self) -> None: ...
def reset(self) -> None: ...
def get_starttag_text(self) -> AnyStr: ...
def set_cdata_mode(self, AnyStr) -> None: ...
def clear_cdata_mode(self) -> None: ...
def handle_startendtag(self, tag: AnyStr, attrs: List[Tuple[AnyStr, AnyStr]]): ...
def handle_starttag(self, tag: AnyStr, attrs: List[Tuple[AnyStr, AnyStr]]): ...
def handle_endtag(self, tag: AnyStr): ...
@@ -19,7 +20,9 @@ class HTMLParser(ParserBase):
def handle_comment(self, data: AnyStr): ...
def handle_decl(self, decl: AnyStr): ...
def handle_pi(self, data: AnyStr): ...
def unknown_decl(self, data: AnyStr): ...
def unescape(self, s: AnyStr) -> AnyStr: ...
class HTMLParseError(Exception):
+8 -6
View File
@@ -1,7 +1,9 @@
from collections import deque
from typing import Any, Deque, Generic, Optional, TypeVar
# Stubs for Queue (Python 2)
_T = TypeVar("_T")
from collections import deque
from typing import Any, TypeVar, Generic, Optional
_T = TypeVar('_T')
class Empty(Exception): ...
class Full(Exception): ...
@@ -13,7 +15,7 @@ class Queue(Generic[_T]):
not_full: Any
all_tasks_done: Any
unfinished_tasks: Any
queue: Deque[Any] # undocumented
queue: deque # undocumented
def __init__(self, maxsize: int = ...) -> None: ...
def task_done(self) -> None: ...
def join(self) -> None: ...
@@ -25,5 +27,5 @@ class Queue(Generic[_T]):
def get(self, block: bool = ..., timeout: Optional[float] = ...) -> _T: ...
def get_nowait(self) -> _T: ...
class PriorityQueue(Queue[_T]): ...
class LifoQueue(Queue[_T]): ...
class PriorityQueue(Queue): ...
class LifoQueue(Queue): ...
+4 -2
View File
@@ -1,13 +1,15 @@
# Stubs for SimpleHTTPServer (Python 2)
from typing import Any, AnyStr, IO, Mapping, Optional, Union
import BaseHTTPServer
from StringIO import StringIO
from typing import IO, Any, AnyStr, Mapping, Optional, Union
class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
server_version: 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[Any]]: ...
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: ...
+45 -61
View File
@@ -1,89 +1,80 @@
# NB: SocketServer.pyi and socketserver.pyi must remain consistent!
# Stubs for socketserver
from typing import Any, BinaryIO, Optional, Tuple, Type
from socket import SocketType
import sys
import types
from socket import SocketType
from typing import Any, BinaryIO, Callable, ClassVar, List, Optional, Text, Tuple, Type, Union
class BaseServer:
address_family: int
RequestHandlerClass: Callable[..., BaseRequestHandler]
RequestHandlerClass: type
server_address: Tuple[str, int]
socket: SocketType
allow_reuse_address: bool
request_queue_size: int
socket_type: int
timeout: Optional[float]
def __init__(self, server_address: Any, RequestHandlerClass: Callable[..., BaseRequestHandler]) -> None: ...
def __init__(self, server_address: Tuple[str, int],
RequestHandlerClass: type) -> None: ...
def fileno(self) -> int: ...
def handle_request(self) -> None: ...
def serve_forever(self, poll_interval: float = ...) -> None: ...
def shutdown(self) -> None: ...
def server_close(self) -> None: ...
def finish_request(self, request: bytes, client_address: Tuple[str, int]) -> None: ...
def get_request(self) -> Tuple[SocketType, Tuple[str, int]]: ...
def handle_error(self, request: bytes, client_address: Tuple[str, int]) -> None: ...
def finish_request(self, request: bytes,
client_address: Tuple[str, int]) -> None: ...
def get_request(self) -> None: ...
def handle_error(self, request: bytes,
client_address: Tuple[str, int]) -> None: ...
def handle_timeout(self) -> None: ...
def process_request(self, request: bytes, client_address: Tuple[str, int]) -> None: ...
def process_request(self, request: bytes,
client_address: Tuple[str, int]) -> None: ...
def server_activate(self) -> None: ...
def server_bind(self) -> None: ...
def verify_request(self, request: bytes, client_address: Tuple[str, int]) -> bool: ...
def verify_request(self, request: bytes,
client_address: Tuple[str, int]) -> bool: ...
if sys.version_info >= (3, 6):
def __enter__(self) -> BaseServer: ...
def __exit__(self, exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[types.TracebackType]) -> bool: ...
if sys.version_info >= (3, 3):
def service_actions(self) -> None: ...
class TCPServer(BaseServer):
def __init__(
self,
server_address: Tuple[str, int],
RequestHandlerClass: Callable[..., BaseRequestHandler],
bind_and_activate: bool = ...,
) -> None: ...
def __init__(self, server_address: Tuple[str, int],
RequestHandlerClass: type,
bind_and_activate: bool = ...) -> None: ...
class UDPServer(BaseServer):
def __init__(
self,
server_address: Tuple[str, int],
RequestHandlerClass: Callable[..., BaseRequestHandler],
bind_and_activate: bool = ...,
) -> None: ...
def __init__(self, server_address: Tuple[str, int],
RequestHandlerClass: type,
bind_and_activate: bool = ...) -> None: ...
if sys.platform != "win32":
if sys.platform != 'win32':
class UnixStreamServer(BaseServer):
def __init__(
self,
server_address: Union[Text, bytes],
RequestHandlerClass: Callable[..., BaseRequestHandler],
bind_and_activate: bool = ...,
) -> None: ...
def __init__(self, server_address: Tuple[str, int],
RequestHandlerClass: type,
bind_and_activate: bool = ...) -> None: ...
class UnixDatagramServer(BaseServer):
def __init__(
self,
server_address: Union[Text, bytes],
RequestHandlerClass: Callable[..., BaseRequestHandler],
bind_and_activate: bool = ...,
) -> None: ...
def __init__(self, server_address: Tuple[str, int],
RequestHandlerClass: type,
bind_and_activate: bool = ...) -> None: ...
if sys.platform != "win32":
class ForkingMixIn:
timeout: Optional[float] # undocumented
active_children: Optional[List[int]] # undocumented
max_children: int # undocumented
def collect_children(self) -> None: ... # undocumented
def handle_timeout(self) -> None: ... # undocumented
def process_request(self, request: bytes, client_address: Tuple[str, int]) -> None: ...
class ThreadingMixIn:
daemon_threads: bool
def process_request_thread(self, request: bytes, client_address: Tuple[str, int]) -> None: ... # undocumented
def process_request(self, request: bytes, client_address: Tuple[str, int]) -> None: ...
if sys.platform != "win32":
class ForkingTCPServer(ForkingMixIn, TCPServer): ...
class ForkingUDPServer(ForkingMixIn, UDPServer): ...
class ForkingMixIn: ...
class ThreadingMixIn: ...
class ForkingTCPServer(ForkingMixIn, TCPServer): ...
class ForkingUDPServer(ForkingMixIn, UDPServer): ...
class ThreadingTCPServer(ThreadingMixIn, TCPServer): ...
class ThreadingUDPServer(ThreadingMixIn, UDPServer): ...
if sys.platform != "win32":
if sys.platform != 'win32':
class ThreadingUnixStreamServer(ThreadingMixIn, UnixStreamServer): ...
class ThreadingUnixDatagramServer(ThreadingMixIn, UnixDatagramServer): ...
class BaseRequestHandler:
# Those are technically of types, respectively:
# * Union[SocketType, Tuple[bytes, SocketType]]
@@ -93,23 +84,16 @@ class BaseRequestHandler:
# https://github.com/python/typeshed/pull/384#issuecomment-234649696)
request: Any
client_address: Any
server: BaseServer
def __init__(self, request: Any, client_address: Any, server: BaseServer) -> None: ...
def setup(self) -> None: ...
def handle(self) -> None: ...
def finish(self) -> None: ...
class StreamRequestHandler(BaseRequestHandler):
rbufsize: ClassVar[int] # Undocumented
wbufsize: ClassVar[int] # Undocumented
timeout: ClassVar[Optional[float]] # Undocumented
disable_nagle_algorithm: ClassVar[bool] # Undocumented
connection: SocketType # Undocumented
rfile: BinaryIO
wfile: BinaryIO
class DatagramRequestHandler(BaseRequestHandler):
packet: SocketType # Undocumented
socket: SocketType # Undocumented
rfile: BinaryIO
wfile: BinaryIO
+3 -1
View File
@@ -1,4 +1,6 @@
from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, List, Optional
# Stubs for StringIO (Python 2)
from typing import Any, IO, AnyStr, Iterator, Iterable, Generic, List, Optional
class StringIO(IO[AnyStr], Generic[AnyStr]):
closed: bool
+12 -21
View File
@@ -1,35 +1,25 @@
from typing import (
Any,
Container,
Dict,
Generic,
Iterable,
Iterator,
List,
Mapping,
Optional,
Sized,
Tuple,
TypeVar,
Union,
overload,
)
from typing import (Any, Container, Dict, Generic, Iterable, Iterator, List,
Mapping, Optional, Sized, Tuple, TypeVar, Union, overload)
_KT = TypeVar("_KT")
_VT = TypeVar("_VT")
_T = TypeVar("_T")
_KT = TypeVar('_KT')
_VT = TypeVar('_VT')
_T = TypeVar('_T')
class UserDict(Dict[_KT, _VT], Generic[_KT, _VT]):
data: Dict[_KT, _VT]
data: Mapping[_KT, _VT]
def __init__(self, initialdata: Mapping[_KT, _VT] = ...) -> None: ...
# TODO: __iter__ is not available for UserDict
class IterableUserDict(UserDict[_KT, _VT], Generic[_KT, _VT]): ...
class IterableUserDict(UserDict[_KT, _VT], Generic[_KT, _VT]):
...
class DictMixin(Iterable[_KT], Container[_KT], Sized, Generic[_KT, _VT]):
def has_key(self, key: _KT) -> bool: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_KT]: ...
# From typing.Mapping[_KT, _VT]
# (can't inherit because of keys())
@overload
@@ -42,6 +32,7 @@ class DictMixin(Iterable[_KT], Container[_KT], Sized, Generic[_KT, _VT]):
def itervalues(self) -> Iterator[_VT]: ...
def iteritems(self) -> Iterator[Tuple[_KT, _VT]]: ...
def __contains__(self, o: Any) -> bool: ...
# From typing.MutableMapping[_KT, _VT]
def clear(self) -> None: ...
def pop(self, k: _KT, default: _VT = ...) -> _VT: ...
+3 -4
View File
@@ -1,10 +1,9 @@
from typing import Iterable, List, MutableSequence, TypeVar, Union, overload
from typing import Iterable, MutableSequence, TypeVar, Union, overload
_T = TypeVar("_T")
_S = TypeVar("_S")
_ULT = TypeVar("_ULT", bound=UserList)
class UserList(MutableSequence[_T]):
data: List[_T]
def insert(self, index: int, object: _T) -> None: ...
@overload
def __setitem__(self, i: int, o: _T) -> None: ...
@@ -15,5 +14,5 @@ class UserList(MutableSequence[_T]):
@overload
def __getitem__(self, i: int) -> _T: ...
@overload
def __getitem__(self: _S, s: slice) -> _S: ...
def __getitem__(self: _ULT, s: slice) -> _ULT: ...
def sort(self) -> None: ...
+2 -2
View File
@@ -1,5 +1,5 @@
import collections
from typing import Any, Iterable, List, MutableSequence, Optional, Sequence, Text, Tuple, TypeVar, Union, overload
from typing import Any, Iterable, List, MutableSequence, Sequence, Optional, overload, Text, TypeVar, Tuple, Union
_UST = TypeVar("_UST", bound=UserString)
_MST = TypeVar("_MST", bound=MutableString)
@@ -62,7 +62,7 @@ class UserString(Sequence[UserString]):
def upper(self: _UST) -> _UST: ...
def zfill(self: _UST, width: int) -> _UST: ...
class MutableString(UserString, MutableSequence[MutableString]):
class MutableString(UserString, MutableSequence[MutableString]): # type: ignore
@overload
def __getitem__(self: _MST, i: int) -> _MST: ...
@overload
+1063 -636
View File
File diff suppressed because it is too large Load Diff
+35 -8
View File
@@ -10,7 +10,8 @@ class AST:
_fields: typing.Tuple[str, ...]
def __init__(self, *args, **kwargs) -> None: ...
class mod(AST): ...
class mod(AST):
...
class Module(mod):
body: typing.List[stmt]
@@ -24,6 +25,7 @@ class Expression(mod):
class Suite(mod):
body: typing.List[stmt]
class stmt(AST):
lineno: int
col_offset: int
@@ -121,7 +123,10 @@ class Expr(stmt):
class Pass(stmt): ...
class Break(stmt): ...
class Continue(stmt): ...
class slice(AST): ...
class slice(AST):
...
_slice = slice # this lets us type the variable named 'slice' below
@@ -138,6 +143,7 @@ class Index(slice):
class Ellipsis(slice): ...
class expr(AST):
lineno: int
col_offset: int
@@ -234,17 +240,27 @@ class Tuple(expr):
elts: typing.List[expr]
ctx: expr_context
class expr_context(AST): ...
class expr_context(AST):
...
class AugLoad(expr_context): ...
class AugStore(expr_context): ...
class Del(expr_context): ...
class Load(expr_context): ...
class Param(expr_context): ...
class Store(expr_context): ...
class boolop(AST): ...
class boolop(AST):
...
class And(boolop): ...
class Or(boolop): ...
class operator(AST): ...
class operator(AST):
...
class Add(operator): ...
class BitAnd(operator): ...
class BitOr(operator): ...
@@ -257,12 +273,18 @@ class Mult(operator): ...
class Pow(operator): ...
class RShift(operator): ...
class Sub(operator): ...
class unaryop(AST): ...
class unaryop(AST):
...
class Invert(unaryop): ...
class Not(unaryop): ...
class UAdd(unaryop): ...
class USub(unaryop): ...
class cmpop(AST): ...
class cmpop(AST):
...
class Eq(cmpop): ...
class Gt(cmpop): ...
class GtE(cmpop): ...
@@ -274,12 +296,16 @@ class LtE(cmpop): ...
class NotEq(cmpop): ...
class NotIn(cmpop): ...
class comprehension(AST):
target: expr
iter: expr
ifs: typing.List[expr]
class excepthandler(AST): ...
class excepthandler(AST):
...
class ExceptHandler(excepthandler):
type: Optional[expr]
@@ -288,6 +314,7 @@ class ExceptHandler(excepthandler):
lineno: int
col_offset: int
class arguments(AST):
args: typing.List[expr]
vararg: Optional[_identifier]
+19 -14
View File
@@ -1,16 +1,17 @@
from typing import Any, Callable, Dict, Generic, Iterator, Optional, TypeVar, Union
"""Stub file for the '_collections' module."""
_K = TypeVar("_K")
_V = TypeVar("_V")
_T = TypeVar("_T")
_T2 = TypeVar("_T2")
from typing import Any, Generic, Iterator, TypeVar, Optional, Union
class defaultdict(Dict[_K, _V]):
class defaultdict(dict):
default_factory: None
def __init__(self, __default_factory: Callable[[], _V] = ..., init: Any = ...) -> None: ...
def __missing__(self, key: _K) -> _V: ...
def __copy__(self: _T) -> _T: ...
def copy(self: _T) -> _T: ...
def __init__(self, default: Any = ..., init: Any = ...) -> None: ...
def __missing__(self, key) -> Any:
raise KeyError()
def __copy__(self) -> defaultdict: ...
def copy(self) -> defaultdict: ...
_T = TypeVar('_T')
_T2 = TypeVar('_T2')
class deque(Generic[_T]):
maxlen: Optional[int]
@@ -21,14 +22,18 @@ class deque(Generic[_T]):
def count(self, x: Any) -> int: ...
def extend(self, iterable: Iterator[_T]) -> None: ...
def extendleft(self, iterable: Iterator[_T]) -> None: ...
def pop(self) -> _T: ...
def popleft(self) -> _T: ...
def remove(self, value: _T) -> None: ...
def pop(self) -> _T:
raise IndexError()
def popleft(self) -> _T:
raise IndexError()
def remove(self, value: _T) -> None:
raise IndexError()
def reverse(self) -> None: ...
def rotate(self, n: int = ...) -> None: ...
def __contains__(self, o: Any) -> bool: ...
def __copy__(self) -> deque[_T]: ...
def __getitem__(self, i: int) -> _T: ...
def __getitem__(self, i: int) -> _T:
raise IndexError()
def __iadd__(self, other: deque[_T2]) -> deque[Union[_T, _T2]]: ...
def __iter__(self) -> Iterator[_T]: ...
def __len__(self) -> int: ...
+83 -11
View File
@@ -1,15 +1,87 @@
from typing import Any, Callable, Dict, Iterable, Optional, Tuple, TypeVar, overload
"""Stub file for the '_functools' module."""
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Tuple, overload
_T = TypeVar("_T")
_T2 = TypeVar("_T2")
_T3 = TypeVar("_T3")
_T4 = TypeVar("_T4")
_T5 = TypeVar("_T5")
_S = TypeVar("_S")
@overload
def reduce(function: Callable[[_T, _T], _T], sequence: Iterable[_T]) -> _T: ...
@overload
def reduce(function: Callable[[_T, _S], _T], sequence: Iterable[_S], initial: _T) -> _T: ...
class partial(object):
func: Callable[..., Any]
args: Tuple[Any, ...]
keywords: Dict[str, Any]
def __init__(self, func: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
@overload
def reduce(function: Callable[[_T, _T], _T],
sequence: Iterable[_T]) -> _T: ...
@overload
def reduce(function: Callable[[_T, _S], _T],
sequence: Iterable[_S], initial: _T) -> _T: ...
@overload
def partial(__func: Callable[[_T], _S], __arg: _T) -> Callable[[], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2], _S], __arg: _T) -> Callable[[_T2], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3], _S], __arg: _T) -> Callable[[_T2, _T3], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4], _S], __arg: _T) -> Callable[[_T2, _T3, _T4], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4, _T5], _S], __arg: _T) -> Callable[[_T2, _T3, _T4, _T5], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2], _S],
__arg1: _T,
__arg2: _T2) -> Callable[[], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3], _S],
__arg1: _T,
__arg2: _T2) -> Callable[[_T3], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4], _S],
__arg1: _T,
__arg2: _T2) -> Callable[[_T3, _T4], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4, _T5], _S],
__arg1: _T,
__arg2: _T2) -> Callable[[_T3, _T4, _T5], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3) -> Callable[[], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3) -> Callable[[_T4], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4, _T5], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3) -> Callable[[_T4, _T5], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3,
__arg4: _T4) -> Callable[[], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4, _T5], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3,
__arg4: _T4) -> Callable[[_T5], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4, _T5], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3,
__arg4: _T4,
__arg5: _T5) -> Callable[[], _S]: ...
@overload
def partial(__func: Callable[..., _S],
*args: Any,
**kwargs: Any) -> Callable[..., _S]: ...
+22 -7
View File
@@ -1,19 +1,34 @@
from typing import Any, Dict, Generic, List, Tuple
"""Stub file for the '_hotshot' module."""
# This is an autogenerated file. It serves as a starting point
# for a more precise manual annotation of this module.
# Feel free to edit the source below, but remove this header when you do.
from typing import Any, List, Tuple, Dict, Generic
def coverage(a: str) -> Any: ...
def logreader(a: str) -> LogReaderType: ...
def profiler(a: str, *args, **kwargs) -> Any: ...
def resolution() -> Tuple[Any, ...]: ...
def logreader(a: str) -> LogReaderType:
raise IOError()
raise RuntimeError()
def profiler(a: str, *args, **kwargs) -> Any:
raise IOError()
def resolution() -> tuple: ...
class LogReaderType(object):
def close(self) -> None: ...
def fileno(self) -> int: ...
def fileno(self) -> int:
raise ValueError()
class ProfilerType(object):
def addinfo(self, a: str, b: str) -> None: ...
def close(self) -> None: ...
def fileno(self) -> int: ...
def fileno(self) -> int:
raise ValueError()
def runcall(self, *args, **kwargs) -> Any: ...
def runcode(self, a, b, *args, **kwargs) -> Any: ...
def runcode(self, a, b, *args, **kwargs) -> Any:
raise TypeError()
def start(self) -> None: ...
def stop(self) -> None: ...
+34 -35
View File
@@ -1,6 +1,6 @@
from typing import Any, AnyStr, BinaryIO, IO, Text, TextIO, Iterable, Iterator, List, Optional, Type, Tuple, TypeVar, Union
from mmap import mmap
from types import TracebackType
from typing import IO, Any, AnyStr, BinaryIO, Iterable, Iterator, List, Optional, Text, TextIO, Tuple, Type, TypeVar, Union
_bytearray_like = Union[bytearray, mmap]
@@ -16,7 +16,7 @@ _T = TypeVar("_T")
class _IOBase(BinaryIO):
@property
def closed(self) -> bool: ...
def _checkClosed(self, msg: Optional[str] = ...) -> None: ... # undocumented
def _checkClosed(self) -> None: ...
def _checkReadable(self) -> None: ...
def _checkSeekable(self) -> None: ...
def _checkWritable(self) -> None: ...
@@ -32,9 +32,7 @@ class _IOBase(BinaryIO):
def truncate(self, size: Optional[int] = ...) -> int: ...
def writable(self) -> bool: ...
def __enter__(self: _T) -> _T: ...
def __exit__(
self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[Any]
) -> Optional[bool]: ...
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: ...
@@ -55,7 +53,8 @@ class _BufferedIOBase(_IOBase):
def detach(self) -> _IOBase: ...
class BufferedRWPair(_BufferedIOBase):
def __init__(self, reader: _RawIOBase, writer: _RawIOBase, buffer_size: int = ..., max_buffer_size: int = ...) -> None: ...
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: ...
@@ -63,7 +62,9 @@ class BufferedRandom(_BufferedIOBase):
mode: str
name: str
raw: _IOBase
def __init__(self, raw: _IOBase, buffer_size: int = ..., max_buffer_size: int = ...) -> None: ...
def __init__(self, raw: _IOBase,
buffer_size: int = ...,
max_buffer_size: int = ...) -> None: ...
def peek(self, n: int = ...) -> bytes: ...
class BufferedReader(_BufferedIOBase):
@@ -77,12 +78,14 @@ class BufferedWriter(_BufferedIOBase):
name: str
raw: _IOBase
mode: str
def __init__(self, raw: _IOBase, buffer_size: int = ..., max_buffer_size: int = ...) -> None: ...
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, state: Tuple[Any, ...]) -> None: ...
def __getstate__(self) -> Tuple[Any, ...]: ...
def __setstate__(self, tuple) -> None: ...
def __getstate__(self) -> tuple: ...
# BytesIO does not contain a "name" field. This workaround is necessary
# to allow BytesIO sub-classes to add this field, as it is defined
# as a read-only property on IO[].
@@ -112,6 +115,7 @@ class IncrementalNewlineDecoder(object):
def setstate(self, state: Tuple[Any, int]) -> None: ...
def reset(self) -> None: ...
# Note: In the actual _io.py, _TextIOBase inherits from _IOBase.
class _TextIOBase(TextIO):
errors: Optional[str]
@@ -125,7 +129,7 @@ class _TextIOBase(TextIO):
def _checkSeekable(self) -> None: ...
def _checkWritable(self) -> None: ...
def close(self) -> None: ...
def detach(self) -> IO[Any]: ...
def detach(self) -> IO: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
@@ -142,16 +146,16 @@ class _TextIOBase(TextIO):
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]
) -> Optional[bool]: ...
def __exit__(self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[Any]) -> bool: ...
def __iter__(self: _T) -> _T: ...
class StringIO(_TextIOBase):
line_buffering: bool
def __init__(self, initial_value: Optional[unicode] = ..., newline: Optional[unicode] = ...) -> None: ...
def __setstate__(self, state: Tuple[Any, ...]) -> None: ...
def __getstate__(self) -> Tuple[Any, ...]: ...
def __init__(self,
initial_value: Optional[unicode] = ...,
newline: Optional[unicode] = ...) -> None: ...
def __setstate__(self, state: tuple) -> None: ...
def __getstate__(self) -> tuple: ...
# StringIO does not contain a "name" field. This workaround is necessary
# to allow StringIO sub-classes to add this field, as it is defined
# as a read-only property on IO[].
@@ -163,22 +167,17 @@ class TextIOWrapper(_TextIOBase):
line_buffering: bool
buffer: BinaryIO
_CHUNK_SIZE: int
def __init__(
self,
buffer: IO[Any],
encoding: Optional[Text] = ...,
errors: Optional[Text] = ...,
newline: Optional[Text] = ...,
line_buffering: bool = ...,
write_through: bool = ...,
) -> None: ...
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[str, unicode, int],
mode: Text = ...,
buffering: int = ...,
encoding: Optional[Text] = ...,
errors: Optional[Text] = ...,
newline: Optional[Text] = ...,
closefd: bool = ...,
) -> IO[Any]: ...
def open(file: Union[str, unicode, int],
mode: Text = ...,
buffering: int = ...,
encoding: Optional[Text] = ...,
errors: Optional[Text] = ...,
newline: Optional[Text] = ...,
closefd: bool = ...) -> IO[Any]: ...
+13 -3
View File
@@ -1,7 +1,17 @@
from typing import Any, Dict, Generic, List, Tuple
"""Stub file for the '_json' module."""
# This is an autogenerated file. It serves as a starting point
# for a more precise manual annotation of this module.
# Feel free to edit the source below, but remove this header when you do.
from typing import Any, List, Tuple, Dict, Generic
def encode_basestring_ascii(*args, **kwargs) -> str:
raise TypeError()
def scanstring(a, b, *args, **kwargs) -> tuple:
raise TypeError()
def encode_basestring_ascii(*args, **kwargs) -> str: ...
def scanstring(a, b, *args, **kwargs) -> Tuple[Any, ...]: ...
class Encoder(object): ...
class Scanner(object): ...
+18 -12
View File
@@ -1,4 +1,4 @@
from typing import IO, Any, Optional, Tuple, Union, overload
from typing import Tuple, Union, IO, Any, Optional, overload
AF_APPLETALK: int
AF_ASH: int
@@ -251,30 +251,36 @@ class SocketType(object):
type: int
proto: int
timeout: float
def __init__(self, family: int = ..., type: int = ..., proto: int = ...) -> None: ...
def accept(self) -> Tuple[SocketType, Tuple[Any, ...]]: ...
def bind(self, address: Tuple[Any, ...]) -> None: ...
def accept(self) -> Tuple[SocketType, tuple]: ...
def bind(self, address: tuple) -> None: ...
def close(self) -> None: ...
def connect(self, address: Tuple[Any, ...]) -> None: ...
def connect_ex(self, address: Tuple[Any, ...]) -> int: ...
def connect(self, address: tuple) -> None:
raise gaierror
raise timeout
def connect_ex(self, address: tuple) -> int: ...
def dup(self) -> SocketType: ...
def fileno(self) -> int: ...
def getpeername(self) -> Tuple[Any, ...]: ...
def getsockname(self) -> Tuple[Any, ...]: ...
def getpeername(self) -> tuple: ...
def getsockname(self) -> tuple: ...
def getsockopt(self, level: int, option: int, buffersize: int = ...) -> str: ...
def gettimeout(self) -> float: ...
def listen(self, backlog: int) -> None: ...
def listen(self, backlog: int) -> None:
raise error
def makefile(self, mode: str = ..., buffersize: int = ...) -> IO[Any]: ...
def recv(self, buffersize: int, flags: int = ...) -> str: ...
def recv_into(self, buffer: bytearray, nbytes: int = ..., flags: int = ...) -> int: ...
def recvfrom(self, buffersize: int, flags: int = ...) -> Tuple[Any, ...]: ...
def recvfrom_into(self, buffer: bytearray, nbytes: int = ..., flags: int = ...) -> int: ...
def recvfrom(self, buffersize: int, flags: int = ...) -> tuple:
raise error
def recvfrom_into(self, buffer: bytearray, nbytes: int = ...,
flags: int = ...) -> int: ...
def send(self, data: str, flags: int = ...) -> int: ...
def sendall(self, data: str, flags: int = ...) -> None: ...
@overload
def sendto(self, data: str, address: Tuple[Any, ...]) -> int: ...
def sendto(self, data: str, address: tuple) -> int: ...
@overload
def sendto(self, data: str, flags: int, address: Tuple[Any, ...]) -> int: ...
def sendto(self, data: str, flags: int, address: tuple) -> int: ...
def setblocking(self, flag: bool) -> None: ...
def setsockopt(self, level: int, option: int, value: Union[int, str]) -> None: ...
def settimeout(self, value: Optional[float]) -> None: ...
+20 -18
View File
@@ -1,4 +1,6 @@
from typing import Any, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Union, overload
"""Stub file for the '_sre' module."""
from typing import Any, Union, Iterable, Optional, Mapping, Sequence, Dict, List, Tuple, overload
CODESIZE: int
MAGIC: int
@@ -6,8 +8,10 @@ MAXREPEAT: long
copyright: str
class SRE_Match(object):
def start(self, group: int = ...) -> int: ...
def end(self, group: int = ...) -> int: ...
def start(self, group: int = ...) -> int:
raise IndexError()
def end(self, group: int = ...) -> int:
raise IndexError()
def expand(self, s: str) -> Any: ...
@overload
def group(self) -> str: ...
@@ -15,9 +19,8 @@ class SRE_Match(object):
def group(self, group: int = ...) -> Optional[str]: ...
def groupdict(self) -> Dict[int, Optional[str]]: ...
def groups(self) -> Tuple[Optional[str], ...]: ...
def span(self) -> Tuple[int, int]: ...
@property
def regs(self) -> Tuple[Tuple[int, int], ...]: ... # undocumented
def span(self) -> Tuple[int, int]:
raise IndexError()
class SRE_Scanner(object):
pattern: str
@@ -30,22 +33,21 @@ class SRE_Pattern(object):
groups: int
groupindex: Mapping[str, int]
indexgroup: Sequence[int]
def findall(self, source: str, pos: int = ..., endpos: int = ...) -> List[Union[Tuple[Any, ...], str]]: ...
def finditer(self, source: str, pos: int = ..., endpos: int = ...) -> Iterable[Union[Tuple[Any, ...], str]]: ...
def findall(self, source: str, pos: int = ..., endpos: int = ...) -> List[Union[tuple, str]]: ...
def finditer(self, source: str, pos: int = ..., endpos: int = ...) -> Iterable[Union[tuple, str]]: ...
def match(self, pattern, pos: int = ..., endpos: int = ...) -> SRE_Match: ...
def scanner(self, s: str, start: int = ..., end: int = ...) -> SRE_Scanner: ...
def search(self, pattern, pos: int = ..., endpos: int = ...) -> SRE_Match: ...
def split(self, source: str, maxsplit: int = ...) -> List[Optional[str]]: ...
def sub(self, repl: str, string: str, count: int = ...) -> Tuple[Any, ...]: ...
def subn(self, repl: str, string: str, count: int = ...) -> Tuple[Any, ...]: ...
def sub(self, repl: str, string: str, count: int = ...) -> tuple: ...
def subn(self, repl: str, string: str, count: int = ...) -> tuple: ...
def compile(pattern: str, flags: int, code: List[int],
groups: int = ...,
groupindex: Mapping[str, int] = ...,
indexgroup: Sequence[int] = ...) -> SRE_Pattern:
raise OverflowError()
def compile(
pattern: str,
flags: int,
code: List[int],
groups: int = ...,
groupindex: Mapping[str, int] = ...,
indexgroup: Sequence[int] = ...,
) -> SRE_Pattern: ...
def getcodesize() -> int: ...
def getlower(a: int, b: int) -> int: ...
+3
View File
@@ -1,3 +1,5 @@
"""Stub file for the '_struct' module."""
from typing import Any, AnyStr, Tuple
class error(Exception): ...
@@ -5,6 +7,7 @@ class error(Exception): ...
class Struct(object):
size: int
format: str
def __init__(self, fmt: str) -> None: ...
def pack_into(self, buffer: bytearray, offset: int, obj: Any) -> None: ...
def pack(self, *args) -> str: ...
+4 -2
View File
@@ -1,4 +1,4 @@
from typing import Dict, List
from typing import List, Dict
CELL: int
DEF_BOUND: int
@@ -22,7 +22,8 @@ TYPE_FUNCTION: int
TYPE_MODULE: int
USE: int
class _symtable_entry(object): ...
class _symtable_entry(object):
...
class symtable(object):
children: List[_symtable_entry]
@@ -34,4 +35,5 @@ class symtable(object):
symbols: Dict[str, int]
type: int
varnames: List[str]
def __init__(self, src: str, filename: str, startstr: str) -> None: ...
+4 -1
View File
@@ -1,4 +1,7 @@
from typing import Any
# Source: https://hg.python.org/cpython/file/2.7/Lib/_threading_local.py
from typing import Any, List
__all__: List[str]
class _localbase(object): ...
+11
View File
@@ -0,0 +1,11 @@
from typing import Any, List, Optional, Type
default_action: str
filters: List[tuple]
once_registry: dict
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: ...
-97
View File
@@ -1,97 +0,0 @@
import sys
from types import TracebackType
from typing import Any, Optional, Tuple, Type, Union
_KeyType = Union[HKEYType, int]
def CloseKey(__hkey: _KeyType) -> None: ...
def ConnectRegistry(__computer_name: Optional[str], __key: _KeyType) -> HKEYType: ...
def CreateKey(__key: _KeyType, __sub_key: Optional[str]) -> HKEYType: ...
def CreateKeyEx(key: _KeyType, sub_key: Optional[str], reserved: int = ..., access: int = ...) -> HKEYType: ...
def DeleteKey(__key: _KeyType, __sub_key: str) -> None: ...
def DeleteKeyEx(key: _KeyType, sub_key: str, access: int = ..., reserved: int = ...) -> None: ...
def DeleteValue(__key: _KeyType, __value: str) -> None: ...
def EnumKey(__key: _KeyType, __index: int) -> str: ...
def EnumValue(__key: _KeyType, __index: int) -> Tuple[str, Any, int]: ...
def ExpandEnvironmentStrings(__str: str) -> str: ...
def FlushKey(__key: _KeyType) -> None: ...
def LoadKey(__key: _KeyType, __sub_key: str, __file_name: str) -> None: ...
def OpenKey(key: _KeyType, sub_key: str, reserved: int = ..., access: int = ...) -> HKEYType: ...
def OpenKeyEx(key: _KeyType, sub_key: str, reserved: int = ..., access: int = ...) -> HKEYType: ...
def QueryInfoKey(__key: _KeyType) -> Tuple[int, int, int]: ...
def QueryValue(__key: _KeyType, __sub_key: Optional[str]) -> str: ...
def QueryValueEx(__key: _KeyType, __name: str) -> Tuple[Any, int]: ...
def SaveKey(__key: _KeyType, __file_name: str) -> None: ...
def SetValue(__key: _KeyType, __sub_key: str, __type: int, __value: str) -> None: ...
def SetValueEx(
__key: _KeyType, __value_name: Optional[str], __reserved: Any, __type: int, __value: Union[str, int]
) -> None: ... # reserved is ignored
def DisableReflectionKey(__key: _KeyType) -> None: ...
def EnableReflectionKey(__key: _KeyType) -> None: ...
def QueryReflectionKey(__key: _KeyType) -> bool: ...
HKEY_CLASSES_ROOT: int
HKEY_CURRENT_USER: int
HKEY_LOCAL_MACHINE: int
HKEY_USERS: int
HKEY_PERFORMANCE_DATA: int
HKEY_CURRENT_CONFIG: int
HKEY_DYN_DATA: int
KEY_ALL_ACCESS: int
KEY_WRITE: int
KEY_READ: int
KEY_EXECUTE: int
KEY_QUERY_VALUE: int
KEY_SET_VALUE: int
KEY_CREATE_SUB_KEY: int
KEY_ENUMERATE_SUB_KEYS: int
KEY_NOTIFY: int
KEY_CREATE_LINK: int
KEY_WOW64_64KEY: int
KEY_WOW64_32KEY: int
REG_BINARY: int
REG_DWORD: int
REG_DWORD_LITTLE_ENDIAN: int
REG_DWORD_BIG_ENDIAN: int
REG_EXPAND_SZ: int
REG_LINK: int
REG_MULTI_SZ: int
REG_NONE: int
REG_RESOURCE_LIST: int
REG_FULL_RESOURCE_DESCRIPTOR: int
REG_RESOURCE_REQUIREMENTS_LIST: int
REG_SZ: int
REG_CREATED_NEW_KEY: int # undocumented
REG_LEGAL_CHANGE_FILTER: int # undocumented
REG_LEGAL_OPTION: int # undocumented
REG_NOTIFY_CHANGE_ATTRIBUTES: int # undocumented
REG_NOTIFY_CHANGE_LAST_SET: int # undocumented
REG_NOTIFY_CHANGE_NAME: int # undocumented
REG_NOTIFY_CHANGE_SECURITY: int # undocumented
REG_NO_LAZY_FLUSH: int # undocumented
REG_OPENED_EXISTING_KEY: int # undocumented
REG_OPTION_BACKUP_RESTORE: int # undocumented
REG_OPTION_CREATE_LINK: int # undocumented
REG_OPTION_NON_VOLATILE: int # undocumented
REG_OPTION_OPEN_LINK: int # undocumented
REG_OPTION_RESERVED: int # undocumented
REG_OPTION_VOLATILE: int # undocumented
REG_REFRESH_HIVE: int # undocumented
REG_WHOLE_HIVE_VOLATILE: int # undocumented
error = OSError
# Though this class has a __name__ of PyHKEY, it's exposed as HKEYType for some reason
class HKEYType:
def __bool__(self) -> bool: ...
def __int__(self) -> int: ...
def __enter__(self) -> HKEYType: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> Optional[bool]: ...
def Close(self) -> None: ...
def Detach(self) -> int: ...
+5 -7
View File
@@ -1,20 +1,18 @@
from typing import Any, Dict, Set, Tuple, Type
import _weakrefset
from typing import Any, Callable, Dict, Set, Tuple, Type, TypeVar
_FuncT = TypeVar("_FuncT", bound=Callable[..., Any])
# NOTE: mypy has special processing for ABCMeta and abstractmethod.
def abstractmethod(funcobj: _FuncT) -> _FuncT: ...
def abstractmethod(funcobj: Any) -> Any: ...
class ABCMeta(type):
# TODO: FrozenSet
__abstractmethods__: Set[Any]
_abc_cache: _weakrefset.WeakSet[Any]
_abc_cache: _weakrefset.WeakSet
_abc_invalidation_counter: int
_abc_negative_cache: _weakrefset.WeakSet[Any]
_abc_negative_cache: _weakrefset.WeakSet
_abc_negative_cache_version: int
_abc_registry: _weakrefset.WeakSet[Any]
_abc_registry: _weakrefset.WeakSet
def __init__(self, name: str, bases: Tuple[type, ...], namespace: Dict[Any, Any]) -> None: ...
def __instancecheck__(cls: ABCMeta, instance: Any) -> Any: ...
def __subclasscheck__(cls: ABCMeta, subclass: Any) -> Any: ...
+1 -1
View File
@@ -20,7 +20,7 @@ def iter_fields(node: AST) -> Iterator[_typing.Tuple[str, Any]]: ...
def literal_eval(node_or_string: Union[str, unicode, AST]) -> Any: ...
def walk(node: AST) -> Iterator[AST]: ...
class NodeVisitor:
class NodeVisitor():
def visit(self, node: AST) -> Any: ...
def generic_visit(self, node: AST) -> Any: ...
+2 -2
View File
@@ -1,5 +1,5 @@
from typing import Any, TypeVar
from typing import TypeVar, Any
_FT = TypeVar("_FT")
_FT = TypeVar('_FT')
def register(func: _FT, *args: Any, **kargs: Any) -> _FT: ...
File diff suppressed because it is too large Load Diff
+7 -1
View File
@@ -1,4 +1,4 @@
from typing import IO, Any, List
from typing import Any, IO, List
HIGHEST_PROTOCOL: int
compatible_formats: List[str]
@@ -6,14 +6,20 @@ format_version: str
class Pickler:
def __init__(self, file: IO[str], protocol: int = ...) -> None: ...
def dump(self, obj: Any) -> None: ...
def clear_memo(self) -> None: ...
class Unpickler:
def __init__(self, file: IO[str]) -> None: ...
def load(self) -> Any: ...
def noload(self) -> Any: ...
def dump(obj: Any, file: IO[str], protocol: int = ...) -> None: ...
def dumps(obj: Any, protocol: int = ...) -> str: ...
def load(file: IO[str]) -> Any: ...
+7 -1
View File
@@ -1,6 +1,11 @@
# Stubs for cStringIO (Python 2.7)
# See https://docs.python.org/2/library/stringio.html
from abc import ABCMeta
from typing import overload, IO, List, Iterable, Iterator, Optional, Union
from types import TracebackType
from typing import IO, Iterable, Iterator, List, Optional, Union, overload
# TODO the typing.IO[] generics should be split into input and output.
# This class isn't actually abstract, but you can't instantiate it
# directly, so we might as well treat it as abstract in the stub.
@@ -21,6 +26,7 @@ class InputType(IO[str], Iterator[str], metaclass=ABCMeta):
def next(self) -> str: ...
def reset(self) -> None: ...
class OutputType(IO[str], Iterator[str], metaclass=ABCMeta):
@property
def softspace(self) -> int: ...
+32 -35
View File
@@ -1,50 +1,38 @@
# These are not exported.
from typing import Dict, Generic, TypeVar, Tuple, overload, Type, Optional, List, Union, Reversible
# These are exported.
from typing import (
AbstractSet,
Any,
Callable as Callable,
Container as Container,
Dict,
Generic,
Hashable as Hashable,
ItemsView as ItemsView,
Iterable as Iterable,
Iterator as Iterator,
KeysView as KeysView,
List,
Mapping as Mapping,
MappingView as MappingView,
MutableMapping as MutableMapping,
MutableSequence as MutableSequence,
MutableSet as MutableSet,
Optional,
Reversible,
Sequence as Sequence,
AbstractSet as Set,
Sized as Sized,
Tuple,
Type,
TypeVar,
Union,
ValuesView as ValuesView,
overload,
)
Set = AbstractSet
_S = TypeVar("_S")
_T = TypeVar("_T")
_KT = TypeVar("_KT")
_VT = TypeVar("_VT")
_S = TypeVar('_S')
_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[Union[str, unicode]]],
verbose: bool = ...,
rename: bool = ...,
) -> Type[Tuple[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]):
def __init__(self, iterable: Iterable[_T] = ..., maxlen: int = ...) -> None: ...
def __init__(self, iterable: Iterable[_T] = ...,
maxlen: int = ...) -> None: ...
@property
def maxlen(self) -> Optional[int]: ...
def append(self, x: _T) -> None: ...
@@ -57,7 +45,7 @@ class deque(Sized, Iterable[_T], Reversible[_T], Generic[_T]):
def popleft(self) -> _T: ...
def remove(self, value: _T) -> None: ...
def reverse(self) -> None: ...
def rotate(self, n: int = ...) -> None: ...
def rotate(self, n: int) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
def __str__(self) -> str: ...
@@ -68,6 +56,8 @@ class deque(Sized, Iterable[_T], Reversible[_T], Generic[_T]):
def __reversed__(self) -> Iterator[_T]: ...
def __iadd__(self: _S, iterable: Iterable[_T]) -> _S: ...
_CounterT = TypeVar('_CounterT', bound=Counter)
class Counter(Dict[_T, int], Generic[_T]):
@overload
def __init__(self, **kwargs: int) -> None: ...
@@ -75,7 +65,7 @@ class Counter(Dict[_T, int], Generic[_T]):
def __init__(self, mapping: Mapping[_T, int]) -> None: ...
@overload
def __init__(self, iterable: Iterable[_T]) -> None: ...
def copy(self: _S) -> _S: ...
def copy(self: _CounterT) -> _CounterT: ...
def elements(self) -> Iterator[_T]: ...
def most_common(self, n: Optional[int] = ...) -> List[Tuple[_T, int]]: ...
@overload
@@ -93,6 +83,7 @@ class Counter(Dict[_T, int], Generic[_T]):
def update(self, __m: Union[Iterable[_T], Iterable[Tuple[_T, int]]], **kwargs: int) -> None: ...
@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]: ...
@@ -102,11 +93,15 @@ class Counter(Dict[_T, int], Generic[_T]):
def __iand__(self, other: Counter[_T]) -> Counter[_T]: ...
def __ior__(self, other: Counter[_T]) -> Counter[_T]: ...
_OrderedDictT = TypeVar('_OrderedDictT', bound=OrderedDict)
class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
def popitem(self, last: bool = ...) -> Tuple[_KT, _VT]: ...
def copy(self: _S) -> _S: ...
def copy(self: _OrderedDictT) -> _OrderedDictT: ...
def __reversed__(self) -> Iterator[_KT]: ...
_DefaultDictT = TypeVar('_DefaultDictT', bound=defaultdict)
class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
default_factory: Callable[[], _VT]
@overload
@@ -116,14 +111,16 @@ class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
@overload
def __init__(self, default_factory: Optional[Callable[[], _VT]], **kwargs: _VT) -> None: ...
@overload
def __init__(self, default_factory: Optional[Callable[[], _VT]], map: Mapping[_KT, _VT]) -> None: ...
def __init__(self, default_factory: Optional[Callable[[], _VT]],
map: Mapping[_KT, _VT]) -> None: ...
@overload
def __init__(self, default_factory: Optional[Callable[[], _VT]], map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...
def __init__(self, default_factory: Optional[Callable[[], _VT]],
map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...
@overload
def __init__(self, default_factory: Optional[Callable[[], _VT]], iterable: Iterable[Tuple[_KT, _VT]]) -> None: ...
def __init__(self, default_factory: Optional[Callable[[], _VT]],
iterable: Iterable[Tuple[_KT, _VT]]) -> None: ...
@overload
def __init__(
self, default_factory: Optional[Callable[[], _VT]], iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT
) -> None: ...
def __init__(self, default_factory: Optional[Callable[[], _VT]],
iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
def __missing__(self, key: _KT) -> _VT: ...
def copy(self: _S) -> _S: ...
def copy(self: _DefaultDictT) -> _DefaultDictT: ...
+3 -1
View File
@@ -1,10 +1,12 @@
from typing import AnyStr, Text, Tuple, overload
from typing import overload, AnyStr, Text, Tuple
def getstatus(file: Text) -> str: ...
def getoutput(cmd: Text) -> str: ...
def getstatusoutput(cmd: Text) -> Tuple[int, str]: ...
@overload
def mk2arg(head: bytes, x: bytes) -> bytes: ...
@overload
def mk2arg(head: Text, x: Text) -> Text: ...
def mkarg(x: AnyStr) -> AnyStr: ...
+7 -13
View File
@@ -1,16 +1,10 @@
from _typeshed import AnyPath
from typing import Any, Optional, Pattern
# Stubs for compileall (Python 2)
from typing import Optional, Pattern, Union
_Path = Union[str, bytes]
# rx can be any object with a 'search' method; once we have Protocols we can change the type
def compile_dir(
dir: AnyPath,
maxlevels: int = ...,
ddir: Optional[AnyPath] = ...,
force: bool = ...,
rx: Optional[Pattern[Any]] = ...,
quiet: int = ...,
) -> int: ...
def compile_file(
fullname: AnyPath, ddir: Optional[AnyPath] = ..., force: bool = ..., rx: Optional[Pattern[Any]] = ..., quiet: int = ...
) -> int: ...
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: ...
+7 -39
View File
@@ -17,26 +17,8 @@ class Cookie:
comment: Any
comment_url: Any
rfc2109: Any
def __init__(
self,
version,
name,
value,
port,
port_specified,
domain,
domain_specified,
domain_initial_dot,
path,
path_specified,
secure,
expires,
discard,
comment,
comment_url,
rest,
rfc2109: bool = ...,
): ...
def __init__(self, version, name, value, port, port_specified, domain, domain_specified, domain_initial_dot, path,
path_specified, secure, expires, discard, comment, comment_url, rest, rfc2109: bool = ...): ...
def has_nonstandard_attr(self, name): ...
def get_nonstandard_attr(self, name, default: Optional[Any] = ...): ...
def set_nonstandard_attr(self, name, value): ...
@@ -64,21 +46,10 @@ class DefaultCookiePolicy(CookiePolicy):
strict_ns_domain: Any
strict_ns_set_initial_dollar: Any
strict_ns_set_path: Any
def __init__(
self,
blocked_domains: Optional[Any] = ...,
allowed_domains: Optional[Any] = ...,
netscape: bool = ...,
rfc2965: bool = ...,
rfc2109_as_netscape: Optional[Any] = ...,
hide_cookie2: bool = ...,
strict_domain: bool = ...,
strict_rfc2965_unverifiable: bool = ...,
strict_ns_unverifiable: bool = ...,
strict_ns_domain=...,
strict_ns_set_initial_dollar: bool = ...,
strict_ns_set_path: bool = ...,
): ...
def __init__(self, blocked_domains: Optional[Any] = ..., allowed_domains: Optional[Any] = ..., netscape: bool = ...,
rfc2965: bool = ..., rfc2109_as_netscape: Optional[Any] = ..., hide_cookie2: bool = ...,
strict_domain: bool = ..., strict_rfc2965_unverifiable: bool = ..., strict_ns_unverifiable: bool = ...,
strict_ns_domain=..., strict_ns_set_initial_dollar: bool = ..., strict_ns_set_path: bool = ...): ...
def blocked_domains(self): ...
def set_blocked_domains(self, blocked_domains): ...
def is_blocked(self, domain): ...
@@ -134,9 +105,6 @@ class FileCookieJar(CookieJar):
def load(self, filename: Optional[Any] = ..., ignore_discard: bool = ..., ignore_expires: bool = ...): ...
def revert(self, filename: Optional[Any] = ..., ignore_discard: bool = ..., ignore_expires: bool = ...): ...
class LWPCookieJar(FileCookieJar):
def as_lwp_str(self, ignore_discard: bool = ..., ignore_expires: bool = ...) -> str: ... # undocumented
MozillaCookieJar = FileCookieJar
LWPCookieJar = FileCookieJar
def lwp_cookie_str(cookie: Cookie) -> str: ...
-16
View File
@@ -1,16 +0,0 @@
from typing import Any, Callable, Hashable, List, Optional, SupportsInt, Tuple, TypeVar, Union
_Type = TypeVar("_Type", bound=type)
_Reduce = Union[Tuple[Callable[..., _Type], Tuple[Any, ...]], Tuple[Callable[..., _Type], Tuple[Any, ...], Optional[Any]]]
__all__: List[str]
def pickle(
ob_type: _Type,
pickle_function: Callable[[_Type], Union[str, _Reduce[_Type]]],
constructor_ob: Optional[Callable[[_Reduce[_Type]], _Type]] = ...,
) -> None: ...
def constructor(object: Callable[[_Reduce[_Type]], _Type]) -> None: ...
def add_extension(module: Hashable, name: Hashable, code: SupportsInt) -> None: ...
def remove_extension(module: Hashable, name: Hashable, code: int) -> None: ...
def clear_extension_cache() -> None: ...
+2
View File
@@ -1,3 +1,5 @@
# Source: https://hg.python.org/cpython/file/2.7/Lib/dircache.py
from typing import List, MutableSequence, Text, Union
def reset() -> None: ...
-12
View File
@@ -1,12 +0,0 @@
from typing import Optional
def make_archive(
base_name: str,
format: str,
root_dir: Optional[str] = ...,
base_dir: Optional[str] = ...,
verbose: int = ...,
dry_run: int = ...,
) -> str: ...
def make_tarball(base_name: str, base_dir: str, compress: Optional[str] = ..., verbose: int = ..., dry_run: int = ...) -> str: ...
def make_zipfile(base_name: str, base_dir: str, verbose: int = ..., dry_run: int = ...) -> str: ...
-150
View File
@@ -1,150 +0,0 @@
from typing import Any, Callable, List, Optional, Tuple, Union
_Macro = Union[Tuple[str], Tuple[str, Optional[str]]]
def gen_lib_options(
compiler: CCompiler, library_dirs: List[str], runtime_library_dirs: List[str], libraries: List[str]
) -> List[str]: ...
def gen_preprocess_options(macros: List[_Macro], include_dirs: List[str]) -> List[str]: ...
def get_default_compiler(osname: Optional[str] = ..., platform: Optional[str] = ...) -> str: ...
def new_compiler(
plat: Optional[str] = ..., compiler: Optional[str] = ..., verbose: int = ..., dry_run: int = ..., force: int = ...
) -> CCompiler: ...
def show_compilers() -> None: ...
class CCompiler:
dry_run: bool
force: bool
verbose: bool
output_dir: Optional[str]
macros: List[_Macro]
include_dirs: List[str]
libraries: List[str]
library_dirs: List[str]
runtime_library_dirs: List[str]
objects: List[str]
def __init__(self, verbose: int = ..., dry_run: int = ..., force: int = ...) -> None: ...
def add_include_dir(self, dir: str) -> None: ...
def set_include_dirs(self, dirs: List[str]) -> None: ...
def add_library(self, libname: str) -> None: ...
def set_libraries(self, libnames: List[str]) -> None: ...
def add_library_dir(self, dir: str) -> None: ...
def set_library_dirs(self, dirs: List[str]) -> None: ...
def add_runtime_library_dir(self, dir: str) -> None: ...
def set_runtime_library_dirs(self, dirs: List[str]) -> None: ...
def define_macro(self, name: str, value: Optional[str] = ...) -> None: ...
def undefine_macro(self, name: str) -> None: ...
def add_link_object(self, object: str) -> None: ...
def set_link_objects(self, objects: List[str]) -> None: ...
def detect_language(self, sources: Union[str, List[str]]) -> Optional[str]: ...
def find_library_file(self, dirs: List[str], lib: str, debug: bool = ...) -> Optional[str]: ...
def has_function(
self,
funcname: str,
includes: Optional[List[str]] = ...,
include_dirs: Optional[List[str]] = ...,
libraries: Optional[List[str]] = ...,
library_dirs: Optional[List[str]] = ...,
) -> bool: ...
def library_dir_option(self, dir: str) -> str: ...
def library_option(self, lib: str) -> str: ...
def runtime_library_dir_option(self, dir: str) -> str: ...
def set_executables(self, **args: str) -> None: ...
def compile(
self,
sources: List[str],
output_dir: Optional[str] = ...,
macros: Optional[_Macro] = ...,
include_dirs: Optional[List[str]] = ...,
debug: bool = ...,
extra_preargs: Optional[List[str]] = ...,
extra_postargs: Optional[List[str]] = ...,
depends: Optional[List[str]] = ...,
) -> List[str]: ...
def create_static_lib(
self,
objects: List[str],
output_libname: str,
output_dir: Optional[str] = ...,
debug: bool = ...,
target_lang: Optional[str] = ...,
) -> None: ...
def link(
self,
target_desc: str,
objects: List[str],
output_filename: str,
output_dir: Optional[str] = ...,
libraries: Optional[List[str]] = ...,
library_dirs: Optional[List[str]] = ...,
runtime_library_dirs: Optional[List[str]] = ...,
export_symbols: Optional[List[str]] = ...,
debug: bool = ...,
extra_preargs: Optional[List[str]] = ...,
extra_postargs: Optional[List[str]] = ...,
build_temp: Optional[str] = ...,
target_lang: Optional[str] = ...,
) -> None: ...
def link_executable(
self,
objects: List[str],
output_progname: str,
output_dir: Optional[str] = ...,
libraries: Optional[List[str]] = ...,
library_dirs: Optional[List[str]] = ...,
runtime_library_dirs: Optional[List[str]] = ...,
debug: bool = ...,
extra_preargs: Optional[List[str]] = ...,
extra_postargs: Optional[List[str]] = ...,
target_lang: Optional[str] = ...,
) -> None: ...
def link_shared_lib(
self,
objects: List[str],
output_libname: str,
output_dir: Optional[str] = ...,
libraries: Optional[List[str]] = ...,
library_dirs: Optional[List[str]] = ...,
runtime_library_dirs: Optional[List[str]] = ...,
export_symbols: Optional[List[str]] = ...,
debug: bool = ...,
extra_preargs: Optional[List[str]] = ...,
extra_postargs: Optional[List[str]] = ...,
build_temp: Optional[str] = ...,
target_lang: Optional[str] = ...,
) -> None: ...
def link_shared_object(
self,
objects: List[str],
output_filename: str,
output_dir: Optional[str] = ...,
libraries: Optional[List[str]] = ...,
library_dirs: Optional[List[str]] = ...,
runtime_library_dirs: Optional[List[str]] = ...,
export_symbols: Optional[List[str]] = ...,
debug: bool = ...,
extra_preargs: Optional[List[str]] = ...,
extra_postargs: Optional[List[str]] = ...,
build_temp: Optional[str] = ...,
target_lang: Optional[str] = ...,
) -> None: ...
def preprocess(
self,
source: str,
output_file: Optional[str] = ...,
macros: Optional[List[_Macro]] = ...,
include_dirs: Optional[List[str]] = ...,
extra_preargs: Optional[List[str]] = ...,
extra_postargs: Optional[List[str]] = ...,
) -> None: ...
def executable_filename(self, basename: str, strip_dir: int = ..., output_dir: str = ...) -> str: ...
def library_filename(self, libname: str, lib_type: str = ..., strip_dir: int = ..., output_dir: str = ...) -> str: ...
def object_filenames(self, source_filenames: List[str], strip_dir: int = ..., output_dir: str = ...) -> List[str]: ...
def shared_object_filename(self, basename: str, strip_dir: int = ..., output_dir: str = ...) -> str: ...
def execute(self, func: Callable[..., None], args: Tuple[Any, ...], msg: Optional[str] = ..., level: int = ...) -> None: ...
def spawn(self, cmd: List[str]) -> None: ...
def mkpath(self, name: str, mode: int = ...) -> None: ...
def move_file(self, src: str, dst: str) -> str: ...
def announce(self, msg: str, level: int = ...) -> None: ...
def warn(self, msg: str) -> None: ...
def debug_print(self, msg: str) -> None: ...
-6
View File
@@ -1,6 +0,0 @@
from distutils.cmd import Command
class build_py(Command):
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
def run(self) -> None: ...
-87
View File
@@ -1,87 +0,0 @@
from distutils import log as log
from distutils.ccompiler import CCompiler
from distutils.core import Command as Command
from distutils.errors import DistutilsExecError as DistutilsExecError
from distutils.sysconfig import customize_compiler as customize_compiler
from typing import Dict, List, Optional, Pattern, Sequence, Tuple, Union
LANG_EXT: Dict[str, str]
class config(Command):
description: str = ...
# Tuple is full name, short name, description
user_options: Sequence[Tuple[str, Optional[str], str]] = ...
compiler: Optional[Union[str, CCompiler]] = ...
cc: Optional[str] = ...
include_dirs: Optional[Sequence[str]] = ...
libraries: Optional[Sequence[str]] = ...
library_dirs: Optional[Sequence[str]] = ...
noisy: int = ...
dump_source: int = ...
temp_files: Sequence[str] = ...
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
def run(self) -> None: ...
def try_cpp(
self,
body: Optional[str] = ...,
headers: Optional[Sequence[str]] = ...,
include_dirs: Optional[Sequence[str]] = ...,
lang: str = ...,
) -> bool: ...
def search_cpp(
self,
pattern: Union[Pattern[str], str],
body: Optional[str] = ...,
headers: Optional[Sequence[str]] = ...,
include_dirs: Optional[Sequence[str]] = ...,
lang: str = ...,
) -> bool: ...
def try_compile(
self, body: str, headers: Optional[Sequence[str]] = ..., include_dirs: Optional[Sequence[str]] = ..., lang: str = ...
) -> bool: ...
def try_link(
self,
body: str,
headers: Optional[Sequence[str]] = ...,
include_dirs: Optional[Sequence[str]] = ...,
libraries: Optional[Sequence[str]] = ...,
library_dirs: Optional[Sequence[str]] = ...,
lang: str = ...,
) -> bool: ...
def try_run(
self,
body: str,
headers: Optional[Sequence[str]] = ...,
include_dirs: Optional[Sequence[str]] = ...,
libraries: Optional[Sequence[str]] = ...,
library_dirs: Optional[Sequence[str]] = ...,
lang: str = ...,
) -> bool: ...
def check_func(
self,
func: str,
headers: Optional[Sequence[str]] = ...,
include_dirs: Optional[Sequence[str]] = ...,
libraries: Optional[Sequence[str]] = ...,
library_dirs: Optional[Sequence[str]] = ...,
decl: int = ...,
call: int = ...,
) -> bool: ...
def check_lib(
self,
library: str,
library_dirs: Optional[Sequence[str]] = ...,
headers: Optional[Sequence[str]] = ...,
include_dirs: Optional[Sequence[str]] = ...,
other_libraries: List[str] = ...,
) -> bool: ...
def check_header(
self,
header: str,
include_dirs: Optional[Sequence[str]] = ...,
library_dirs: Optional[Sequence[str]] = ...,
lang: str = ...,
) -> bool: ...
def dump_file(filename: str, head: Optional[str] = ...) -> None: ...
@@ -1,10 +0,0 @@
from distutils.cmd import Command
from typing import ClassVar, List, Optional, Tuple
class install_egg_info(Command):
description: ClassVar[str]
user_options: ClassVar[List[Tuple[str, Optional[str], str]]]
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
def run(self) -> None: ...
def get_outputs(self) -> List[str]: ...
-8
View File
@@ -1,8 +0,0 @@
from distutils.config import PyPIRCCommand
from typing import ClassVar, List, Optional, Tuple
class upload(PyPIRCCommand):
description: ClassVar[str]
boolean_options: ClassVar[List[str]]
def run(self) -> None: ...
def upload_file(self, command, pyversion, filename) -> None: ...
-17
View File
@@ -1,17 +0,0 @@
from abc import abstractmethod
from distutils.cmd import Command
from typing import ClassVar, List, Optional, Tuple
DEFAULT_PYPIRC: str
class PyPIRCCommand(Command):
DEFAULT_REPOSITORY: ClassVar[str]
DEFAULT_REALM: ClassVar[str]
repository: None
realm: None
user_options: ClassVar[List[Tuple[str, Optional[str], str]]]
boolean_options: ClassVar[List[str]]
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
@abstractmethod
def run(self) -> None: ...
-48
View File
@@ -1,48 +0,0 @@
from distutils.cmd import Command as Command
from distutils.dist import Distribution as Distribution
from distutils.extension import Extension as Extension
from typing import Any, List, Mapping, Optional, Tuple, Type, Union
def setup(
*,
name: str = ...,
version: str = ...,
description: str = ...,
long_description: str = ...,
author: str = ...,
author_email: str = ...,
maintainer: str = ...,
maintainer_email: str = ...,
url: str = ...,
download_url: str = ...,
packages: List[str] = ...,
py_modules: List[str] = ...,
scripts: List[str] = ...,
ext_modules: List[Extension] = ...,
classifiers: List[str] = ...,
distclass: Type[Distribution] = ...,
script_name: str = ...,
script_args: List[str] = ...,
options: Mapping[str, Any] = ...,
license: str = ...,
keywords: Union[List[str], str] = ...,
platforms: Union[List[str], str] = ...,
cmdclass: Mapping[str, Type[Command]] = ...,
data_files: List[Tuple[str, List[str]]] = ...,
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: ...
-4
View File
@@ -1,4 +0,0 @@
from distutils.unixccompiler import UnixCCompiler
class CygwinCCompiler(UnixCCompiler): ...
class Mingw32CCompiler(CygwinCCompiler): ...
-1
View File
@@ -1 +0,0 @@
DEBUG: bool
-5
View File
@@ -1,5 +0,0 @@
from typing import List, Tuple
def newer(source: str, target: str) -> bool: ...
def newer_pairwise(sources: List[str], targets: List[str]) -> List[Tuple[str, str]]: ...
def newer_group(sources: List[str], target: str, missing: str = ...) -> bool: ...
-15
View File
@@ -1,15 +0,0 @@
from typing import List
def mkpath(name: str, mode: int = ..., verbose: int = ..., dry_run: int = ...) -> List[str]: ...
def create_tree(base_dir: str, files: List[str], mode: int = ..., verbose: int = ..., dry_run: int = ...) -> None: ...
def copy_tree(
src: str,
dst: str,
preserve_mode: int = ...,
preserve_times: int = ...,
preserve_symlinks: int = ...,
update: int = ...,
verbose: int = ...,
dry_run: int = ...,
) -> List[str]: ...
def remove_tree(directory: str, verbose: int = ..., dry_run: int = ...) -> None: ...
+2
View File
@@ -1,3 +1,5 @@
# Stubs for emxccompiler
from distutils.unixccompiler import UnixCCompiler
class EMXCCompiler(UnixCCompiler): ...
-21
View File
@@ -1,21 +0,0 @@
from typing import List, Optional, Tuple
class Extension:
def __init__(
self,
name: str,
sources: List[str],
include_dirs: List[str] = ...,
define_macros: List[Tuple[str, Optional[str]]] = ...,
undef_macros: List[str] = ...,
library_dirs: List[str] = ...,
libraries: List[str] = ...,
runtime_library_dirs: List[str] = ...,
extra_objects: List[str] = ...,
extra_compile_args: List[str] = ...,
extra_link_args: List[str] = ...,
export_symbols: List[str] = ...,
swig_opts: Optional[str] = ..., # undocumented
depends: List[str] = ...,
language: str = ...,
) -> None: ...
-14
View File
@@ -1,14 +0,0 @@
from typing import Optional, Sequence, Tuple
def copy_file(
src: str,
dst: str,
preserve_mode: bool = ...,
preserve_times: bool = ...,
update: bool = ...,
link: Optional[str] = ...,
verbose: bool = ...,
dry_run: bool = ...,
) -> Tuple[str, str]: ...
def move_file(src: str, dst: str, verbose: bool = ..., dry_run: bool = ...) -> str: ...
def write_file(filename: str, contents: Sequence[str]) -> None: ...
-1
View File
@@ -1 +0,0 @@
class FileList: ...
-4
View File
@@ -1,4 +0,0 @@
from typing import List, Optional
def spawn(cmd: List[str], search_path: bool = ..., verbose: bool = ..., dry_run: bool = ...) -> None: ...
def find_executable(executable: str, path: Optional[str] = ...) -> Optional[str]: ...
-14
View File
@@ -1,14 +0,0 @@
from distutils.ccompiler import CCompiler
from typing import Mapping, Optional, Union
PREFIX: str
EXEC_PREFIX: str
def get_config_var(name: str) -> Union[int, str, None]: ...
def get_config_vars(*args: str) -> Mapping[str, Union[int, str]]: ...
def get_config_h_filename() -> str: ...
def get_makefile_filename() -> str: ...
def get_python_inc(plat_specific: bool = ..., prefix: Optional[str] = ...) -> str: ...
def get_python_lib(plat_specific: bool = ..., standard_lib: bool = ..., prefix: Optional[str] = ...) -> str: ...
def customize_compiler(compiler: CCompiler) -> None: ...
def set_python_build() -> None: ...
-21
View File
@@ -1,21 +0,0 @@
from typing import IO, List, Optional, Tuple, Union
class TextFile:
def __init__(
self,
filename: Optional[str] = ...,
file: Optional[IO[str]] = ...,
*,
strip_comments: bool = ...,
lstrip_ws: bool = ...,
rstrip_ws: bool = ...,
skip_blanks: bool = ...,
join_lines: bool = ...,
collapse_join: bool = ...,
) -> None: ...
def open(self, filename: str) -> None: ...
def close(self) -> None: ...
def warn(self, msg: str, line: Union[List[int], Tuple[int, int], int] = ...) -> None: ...
def readline(self) -> Optional[str]: ...
def readlines(self) -> List[str]: ...
def unreadline(self, line: str) -> str: ...
-3
View File
@@ -1,3 +0,0 @@
from distutils.ccompiler import CCompiler
class UnixCCompiler(CCompiler): ...
-23
View File
@@ -1,23 +0,0 @@
from typing import Any, Callable, List, Mapping, Optional, Tuple
def get_platform() -> str: ...
def convert_path(pathname: str) -> str: ...
def change_root(new_root: str, pathname: str) -> str: ...
def check_environ() -> None: ...
def subst_vars(s: str, local_vars: Mapping[str, str]) -> None: ...
def split_quoted(s: str) -> List[str]: ...
def execute(
func: Callable[..., None], args: Tuple[Any, ...], msg: Optional[str] = ..., verbose: bool = ..., dry_run: bool = ...
) -> None: ...
def strtobool(val: str) -> bool: ...
def byte_compile(
py_files: List[str],
optimize: int = ...,
force: bool = ...,
prefix: Optional[str] = ...,
base_dir: Optional[str] = ...,
verbose: bool = ...,
dry_run: bool = ...,
direct: Optional[bool] = ...,
) -> None: ...
def rfc822_escape(header: str) -> str: ...
-33
View File
@@ -1,33 +0,0 @@
from abc import abstractmethod
from typing import Optional, Pattern, Text, Tuple, TypeVar, Union
_T = TypeVar("_T", bound=Version)
class Version:
def __repr__(self) -> str: ...
@abstractmethod
def __init__(self, vstring: Optional[Text] = ...) -> None: ...
@abstractmethod
def parse(self: _T, vstring: Text) -> _T: ...
@abstractmethod
def __str__(self) -> str: ...
@abstractmethod
def __cmp__(self: _T, other: Union[_T, str]) -> bool: ...
class StrictVersion(Version):
version_re: Pattern[str]
version: Tuple[int, int, int]
prerelease: Optional[Tuple[Text, int]]
def __init__(self, vstring: Optional[Text] = ...) -> None: ...
def parse(self: _T, vstring: Text) -> _T: ...
def __str__(self) -> str: ...
def __cmp__(self: _T, other: Union[_T, str]) -> bool: ...
class LooseVersion(Version):
component_re: Pattern[str]
vstring: Text
version: Tuple[Union[Text, int], ...]
def __init__(self, vstring: Optional[Text] = ...) -> None: ...
def parse(self: _T, vstring: Text) -> _T: ...
def __str__(self) -> str: ...
def __cmp__(self: _T, other: Union[_T, str]) -> bool: ...
-3
View File
@@ -1,11 +1,8 @@
def base64_len(s: bytes) -> int: ...
def header_encode(header, charset=..., keep_eols=..., maxlinelen=..., eol=...): ...
def encode(s, binary=..., maxlinelen=..., eol=...): ...
body_encode = encode
encodestring = encode
def decode(s, convert_eols=...): ...
body_decode = decode
decodestring = decode
+1
View File
@@ -11,6 +11,7 @@ class BufferedSubFile:
def __iter__(self): ...
def next(self): ...
class FeedParser:
def __init__(self, _factory=...) -> None: ...
def feed(self, data) -> None: ...
+1
View File
@@ -4,5 +4,6 @@ class Generator:
def flatten(self, msg, unixfrom: bool = ...) -> None: ...
def clone(self, fp): ...
class DecodedGenerator(Generator):
def __init__(self, outfp, mangle_from_: bool = ..., maxheaderlen: int = ..., fmt=...) -> None: ...
+2 -1
View File
@@ -2,7 +2,8 @@ def decode_header(header): ...
def make_header(decoded_seq, maxlinelen=..., header_name=..., continuation_ws=...): ...
class Header:
def __init__(self, s=..., charset=..., maxlinelen=..., header_name=..., continuation_ws=..., errors=...) -> None: ...
def __init__(self, s=..., charset=..., maxlinelen=..., header_name=..., continuation_ws=...,
errors=...) -> None: ...
def __unicode__(self): ...
def __eq__(self, other): ...
def __ne__(self, other): ...
+4 -4
View File
@@ -1,5 +1,5 @@
from typing import Any, Generator
from typing import Generator
def walk(self) -> Generator[Any, Any, Any]: ...
def body_line_iterator(msg, decode: bool = ...) -> Generator[Any, Any, Any]: ...
def typed_subpart_iterator(msg, maintype=..., subtype=...) -> Generator[Any, Any, Any]: ...
def walk(self) -> Generator: ...
def body_line_iterator(msg, decode: bool = ...) -> Generator: ...
def typed_subpart_iterator(msg, maintype=..., subtype=...) -> Generator: ...
+2 -2
View File
@@ -1,4 +1,4 @@
from typing import Any, Generator
from typing import Generator
class Message:
preamble = ...
@@ -42,4 +42,4 @@ class Message:
def set_boundary(self, boundary) -> None: ...
def get_content_charset(self, failobj=...): ...
def get_charsets(self, failobj=...): ...
def walk(self) -> Generator[Any, Any, Any]: ...
def walk(self) -> Generator: ...
+6 -4
View File
@@ -1,9 +1,11 @@
from email.mime.nonmultipart import MIMENonMultipart
# 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: ...
def __init__(self, _data: bytes, _subtype: str = ...,
_encoder: Callable[[MIMEApplication], None] = ...,
**_params: _ParamsType) -> None: ...
+1
View File
@@ -1,4 +1,5 @@
from email.mime.nonmultipart import MIMENonMultipart
class MIMEAudio(MIMENonMultipart):
def __init__(self, _audiodata, _subtype=..., _encoder=..., **_params) -> None: ...
+1
View File
@@ -1,4 +1,5 @@
from email.mime.nonmultipart import MIMENonMultipart
class MIMEImage(MIMENonMultipart):
def __init__(self, _imagedata, _subtype=..., _encoder=..., **_params) -> None: ...
+1
View File
@@ -1,4 +1,5 @@
from email.mime.nonmultipart import MIMENonMultipart
class MIMEMessage(MIMENonMultipart):
def __init__(self, _msg, _subtype=...) -> None: ...
+5 -7
View File
@@ -1,11 +1,9 @@
from email._parseaddr import (
AddressList as _AddressList,
mktime_tz as mktime_tz,
parsedate as _parsedate,
parsedate_tz as _parsedate_tz,
)
from email._parseaddr import AddressList as _AddressList
from email._parseaddr import mktime_tz as mktime_tz
from email._parseaddr import parsedate as _parsedate
from email._parseaddr import parsedate_tz as _parsedate_tz
from quopri import decodestring as _qdecode
from typing import Any, Optional
from typing import Optional, Any
def formataddr(pair): ...
def getaddresses(fieldvalues): ...
+3 -4
View File
@@ -1,7 +1,6 @@
import codecs
from typing import Any
def search_function(encoding: str) -> codecs.CodecInfo: ...
import typing
# Explicitly mark this package as incomplete.
def __getattr__(name: str) -> Any: ...
def search_function(encoding: str) -> codecs.CodecInfo:
...
+48 -50
View File
@@ -1,50 +1,48 @@
from __builtin__ import (
ArithmeticError as ArithmeticError,
AssertionError as AssertionError,
AttributeError as AttributeError,
BaseException as BaseException,
BufferError as BufferError,
BytesWarning as BytesWarning,
DeprecationWarning as DeprecationWarning,
EnvironmentError as EnvironmentError,
EOFError as EOFError,
Exception as Exception,
FloatingPointError as FloatingPointError,
FutureWarning as FutureWarning,
GeneratorExit as GeneratorExit,
ImportError as ImportError,
ImportWarning as ImportWarning,
IndentationError as IndentationError,
IndexError as IndexError,
IOError as IOError,
KeyboardInterrupt as KeyboardInterrupt,
KeyError as KeyError,
LookupError as LookupError,
MemoryError as MemoryError,
NameError as NameError,
NotImplementedError as NotImplementedError,
OSError as OSError,
OverflowError as OverflowError,
PendingDeprecationWarning as PendingDeprecationWarning,
ReferenceError as ReferenceError,
RuntimeError as RuntimeError,
RuntimeWarning as RuntimeWarning,
StandardError as StandardError,
StopIteration as StopIteration,
SyntaxError as SyntaxError,
SyntaxWarning as SyntaxWarning,
SystemError as SystemError,
SystemExit as SystemExit,
TabError as TabError,
TypeError as TypeError,
UnboundLocalError as UnboundLocalError,
UnicodeDecodeError as UnicodeDecodeError,
UnicodeEncodeError as UnicodeEncodeError,
UnicodeError as UnicodeError,
UnicodeTranslateError as UnicodeTranslateError,
UnicodeWarning as UnicodeWarning,
UserWarning as UserWarning,
ValueError as ValueError,
Warning as Warning,
ZeroDivisionError as ZeroDivisionError,
)
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
+11 -6
View File
@@ -1,5 +1,5 @@
from _typeshed import FileDescriptorLike
from typing import Any, Union
from typing import Any, Union, IO
import io
FASYNC: int
FD_CLOEXEC: int
@@ -72,11 +72,16 @@ LOCK_SH: int
LOCK_UN: int
LOCK_WRITE: int
_ANYFILE = Union[int, IO]
# TODO All these return either int or bytes depending on the value of
# cmd (not on the type of arg).
def fcntl(fd: FileDescriptorLike, op: int, arg: Union[int, bytes] = ...) -> Any: ...
def fcntl(fd: _ANYFILE, op: int, arg: Union[int, bytes] = ...) -> Any: ...
# TODO: arg: int or read-only buffer interface or read-write buffer interface
def ioctl(fd: FileDescriptorLike, op: int, arg: Union[int, bytes] = ..., mutate_flag: bool = ...) -> Any: ...
def flock(fd: FileDescriptorLike, op: int) -> None: ...
def lockf(fd: FileDescriptorLike, op: int, length: int = ..., start: int = ..., whence: int = ...) -> Any: ...
def ioctl(fd: _ANYFILE, op: int, arg: Union[int, bytes] = ...,
mutate_flag: bool = ...) -> Any: ...
def flock(fd: _ANYFILE, op: int) -> None: ...
def lockf(fd: _ANYFILE, op: int, length: int = ..., start: int = ...,
whence: int = ...) -> Any: ...
+87 -16
View File
@@ -1,30 +1,101 @@
# Stubs for functools (Python 2.7)
# NOTE: These are incomplete!
from abc import ABCMeta, abstractmethod
from typing import Any, Callable, Dict, Generic, Iterable, Optional, Sequence, Tuple, Type, TypeVar, overload
from typing import Any, Callable, Generic, Dict, Iterable, Optional, Sequence, Tuple, TypeVar, overload
from collections import namedtuple
_AnyCallable = Callable[..., Any]
_T = TypeVar("_T")
_T2 = TypeVar("_T2")
_T3 = TypeVar("_T3")
_T4 = TypeVar("_T4")
_T5 = TypeVar("_T5")
_S = TypeVar("_S")
@overload
def reduce(function: Callable[[_T, _T], _T], sequence: Iterable[_T]) -> _T: ...
def reduce(function: Callable[[_T, _T], _T],
sequence: Iterable[_T]) -> _T: ...
@overload
def reduce(function: Callable[[_T, _S], _T], sequence: Iterable[_S], initial: _T) -> _T: ...
def reduce(function: Callable[[_T, _S], _T],
sequence: Iterable[_S], initial: _T) -> _T: ...
WRAPPER_ASSIGNMENTS: Sequence[str]
WRAPPER_UPDATES: Sequence[str]
def update_wrapper(
wrapper: _AnyCallable, wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...
) -> _AnyCallable: ...
def wraps(
wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...
) -> Callable[[_AnyCallable], _AnyCallable]: ...
def total_ordering(cls: Type[_T]) -> Type[_T]: ...
def update_wrapper(wrapper: _AnyCallable, wrapped: _AnyCallable, assigned: Sequence[str] = ...,
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]: ...
class partial(Generic[_T]):
func = ... # Callable[..., _T]
args: Tuple[Any, ...]
keywords: Dict[str, Any]
def __init__(self, func: Callable[..., _T], *args: Any, **kwargs: Any) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> _T: ...
@overload
def partial(__func: Callable[[_T], _S], __arg: _T) -> Callable[[], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2], _S], __arg: _T) -> Callable[[_T2], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3], _S], __arg: _T) -> Callable[[_T2, _T3], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4], _S], __arg: _T) -> Callable[[_T2, _T3, _T4], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4, _T5], _S], __arg: _T) -> Callable[[_T2, _T3, _T4, _T5], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2], _S],
__arg1: _T,
__arg2: _T2) -> Callable[[], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3], _S],
__arg1: _T,
__arg2: _T2) -> Callable[[_T3], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4], _S],
__arg1: _T,
__arg2: _T2) -> Callable[[_T3, _T4], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4, _T5], _S],
__arg1: _T,
__arg2: _T2) -> Callable[[_T3, _T4, _T5], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3) -> Callable[[], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3) -> Callable[[_T4], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4, _T5], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3) -> Callable[[_T4, _T5], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3,
__arg4: _T4) -> Callable[[], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4, _T5], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3,
__arg4: _T4) -> Callable[[_T5], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4, _T5], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3,
__arg4: _T4,
__arg5: _T5) -> Callable[[], _S]: ...
@overload
def partial(__func: Callable[..., _S],
*args: Any,
**kwargs: Any) -> Callable[..., _S]: ...
+8 -4
View File
@@ -1,10 +1,14 @@
from itertools import ifilter, imap, izip
from typing import Any
filter = ifilter
map = imap
zip = izip
from itertools import ifilter as filter
from itertools import imap as map
from itertools import izip as zip
def ascii(obj: Any) -> str: ...
def hex(x: int) -> str: ...
def oct(x: int) -> str: ...
+5 -1
View File
@@ -1,5 +1,8 @@
# Stubs for gc
from typing import Any, List, Tuple
def enable() -> None: ...
def disable() -> None: ...
def isenabled() -> bool: ...
@@ -7,7 +10,8 @@ def collect(generation: int = ...) -> int: ...
def set_debug(flags: int) -> None: ...
def get_debug() -> int: ...
def get_objects() -> List[Any]: ...
def set_threshold(threshold0: int, threshold1: int = ..., threshold2: int = ...) -> None: ...
def set_threshold(threshold0: int, threshold1: int = ...,
threshold2: int = ...) -> None: ...
def get_count() -> Tuple[int, int, int]: ...
def get_threshold() -> Tuple[int, int, int]: ...
def get_referrers(*objs: Any) -> List[Any]: ...
+3 -1
View File
@@ -1,4 +1,6 @@
from typing import IO, Any
# Stubs for getpass (Python 2)
from typing import Any, IO
class GetPassWarning(UserWarning): ...
+8 -15
View File
@@ -1,4 +1,4 @@
from typing import IO, Any, Container, Dict, List, Optional, Sequence, Type, Union
from typing import Any, Container, Dict, IO, List, Optional, Sequence, Type, Union
def bindtextdomain(domain: str, localedir: str = ...) -> str: ...
def bind_textdomain_codeset(domain: str, codeset: str = ...) -> str: ...
@@ -32,17 +32,10 @@ class GNUTranslations(NullTranslations):
LE_MAGIC: int
BE_MAGIC: int
def find(
domain: str, localedir: Optional[str] = ..., languages: Optional[Sequence[str]] = ..., all: Any = ...
) -> Optional[Union[str, List[str]]]: ...
def translation(
domain: str,
localedir: Optional[str] = ...,
languages: Optional[Sequence[str]] = ...,
class_: Optional[Type[NullTranslations]] = ...,
fallback: bool = ...,
codeset: Optional[str] = ...,
) -> NullTranslations: ...
def install(
domain: str, localedir: Optional[str] = ..., unicode: bool = ..., codeset: Optional[str] = ..., names: Container[str] = ...
) -> None: ...
def find(domain: str, localedir: Optional[str] = ..., languages: Optional[Sequence[str]] = ...,
all: Any = ...) -> Optional[Union[str, List[str]]]: ...
def translation(domain: str, localedir: Optional[str] = ..., languages: Optional[Sequence[str]] = ...,
class_: Optional[Type[NullTranslations]] = ..., fallback: bool = ..., codeset: Optional[str] = ...) -> NullTranslations: ...
def install(domain: str, localedir: Optional[str] = ..., unicode: bool = ..., codeset: Optional[str] = ...,
names: Container[str] = ...) -> None: ...
+1 -1
View File
@@ -1,4 +1,4 @@
from typing import AnyStr, Iterator, List, Union
from typing import List, Iterator, Union, AnyStr
def glob(pathname: AnyStr) -> List[AnyStr]: ...
def iglob(pathname: AnyStr) -> Iterator[AnyStr]: ...
+3 -4
View File
@@ -1,5 +1,5 @@
from typing import Any, IO, Text
import io
from typing import IO, Any, Text
class GzipFile(io.BufferedIOBase):
myfileobj: Any
@@ -14,9 +14,8 @@ class GzipFile(io.BufferedIOBase):
fileobj: Any
offset: Any
mtime: Any
def __init__(
self, filename: str = ..., mode: Text = ..., compresslevel: int = ..., fileobj: IO[str] = ..., mtime: float = ...
) -> None: ...
def __init__(self, filename: str = ..., mode: Text = ..., compresslevel: int = ...,
fileobj: IO[str] = ..., mtime: float = ...) -> None: ...
@property
def filename(self): ...
size: Any
+6 -3
View File
@@ -1,12 +1,14 @@
# Stubs for hashlib (Python 2)
from typing import Tuple, Union
_DataType = Union[str, unicode, bytearray, buffer, memoryview]
class _hash(object): # This is not actually in the module namespace.
name: str
block_size: int
digest_size: int
digestsize: int
block_size = 0
digest_size = 0
digestsize = 0
def __init__(self, arg: _DataType = ...) -> None: ...
def update(self, arg: _DataType) -> None: ...
def digest(self) -> str: ...
@@ -14,6 +16,7 @@ class _hash(object): # This is not actually in the module namespace.
def copy(self) -> _hash: ...
def new(name: str, data: str = ...) -> _hash: ...
def md5(s: _DataType = ...) -> _hash: ...
def sha1(s: _DataType = ...) -> _hash: ...
def sha224(s: _DataType = ...) -> _hash: ...
+9 -8
View File
@@ -1,15 +1,16 @@
from _typeshed import SupportsLessThan
from typing import Any, Callable, Iterable, List, Optional, Protocol, TypeVar
from typing import TypeVar, List, Iterable, Any, Callable, Optional
_T = TypeVar("_T")
_T = TypeVar('_T')
def cmp_lt(x, y) -> bool: ...
def heappush(heap: List[_T], item: _T) -> None: ...
def heappop(heap: List[_T]) -> _T: ...
def heappop(heap: List[_T]) -> _T:
raise IndexError() # if heap is empty
def heappushpop(heap: List[_T], item: _T) -> _T: ...
def heapify(x: List[_T]) -> None: ...
def heapreplace(heap: List[_T], item: _T) -> _T: ...
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], key: Optional[Callable[[_T], SupportsLessThan]] = ...) -> List[_T]: ...
def nsmallest(n: int, iterable: Iterable[_T], key: Optional[Callable[[_T], SupportsLessThan]] = ...) -> List[_T]: ...
def _heapify_max(__x: List[_T]) -> None: ... # undocumented
def nlargest(n: int, iterable: Iterable[_T],
key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ...
def nsmallest(n: int, iterable: Iterable[_T]) -> List[_T]: ...
+4 -4
View File
@@ -1,5 +1,5 @@
from typing import Dict
from typing import Any, Mapping
name2codepoint: Dict[str, int]
codepoint2name: Dict[int, str]
entitydefs: Dict[str, str]
name2codepoint: Mapping[str, int]
codepoint2name: Mapping[int, str]
entitydefs: Mapping[str, str]
+14 -27
View File
@@ -1,6 +1,11 @@
# Stubs for httplib (Python 2)
#
# Generated by stubgen and manually massaged a bit.
# Needs lots more work!
from typing import Any, Dict, Optional, Protocol
import mimetools
import ssl
from typing import Any, Dict, Optional, Protocol
class HTTPMessage(mimetools.Message):
def addcontinue(self, key: str, more: str) -> None: ...
@@ -24,9 +29,8 @@ class HTTPResponse:
chunk_left: Any
length: Any
will_close: Any
def __init__(
self, sock, debuglevel: int = ..., strict: int = ..., method: Optional[Any] = ..., buffering: bool = ...
) -> None: ...
def __init__(self, sock, debuglevel: int = ..., strict: int = ..., method: Optional[Any] = ...,
buffering: bool = ...) -> None: ...
def begin(self): ...
def close(self): ...
def isclosed(self): ...
@@ -55,9 +59,8 @@ class HTTPConnection:
sock: Any
host: str = ...
port: int = ...
def __init__(
self, host, port: Optional[Any] = ..., strict: Optional[Any] = ..., timeout=..., source_address: Optional[Any] = ...
) -> None: ...
def __init__(self, host, port: Optional[Any] = ..., strict: Optional[Any] = ..., timeout=...,
source_address: Optional[Any] = ...) -> None: ...
def set_tunnel(self, host, port: Optional[Any] = ..., headers: Optional[Any] = ...): ...
def set_debuglevel(self, level): ...
def connect(self): ...
@@ -83,32 +86,16 @@ class HTTPSConnection(HTTPConnection):
default_port: Any
key_file: Any
cert_file: Any
def __init__(
self,
host,
port: Optional[Any] = ...,
key_file: Optional[Any] = ...,
cert_file: Optional[Any] = ...,
strict: Optional[Any] = ...,
timeout=...,
source_address: Optional[Any] = ...,
context: Optional[Any] = ...,
) -> None: ...
def __init__(self, host, port: Optional[Any] = ..., key_file: Optional[Any] = ..., cert_file: Optional[Any] = ...,
strict: Optional[Any] = ..., timeout=..., source_address: Optional[Any] = ...,
context: Optional[Any] = ...) -> None: ...
sock: Any
def connect(self): ...
class HTTPS(HTTP):
key_file: Any
cert_file: Any
def __init__(
self,
host: str = ...,
port: Optional[Any] = ...,
key_file: Optional[Any] = ...,
cert_file: Optional[Any] = ...,
strict: Optional[Any] = ...,
context: Optional[Any] = ...,
) -> None: ...
def __init__(self, host: str = ..., port: Optional[Any] = ..., key_file: Optional[Any] = ..., cert_file: Optional[Any] = ..., strict: Optional[Any] = ..., context: Optional[Any] = ...) -> None: ...
class HTTPException(Exception): ...
class NotConnected(HTTPException): ...

Some files were not shown because too many files have changed in this diff Show More