mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Sync with typeshed @ 771e872cf605dbe6b489aa228c0a09a1a8ca69f2 (PY-41510)
Support new typeshed structure GitOrigin-RevId: 4ada15febc11dc9acb8243c791aef722e16dd958
This commit is contained in:
committed by
intellij-monorepo-bot
parent
bf948101cc
commit
39700adb5e
@@ -38,7 +38,7 @@ jobs:
|
||||
# fail action if exit code isn't zero or one
|
||||
(
|
||||
mypy_primer \
|
||||
--new 0.790 --old 0.790 \
|
||||
--new 4d5a1bc752 --old 4d5a1bc752 \
|
||||
--custom-typeshed-repo typeshed_to_test \
|
||||
--new-typeshed $GITHUB_SHA --old-typeshed upstream_master \
|
||||
--num-shards 2 --shard-index ${{ matrix.shard-index }} \
|
||||
|
||||
@@ -89,15 +89,11 @@ jobs:
|
||||
|
||||
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)
|
||||
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 + '```'
|
||||
})
|
||||
}
|
||||
|
||||
+23
-5
@@ -11,7 +11,9 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
- run: ./tests/check_consistent.py
|
||||
- run: |
|
||||
pip install toml
|
||||
./tests/check_consistent.py
|
||||
|
||||
flake8:
|
||||
name: Lint with flake8
|
||||
@@ -31,7 +33,7 @@ jobs:
|
||||
- uses: actions/setup-python@v2
|
||||
- run: |
|
||||
pip install $(grep black requirements-tests-py3.txt)
|
||||
black --check --diff stdlib third_party
|
||||
black --check --diff stdlib stubs
|
||||
|
||||
isort:
|
||||
name: Check imports with isort
|
||||
@@ -41,7 +43,7 @@ jobs:
|
||||
- uses: actions/setup-python@v2
|
||||
- run: |
|
||||
pip install $(grep isort requirements-tests-py3.txt)
|
||||
isort --check-only --diff stdlib third_party
|
||||
isort --check-only --diff stdlib stubs
|
||||
|
||||
pytype:
|
||||
name: Run pytype against the stubs
|
||||
@@ -83,8 +85,24 @@ jobs:
|
||||
- uses: actions/setup-python@v2
|
||||
- run: ./tests/mypy_test_suite.py
|
||||
|
||||
pyright:
|
||||
name: Run pyright against the stubs
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-platform: ["Linux", "Windows", "Darwin"]
|
||||
python-version: [3.6, 3.7, 3.8, 3.9]
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '14'
|
||||
- run: ./tests/pyright_test.py --pythonplatform ${{ matrix.python-platform }} --pythonversion ${{ matrix.python-version }}
|
||||
|
||||
stubtest:
|
||||
name: Check stubs with stubtest
|
||||
name: Check stdlib with stubtest
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
@@ -101,6 +119,6 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install -U pip
|
||||
pip install -U git+git://github.com/python/mypy@24fdf343
|
||||
pip install -U git+git://github.com/python/mypy@master
|
||||
- name: Run stubtest
|
||||
run: python tests/stubtest_test.py --ignore-unused-whitelist
|
||||
|
||||
@@ -209,9 +209,6 @@ you should know about.
|
||||
|
||||
Style conventions for stub files are different from PEP 8. The general
|
||||
rule is that they should be as concise as possible. Specifically:
|
||||
* lines can be up to 130 characters long;
|
||||
* functions and methods that don't fit in one line should be split up
|
||||
with one argument per line;
|
||||
* all function bodies should be empty;
|
||||
* prefer ``...`` over ``pass``;
|
||||
* prefer ``...`` on the same line as the class/function signature;
|
||||
@@ -221,8 +218,7 @@ rule is that they should be as concise as possible. Specifically:
|
||||
if the classes are very small;
|
||||
* do not use docstrings;
|
||||
* 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 `=`.
|
||||
that target older versions of Python.
|
||||
|
||||
Stubs should be reformatted with the formatters
|
||||
[black](https://github.com/psf/black) and
|
||||
@@ -241,7 +237,13 @@ checker, and leave out unnecessary detail:
|
||||
* use `float` instead of `Union[int, float]`.
|
||||
|
||||
Some further tips for good type hints:
|
||||
* avoid invariant collection types (`List`, `Dict`) in argument
|
||||
* use built-in generics (`list`, `dict`, `tuple`, `set`), instead
|
||||
of importing them from `typing`, **except** for arbitrary length tuples
|
||||
(`Tuple[int, ...]`) (see
|
||||
[python/mypy#9980](https://github.com/python/mypy/issues/9980));
|
||||
* in Python 3 stubs, import collections (`Mapping`, `Iterable`, etc.)
|
||||
from `collections.abc` instead of `typing`;
|
||||
* avoid invariant collection types (`list`, `dict`) in argument
|
||||
positions, in favor of covariant types like `Mapping` or `Sequence`;
|
||||
* avoid Union return types: https://github.com/python/mypy/issues/1693;
|
||||
* in Python 2, whenever possible, use `unicode` if that's the only
|
||||
@@ -265,14 +267,6 @@ Note that `Any` is not the correct type to use if you want to indicate
|
||||
that some function can accept literally anything: in those cases use
|
||||
`object` instead.
|
||||
|
||||
For arguments with type and a default value of `None`, PEP 484
|
||||
prescribes that the type automatically becomes `Optional`. However we
|
||||
prefer explicit over implicit in this case, and require the explicit
|
||||
`Optional[]` around the type. The mypy tests enforce this (through
|
||||
the use of --no-implicit-optional) and the error looks like
|
||||
`Incompatible types in assignment (expression has type None, variable
|
||||
has type "Blah") `.
|
||||
|
||||
Stub files support forward references natively. In other words, the
|
||||
order of class declarations and type aliases does not matter in
|
||||
a stub file. You can also use the name of the class within its own
|
||||
@@ -308,30 +302,19 @@ contributors.
|
||||
|
||||
### Stub versioning
|
||||
|
||||
There are separate directories for `stdlib` and `third_party` stubs.
|
||||
Within those, there are separate directories for different versions of
|
||||
Python the stubs target.
|
||||
There are separate directories for `stdlib` (standard library) and `stubs`
|
||||
(all other stubs). For standard library stubs Python version support is
|
||||
given in `VERSIONS` file. Each line in this file is a module or package name
|
||||
followed by `: `, followed by the oldest *supported* Python version where
|
||||
the module is available. For third party packages, the Python version support
|
||||
(2 and/or 3 only, no finer grained version is supported) is indicated in the
|
||||
corresponding `METADATA.toml` file as `python2 = (True|False)` (defaults to
|
||||
`False`) and `python3 = (True|False)` (defaults to `True`).
|
||||
|
||||
The directory name indicates the major version of Python that a stub targets
|
||||
and optionally the lowest minor version, with the exception of the `2and3`
|
||||
directory which applies to both Python 2 and 3.
|
||||
|
||||
For example, stubs in the `3` directory will be applied to all versions of
|
||||
Python 3, though stubs in the `3.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.
|
||||
|
||||
It is preferred to use a single stub in the more generic directory that
|
||||
conditionally targets specific versions when needed, as opposed
|
||||
to maintaining multiple stub files within more specific directories. Similarly,
|
||||
if the given library works on both Python 2 and Python 3, prefer to put your
|
||||
stubs in the `2and3` directory, unless the types are so different that the stubs
|
||||
become unreadable that way.
|
||||
|
||||
You can use checks like `if sys.version_info >= (3, 8):` 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:
|
||||
It is preferred to use a single stub for every module. You can use checks
|
||||
like `if sys.version_info >= (3, 8):` 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:
|
||||
|
||||
* mypy doesn't support more fine-grained version checks; and more
|
||||
importantly
|
||||
@@ -353,10 +336,28 @@ 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.
|
||||
|
||||
If it is not possible to generate combined stubs for all Python versions
|
||||
in a single file, you can split Python 2 and Python 3 stubs and place Python 2
|
||||
stubs into `@python2` subdirectory for corresponding distribution. Note that
|
||||
you don't need `@python2` in most cases, if your package supports Python 2,
|
||||
just put the stubs at root of the distribution directory, and put
|
||||
`python2 = True` in `METADATA.toml`.
|
||||
|
||||
Note: in its current implementation, typeshed cannot contain stubs for
|
||||
multiple versions of the same third-party library. Prefer to generate
|
||||
stubs for the latest version released on PyPI at the time of your
|
||||
stubbing.
|
||||
stubbing. The oldest version of the library for which the stubs are still
|
||||
applicable (i.e. reflect the actual runtime behaviour) can be indicated
|
||||
in `METADATA.toml` as `version = "x.y"`. Note that only two most significant
|
||||
version levels are supported (i.e. only single dot). When a significant change
|
||||
is made in the library, the version of the stub should be bumped (note that
|
||||
previous versions are still available on PyPI).
|
||||
|
||||
Internal typeshed machinery will periodically build and upload modified
|
||||
third party packages to PyPI, each time this happens the least significant
|
||||
version level is incremented. For example, if `stubs/foo/METADATA.toml` has
|
||||
`version = "x.y"` the package on PyPI will be updated from `types-foo-x.y.n`
|
||||
to `types-foo-x.y.n+1`.
|
||||
|
||||
### What to do when a project's documentation and implementation disagree
|
||||
|
||||
|
||||
@@ -23,27 +23,20 @@ Typeshed supports Python versions 2.7 and 3.6 and up.
|
||||
|
||||
If you're just using mypy (or pytype or PyCharm), as opposed to
|
||||
developing it, you don't need to interact with the typeshed repo at
|
||||
all: a copy of typeshed is bundled with mypy.
|
||||
all: a copy of standard library part of typeshed is bundled with mypy.
|
||||
And type stubs for third party packages and modules you are using can
|
||||
be installed from PyPI. For example, if you are using `six` and `requests`,
|
||||
you can install the type stubs using
|
||||
|
||||
When you use a checked-out clone of the mypy repo, a copy of typeshed
|
||||
should be included as a submodule, using
|
||||
$ pip install types-six types-requests
|
||||
|
||||
$ git clone --recurse-submodules https://github.com/python/mypy.git
|
||||
These PyPI packages follow [PEP 561](http://www.python.org/dev/peps/pep-0561/)
|
||||
and are automatically generated by typeshed internal machinery. Also starting
|
||||
from version 0.900 mypy will provide an option to automatically install missing
|
||||
type stub packages (if found on PyPI).
|
||||
|
||||
or
|
||||
|
||||
$ git clone https://github.com/python/mypy.git
|
||||
$ cd mypy
|
||||
$ git submodule init
|
||||
$ git submodule update
|
||||
|
||||
and occasionally you will have to repeat the final command (`git
|
||||
submodule update`) to pull in changes made in the upstream typeshed
|
||||
repo.
|
||||
|
||||
PyCharm and pytype similarly include a copy of typeshed. The one in
|
||||
pytype can be updated in the same way if you are working with the
|
||||
pytype repo.
|
||||
PyCharm, pytype etc. work in a similar way, for more details see documentation
|
||||
for the type-checking tool you are using.
|
||||
|
||||
## Format
|
||||
|
||||
@@ -63,16 +56,31 @@ coding style used in typeshed.
|
||||
|
||||
### stdlib
|
||||
|
||||
This contains stubs for modules the Python standard library -- which
|
||||
This contains stubs for modules in the Python standard library -- which
|
||||
includes pure Python modules, dynamically loaded extension modules,
|
||||
hard-linked extension modules, and the builtins.
|
||||
hard-linked extension modules, and the builtins. `VERSIONS` file lists
|
||||
the oldest *supported* Python version where the module is available.
|
||||
In the `stdlib/@python2` subdirectory you can find Python 2 versions of
|
||||
the stub files that must be kept different for Python 2 and 3, like
|
||||
`builtins.pyi`.
|
||||
|
||||
### third_party
|
||||
### stubs
|
||||
|
||||
Modules that are not shipped with Python but have a type description in Python
|
||||
go into `third_party`. Since these modules can behave differently for different
|
||||
versions of Python, `third_party` has version subdirectories, just like
|
||||
`stdlib`.
|
||||
go into `stubs`. Each subdirectory there represents a PyPI distribution, and
|
||||
contains the following:
|
||||
* `METADATA.toml` that specifies oldest version of the source library for
|
||||
which the stubs are applicable, supported Python versions (Python 3 defaults
|
||||
to `True`, Python 2 defaults to `False`), and dependency on other type stub
|
||||
packages.
|
||||
* Stubs (i.e. `*.pyi` files) for packages and modules that are shipped in the
|
||||
source distribution. Similar to standard library, if the Python 2 version of
|
||||
the stubs must be kept *separate*, it can be put in a `@python` subdirectory.
|
||||
* (Rarely) some docs specific to a given type stub package in `README` file.
|
||||
|
||||
No other files are allowed in `stdlib` and `stubs`. When a third party stub is
|
||||
modified, an updated version of the corresponding distribution will be
|
||||
automatically uploaded to PyPI shortly (within few hours).
|
||||
|
||||
For more information on directory structure and stub versioning, see
|
||||
[the relevant section of CONTRIBUTING.md](
|
||||
@@ -87,8 +95,8 @@ following criteria is met:
|
||||
|
||||
## Contributing
|
||||
|
||||
Please read [CONTRIBUTING.md](CONTRIBUTING.md) before submitting pull
|
||||
requests. If you have questions related to contributing, drop by the [typing Gitter](https://gitter.im/python/typing).
|
||||
Please read [CONTRIBUTING.md](CONTRIBUTING.md) before submitting pull requests.
|
||||
If you have questions related to contributing, drop by the [typing Gitter](https://gitter.im/python/typing).
|
||||
|
||||
## Running the tests
|
||||
|
||||
@@ -100,6 +108,8 @@ There are several tests:
|
||||
tests typeshed with [mypy](https://github.com/python/mypy/)
|
||||
- `tests/pytype_test.py` tests typeshed with
|
||||
[pytype](https://github.com/google/pytype/).
|
||||
- `tests/pyright_test.py` tests typeshed with
|
||||
[pyright](https://github.com/microsoft/pyright).
|
||||
- `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
|
||||
@@ -113,7 +123,7 @@ consistent with each other.
|
||||
|
||||
Run:
|
||||
```
|
||||
$ python3.6 -m venv .venv3
|
||||
$ python3 -m venv .venv3
|
||||
$ source .venv3/bin/activate
|
||||
(.venv3)$ pip install -U pip
|
||||
(.venv3)$ pip install -r requirements-tests-py3.txt
|
||||
@@ -121,6 +131,9 @@ $ source .venv3/bin/activate
|
||||
This will install mypy (you need the latest master branch from GitHub),
|
||||
typed-ast, flake8 (and plugins), pytype, black and isort.
|
||||
|
||||
If you want to run the pyright tests, you need to have
|
||||
[Node.js](https://nodejs.org/) installed.
|
||||
|
||||
### mypy_test.py
|
||||
|
||||
This test requires Python 3.6 or higher; Python 3.6.1 or higher is recommended.
|
||||
@@ -152,6 +165,10 @@ Run using: `(.venv3)$ python3 tests/pytype_test.py`
|
||||
|
||||
This test works similarly to `mypy_test.py`, except it uses `pytype`.
|
||||
|
||||
### pyright\_test.py
|
||||
|
||||
This test requires Node.js to be installed.
|
||||
|
||||
### mypy_self_check.py
|
||||
|
||||
This test requires Python 3.6 or higher; Python 3.6.1 or higher is recommended.
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
{
|
||||
"typeshedPath": ".",
|
||||
"include": [
|
||||
"stdlib",
|
||||
"stubs"
|
||||
],
|
||||
"exclude": [
|
||||
"**/@python2",
|
||||
"stdlib/encodings/__init__.pyi",
|
||||
"stdlib/sqlite3/dbapi2.pyi",
|
||||
"stdlib/tkinter",
|
||||
"stdlib/xml/dom",
|
||||
"stdlib/xml/sax",
|
||||
"stubs/backports",
|
||||
"stubs/backports_abc",
|
||||
"stubs/boto",
|
||||
"stubs/chardet",
|
||||
"stubs/cryptography",
|
||||
"stubs/dateparser",
|
||||
"stubs/docutils",
|
||||
"stubs/fb303",
|
||||
"stubs/Flask",
|
||||
"stubs/Jinja2",
|
||||
"stubs/kazoo",
|
||||
"stubs/Markdown",
|
||||
"stubs/paramiko",
|
||||
"stubs/protobuf",
|
||||
"stubs/pymssql",
|
||||
"stubs/PyMySQL",
|
||||
"stubs/python-dateutil",
|
||||
"stubs/pyvmomi",
|
||||
"stubs/PyYAML",
|
||||
"stubs/redis",
|
||||
"stubs/requests",
|
||||
"stubs/Routes",
|
||||
"stubs/scribe",
|
||||
"stubs/simplejson",
|
||||
"stubs/tornado",
|
||||
"stubs/waitress",
|
||||
"stubs/Werkzeug"
|
||||
],
|
||||
"typeCheckingMode": "basic",
|
||||
"strictListInference": true,
|
||||
"strictDictionaryInference": true,
|
||||
"strictParameterNoneValue": true,
|
||||
"reportFunctionMemberAccess": "error",
|
||||
"reportMissingModuleSource": "none",
|
||||
"reportMissingTypeStubs": "error",
|
||||
"reportUnusedImport": "error",
|
||||
"reportUnusedClass": "error",
|
||||
"reportUnusedFunction": "error",
|
||||
"reportUnusedVariable": "error",
|
||||
"reportDuplicateImport": "error",
|
||||
"reportOptionalSubscript": "error",
|
||||
"reportOptionalMemberAccess": "error",
|
||||
"reportOptionalCall": "error",
|
||||
"reportOptionalIterable": "error",
|
||||
"reportOptionalContextManager": "error",
|
||||
"reportOptionalOperand": "error",
|
||||
"reportUntypedFunctionDecorator": "error",
|
||||
"reportUntypedClassDecorator": "error",
|
||||
"reportUntypedBaseClass": "error",
|
||||
"reportUntypedNamedTuple": "error",
|
||||
"reportPrivateUsage": "error",
|
||||
"reportConstantRedefinition": "error",
|
||||
"reportIncompatibleMethodOverride": "error",
|
||||
"reportIncompatibleVariableOverride": "error",
|
||||
"reportInvalidStringEscapeSequence": "error",
|
||||
"reportUnknownParameterType": "error",
|
||||
"reportUnknownArgumentType": "error",
|
||||
"reportUnknownLambdaType": "error",
|
||||
"reportUnknownVariableType": "error",
|
||||
"reportUnknownMemberType": "error",
|
||||
"reportMissingTypeArgument": "error",
|
||||
"reportUndefinedVariable": "error",
|
||||
"reportUnboundVariable": "error",
|
||||
"reportInvalidStubStatement": "error",
|
||||
"reportUnsupportedDunderAll": "error",
|
||||
"reportInvalidTypeVarUse": "none",
|
||||
"reportOverlappingOverload": "none",
|
||||
"reportPropertyTypeMismatch": "none",
|
||||
"reportSelfClsParameterName": "none"
|
||||
}
|
||||
@@ -5,4 +5,4 @@ flake8==3.8.4
|
||||
flake8-bugbear==20.1.4
|
||||
flake8-pyi==20.10.0
|
||||
isort[pyproject]==5.5.3
|
||||
pytype>=2020.09.16
|
||||
pytype>=2021.01.28
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#!/bin/bash
|
||||
# Some of the proto .pyi stubs in third_party/2and3/google/protobuf/
|
||||
# Some of the proto .pyi stubs in stubs/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
|
||||
# stubs/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
|
||||
#
|
||||
@@ -46,7 +46,7 @@ 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
|
||||
find $REPO_ROOT/stubs/protobuf/ -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.
|
||||
@@ -65,4 +65,4 @@ PROTO_FILES=$(grep "generate_proto.*google" $PYTHON_PROTOBUF_DIR/python/setup.py
|
||||
)
|
||||
|
||||
# And regenerate!
|
||||
protoc_install/bin/protoc --proto_path=$PYTHON_PROTOBUF_DIR/src --mypy_out=$REPO_ROOT/third_party/2and3 $PROTO_FILES
|
||||
protoc_install/bin/protoc --proto_path=$PYTHON_PROTOBUF_DIR/src --mypy_out=$REPO_ROOT/stubs/protobuf $PROTO_FILES
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
import sys
|
||||
from _typeshed import SupportsGetItem, SupportsItemAccess
|
||||
from builtins import type as _type
|
||||
from typing import IO, Any, AnyStr, Dict, Iterable, Iterator, List, Mapping, Optional, Protocol, Tuple, TypeVar, Union
|
||||
|
||||
_T = TypeVar("_T", bound=FieldStorage)
|
||||
|
||||
def parse(
|
||||
fp: Optional[IO[Any]] = ...,
|
||||
environ: SupportsItemAccess[str, str] = ...,
|
||||
keep_blank_values: bool = ...,
|
||||
strict_parsing: bool = ...,
|
||||
) -> Dict[str, List[str]]: ...
|
||||
|
||||
if sys.version_info < (3, 8):
|
||||
def parse_qs(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> Dict[str, List[str]]: ...
|
||||
def parse_qsl(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> List[Tuple[str, str]]: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
def parse_multipart(
|
||||
fp: IO[Any], pdict: SupportsGetItem[str, bytes], encoding: str = ..., errors: str = ...
|
||||
) -> Dict[str, List[Any]]: ...
|
||||
|
||||
else:
|
||||
def parse_multipart(fp: IO[Any], pdict: SupportsGetItem[str, bytes]) -> Dict[str, List[bytes]]: ...
|
||||
|
||||
class _Environ(Protocol):
|
||||
def __getitem__(self, __k: str) -> str: ...
|
||||
def keys(self) -> Iterable[str]: ...
|
||||
|
||||
def parse_header(line: str) -> Tuple[str, Dict[str, str]]: ...
|
||||
def test(environ: _Environ = ...) -> None: ...
|
||||
def print_environ(environ: _Environ = ...) -> None: ...
|
||||
def print_form(form: Dict[str, Any]) -> None: ...
|
||||
def print_directory() -> None: ...
|
||||
def print_environ_usage() -> None: ...
|
||||
|
||||
if sys.version_info < (3,):
|
||||
def escape(s: AnyStr, quote: bool = ...) -> AnyStr: ...
|
||||
|
||||
elif sys.version_info < (3, 8):
|
||||
def escape(s: str, quote: Optional[bool] = ...) -> str: ...
|
||||
|
||||
class MiniFieldStorage:
|
||||
# The first five "Any" attributes here are always None, but mypy doesn't support that
|
||||
filename: Any
|
||||
list: Any
|
||||
type: Any
|
||||
file: Optional[IO[bytes]]
|
||||
type_options: Dict[Any, Any]
|
||||
disposition: Any
|
||||
disposition_options: Dict[Any, Any]
|
||||
headers: Dict[Any, Any]
|
||||
name: Any
|
||||
value: Any
|
||||
def __init__(self, name: Any, value: Any) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
|
||||
class FieldStorage(object):
|
||||
FieldStorageClass: Optional[_type]
|
||||
keep_blank_values: int
|
||||
strict_parsing: int
|
||||
qs_on_post: Optional[str]
|
||||
headers: Mapping[str, str]
|
||||
fp: IO[bytes]
|
||||
encoding: str
|
||||
errors: str
|
||||
outerboundary: bytes
|
||||
bytes_read: int
|
||||
limit: Optional[int]
|
||||
disposition: str
|
||||
disposition_options: Dict[str, str]
|
||||
filename: Optional[str]
|
||||
file: Optional[IO[bytes]]
|
||||
type: str
|
||||
type_options: Dict[str, str]
|
||||
innerboundary: bytes
|
||||
length: int
|
||||
done: int
|
||||
list: Optional[List[Any]]
|
||||
value: Union[None, bytes, List[Any]]
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
def __init__(
|
||||
self,
|
||||
fp: Optional[IO[Any]] = ...,
|
||||
headers: Optional[Mapping[str, str]] = ...,
|
||||
outerboundary: bytes = ...,
|
||||
environ: SupportsGetItem[str, str] = ...,
|
||||
keep_blank_values: int = ...,
|
||||
strict_parsing: int = ...,
|
||||
limit: Optional[int] = ...,
|
||||
encoding: str = ...,
|
||||
errors: str = ...,
|
||||
max_num_fields: Optional[int] = ...,
|
||||
) -> None: ...
|
||||
elif sys.version_info >= (3, 0):
|
||||
def __init__(
|
||||
self,
|
||||
fp: Optional[IO[Any]] = ...,
|
||||
headers: Optional[Mapping[str, str]] = ...,
|
||||
outerboundary: bytes = ...,
|
||||
environ: SupportsGetItem[str, str] = ...,
|
||||
keep_blank_values: int = ...,
|
||||
strict_parsing: int = ...,
|
||||
limit: Optional[int] = ...,
|
||||
encoding: str = ...,
|
||||
errors: str = ...,
|
||||
) -> None: ...
|
||||
else:
|
||||
def __init__(
|
||||
self,
|
||||
fp: IO[Any] = ...,
|
||||
headers: Mapping[str, str] = ...,
|
||||
outerboundary: bytes = ...,
|
||||
environ: SupportsGetItem[str, str] = ...,
|
||||
keep_blank_values: int = ...,
|
||||
strict_parsing: int = ...,
|
||||
) -> None: ...
|
||||
if sys.version_info >= (3, 0):
|
||||
def __enter__(self: _T) -> _T: ...
|
||||
def __exit__(self, *args: Any) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def __iter__(self) -> Iterator[str]: ...
|
||||
def __getitem__(self, key: str) -> Any: ...
|
||||
def getvalue(self, key: str, default: Any = ...) -> Any: ...
|
||||
def getfirst(self, key: str, default: Any = ...) -> Any: ...
|
||||
def getlist(self, key: str) -> List[Any]: ...
|
||||
def keys(self) -> List[str]: ...
|
||||
if sys.version_info < (3, 0):
|
||||
def has_key(self, key: str) -> bool: ...
|
||||
def __contains__(self, key: str) -> bool: ...
|
||||
def __len__(self) -> int: ...
|
||||
if sys.version_info >= (3, 0):
|
||||
def __bool__(self) -> bool: ...
|
||||
else:
|
||||
def __nonzero__(self) -> bool: ...
|
||||
if sys.version_info >= (3, 0):
|
||||
# In Python 3 it returns bytes or str IO depending on an internal flag
|
||||
def make_file(self) -> IO[Any]: ...
|
||||
else:
|
||||
# In Python 2 it always returns bytes and ignores the "binary" flag
|
||||
def make_file(self, binary: Any = ...) -> IO[bytes]: ...
|
||||
|
||||
if sys.version_info < (3, 0):
|
||||
from UserDict import UserDict
|
||||
class FormContentDict(UserDict[str, List[str]]):
|
||||
query_string: str
|
||||
def __init__(self, environ: Mapping[str, str] = ..., keep_blank_values: int = ..., strict_parsing: int = ...) -> None: ...
|
||||
class SvFormContentDict(FormContentDict):
|
||||
def getlist(self, key: Any) -> Any: ...
|
||||
class InterpFormContentDict(SvFormContentDict): ...
|
||||
class FormContent(FormContentDict):
|
||||
# TODO this should have
|
||||
# def values(self, key: Any) -> Any: ...
|
||||
# but this is incompatible with the supertype, and adding '# type: ignore' triggers
|
||||
# a parse error in pytype (https://github.com/google/pytype/issues/53)
|
||||
def indexed_value(self, key: Any, location: int) -> Any: ...
|
||||
def value(self, key: Any) -> Any: ...
|
||||
def length(self, key: Any) -> int: ...
|
||||
def stripped(self, key: Any) -> Any: ...
|
||||
def pars(self) -> Dict[Any, Any]: ...
|
||||
@@ -1,13 +0,0 @@
|
||||
from typing import Any
|
||||
|
||||
class Null: ...
|
||||
class Str: ...
|
||||
|
||||
class Xxo:
|
||||
def demo(self) -> None: ...
|
||||
|
||||
class error: ...
|
||||
|
||||
def foo(__i: int, __j: int) -> Any: ...
|
||||
def new() -> Xxo: ...
|
||||
def roj(__b: Any) -> None: ...
|
||||
@@ -0,0 +1,109 @@
|
||||
from _typeshed import SupportsGetItem, SupportsItemAccess
|
||||
from builtins import type as _type
|
||||
from typing import IO, Any, AnyStr, Iterable, Iterator, List, Mapping, Optional, Protocol, TypeVar, Union
|
||||
from UserDict import UserDict
|
||||
|
||||
_T = TypeVar("_T", bound=FieldStorage)
|
||||
|
||||
def parse(
|
||||
fp: Optional[IO[Any]] = ...,
|
||||
environ: SupportsItemAccess[str, str] = ...,
|
||||
keep_blank_values: bool = ...,
|
||||
strict_parsing: bool = ...,
|
||||
) -> dict[str, List[str]]: ...
|
||||
def parse_qs(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> dict[str, List[str]]: ...
|
||||
def parse_qsl(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> List[tuple[str, str]]: ...
|
||||
def parse_multipart(fp: IO[Any], pdict: SupportsGetItem[str, bytes]) -> dict[str, List[bytes]]: ...
|
||||
|
||||
class _Environ(Protocol):
|
||||
def __getitem__(self, __k: str) -> str: ...
|
||||
def keys(self) -> Iterable[str]: ...
|
||||
|
||||
def parse_header(line: str) -> tuple[str, dict[str, str]]: ...
|
||||
def test(environ: _Environ = ...) -> None: ...
|
||||
def print_environ(environ: _Environ = ...) -> None: ...
|
||||
def print_form(form: dict[str, Any]) -> None: ...
|
||||
def print_directory() -> None: ...
|
||||
def print_environ_usage() -> None: ...
|
||||
def escape(s: AnyStr, quote: bool = ...) -> AnyStr: ...
|
||||
|
||||
class MiniFieldStorage:
|
||||
# The first five "Any" attributes here are always None, but mypy doesn't support that
|
||||
filename: Any
|
||||
list: Any
|
||||
type: Any
|
||||
file: Optional[IO[bytes]]
|
||||
type_options: dict[Any, Any]
|
||||
disposition: Any
|
||||
disposition_options: dict[Any, Any]
|
||||
headers: dict[Any, Any]
|
||||
name: Any
|
||||
value: Any
|
||||
def __init__(self, name: Any, value: Any) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
|
||||
class FieldStorage(object):
|
||||
FieldStorageClass: Optional[_type]
|
||||
keep_blank_values: int
|
||||
strict_parsing: int
|
||||
qs_on_post: Optional[str]
|
||||
headers: Mapping[str, str]
|
||||
fp: IO[bytes]
|
||||
encoding: str
|
||||
errors: str
|
||||
outerboundary: bytes
|
||||
bytes_read: int
|
||||
limit: Optional[int]
|
||||
disposition: str
|
||||
disposition_options: dict[str, str]
|
||||
filename: Optional[str]
|
||||
file: Optional[IO[bytes]]
|
||||
type: str
|
||||
type_options: dict[str, str]
|
||||
innerboundary: bytes
|
||||
length: int
|
||||
done: int
|
||||
list: Optional[List[Any]]
|
||||
value: Union[None, bytes, List[Any]]
|
||||
def __init__(
|
||||
self,
|
||||
fp: IO[Any] = ...,
|
||||
headers: Mapping[str, str] = ...,
|
||||
outerboundary: bytes = ...,
|
||||
environ: SupportsGetItem[str, str] = ...,
|
||||
keep_blank_values: int = ...,
|
||||
strict_parsing: int = ...,
|
||||
) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def __iter__(self) -> Iterator[str]: ...
|
||||
def __getitem__(self, key: str) -> Any: ...
|
||||
def getvalue(self, key: str, default: Any = ...) -> Any: ...
|
||||
def getfirst(self, key: str, default: Any = ...) -> Any: ...
|
||||
def getlist(self, key: str) -> List[Any]: ...
|
||||
def keys(self) -> List[str]: ...
|
||||
def has_key(self, key: str) -> bool: ...
|
||||
def __contains__(self, key: str) -> bool: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __nonzero__(self) -> bool: ...
|
||||
# In Python 2 it always returns bytes and ignores the "binary" flag
|
||||
def make_file(self, binary: Any = ...) -> IO[bytes]: ...
|
||||
|
||||
class FormContentDict(UserDict[str, List[str]]):
|
||||
query_string: str
|
||||
def __init__(self, environ: Mapping[str, str] = ..., keep_blank_values: int = ..., strict_parsing: int = ...) -> None: ...
|
||||
|
||||
class SvFormContentDict(FormContentDict):
|
||||
def getlist(self, key: Any) -> Any: ...
|
||||
|
||||
class InterpFormContentDict(SvFormContentDict): ...
|
||||
|
||||
class FormContent(FormContentDict):
|
||||
# TODO this should have
|
||||
# def values(self, key: Any) -> Any: ...
|
||||
# but this is incompatible with the supertype, and adding '# type: ignore' triggers
|
||||
# a parse error in pytype (https://github.com/google/pytype/issues/53)
|
||||
def indexed_value(self, key: Any, location: int) -> Any: ...
|
||||
def value(self, key: Any) -> Any: ...
|
||||
def length(self, key: Any) -> int: ...
|
||||
def stripped(self, key: Any) -> Any: ...
|
||||
def pars(self) -> dict[Any, Any]: ...
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user