mirror of https://github.com/astral-sh/ruff
[red-knot] Vendor typeshed's stdlib (#11340)
This PR vendors typeshed! - The first commit vendors the stdlib directory from typeshed into a new crates/red_knot/vendored_typeshed directory. - The second commit adjusts various linting config files to make sure that the vendored code is excluded from typo checks, formatting checks, etc. - The LICENSE and README.md files are also vendored, but all other directories and files (stubs, scripts, tests, test_cases, etc.) are excluded. We should have no need for them (except possibly stubs/, discussed in more depth below). - Similar to the way pyright has a commit.txt file in its vendored copy of typeshed, to indicate which typeshed commit the vendored code corresponds to, I've also added a crates/red_knot/vendored_typeshed/source_commit.txt file in the third commit of this PR. One open question is: should we vendor the stdlib and stubs directories, or just the stdlib directory? The stubs/ directory contains stubs for 162 third-party packages outside the stdlib. Mypy and typeshed_client1 only vendor the stdlib directory; pyright and pyre vendor both the stdlib and stubs directories; pytype vendors the entire typeshed repo (scripts/, tests/ and all). In this PR, I've chosen to copy mypy and typeshed_client. Unlike vendoring the stdlib, which is unavoidable if we want to do typechecking of the stdlib, it's not strictly necessary to vendor the stubs directory: each subdirectory in stubs is published to PyPI as a standalone stubs distribution that can be (uv)-pip-installed into a virtual environment. It might be useful for our users if we vendored those stubs anyway, but there are costs as well as benefits to doing so (apart from just the sheer amount of vendored code in the ruff repository), so I'd rather consider it separately.
This commit is contained in:
parent
e2fe177c6b
commit
c80c1712f0
|
|
@ -2,6 +2,7 @@ fail_fast: true
|
||||||
|
|
||||||
exclude: |
|
exclude: |
|
||||||
(?x)^(
|
(?x)^(
|
||||||
|
crates/red_knot/vendor/.*|
|
||||||
crates/ruff_linter/resources/.*|
|
crates/ruff_linter/resources/.*|
|
||||||
crates/ruff_linter/src/rules/.*/snapshots/.*|
|
crates/ruff_linter/src/rules/.*/snapshots/.*|
|
||||||
crates/ruff/resources/.*|
|
crates/ruff/resources/.*|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[files]
|
[files]
|
||||||
# https://github.com/crate-ci/typos/issues/868
|
# https://github.com/crate-ci/typos/issues/868
|
||||||
extend-exclude = ["**/resources/**/*", "**/snapshots/**/*"]
|
extend-exclude = ["crates/red_knot/vendor/**/*", "**/resources/**/*", "**/snapshots/**/*"]
|
||||||
|
|
||||||
[default.extend-words]
|
[default.extend-words]
|
||||||
"arange" = "arange" # e.g. `numpy.arange`
|
"arange" = "arange" # e.g. `numpy.arange`
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Red Knot
|
||||||
|
|
||||||
|
The Red Knot crate contains code working towards multifile analysis, type inference and, ultimately, type-checking. It's very much a work in progress for now.
|
||||||
|
|
||||||
|
## Vendored types for the stdlib
|
||||||
|
|
||||||
|
Red Knot vendors [typeshed](https://github.com/python/typeshed)'s stubs for the standard library. The vendored stubs can be found in `crates/red_knot/vendor/typeshed`. The file `crates/red_knot/vendor/typeshed/source_commit.txt` tells you the typeshed commit that our vendored stdlib stubs currently correspond to.
|
||||||
|
|
||||||
|
Updating the vendored stubs is currently done manually. On a Unix machine, follow the following steps (if you have a typeshed clone in a `typeshed` directory, and a Ruff clone in a `ruff` directory):
|
||||||
|
|
||||||
|
```shell
|
||||||
|
rm -rf ruff/crates/red_knot/vendor/typeshed
|
||||||
|
mkdir ruff/crates/red_knot/vendor/typeshed
|
||||||
|
cp typeshed/README.md ruff/crates/red_knot/vendor/typeshed
|
||||||
|
cp typeshed/LICENSE ruff/crates/red_knot/vendor/typeshed
|
||||||
|
cp -r typeshed/stdlib ruff/crates/red_knot/vendor/typeshed/stdlib
|
||||||
|
git -C typeshed rev-parse HEAD > ruff/crates/red_knot/vendor/typeshed/source_commit.txt
|
||||||
|
```
|
||||||
|
|
@ -0,0 +1,237 @@
|
||||||
|
The "typeshed" project is licensed under the terms of the Apache license, as
|
||||||
|
reproduced below.
|
||||||
|
|
||||||
|
= = = = =
|
||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright {yyyy} {name of copyright owner}
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
= = = = =
|
||||||
|
|
||||||
|
Parts of typeshed are licensed under different licenses (like the MIT
|
||||||
|
license), reproduced below.
|
||||||
|
|
||||||
|
= = = = =
|
||||||
|
|
||||||
|
The MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2015 Jukka Lehtosalo and contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
to deal in the Software without restriction, including without limitation
|
||||||
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
= = = = =
|
||||||
|
|
@ -0,0 +1,124 @@
|
||||||
|
# typeshed
|
||||||
|
|
||||||
|
[](https://github.com/python/typeshed/actions/workflows/tests.yml)
|
||||||
|
[](https://gitter.im/python/typing?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
[](https://github.com/python/typeshed/blob/main/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.
|
||||||
|
|
||||||
|
This data can e.g. be used for static analysis, type checking, type inference,
|
||||||
|
and autocompletion.
|
||||||
|
|
||||||
|
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.**
|
||||||
|
|
||||||
|
Further documentation on stub files, typeshed, and Python's typing system in
|
||||||
|
general, can also be found at https://typing.readthedocs.io/en/latest/.
|
||||||
|
|
||||||
|
Typeshed supports Python versions 3.8 and up.
|
||||||
|
|
||||||
|
## Using
|
||||||
|
|
||||||
|
If you're just using a type checker ([mypy](https://github.com/python/mypy/),
|
||||||
|
[pyright](https://github.com/microsoft/pyright),
|
||||||
|
[pytype](https://github.com/google/pytype/), PyCharm, ...), as opposed to
|
||||||
|
developing it, you don't need to interact with the typeshed repo at
|
||||||
|
all: a copy of standard library part of typeshed is bundled with type checkers.
|
||||||
|
And type stubs for third party packages and modules you are using can
|
||||||
|
be installed from PyPI. For example, if you are using `html5lib` and `requests`,
|
||||||
|
you can install the type stubs using
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ pip install types-html5lib types-requests
|
||||||
|
```
|
||||||
|
|
||||||
|
These PyPI packages follow [PEP 561](http://www.python.org/dev/peps/pep-0561/)
|
||||||
|
and are automatically released (up to once a day) by
|
||||||
|
[typeshed internal machinery](https://github.com/typeshed-internal/stub_uploader).
|
||||||
|
|
||||||
|
Type checkers should be able to use these stub packages when installed. For more
|
||||||
|
details, see the documentation for your type checker.
|
||||||
|
|
||||||
|
### Package versioning for third-party stubs
|
||||||
|
|
||||||
|
Version numbers of third-party stub packages consist of at least four parts.
|
||||||
|
All parts of the stub version, except for the last part, correspond to the
|
||||||
|
version of the runtime package being stubbed. For example, if the `types-foo`
|
||||||
|
package has version `1.2.0.20240309`, this guarantees that the `types-foo` package
|
||||||
|
contains stubs targeted against `foo==1.2.*` and tested against the latest
|
||||||
|
version of `foo` matching that specifier. In this example, the final element
|
||||||
|
of the version number (20240309) indicates that the stub package was pushed on
|
||||||
|
March 9, 2024.
|
||||||
|
|
||||||
|
At typeshed, we try to keep breaking changes to a minimum. However, due to the
|
||||||
|
nature of stubs, any version bump can introduce changes that might make your
|
||||||
|
code fail to type check.
|
||||||
|
|
||||||
|
There are several strategies available for specifying the version of a stubs
|
||||||
|
package you're using, each with its own tradeoffs:
|
||||||
|
|
||||||
|
1. Use the same bounds that you use for the package being stubbed. For example,
|
||||||
|
if you use `requests>=2.30.0,<2.32`, you can use
|
||||||
|
`types-requests>=2.30.0,<2.32`. This ensures that the stubs are compatible
|
||||||
|
with the package you are using, but it carries a small risk of breaking
|
||||||
|
type checking due to changes in the stubs.
|
||||||
|
|
||||||
|
Another risk of this strategy is that stubs often lag behind
|
||||||
|
the package being stubbed. You might want to force the package being stubbed
|
||||||
|
to a certain minimum version because it fixes a critical bug, but if
|
||||||
|
correspondingly updated stubs have not been released, your type
|
||||||
|
checking results may not be fully accurate.
|
||||||
|
2. Pin the stubs to a known good version and update the pin from time to time
|
||||||
|
(either manually, or using a tool such as dependabot or renovate).
|
||||||
|
|
||||||
|
For example, if you use `types-requests==2.31.0.1`, you can have confidence
|
||||||
|
that upgrading dependencies will not break type checking. However, you will
|
||||||
|
miss out on improvements in the stubs that could potentially improve type
|
||||||
|
checking until you update the pin. This strategy also has the risk that the
|
||||||
|
stubs you are using might become incompatible with the package being stubbed.
|
||||||
|
3. Don't pin the stubs. This is the option that demands the least work from
|
||||||
|
you when it comes to updating version pins, and has the advantage that you
|
||||||
|
will automatically benefit from improved stubs whenever a new version of the
|
||||||
|
stubs package is released. However, it carries the risk that the stubs
|
||||||
|
become incompatible with the package being stubbed.
|
||||||
|
|
||||||
|
For example, if a new major version of the package is released, there's a
|
||||||
|
chance the stubs might be updated to reflect the new version of the runtime
|
||||||
|
package before you update the package being stubbed.
|
||||||
|
|
||||||
|
You can also switch between the different strategies as needed. For example,
|
||||||
|
you could default to strategy (1), but fall back to strategy (2) when
|
||||||
|
a problem arises that can't easily be fixed.
|
||||||
|
|
||||||
|
### The `_typeshed` package
|
||||||
|
|
||||||
|
typeshed includes a package `_typeshed` as part of the standard library.
|
||||||
|
This package and its submodules contain utility types, but are not
|
||||||
|
available at runtime. For more information about how to use this package,
|
||||||
|
[see the `stdlib/_typeshed` directory](https://github.com/python/typeshed/tree/main/stdlib/_typeshed).
|
||||||
|
|
||||||
|
## Discussion
|
||||||
|
|
||||||
|
If you've run into behavior in the type checker that suggests the type
|
||||||
|
stubs for a given library are incorrect or incomplete,
|
||||||
|
we want to hear from you!
|
||||||
|
|
||||||
|
Our main forum for discussion is the project's [GitHub issue
|
||||||
|
tracker](https://github.com/python/typeshed/issues). This is the right
|
||||||
|
place to start a discussion of any of the above or most any other
|
||||||
|
topic concerning the project.
|
||||||
|
|
||||||
|
If you have general questions about typing with Python, or you need
|
||||||
|
a review of your type annotations or stubs outside of typeshed, head over to
|
||||||
|
[our discussion forum](https://github.com/python/typing/discussions).
|
||||||
|
For less formal discussion, try the typing chat room on
|
||||||
|
[gitter.im](https://gitter.im/python/typing). Some typeshed maintainers
|
||||||
|
are almost always present; feel free to find us there and we're happy
|
||||||
|
to chat. Substantive technical discussion will be directed to the
|
||||||
|
issue tracker.
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
2d33fe212221a05661c0db5215a91cf3d7b7f072
|
||||||
|
|
@ -0,0 +1,309 @@
|
||||||
|
# The structure of this file is as follows:
|
||||||
|
# - Blank lines and comments starting with `#` are ignored.
|
||||||
|
# - Lines contain the name of a module, followed by a colon,
|
||||||
|
# a space, and a version range (for example: `symbol: 3.0-3.9`).
|
||||||
|
#
|
||||||
|
# Version ranges may be of the form "X.Y-A.B" or "X.Y-". The
|
||||||
|
# first form means that a module was introduced in version X.Y and last
|
||||||
|
# available in version A.B. The second form means that the module was
|
||||||
|
# introduced in version X.Y and is still available in the latest
|
||||||
|
# version of Python.
|
||||||
|
#
|
||||||
|
# If a submodule is not listed separately, it has the same lifetime as
|
||||||
|
# its parent module.
|
||||||
|
#
|
||||||
|
# Python versions before 3.0 are ignored, so any module that was already
|
||||||
|
# present in 3.0 will have "3.0" as its minimum version. Version ranges
|
||||||
|
# for unsupported versions of Python 3 are generally accurate but we do
|
||||||
|
# not guarantee their correctness.
|
||||||
|
|
||||||
|
__future__: 3.0-
|
||||||
|
__main__: 3.0-
|
||||||
|
_ast: 3.0-
|
||||||
|
_bisect: 3.0-
|
||||||
|
_bootlocale: 3.4-3.9
|
||||||
|
_codecs: 3.0-
|
||||||
|
_collections_abc: 3.3-
|
||||||
|
_compat_pickle: 3.1-
|
||||||
|
_compression: 3.5-
|
||||||
|
_csv: 3.0-
|
||||||
|
_ctypes: 3.0-
|
||||||
|
_curses: 3.0-
|
||||||
|
_decimal: 3.3-
|
||||||
|
_dummy_thread: 3.0-3.8
|
||||||
|
_dummy_threading: 3.0-3.8
|
||||||
|
_heapq: 3.0-
|
||||||
|
_imp: 3.0-
|
||||||
|
_json: 3.0-
|
||||||
|
_locale: 3.0-
|
||||||
|
_lsprof: 3.0-
|
||||||
|
_markupbase: 3.0-
|
||||||
|
_msi: 3.0-
|
||||||
|
_operator: 3.4-
|
||||||
|
_osx_support: 3.0-
|
||||||
|
_posixsubprocess: 3.2-
|
||||||
|
_py_abc: 3.7-
|
||||||
|
_pydecimal: 3.5-
|
||||||
|
_random: 3.0-
|
||||||
|
_sitebuiltins: 3.4-
|
||||||
|
_socket: 3.0- # present in 3.0 at runtime, but not in typeshed
|
||||||
|
_stat: 3.4-
|
||||||
|
_thread: 3.0-
|
||||||
|
_threading_local: 3.0-
|
||||||
|
_tkinter: 3.0-
|
||||||
|
_tracemalloc: 3.4-
|
||||||
|
_typeshed: 3.0- # not present at runtime, only for type checking
|
||||||
|
_warnings: 3.0-
|
||||||
|
_weakref: 3.0-
|
||||||
|
_weakrefset: 3.0-
|
||||||
|
_winapi: 3.3-
|
||||||
|
abc: 3.0-
|
||||||
|
aifc: 3.0-3.12
|
||||||
|
antigravity: 3.0-
|
||||||
|
argparse: 3.0-
|
||||||
|
array: 3.0-
|
||||||
|
ast: 3.0-
|
||||||
|
asynchat: 3.0-3.11
|
||||||
|
asyncio: 3.4-
|
||||||
|
asyncio.mixins: 3.10-
|
||||||
|
asyncio.exceptions: 3.8-
|
||||||
|
asyncio.format_helpers: 3.7-
|
||||||
|
asyncio.runners: 3.7-
|
||||||
|
asyncio.staggered: 3.8-
|
||||||
|
asyncio.taskgroups: 3.11-
|
||||||
|
asyncio.threads: 3.9-
|
||||||
|
asyncio.timeouts: 3.11-
|
||||||
|
asyncio.trsock: 3.8-
|
||||||
|
asyncore: 3.0-3.11
|
||||||
|
atexit: 3.0-
|
||||||
|
audioop: 3.0-3.12
|
||||||
|
base64: 3.0-
|
||||||
|
bdb: 3.0-
|
||||||
|
binascii: 3.0-
|
||||||
|
binhex: 3.0-3.10
|
||||||
|
bisect: 3.0-
|
||||||
|
builtins: 3.0-
|
||||||
|
bz2: 3.0-
|
||||||
|
cProfile: 3.0-
|
||||||
|
calendar: 3.0-
|
||||||
|
cgi: 3.0-3.12
|
||||||
|
cgitb: 3.0-3.12
|
||||||
|
chunk: 3.0-3.12
|
||||||
|
cmath: 3.0-
|
||||||
|
cmd: 3.0-
|
||||||
|
code: 3.0-
|
||||||
|
codecs: 3.0-
|
||||||
|
codeop: 3.0-
|
||||||
|
collections: 3.0-
|
||||||
|
collections.abc: 3.3-
|
||||||
|
colorsys: 3.0-
|
||||||
|
compileall: 3.0-
|
||||||
|
concurrent: 3.2-
|
||||||
|
configparser: 3.0-
|
||||||
|
contextlib: 3.0-
|
||||||
|
contextvars: 3.7-
|
||||||
|
copy: 3.0-
|
||||||
|
copyreg: 3.0-
|
||||||
|
crypt: 3.0-3.12
|
||||||
|
csv: 3.0-
|
||||||
|
ctypes: 3.0-
|
||||||
|
curses: 3.0-
|
||||||
|
dataclasses: 3.7-
|
||||||
|
datetime: 3.0-
|
||||||
|
dbm: 3.0-
|
||||||
|
decimal: 3.0-
|
||||||
|
difflib: 3.0-
|
||||||
|
dis: 3.0-
|
||||||
|
distutils: 3.0-3.11
|
||||||
|
distutils.command.bdist_msi: 3.0-3.10
|
||||||
|
distutils.command.bdist_wininst: 3.0-3.9
|
||||||
|
doctest: 3.0-
|
||||||
|
dummy_threading: 3.0-3.8
|
||||||
|
email: 3.0-
|
||||||
|
encodings: 3.0-
|
||||||
|
ensurepip: 3.0-
|
||||||
|
enum: 3.4-
|
||||||
|
errno: 3.0-
|
||||||
|
faulthandler: 3.3-
|
||||||
|
fcntl: 3.0-
|
||||||
|
filecmp: 3.0-
|
||||||
|
fileinput: 3.0-
|
||||||
|
fnmatch: 3.0-
|
||||||
|
formatter: 3.0-3.9
|
||||||
|
fractions: 3.0-
|
||||||
|
ftplib: 3.0-
|
||||||
|
functools: 3.0-
|
||||||
|
gc: 3.0-
|
||||||
|
genericpath: 3.0-
|
||||||
|
getopt: 3.0-
|
||||||
|
getpass: 3.0-
|
||||||
|
gettext: 3.0-
|
||||||
|
glob: 3.0-
|
||||||
|
graphlib: 3.9-
|
||||||
|
grp: 3.0-
|
||||||
|
gzip: 3.0-
|
||||||
|
hashlib: 3.0-
|
||||||
|
heapq: 3.0-
|
||||||
|
hmac: 3.0-
|
||||||
|
html: 3.0-
|
||||||
|
http: 3.0-
|
||||||
|
imaplib: 3.0-
|
||||||
|
imghdr: 3.0-3.12
|
||||||
|
imp: 3.0-3.11
|
||||||
|
importlib: 3.0-
|
||||||
|
importlib._abc: 3.10-
|
||||||
|
importlib.metadata: 3.8-
|
||||||
|
importlib.metadata._meta: 3.10-
|
||||||
|
importlib.readers: 3.10-
|
||||||
|
importlib.resources: 3.7-
|
||||||
|
importlib.resources.abc: 3.11-
|
||||||
|
importlib.resources.readers: 3.11-
|
||||||
|
importlib.resources.simple: 3.11-
|
||||||
|
importlib.simple: 3.11-
|
||||||
|
inspect: 3.0-
|
||||||
|
io: 3.0-
|
||||||
|
ipaddress: 3.3-
|
||||||
|
itertools: 3.0-
|
||||||
|
json: 3.0-
|
||||||
|
keyword: 3.0-
|
||||||
|
lib2to3: 3.0-
|
||||||
|
linecache: 3.0-
|
||||||
|
locale: 3.0-
|
||||||
|
logging: 3.0-
|
||||||
|
lzma: 3.3-
|
||||||
|
mailbox: 3.0-
|
||||||
|
mailcap: 3.0-3.12
|
||||||
|
marshal: 3.0-
|
||||||
|
math: 3.0-
|
||||||
|
mimetypes: 3.0-
|
||||||
|
mmap: 3.0-
|
||||||
|
modulefinder: 3.0-
|
||||||
|
msilib: 3.0-3.12
|
||||||
|
msvcrt: 3.0-
|
||||||
|
multiprocessing: 3.0-
|
||||||
|
multiprocessing.resource_tracker: 3.8-
|
||||||
|
multiprocessing.shared_memory: 3.8-
|
||||||
|
netrc: 3.0-
|
||||||
|
nis: 3.0-3.12
|
||||||
|
nntplib: 3.0-3.12
|
||||||
|
nt: 3.0-
|
||||||
|
ntpath: 3.0-
|
||||||
|
nturl2path: 3.0-
|
||||||
|
numbers: 3.0-
|
||||||
|
opcode: 3.0-
|
||||||
|
operator: 3.0-
|
||||||
|
optparse: 3.0-
|
||||||
|
os: 3.0-
|
||||||
|
ossaudiodev: 3.0-3.12
|
||||||
|
parser: 3.0-3.9
|
||||||
|
pathlib: 3.4-
|
||||||
|
pdb: 3.0-
|
||||||
|
pickle: 3.0-
|
||||||
|
pickletools: 3.0-
|
||||||
|
pipes: 3.0-3.12
|
||||||
|
pkgutil: 3.0-
|
||||||
|
platform: 3.0-
|
||||||
|
plistlib: 3.0-
|
||||||
|
poplib: 3.0-
|
||||||
|
posix: 3.0-
|
||||||
|
posixpath: 3.0-
|
||||||
|
pprint: 3.0-
|
||||||
|
profile: 3.0-
|
||||||
|
pstats: 3.0-
|
||||||
|
pty: 3.0-
|
||||||
|
pwd: 3.0-
|
||||||
|
py_compile: 3.0-
|
||||||
|
pyclbr: 3.0-
|
||||||
|
pydoc: 3.0-
|
||||||
|
pydoc_data: 3.0-
|
||||||
|
pyexpat: 3.0-
|
||||||
|
queue: 3.0-
|
||||||
|
quopri: 3.0-
|
||||||
|
random: 3.0-
|
||||||
|
re: 3.0-
|
||||||
|
readline: 3.0-
|
||||||
|
reprlib: 3.0-
|
||||||
|
resource: 3.0-
|
||||||
|
rlcompleter: 3.0-
|
||||||
|
runpy: 3.0-
|
||||||
|
sched: 3.0-
|
||||||
|
secrets: 3.6-
|
||||||
|
select: 3.0-
|
||||||
|
selectors: 3.4-
|
||||||
|
shelve: 3.0-
|
||||||
|
shlex: 3.0-
|
||||||
|
shutil: 3.0-
|
||||||
|
signal: 3.0-
|
||||||
|
site: 3.0-
|
||||||
|
smtpd: 3.0-3.11
|
||||||
|
smtplib: 3.0-
|
||||||
|
sndhdr: 3.0-3.12
|
||||||
|
socket: 3.0-
|
||||||
|
socketserver: 3.0-
|
||||||
|
spwd: 3.0-3.12
|
||||||
|
sqlite3: 3.0-
|
||||||
|
sre_compile: 3.0-
|
||||||
|
sre_constants: 3.0-
|
||||||
|
sre_parse: 3.0-
|
||||||
|
ssl: 3.0-
|
||||||
|
stat: 3.0-
|
||||||
|
statistics: 3.4-
|
||||||
|
string: 3.0-
|
||||||
|
stringprep: 3.0-
|
||||||
|
struct: 3.0-
|
||||||
|
subprocess: 3.0-
|
||||||
|
sunau: 3.0-3.12
|
||||||
|
symbol: 3.0-3.9
|
||||||
|
symtable: 3.0-
|
||||||
|
sys: 3.0-
|
||||||
|
sys._monitoring: 3.12- # Doesn't actually exist. See comments in the stub.
|
||||||
|
sysconfig: 3.0-
|
||||||
|
syslog: 3.0-
|
||||||
|
tabnanny: 3.0-
|
||||||
|
tarfile: 3.0-
|
||||||
|
telnetlib: 3.0-3.12
|
||||||
|
tempfile: 3.0-
|
||||||
|
termios: 3.0-
|
||||||
|
textwrap: 3.0-
|
||||||
|
this: 3.0-
|
||||||
|
threading: 3.0-
|
||||||
|
time: 3.0-
|
||||||
|
timeit: 3.0-
|
||||||
|
tkinter: 3.0-
|
||||||
|
token: 3.0-
|
||||||
|
tokenize: 3.0-
|
||||||
|
tomllib: 3.11-
|
||||||
|
trace: 3.0-
|
||||||
|
traceback: 3.0-
|
||||||
|
tracemalloc: 3.4-
|
||||||
|
tty: 3.0-
|
||||||
|
turtle: 3.0-
|
||||||
|
types: 3.0-
|
||||||
|
typing: 3.5-
|
||||||
|
typing_extensions: 3.0-
|
||||||
|
unicodedata: 3.0-
|
||||||
|
unittest: 3.0-
|
||||||
|
unittest._log: 3.9-
|
||||||
|
unittest.async_case: 3.8-
|
||||||
|
urllib: 3.0-
|
||||||
|
uu: 3.0-3.12
|
||||||
|
uuid: 3.0-
|
||||||
|
venv: 3.3-
|
||||||
|
warnings: 3.0-
|
||||||
|
wave: 3.0-
|
||||||
|
weakref: 3.0-
|
||||||
|
webbrowser: 3.0-
|
||||||
|
winreg: 3.0-
|
||||||
|
winsound: 3.0-
|
||||||
|
wsgiref: 3.0-
|
||||||
|
wsgiref.types: 3.11-
|
||||||
|
xdrlib: 3.0-3.12
|
||||||
|
xml: 3.0-
|
||||||
|
xmlrpc: 3.0-
|
||||||
|
xxlimited: 3.2-
|
||||||
|
zipapp: 3.5-
|
||||||
|
zipfile: 3.0-
|
||||||
|
zipfile._path: 3.12-
|
||||||
|
zipimport: 3.0-
|
||||||
|
zlib: 3.0-
|
||||||
|
zoneinfo: 3.9-
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
from typing_extensions import TypeAlias
|
||||||
|
|
||||||
|
_VersionInfo: TypeAlias = tuple[int, int, int, str, int]
|
||||||
|
|
||||||
|
class _Feature:
|
||||||
|
def __init__(self, optionalRelease: _VersionInfo, mandatoryRelease: _VersionInfo | None, compiler_flag: int) -> None: ...
|
||||||
|
def getOptionalRelease(self) -> _VersionInfo: ...
|
||||||
|
def getMandatoryRelease(self) -> _VersionInfo | None: ...
|
||||||
|
compiler_flag: int
|
||||||
|
|
||||||
|
absolute_import: _Feature
|
||||||
|
division: _Feature
|
||||||
|
generators: _Feature
|
||||||
|
nested_scopes: _Feature
|
||||||
|
print_function: _Feature
|
||||||
|
unicode_literals: _Feature
|
||||||
|
with_statement: _Feature
|
||||||
|
barry_as_FLUFL: _Feature
|
||||||
|
generator_stop: _Feature
|
||||||
|
annotations: _Feature
|
||||||
|
|
||||||
|
all_feature_names: list[str] # undocumented
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"all_feature_names",
|
||||||
|
"absolute_import",
|
||||||
|
"division",
|
||||||
|
"generators",
|
||||||
|
"nested_scopes",
|
||||||
|
"print_function",
|
||||||
|
"unicode_literals",
|
||||||
|
"with_statement",
|
||||||
|
"barry_as_FLUFL",
|
||||||
|
"generator_stop",
|
||||||
|
"annotations",
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
def __getattr__(name: str) -> Any: ...
|
||||||
|
|
@ -0,0 +1,591 @@
|
||||||
|
import sys
|
||||||
|
import typing_extensions
|
||||||
|
from typing import Any, ClassVar, Literal
|
||||||
|
|
||||||
|
PyCF_ONLY_AST: Literal[1024]
|
||||||
|
PyCF_TYPE_COMMENTS: Literal[4096]
|
||||||
|
PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192]
|
||||||
|
|
||||||
|
# Alias used for fields that must always be valid identifiers
|
||||||
|
# A string `x` counts as a valid identifier if both the following are True
|
||||||
|
# (1) `x.isidentifier()` evaluates to `True`
|
||||||
|
# (2) `keyword.iskeyword(x)` evaluates to `False`
|
||||||
|
_Identifier: typing_extensions.TypeAlias = str
|
||||||
|
|
||||||
|
class AST:
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ()
|
||||||
|
_attributes: ClassVar[tuple[str, ...]]
|
||||||
|
_fields: ClassVar[tuple[str, ...]]
|
||||||
|
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||||
|
# TODO: Not all nodes have all of the following attributes
|
||||||
|
lineno: int
|
||||||
|
col_offset: int
|
||||||
|
end_lineno: int | None
|
||||||
|
end_col_offset: int | None
|
||||||
|
type_comment: str | None
|
||||||
|
|
||||||
|
class mod(AST): ...
|
||||||
|
class type_ignore(AST): ...
|
||||||
|
|
||||||
|
class TypeIgnore(type_ignore):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("lineno", "tag")
|
||||||
|
tag: str
|
||||||
|
|
||||||
|
class FunctionType(mod):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("argtypes", "returns")
|
||||||
|
argtypes: list[expr]
|
||||||
|
returns: expr
|
||||||
|
|
||||||
|
class Module(mod):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("body", "type_ignores")
|
||||||
|
body: list[stmt]
|
||||||
|
type_ignores: list[TypeIgnore]
|
||||||
|
|
||||||
|
class Interactive(mod):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("body",)
|
||||||
|
body: list[stmt]
|
||||||
|
|
||||||
|
class Expression(mod):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("body",)
|
||||||
|
body: expr
|
||||||
|
|
||||||
|
class stmt(AST): ...
|
||||||
|
|
||||||
|
class FunctionDef(stmt):
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
__match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment", "type_params")
|
||||||
|
elif sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment")
|
||||||
|
name: _Identifier
|
||||||
|
args: arguments
|
||||||
|
body: list[stmt]
|
||||||
|
decorator_list: list[expr]
|
||||||
|
returns: expr | None
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
type_params: list[type_param]
|
||||||
|
|
||||||
|
class AsyncFunctionDef(stmt):
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
__match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment", "type_params")
|
||||||
|
elif sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment")
|
||||||
|
name: _Identifier
|
||||||
|
args: arguments
|
||||||
|
body: list[stmt]
|
||||||
|
decorator_list: list[expr]
|
||||||
|
returns: expr | None
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
type_params: list[type_param]
|
||||||
|
|
||||||
|
class ClassDef(stmt):
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
__match_args__ = ("name", "bases", "keywords", "body", "decorator_list", "type_params")
|
||||||
|
elif sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("name", "bases", "keywords", "body", "decorator_list")
|
||||||
|
name: _Identifier
|
||||||
|
bases: list[expr]
|
||||||
|
keywords: list[keyword]
|
||||||
|
body: list[stmt]
|
||||||
|
decorator_list: list[expr]
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
type_params: list[type_param]
|
||||||
|
|
||||||
|
class Return(stmt):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("value",)
|
||||||
|
value: expr | None
|
||||||
|
|
||||||
|
class Delete(stmt):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("targets",)
|
||||||
|
targets: list[expr]
|
||||||
|
|
||||||
|
class Assign(stmt):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("targets", "value", "type_comment")
|
||||||
|
targets: list[expr]
|
||||||
|
value: expr
|
||||||
|
|
||||||
|
class AugAssign(stmt):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("target", "op", "value")
|
||||||
|
target: Name | Attribute | Subscript
|
||||||
|
op: operator
|
||||||
|
value: expr
|
||||||
|
|
||||||
|
class AnnAssign(stmt):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("target", "annotation", "value", "simple")
|
||||||
|
target: Name | Attribute | Subscript
|
||||||
|
annotation: expr
|
||||||
|
value: expr | None
|
||||||
|
simple: int
|
||||||
|
|
||||||
|
class For(stmt):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("target", "iter", "body", "orelse", "type_comment")
|
||||||
|
target: expr
|
||||||
|
iter: expr
|
||||||
|
body: list[stmt]
|
||||||
|
orelse: list[stmt]
|
||||||
|
|
||||||
|
class AsyncFor(stmt):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("target", "iter", "body", "orelse", "type_comment")
|
||||||
|
target: expr
|
||||||
|
iter: expr
|
||||||
|
body: list[stmt]
|
||||||
|
orelse: list[stmt]
|
||||||
|
|
||||||
|
class While(stmt):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("test", "body", "orelse")
|
||||||
|
test: expr
|
||||||
|
body: list[stmt]
|
||||||
|
orelse: list[stmt]
|
||||||
|
|
||||||
|
class If(stmt):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("test", "body", "orelse")
|
||||||
|
test: expr
|
||||||
|
body: list[stmt]
|
||||||
|
orelse: list[stmt]
|
||||||
|
|
||||||
|
class With(stmt):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("items", "body", "type_comment")
|
||||||
|
items: list[withitem]
|
||||||
|
body: list[stmt]
|
||||||
|
|
||||||
|
class AsyncWith(stmt):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("items", "body", "type_comment")
|
||||||
|
items: list[withitem]
|
||||||
|
body: list[stmt]
|
||||||
|
|
||||||
|
class Raise(stmt):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("exc", "cause")
|
||||||
|
exc: expr | None
|
||||||
|
cause: expr | None
|
||||||
|
|
||||||
|
class Try(stmt):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("body", "handlers", "orelse", "finalbody")
|
||||||
|
body: list[stmt]
|
||||||
|
handlers: list[ExceptHandler]
|
||||||
|
orelse: list[stmt]
|
||||||
|
finalbody: list[stmt]
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
class TryStar(stmt):
|
||||||
|
__match_args__ = ("body", "handlers", "orelse", "finalbody")
|
||||||
|
body: list[stmt]
|
||||||
|
handlers: list[ExceptHandler]
|
||||||
|
orelse: list[stmt]
|
||||||
|
finalbody: list[stmt]
|
||||||
|
|
||||||
|
class Assert(stmt):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("test", "msg")
|
||||||
|
test: expr
|
||||||
|
msg: expr | None
|
||||||
|
|
||||||
|
class Import(stmt):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("names",)
|
||||||
|
names: list[alias]
|
||||||
|
|
||||||
|
class ImportFrom(stmt):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("module", "names", "level")
|
||||||
|
module: str | None
|
||||||
|
names: list[alias]
|
||||||
|
level: int
|
||||||
|
|
||||||
|
class Global(stmt):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("names",)
|
||||||
|
names: list[_Identifier]
|
||||||
|
|
||||||
|
class Nonlocal(stmt):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("names",)
|
||||||
|
names: list[_Identifier]
|
||||||
|
|
||||||
|
class Expr(stmt):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("value",)
|
||||||
|
value: expr
|
||||||
|
|
||||||
|
class Pass(stmt): ...
|
||||||
|
class Break(stmt): ...
|
||||||
|
class Continue(stmt): ...
|
||||||
|
class expr(AST): ...
|
||||||
|
|
||||||
|
class BoolOp(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("op", "values")
|
||||||
|
op: boolop
|
||||||
|
values: list[expr]
|
||||||
|
|
||||||
|
class BinOp(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("left", "op", "right")
|
||||||
|
left: expr
|
||||||
|
op: operator
|
||||||
|
right: expr
|
||||||
|
|
||||||
|
class UnaryOp(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("op", "operand")
|
||||||
|
op: unaryop
|
||||||
|
operand: expr
|
||||||
|
|
||||||
|
class Lambda(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("args", "body")
|
||||||
|
args: arguments
|
||||||
|
body: expr
|
||||||
|
|
||||||
|
class IfExp(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("test", "body", "orelse")
|
||||||
|
test: expr
|
||||||
|
body: expr
|
||||||
|
orelse: expr
|
||||||
|
|
||||||
|
class Dict(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("keys", "values")
|
||||||
|
keys: list[expr | None]
|
||||||
|
values: list[expr]
|
||||||
|
|
||||||
|
class Set(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("elts",)
|
||||||
|
elts: list[expr]
|
||||||
|
|
||||||
|
class ListComp(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("elt", "generators")
|
||||||
|
elt: expr
|
||||||
|
generators: list[comprehension]
|
||||||
|
|
||||||
|
class SetComp(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("elt", "generators")
|
||||||
|
elt: expr
|
||||||
|
generators: list[comprehension]
|
||||||
|
|
||||||
|
class DictComp(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("key", "value", "generators")
|
||||||
|
key: expr
|
||||||
|
value: expr
|
||||||
|
generators: list[comprehension]
|
||||||
|
|
||||||
|
class GeneratorExp(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("elt", "generators")
|
||||||
|
elt: expr
|
||||||
|
generators: list[comprehension]
|
||||||
|
|
||||||
|
class Await(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("value",)
|
||||||
|
value: expr
|
||||||
|
|
||||||
|
class Yield(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("value",)
|
||||||
|
value: expr | None
|
||||||
|
|
||||||
|
class YieldFrom(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("value",)
|
||||||
|
value: expr
|
||||||
|
|
||||||
|
class Compare(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("left", "ops", "comparators")
|
||||||
|
left: expr
|
||||||
|
ops: list[cmpop]
|
||||||
|
comparators: list[expr]
|
||||||
|
|
||||||
|
class Call(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("func", "args", "keywords")
|
||||||
|
func: expr
|
||||||
|
args: list[expr]
|
||||||
|
keywords: list[keyword]
|
||||||
|
|
||||||
|
class FormattedValue(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("value", "conversion", "format_spec")
|
||||||
|
value: expr
|
||||||
|
conversion: int
|
||||||
|
format_spec: expr | None
|
||||||
|
|
||||||
|
class JoinedStr(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("values",)
|
||||||
|
values: list[expr]
|
||||||
|
|
||||||
|
class Constant(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("value", "kind")
|
||||||
|
value: Any # None, str, bytes, bool, int, float, complex, Ellipsis
|
||||||
|
kind: str | None
|
||||||
|
# Aliases for value, for backwards compatibility
|
||||||
|
s: Any
|
||||||
|
n: int | float | complex
|
||||||
|
|
||||||
|
class NamedExpr(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("target", "value")
|
||||||
|
target: Name
|
||||||
|
value: expr
|
||||||
|
|
||||||
|
class Attribute(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("value", "attr", "ctx")
|
||||||
|
value: expr
|
||||||
|
attr: _Identifier
|
||||||
|
ctx: expr_context
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
_Slice: typing_extensions.TypeAlias = expr
|
||||||
|
else:
|
||||||
|
class slice(AST): ...
|
||||||
|
_Slice: typing_extensions.TypeAlias = slice
|
||||||
|
|
||||||
|
class Slice(_Slice):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("lower", "upper", "step")
|
||||||
|
lower: expr | None
|
||||||
|
upper: expr | None
|
||||||
|
step: expr | None
|
||||||
|
|
||||||
|
if sys.version_info < (3, 9):
|
||||||
|
class ExtSlice(slice):
|
||||||
|
dims: list[slice]
|
||||||
|
|
||||||
|
class Index(slice):
|
||||||
|
value: expr
|
||||||
|
|
||||||
|
class Subscript(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("value", "slice", "ctx")
|
||||||
|
value: expr
|
||||||
|
slice: _Slice
|
||||||
|
ctx: expr_context
|
||||||
|
|
||||||
|
class Starred(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("value", "ctx")
|
||||||
|
value: expr
|
||||||
|
ctx: expr_context
|
||||||
|
|
||||||
|
class Name(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("id", "ctx")
|
||||||
|
id: _Identifier
|
||||||
|
ctx: expr_context
|
||||||
|
|
||||||
|
class List(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("elts", "ctx")
|
||||||
|
elts: list[expr]
|
||||||
|
ctx: expr_context
|
||||||
|
|
||||||
|
class Tuple(expr):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("elts", "ctx")
|
||||||
|
elts: list[expr]
|
||||||
|
ctx: expr_context
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
dims: list[expr]
|
||||||
|
|
||||||
|
class expr_context(AST): ...
|
||||||
|
|
||||||
|
if sys.version_info < (3, 9):
|
||||||
|
class AugLoad(expr_context): ...
|
||||||
|
class AugStore(expr_context): ...
|
||||||
|
class Param(expr_context): ...
|
||||||
|
|
||||||
|
class Suite(mod):
|
||||||
|
body: list[stmt]
|
||||||
|
|
||||||
|
class Del(expr_context): ...
|
||||||
|
class Load(expr_context): ...
|
||||||
|
class Store(expr_context): ...
|
||||||
|
class boolop(AST): ...
|
||||||
|
class And(boolop): ...
|
||||||
|
class Or(boolop): ...
|
||||||
|
class operator(AST): ...
|
||||||
|
class Add(operator): ...
|
||||||
|
class BitAnd(operator): ...
|
||||||
|
class BitOr(operator): ...
|
||||||
|
class BitXor(operator): ...
|
||||||
|
class Div(operator): ...
|
||||||
|
class FloorDiv(operator): ...
|
||||||
|
class LShift(operator): ...
|
||||||
|
class Mod(operator): ...
|
||||||
|
class Mult(operator): ...
|
||||||
|
class MatMult(operator): ...
|
||||||
|
class Pow(operator): ...
|
||||||
|
class RShift(operator): ...
|
||||||
|
class Sub(operator): ...
|
||||||
|
class unaryop(AST): ...
|
||||||
|
class Invert(unaryop): ...
|
||||||
|
class Not(unaryop): ...
|
||||||
|
class UAdd(unaryop): ...
|
||||||
|
class USub(unaryop): ...
|
||||||
|
class cmpop(AST): ...
|
||||||
|
class Eq(cmpop): ...
|
||||||
|
class Gt(cmpop): ...
|
||||||
|
class GtE(cmpop): ...
|
||||||
|
class In(cmpop): ...
|
||||||
|
class Is(cmpop): ...
|
||||||
|
class IsNot(cmpop): ...
|
||||||
|
class Lt(cmpop): ...
|
||||||
|
class LtE(cmpop): ...
|
||||||
|
class NotEq(cmpop): ...
|
||||||
|
class NotIn(cmpop): ...
|
||||||
|
|
||||||
|
class comprehension(AST):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("target", "iter", "ifs", "is_async")
|
||||||
|
target: expr
|
||||||
|
iter: expr
|
||||||
|
ifs: list[expr]
|
||||||
|
is_async: int
|
||||||
|
|
||||||
|
class excepthandler(AST): ...
|
||||||
|
|
||||||
|
class ExceptHandler(excepthandler):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("type", "name", "body")
|
||||||
|
type: expr | None
|
||||||
|
name: _Identifier | None
|
||||||
|
body: list[stmt]
|
||||||
|
|
||||||
|
class arguments(AST):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("posonlyargs", "args", "vararg", "kwonlyargs", "kw_defaults", "kwarg", "defaults")
|
||||||
|
posonlyargs: list[arg]
|
||||||
|
args: list[arg]
|
||||||
|
vararg: arg | None
|
||||||
|
kwonlyargs: list[arg]
|
||||||
|
kw_defaults: list[expr | None]
|
||||||
|
kwarg: arg | None
|
||||||
|
defaults: list[expr]
|
||||||
|
|
||||||
|
class arg(AST):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("arg", "annotation", "type_comment")
|
||||||
|
arg: _Identifier
|
||||||
|
annotation: expr | None
|
||||||
|
|
||||||
|
class keyword(AST):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("arg", "value")
|
||||||
|
arg: _Identifier | None
|
||||||
|
value: expr
|
||||||
|
|
||||||
|
class alias(AST):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("name", "asname")
|
||||||
|
name: str
|
||||||
|
asname: _Identifier | None
|
||||||
|
|
||||||
|
class withitem(AST):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__ = ("context_expr", "optional_vars")
|
||||||
|
context_expr: expr
|
||||||
|
optional_vars: expr | None
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
class Match(stmt):
|
||||||
|
__match_args__ = ("subject", "cases")
|
||||||
|
subject: expr
|
||||||
|
cases: list[match_case]
|
||||||
|
|
||||||
|
class pattern(AST): ...
|
||||||
|
# Without the alias, Pyright complains variables named pattern are recursively defined
|
||||||
|
_Pattern: typing_extensions.TypeAlias = pattern
|
||||||
|
|
||||||
|
class match_case(AST):
|
||||||
|
__match_args__ = ("pattern", "guard", "body")
|
||||||
|
pattern: _Pattern
|
||||||
|
guard: expr | None
|
||||||
|
body: list[stmt]
|
||||||
|
|
||||||
|
class MatchValue(pattern):
|
||||||
|
__match_args__ = ("value",)
|
||||||
|
value: expr
|
||||||
|
|
||||||
|
class MatchSingleton(pattern):
|
||||||
|
__match_args__ = ("value",)
|
||||||
|
value: Literal[True, False] | None
|
||||||
|
|
||||||
|
class MatchSequence(pattern):
|
||||||
|
__match_args__ = ("patterns",)
|
||||||
|
patterns: list[pattern]
|
||||||
|
|
||||||
|
class MatchStar(pattern):
|
||||||
|
__match_args__ = ("name",)
|
||||||
|
name: _Identifier | None
|
||||||
|
|
||||||
|
class MatchMapping(pattern):
|
||||||
|
__match_args__ = ("keys", "patterns", "rest")
|
||||||
|
keys: list[expr]
|
||||||
|
patterns: list[pattern]
|
||||||
|
rest: _Identifier | None
|
||||||
|
|
||||||
|
class MatchClass(pattern):
|
||||||
|
__match_args__ = ("cls", "patterns", "kwd_attrs", "kwd_patterns")
|
||||||
|
cls: expr
|
||||||
|
patterns: list[pattern]
|
||||||
|
kwd_attrs: list[_Identifier]
|
||||||
|
kwd_patterns: list[pattern]
|
||||||
|
|
||||||
|
class MatchAs(pattern):
|
||||||
|
__match_args__ = ("pattern", "name")
|
||||||
|
pattern: _Pattern | None
|
||||||
|
name: _Identifier | None
|
||||||
|
|
||||||
|
class MatchOr(pattern):
|
||||||
|
__match_args__ = ("patterns",)
|
||||||
|
patterns: list[pattern]
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
class type_param(AST):
|
||||||
|
end_lineno: int
|
||||||
|
end_col_offset: int
|
||||||
|
|
||||||
|
class TypeVar(type_param):
|
||||||
|
__match_args__ = ("name", "bound")
|
||||||
|
name: _Identifier
|
||||||
|
bound: expr | None
|
||||||
|
|
||||||
|
class ParamSpec(type_param):
|
||||||
|
__match_args__ = ("name",)
|
||||||
|
name: _Identifier
|
||||||
|
|
||||||
|
class TypeVarTuple(type_param):
|
||||||
|
__match_args__ = ("name",)
|
||||||
|
name: _Identifier
|
||||||
|
|
||||||
|
class TypeAlias(stmt):
|
||||||
|
__match_args__ = ("name", "type_params", "value")
|
||||||
|
name: Name
|
||||||
|
type_params: list[type_param]
|
||||||
|
value: expr
|
||||||
|
|
@ -0,0 +1,84 @@
|
||||||
|
import sys
|
||||||
|
from _typeshed import SupportsLenAndGetItem, SupportsRichComparisonT
|
||||||
|
from collections.abc import Callable, MutableSequence
|
||||||
|
from typing import TypeVar, overload
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
@overload
|
||||||
|
def bisect_left(
|
||||||
|
a: SupportsLenAndGetItem[SupportsRichComparisonT],
|
||||||
|
x: SupportsRichComparisonT,
|
||||||
|
lo: int = 0,
|
||||||
|
hi: int | None = None,
|
||||||
|
*,
|
||||||
|
key: None = None,
|
||||||
|
) -> int: ...
|
||||||
|
@overload
|
||||||
|
def bisect_left(
|
||||||
|
a: SupportsLenAndGetItem[_T],
|
||||||
|
x: SupportsRichComparisonT,
|
||||||
|
lo: int = 0,
|
||||||
|
hi: int | None = None,
|
||||||
|
*,
|
||||||
|
key: Callable[[_T], SupportsRichComparisonT],
|
||||||
|
) -> int: ...
|
||||||
|
@overload
|
||||||
|
def bisect_right(
|
||||||
|
a: SupportsLenAndGetItem[SupportsRichComparisonT],
|
||||||
|
x: SupportsRichComparisonT,
|
||||||
|
lo: int = 0,
|
||||||
|
hi: int | None = None,
|
||||||
|
*,
|
||||||
|
key: None = None,
|
||||||
|
) -> int: ...
|
||||||
|
@overload
|
||||||
|
def bisect_right(
|
||||||
|
a: SupportsLenAndGetItem[_T],
|
||||||
|
x: SupportsRichComparisonT,
|
||||||
|
lo: int = 0,
|
||||||
|
hi: int | None = None,
|
||||||
|
*,
|
||||||
|
key: Callable[[_T], SupportsRichComparisonT],
|
||||||
|
) -> int: ...
|
||||||
|
@overload
|
||||||
|
def insort_left(
|
||||||
|
a: MutableSequence[SupportsRichComparisonT],
|
||||||
|
x: SupportsRichComparisonT,
|
||||||
|
lo: int = 0,
|
||||||
|
hi: int | None = None,
|
||||||
|
*,
|
||||||
|
key: None = None,
|
||||||
|
) -> None: ...
|
||||||
|
@overload
|
||||||
|
def insort_left(
|
||||||
|
a: MutableSequence[_T], x: _T, lo: int = 0, hi: int | None = None, *, key: Callable[[_T], SupportsRichComparisonT]
|
||||||
|
) -> None: ...
|
||||||
|
@overload
|
||||||
|
def insort_right(
|
||||||
|
a: MutableSequence[SupportsRichComparisonT],
|
||||||
|
x: SupportsRichComparisonT,
|
||||||
|
lo: int = 0,
|
||||||
|
hi: int | None = None,
|
||||||
|
*,
|
||||||
|
key: None = None,
|
||||||
|
) -> None: ...
|
||||||
|
@overload
|
||||||
|
def insort_right(
|
||||||
|
a: MutableSequence[_T], x: _T, lo: int = 0, hi: int | None = None, *, key: Callable[[_T], SupportsRichComparisonT]
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
def bisect_left(
|
||||||
|
a: SupportsLenAndGetItem[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None
|
||||||
|
) -> int: ...
|
||||||
|
def bisect_right(
|
||||||
|
a: SupportsLenAndGetItem[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None
|
||||||
|
) -> int: ...
|
||||||
|
def insort_left(
|
||||||
|
a: MutableSequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None
|
||||||
|
) -> None: ...
|
||||||
|
def insort_right(
|
||||||
|
a: MutableSequence[SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, hi: int | None = None
|
||||||
|
) -> None: ...
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
def getpreferredencoding(do_setlocale: bool = True) -> str: ...
|
||||||
|
|
@ -0,0 +1,133 @@
|
||||||
|
import codecs
|
||||||
|
import sys
|
||||||
|
from _typeshed import ReadableBuffer
|
||||||
|
from collections.abc import Callable
|
||||||
|
from typing import Literal, overload
|
||||||
|
from typing_extensions import TypeAlias
|
||||||
|
|
||||||
|
# This type is not exposed; it is defined in unicodeobject.c
|
||||||
|
class _EncodingMap:
|
||||||
|
def size(self) -> int: ...
|
||||||
|
|
||||||
|
_CharMap: TypeAlias = dict[int, int] | _EncodingMap
|
||||||
|
_Handler: TypeAlias = Callable[[UnicodeError], tuple[str | bytes, int]]
|
||||||
|
_SearchFunction: TypeAlias = Callable[[str], codecs.CodecInfo | None]
|
||||||
|
|
||||||
|
def register(search_function: _SearchFunction, /) -> None: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
def unregister(search_function: _SearchFunction, /) -> None: ...
|
||||||
|
|
||||||
|
def register_error(errors: str, handler: _Handler, /) -> None: ...
|
||||||
|
def lookup_error(name: str, /) -> _Handler: ...
|
||||||
|
|
||||||
|
# The type ignore on `encode` and `decode` is to avoid issues with overlapping overloads, for more details, see #300
|
||||||
|
# https://docs.python.org/3/library/codecs.html#binary-transforms
|
||||||
|
_BytesToBytesEncoding: TypeAlias = Literal[
|
||||||
|
"base64",
|
||||||
|
"base_64",
|
||||||
|
"base64_codec",
|
||||||
|
"bz2",
|
||||||
|
"bz2_codec",
|
||||||
|
"hex",
|
||||||
|
"hex_codec",
|
||||||
|
"quopri",
|
||||||
|
"quotedprintable",
|
||||||
|
"quoted_printable",
|
||||||
|
"quopri_codec",
|
||||||
|
"uu",
|
||||||
|
"uu_codec",
|
||||||
|
"zip",
|
||||||
|
"zlib",
|
||||||
|
"zlib_codec",
|
||||||
|
]
|
||||||
|
# https://docs.python.org/3/library/codecs.html#text-transforms
|
||||||
|
_StrToStrEncoding: TypeAlias = Literal["rot13", "rot_13"]
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def encode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = "strict") -> bytes: ...
|
||||||
|
@overload
|
||||||
|
def encode(obj: str, encoding: _StrToStrEncoding, errors: str = "strict") -> str: ... # type: ignore[overload-overlap]
|
||||||
|
@overload
|
||||||
|
def encode(obj: str, encoding: str = "utf-8", errors: str = "strict") -> bytes: ...
|
||||||
|
@overload
|
||||||
|
def decode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = "strict") -> bytes: ... # type: ignore[overload-overlap]
|
||||||
|
@overload
|
||||||
|
def decode(obj: str, encoding: _StrToStrEncoding, errors: str = "strict") -> str: ...
|
||||||
|
|
||||||
|
# these are documented as text encodings but in practice they also accept str as input
|
||||||
|
@overload
|
||||||
|
def decode(
|
||||||
|
obj: str,
|
||||||
|
encoding: Literal["unicode_escape", "unicode-escape", "raw_unicode_escape", "raw-unicode-escape"],
|
||||||
|
errors: str = "strict",
|
||||||
|
) -> str: ...
|
||||||
|
|
||||||
|
# hex is officially documented as a bytes to bytes encoding, but it appears to also work with str
|
||||||
|
@overload
|
||||||
|
def decode(obj: str, encoding: Literal["hex", "hex_codec"], errors: str = "strict") -> bytes: ...
|
||||||
|
@overload
|
||||||
|
def decode(obj: ReadableBuffer, encoding: str = "utf-8", errors: str = "strict") -> str: ...
|
||||||
|
def lookup(encoding: str, /) -> codecs.CodecInfo: ...
|
||||||
|
def charmap_build(map: str, /) -> _CharMap: ...
|
||||||
|
def ascii_decode(data: ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
|
||||||
|
def ascii_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
|
||||||
|
def charmap_decode(data: ReadableBuffer, errors: str | None = None, mapping: _CharMap | None = None, /) -> tuple[str, int]: ...
|
||||||
|
def charmap_encode(str: str, errors: str | None = None, mapping: _CharMap | None = None, /) -> tuple[bytes, int]: ...
|
||||||
|
def escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
|
||||||
|
def escape_encode(data: bytes, errors: str | None = None, /) -> tuple[bytes, int]: ...
|
||||||
|
def latin_1_decode(data: ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
|
||||||
|
def latin_1_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
def raw_unicode_escape_decode(
|
||||||
|
data: str | ReadableBuffer, errors: str | None = None, final: bool = True, /
|
||||||
|
) -> tuple[str, int]: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
def raw_unicode_escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
|
||||||
|
|
||||||
|
def raw_unicode_escape_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
|
||||||
|
def readbuffer_encode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[bytes, int]: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
def unicode_escape_decode(
|
||||||
|
data: str | ReadableBuffer, errors: str | None = None, final: bool = True, /
|
||||||
|
) -> tuple[str, int]: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
def unicode_escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
|
||||||
|
|
||||||
|
def unicode_escape_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
|
||||||
|
def utf_16_be_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
|
||||||
|
def utf_16_be_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
|
||||||
|
def utf_16_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
|
||||||
|
def utf_16_encode(str: str, errors: str | None = None, byteorder: int = 0, /) -> tuple[bytes, int]: ...
|
||||||
|
def utf_16_ex_decode(
|
||||||
|
data: ReadableBuffer, errors: str | None = None, byteorder: int = 0, final: bool = False, /
|
||||||
|
) -> tuple[str, int, int]: ...
|
||||||
|
def utf_16_le_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
|
||||||
|
def utf_16_le_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
|
||||||
|
def utf_32_be_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
|
||||||
|
def utf_32_be_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
|
||||||
|
def utf_32_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
|
||||||
|
def utf_32_encode(str: str, errors: str | None = None, byteorder: int = 0, /) -> tuple[bytes, int]: ...
|
||||||
|
def utf_32_ex_decode(
|
||||||
|
data: ReadableBuffer, errors: str | None = None, byteorder: int = 0, final: bool = False, /
|
||||||
|
) -> tuple[str, int, int]: ...
|
||||||
|
def utf_32_le_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
|
||||||
|
def utf_32_le_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
|
||||||
|
def utf_7_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
|
||||||
|
def utf_7_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
|
||||||
|
def utf_8_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
|
||||||
|
def utf_8_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
|
||||||
|
|
||||||
|
if sys.platform == "win32":
|
||||||
|
def mbcs_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
|
||||||
|
def mbcs_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
|
||||||
|
def code_page_decode(
|
||||||
|
codepage: int, data: ReadableBuffer, errors: str | None = None, final: bool = False, /
|
||||||
|
) -> tuple[str, int]: ...
|
||||||
|
def code_page_encode(code_page: int, str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
|
||||||
|
def oem_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
|
||||||
|
def oem_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
|
||||||
|
|
@ -0,0 +1,94 @@
|
||||||
|
import sys
|
||||||
|
from abc import abstractmethod
|
||||||
|
from types import MappingProxyType
|
||||||
|
from typing import ( # noqa: Y022,Y038,Y057
|
||||||
|
AbstractSet as Set,
|
||||||
|
AsyncGenerator as AsyncGenerator,
|
||||||
|
AsyncIterable as AsyncIterable,
|
||||||
|
AsyncIterator as AsyncIterator,
|
||||||
|
Awaitable as Awaitable,
|
||||||
|
ByteString as ByteString,
|
||||||
|
Callable as Callable,
|
||||||
|
Collection as Collection,
|
||||||
|
Container as Container,
|
||||||
|
Coroutine as Coroutine,
|
||||||
|
Generator as Generator,
|
||||||
|
Generic,
|
||||||
|
Hashable as Hashable,
|
||||||
|
ItemsView as ItemsView,
|
||||||
|
Iterable as Iterable,
|
||||||
|
Iterator as Iterator,
|
||||||
|
KeysView as KeysView,
|
||||||
|
Mapping as Mapping,
|
||||||
|
MappingView as MappingView,
|
||||||
|
MutableMapping as MutableMapping,
|
||||||
|
MutableSequence as MutableSequence,
|
||||||
|
MutableSet as MutableSet,
|
||||||
|
Protocol,
|
||||||
|
Reversible as Reversible,
|
||||||
|
Sequence as Sequence,
|
||||||
|
Sized as Sized,
|
||||||
|
TypeVar,
|
||||||
|
ValuesView as ValuesView,
|
||||||
|
final,
|
||||||
|
runtime_checkable,
|
||||||
|
)
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"Awaitable",
|
||||||
|
"Coroutine",
|
||||||
|
"AsyncIterable",
|
||||||
|
"AsyncIterator",
|
||||||
|
"AsyncGenerator",
|
||||||
|
"Hashable",
|
||||||
|
"Iterable",
|
||||||
|
"Iterator",
|
||||||
|
"Generator",
|
||||||
|
"Reversible",
|
||||||
|
"Sized",
|
||||||
|
"Container",
|
||||||
|
"Callable",
|
||||||
|
"Collection",
|
||||||
|
"Set",
|
||||||
|
"MutableSet",
|
||||||
|
"Mapping",
|
||||||
|
"MutableMapping",
|
||||||
|
"MappingView",
|
||||||
|
"KeysView",
|
||||||
|
"ItemsView",
|
||||||
|
"ValuesView",
|
||||||
|
"Sequence",
|
||||||
|
"MutableSequence",
|
||||||
|
"ByteString",
|
||||||
|
]
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
__all__ += ["Buffer"]
|
||||||
|
|
||||||
|
_KT_co = TypeVar("_KT_co", covariant=True) # Key type covariant containers.
|
||||||
|
_VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers.
|
||||||
|
|
||||||
|
@final
|
||||||
|
class dict_keys(KeysView[_KT_co], Generic[_KT_co, _VT_co]): # undocumented
|
||||||
|
def __eq__(self, value: object, /) -> bool: ...
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
@property
|
||||||
|
def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ...
|
||||||
|
|
||||||
|
@final
|
||||||
|
class dict_values(ValuesView[_VT_co], Generic[_KT_co, _VT_co]): # undocumented
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
@property
|
||||||
|
def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ...
|
||||||
|
|
||||||
|
@final
|
||||||
|
class dict_items(ItemsView[_KT_co, _VT_co]): # undocumented
|
||||||
|
def __eq__(self, value: object, /) -> bool: ...
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
@property
|
||||||
|
def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
@runtime_checkable
|
||||||
|
class Buffer(Protocol):
|
||||||
|
@abstractmethod
|
||||||
|
def __buffer__(self, flags: int, /) -> memoryview: ...
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
IMPORT_MAPPING: dict[str, str]
|
||||||
|
NAME_MAPPING: dict[tuple[str, str], tuple[str, str]]
|
||||||
|
PYTHON2_EXCEPTIONS: tuple[str, ...]
|
||||||
|
MULTIPROCESSING_EXCEPTIONS: tuple[str, ...]
|
||||||
|
REVERSE_IMPORT_MAPPING: dict[str, str]
|
||||||
|
REVERSE_NAME_MAPPING: dict[tuple[str, str], tuple[str, str]]
|
||||||
|
PYTHON3_OSERROR_EXCEPTIONS: tuple[str, ...]
|
||||||
|
PYTHON3_IMPORTERROR_EXCEPTIONS: tuple[str, ...]
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
from _typeshed import WriteableBuffer
|
||||||
|
from collections.abc import Callable
|
||||||
|
from io import DEFAULT_BUFFER_SIZE, BufferedIOBase, RawIOBase
|
||||||
|
from typing import Any, Protocol
|
||||||
|
|
||||||
|
BUFFER_SIZE = DEFAULT_BUFFER_SIZE
|
||||||
|
|
||||||
|
class _Reader(Protocol):
|
||||||
|
def read(self, n: int, /) -> bytes: ...
|
||||||
|
def seekable(self) -> bool: ...
|
||||||
|
def seek(self, n: int, /) -> Any: ...
|
||||||
|
|
||||||
|
class BaseStream(BufferedIOBase): ...
|
||||||
|
|
||||||
|
class DecompressReader(RawIOBase):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
fp: _Reader,
|
||||||
|
decomp_factory: Callable[..., object],
|
||||||
|
trailing_error: type[Exception] | tuple[type[Exception], ...] = (),
|
||||||
|
**decomp_args: Any,
|
||||||
|
) -> None: ...
|
||||||
|
def readinto(self, b: WriteableBuffer) -> int: ...
|
||||||
|
def read(self, size: int = -1) -> bytes: ...
|
||||||
|
def seek(self, offset: int, whence: int = 0) -> int: ...
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
import sys
|
||||||
|
from _typeshed import SupportsWrite
|
||||||
|
from collections.abc import Iterable, Iterator
|
||||||
|
from typing import Any, Final, Literal
|
||||||
|
from typing_extensions import TypeAlias
|
||||||
|
|
||||||
|
__version__: Final[str]
|
||||||
|
|
||||||
|
QUOTE_ALL: Literal[1]
|
||||||
|
QUOTE_MINIMAL: Literal[0]
|
||||||
|
QUOTE_NONE: Literal[3]
|
||||||
|
QUOTE_NONNUMERIC: Literal[2]
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
QUOTE_STRINGS: Literal[4]
|
||||||
|
QUOTE_NOTNULL: Literal[5]
|
||||||
|
|
||||||
|
# Ideally this would be `QUOTE_ALL | QUOTE_MINIMAL | QUOTE_NONE | QUOTE_NONNUMERIC`
|
||||||
|
# However, using literals in situations like these can cause false-positives (see #7258)
|
||||||
|
_QuotingType: TypeAlias = int
|
||||||
|
|
||||||
|
class Error(Exception): ...
|
||||||
|
|
||||||
|
class Dialect:
|
||||||
|
delimiter: str
|
||||||
|
quotechar: str | None
|
||||||
|
escapechar: str | None
|
||||||
|
doublequote: bool
|
||||||
|
skipinitialspace: bool
|
||||||
|
lineterminator: str
|
||||||
|
quoting: _QuotingType
|
||||||
|
strict: bool
|
||||||
|
def __init__(self) -> None: ...
|
||||||
|
|
||||||
|
_DialectLike: TypeAlias = str | Dialect | type[Dialect]
|
||||||
|
|
||||||
|
class _reader(Iterator[list[str]]):
|
||||||
|
@property
|
||||||
|
def dialect(self) -> Dialect: ...
|
||||||
|
line_num: int
|
||||||
|
def __next__(self) -> list[str]: ...
|
||||||
|
|
||||||
|
class _writer:
|
||||||
|
@property
|
||||||
|
def dialect(self) -> Dialect: ...
|
||||||
|
def writerow(self, row: Iterable[Any]) -> Any: ...
|
||||||
|
def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ...
|
||||||
|
|
||||||
|
def writer(
|
||||||
|
csvfile: SupportsWrite[str],
|
||||||
|
dialect: _DialectLike = "excel",
|
||||||
|
*,
|
||||||
|
delimiter: str = ",",
|
||||||
|
quotechar: str | None = '"',
|
||||||
|
escapechar: str | None = None,
|
||||||
|
doublequote: bool = True,
|
||||||
|
skipinitialspace: bool = False,
|
||||||
|
lineterminator: str = "\r\n",
|
||||||
|
quoting: _QuotingType = 0,
|
||||||
|
strict: bool = False,
|
||||||
|
) -> _writer: ...
|
||||||
|
def reader(
|
||||||
|
csvfile: Iterable[str],
|
||||||
|
dialect: _DialectLike = "excel",
|
||||||
|
*,
|
||||||
|
delimiter: str = ",",
|
||||||
|
quotechar: str | None = '"',
|
||||||
|
escapechar: str | None = None,
|
||||||
|
doublequote: bool = True,
|
||||||
|
skipinitialspace: bool = False,
|
||||||
|
lineterminator: str = "\r\n",
|
||||||
|
quoting: _QuotingType = 0,
|
||||||
|
strict: bool = False,
|
||||||
|
) -> _reader: ...
|
||||||
|
def register_dialect(
|
||||||
|
name: str,
|
||||||
|
dialect: type[Dialect] = ...,
|
||||||
|
*,
|
||||||
|
delimiter: str = ",",
|
||||||
|
quotechar: str | None = '"',
|
||||||
|
escapechar: str | None = None,
|
||||||
|
doublequote: bool = True,
|
||||||
|
skipinitialspace: bool = False,
|
||||||
|
lineterminator: str = "\r\n",
|
||||||
|
quoting: _QuotingType = 0,
|
||||||
|
strict: bool = False,
|
||||||
|
) -> None: ...
|
||||||
|
def unregister_dialect(name: str) -> None: ...
|
||||||
|
def get_dialect(name: str) -> Dialect: ...
|
||||||
|
def list_dialects() -> list[str]: ...
|
||||||
|
def field_size_limit(new_limit: int = ...) -> int: ...
|
||||||
|
|
@ -0,0 +1,211 @@
|
||||||
|
import sys
|
||||||
|
from _typeshed import ReadableBuffer, WriteableBuffer
|
||||||
|
from abc import abstractmethod
|
||||||
|
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
|
||||||
|
from ctypes import CDLL, ArgumentError as ArgumentError
|
||||||
|
from typing import Any, ClassVar, Generic, TypeVar, overload
|
||||||
|
from typing_extensions import Self, TypeAlias
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
from types import GenericAlias
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
_CT = TypeVar("_CT", bound=_CData)
|
||||||
|
|
||||||
|
FUNCFLAG_CDECL: int
|
||||||
|
FUNCFLAG_PYTHONAPI: int
|
||||||
|
FUNCFLAG_USE_ERRNO: int
|
||||||
|
FUNCFLAG_USE_LASTERROR: int
|
||||||
|
RTLD_GLOBAL: int
|
||||||
|
RTLD_LOCAL: int
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
CTYPES_MAX_ARGCOUNT: int
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
SIZEOF_TIME_T: int
|
||||||
|
|
||||||
|
if sys.platform == "win32":
|
||||||
|
# Description, Source, HelpFile, HelpContext, scode
|
||||||
|
_COMError_Details: TypeAlias = tuple[str | None, str | None, str | None, int | None, int | None]
|
||||||
|
|
||||||
|
class COMError(Exception):
|
||||||
|
hresult: int
|
||||||
|
text: str | None
|
||||||
|
details: _COMError_Details
|
||||||
|
|
||||||
|
def __init__(self, hresult: int, text: str | None, details: _COMError_Details) -> None: ...
|
||||||
|
|
||||||
|
def CopyComPointer(src: _PointerLike, dst: _PointerLike | _CArgObject) -> int: ...
|
||||||
|
|
||||||
|
FUNCFLAG_HRESULT: int
|
||||||
|
FUNCFLAG_STDCALL: int
|
||||||
|
|
||||||
|
def FormatError(code: int = ...) -> str: ...
|
||||||
|
def get_last_error() -> int: ...
|
||||||
|
def set_last_error(value: int) -> int: ...
|
||||||
|
def LoadLibrary(name: str, load_flags: int = 0, /) -> int: ...
|
||||||
|
def FreeLibrary(handle: int, /) -> None: ...
|
||||||
|
|
||||||
|
class _CDataMeta(type):
|
||||||
|
# By default mypy complains about the following two methods, because strictly speaking cls
|
||||||
|
# might not be a Type[_CT]. However this can never actually happen, because the only class that
|
||||||
|
# uses _CDataMeta as its metaclass is _CData. So it's safe to ignore the errors here.
|
||||||
|
def __mul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc]
|
||||||
|
def __rmul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc]
|
||||||
|
|
||||||
|
class _CData(metaclass=_CDataMeta):
|
||||||
|
_b_base_: int
|
||||||
|
_b_needsfree_: bool
|
||||||
|
_objects: Mapping[Any, int] | None
|
||||||
|
# At runtime the following classmethods are available only on classes, not
|
||||||
|
# on instances. This can't be reflected properly in the type system:
|
||||||
|
#
|
||||||
|
# Structure.from_buffer(...) # valid at runtime
|
||||||
|
# Structure(...).from_buffer(...) # invalid at runtime
|
||||||
|
#
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_buffer(cls, source: WriteableBuffer, offset: int = ...) -> Self: ...
|
||||||
|
@classmethod
|
||||||
|
def from_buffer_copy(cls, source: ReadableBuffer, offset: int = ...) -> Self: ...
|
||||||
|
@classmethod
|
||||||
|
def from_address(cls, address: int) -> Self: ...
|
||||||
|
@classmethod
|
||||||
|
def from_param(cls, obj: Any) -> Self | _CArgObject: ...
|
||||||
|
@classmethod
|
||||||
|
def in_dll(cls, library: CDLL, name: str) -> Self: ...
|
||||||
|
def __buffer__(self, flags: int, /) -> memoryview: ...
|
||||||
|
def __release_buffer__(self, buffer: memoryview, /) -> None: ...
|
||||||
|
|
||||||
|
class _SimpleCData(_CData, Generic[_T]):
|
||||||
|
value: _T
|
||||||
|
# The TypeVar can be unsolved here,
|
||||||
|
# but we can't use overloads without creating many, many mypy false-positive errors
|
||||||
|
def __init__(self, value: _T = ...) -> None: ... # pyright: ignore[reportInvalidTypeVarUse]
|
||||||
|
|
||||||
|
class _CanCastTo(_CData): ...
|
||||||
|
class _PointerLike(_CanCastTo): ...
|
||||||
|
|
||||||
|
class _Pointer(_PointerLike, _CData, Generic[_CT]):
|
||||||
|
_type_: type[_CT]
|
||||||
|
contents: _CT
|
||||||
|
@overload
|
||||||
|
def __init__(self) -> None: ...
|
||||||
|
@overload
|
||||||
|
def __init__(self, arg: _CT) -> None: ...
|
||||||
|
@overload
|
||||||
|
def __getitem__(self, key: int, /) -> Any: ...
|
||||||
|
@overload
|
||||||
|
def __getitem__(self, key: slice, /) -> list[Any]: ...
|
||||||
|
def __setitem__(self, key: int, value: Any, /) -> None: ...
|
||||||
|
|
||||||
|
def POINTER(type: type[_CT]) -> type[_Pointer[_CT]]: ...
|
||||||
|
def pointer(arg: _CT, /) -> _Pointer[_CT]: ...
|
||||||
|
|
||||||
|
class _CArgObject: ...
|
||||||
|
|
||||||
|
def byref(obj: _CData, offset: int = ...) -> _CArgObject: ...
|
||||||
|
|
||||||
|
_ECT: TypeAlias = Callable[[_CData | None, CFuncPtr, tuple[_CData, ...]], _CData]
|
||||||
|
_PF: TypeAlias = tuple[int] | tuple[int, str | None] | tuple[int, str | None, Any]
|
||||||
|
|
||||||
|
class CFuncPtr(_PointerLike, _CData):
|
||||||
|
restype: type[_CData] | Callable[[int], Any] | None
|
||||||
|
argtypes: Sequence[type[_CData]]
|
||||||
|
errcheck: _ECT
|
||||||
|
# Abstract attribute that must be defined on subclasses
|
||||||
|
_flags_: ClassVar[int]
|
||||||
|
@overload
|
||||||
|
def __init__(self) -> None: ...
|
||||||
|
@overload
|
||||||
|
def __init__(self, address: int, /) -> None: ...
|
||||||
|
@overload
|
||||||
|
def __init__(self, callable: Callable[..., Any], /) -> None: ...
|
||||||
|
@overload
|
||||||
|
def __init__(self, func_spec: tuple[str | int, CDLL], paramflags: tuple[_PF, ...] | None = ..., /) -> None: ...
|
||||||
|
if sys.platform == "win32":
|
||||||
|
@overload
|
||||||
|
def __init__(
|
||||||
|
self, vtbl_index: int, name: str, paramflags: tuple[_PF, ...] | None = ..., iid: _CData | None = ..., /
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||||
|
|
||||||
|
_GetT = TypeVar("_GetT")
|
||||||
|
_SetT = TypeVar("_SetT")
|
||||||
|
|
||||||
|
class _CField(Generic[_CT, _GetT, _SetT]):
|
||||||
|
offset: int
|
||||||
|
size: int
|
||||||
|
@overload
|
||||||
|
def __get__(self, instance: None, owner: type[Any] | None, /) -> Self: ...
|
||||||
|
@overload
|
||||||
|
def __get__(self, instance: Any, owner: type[Any] | None, /) -> _GetT: ...
|
||||||
|
def __set__(self, instance: Any, value: _SetT, /) -> None: ...
|
||||||
|
|
||||||
|
class _StructUnionMeta(_CDataMeta):
|
||||||
|
_fields_: Sequence[tuple[str, type[_CData]] | tuple[str, type[_CData], int]]
|
||||||
|
_pack_: int
|
||||||
|
_anonymous_: Sequence[str]
|
||||||
|
def __getattr__(self, name: str) -> _CField[Any, Any, Any]: ...
|
||||||
|
|
||||||
|
class _StructUnionBase(_CData, metaclass=_StructUnionMeta):
|
||||||
|
def __init__(self, *args: Any, **kw: Any) -> None: ...
|
||||||
|
def __getattr__(self, name: str) -> Any: ...
|
||||||
|
def __setattr__(self, name: str, value: Any) -> None: ...
|
||||||
|
|
||||||
|
class Union(_StructUnionBase): ...
|
||||||
|
class Structure(_StructUnionBase): ...
|
||||||
|
|
||||||
|
class Array(_CData, Generic[_CT]):
|
||||||
|
@property
|
||||||
|
@abstractmethod
|
||||||
|
def _length_(self) -> int: ...
|
||||||
|
@_length_.setter
|
||||||
|
def _length_(self, value: int) -> None: ...
|
||||||
|
@property
|
||||||
|
@abstractmethod
|
||||||
|
def _type_(self) -> type[_CT]: ...
|
||||||
|
@_type_.setter
|
||||||
|
def _type_(self, value: type[_CT]) -> None: ...
|
||||||
|
# Note: only available if _CT == c_char
|
||||||
|
@property
|
||||||
|
def raw(self) -> bytes: ...
|
||||||
|
@raw.setter
|
||||||
|
def raw(self, value: ReadableBuffer) -> None: ...
|
||||||
|
value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise
|
||||||
|
# TODO These methods cannot be annotated correctly at the moment.
|
||||||
|
# All of these "Any"s stand for the array's element type, but it's not possible to use _CT
|
||||||
|
# here, because of a special feature of ctypes.
|
||||||
|
# By default, when accessing an element of an Array[_CT], the returned object has type _CT.
|
||||||
|
# However, when _CT is a "simple type" like c_int, ctypes automatically "unboxes" the object
|
||||||
|
# and converts it to the corresponding Python primitive. For example, when accessing an element
|
||||||
|
# of an Array[c_int], a Python int object is returned, not a c_int.
|
||||||
|
# This behavior does *not* apply to subclasses of "simple types".
|
||||||
|
# If MyInt is a subclass of c_int, then accessing an element of an Array[MyInt] returns
|
||||||
|
# a MyInt, not an int.
|
||||||
|
# This special behavior is not easy to model in a stub, so for now all places where
|
||||||
|
# the array element type would belong are annotated with Any instead.
|
||||||
|
def __init__(self, *args: Any) -> None: ...
|
||||||
|
@overload
|
||||||
|
def __getitem__(self, key: int, /) -> Any: ...
|
||||||
|
@overload
|
||||||
|
def __getitem__(self, key: slice, /) -> list[Any]: ...
|
||||||
|
@overload
|
||||||
|
def __setitem__(self, key: int, value: Any, /) -> None: ...
|
||||||
|
@overload
|
||||||
|
def __setitem__(self, key: slice, value: Iterable[Any], /) -> None: ...
|
||||||
|
def __iter__(self) -> Iterator[Any]: ...
|
||||||
|
# Can't inherit from Sized because the metaclass conflict between
|
||||||
|
# Sized and _CData prevents using _CDataMeta.
|
||||||
|
def __len__(self) -> int: ...
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||||
|
|
||||||
|
def addressof(obj: _CData) -> int: ...
|
||||||
|
def alignment(obj_or_type: _CData | type[_CData]) -> int: ...
|
||||||
|
def get_errno() -> int: ...
|
||||||
|
def resize(obj: _CData, size: int) -> None: ...
|
||||||
|
def set_errno(value: int) -> int: ...
|
||||||
|
def sizeof(obj_or_type: _CData | type[_CData]) -> int: ...
|
||||||
|
|
@ -0,0 +1,566 @@
|
||||||
|
import sys
|
||||||
|
from _typeshed import ReadOnlyBuffer, SupportsRead
|
||||||
|
from typing import IO, Any, NamedTuple, final, overload
|
||||||
|
from typing_extensions import TypeAlias
|
||||||
|
|
||||||
|
# NOTE: This module is ordinarily only available on Unix, but the windows-curses
|
||||||
|
# package makes it available on Windows as well with the same contents.
|
||||||
|
|
||||||
|
# Handled by PyCurses_ConvertToChtype in _cursesmodule.c.
|
||||||
|
_ChType: TypeAlias = str | bytes | int
|
||||||
|
|
||||||
|
# ACS codes are only initialized after initscr is called
|
||||||
|
ACS_BBSS: int
|
||||||
|
ACS_BLOCK: int
|
||||||
|
ACS_BOARD: int
|
||||||
|
ACS_BSBS: int
|
||||||
|
ACS_BSSB: int
|
||||||
|
ACS_BSSS: int
|
||||||
|
ACS_BTEE: int
|
||||||
|
ACS_BULLET: int
|
||||||
|
ACS_CKBOARD: int
|
||||||
|
ACS_DARROW: int
|
||||||
|
ACS_DEGREE: int
|
||||||
|
ACS_DIAMOND: int
|
||||||
|
ACS_GEQUAL: int
|
||||||
|
ACS_HLINE: int
|
||||||
|
ACS_LANTERN: int
|
||||||
|
ACS_LARROW: int
|
||||||
|
ACS_LEQUAL: int
|
||||||
|
ACS_LLCORNER: int
|
||||||
|
ACS_LRCORNER: int
|
||||||
|
ACS_LTEE: int
|
||||||
|
ACS_NEQUAL: int
|
||||||
|
ACS_PI: int
|
||||||
|
ACS_PLMINUS: int
|
||||||
|
ACS_PLUS: int
|
||||||
|
ACS_RARROW: int
|
||||||
|
ACS_RTEE: int
|
||||||
|
ACS_S1: int
|
||||||
|
ACS_S3: int
|
||||||
|
ACS_S7: int
|
||||||
|
ACS_S9: int
|
||||||
|
ACS_SBBS: int
|
||||||
|
ACS_SBSB: int
|
||||||
|
ACS_SBSS: int
|
||||||
|
ACS_SSBB: int
|
||||||
|
ACS_SSBS: int
|
||||||
|
ACS_SSSB: int
|
||||||
|
ACS_SSSS: int
|
||||||
|
ACS_STERLING: int
|
||||||
|
ACS_TTEE: int
|
||||||
|
ACS_UARROW: int
|
||||||
|
ACS_ULCORNER: int
|
||||||
|
ACS_URCORNER: int
|
||||||
|
ACS_VLINE: int
|
||||||
|
ALL_MOUSE_EVENTS: int
|
||||||
|
A_ALTCHARSET: int
|
||||||
|
A_ATTRIBUTES: int
|
||||||
|
A_BLINK: int
|
||||||
|
A_BOLD: int
|
||||||
|
A_CHARTEXT: int
|
||||||
|
A_COLOR: int
|
||||||
|
A_DIM: int
|
||||||
|
A_HORIZONTAL: int
|
||||||
|
A_INVIS: int
|
||||||
|
if sys.platform != "darwin":
|
||||||
|
A_ITALIC: int
|
||||||
|
A_LEFT: int
|
||||||
|
A_LOW: int
|
||||||
|
A_NORMAL: int
|
||||||
|
A_PROTECT: int
|
||||||
|
A_REVERSE: int
|
||||||
|
A_RIGHT: int
|
||||||
|
A_STANDOUT: int
|
||||||
|
A_TOP: int
|
||||||
|
A_UNDERLINE: int
|
||||||
|
A_VERTICAL: int
|
||||||
|
BUTTON1_CLICKED: int
|
||||||
|
BUTTON1_DOUBLE_CLICKED: int
|
||||||
|
BUTTON1_PRESSED: int
|
||||||
|
BUTTON1_RELEASED: int
|
||||||
|
BUTTON1_TRIPLE_CLICKED: int
|
||||||
|
BUTTON2_CLICKED: int
|
||||||
|
BUTTON2_DOUBLE_CLICKED: int
|
||||||
|
BUTTON2_PRESSED: int
|
||||||
|
BUTTON2_RELEASED: int
|
||||||
|
BUTTON2_TRIPLE_CLICKED: int
|
||||||
|
BUTTON3_CLICKED: int
|
||||||
|
BUTTON3_DOUBLE_CLICKED: int
|
||||||
|
BUTTON3_PRESSED: int
|
||||||
|
BUTTON3_RELEASED: int
|
||||||
|
BUTTON3_TRIPLE_CLICKED: int
|
||||||
|
BUTTON4_CLICKED: int
|
||||||
|
BUTTON4_DOUBLE_CLICKED: int
|
||||||
|
BUTTON4_PRESSED: int
|
||||||
|
BUTTON4_RELEASED: int
|
||||||
|
BUTTON4_TRIPLE_CLICKED: int
|
||||||
|
# Darwin ncurses doesn't provide BUTTON5_* constants
|
||||||
|
if sys.version_info >= (3, 10) and sys.platform != "darwin":
|
||||||
|
BUTTON5_PRESSED: int
|
||||||
|
BUTTON5_RELEASED: int
|
||||||
|
BUTTON5_CLICKED: int
|
||||||
|
BUTTON5_DOUBLE_CLICKED: int
|
||||||
|
BUTTON5_TRIPLE_CLICKED: int
|
||||||
|
BUTTON_ALT: int
|
||||||
|
BUTTON_CTRL: int
|
||||||
|
BUTTON_SHIFT: int
|
||||||
|
COLOR_BLACK: int
|
||||||
|
COLOR_BLUE: int
|
||||||
|
COLOR_CYAN: int
|
||||||
|
COLOR_GREEN: int
|
||||||
|
COLOR_MAGENTA: int
|
||||||
|
COLOR_RED: int
|
||||||
|
COLOR_WHITE: int
|
||||||
|
COLOR_YELLOW: int
|
||||||
|
ERR: int
|
||||||
|
KEY_A1: int
|
||||||
|
KEY_A3: int
|
||||||
|
KEY_B2: int
|
||||||
|
KEY_BACKSPACE: int
|
||||||
|
KEY_BEG: int
|
||||||
|
KEY_BREAK: int
|
||||||
|
KEY_BTAB: int
|
||||||
|
KEY_C1: int
|
||||||
|
KEY_C3: int
|
||||||
|
KEY_CANCEL: int
|
||||||
|
KEY_CATAB: int
|
||||||
|
KEY_CLEAR: int
|
||||||
|
KEY_CLOSE: int
|
||||||
|
KEY_COMMAND: int
|
||||||
|
KEY_COPY: int
|
||||||
|
KEY_CREATE: int
|
||||||
|
KEY_CTAB: int
|
||||||
|
KEY_DC: int
|
||||||
|
KEY_DL: int
|
||||||
|
KEY_DOWN: int
|
||||||
|
KEY_EIC: int
|
||||||
|
KEY_END: int
|
||||||
|
KEY_ENTER: int
|
||||||
|
KEY_EOL: int
|
||||||
|
KEY_EOS: int
|
||||||
|
KEY_EXIT: int
|
||||||
|
KEY_F0: int
|
||||||
|
KEY_F1: int
|
||||||
|
KEY_F10: int
|
||||||
|
KEY_F11: int
|
||||||
|
KEY_F12: int
|
||||||
|
KEY_F13: int
|
||||||
|
KEY_F14: int
|
||||||
|
KEY_F15: int
|
||||||
|
KEY_F16: int
|
||||||
|
KEY_F17: int
|
||||||
|
KEY_F18: int
|
||||||
|
KEY_F19: int
|
||||||
|
KEY_F2: int
|
||||||
|
KEY_F20: int
|
||||||
|
KEY_F21: int
|
||||||
|
KEY_F22: int
|
||||||
|
KEY_F23: int
|
||||||
|
KEY_F24: int
|
||||||
|
KEY_F25: int
|
||||||
|
KEY_F26: int
|
||||||
|
KEY_F27: int
|
||||||
|
KEY_F28: int
|
||||||
|
KEY_F29: int
|
||||||
|
KEY_F3: int
|
||||||
|
KEY_F30: int
|
||||||
|
KEY_F31: int
|
||||||
|
KEY_F32: int
|
||||||
|
KEY_F33: int
|
||||||
|
KEY_F34: int
|
||||||
|
KEY_F35: int
|
||||||
|
KEY_F36: int
|
||||||
|
KEY_F37: int
|
||||||
|
KEY_F38: int
|
||||||
|
KEY_F39: int
|
||||||
|
KEY_F4: int
|
||||||
|
KEY_F40: int
|
||||||
|
KEY_F41: int
|
||||||
|
KEY_F42: int
|
||||||
|
KEY_F43: int
|
||||||
|
KEY_F44: int
|
||||||
|
KEY_F45: int
|
||||||
|
KEY_F46: int
|
||||||
|
KEY_F47: int
|
||||||
|
KEY_F48: int
|
||||||
|
KEY_F49: int
|
||||||
|
KEY_F5: int
|
||||||
|
KEY_F50: int
|
||||||
|
KEY_F51: int
|
||||||
|
KEY_F52: int
|
||||||
|
KEY_F53: int
|
||||||
|
KEY_F54: int
|
||||||
|
KEY_F55: int
|
||||||
|
KEY_F56: int
|
||||||
|
KEY_F57: int
|
||||||
|
KEY_F58: int
|
||||||
|
KEY_F59: int
|
||||||
|
KEY_F6: int
|
||||||
|
KEY_F60: int
|
||||||
|
KEY_F61: int
|
||||||
|
KEY_F62: int
|
||||||
|
KEY_F63: int
|
||||||
|
KEY_F7: int
|
||||||
|
KEY_F8: int
|
||||||
|
KEY_F9: int
|
||||||
|
KEY_FIND: int
|
||||||
|
KEY_HELP: int
|
||||||
|
KEY_HOME: int
|
||||||
|
KEY_IC: int
|
||||||
|
KEY_IL: int
|
||||||
|
KEY_LEFT: int
|
||||||
|
KEY_LL: int
|
||||||
|
KEY_MARK: int
|
||||||
|
KEY_MAX: int
|
||||||
|
KEY_MESSAGE: int
|
||||||
|
KEY_MIN: int
|
||||||
|
KEY_MOUSE: int
|
||||||
|
KEY_MOVE: int
|
||||||
|
KEY_NEXT: int
|
||||||
|
KEY_NPAGE: int
|
||||||
|
KEY_OPEN: int
|
||||||
|
KEY_OPTIONS: int
|
||||||
|
KEY_PPAGE: int
|
||||||
|
KEY_PREVIOUS: int
|
||||||
|
KEY_PRINT: int
|
||||||
|
KEY_REDO: int
|
||||||
|
KEY_REFERENCE: int
|
||||||
|
KEY_REFRESH: int
|
||||||
|
KEY_REPLACE: int
|
||||||
|
KEY_RESET: int
|
||||||
|
KEY_RESIZE: int
|
||||||
|
KEY_RESTART: int
|
||||||
|
KEY_RESUME: int
|
||||||
|
KEY_RIGHT: int
|
||||||
|
KEY_SAVE: int
|
||||||
|
KEY_SBEG: int
|
||||||
|
KEY_SCANCEL: int
|
||||||
|
KEY_SCOMMAND: int
|
||||||
|
KEY_SCOPY: int
|
||||||
|
KEY_SCREATE: int
|
||||||
|
KEY_SDC: int
|
||||||
|
KEY_SDL: int
|
||||||
|
KEY_SELECT: int
|
||||||
|
KEY_SEND: int
|
||||||
|
KEY_SEOL: int
|
||||||
|
KEY_SEXIT: int
|
||||||
|
KEY_SF: int
|
||||||
|
KEY_SFIND: int
|
||||||
|
KEY_SHELP: int
|
||||||
|
KEY_SHOME: int
|
||||||
|
KEY_SIC: int
|
||||||
|
KEY_SLEFT: int
|
||||||
|
KEY_SMESSAGE: int
|
||||||
|
KEY_SMOVE: int
|
||||||
|
KEY_SNEXT: int
|
||||||
|
KEY_SOPTIONS: int
|
||||||
|
KEY_SPREVIOUS: int
|
||||||
|
KEY_SPRINT: int
|
||||||
|
KEY_SR: int
|
||||||
|
KEY_SREDO: int
|
||||||
|
KEY_SREPLACE: int
|
||||||
|
KEY_SRESET: int
|
||||||
|
KEY_SRIGHT: int
|
||||||
|
KEY_SRSUME: int
|
||||||
|
KEY_SSAVE: int
|
||||||
|
KEY_SSUSPEND: int
|
||||||
|
KEY_STAB: int
|
||||||
|
KEY_SUNDO: int
|
||||||
|
KEY_SUSPEND: int
|
||||||
|
KEY_UNDO: int
|
||||||
|
KEY_UP: int
|
||||||
|
OK: int
|
||||||
|
REPORT_MOUSE_POSITION: int
|
||||||
|
_C_API: Any
|
||||||
|
version: bytes
|
||||||
|
|
||||||
|
def baudrate() -> int: ...
|
||||||
|
def beep() -> None: ...
|
||||||
|
def can_change_color() -> bool: ...
|
||||||
|
def cbreak(flag: bool = True, /) -> None: ...
|
||||||
|
def color_content(color_number: int, /) -> tuple[int, int, int]: ...
|
||||||
|
def color_pair(pair_number: int, /) -> int: ...
|
||||||
|
def curs_set(visibility: int, /) -> int: ...
|
||||||
|
def def_prog_mode() -> None: ...
|
||||||
|
def def_shell_mode() -> None: ...
|
||||||
|
def delay_output(ms: int, /) -> None: ...
|
||||||
|
def doupdate() -> None: ...
|
||||||
|
def echo(flag: bool = True, /) -> None: ...
|
||||||
|
def endwin() -> None: ...
|
||||||
|
def erasechar() -> bytes: ...
|
||||||
|
def filter() -> None: ...
|
||||||
|
def flash() -> None: ...
|
||||||
|
def flushinp() -> None: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
def get_escdelay() -> int: ...
|
||||||
|
def get_tabsize() -> int: ...
|
||||||
|
|
||||||
|
def getmouse() -> tuple[int, int, int, int, int]: ...
|
||||||
|
def getsyx() -> tuple[int, int]: ...
|
||||||
|
def getwin(file: SupportsRead[bytes], /) -> _CursesWindow: ...
|
||||||
|
def halfdelay(tenths: int, /) -> None: ...
|
||||||
|
def has_colors() -> bool: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
def has_extended_color_support() -> bool: ...
|
||||||
|
|
||||||
|
def has_ic() -> bool: ...
|
||||||
|
def has_il() -> bool: ...
|
||||||
|
def has_key(key: int, /) -> bool: ...
|
||||||
|
def init_color(color_number: int, r: int, g: int, b: int, /) -> None: ...
|
||||||
|
def init_pair(pair_number: int, fg: int, bg: int, /) -> None: ...
|
||||||
|
def initscr() -> _CursesWindow: ...
|
||||||
|
def intrflush(flag: bool, /) -> None: ...
|
||||||
|
def is_term_resized(nlines: int, ncols: int, /) -> bool: ...
|
||||||
|
def isendwin() -> bool: ...
|
||||||
|
def keyname(key: int, /) -> bytes: ...
|
||||||
|
def killchar() -> bytes: ...
|
||||||
|
def longname() -> bytes: ...
|
||||||
|
def meta(yes: bool, /) -> None: ...
|
||||||
|
def mouseinterval(interval: int, /) -> None: ...
|
||||||
|
def mousemask(newmask: int, /) -> tuple[int, int]: ...
|
||||||
|
def napms(ms: int, /) -> int: ...
|
||||||
|
def newpad(nlines: int, ncols: int, /) -> _CursesWindow: ...
|
||||||
|
def newwin(nlines: int, ncols: int, begin_y: int = ..., begin_x: int = ..., /) -> _CursesWindow: ...
|
||||||
|
def nl(flag: bool = True, /) -> None: ...
|
||||||
|
def nocbreak() -> None: ...
|
||||||
|
def noecho() -> None: ...
|
||||||
|
def nonl() -> None: ...
|
||||||
|
def noqiflush() -> None: ...
|
||||||
|
def noraw() -> None: ...
|
||||||
|
def pair_content(pair_number: int, /) -> tuple[int, int]: ...
|
||||||
|
def pair_number(attr: int, /) -> int: ...
|
||||||
|
def putp(string: ReadOnlyBuffer, /) -> None: ...
|
||||||
|
def qiflush(flag: bool = True, /) -> None: ...
|
||||||
|
def raw(flag: bool = True, /) -> None: ...
|
||||||
|
def reset_prog_mode() -> None: ...
|
||||||
|
def reset_shell_mode() -> None: ...
|
||||||
|
def resetty() -> None: ...
|
||||||
|
def resize_term(nlines: int, ncols: int, /) -> None: ...
|
||||||
|
def resizeterm(nlines: int, ncols: int, /) -> None: ...
|
||||||
|
def savetty() -> None: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
def set_escdelay(ms: int, /) -> None: ...
|
||||||
|
def set_tabsize(size: int, /) -> None: ...
|
||||||
|
|
||||||
|
def setsyx(y: int, x: int, /) -> None: ...
|
||||||
|
def setupterm(term: str | None = None, fd: int = -1) -> None: ...
|
||||||
|
def start_color() -> None: ...
|
||||||
|
def termattrs() -> int: ...
|
||||||
|
def termname() -> bytes: ...
|
||||||
|
def tigetflag(capname: str, /) -> int: ...
|
||||||
|
def tigetnum(capname: str, /) -> int: ...
|
||||||
|
def tigetstr(capname: str, /) -> bytes | None: ...
|
||||||
|
def tparm(
|
||||||
|
str: ReadOnlyBuffer,
|
||||||
|
i1: int = 0,
|
||||||
|
i2: int = 0,
|
||||||
|
i3: int = 0,
|
||||||
|
i4: int = 0,
|
||||||
|
i5: int = 0,
|
||||||
|
i6: int = 0,
|
||||||
|
i7: int = 0,
|
||||||
|
i8: int = 0,
|
||||||
|
i9: int = 0,
|
||||||
|
/,
|
||||||
|
) -> bytes: ...
|
||||||
|
def typeahead(fd: int, /) -> None: ...
|
||||||
|
def unctrl(ch: _ChType, /) -> bytes: ...
|
||||||
|
|
||||||
|
if sys.version_info < (3, 12) or sys.platform != "darwin":
|
||||||
|
# The support for macos was dropped in 3.12
|
||||||
|
def unget_wch(ch: int | str, /) -> None: ...
|
||||||
|
|
||||||
|
def ungetch(ch: _ChType, /) -> None: ...
|
||||||
|
def ungetmouse(id: int, x: int, y: int, z: int, bstate: int, /) -> None: ...
|
||||||
|
def update_lines_cols() -> None: ...
|
||||||
|
def use_default_colors() -> None: ...
|
||||||
|
def use_env(flag: bool, /) -> None: ...
|
||||||
|
|
||||||
|
class error(Exception): ...
|
||||||
|
|
||||||
|
@final
|
||||||
|
class _CursesWindow:
|
||||||
|
encoding: str
|
||||||
|
@overload
|
||||||
|
def addch(self, ch: _ChType, attr: int = ...) -> None: ...
|
||||||
|
@overload
|
||||||
|
def addch(self, y: int, x: int, ch: _ChType, attr: int = ...) -> None: ...
|
||||||
|
@overload
|
||||||
|
def addnstr(self, str: str, n: int, attr: int = ...) -> None: ...
|
||||||
|
@overload
|
||||||
|
def addnstr(self, y: int, x: int, str: str, n: int, attr: int = ...) -> None: ...
|
||||||
|
@overload
|
||||||
|
def addstr(self, str: str, attr: int = ...) -> None: ...
|
||||||
|
@overload
|
||||||
|
def addstr(self, y: int, x: int, str: str, attr: int = ...) -> None: ...
|
||||||
|
def attroff(self, attr: int, /) -> None: ...
|
||||||
|
def attron(self, attr: int, /) -> None: ...
|
||||||
|
def attrset(self, attr: int, /) -> None: ...
|
||||||
|
def bkgd(self, ch: _ChType, attr: int = ..., /) -> None: ...
|
||||||
|
def bkgdset(self, ch: _ChType, attr: int = ..., /) -> None: ...
|
||||||
|
def border(
|
||||||
|
self,
|
||||||
|
ls: _ChType = ...,
|
||||||
|
rs: _ChType = ...,
|
||||||
|
ts: _ChType = ...,
|
||||||
|
bs: _ChType = ...,
|
||||||
|
tl: _ChType = ...,
|
||||||
|
tr: _ChType = ...,
|
||||||
|
bl: _ChType = ...,
|
||||||
|
br: _ChType = ...,
|
||||||
|
) -> None: ...
|
||||||
|
@overload
|
||||||
|
def box(self) -> None: ...
|
||||||
|
@overload
|
||||||
|
def box(self, vertch: _ChType = ..., horch: _ChType = ...) -> None: ...
|
||||||
|
@overload
|
||||||
|
def chgat(self, attr: int) -> None: ...
|
||||||
|
@overload
|
||||||
|
def chgat(self, num: int, attr: int) -> None: ...
|
||||||
|
@overload
|
||||||
|
def chgat(self, y: int, x: int, attr: int) -> None: ...
|
||||||
|
@overload
|
||||||
|
def chgat(self, y: int, x: int, num: int, attr: int) -> None: ...
|
||||||
|
def clear(self) -> None: ...
|
||||||
|
def clearok(self, yes: int) -> None: ...
|
||||||
|
def clrtobot(self) -> None: ...
|
||||||
|
def clrtoeol(self) -> None: ...
|
||||||
|
def cursyncup(self) -> None: ...
|
||||||
|
@overload
|
||||||
|
def delch(self) -> None: ...
|
||||||
|
@overload
|
||||||
|
def delch(self, y: int, x: int) -> None: ...
|
||||||
|
def deleteln(self) -> None: ...
|
||||||
|
@overload
|
||||||
|
def derwin(self, begin_y: int, begin_x: int) -> _CursesWindow: ...
|
||||||
|
@overload
|
||||||
|
def derwin(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> _CursesWindow: ...
|
||||||
|
def echochar(self, ch: _ChType, attr: int = ..., /) -> None: ...
|
||||||
|
def enclose(self, y: int, x: int, /) -> bool: ...
|
||||||
|
def erase(self) -> None: ...
|
||||||
|
def getbegyx(self) -> tuple[int, int]: ...
|
||||||
|
def getbkgd(self) -> tuple[int, int]: ...
|
||||||
|
@overload
|
||||||
|
def getch(self) -> int: ...
|
||||||
|
@overload
|
||||||
|
def getch(self, y: int, x: int) -> int: ...
|
||||||
|
if sys.version_info < (3, 12) or sys.platform != "darwin":
|
||||||
|
# The support for macos was dropped in 3.12
|
||||||
|
@overload
|
||||||
|
def get_wch(self) -> int | str: ...
|
||||||
|
@overload
|
||||||
|
def get_wch(self, y: int, x: int) -> int | str: ...
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def getkey(self) -> str: ...
|
||||||
|
@overload
|
||||||
|
def getkey(self, y: int, x: int) -> str: ...
|
||||||
|
def getmaxyx(self) -> tuple[int, int]: ...
|
||||||
|
def getparyx(self) -> tuple[int, int]: ...
|
||||||
|
@overload
|
||||||
|
def getstr(self) -> bytes: ...
|
||||||
|
@overload
|
||||||
|
def getstr(self, n: int) -> bytes: ...
|
||||||
|
@overload
|
||||||
|
def getstr(self, y: int, x: int) -> bytes: ...
|
||||||
|
@overload
|
||||||
|
def getstr(self, y: int, x: int, n: int) -> bytes: ...
|
||||||
|
def getyx(self) -> tuple[int, int]: ...
|
||||||
|
@overload
|
||||||
|
def hline(self, ch: _ChType, n: int) -> None: ...
|
||||||
|
@overload
|
||||||
|
def hline(self, y: int, x: int, ch: _ChType, n: int) -> None: ...
|
||||||
|
def idcok(self, flag: bool) -> None: ...
|
||||||
|
def idlok(self, yes: bool) -> None: ...
|
||||||
|
def immedok(self, flag: bool) -> None: ...
|
||||||
|
@overload
|
||||||
|
def inch(self) -> int: ...
|
||||||
|
@overload
|
||||||
|
def inch(self, y: int, x: int) -> int: ...
|
||||||
|
@overload
|
||||||
|
def insch(self, ch: _ChType, attr: int = ...) -> None: ...
|
||||||
|
@overload
|
||||||
|
def insch(self, y: int, x: int, ch: _ChType, attr: int = ...) -> None: ...
|
||||||
|
def insdelln(self, nlines: int) -> None: ...
|
||||||
|
def insertln(self) -> None: ...
|
||||||
|
@overload
|
||||||
|
def insnstr(self, str: str, n: int, attr: int = ...) -> None: ...
|
||||||
|
@overload
|
||||||
|
def insnstr(self, y: int, x: int, str: str, n: int, attr: int = ...) -> None: ...
|
||||||
|
@overload
|
||||||
|
def insstr(self, str: str, attr: int = ...) -> None: ...
|
||||||
|
@overload
|
||||||
|
def insstr(self, y: int, x: int, str: str, attr: int = ...) -> None: ...
|
||||||
|
@overload
|
||||||
|
def instr(self, n: int = ...) -> bytes: ...
|
||||||
|
@overload
|
||||||
|
def instr(self, y: int, x: int, n: int = ...) -> bytes: ...
|
||||||
|
def is_linetouched(self, line: int, /) -> bool: ...
|
||||||
|
def is_wintouched(self) -> bool: ...
|
||||||
|
def keypad(self, yes: bool) -> None: ...
|
||||||
|
def leaveok(self, yes: bool) -> None: ...
|
||||||
|
def move(self, new_y: int, new_x: int) -> None: ...
|
||||||
|
def mvderwin(self, y: int, x: int) -> None: ...
|
||||||
|
def mvwin(self, new_y: int, new_x: int) -> None: ...
|
||||||
|
def nodelay(self, yes: bool) -> None: ...
|
||||||
|
def notimeout(self, yes: bool) -> None: ...
|
||||||
|
@overload
|
||||||
|
def noutrefresh(self) -> None: ...
|
||||||
|
@overload
|
||||||
|
def noutrefresh(self, pminrow: int, pmincol: int, sminrow: int, smincol: int, smaxrow: int, smaxcol: int) -> None: ...
|
||||||
|
@overload
|
||||||
|
def overlay(self, destwin: _CursesWindow) -> None: ...
|
||||||
|
@overload
|
||||||
|
def overlay(
|
||||||
|
self, destwin: _CursesWindow, sminrow: int, smincol: int, dminrow: int, dmincol: int, dmaxrow: int, dmaxcol: int
|
||||||
|
) -> None: ...
|
||||||
|
@overload
|
||||||
|
def overwrite(self, destwin: _CursesWindow) -> None: ...
|
||||||
|
@overload
|
||||||
|
def overwrite(
|
||||||
|
self, destwin: _CursesWindow, sminrow: int, smincol: int, dminrow: int, dmincol: int, dmaxrow: int, dmaxcol: int
|
||||||
|
) -> None: ...
|
||||||
|
def putwin(self, file: IO[Any], /) -> None: ...
|
||||||
|
def redrawln(self, beg: int, num: int, /) -> None: ...
|
||||||
|
def redrawwin(self) -> None: ...
|
||||||
|
@overload
|
||||||
|
def refresh(self) -> None: ...
|
||||||
|
@overload
|
||||||
|
def refresh(self, pminrow: int, pmincol: int, sminrow: int, smincol: int, smaxrow: int, smaxcol: int) -> None: ...
|
||||||
|
def resize(self, nlines: int, ncols: int) -> None: ...
|
||||||
|
def scroll(self, lines: int = ...) -> None: ...
|
||||||
|
def scrollok(self, flag: bool) -> None: ...
|
||||||
|
def setscrreg(self, top: int, bottom: int, /) -> None: ...
|
||||||
|
def standend(self) -> None: ...
|
||||||
|
def standout(self) -> None: ...
|
||||||
|
@overload
|
||||||
|
def subpad(self, begin_y: int, begin_x: int) -> _CursesWindow: ...
|
||||||
|
@overload
|
||||||
|
def subpad(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> _CursesWindow: ...
|
||||||
|
@overload
|
||||||
|
def subwin(self, begin_y: int, begin_x: int) -> _CursesWindow: ...
|
||||||
|
@overload
|
||||||
|
def subwin(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> _CursesWindow: ...
|
||||||
|
def syncdown(self) -> None: ...
|
||||||
|
def syncok(self, flag: bool) -> None: ...
|
||||||
|
def syncup(self) -> None: ...
|
||||||
|
def timeout(self, delay: int) -> None: ...
|
||||||
|
def touchline(self, start: int, count: int, changed: bool = ...) -> None: ...
|
||||||
|
def touchwin(self) -> None: ...
|
||||||
|
def untouchwin(self) -> None: ...
|
||||||
|
@overload
|
||||||
|
def vline(self, ch: _ChType, n: int) -> None: ...
|
||||||
|
@overload
|
||||||
|
def vline(self, y: int, x: int, ch: _ChType, n: int) -> None: ...
|
||||||
|
|
||||||
|
class _ncurses_version(NamedTuple):
|
||||||
|
major: int
|
||||||
|
minor: int
|
||||||
|
patch: int
|
||||||
|
|
||||||
|
ncurses_version: _ncurses_version
|
||||||
|
window = _CursesWindow # undocumented
|
||||||
|
|
@ -0,0 +1,281 @@
|
||||||
|
import numbers
|
||||||
|
import sys
|
||||||
|
from collections.abc import Container, Sequence
|
||||||
|
from types import TracebackType
|
||||||
|
from typing import Any, ClassVar, Final, Literal, NamedTuple, overload
|
||||||
|
from typing_extensions import Self, TypeAlias
|
||||||
|
|
||||||
|
_Decimal: TypeAlias = Decimal | int
|
||||||
|
_DecimalNew: TypeAlias = Decimal | float | str | tuple[int, Sequence[int], int]
|
||||||
|
_ComparableNum: TypeAlias = Decimal | float | numbers.Rational
|
||||||
|
|
||||||
|
__version__: Final[str]
|
||||||
|
__libmpdec_version__: Final[str]
|
||||||
|
|
||||||
|
class DecimalTuple(NamedTuple):
|
||||||
|
sign: int
|
||||||
|
digits: tuple[int, ...]
|
||||||
|
exponent: int | Literal["n", "N", "F"]
|
||||||
|
|
||||||
|
ROUND_DOWN: str
|
||||||
|
ROUND_HALF_UP: str
|
||||||
|
ROUND_HALF_EVEN: str
|
||||||
|
ROUND_CEILING: str
|
||||||
|
ROUND_FLOOR: str
|
||||||
|
ROUND_UP: str
|
||||||
|
ROUND_HALF_DOWN: str
|
||||||
|
ROUND_05UP: str
|
||||||
|
HAVE_CONTEXTVAR: bool
|
||||||
|
HAVE_THREADS: bool
|
||||||
|
MAX_EMAX: int
|
||||||
|
MAX_PREC: int
|
||||||
|
MIN_EMIN: int
|
||||||
|
MIN_ETINY: int
|
||||||
|
|
||||||
|
class DecimalException(ArithmeticError): ...
|
||||||
|
class Clamped(DecimalException): ...
|
||||||
|
class InvalidOperation(DecimalException): ...
|
||||||
|
class ConversionSyntax(InvalidOperation): ...
|
||||||
|
class DivisionByZero(DecimalException, ZeroDivisionError): ...
|
||||||
|
class DivisionImpossible(InvalidOperation): ...
|
||||||
|
class DivisionUndefined(InvalidOperation, ZeroDivisionError): ...
|
||||||
|
class Inexact(DecimalException): ...
|
||||||
|
class InvalidContext(InvalidOperation): ...
|
||||||
|
class Rounded(DecimalException): ...
|
||||||
|
class Subnormal(DecimalException): ...
|
||||||
|
class Overflow(Inexact, Rounded): ...
|
||||||
|
class Underflow(Inexact, Rounded, Subnormal): ...
|
||||||
|
class FloatOperation(DecimalException, TypeError): ...
|
||||||
|
|
||||||
|
def setcontext(context: Context, /) -> None: ...
|
||||||
|
def getcontext() -> Context: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
def localcontext(
|
||||||
|
ctx: Context | None = None,
|
||||||
|
*,
|
||||||
|
prec: int | None = ...,
|
||||||
|
rounding: str | None = ...,
|
||||||
|
Emin: int | None = ...,
|
||||||
|
Emax: int | None = ...,
|
||||||
|
capitals: int | None = ...,
|
||||||
|
clamp: int | None = ...,
|
||||||
|
traps: dict[_TrapType, bool] | None = ...,
|
||||||
|
flags: dict[_TrapType, bool] | None = ...,
|
||||||
|
) -> _ContextManager: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
def localcontext(ctx: Context | None = None) -> _ContextManager: ...
|
||||||
|
|
||||||
|
class Decimal:
|
||||||
|
def __new__(cls, value: _DecimalNew = ..., context: Context | None = ...) -> Self: ...
|
||||||
|
@classmethod
|
||||||
|
def from_float(cls, f: float, /) -> Self: ...
|
||||||
|
def __bool__(self) -> bool: ...
|
||||||
|
def compare(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
|
||||||
|
def __hash__(self) -> int: ...
|
||||||
|
def as_tuple(self) -> DecimalTuple: ...
|
||||||
|
def as_integer_ratio(self) -> tuple[int, int]: ...
|
||||||
|
def to_eng_string(self, context: Context | None = None) -> str: ...
|
||||||
|
def __abs__(self) -> Decimal: ...
|
||||||
|
def __add__(self, value: _Decimal, /) -> Decimal: ...
|
||||||
|
def __divmod__(self, value: _Decimal, /) -> tuple[Decimal, Decimal]: ...
|
||||||
|
def __eq__(self, value: object, /) -> bool: ...
|
||||||
|
def __floordiv__(self, value: _Decimal, /) -> Decimal: ...
|
||||||
|
def __ge__(self, value: _ComparableNum, /) -> bool: ...
|
||||||
|
def __gt__(self, value: _ComparableNum, /) -> bool: ...
|
||||||
|
def __le__(self, value: _ComparableNum, /) -> bool: ...
|
||||||
|
def __lt__(self, value: _ComparableNum, /) -> bool: ...
|
||||||
|
def __mod__(self, value: _Decimal, /) -> Decimal: ...
|
||||||
|
def __mul__(self, value: _Decimal, /) -> Decimal: ...
|
||||||
|
def __neg__(self) -> Decimal: ...
|
||||||
|
def __pos__(self) -> Decimal: ...
|
||||||
|
def __pow__(self, value: _Decimal, mod: _Decimal | None = None, /) -> Decimal: ...
|
||||||
|
def __radd__(self, value: _Decimal, /) -> Decimal: ...
|
||||||
|
def __rdivmod__(self, value: _Decimal, /) -> tuple[Decimal, Decimal]: ...
|
||||||
|
def __rfloordiv__(self, value: _Decimal, /) -> Decimal: ...
|
||||||
|
def __rmod__(self, value: _Decimal, /) -> Decimal: ...
|
||||||
|
def __rmul__(self, value: _Decimal, /) -> Decimal: ...
|
||||||
|
def __rsub__(self, value: _Decimal, /) -> Decimal: ...
|
||||||
|
def __rtruediv__(self, value: _Decimal, /) -> Decimal: ...
|
||||||
|
def __sub__(self, value: _Decimal, /) -> Decimal: ...
|
||||||
|
def __truediv__(self, value: _Decimal, /) -> Decimal: ...
|
||||||
|
def remainder_near(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
|
||||||
|
def __float__(self) -> float: ...
|
||||||
|
def __int__(self) -> int: ...
|
||||||
|
def __trunc__(self) -> int: ...
|
||||||
|
@property
|
||||||
|
def real(self) -> Decimal: ...
|
||||||
|
@property
|
||||||
|
def imag(self) -> Decimal: ...
|
||||||
|
def conjugate(self) -> Decimal: ...
|
||||||
|
def __complex__(self) -> complex: ...
|
||||||
|
@overload
|
||||||
|
def __round__(self) -> int: ...
|
||||||
|
@overload
|
||||||
|
def __round__(self, ndigits: int, /) -> Decimal: ...
|
||||||
|
def __floor__(self) -> int: ...
|
||||||
|
def __ceil__(self) -> int: ...
|
||||||
|
def fma(self, other: _Decimal, third: _Decimal, context: Context | None = None) -> Decimal: ...
|
||||||
|
def __rpow__(self, value: _Decimal, mod: Context | None = None, /) -> Decimal: ...
|
||||||
|
def normalize(self, context: Context | None = None) -> Decimal: ...
|
||||||
|
def quantize(self, exp: _Decimal, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
|
||||||
|
def same_quantum(self, other: _Decimal, context: Context | None = None) -> bool: ...
|
||||||
|
def to_integral_exact(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
|
||||||
|
def to_integral_value(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
|
||||||
|
def to_integral(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
|
||||||
|
def sqrt(self, context: Context | None = None) -> Decimal: ...
|
||||||
|
def max(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
|
||||||
|
def min(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
|
||||||
|
def adjusted(self) -> int: ...
|
||||||
|
def canonical(self) -> Decimal: ...
|
||||||
|
def compare_signal(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
|
||||||
|
def compare_total(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
|
||||||
|
def compare_total_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
|
||||||
|
def copy_abs(self) -> Decimal: ...
|
||||||
|
def copy_negate(self) -> Decimal: ...
|
||||||
|
def copy_sign(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
|
||||||
|
def exp(self, context: Context | None = None) -> Decimal: ...
|
||||||
|
def is_canonical(self) -> bool: ...
|
||||||
|
def is_finite(self) -> bool: ...
|
||||||
|
def is_infinite(self) -> bool: ...
|
||||||
|
def is_nan(self) -> bool: ...
|
||||||
|
def is_normal(self, context: Context | None = None) -> bool: ...
|
||||||
|
def is_qnan(self) -> bool: ...
|
||||||
|
def is_signed(self) -> bool: ...
|
||||||
|
def is_snan(self) -> bool: ...
|
||||||
|
def is_subnormal(self, context: Context | None = None) -> bool: ...
|
||||||
|
def is_zero(self) -> bool: ...
|
||||||
|
def ln(self, context: Context | None = None) -> Decimal: ...
|
||||||
|
def log10(self, context: Context | None = None) -> Decimal: ...
|
||||||
|
def logb(self, context: Context | None = None) -> Decimal: ...
|
||||||
|
def logical_and(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
|
||||||
|
def logical_invert(self, context: Context | None = None) -> Decimal: ...
|
||||||
|
def logical_or(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
|
||||||
|
def logical_xor(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
|
||||||
|
def max_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
|
||||||
|
def min_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
|
||||||
|
def next_minus(self, context: Context | None = None) -> Decimal: ...
|
||||||
|
def next_plus(self, context: Context | None = None) -> Decimal: ...
|
||||||
|
def next_toward(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
|
||||||
|
def number_class(self, context: Context | None = None) -> str: ...
|
||||||
|
def radix(self) -> Decimal: ...
|
||||||
|
def rotate(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
|
||||||
|
def scaleb(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
|
||||||
|
def shift(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
|
||||||
|
def __reduce__(self) -> tuple[type[Self], tuple[str]]: ...
|
||||||
|
def __copy__(self) -> Self: ...
|
||||||
|
def __deepcopy__(self, memo: Any, /) -> Self: ...
|
||||||
|
def __format__(self, specifier: str, context: Context | None = ..., /) -> str: ...
|
||||||
|
|
||||||
|
class _ContextManager:
|
||||||
|
new_context: Context
|
||||||
|
saved_context: Context
|
||||||
|
def __init__(self, new_context: Context) -> None: ...
|
||||||
|
def __enter__(self) -> Context: ...
|
||||||
|
def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
|
||||||
|
|
||||||
|
_TrapType: TypeAlias = type[DecimalException]
|
||||||
|
|
||||||
|
class Context:
|
||||||
|
# TODO: Context doesn't allow you to delete *any* attributes from instances of the class at runtime,
|
||||||
|
# even settable attributes like `prec` and `rounding`,
|
||||||
|
# but that's inexpressable in the stub.
|
||||||
|
# Type checkers either ignore it or misinterpret it
|
||||||
|
# if you add a `def __delattr__(self, name: str, /) -> NoReturn` method to the stub
|
||||||
|
prec: int
|
||||||
|
rounding: str
|
||||||
|
Emin: int
|
||||||
|
Emax: int
|
||||||
|
capitals: int
|
||||||
|
clamp: int
|
||||||
|
traps: dict[_TrapType, bool]
|
||||||
|
flags: dict[_TrapType, bool]
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
prec: int | None = ...,
|
||||||
|
rounding: str | None = ...,
|
||||||
|
Emin: int | None = ...,
|
||||||
|
Emax: int | None = ...,
|
||||||
|
capitals: int | None = ...,
|
||||||
|
clamp: int | None = ...,
|
||||||
|
flags: None | dict[_TrapType, bool] | Container[_TrapType] = ...,
|
||||||
|
traps: None | dict[_TrapType, bool] | Container[_TrapType] = ...,
|
||||||
|
_ignored_flags: list[_TrapType] | None = ...,
|
||||||
|
) -> None: ...
|
||||||
|
def __reduce__(self) -> tuple[type[Self], tuple[Any, ...]]: ...
|
||||||
|
def clear_flags(self) -> None: ...
|
||||||
|
def clear_traps(self) -> None: ...
|
||||||
|
def copy(self) -> Context: ...
|
||||||
|
def __copy__(self) -> Context: ...
|
||||||
|
# see https://github.com/python/cpython/issues/94107
|
||||||
|
__hash__: ClassVar[None] # type: ignore[assignment]
|
||||||
|
def Etiny(self) -> int: ...
|
||||||
|
def Etop(self) -> int: ...
|
||||||
|
def create_decimal(self, num: _DecimalNew = "0", /) -> Decimal: ...
|
||||||
|
def create_decimal_from_float(self, f: float, /) -> Decimal: ...
|
||||||
|
def abs(self, x: _Decimal, /) -> Decimal: ...
|
||||||
|
def add(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def canonical(self, x: Decimal, /) -> Decimal: ...
|
||||||
|
def compare(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def compare_signal(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def compare_total(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def compare_total_mag(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def copy_abs(self, x: _Decimal, /) -> Decimal: ...
|
||||||
|
def copy_decimal(self, x: _Decimal, /) -> Decimal: ...
|
||||||
|
def copy_negate(self, x: _Decimal, /) -> Decimal: ...
|
||||||
|
def copy_sign(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def divide(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def divide_int(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def divmod(self, x: _Decimal, y: _Decimal, /) -> tuple[Decimal, Decimal]: ...
|
||||||
|
def exp(self, x: _Decimal, /) -> Decimal: ...
|
||||||
|
def fma(self, x: _Decimal, y: _Decimal, z: _Decimal, /) -> Decimal: ...
|
||||||
|
def is_canonical(self, x: _Decimal, /) -> bool: ...
|
||||||
|
def is_finite(self, x: _Decimal, /) -> bool: ...
|
||||||
|
def is_infinite(self, x: _Decimal, /) -> bool: ...
|
||||||
|
def is_nan(self, x: _Decimal, /) -> bool: ...
|
||||||
|
def is_normal(self, x: _Decimal, /) -> bool: ...
|
||||||
|
def is_qnan(self, x: _Decimal, /) -> bool: ...
|
||||||
|
def is_signed(self, x: _Decimal, /) -> bool: ...
|
||||||
|
def is_snan(self, x: _Decimal, /) -> bool: ...
|
||||||
|
def is_subnormal(self, x: _Decimal, /) -> bool: ...
|
||||||
|
def is_zero(self, x: _Decimal, /) -> bool: ...
|
||||||
|
def ln(self, x: _Decimal, /) -> Decimal: ...
|
||||||
|
def log10(self, x: _Decimal, /) -> Decimal: ...
|
||||||
|
def logb(self, x: _Decimal, /) -> Decimal: ...
|
||||||
|
def logical_and(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def logical_invert(self, x: _Decimal, /) -> Decimal: ...
|
||||||
|
def logical_or(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def logical_xor(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def max(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def max_mag(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def min(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def min_mag(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def minus(self, x: _Decimal, /) -> Decimal: ...
|
||||||
|
def multiply(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def next_minus(self, x: _Decimal, /) -> Decimal: ...
|
||||||
|
def next_plus(self, x: _Decimal, /) -> Decimal: ...
|
||||||
|
def next_toward(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def normalize(self, x: _Decimal, /) -> Decimal: ...
|
||||||
|
def number_class(self, x: _Decimal, /) -> str: ...
|
||||||
|
def plus(self, x: _Decimal, /) -> Decimal: ...
|
||||||
|
def power(self, a: _Decimal, b: _Decimal, modulo: _Decimal | None = None) -> Decimal: ...
|
||||||
|
def quantize(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def radix(self) -> Decimal: ...
|
||||||
|
def remainder(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def remainder_near(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def rotate(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def same_quantum(self, x: _Decimal, y: _Decimal, /) -> bool: ...
|
||||||
|
def scaleb(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def shift(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def sqrt(self, x: _Decimal, /) -> Decimal: ...
|
||||||
|
def subtract(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
|
||||||
|
def to_eng_string(self, x: _Decimal, /) -> str: ...
|
||||||
|
def to_sci_string(self, x: _Decimal, /) -> str: ...
|
||||||
|
def to_integral_exact(self, x: _Decimal, /) -> Decimal: ...
|
||||||
|
def to_integral_value(self, x: _Decimal, /) -> Decimal: ...
|
||||||
|
def to_integral(self, x: _Decimal, /) -> Decimal: ...
|
||||||
|
|
||||||
|
DefaultContext: Context
|
||||||
|
BasicContext: Context
|
||||||
|
ExtendedContext: Context
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
from collections.abc import Callable
|
||||||
|
from types import TracebackType
|
||||||
|
from typing import Any, NoReturn, overload
|
||||||
|
from typing_extensions import TypeVarTuple, Unpack
|
||||||
|
|
||||||
|
__all__ = ["error", "start_new_thread", "exit", "get_ident", "allocate_lock", "interrupt_main", "LockType", "RLock"]
|
||||||
|
|
||||||
|
_Ts = TypeVarTuple("_Ts")
|
||||||
|
|
||||||
|
TIMEOUT_MAX: int
|
||||||
|
error = RuntimeError
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def start_new_thread(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]]) -> None: ...
|
||||||
|
@overload
|
||||||
|
def start_new_thread(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any]) -> None: ...
|
||||||
|
def exit() -> NoReturn: ...
|
||||||
|
def get_ident() -> int: ...
|
||||||
|
def allocate_lock() -> LockType: ...
|
||||||
|
def stack_size(size: int | None = None) -> int: ...
|
||||||
|
|
||||||
|
class LockType:
|
||||||
|
locked_status: bool
|
||||||
|
def acquire(self, waitflag: bool | None = None, timeout: int = -1) -> bool: ...
|
||||||
|
def __enter__(self, waitflag: bool | None = None, timeout: int = -1) -> bool: ...
|
||||||
|
def __exit__(self, typ: type[BaseException] | None, val: BaseException | None, tb: TracebackType | None) -> None: ...
|
||||||
|
def release(self) -> bool: ...
|
||||||
|
def locked(self) -> bool: ...
|
||||||
|
|
||||||
|
class RLock(LockType):
|
||||||
|
def release(self) -> None: ... # type: ignore[override]
|
||||||
|
|
||||||
|
def interrupt_main() -> None: ...
|
||||||
|
|
@ -0,0 +1,164 @@
|
||||||
|
import sys
|
||||||
|
from _thread import _excepthook, _ExceptHookArgs
|
||||||
|
from _typeshed import ProfileFunction, TraceFunction
|
||||||
|
from collections.abc import Callable, Iterable, Mapping
|
||||||
|
from types import TracebackType
|
||||||
|
from typing import Any, TypeVar
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"get_ident",
|
||||||
|
"active_count",
|
||||||
|
"Condition",
|
||||||
|
"current_thread",
|
||||||
|
"enumerate",
|
||||||
|
"main_thread",
|
||||||
|
"TIMEOUT_MAX",
|
||||||
|
"Event",
|
||||||
|
"Lock",
|
||||||
|
"RLock",
|
||||||
|
"Semaphore",
|
||||||
|
"BoundedSemaphore",
|
||||||
|
"Thread",
|
||||||
|
"Barrier",
|
||||||
|
"BrokenBarrierError",
|
||||||
|
"Timer",
|
||||||
|
"ThreadError",
|
||||||
|
"setprofile",
|
||||||
|
"settrace",
|
||||||
|
"local",
|
||||||
|
"stack_size",
|
||||||
|
"ExceptHookArgs",
|
||||||
|
"excepthook",
|
||||||
|
]
|
||||||
|
|
||||||
|
def active_count() -> int: ...
|
||||||
|
def current_thread() -> Thread: ...
|
||||||
|
def currentThread() -> Thread: ...
|
||||||
|
def get_ident() -> int: ...
|
||||||
|
def enumerate() -> list[Thread]: ...
|
||||||
|
def main_thread() -> Thread: ...
|
||||||
|
def settrace(func: TraceFunction) -> None: ...
|
||||||
|
def setprofile(func: ProfileFunction | None) -> None: ...
|
||||||
|
def stack_size(size: int | None = None) -> int: ...
|
||||||
|
|
||||||
|
TIMEOUT_MAX: float
|
||||||
|
|
||||||
|
class ThreadError(Exception): ...
|
||||||
|
|
||||||
|
class local:
|
||||||
|
def __getattribute__(self, name: str) -> Any: ...
|
||||||
|
def __setattr__(self, name: str, value: Any) -> None: ...
|
||||||
|
def __delattr__(self, name: str) -> None: ...
|
||||||
|
|
||||||
|
class Thread:
|
||||||
|
name: str
|
||||||
|
daemon: bool
|
||||||
|
@property
|
||||||
|
def ident(self) -> int | None: ...
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
group: None = None,
|
||||||
|
target: Callable[..., object] | None = None,
|
||||||
|
name: str | None = None,
|
||||||
|
args: Iterable[Any] = (),
|
||||||
|
kwargs: Mapping[str, Any] | None = None,
|
||||||
|
*,
|
||||||
|
daemon: bool | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
def start(self) -> None: ...
|
||||||
|
def run(self) -> None: ...
|
||||||
|
def join(self, timeout: float | None = None) -> None: ...
|
||||||
|
def getName(self) -> str: ...
|
||||||
|
def setName(self, name: str) -> None: ...
|
||||||
|
@property
|
||||||
|
def native_id(self) -> int | None: ... # only available on some platforms
|
||||||
|
def is_alive(self) -> bool: ...
|
||||||
|
if sys.version_info < (3, 9):
|
||||||
|
def isAlive(self) -> bool: ...
|
||||||
|
|
||||||
|
def isDaemon(self) -> bool: ...
|
||||||
|
def setDaemon(self, daemonic: bool) -> None: ...
|
||||||
|
|
||||||
|
class _DummyThread(Thread): ...
|
||||||
|
|
||||||
|
class Lock:
|
||||||
|
def __enter__(self) -> bool: ...
|
||||||
|
def __exit__(
|
||||||
|
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||||
|
) -> bool | None: ...
|
||||||
|
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
|
||||||
|
def release(self) -> None: ...
|
||||||
|
def locked(self) -> bool: ...
|
||||||
|
|
||||||
|
class _RLock:
|
||||||
|
def __enter__(self) -> bool: ...
|
||||||
|
def __exit__(
|
||||||
|
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||||
|
) -> bool | None: ...
|
||||||
|
def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ...
|
||||||
|
def release(self) -> None: ...
|
||||||
|
|
||||||
|
RLock = _RLock
|
||||||
|
|
||||||
|
class Condition:
|
||||||
|
def __init__(self, lock: Lock | _RLock | None = None) -> None: ...
|
||||||
|
def __enter__(self) -> bool: ...
|
||||||
|
def __exit__(
|
||||||
|
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||||
|
) -> bool | None: ...
|
||||||
|
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
|
||||||
|
def release(self) -> None: ...
|
||||||
|
def wait(self, timeout: float | None = None) -> bool: ...
|
||||||
|
def wait_for(self, predicate: Callable[[], _T], timeout: float | None = None) -> _T: ...
|
||||||
|
def notify(self, n: int = 1) -> None: ...
|
||||||
|
def notify_all(self) -> None: ...
|
||||||
|
def notifyAll(self) -> None: ...
|
||||||
|
|
||||||
|
class Semaphore:
|
||||||
|
def __init__(self, value: int = 1) -> None: ...
|
||||||
|
def __exit__(
|
||||||
|
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||||
|
) -> bool | None: ...
|
||||||
|
def acquire(self, blocking: bool = True, timeout: float | None = None) -> bool: ...
|
||||||
|
def __enter__(self, blocking: bool = True, timeout: float | None = None) -> bool: ...
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
def release(self, n: int = ...) -> None: ...
|
||||||
|
else:
|
||||||
|
def release(self) -> None: ...
|
||||||
|
|
||||||
|
class BoundedSemaphore(Semaphore): ...
|
||||||
|
|
||||||
|
class Event:
|
||||||
|
def is_set(self) -> bool: ...
|
||||||
|
def set(self) -> None: ...
|
||||||
|
def clear(self) -> None: ...
|
||||||
|
def wait(self, timeout: float | None = None) -> bool: ...
|
||||||
|
|
||||||
|
excepthook = _excepthook
|
||||||
|
ExceptHookArgs = _ExceptHookArgs
|
||||||
|
|
||||||
|
class Timer(Thread):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
interval: float,
|
||||||
|
function: Callable[..., object],
|
||||||
|
args: Iterable[Any] | None = None,
|
||||||
|
kwargs: Mapping[str, Any] | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
def cancel(self) -> None: ...
|
||||||
|
|
||||||
|
class Barrier:
|
||||||
|
@property
|
||||||
|
def parties(self) -> int: ...
|
||||||
|
@property
|
||||||
|
def n_waiting(self) -> int: ...
|
||||||
|
@property
|
||||||
|
def broken(self) -> bool: ...
|
||||||
|
def __init__(self, parties: int, action: Callable[[], None] | None = None, timeout: float | None = None) -> None: ...
|
||||||
|
def wait(self, timeout: float | None = None) -> int: ...
|
||||||
|
def reset(self) -> None: ...
|
||||||
|
def abort(self) -> None: ...
|
||||||
|
|
||||||
|
class BrokenBarrierError(RuntimeError): ...
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
from typing import Any, Final, TypeVar
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
|
||||||
|
__about__: Final[str]
|
||||||
|
|
||||||
|
def heapify(heap: list[Any], /) -> None: ...
|
||||||
|
def heappop(heap: list[_T], /) -> _T: ...
|
||||||
|
def heappush(heap: list[_T], item: _T, /) -> None: ...
|
||||||
|
def heappushpop(heap: list[_T], item: _T, /) -> _T: ...
|
||||||
|
def heapreplace(heap: list[_T], item: _T, /) -> _T: ...
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
import sys
|
||||||
|
import types
|
||||||
|
from _typeshed import ReadableBuffer
|
||||||
|
from importlib.machinery import ModuleSpec
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
check_hash_based_pycs: str
|
||||||
|
|
||||||
|
def source_hash(key: int, source: ReadableBuffer) -> bytes: ...
|
||||||
|
def create_builtin(spec: ModuleSpec, /) -> types.ModuleType: ...
|
||||||
|
def create_dynamic(spec: ModuleSpec, file: Any = None, /) -> types.ModuleType: ...
|
||||||
|
def acquire_lock() -> None: ...
|
||||||
|
def exec_builtin(mod: types.ModuleType, /) -> int: ...
|
||||||
|
def exec_dynamic(mod: types.ModuleType, /) -> int: ...
|
||||||
|
def extension_suffixes() -> list[str]: ...
|
||||||
|
def init_frozen(name: str, /) -> types.ModuleType: ...
|
||||||
|
def is_builtin(name: str, /) -> int: ...
|
||||||
|
def is_frozen(name: str, /) -> bool: ...
|
||||||
|
def is_frozen_package(name: str, /) -> bool: ...
|
||||||
|
def lock_held() -> bool: ...
|
||||||
|
def release_lock() -> None: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
def find_frozen(name: str, /, *, withdata: bool = False) -> tuple[memoryview | None, bool, str | None] | None: ...
|
||||||
|
def get_frozen_object(name: str, data: ReadableBuffer | None = None, /) -> types.CodeType: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
def get_frozen_object(name: str, /) -> types.CodeType: ...
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
from collections.abc import Callable
|
||||||
|
from typing import Any, final
|
||||||
|
|
||||||
|
@final
|
||||||
|
class make_encoder:
|
||||||
|
@property
|
||||||
|
def sort_keys(self) -> bool: ...
|
||||||
|
@property
|
||||||
|
def skipkeys(self) -> bool: ...
|
||||||
|
@property
|
||||||
|
def key_separator(self) -> str: ...
|
||||||
|
@property
|
||||||
|
def indent(self) -> int | None: ...
|
||||||
|
@property
|
||||||
|
def markers(self) -> dict[int, Any] | None: ...
|
||||||
|
@property
|
||||||
|
def default(self) -> Callable[[Any], Any]: ...
|
||||||
|
@property
|
||||||
|
def encoder(self) -> Callable[[str], str]: ...
|
||||||
|
@property
|
||||||
|
def item_separator(self) -> str: ...
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
markers: dict[int, Any] | None,
|
||||||
|
default: Callable[[Any], Any],
|
||||||
|
encoder: Callable[[str], str],
|
||||||
|
indent: int | None,
|
||||||
|
key_separator: str,
|
||||||
|
item_separator: str,
|
||||||
|
sort_keys: bool,
|
||||||
|
skipkeys: bool,
|
||||||
|
allow_nan: bool,
|
||||||
|
) -> None: ...
|
||||||
|
def __call__(self, obj: object, _current_indent_level: int) -> Any: ...
|
||||||
|
|
||||||
|
@final
|
||||||
|
class make_scanner:
|
||||||
|
object_hook: Any
|
||||||
|
object_pairs_hook: Any
|
||||||
|
parse_int: Any
|
||||||
|
parse_constant: Any
|
||||||
|
parse_float: Any
|
||||||
|
strict: bool
|
||||||
|
# TODO: 'context' needs the attrs above (ducktype), but not __call__.
|
||||||
|
def __init__(self, context: make_scanner) -> None: ...
|
||||||
|
def __call__(self, string: str, index: int) -> tuple[Any, int]: ...
|
||||||
|
|
||||||
|
def encode_basestring_ascii(s: str) -> str: ...
|
||||||
|
def scanstring(string: str, end: int, strict: bool = ...) -> tuple[str, int]: ...
|
||||||
|
|
@ -0,0 +1,100 @@
|
||||||
|
import sys
|
||||||
|
from _typeshed import StrPath
|
||||||
|
from collections.abc import Mapping
|
||||||
|
|
||||||
|
LC_CTYPE: int
|
||||||
|
LC_COLLATE: int
|
||||||
|
LC_TIME: int
|
||||||
|
LC_MONETARY: int
|
||||||
|
LC_NUMERIC: int
|
||||||
|
LC_ALL: int
|
||||||
|
CHAR_MAX: int
|
||||||
|
|
||||||
|
def setlocale(category: int, locale: str | None = None, /) -> str: ...
|
||||||
|
def localeconv() -> Mapping[str, int | str | list[int]]: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
def getencoding() -> str: ...
|
||||||
|
|
||||||
|
def strcoll(os1: str, os2: str, /) -> int: ...
|
||||||
|
def strxfrm(string: str, /) -> str: ...
|
||||||
|
|
||||||
|
# native gettext functions
|
||||||
|
# https://docs.python.org/3/library/locale.html#access-to-message-catalogs
|
||||||
|
# https://github.com/python/cpython/blob/f4c03484da59049eb62a9bf7777b963e2267d187/Modules/_localemodule.c#L626
|
||||||
|
if sys.platform != "win32":
|
||||||
|
LC_MESSAGES: int
|
||||||
|
|
||||||
|
ABDAY_1: int
|
||||||
|
ABDAY_2: int
|
||||||
|
ABDAY_3: int
|
||||||
|
ABDAY_4: int
|
||||||
|
ABDAY_5: int
|
||||||
|
ABDAY_6: int
|
||||||
|
ABDAY_7: int
|
||||||
|
|
||||||
|
ABMON_1: int
|
||||||
|
ABMON_2: int
|
||||||
|
ABMON_3: int
|
||||||
|
ABMON_4: int
|
||||||
|
ABMON_5: int
|
||||||
|
ABMON_6: int
|
||||||
|
ABMON_7: int
|
||||||
|
ABMON_8: int
|
||||||
|
ABMON_9: int
|
||||||
|
ABMON_10: int
|
||||||
|
ABMON_11: int
|
||||||
|
ABMON_12: int
|
||||||
|
|
||||||
|
DAY_1: int
|
||||||
|
DAY_2: int
|
||||||
|
DAY_3: int
|
||||||
|
DAY_4: int
|
||||||
|
DAY_5: int
|
||||||
|
DAY_6: int
|
||||||
|
DAY_7: int
|
||||||
|
|
||||||
|
ERA: int
|
||||||
|
ERA_D_T_FMT: int
|
||||||
|
ERA_D_FMT: int
|
||||||
|
ERA_T_FMT: int
|
||||||
|
|
||||||
|
MON_1: int
|
||||||
|
MON_2: int
|
||||||
|
MON_3: int
|
||||||
|
MON_4: int
|
||||||
|
MON_5: int
|
||||||
|
MON_6: int
|
||||||
|
MON_7: int
|
||||||
|
MON_8: int
|
||||||
|
MON_9: int
|
||||||
|
MON_10: int
|
||||||
|
MON_11: int
|
||||||
|
MON_12: int
|
||||||
|
|
||||||
|
CODESET: int
|
||||||
|
D_T_FMT: int
|
||||||
|
D_FMT: int
|
||||||
|
T_FMT: int
|
||||||
|
T_FMT_AMPM: int
|
||||||
|
AM_STR: int
|
||||||
|
PM_STR: int
|
||||||
|
|
||||||
|
RADIXCHAR: int
|
||||||
|
THOUSEP: int
|
||||||
|
YESEXPR: int
|
||||||
|
NOEXPR: int
|
||||||
|
CRNCYSTR: int
|
||||||
|
ALT_DIGITS: int
|
||||||
|
|
||||||
|
def nl_langinfo(key: int, /) -> str: ...
|
||||||
|
|
||||||
|
# This is dependent on `libintl.h` which is a part of `gettext`
|
||||||
|
# system dependency. These functions might be missing.
|
||||||
|
# But, we always say that they are present.
|
||||||
|
def gettext(msg: str, /) -> str: ...
|
||||||
|
def dgettext(domain: str | None, msg: str, /) -> str: ...
|
||||||
|
def dcgettext(domain: str | None, msg: str, category: int, /) -> str: ...
|
||||||
|
def textdomain(domain: str | None, /) -> str: ...
|
||||||
|
def bindtextdomain(domain: str, dir: StrPath | None, /) -> str: ...
|
||||||
|
def bind_textdomain_codeset(domain: str, codeset: str | None, /) -> str | None: ...
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
import sys
|
||||||
|
from _typeshed import structseq
|
||||||
|
from collections.abc import Callable
|
||||||
|
from types import CodeType
|
||||||
|
from typing import Any, Final, final
|
||||||
|
|
||||||
|
class Profiler:
|
||||||
|
def __init__(
|
||||||
|
self, timer: Callable[[], float] | None = None, timeunit: float = 0.0, subcalls: bool = True, builtins: bool = True
|
||||||
|
) -> None: ...
|
||||||
|
def getstats(self) -> list[profiler_entry]: ...
|
||||||
|
def enable(self, subcalls: bool = True, builtins: bool = True) -> None: ...
|
||||||
|
def disable(self) -> None: ...
|
||||||
|
def clear(self) -> None: ...
|
||||||
|
|
||||||
|
@final
|
||||||
|
class profiler_entry(structseq[Any], tuple[CodeType | str, int, int, float, float, list[profiler_subentry]]):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__: Final = ("code", "callcount", "reccallcount", "totaltime", "inlinetime", "calls")
|
||||||
|
code: CodeType | str
|
||||||
|
callcount: int
|
||||||
|
reccallcount: int
|
||||||
|
totaltime: float
|
||||||
|
inlinetime: float
|
||||||
|
calls: list[profiler_subentry]
|
||||||
|
|
||||||
|
@final
|
||||||
|
class profiler_subentry(structseq[Any], tuple[CodeType | str, int, int, float, float]):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__: Final = ("code", "callcount", "reccallcount", "totaltime", "inlinetime")
|
||||||
|
code: CodeType | str
|
||||||
|
callcount: int
|
||||||
|
reccallcount: int
|
||||||
|
totaltime: float
|
||||||
|
inlinetime: float
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
import sys
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class ParserBase:
|
||||||
|
def reset(self) -> None: ...
|
||||||
|
def getpos(self) -> tuple[int, int]: ...
|
||||||
|
def unknown_decl(self, data: str) -> None: ...
|
||||||
|
def parse_comment(self, i: int, report: int = 1) -> int: ... # undocumented
|
||||||
|
def parse_declaration(self, i: int) -> int: ... # undocumented
|
||||||
|
def parse_marked_section(self, i: int, report: int = 1) -> int: ... # undocumented
|
||||||
|
def updatepos(self, i: int, j: int) -> int: ... # undocumented
|
||||||
|
if sys.version_info < (3, 10):
|
||||||
|
# Removed from ParserBase: https://bugs.python.org/issue31844
|
||||||
|
def error(self, message: str) -> Any: ... # undocumented
|
||||||
|
lineno: int # undocumented
|
||||||
|
offset: int # undocumented
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if sys.platform == "win32":
|
||||||
|
class MSIError(Exception): ...
|
||||||
|
# Actual typename View, not exposed by the implementation
|
||||||
|
class _View:
|
||||||
|
def Execute(self, params: _Record | None = ...) -> None: ...
|
||||||
|
def GetColumnInfo(self, kind: int) -> _Record: ...
|
||||||
|
def Fetch(self) -> _Record: ...
|
||||||
|
def Modify(self, mode: int, record: _Record) -> None: ...
|
||||||
|
def Close(self) -> None: ...
|
||||||
|
# Don't exist at runtime
|
||||||
|
__new__: None # type: ignore[assignment]
|
||||||
|
__init__: None # type: ignore[assignment]
|
||||||
|
|
||||||
|
# Actual typename SummaryInformation, not exposed by the implementation
|
||||||
|
class _SummaryInformation:
|
||||||
|
def GetProperty(self, field: int) -> int | bytes | None: ...
|
||||||
|
def GetPropertyCount(self) -> int: ...
|
||||||
|
def SetProperty(self, field: int, value: int | str) -> None: ...
|
||||||
|
def Persist(self) -> None: ...
|
||||||
|
# Don't exist at runtime
|
||||||
|
__new__: None # type: ignore[assignment]
|
||||||
|
__init__: None # type: ignore[assignment]
|
||||||
|
|
||||||
|
# Actual typename Database, not exposed by the implementation
|
||||||
|
class _Database:
|
||||||
|
def OpenView(self, sql: str) -> _View: ...
|
||||||
|
def Commit(self) -> None: ...
|
||||||
|
def GetSummaryInformation(self, updateCount: int) -> _SummaryInformation: ...
|
||||||
|
def Close(self) -> None: ...
|
||||||
|
# Don't exist at runtime
|
||||||
|
__new__: None # type: ignore[assignment]
|
||||||
|
__init__: None # type: ignore[assignment]
|
||||||
|
|
||||||
|
# Actual typename Record, not exposed by the implementation
|
||||||
|
class _Record:
|
||||||
|
def GetFieldCount(self) -> int: ...
|
||||||
|
def GetInteger(self, field: int) -> int: ...
|
||||||
|
def GetString(self, field: int) -> str: ...
|
||||||
|
def SetString(self, field: int, str: str) -> None: ...
|
||||||
|
def SetStream(self, field: int, stream: str) -> None: ...
|
||||||
|
def SetInteger(self, field: int, int: int) -> None: ...
|
||||||
|
def ClearData(self) -> None: ...
|
||||||
|
# Don't exist at runtime
|
||||||
|
__new__: None # type: ignore[assignment]
|
||||||
|
__init__: None # type: ignore[assignment]
|
||||||
|
|
||||||
|
def UuidCreate() -> str: ...
|
||||||
|
def FCICreate(cabname: str, files: list[str], /) -> None: ...
|
||||||
|
def OpenDatabase(path: str, persist: int, /) -> _Database: ...
|
||||||
|
def CreateRecord(count: int, /) -> _Record: ...
|
||||||
|
|
||||||
|
MSICOLINFO_NAMES: int
|
||||||
|
MSICOLINFO_TYPES: int
|
||||||
|
MSIDBOPEN_CREATE: int
|
||||||
|
MSIDBOPEN_CREATEDIRECT: int
|
||||||
|
MSIDBOPEN_DIRECT: int
|
||||||
|
MSIDBOPEN_PATCHFILE: int
|
||||||
|
MSIDBOPEN_READONLY: int
|
||||||
|
MSIDBOPEN_TRANSACT: int
|
||||||
|
MSIMODIFY_ASSIGN: int
|
||||||
|
MSIMODIFY_DELETE: int
|
||||||
|
MSIMODIFY_INSERT: int
|
||||||
|
MSIMODIFY_INSERT_TEMPORARY: int
|
||||||
|
MSIMODIFY_MERGE: int
|
||||||
|
MSIMODIFY_REFRESH: int
|
||||||
|
MSIMODIFY_REPLACE: int
|
||||||
|
MSIMODIFY_SEEK: int
|
||||||
|
MSIMODIFY_UPDATE: int
|
||||||
|
MSIMODIFY_VALIDATE: int
|
||||||
|
MSIMODIFY_VALIDATE_DELETE: int
|
||||||
|
MSIMODIFY_VALIDATE_FIELD: int
|
||||||
|
MSIMODIFY_VALIDATE_NEW: int
|
||||||
|
|
||||||
|
PID_APPNAME: int
|
||||||
|
PID_AUTHOR: int
|
||||||
|
PID_CHARCOUNT: int
|
||||||
|
PID_CODEPAGE: int
|
||||||
|
PID_COMMENTS: int
|
||||||
|
PID_CREATE_DTM: int
|
||||||
|
PID_KEYWORDS: int
|
||||||
|
PID_LASTAUTHOR: int
|
||||||
|
PID_LASTPRINTED: int
|
||||||
|
PID_LASTSAVE_DTM: int
|
||||||
|
PID_PAGECOUNT: int
|
||||||
|
PID_REVNUMBER: int
|
||||||
|
PID_SECURITY: int
|
||||||
|
PID_SUBJECT: int
|
||||||
|
PID_TEMPLATE: int
|
||||||
|
PID_TITLE: int
|
||||||
|
PID_WORDCOUNT: int
|
||||||
|
|
@ -0,0 +1,147 @@
|
||||||
|
import sys
|
||||||
|
from _typeshed import SupportsGetItem
|
||||||
|
from collections.abc import Callable, Container, Iterable, MutableMapping, MutableSequence, Sequence
|
||||||
|
from typing import Any, AnyStr, Generic, Protocol, SupportsAbs, SupportsIndex, TypeVar, final, overload
|
||||||
|
from typing_extensions import ParamSpec, TypeAlias, TypeVarTuple, Unpack
|
||||||
|
|
||||||
|
_R = TypeVar("_R")
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
_T_co = TypeVar("_T_co", covariant=True)
|
||||||
|
_T1 = TypeVar("_T1")
|
||||||
|
_T2 = TypeVar("_T2")
|
||||||
|
_K = TypeVar("_K")
|
||||||
|
_V = TypeVar("_V")
|
||||||
|
_P = ParamSpec("_P")
|
||||||
|
_Ts = TypeVarTuple("_Ts")
|
||||||
|
|
||||||
|
# The following protocols return "Any" instead of bool, since the comparison
|
||||||
|
# operators can be overloaded to return an arbitrary object. For example,
|
||||||
|
# the numpy.array comparison dunders return another numpy.array.
|
||||||
|
|
||||||
|
class _SupportsDunderLT(Protocol):
|
||||||
|
def __lt__(self, other: Any, /) -> Any: ...
|
||||||
|
|
||||||
|
class _SupportsDunderGT(Protocol):
|
||||||
|
def __gt__(self, other: Any, /) -> Any: ...
|
||||||
|
|
||||||
|
class _SupportsDunderLE(Protocol):
|
||||||
|
def __le__(self, other: Any, /) -> Any: ...
|
||||||
|
|
||||||
|
class _SupportsDunderGE(Protocol):
|
||||||
|
def __ge__(self, other: Any, /) -> Any: ...
|
||||||
|
|
||||||
|
_SupportsComparison: TypeAlias = _SupportsDunderLE | _SupportsDunderGE | _SupportsDunderGT | _SupportsDunderLT
|
||||||
|
|
||||||
|
class _SupportsInversion(Protocol[_T_co]):
|
||||||
|
def __invert__(self) -> _T_co: ...
|
||||||
|
|
||||||
|
class _SupportsNeg(Protocol[_T_co]):
|
||||||
|
def __neg__(self) -> _T_co: ...
|
||||||
|
|
||||||
|
class _SupportsPos(Protocol[_T_co]):
|
||||||
|
def __pos__(self) -> _T_co: ...
|
||||||
|
|
||||||
|
# All four comparison functions must have the same signature, or we get false-positive errors
|
||||||
|
def lt(a: _SupportsComparison, b: _SupportsComparison, /) -> Any: ...
|
||||||
|
def le(a: _SupportsComparison, b: _SupportsComparison, /) -> Any: ...
|
||||||
|
def eq(a: object, b: object, /) -> Any: ...
|
||||||
|
def ne(a: object, b: object, /) -> Any: ...
|
||||||
|
def ge(a: _SupportsComparison, b: _SupportsComparison, /) -> Any: ...
|
||||||
|
def gt(a: _SupportsComparison, b: _SupportsComparison, /) -> Any: ...
|
||||||
|
def not_(a: object, /) -> bool: ...
|
||||||
|
def truth(a: object, /) -> bool: ...
|
||||||
|
def is_(a: object, b: object, /) -> bool: ...
|
||||||
|
def is_not(a: object, b: object, /) -> bool: ...
|
||||||
|
def abs(a: SupportsAbs[_T], /) -> _T: ...
|
||||||
|
def add(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def and_(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def floordiv(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def index(a: SupportsIndex, /) -> int: ...
|
||||||
|
def inv(a: _SupportsInversion[_T_co], /) -> _T_co: ...
|
||||||
|
def invert(a: _SupportsInversion[_T_co], /) -> _T_co: ...
|
||||||
|
def lshift(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def mod(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def mul(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def matmul(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def neg(a: _SupportsNeg[_T_co], /) -> _T_co: ...
|
||||||
|
def or_(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def pos(a: _SupportsPos[_T_co], /) -> _T_co: ...
|
||||||
|
def pow(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def rshift(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def sub(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def truediv(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def xor(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def concat(a: Sequence[_T], b: Sequence[_T], /) -> Sequence[_T]: ...
|
||||||
|
def contains(a: Container[object], b: object, /) -> bool: ...
|
||||||
|
def countOf(a: Iterable[object], b: object, /) -> int: ...
|
||||||
|
@overload
|
||||||
|
def delitem(a: MutableSequence[Any], b: SupportsIndex, /) -> None: ...
|
||||||
|
@overload
|
||||||
|
def delitem(a: MutableSequence[Any], b: slice, /) -> None: ...
|
||||||
|
@overload
|
||||||
|
def delitem(a: MutableMapping[_K, Any], b: _K, /) -> None: ...
|
||||||
|
@overload
|
||||||
|
def getitem(a: Sequence[_T], b: slice, /) -> Sequence[_T]: ...
|
||||||
|
@overload
|
||||||
|
def getitem(a: SupportsGetItem[_K, _V], b: _K, /) -> _V: ...
|
||||||
|
def indexOf(a: Iterable[_T], b: _T, /) -> int: ...
|
||||||
|
@overload
|
||||||
|
def setitem(a: MutableSequence[_T], b: SupportsIndex, c: _T, /) -> None: ...
|
||||||
|
@overload
|
||||||
|
def setitem(a: MutableSequence[_T], b: slice, c: Sequence[_T], /) -> None: ...
|
||||||
|
@overload
|
||||||
|
def setitem(a: MutableMapping[_K, _V], b: _K, c: _V, /) -> None: ...
|
||||||
|
def length_hint(obj: object, default: int = 0, /) -> int: ...
|
||||||
|
@final
|
||||||
|
class attrgetter(Generic[_T_co]):
|
||||||
|
@overload
|
||||||
|
def __new__(cls, attr: str, /) -> attrgetter[Any]: ...
|
||||||
|
@overload
|
||||||
|
def __new__(cls, attr: str, attr2: str, /) -> attrgetter[tuple[Any, Any]]: ...
|
||||||
|
@overload
|
||||||
|
def __new__(cls, attr: str, attr2: str, attr3: str, /) -> attrgetter[tuple[Any, Any, Any]]: ...
|
||||||
|
@overload
|
||||||
|
def __new__(cls, attr: str, attr2: str, attr3: str, attr4: str, /) -> attrgetter[tuple[Any, Any, Any, Any]]: ...
|
||||||
|
@overload
|
||||||
|
def __new__(cls, attr: str, /, *attrs: str) -> attrgetter[tuple[Any, ...]]: ...
|
||||||
|
def __call__(self, obj: Any, /) -> _T_co: ...
|
||||||
|
|
||||||
|
@final
|
||||||
|
class itemgetter(Generic[_T_co]):
|
||||||
|
@overload
|
||||||
|
def __new__(cls, item: _T, /) -> itemgetter[_T]: ...
|
||||||
|
@overload
|
||||||
|
def __new__(cls, item1: _T1, item2: _T2, /, *items: Unpack[_Ts]) -> itemgetter[tuple[_T1, _T2, Unpack[_Ts]]]: ...
|
||||||
|
# __key: _KT_contra in SupportsGetItem seems to be causing variance issues, ie:
|
||||||
|
# TypeVar "_KT_contra@SupportsGetItem" is contravariant
|
||||||
|
# "tuple[int, int]" is incompatible with protocol "SupportsIndex"
|
||||||
|
# preventing [_T_co, ...] instead of [Any, ...]
|
||||||
|
#
|
||||||
|
# A suspected mypy issue prevents using [..., _T] instead of [..., Any] here.
|
||||||
|
# https://github.com/python/mypy/issues/14032
|
||||||
|
def __call__(self, obj: SupportsGetItem[Any, Any]) -> Any: ...
|
||||||
|
|
||||||
|
@final
|
||||||
|
class methodcaller:
|
||||||
|
def __init__(self, name: str, /, *args: Any, **kwargs: Any) -> None: ...
|
||||||
|
def __call__(self, obj: Any) -> Any: ...
|
||||||
|
|
||||||
|
def iadd(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def iand(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def iconcat(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def ifloordiv(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def ilshift(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def imod(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def imul(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def imatmul(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def ior(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def ipow(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def irshift(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def isub(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def itruediv(a: Any, b: Any, /) -> Any: ...
|
||||||
|
def ixor(a: Any, b: Any, /) -> Any: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
def call(obj: Callable[_P, _R], /, *args: _P.args, **kwargs: _P.kwargs) -> _R: ...
|
||||||
|
|
||||||
|
def _compare_digest(a: AnyStr, b: AnyStr, /) -> bool: ...
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
from collections.abc import Iterable, Sequence
|
||||||
|
from typing import TypeVar
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
_K = TypeVar("_K")
|
||||||
|
_V = TypeVar("_V")
|
||||||
|
|
||||||
|
__all__ = ["compiler_fixup", "customize_config_vars", "customize_compiler", "get_platform_osx"]
|
||||||
|
|
||||||
|
_UNIVERSAL_CONFIG_VARS: tuple[str, ...] # undocumented
|
||||||
|
_COMPILER_CONFIG_VARS: tuple[str, ...] # undocumented
|
||||||
|
_INITPRE: str # undocumented
|
||||||
|
|
||||||
|
def _find_executable(executable: str, path: str | None = None) -> str | None: ... # undocumented
|
||||||
|
def _read_output(commandstring: str, capture_stderr: bool = False) -> str | None: ... # undocumented
|
||||||
|
def _find_build_tool(toolname: str) -> str: ... # undocumented
|
||||||
|
|
||||||
|
_SYSTEM_VERSION: str | None # undocumented
|
||||||
|
|
||||||
|
def _get_system_version() -> str: ... # undocumented
|
||||||
|
def _remove_original_values(_config_vars: dict[str, str]) -> None: ... # undocumented
|
||||||
|
def _save_modified_value(_config_vars: dict[str, str], cv: str, newvalue: str) -> None: ... # undocumented
|
||||||
|
def _supports_universal_builds() -> bool: ... # undocumented
|
||||||
|
def _find_appropriate_compiler(_config_vars: dict[str, str]) -> dict[str, str]: ... # undocumented
|
||||||
|
def _remove_universal_flags(_config_vars: dict[str, str]) -> dict[str, str]: ... # undocumented
|
||||||
|
def _remove_unsupported_archs(_config_vars: dict[str, str]) -> dict[str, str]: ... # undocumented
|
||||||
|
def _override_all_archs(_config_vars: dict[str, str]) -> dict[str, str]: ... # undocumented
|
||||||
|
def _check_for_unavailable_sdk(_config_vars: dict[str, str]) -> dict[str, str]: ... # undocumented
|
||||||
|
def compiler_fixup(compiler_so: Iterable[str], cc_args: Sequence[str]) -> list[str]: ...
|
||||||
|
def customize_config_vars(_config_vars: dict[str, str]) -> dict[str, str]: ...
|
||||||
|
def customize_compiler(_config_vars: dict[str, str]) -> dict[str, str]: ...
|
||||||
|
def get_platform_osx(
|
||||||
|
_config_vars: dict[str, str], osname: _T, release: _K, machine: _V
|
||||||
|
) -> tuple[str | _T, str | _K, str | _V]: ...
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
import sys
|
||||||
|
from _typeshed import StrOrBytesPath
|
||||||
|
from collections.abc import Callable, Sequence
|
||||||
|
from typing import SupportsIndex
|
||||||
|
|
||||||
|
if sys.platform != "win32":
|
||||||
|
def cloexec_pipe() -> tuple[int, int]: ...
|
||||||
|
def fork_exec(
|
||||||
|
args: Sequence[StrOrBytesPath] | None,
|
||||||
|
executable_list: Sequence[bytes],
|
||||||
|
close_fds: bool,
|
||||||
|
pass_fds: tuple[int, ...],
|
||||||
|
cwd: str,
|
||||||
|
env: Sequence[bytes] | None,
|
||||||
|
p2cread: int,
|
||||||
|
p2cwrite: int,
|
||||||
|
c2pread: int,
|
||||||
|
c2pwrite: int,
|
||||||
|
errread: int,
|
||||||
|
errwrite: int,
|
||||||
|
errpipe_read: int,
|
||||||
|
errpipe_write: int,
|
||||||
|
restore_signals: int,
|
||||||
|
call_setsid: int,
|
||||||
|
pgid_to_set: int,
|
||||||
|
gid: SupportsIndex | None,
|
||||||
|
extra_groups: list[int] | None,
|
||||||
|
uid: SupportsIndex | None,
|
||||||
|
child_umask: int,
|
||||||
|
preexec_fn: Callable[[], None],
|
||||||
|
allow_vfork: bool,
|
||||||
|
/,
|
||||||
|
) -> int: ...
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
import _typeshed
|
||||||
|
from typing import Any, NewType, TypeVar
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
|
||||||
|
_CacheToken = NewType("_CacheToken", int)
|
||||||
|
|
||||||
|
def get_cache_token() -> _CacheToken: ...
|
||||||
|
|
||||||
|
class ABCMeta(type):
|
||||||
|
def __new__(
|
||||||
|
mcls: type[_typeshed.Self], name: str, bases: tuple[type[Any], ...], namespace: dict[str, Any], /
|
||||||
|
) -> _typeshed.Self: ...
|
||||||
|
def register(cls, subclass: type[_T]) -> type[_T]: ...
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
# This is a slight lie, the implementations aren't exactly identical
|
||||||
|
# However, in all likelihood, the differences are inconsequential
|
||||||
|
from _decimal import *
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"Decimal",
|
||||||
|
"Context",
|
||||||
|
"DecimalTuple",
|
||||||
|
"DefaultContext",
|
||||||
|
"BasicContext",
|
||||||
|
"ExtendedContext",
|
||||||
|
"DecimalException",
|
||||||
|
"Clamped",
|
||||||
|
"InvalidOperation",
|
||||||
|
"DivisionByZero",
|
||||||
|
"Inexact",
|
||||||
|
"Rounded",
|
||||||
|
"Subnormal",
|
||||||
|
"Overflow",
|
||||||
|
"Underflow",
|
||||||
|
"FloatOperation",
|
||||||
|
"DivisionImpossible",
|
||||||
|
"InvalidContext",
|
||||||
|
"ConversionSyntax",
|
||||||
|
"DivisionUndefined",
|
||||||
|
"ROUND_DOWN",
|
||||||
|
"ROUND_HALF_UP",
|
||||||
|
"ROUND_HALF_EVEN",
|
||||||
|
"ROUND_CEILING",
|
||||||
|
"ROUND_FLOOR",
|
||||||
|
"ROUND_UP",
|
||||||
|
"ROUND_HALF_DOWN",
|
||||||
|
"ROUND_05UP",
|
||||||
|
"setcontext",
|
||||||
|
"getcontext",
|
||||||
|
"localcontext",
|
||||||
|
"MAX_PREC",
|
||||||
|
"MAX_EMAX",
|
||||||
|
"MIN_EMIN",
|
||||||
|
"MIN_ETINY",
|
||||||
|
"HAVE_THREADS",
|
||||||
|
"HAVE_CONTEXTVAR",
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
from typing_extensions import TypeAlias
|
||||||
|
|
||||||
|
# Actually Tuple[(int,) * 625]
|
||||||
|
_State: TypeAlias = tuple[int, ...]
|
||||||
|
|
||||||
|
class Random:
|
||||||
|
def __init__(self, seed: object = ...) -> None: ...
|
||||||
|
def seed(self, n: object = None, /) -> None: ...
|
||||||
|
def getstate(self) -> _State: ...
|
||||||
|
def setstate(self, state: _State, /) -> None: ...
|
||||||
|
def random(self) -> float: ...
|
||||||
|
def getrandbits(self, k: int, /) -> int: ...
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
from collections.abc import Iterable
|
||||||
|
from typing import ClassVar, Literal, NoReturn
|
||||||
|
|
||||||
|
class Quitter:
|
||||||
|
name: str
|
||||||
|
eof: str
|
||||||
|
def __init__(self, name: str, eof: str) -> None: ...
|
||||||
|
def __call__(self, code: int | None = None) -> NoReturn: ...
|
||||||
|
|
||||||
|
class _Printer:
|
||||||
|
MAXLINES: ClassVar[Literal[23]]
|
||||||
|
def __init__(self, name: str, data: str, files: Iterable[str] = (), dirs: Iterable[str] = ()) -> None: ...
|
||||||
|
def __call__(self) -> None: ...
|
||||||
|
|
||||||
|
class _Helper:
|
||||||
|
def __call__(self, request: object) -> None: ...
|
||||||
|
|
@ -0,0 +1,803 @@
|
||||||
|
import sys
|
||||||
|
from _typeshed import ReadableBuffer, WriteableBuffer
|
||||||
|
from collections.abc import Iterable
|
||||||
|
from typing import Any, SupportsIndex, overload
|
||||||
|
from typing_extensions import TypeAlias
|
||||||
|
|
||||||
|
_CMSG: TypeAlias = tuple[int, int, bytes]
|
||||||
|
_CMSGArg: TypeAlias = tuple[int, int, ReadableBuffer]
|
||||||
|
|
||||||
|
# Addresses can be either tuples of varying lengths (AF_INET, AF_INET6,
|
||||||
|
# AF_NETLINK, AF_TIPC) or strings/buffers (AF_UNIX).
|
||||||
|
# See getsockaddrarg() in socketmodule.c.
|
||||||
|
_Address: TypeAlias = tuple[Any, ...] | str | ReadableBuffer
|
||||||
|
_RetAddress: TypeAlias = Any
|
||||||
|
|
||||||
|
# ===== Constants =====
|
||||||
|
# This matches the order in the CPython documentation
|
||||||
|
# https://docs.python.org/3/library/socket.html#constants
|
||||||
|
|
||||||
|
if sys.platform != "win32":
|
||||||
|
AF_UNIX: int
|
||||||
|
|
||||||
|
AF_INET: int
|
||||||
|
AF_INET6: int
|
||||||
|
|
||||||
|
AF_UNSPEC: int
|
||||||
|
|
||||||
|
SOCK_STREAM: int
|
||||||
|
SOCK_DGRAM: int
|
||||||
|
SOCK_RAW: int
|
||||||
|
SOCK_RDM: int
|
||||||
|
SOCK_SEQPACKET: int
|
||||||
|
|
||||||
|
if sys.platform == "linux":
|
||||||
|
# Availability: Linux >= 2.6.27
|
||||||
|
SOCK_CLOEXEC: int
|
||||||
|
SOCK_NONBLOCK: int
|
||||||
|
|
||||||
|
# --------------------
|
||||||
|
# Many constants of these forms, documented in the Unix documentation on
|
||||||
|
# sockets and/or the IP protocol, are also defined in the socket module.
|
||||||
|
# SO_*
|
||||||
|
# socket.SOMAXCONN
|
||||||
|
# MSG_*
|
||||||
|
# SOL_*
|
||||||
|
# SCM_*
|
||||||
|
# IPPROTO_*
|
||||||
|
# IPPORT_*
|
||||||
|
# INADDR_*
|
||||||
|
# IP_*
|
||||||
|
# IPV6_*
|
||||||
|
# EAI_*
|
||||||
|
# AI_*
|
||||||
|
# NI_*
|
||||||
|
# TCP_*
|
||||||
|
# --------------------
|
||||||
|
|
||||||
|
SO_ACCEPTCONN: int
|
||||||
|
SO_BROADCAST: int
|
||||||
|
SO_DEBUG: int
|
||||||
|
SO_DONTROUTE: int
|
||||||
|
SO_ERROR: int
|
||||||
|
SO_KEEPALIVE: int
|
||||||
|
SO_LINGER: int
|
||||||
|
SO_OOBINLINE: int
|
||||||
|
SO_RCVBUF: int
|
||||||
|
SO_RCVLOWAT: int
|
||||||
|
SO_RCVTIMEO: int
|
||||||
|
SO_REUSEADDR: int
|
||||||
|
SO_SNDBUF: int
|
||||||
|
SO_SNDLOWAT: int
|
||||||
|
SO_SNDTIMEO: int
|
||||||
|
SO_TYPE: int
|
||||||
|
SO_USELOOPBACK: int
|
||||||
|
if sys.platform == "win32":
|
||||||
|
SO_EXCLUSIVEADDRUSE: int
|
||||||
|
if sys.platform != "win32":
|
||||||
|
SO_REUSEPORT: int
|
||||||
|
if sys.platform != "win32" and sys.platform != "darwin":
|
||||||
|
SO_BINDTODEVICE: int
|
||||||
|
SO_DOMAIN: int
|
||||||
|
SO_MARK: int
|
||||||
|
SO_PASSCRED: int
|
||||||
|
SO_PASSSEC: int
|
||||||
|
SO_PEERCRED: int
|
||||||
|
SO_PEERSEC: int
|
||||||
|
SO_PRIORITY: int
|
||||||
|
SO_PROTOCOL: int
|
||||||
|
SO_SETFIB: int
|
||||||
|
|
||||||
|
SOMAXCONN: int
|
||||||
|
|
||||||
|
MSG_CTRUNC: int
|
||||||
|
MSG_DONTROUTE: int
|
||||||
|
MSG_OOB: int
|
||||||
|
MSG_PEEK: int
|
||||||
|
MSG_TRUNC: int
|
||||||
|
MSG_WAITALL: int
|
||||||
|
if sys.platform != "win32":
|
||||||
|
MSG_DONTWAIT: int
|
||||||
|
MSG_EOF: int
|
||||||
|
MSG_EOR: int
|
||||||
|
MSG_NOSIGNAL: int # Sometimes this exists on darwin, sometimes not
|
||||||
|
if sys.platform != "darwin":
|
||||||
|
MSG_BCAST: int
|
||||||
|
MSG_ERRQUEUE: int
|
||||||
|
MSG_MCAST: int
|
||||||
|
if sys.platform != "win32" and sys.platform != "darwin":
|
||||||
|
MSG_BTAG: int
|
||||||
|
MSG_CMSG_CLOEXEC: int
|
||||||
|
MSG_CONFIRM: int
|
||||||
|
MSG_ETAG: int
|
||||||
|
MSG_FASTOPEN: int
|
||||||
|
MSG_MORE: int
|
||||||
|
MSG_NOTIFICATION: int
|
||||||
|
|
||||||
|
SOL_IP: int
|
||||||
|
SOL_SOCKET: int
|
||||||
|
SOL_TCP: int
|
||||||
|
SOL_UDP: int
|
||||||
|
if sys.platform != "win32" and sys.platform != "darwin":
|
||||||
|
SOL_ATALK: int
|
||||||
|
SOL_AX25: int
|
||||||
|
SOL_HCI: int
|
||||||
|
SOL_IPX: int
|
||||||
|
SOL_NETROM: int
|
||||||
|
SOL_ROSE: int
|
||||||
|
|
||||||
|
if sys.platform != "win32":
|
||||||
|
SCM_CREDS: int
|
||||||
|
SCM_RIGHTS: int
|
||||||
|
if sys.platform != "win32" and sys.platform != "darwin":
|
||||||
|
SCM_CREDENTIALS: int
|
||||||
|
|
||||||
|
IPPROTO_ICMP: int
|
||||||
|
IPPROTO_IP: int
|
||||||
|
IPPROTO_RAW: int
|
||||||
|
IPPROTO_TCP: int
|
||||||
|
IPPROTO_UDP: int
|
||||||
|
IPPROTO_AH: int
|
||||||
|
IPPROTO_DSTOPTS: int
|
||||||
|
IPPROTO_EGP: int
|
||||||
|
IPPROTO_ESP: int
|
||||||
|
IPPROTO_FRAGMENT: int
|
||||||
|
IPPROTO_GGP: int
|
||||||
|
IPPROTO_HOPOPTS: int
|
||||||
|
IPPROTO_ICMPV6: int
|
||||||
|
IPPROTO_IDP: int
|
||||||
|
IPPROTO_IGMP: int
|
||||||
|
IPPROTO_IPV4: int
|
||||||
|
IPPROTO_IPV6: int
|
||||||
|
IPPROTO_MAX: int
|
||||||
|
IPPROTO_ND: int
|
||||||
|
IPPROTO_NONE: int
|
||||||
|
IPPROTO_PIM: int
|
||||||
|
IPPROTO_PUP: int
|
||||||
|
IPPROTO_ROUTING: int
|
||||||
|
IPPROTO_SCTP: int
|
||||||
|
if sys.platform != "darwin":
|
||||||
|
IPPROTO_CBT: int
|
||||||
|
IPPROTO_ICLFXBM: int
|
||||||
|
IPPROTO_IGP: int
|
||||||
|
IPPROTO_L2TP: int
|
||||||
|
IPPROTO_PGM: int
|
||||||
|
IPPROTO_RDP: int
|
||||||
|
IPPROTO_ST: int
|
||||||
|
if sys.platform != "win32":
|
||||||
|
IPPROTO_EON: int
|
||||||
|
IPPROTO_GRE: int
|
||||||
|
IPPROTO_HELLO: int
|
||||||
|
IPPROTO_IPCOMP: int
|
||||||
|
IPPROTO_IPIP: int
|
||||||
|
IPPROTO_RSVP: int
|
||||||
|
IPPROTO_TP: int
|
||||||
|
IPPROTO_XTP: int
|
||||||
|
if sys.platform != "win32" and sys.platform != "darwin":
|
||||||
|
IPPROTO_BIP: int
|
||||||
|
IPPROTO_MOBILE: int
|
||||||
|
IPPROTO_VRRP: int
|
||||||
|
if sys.version_info >= (3, 9) and sys.platform == "linux":
|
||||||
|
# Availability: Linux >= 2.6.20, FreeBSD >= 10.1
|
||||||
|
IPPROTO_UDPLITE: int
|
||||||
|
if sys.version_info >= (3, 10) and sys.platform == "linux":
|
||||||
|
IPPROTO_MPTCP: int
|
||||||
|
|
||||||
|
IPPORT_RESERVED: int
|
||||||
|
IPPORT_USERRESERVED: int
|
||||||
|
|
||||||
|
INADDR_ALLHOSTS_GROUP: int
|
||||||
|
INADDR_ANY: int
|
||||||
|
INADDR_BROADCAST: int
|
||||||
|
INADDR_LOOPBACK: int
|
||||||
|
INADDR_MAX_LOCAL_GROUP: int
|
||||||
|
INADDR_NONE: int
|
||||||
|
INADDR_UNSPEC_GROUP: int
|
||||||
|
|
||||||
|
IP_ADD_MEMBERSHIP: int
|
||||||
|
IP_DROP_MEMBERSHIP: int
|
||||||
|
IP_HDRINCL: int
|
||||||
|
IP_MULTICAST_IF: int
|
||||||
|
IP_MULTICAST_LOOP: int
|
||||||
|
IP_MULTICAST_TTL: int
|
||||||
|
IP_OPTIONS: int
|
||||||
|
IP_RECVDSTADDR: int
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
IP_RECVTOS: int
|
||||||
|
elif sys.platform != "win32" and sys.platform != "darwin":
|
||||||
|
IP_RECVTOS: int
|
||||||
|
IP_TOS: int
|
||||||
|
IP_TTL: int
|
||||||
|
if sys.platform != "win32":
|
||||||
|
IP_DEFAULT_MULTICAST_LOOP: int
|
||||||
|
IP_DEFAULT_MULTICAST_TTL: int
|
||||||
|
IP_MAX_MEMBERSHIPS: int
|
||||||
|
IP_RECVOPTS: int
|
||||||
|
IP_RECVRETOPTS: int
|
||||||
|
IP_RETOPTS: int
|
||||||
|
if sys.platform != "win32" and sys.platform != "darwin":
|
||||||
|
IP_TRANSPARENT: int
|
||||||
|
IP_BIND_ADDRESS_NO_PORT: int
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
IP_ADD_SOURCE_MEMBERSHIP: int
|
||||||
|
IP_BLOCK_SOURCE: int
|
||||||
|
IP_DROP_SOURCE_MEMBERSHIP: int
|
||||||
|
IP_PKTINFO: int
|
||||||
|
IP_UNBLOCK_SOURCE: int
|
||||||
|
|
||||||
|
IPV6_CHECKSUM: int
|
||||||
|
IPV6_JOIN_GROUP: int
|
||||||
|
IPV6_LEAVE_GROUP: int
|
||||||
|
IPV6_MULTICAST_HOPS: int
|
||||||
|
IPV6_MULTICAST_IF: int
|
||||||
|
IPV6_MULTICAST_LOOP: int
|
||||||
|
IPV6_RECVTCLASS: int
|
||||||
|
IPV6_TCLASS: int
|
||||||
|
IPV6_UNICAST_HOPS: int
|
||||||
|
IPV6_V6ONLY: int
|
||||||
|
if sys.version_info >= (3, 9) or sys.platform != "darwin":
|
||||||
|
IPV6_DONTFRAG: int
|
||||||
|
IPV6_HOPLIMIT: int
|
||||||
|
IPV6_HOPOPTS: int
|
||||||
|
IPV6_PKTINFO: int
|
||||||
|
IPV6_RECVRTHDR: int
|
||||||
|
IPV6_RTHDR: int
|
||||||
|
if sys.platform != "win32":
|
||||||
|
IPV6_RTHDR_TYPE_0: int
|
||||||
|
if sys.version_info >= (3, 9) or sys.platform != "darwin":
|
||||||
|
IPV6_DSTOPTS: int
|
||||||
|
IPV6_NEXTHOP: int
|
||||||
|
IPV6_PATHMTU: int
|
||||||
|
IPV6_RECVDSTOPTS: int
|
||||||
|
IPV6_RECVHOPLIMIT: int
|
||||||
|
IPV6_RECVHOPOPTS: int
|
||||||
|
IPV6_RECVPATHMTU: int
|
||||||
|
IPV6_RECVPKTINFO: int
|
||||||
|
IPV6_RTHDRDSTOPTS: int
|
||||||
|
IPV6_USE_MIN_MTU: int
|
||||||
|
|
||||||
|
EAI_AGAIN: int
|
||||||
|
EAI_BADFLAGS: int
|
||||||
|
EAI_FAIL: int
|
||||||
|
EAI_FAMILY: int
|
||||||
|
EAI_MEMORY: int
|
||||||
|
EAI_NODATA: int
|
||||||
|
EAI_NONAME: int
|
||||||
|
EAI_SERVICE: int
|
||||||
|
EAI_SOCKTYPE: int
|
||||||
|
if sys.platform != "win32":
|
||||||
|
EAI_ADDRFAMILY: int
|
||||||
|
EAI_BADHINTS: int
|
||||||
|
EAI_MAX: int
|
||||||
|
EAI_OVERFLOW: int
|
||||||
|
EAI_PROTOCOL: int
|
||||||
|
EAI_SYSTEM: int
|
||||||
|
|
||||||
|
AI_ADDRCONFIG: int
|
||||||
|
AI_ALL: int
|
||||||
|
AI_CANONNAME: int
|
||||||
|
AI_NUMERICHOST: int
|
||||||
|
AI_NUMERICSERV: int
|
||||||
|
AI_PASSIVE: int
|
||||||
|
AI_V4MAPPED: int
|
||||||
|
if sys.platform != "win32":
|
||||||
|
AI_DEFAULT: int
|
||||||
|
AI_MASK: int
|
||||||
|
AI_V4MAPPED_CFG: int
|
||||||
|
|
||||||
|
NI_DGRAM: int
|
||||||
|
NI_MAXHOST: int
|
||||||
|
NI_MAXSERV: int
|
||||||
|
NI_NAMEREQD: int
|
||||||
|
NI_NOFQDN: int
|
||||||
|
NI_NUMERICHOST: int
|
||||||
|
NI_NUMERICSERV: int
|
||||||
|
|
||||||
|
TCP_FASTOPEN: int
|
||||||
|
TCP_KEEPCNT: int
|
||||||
|
TCP_KEEPINTVL: int
|
||||||
|
TCP_MAXSEG: int
|
||||||
|
TCP_NODELAY: int
|
||||||
|
if sys.platform != "win32":
|
||||||
|
TCP_NOTSENT_LOWAT: int
|
||||||
|
if sys.platform != "darwin":
|
||||||
|
TCP_KEEPIDLE: int
|
||||||
|
if sys.version_info >= (3, 10) and sys.platform == "darwin":
|
||||||
|
TCP_KEEPALIVE: int
|
||||||
|
if sys.version_info >= (3, 11) and sys.platform == "darwin":
|
||||||
|
TCP_CONNECTION_INFO: int
|
||||||
|
|
||||||
|
if sys.platform != "win32" and sys.platform != "darwin":
|
||||||
|
TCP_CONGESTION: int
|
||||||
|
TCP_CORK: int
|
||||||
|
TCP_DEFER_ACCEPT: int
|
||||||
|
TCP_INFO: int
|
||||||
|
TCP_LINGER2: int
|
||||||
|
TCP_QUICKACK: int
|
||||||
|
TCP_SYNCNT: int
|
||||||
|
TCP_USER_TIMEOUT: int
|
||||||
|
TCP_WINDOW_CLAMP: int
|
||||||
|
|
||||||
|
# --------------------
|
||||||
|
# Specifically documented constants
|
||||||
|
# --------------------
|
||||||
|
|
||||||
|
if sys.platform == "linux":
|
||||||
|
# Availability: Linux >= 2.6.25, NetBSD >= 8
|
||||||
|
AF_CAN: int
|
||||||
|
PF_CAN: int
|
||||||
|
SOL_CAN_BASE: int
|
||||||
|
SOL_CAN_RAW: int
|
||||||
|
CAN_EFF_FLAG: int
|
||||||
|
CAN_EFF_MASK: int
|
||||||
|
CAN_ERR_FLAG: int
|
||||||
|
CAN_ERR_MASK: int
|
||||||
|
CAN_RAW: int
|
||||||
|
CAN_RAW_ERR_FILTER: int
|
||||||
|
CAN_RAW_FILTER: int
|
||||||
|
CAN_RAW_LOOPBACK: int
|
||||||
|
CAN_RAW_RECV_OWN_MSGS: int
|
||||||
|
CAN_RTR_FLAG: int
|
||||||
|
CAN_SFF_MASK: int
|
||||||
|
|
||||||
|
if sys.platform == "linux":
|
||||||
|
# Availability: Linux >= 2.6.25
|
||||||
|
CAN_BCM: int
|
||||||
|
CAN_BCM_TX_SETUP: int
|
||||||
|
CAN_BCM_TX_DELETE: int
|
||||||
|
CAN_BCM_TX_READ: int
|
||||||
|
CAN_BCM_TX_SEND: int
|
||||||
|
CAN_BCM_RX_SETUP: int
|
||||||
|
CAN_BCM_RX_DELETE: int
|
||||||
|
CAN_BCM_RX_READ: int
|
||||||
|
CAN_BCM_TX_STATUS: int
|
||||||
|
CAN_BCM_TX_EXPIRED: int
|
||||||
|
CAN_BCM_RX_STATUS: int
|
||||||
|
CAN_BCM_RX_TIMEOUT: int
|
||||||
|
CAN_BCM_RX_CHANGED: int
|
||||||
|
CAN_BCM_SETTIMER: int
|
||||||
|
CAN_BCM_STARTTIMER: int
|
||||||
|
CAN_BCM_TX_COUNTEVT: int
|
||||||
|
CAN_BCM_TX_ANNOUNCE: int
|
||||||
|
CAN_BCM_TX_CP_CAN_ID: int
|
||||||
|
CAN_BCM_RX_FILTER_ID: int
|
||||||
|
CAN_BCM_RX_CHECK_DLC: int
|
||||||
|
CAN_BCM_RX_NO_AUTOTIMER: int
|
||||||
|
CAN_BCM_RX_ANNOUNCE_RESUME: int
|
||||||
|
CAN_BCM_TX_RESET_MULTI_IDX: int
|
||||||
|
CAN_BCM_RX_RTR_FRAME: int
|
||||||
|
CAN_BCM_CAN_FD_FRAME: int
|
||||||
|
|
||||||
|
if sys.platform == "linux":
|
||||||
|
# Availability: Linux >= 3.6
|
||||||
|
CAN_RAW_FD_FRAMES: int
|
||||||
|
|
||||||
|
if sys.platform == "linux" and sys.version_info >= (3, 9):
|
||||||
|
# Availability: Linux >= 4.1
|
||||||
|
CAN_RAW_JOIN_FILTERS: int
|
||||||
|
|
||||||
|
if sys.platform == "linux":
|
||||||
|
# Availability: Linux >= 2.6.25
|
||||||
|
CAN_ISOTP: int
|
||||||
|
|
||||||
|
if sys.platform == "linux" and sys.version_info >= (3, 9):
|
||||||
|
# Availability: Linux >= 5.4
|
||||||
|
CAN_J1939: int
|
||||||
|
|
||||||
|
J1939_MAX_UNICAST_ADDR: int
|
||||||
|
J1939_IDLE_ADDR: int
|
||||||
|
J1939_NO_ADDR: int
|
||||||
|
J1939_NO_NAME: int
|
||||||
|
J1939_PGN_REQUEST: int
|
||||||
|
J1939_PGN_ADDRESS_CLAIMED: int
|
||||||
|
J1939_PGN_ADDRESS_COMMANDED: int
|
||||||
|
J1939_PGN_PDU1_MAX: int
|
||||||
|
J1939_PGN_MAX: int
|
||||||
|
J1939_NO_PGN: int
|
||||||
|
|
||||||
|
SO_J1939_FILTER: int
|
||||||
|
SO_J1939_PROMISC: int
|
||||||
|
SO_J1939_SEND_PRIO: int
|
||||||
|
SO_J1939_ERRQUEUE: int
|
||||||
|
|
||||||
|
SCM_J1939_DEST_ADDR: int
|
||||||
|
SCM_J1939_DEST_NAME: int
|
||||||
|
SCM_J1939_PRIO: int
|
||||||
|
SCM_J1939_ERRQUEUE: int
|
||||||
|
|
||||||
|
J1939_NLA_PAD: int
|
||||||
|
J1939_NLA_BYTES_ACKED: int
|
||||||
|
J1939_EE_INFO_NONE: int
|
||||||
|
J1939_EE_INFO_TX_ABORT: int
|
||||||
|
J1939_FILTER_MAX: int
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12) and sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin":
|
||||||
|
# Availability: FreeBSD >= 14.0
|
||||||
|
AF_DIVERT: int
|
||||||
|
PF_DIVERT: int
|
||||||
|
|
||||||
|
if sys.platform == "linux":
|
||||||
|
# Availability: Linux >= 2.2
|
||||||
|
AF_PACKET: int
|
||||||
|
PF_PACKET: int
|
||||||
|
PACKET_BROADCAST: int
|
||||||
|
PACKET_FASTROUTE: int
|
||||||
|
PACKET_HOST: int
|
||||||
|
PACKET_LOOPBACK: int
|
||||||
|
PACKET_MULTICAST: int
|
||||||
|
PACKET_OTHERHOST: int
|
||||||
|
PACKET_OUTGOING: int
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12) and sys.platform == "linux":
|
||||||
|
ETH_P_ALL: int
|
||||||
|
|
||||||
|
if sys.platform == "linux":
|
||||||
|
# Availability: Linux >= 2.6.30
|
||||||
|
AF_RDS: int
|
||||||
|
PF_RDS: int
|
||||||
|
SOL_RDS: int
|
||||||
|
RDS_CANCEL_SENT_TO: int
|
||||||
|
RDS_CMSG_RDMA_ARGS: int
|
||||||
|
RDS_CMSG_RDMA_DEST: int
|
||||||
|
RDS_CMSG_RDMA_MAP: int
|
||||||
|
RDS_CMSG_RDMA_STATUS: int
|
||||||
|
RDS_CMSG_RDMA_UPDATE: int
|
||||||
|
RDS_CONG_MONITOR: int
|
||||||
|
RDS_FREE_MR: int
|
||||||
|
RDS_GET_MR: int
|
||||||
|
RDS_GET_MR_FOR_DEST: int
|
||||||
|
RDS_RDMA_DONTWAIT: int
|
||||||
|
RDS_RDMA_FENCE: int
|
||||||
|
RDS_RDMA_INVALIDATE: int
|
||||||
|
RDS_RDMA_NOTIFY_ME: int
|
||||||
|
RDS_RDMA_READWRITE: int
|
||||||
|
RDS_RDMA_SILENT: int
|
||||||
|
RDS_RDMA_USE_ONCE: int
|
||||||
|
RDS_RECVERR: int
|
||||||
|
|
||||||
|
if sys.platform == "win32":
|
||||||
|
SIO_RCVALL: int
|
||||||
|
SIO_KEEPALIVE_VALS: int
|
||||||
|
SIO_LOOPBACK_FAST_PATH: int
|
||||||
|
RCVALL_MAX: int
|
||||||
|
RCVALL_OFF: int
|
||||||
|
RCVALL_ON: int
|
||||||
|
RCVALL_SOCKETLEVELONLY: int
|
||||||
|
|
||||||
|
if sys.platform == "linux":
|
||||||
|
AF_TIPC: int
|
||||||
|
SOL_TIPC: int
|
||||||
|
TIPC_ADDR_ID: int
|
||||||
|
TIPC_ADDR_NAME: int
|
||||||
|
TIPC_ADDR_NAMESEQ: int
|
||||||
|
TIPC_CFG_SRV: int
|
||||||
|
TIPC_CLUSTER_SCOPE: int
|
||||||
|
TIPC_CONN_TIMEOUT: int
|
||||||
|
TIPC_CRITICAL_IMPORTANCE: int
|
||||||
|
TIPC_DEST_DROPPABLE: int
|
||||||
|
TIPC_HIGH_IMPORTANCE: int
|
||||||
|
TIPC_IMPORTANCE: int
|
||||||
|
TIPC_LOW_IMPORTANCE: int
|
||||||
|
TIPC_MEDIUM_IMPORTANCE: int
|
||||||
|
TIPC_NODE_SCOPE: int
|
||||||
|
TIPC_PUBLISHED: int
|
||||||
|
TIPC_SRC_DROPPABLE: int
|
||||||
|
TIPC_SUBSCR_TIMEOUT: int
|
||||||
|
TIPC_SUB_CANCEL: int
|
||||||
|
TIPC_SUB_PORTS: int
|
||||||
|
TIPC_SUB_SERVICE: int
|
||||||
|
TIPC_TOP_SRV: int
|
||||||
|
TIPC_WAIT_FOREVER: int
|
||||||
|
TIPC_WITHDRAWN: int
|
||||||
|
TIPC_ZONE_SCOPE: int
|
||||||
|
|
||||||
|
if sys.platform == "linux":
|
||||||
|
# Availability: Linux >= 2.6.38
|
||||||
|
AF_ALG: int
|
||||||
|
SOL_ALG: int
|
||||||
|
ALG_OP_DECRYPT: int
|
||||||
|
ALG_OP_ENCRYPT: int
|
||||||
|
ALG_OP_SIGN: int
|
||||||
|
ALG_OP_VERIFY: int
|
||||||
|
ALG_SET_AEAD_ASSOCLEN: int
|
||||||
|
ALG_SET_AEAD_AUTHSIZE: int
|
||||||
|
ALG_SET_IV: int
|
||||||
|
ALG_SET_KEY: int
|
||||||
|
ALG_SET_OP: int
|
||||||
|
ALG_SET_PUBKEY: int
|
||||||
|
|
||||||
|
if sys.platform == "linux":
|
||||||
|
# Availability: Linux >= 4.8 (or maybe 3.9, CPython docs are confusing)
|
||||||
|
AF_VSOCK: int
|
||||||
|
IOCTL_VM_SOCKETS_GET_LOCAL_CID: int
|
||||||
|
VMADDR_CID_ANY: int
|
||||||
|
VMADDR_CID_HOST: int
|
||||||
|
VMADDR_PORT_ANY: int
|
||||||
|
SO_VM_SOCKETS_BUFFER_MAX_SIZE: int
|
||||||
|
SO_VM_SOCKETS_BUFFER_SIZE: int
|
||||||
|
SO_VM_SOCKETS_BUFFER_MIN_SIZE: int
|
||||||
|
VM_SOCKETS_INVALID_VERSION: int # undocumented
|
||||||
|
|
||||||
|
if sys.platform != "win32" or sys.version_info >= (3, 9):
|
||||||
|
# Documented as only available on BSD, macOS, but empirically sometimes
|
||||||
|
# available on Windows
|
||||||
|
AF_LINK: int
|
||||||
|
|
||||||
|
has_ipv6: bool
|
||||||
|
|
||||||
|
if sys.platform != "darwin":
|
||||||
|
if sys.platform != "win32" or sys.version_info >= (3, 9):
|
||||||
|
BDADDR_ANY: str
|
||||||
|
BDADDR_LOCAL: str
|
||||||
|
|
||||||
|
if sys.platform != "win32" and sys.platform != "darwin":
|
||||||
|
HCI_FILTER: int # not in NetBSD or DragonFlyBSD
|
||||||
|
HCI_TIME_STAMP: int # not in FreeBSD, NetBSD, or DragonFlyBSD
|
||||||
|
HCI_DATA_DIR: int # not in FreeBSD, NetBSD, or DragonFlyBSD
|
||||||
|
|
||||||
|
if sys.platform == "linux":
|
||||||
|
AF_QIPCRTR: int # Availability: Linux >= 4.7
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11) and sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin":
|
||||||
|
# FreeBSD
|
||||||
|
SCM_CREDS2: int
|
||||||
|
LOCAL_CREDS: int
|
||||||
|
LOCAL_CREDS_PERSISTENT: int
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11) and sys.platform == "linux":
|
||||||
|
SO_INCOMING_CPU: int # Availability: Linux >= 3.9
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12) and sys.platform == "win32":
|
||||||
|
# Availability: Windows
|
||||||
|
AF_HYPERV: int
|
||||||
|
HV_PROTOCOL_RAW: int
|
||||||
|
HVSOCKET_CONNECT_TIMEOUT: int
|
||||||
|
HVSOCKET_CONNECT_TIMEOUT_MAX: int
|
||||||
|
HVSOCKET_CONNECTED_SUSPEND: int
|
||||||
|
HVSOCKET_ADDRESS_FLAG_PASSTHRU: int
|
||||||
|
HV_GUID_ZERO: str
|
||||||
|
HV_GUID_WILDCARD: str
|
||||||
|
HV_GUID_BROADCAST: str
|
||||||
|
HV_GUID_CHILDREN: str
|
||||||
|
HV_GUID_LOOPBACK: str
|
||||||
|
HV_GUID_PARENT: str
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
if sys.platform != "win32":
|
||||||
|
# Availability: Linux, FreeBSD, macOS
|
||||||
|
ETHERTYPE_ARP: int
|
||||||
|
ETHERTYPE_IP: int
|
||||||
|
ETHERTYPE_IPV6: int
|
||||||
|
ETHERTYPE_VLAN: int
|
||||||
|
|
||||||
|
# --------------------
|
||||||
|
# Semi-documented constants
|
||||||
|
# These are alluded to under the "Socket families" section in the docs
|
||||||
|
# https://docs.python.org/3/library/socket.html#socket-families
|
||||||
|
# --------------------
|
||||||
|
|
||||||
|
if sys.platform == "linux":
|
||||||
|
# Netlink is defined by Linux
|
||||||
|
AF_NETLINK: int
|
||||||
|
NETLINK_ARPD: int
|
||||||
|
NETLINK_CRYPTO: int
|
||||||
|
NETLINK_DNRTMSG: int
|
||||||
|
NETLINK_FIREWALL: int
|
||||||
|
NETLINK_IP6_FW: int
|
||||||
|
NETLINK_NFLOG: int
|
||||||
|
NETLINK_ROUTE6: int
|
||||||
|
NETLINK_ROUTE: int
|
||||||
|
NETLINK_SKIP: int
|
||||||
|
NETLINK_TAPBASE: int
|
||||||
|
NETLINK_TCPDIAG: int
|
||||||
|
NETLINK_USERSOCK: int
|
||||||
|
NETLINK_W1: int
|
||||||
|
NETLINK_XFRM: int
|
||||||
|
|
||||||
|
if sys.platform == "darwin":
|
||||||
|
PF_SYSTEM: int
|
||||||
|
SYSPROTO_CONTROL: int
|
||||||
|
|
||||||
|
if sys.platform != "darwin":
|
||||||
|
if sys.version_info >= (3, 9) or sys.platform != "win32":
|
||||||
|
AF_BLUETOOTH: int
|
||||||
|
|
||||||
|
if sys.platform != "win32" and sys.platform != "darwin":
|
||||||
|
# Linux and some BSD support is explicit in the docs
|
||||||
|
# Windows and macOS do not support in practice
|
||||||
|
BTPROTO_HCI: int
|
||||||
|
BTPROTO_L2CAP: int
|
||||||
|
BTPROTO_SCO: int # not in FreeBSD
|
||||||
|
if sys.platform != "darwin":
|
||||||
|
if sys.version_info >= (3, 9) or sys.platform != "win32":
|
||||||
|
BTPROTO_RFCOMM: int
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9) and sys.platform == "linux":
|
||||||
|
UDPLITE_RECV_CSCOV: int
|
||||||
|
UDPLITE_SEND_CSCOV: int
|
||||||
|
|
||||||
|
# --------------------
|
||||||
|
# Documented under socket.shutdown
|
||||||
|
# --------------------
|
||||||
|
SHUT_RD: int
|
||||||
|
SHUT_RDWR: int
|
||||||
|
SHUT_WR: int
|
||||||
|
|
||||||
|
# --------------------
|
||||||
|
# Undocumented constants
|
||||||
|
# --------------------
|
||||||
|
|
||||||
|
# Undocumented address families
|
||||||
|
AF_APPLETALK: int
|
||||||
|
AF_DECnet: int
|
||||||
|
AF_IPX: int
|
||||||
|
AF_SNA: int
|
||||||
|
|
||||||
|
if sys.platform != "win32":
|
||||||
|
AF_ROUTE: int
|
||||||
|
AF_SYSTEM: int
|
||||||
|
|
||||||
|
if sys.platform != "darwin":
|
||||||
|
AF_IRDA: int
|
||||||
|
|
||||||
|
if sys.platform != "win32" and sys.platform != "darwin":
|
||||||
|
AF_AAL5: int
|
||||||
|
AF_ASH: int
|
||||||
|
AF_ATMPVC: int
|
||||||
|
AF_ATMSVC: int
|
||||||
|
AF_AX25: int
|
||||||
|
AF_BRIDGE: int
|
||||||
|
AF_ECONET: int
|
||||||
|
AF_KEY: int
|
||||||
|
AF_LLC: int
|
||||||
|
AF_NETBEUI: int
|
||||||
|
AF_NETROM: int
|
||||||
|
AF_PPPOX: int
|
||||||
|
AF_ROSE: int
|
||||||
|
AF_SECURITY: int
|
||||||
|
AF_WANPIPE: int
|
||||||
|
AF_X25: int
|
||||||
|
|
||||||
|
# Miscellaneous undocumented
|
||||||
|
|
||||||
|
if sys.platform != "win32":
|
||||||
|
LOCAL_PEERCRED: int
|
||||||
|
|
||||||
|
if sys.platform != "win32" and sys.platform != "darwin":
|
||||||
|
IPX_TYPE: int
|
||||||
|
|
||||||
|
# ===== Exceptions =====
|
||||||
|
|
||||||
|
error = OSError
|
||||||
|
|
||||||
|
class herror(error): ...
|
||||||
|
class gaierror(error): ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
timeout = TimeoutError
|
||||||
|
else:
|
||||||
|
class timeout(error): ...
|
||||||
|
|
||||||
|
# ===== Classes =====
|
||||||
|
|
||||||
|
class socket:
|
||||||
|
@property
|
||||||
|
def family(self) -> int: ...
|
||||||
|
@property
|
||||||
|
def type(self) -> int: ...
|
||||||
|
@property
|
||||||
|
def proto(self) -> int: ...
|
||||||
|
@property
|
||||||
|
def timeout(self) -> float | None: ...
|
||||||
|
if sys.platform == "win32":
|
||||||
|
def __init__(
|
||||||
|
self, family: int = ..., type: int = ..., proto: int = ..., fileno: SupportsIndex | bytes | None = ...
|
||||||
|
) -> None: ...
|
||||||
|
else:
|
||||||
|
def __init__(self, family: int = ..., type: int = ..., proto: int = ..., fileno: SupportsIndex | None = ...) -> None: ...
|
||||||
|
|
||||||
|
def bind(self, address: _Address, /) -> None: ...
|
||||||
|
def close(self) -> None: ...
|
||||||
|
def connect(self, address: _Address, /) -> None: ...
|
||||||
|
def connect_ex(self, address: _Address, /) -> int: ...
|
||||||
|
def detach(self) -> int: ...
|
||||||
|
def fileno(self) -> int: ...
|
||||||
|
def getpeername(self) -> _RetAddress: ...
|
||||||
|
def getsockname(self) -> _RetAddress: ...
|
||||||
|
@overload
|
||||||
|
def getsockopt(self, level: int, optname: int, /) -> int: ...
|
||||||
|
@overload
|
||||||
|
def getsockopt(self, level: int, optname: int, buflen: int, /) -> bytes: ...
|
||||||
|
def getblocking(self) -> bool: ...
|
||||||
|
def gettimeout(self) -> float | None: ...
|
||||||
|
if sys.platform == "win32":
|
||||||
|
def ioctl(self, control: int, option: int | tuple[int, int, int] | bool, /) -> None: ...
|
||||||
|
|
||||||
|
def listen(self, backlog: int = ..., /) -> None: ...
|
||||||
|
def recv(self, bufsize: int, flags: int = ..., /) -> bytes: ...
|
||||||
|
def recvfrom(self, bufsize: int, flags: int = ..., /) -> tuple[bytes, _RetAddress]: ...
|
||||||
|
if sys.platform != "win32":
|
||||||
|
def recvmsg(self, bufsize: int, ancbufsize: int = ..., flags: int = ..., /) -> tuple[bytes, list[_CMSG], int, Any]: ...
|
||||||
|
def recvmsg_into(
|
||||||
|
self, buffers: Iterable[WriteableBuffer], ancbufsize: int = ..., flags: int = ..., /
|
||||||
|
) -> tuple[int, list[_CMSG], int, Any]: ...
|
||||||
|
|
||||||
|
def recvfrom_into(self, buffer: WriteableBuffer, nbytes: int = ..., flags: int = ...) -> tuple[int, _RetAddress]: ...
|
||||||
|
def recv_into(self, buffer: WriteableBuffer, nbytes: int = ..., flags: int = ...) -> int: ...
|
||||||
|
def send(self, data: ReadableBuffer, flags: int = ..., /) -> int: ...
|
||||||
|
def sendall(self, data: ReadableBuffer, flags: int = ..., /) -> None: ...
|
||||||
|
@overload
|
||||||
|
def sendto(self, data: ReadableBuffer, address: _Address, /) -> int: ...
|
||||||
|
@overload
|
||||||
|
def sendto(self, data: ReadableBuffer, flags: int, address: _Address, /) -> int: ...
|
||||||
|
if sys.platform != "win32":
|
||||||
|
def sendmsg(
|
||||||
|
self,
|
||||||
|
buffers: Iterable[ReadableBuffer],
|
||||||
|
ancdata: Iterable[_CMSGArg] = ...,
|
||||||
|
flags: int = ...,
|
||||||
|
address: _Address | None = ...,
|
||||||
|
/,
|
||||||
|
) -> int: ...
|
||||||
|
if sys.platform == "linux":
|
||||||
|
def sendmsg_afalg(
|
||||||
|
self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ...
|
||||||
|
) -> int: ...
|
||||||
|
|
||||||
|
def setblocking(self, flag: bool, /) -> None: ...
|
||||||
|
def settimeout(self, value: float | None, /) -> None: ...
|
||||||
|
@overload
|
||||||
|
def setsockopt(self, level: int, optname: int, value: int | ReadableBuffer, /) -> None: ...
|
||||||
|
@overload
|
||||||
|
def setsockopt(self, level: int, optname: int, value: None, optlen: int, /) -> None: ...
|
||||||
|
if sys.platform == "win32":
|
||||||
|
def share(self, process_id: int, /) -> bytes: ...
|
||||||
|
|
||||||
|
def shutdown(self, how: int, /) -> None: ...
|
||||||
|
|
||||||
|
SocketType = socket
|
||||||
|
|
||||||
|
# ===== Functions =====
|
||||||
|
|
||||||
|
def close(fd: SupportsIndex, /) -> None: ...
|
||||||
|
def dup(fd: SupportsIndex, /) -> int: ...
|
||||||
|
|
||||||
|
# the 5th tuple item is an address
|
||||||
|
def getaddrinfo(
|
||||||
|
host: bytes | str | None,
|
||||||
|
port: bytes | str | int | None,
|
||||||
|
family: int = ...,
|
||||||
|
type: int = ...,
|
||||||
|
proto: int = ...,
|
||||||
|
flags: int = ...,
|
||||||
|
) -> list[tuple[int, int, int, str, tuple[str, int] | tuple[str, int, int, int]]]: ...
|
||||||
|
def gethostbyname(hostname: str, /) -> str: ...
|
||||||
|
def gethostbyname_ex(hostname: str, /) -> tuple[str, list[str], list[str]]: ...
|
||||||
|
def gethostname() -> str: ...
|
||||||
|
def gethostbyaddr(ip_address: str, /) -> tuple[str, list[str], list[str]]: ...
|
||||||
|
def getnameinfo(sockaddr: tuple[str, int] | tuple[str, int, int, int], flags: int, /) -> tuple[str, str]: ...
|
||||||
|
def getprotobyname(protocolname: str, /) -> int: ...
|
||||||
|
def getservbyname(servicename: str, protocolname: str = ..., /) -> int: ...
|
||||||
|
def getservbyport(port: int, protocolname: str = ..., /) -> str: ...
|
||||||
|
def ntohl(x: int, /) -> int: ... # param & ret val are 32-bit ints
|
||||||
|
def ntohs(x: int, /) -> int: ... # param & ret val are 16-bit ints
|
||||||
|
def htonl(x: int, /) -> int: ... # param & ret val are 32-bit ints
|
||||||
|
def htons(x: int, /) -> int: ... # param & ret val are 16-bit ints
|
||||||
|
def inet_aton(ip_string: str, /) -> bytes: ... # ret val 4 bytes in length
|
||||||
|
def inet_ntoa(packed_ip: ReadableBuffer, /) -> str: ...
|
||||||
|
def inet_pton(address_family: int, ip_string: str, /) -> bytes: ...
|
||||||
|
def inet_ntop(address_family: int, packed_ip: ReadableBuffer, /) -> str: ...
|
||||||
|
def getdefaulttimeout() -> float | None: ...
|
||||||
|
def setdefaulttimeout(timeout: float | None, /) -> None: ...
|
||||||
|
|
||||||
|
if sys.platform != "win32":
|
||||||
|
def sethostname(name: str, /) -> None: ...
|
||||||
|
def CMSG_LEN(length: int, /) -> int: ...
|
||||||
|
def CMSG_SPACE(length: int, /) -> int: ...
|
||||||
|
def socketpair(family: int = ..., type: int = ..., proto: int = ..., /) -> tuple[socket, socket]: ...
|
||||||
|
|
||||||
|
def if_nameindex() -> list[tuple[int, str]]: ...
|
||||||
|
def if_nametoindex(name: str, /) -> int: ...
|
||||||
|
def if_indextoname(index: int, /) -> str: ...
|
||||||
|
|
||||||
|
CAPI: object
|
||||||
|
|
@ -0,0 +1,103 @@
|
||||||
|
import sys
|
||||||
|
from typing import Literal
|
||||||
|
|
||||||
|
SF_APPEND: Literal[0x00040000]
|
||||||
|
SF_ARCHIVED: Literal[0x00010000]
|
||||||
|
SF_IMMUTABLE: Literal[0x00020000]
|
||||||
|
SF_NOUNLINK: Literal[0x00100000]
|
||||||
|
SF_SNAPSHOT: Literal[0x00200000]
|
||||||
|
|
||||||
|
ST_MODE: Literal[0]
|
||||||
|
ST_INO: Literal[1]
|
||||||
|
ST_DEV: Literal[2]
|
||||||
|
ST_NLINK: Literal[3]
|
||||||
|
ST_UID: Literal[4]
|
||||||
|
ST_GID: Literal[5]
|
||||||
|
ST_SIZE: Literal[6]
|
||||||
|
ST_ATIME: Literal[7]
|
||||||
|
ST_MTIME: Literal[8]
|
||||||
|
ST_CTIME: Literal[9]
|
||||||
|
|
||||||
|
S_IFIFO: Literal[0o010000]
|
||||||
|
S_IFLNK: Literal[0o120000]
|
||||||
|
S_IFREG: Literal[0o100000]
|
||||||
|
S_IFSOCK: Literal[0o140000]
|
||||||
|
S_IFBLK: Literal[0o060000]
|
||||||
|
S_IFCHR: Literal[0o020000]
|
||||||
|
S_IFDIR: Literal[0o040000]
|
||||||
|
|
||||||
|
# These are 0 on systems that don't support the specific kind of file.
|
||||||
|
# Example: Linux doesn't support door files, so S_IFDOOR is 0 on linux.
|
||||||
|
S_IFDOOR: int
|
||||||
|
S_IFPORT: int
|
||||||
|
S_IFWHT: int
|
||||||
|
|
||||||
|
S_ISUID: Literal[0o4000]
|
||||||
|
S_ISGID: Literal[0o2000]
|
||||||
|
S_ISVTX: Literal[0o1000]
|
||||||
|
|
||||||
|
S_IRWXU: Literal[0o0700]
|
||||||
|
S_IRUSR: Literal[0o0400]
|
||||||
|
S_IWUSR: Literal[0o0200]
|
||||||
|
S_IXUSR: Literal[0o0100]
|
||||||
|
|
||||||
|
S_IRWXG: Literal[0o0070]
|
||||||
|
S_IRGRP: Literal[0o0040]
|
||||||
|
S_IWGRP: Literal[0o0020]
|
||||||
|
S_IXGRP: Literal[0o0010]
|
||||||
|
|
||||||
|
S_IRWXO: Literal[0o0007]
|
||||||
|
S_IROTH: Literal[0o0004]
|
||||||
|
S_IWOTH: Literal[0o0002]
|
||||||
|
S_IXOTH: Literal[0o0001]
|
||||||
|
|
||||||
|
S_ENFMT: Literal[0o2000]
|
||||||
|
S_IREAD: Literal[0o0400]
|
||||||
|
S_IWRITE: Literal[0o0200]
|
||||||
|
S_IEXEC: Literal[0o0100]
|
||||||
|
|
||||||
|
UF_APPEND: Literal[0x00000004]
|
||||||
|
UF_COMPRESSED: Literal[0x00000020] # OS X 10.6+ only
|
||||||
|
UF_HIDDEN: Literal[0x00008000] # OX X 10.5+ only
|
||||||
|
UF_IMMUTABLE: Literal[0x00000002]
|
||||||
|
UF_NODUMP: Literal[0x00000001]
|
||||||
|
UF_NOUNLINK: Literal[0x00000010]
|
||||||
|
UF_OPAQUE: Literal[0x00000008]
|
||||||
|
|
||||||
|
def S_IMODE(mode: int) -> int: ...
|
||||||
|
def S_IFMT(mode: int) -> int: ...
|
||||||
|
def S_ISBLK(mode: int) -> bool: ...
|
||||||
|
def S_ISCHR(mode: int) -> bool: ...
|
||||||
|
def S_ISDIR(mode: int) -> bool: ...
|
||||||
|
def S_ISDOOR(mode: int) -> bool: ...
|
||||||
|
def S_ISFIFO(mode: int) -> bool: ...
|
||||||
|
def S_ISLNK(mode: int) -> bool: ...
|
||||||
|
def S_ISPORT(mode: int) -> bool: ...
|
||||||
|
def S_ISREG(mode: int) -> bool: ...
|
||||||
|
def S_ISSOCK(mode: int) -> bool: ...
|
||||||
|
def S_ISWHT(mode: int) -> bool: ...
|
||||||
|
def filemode(mode: int) -> str: ...
|
||||||
|
|
||||||
|
if sys.platform == "win32":
|
||||||
|
IO_REPARSE_TAG_SYMLINK: int
|
||||||
|
IO_REPARSE_TAG_MOUNT_POINT: int
|
||||||
|
IO_REPARSE_TAG_APPEXECLINK: int
|
||||||
|
|
||||||
|
if sys.platform == "win32":
|
||||||
|
FILE_ATTRIBUTE_ARCHIVE: Literal[32]
|
||||||
|
FILE_ATTRIBUTE_COMPRESSED: Literal[2048]
|
||||||
|
FILE_ATTRIBUTE_DEVICE: Literal[64]
|
||||||
|
FILE_ATTRIBUTE_DIRECTORY: Literal[16]
|
||||||
|
FILE_ATTRIBUTE_ENCRYPTED: Literal[16384]
|
||||||
|
FILE_ATTRIBUTE_HIDDEN: Literal[2]
|
||||||
|
FILE_ATTRIBUTE_INTEGRITY_STREAM: Literal[32768]
|
||||||
|
FILE_ATTRIBUTE_NORMAL: Literal[128]
|
||||||
|
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: Literal[8192]
|
||||||
|
FILE_ATTRIBUTE_NO_SCRUB_DATA: Literal[131072]
|
||||||
|
FILE_ATTRIBUTE_OFFLINE: Literal[4096]
|
||||||
|
FILE_ATTRIBUTE_READONLY: Literal[1]
|
||||||
|
FILE_ATTRIBUTE_REPARSE_POINT: Literal[1024]
|
||||||
|
FILE_ATTRIBUTE_SPARSE_FILE: Literal[512]
|
||||||
|
FILE_ATTRIBUTE_SYSTEM: Literal[4]
|
||||||
|
FILE_ATTRIBUTE_TEMPORARY: Literal[256]
|
||||||
|
FILE_ATTRIBUTE_VIRTUAL: Literal[65536]
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
import sys
|
||||||
|
from _typeshed import structseq
|
||||||
|
from collections.abc import Callable
|
||||||
|
from threading import Thread
|
||||||
|
from types import TracebackType
|
||||||
|
from typing import Any, Final, NoReturn, final, overload
|
||||||
|
from typing_extensions import TypeVarTuple, Unpack
|
||||||
|
|
||||||
|
_Ts = TypeVarTuple("_Ts")
|
||||||
|
|
||||||
|
error = RuntimeError
|
||||||
|
|
||||||
|
def _count() -> int: ...
|
||||||
|
@final
|
||||||
|
class LockType:
|
||||||
|
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
|
||||||
|
def release(self) -> None: ...
|
||||||
|
def locked(self) -> bool: ...
|
||||||
|
def __enter__(self) -> bool: ...
|
||||||
|
def __exit__(
|
||||||
|
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def start_new_thread(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]]) -> int: ...
|
||||||
|
@overload
|
||||||
|
def start_new_thread(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any]) -> int: ...
|
||||||
|
def interrupt_main() -> None: ...
|
||||||
|
def exit() -> NoReturn: ...
|
||||||
|
def allocate_lock() -> LockType: ...
|
||||||
|
def get_ident() -> int: ...
|
||||||
|
def stack_size(size: int = ...) -> int: ...
|
||||||
|
|
||||||
|
TIMEOUT_MAX: float
|
||||||
|
|
||||||
|
def get_native_id() -> int: ... # only available on some platforms
|
||||||
|
@final
|
||||||
|
class _ExceptHookArgs(structseq[Any], tuple[type[BaseException], BaseException | None, TracebackType | None, Thread | None]):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__match_args__: Final = ("exc_type", "exc_value", "exc_traceback", "thread")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def exc_type(self) -> type[BaseException]: ...
|
||||||
|
@property
|
||||||
|
def exc_value(self) -> BaseException | None: ...
|
||||||
|
@property
|
||||||
|
def exc_traceback(self) -> TracebackType | None: ...
|
||||||
|
@property
|
||||||
|
def thread(self) -> Thread | None: ...
|
||||||
|
|
||||||
|
_excepthook: Callable[[_ExceptHookArgs], Any]
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
def daemon_threads_allowed() -> bool: ...
|
||||||
|
|
||||||
|
class _local:
|
||||||
|
def __getattribute__(self, name: str, /) -> Any: ...
|
||||||
|
def __setattr__(self, name: str, value: Any, /) -> None: ...
|
||||||
|
def __delattr__(self, name: str, /) -> None: ...
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
from typing import Any
|
||||||
|
from typing_extensions import TypeAlias
|
||||||
|
from weakref import ReferenceType
|
||||||
|
|
||||||
|
__all__ = ["local"]
|
||||||
|
_LocalDict: TypeAlias = dict[Any, Any]
|
||||||
|
|
||||||
|
class _localimpl:
|
||||||
|
key: str
|
||||||
|
dicts: dict[int, tuple[ReferenceType[Any], _LocalDict]]
|
||||||
|
def get_dict(self) -> _LocalDict: ...
|
||||||
|
def create_dict(self) -> _LocalDict: ...
|
||||||
|
|
||||||
|
class local:
|
||||||
|
def __getattribute__(self, name: str) -> Any: ...
|
||||||
|
def __setattr__(self, name: str, value: Any) -> None: ...
|
||||||
|
def __delattr__(self, name: str) -> None: ...
|
||||||
|
|
@ -0,0 +1,121 @@
|
||||||
|
import sys
|
||||||
|
from typing import Any, ClassVar, Literal, final
|
||||||
|
|
||||||
|
# _tkinter is meant to be only used internally by tkinter, but some tkinter
|
||||||
|
# functions e.g. return _tkinter.Tcl_Obj objects. Tcl_Obj represents a Tcl
|
||||||
|
# object that hasn't been converted to a string.
|
||||||
|
#
|
||||||
|
# There are not many ways to get Tcl_Objs from tkinter, and I'm not sure if the
|
||||||
|
# only existing ways are supposed to return Tcl_Objs as opposed to returning
|
||||||
|
# strings. Here's one of these things that return Tcl_Objs:
|
||||||
|
#
|
||||||
|
# >>> import tkinter
|
||||||
|
# >>> text = tkinter.Text()
|
||||||
|
# >>> text.tag_add('foo', '1.0', 'end')
|
||||||
|
# >>> text.tag_ranges('foo')
|
||||||
|
# (<textindex object: '1.0'>, <textindex object: '2.0'>)
|
||||||
|
@final
|
||||||
|
class Tcl_Obj:
|
||||||
|
@property
|
||||||
|
def string(self) -> str: ...
|
||||||
|
@property
|
||||||
|
def typename(self) -> str: ...
|
||||||
|
__hash__: ClassVar[None] # type: ignore[assignment]
|
||||||
|
def __eq__(self, value, /): ...
|
||||||
|
def __ge__(self, value, /): ...
|
||||||
|
def __gt__(self, value, /): ...
|
||||||
|
def __le__(self, value, /): ...
|
||||||
|
def __lt__(self, value, /): ...
|
||||||
|
def __ne__(self, value, /): ...
|
||||||
|
|
||||||
|
class TclError(Exception): ...
|
||||||
|
|
||||||
|
# This class allows running Tcl code. Tkinter uses it internally a lot, and
|
||||||
|
# it's often handy to drop a piece of Tcl code into a tkinter program. Example:
|
||||||
|
#
|
||||||
|
# >>> import tkinter, _tkinter
|
||||||
|
# >>> tkapp = tkinter.Tk().tk
|
||||||
|
# >>> isinstance(tkapp, _tkinter.TkappType)
|
||||||
|
# True
|
||||||
|
# >>> tkapp.call('set', 'foo', (1,2,3))
|
||||||
|
# (1, 2, 3)
|
||||||
|
# >>> tkapp.eval('return $foo')
|
||||||
|
# '1 2 3'
|
||||||
|
# >>>
|
||||||
|
#
|
||||||
|
# call args can be pretty much anything. Also, call(some_tuple) is same as call(*some_tuple).
|
||||||
|
#
|
||||||
|
# eval always returns str because _tkinter_tkapp_eval_impl in _tkinter.c calls
|
||||||
|
# Tkapp_UnicodeResult, and it returns a string when it succeeds.
|
||||||
|
@final
|
||||||
|
class TkappType:
|
||||||
|
# Please keep in sync with tkinter.Tk
|
||||||
|
def adderrorinfo(self, msg, /): ...
|
||||||
|
def call(self, command: Any, /, *args: Any) -> Any: ...
|
||||||
|
def createcommand(self, name, func, /): ...
|
||||||
|
if sys.platform != "win32":
|
||||||
|
def createfilehandler(self, file, mask, func, /): ...
|
||||||
|
def deletefilehandler(self, file, /): ...
|
||||||
|
|
||||||
|
def createtimerhandler(self, milliseconds, func, /): ...
|
||||||
|
def deletecommand(self, name, /): ...
|
||||||
|
def dooneevent(self, flags: int = 0, /): ...
|
||||||
|
def eval(self, script: str, /) -> str: ...
|
||||||
|
def evalfile(self, fileName, /): ...
|
||||||
|
def exprboolean(self, s, /): ...
|
||||||
|
def exprdouble(self, s, /): ...
|
||||||
|
def exprlong(self, s, /): ...
|
||||||
|
def exprstring(self, s, /): ...
|
||||||
|
def getboolean(self, arg, /): ...
|
||||||
|
def getdouble(self, arg, /): ...
|
||||||
|
def getint(self, arg, /): ...
|
||||||
|
def getvar(self, *args, **kwargs): ...
|
||||||
|
def globalgetvar(self, *args, **kwargs): ...
|
||||||
|
def globalsetvar(self, *args, **kwargs): ...
|
||||||
|
def globalunsetvar(self, *args, **kwargs): ...
|
||||||
|
def interpaddr(self): ...
|
||||||
|
def loadtk(self) -> None: ...
|
||||||
|
def mainloop(self, threshold: int = 0, /): ...
|
||||||
|
def quit(self): ...
|
||||||
|
def record(self, script, /): ...
|
||||||
|
def setvar(self, *ags, **kwargs): ...
|
||||||
|
if sys.version_info < (3, 11):
|
||||||
|
def split(self, arg, /): ...
|
||||||
|
|
||||||
|
def splitlist(self, arg, /): ...
|
||||||
|
def unsetvar(self, *args, **kwargs): ...
|
||||||
|
def wantobjects(self, *args, **kwargs): ...
|
||||||
|
def willdispatch(self): ...
|
||||||
|
|
||||||
|
# These should be kept in sync with tkinter.tix constants, except ALL_EVENTS which doesn't match TCL_ALL_EVENTS
|
||||||
|
ALL_EVENTS: Literal[-3]
|
||||||
|
FILE_EVENTS: Literal[8]
|
||||||
|
IDLE_EVENTS: Literal[32]
|
||||||
|
TIMER_EVENTS: Literal[16]
|
||||||
|
WINDOW_EVENTS: Literal[4]
|
||||||
|
|
||||||
|
DONT_WAIT: Literal[2]
|
||||||
|
EXCEPTION: Literal[8]
|
||||||
|
READABLE: Literal[2]
|
||||||
|
WRITABLE: Literal[4]
|
||||||
|
|
||||||
|
TCL_VERSION: str
|
||||||
|
TK_VERSION: str
|
||||||
|
|
||||||
|
@final
|
||||||
|
class TkttType:
|
||||||
|
def deletetimerhandler(self): ...
|
||||||
|
|
||||||
|
def create(
|
||||||
|
screenName: str | None = None,
|
||||||
|
baseName: str = "",
|
||||||
|
className: str = "Tk",
|
||||||
|
interactive: bool = False,
|
||||||
|
wantobjects: bool = False,
|
||||||
|
wantTk: bool = True,
|
||||||
|
sync: bool = False,
|
||||||
|
use: str | None = None,
|
||||||
|
/,
|
||||||
|
): ...
|
||||||
|
def getbusywaitinterval(): ...
|
||||||
|
def setbusywaitinterval(new_val, /): ...
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
import sys
|
||||||
|
from collections.abc import Sequence
|
||||||
|
from tracemalloc import _FrameTuple, _TraceTuple
|
||||||
|
|
||||||
|
def _get_object_traceback(obj: object, /) -> Sequence[_FrameTuple] | None: ...
|
||||||
|
def _get_traces() -> Sequence[_TraceTuple]: ...
|
||||||
|
def clear_traces() -> None: ...
|
||||||
|
def get_traceback_limit() -> int: ...
|
||||||
|
def get_traced_memory() -> tuple[int, int]: ...
|
||||||
|
def get_tracemalloc_memory() -> int: ...
|
||||||
|
def is_tracing() -> bool: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
def reset_peak() -> None: ...
|
||||||
|
|
||||||
|
def start(nframe: int = 1, /) -> None: ...
|
||||||
|
def stop() -> None: ...
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Utility types for typeshed
|
||||||
|
|
||||||
|
This package and its submodules contains various common types used by
|
||||||
|
typeshed. It can also be used by packages outside typeshed, but beware
|
||||||
|
the API stability guarantees below.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
The `_typeshed` package and its types do not exist at runtime, but can be
|
||||||
|
used freely in stubs (`.pyi`) files. To import the types from this package in
|
||||||
|
implementation (`.py`) files, use the following construct:
|
||||||
|
|
||||||
|
```python
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from _typeshed import ...
|
||||||
|
```
|
||||||
|
|
||||||
|
Types can then be used in annotations by either quoting them or
|
||||||
|
using:
|
||||||
|
|
||||||
|
```python
|
||||||
|
from __future__ import annotations
|
||||||
|
```
|
||||||
|
|
||||||
|
## API Stability
|
||||||
|
|
||||||
|
You can use this package and its submodules outside of typeshed, but we
|
||||||
|
guarantee only limited API stability. Items marked as "stable" will not be
|
||||||
|
removed or changed in an incompatible way for at least one year.
|
||||||
|
Before making such a change, the "stable" moniker will be removed
|
||||||
|
and we will mark the type in question as deprecated. No guarantees
|
||||||
|
are made about unmarked types.
|
||||||
|
|
@ -0,0 +1,361 @@
|
||||||
|
# Utility types for typeshed
|
||||||
|
#
|
||||||
|
# See the README.md file in this directory for more information.
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from collections.abc import Awaitable, Callable, Iterable, Sequence, Set as AbstractSet, Sized
|
||||||
|
from dataclasses import Field
|
||||||
|
from os import PathLike
|
||||||
|
from types import FrameType, TracebackType
|
||||||
|
from typing import (
|
||||||
|
Any,
|
||||||
|
AnyStr,
|
||||||
|
ClassVar,
|
||||||
|
Final,
|
||||||
|
Generic,
|
||||||
|
Literal,
|
||||||
|
Protocol,
|
||||||
|
SupportsFloat,
|
||||||
|
SupportsIndex,
|
||||||
|
SupportsInt,
|
||||||
|
TypeVar,
|
||||||
|
final,
|
||||||
|
overload,
|
||||||
|
)
|
||||||
|
from typing_extensions import Buffer, LiteralString, TypeAlias
|
||||||
|
|
||||||
|
_KT = TypeVar("_KT")
|
||||||
|
_KT_co = TypeVar("_KT_co", covariant=True)
|
||||||
|
_KT_contra = TypeVar("_KT_contra", contravariant=True)
|
||||||
|
_VT = TypeVar("_VT")
|
||||||
|
_VT_co = TypeVar("_VT_co", covariant=True)
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
_T_co = TypeVar("_T_co", covariant=True)
|
||||||
|
_T_contra = TypeVar("_T_contra", contravariant=True)
|
||||||
|
|
||||||
|
# Alternative to `typing_extensions.Self`, exclusively for use with `__new__`
|
||||||
|
# in metaclasses:
|
||||||
|
# def __new__(cls: type[Self], ...) -> Self: ...
|
||||||
|
# In other cases, use `typing_extensions.Self`.
|
||||||
|
Self = TypeVar("Self") # noqa: Y001
|
||||||
|
|
||||||
|
# covariant version of typing.AnyStr, useful for protocols
|
||||||
|
AnyStr_co = TypeVar("AnyStr_co", str, bytes, covariant=True) # noqa: Y001
|
||||||
|
|
||||||
|
# For partially known annotations. Usually, fields where type annotations
|
||||||
|
# haven't been added are left unannotated, but in some situations this
|
||||||
|
# isn't possible or a type is already partially known. In cases like these,
|
||||||
|
# use Incomplete instead of Any as a marker. For example, use
|
||||||
|
# "Incomplete | None" instead of "Any | None".
|
||||||
|
Incomplete: TypeAlias = Any # stable
|
||||||
|
|
||||||
|
# To describe a function parameter that is unused and will work with anything.
|
||||||
|
Unused: TypeAlias = object # stable
|
||||||
|
|
||||||
|
# Marker for return types that include None, but where forcing the user to
|
||||||
|
# check for None can be detrimental. Sometimes called "the Any trick". See
|
||||||
|
# CONTRIBUTING.md for more information.
|
||||||
|
MaybeNone: TypeAlias = Any # stable
|
||||||
|
|
||||||
|
# Used to mark arguments that default to a sentinel value. This prevents
|
||||||
|
# stubtest from complaining about the default value not matching.
|
||||||
|
#
|
||||||
|
# def foo(x: int | None = sentinel) -> None: ...
|
||||||
|
#
|
||||||
|
# In cases where the sentinel object is exported and can be used by user code,
|
||||||
|
# a construct like this is better:
|
||||||
|
#
|
||||||
|
# _SentinelType = NewType("_SentinelType", object)
|
||||||
|
# sentinel: _SentinelType
|
||||||
|
# def foo(x: int | None | _SentinelType = ...) -> None: ...
|
||||||
|
sentinel: Any
|
||||||
|
|
||||||
|
# stable
|
||||||
|
class IdentityFunction(Protocol):
|
||||||
|
def __call__(self, x: _T, /) -> _T: ...
|
||||||
|
|
||||||
|
# stable
|
||||||
|
class SupportsNext(Protocol[_T_co]):
|
||||||
|
def __next__(self) -> _T_co: ...
|
||||||
|
|
||||||
|
# stable
|
||||||
|
class SupportsAnext(Protocol[_T_co]):
|
||||||
|
def __anext__(self) -> Awaitable[_T_co]: ...
|
||||||
|
|
||||||
|
# Comparison protocols
|
||||||
|
|
||||||
|
class SupportsDunderLT(Protocol[_T_contra]):
|
||||||
|
def __lt__(self, other: _T_contra, /) -> bool: ...
|
||||||
|
|
||||||
|
class SupportsDunderGT(Protocol[_T_contra]):
|
||||||
|
def __gt__(self, other: _T_contra, /) -> bool: ...
|
||||||
|
|
||||||
|
class SupportsDunderLE(Protocol[_T_contra]):
|
||||||
|
def __le__(self, other: _T_contra, /) -> bool: ...
|
||||||
|
|
||||||
|
class SupportsDunderGE(Protocol[_T_contra]):
|
||||||
|
def __ge__(self, other: _T_contra, /) -> bool: ...
|
||||||
|
|
||||||
|
class SupportsAllComparisons(
|
||||||
|
SupportsDunderLT[Any], SupportsDunderGT[Any], SupportsDunderLE[Any], SupportsDunderGE[Any], Protocol
|
||||||
|
): ...
|
||||||
|
|
||||||
|
SupportsRichComparison: TypeAlias = SupportsDunderLT[Any] | SupportsDunderGT[Any]
|
||||||
|
SupportsRichComparisonT = TypeVar("SupportsRichComparisonT", bound=SupportsRichComparison) # noqa: Y001
|
||||||
|
|
||||||
|
# Dunder protocols
|
||||||
|
|
||||||
|
class SupportsAdd(Protocol[_T_contra, _T_co]):
|
||||||
|
def __add__(self, x: _T_contra, /) -> _T_co: ...
|
||||||
|
|
||||||
|
class SupportsRAdd(Protocol[_T_contra, _T_co]):
|
||||||
|
def __radd__(self, x: _T_contra, /) -> _T_co: ...
|
||||||
|
|
||||||
|
class SupportsSub(Protocol[_T_contra, _T_co]):
|
||||||
|
def __sub__(self, x: _T_contra, /) -> _T_co: ...
|
||||||
|
|
||||||
|
class SupportsRSub(Protocol[_T_contra, _T_co]):
|
||||||
|
def __rsub__(self, x: _T_contra, /) -> _T_co: ...
|
||||||
|
|
||||||
|
class SupportsDivMod(Protocol[_T_contra, _T_co]):
|
||||||
|
def __divmod__(self, other: _T_contra, /) -> _T_co: ...
|
||||||
|
|
||||||
|
class SupportsRDivMod(Protocol[_T_contra, _T_co]):
|
||||||
|
def __rdivmod__(self, other: _T_contra, /) -> _T_co: ...
|
||||||
|
|
||||||
|
# This protocol is generic over the iterator type, while Iterable is
|
||||||
|
# generic over the type that is iterated over.
|
||||||
|
class SupportsIter(Protocol[_T_co]):
|
||||||
|
def __iter__(self) -> _T_co: ...
|
||||||
|
|
||||||
|
# This protocol is generic over the iterator type, while AsyncIterable is
|
||||||
|
# generic over the type that is iterated over.
|
||||||
|
class SupportsAiter(Protocol[_T_co]):
|
||||||
|
def __aiter__(self) -> _T_co: ...
|
||||||
|
|
||||||
|
class SupportsLenAndGetItem(Protocol[_T_co]):
|
||||||
|
def __len__(self) -> int: ...
|
||||||
|
def __getitem__(self, k: int, /) -> _T_co: ...
|
||||||
|
|
||||||
|
class SupportsTrunc(Protocol):
|
||||||
|
def __trunc__(self) -> int: ...
|
||||||
|
|
||||||
|
# Mapping-like protocols
|
||||||
|
|
||||||
|
# stable
|
||||||
|
class SupportsItems(Protocol[_KT_co, _VT_co]):
|
||||||
|
def items(self) -> AbstractSet[tuple[_KT_co, _VT_co]]: ...
|
||||||
|
|
||||||
|
# stable
|
||||||
|
class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]):
|
||||||
|
def keys(self) -> Iterable[_KT]: ...
|
||||||
|
def __getitem__(self, key: _KT, /) -> _VT_co: ...
|
||||||
|
|
||||||
|
# This protocol is currently under discussion. Use SupportsContainsAndGetItem
|
||||||
|
# instead, if you require the __contains__ method.
|
||||||
|
# See https://github.com/python/typeshed/issues/11822.
|
||||||
|
class SupportsGetItem(Protocol[_KT_contra, _VT_co]):
|
||||||
|
def __contains__(self, x: Any, /) -> bool: ...
|
||||||
|
def __getitem__(self, key: _KT_contra, /) -> _VT_co: ...
|
||||||
|
|
||||||
|
# stable
|
||||||
|
class SupportsContainsAndGetItem(Protocol[_KT_contra, _VT_co]):
|
||||||
|
def __contains__(self, x: Any, /) -> bool: ...
|
||||||
|
def __getitem__(self, key: _KT_contra, /) -> _VT_co: ...
|
||||||
|
|
||||||
|
# stable
|
||||||
|
class SupportsItemAccess(Protocol[_KT_contra, _VT]):
|
||||||
|
def __contains__(self, x: Any, /) -> bool: ...
|
||||||
|
def __getitem__(self, key: _KT_contra, /) -> _VT: ...
|
||||||
|
def __setitem__(self, key: _KT_contra, value: _VT, /) -> None: ...
|
||||||
|
def __delitem__(self, key: _KT_contra, /) -> None: ...
|
||||||
|
|
||||||
|
StrPath: TypeAlias = str | PathLike[str] # stable
|
||||||
|
BytesPath: TypeAlias = bytes | PathLike[bytes] # stable
|
||||||
|
GenericPath: TypeAlias = AnyStr | PathLike[AnyStr]
|
||||||
|
StrOrBytesPath: TypeAlias = str | bytes | PathLike[str] | PathLike[bytes] # stable
|
||||||
|
|
||||||
|
OpenTextModeUpdating: TypeAlias = Literal[
|
||||||
|
"r+",
|
||||||
|
"+r",
|
||||||
|
"rt+",
|
||||||
|
"r+t",
|
||||||
|
"+rt",
|
||||||
|
"tr+",
|
||||||
|
"t+r",
|
||||||
|
"+tr",
|
||||||
|
"w+",
|
||||||
|
"+w",
|
||||||
|
"wt+",
|
||||||
|
"w+t",
|
||||||
|
"+wt",
|
||||||
|
"tw+",
|
||||||
|
"t+w",
|
||||||
|
"+tw",
|
||||||
|
"a+",
|
||||||
|
"+a",
|
||||||
|
"at+",
|
||||||
|
"a+t",
|
||||||
|
"+at",
|
||||||
|
"ta+",
|
||||||
|
"t+a",
|
||||||
|
"+ta",
|
||||||
|
"x+",
|
||||||
|
"+x",
|
||||||
|
"xt+",
|
||||||
|
"x+t",
|
||||||
|
"+xt",
|
||||||
|
"tx+",
|
||||||
|
"t+x",
|
||||||
|
"+tx",
|
||||||
|
]
|
||||||
|
OpenTextModeWriting: TypeAlias = Literal["w", "wt", "tw", "a", "at", "ta", "x", "xt", "tx"]
|
||||||
|
OpenTextModeReading: TypeAlias = Literal["r", "rt", "tr", "U", "rU", "Ur", "rtU", "rUt", "Urt", "trU", "tUr", "Utr"]
|
||||||
|
OpenTextMode: TypeAlias = OpenTextModeUpdating | OpenTextModeWriting | OpenTextModeReading
|
||||||
|
OpenBinaryModeUpdating: TypeAlias = Literal[
|
||||||
|
"rb+",
|
||||||
|
"r+b",
|
||||||
|
"+rb",
|
||||||
|
"br+",
|
||||||
|
"b+r",
|
||||||
|
"+br",
|
||||||
|
"wb+",
|
||||||
|
"w+b",
|
||||||
|
"+wb",
|
||||||
|
"bw+",
|
||||||
|
"b+w",
|
||||||
|
"+bw",
|
||||||
|
"ab+",
|
||||||
|
"a+b",
|
||||||
|
"+ab",
|
||||||
|
"ba+",
|
||||||
|
"b+a",
|
||||||
|
"+ba",
|
||||||
|
"xb+",
|
||||||
|
"x+b",
|
||||||
|
"+xb",
|
||||||
|
"bx+",
|
||||||
|
"b+x",
|
||||||
|
"+bx",
|
||||||
|
]
|
||||||
|
OpenBinaryModeWriting: TypeAlias = Literal["wb", "bw", "ab", "ba", "xb", "bx"]
|
||||||
|
OpenBinaryModeReading: TypeAlias = Literal["rb", "br", "rbU", "rUb", "Urb", "brU", "bUr", "Ubr"]
|
||||||
|
OpenBinaryMode: TypeAlias = OpenBinaryModeUpdating | OpenBinaryModeReading | OpenBinaryModeWriting
|
||||||
|
|
||||||
|
# stable
|
||||||
|
class HasFileno(Protocol):
|
||||||
|
def fileno(self) -> int: ...
|
||||||
|
|
||||||
|
FileDescriptor: TypeAlias = int # stable
|
||||||
|
FileDescriptorLike: TypeAlias = int | HasFileno # stable
|
||||||
|
FileDescriptorOrPath: TypeAlias = int | StrOrBytesPath
|
||||||
|
|
||||||
|
# stable
|
||||||
|
class SupportsRead(Protocol[_T_co]):
|
||||||
|
def read(self, length: int = ..., /) -> _T_co: ...
|
||||||
|
|
||||||
|
# stable
|
||||||
|
class SupportsReadline(Protocol[_T_co]):
|
||||||
|
def readline(self, length: int = ..., /) -> _T_co: ...
|
||||||
|
|
||||||
|
# stable
|
||||||
|
class SupportsNoArgReadline(Protocol[_T_co]):
|
||||||
|
def readline(self) -> _T_co: ...
|
||||||
|
|
||||||
|
# stable
|
||||||
|
class SupportsWrite(Protocol[_T_contra]):
|
||||||
|
def write(self, s: _T_contra, /) -> object: ...
|
||||||
|
|
||||||
|
# stable
|
||||||
|
class SupportsFlush(Protocol):
|
||||||
|
def flush(self) -> object: ...
|
||||||
|
|
||||||
|
# Unfortunately PEP 688 does not allow us to distinguish read-only
|
||||||
|
# from writable buffers. We use these aliases for readability for now.
|
||||||
|
# Perhaps a future extension of the buffer protocol will allow us to
|
||||||
|
# distinguish these cases in the type system.
|
||||||
|
ReadOnlyBuffer: TypeAlias = Buffer # stable
|
||||||
|
# Anything that implements the read-write buffer interface.
|
||||||
|
WriteableBuffer: TypeAlias = Buffer
|
||||||
|
# Same as WriteableBuffer, but also includes read-only buffer types (like bytes).
|
||||||
|
ReadableBuffer: TypeAlias = Buffer # stable
|
||||||
|
|
||||||
|
class SliceableBuffer(Buffer, Protocol):
|
||||||
|
def __getitem__(self, slice: slice, /) -> Sequence[int]: ...
|
||||||
|
|
||||||
|
class IndexableBuffer(Buffer, Protocol):
|
||||||
|
def __getitem__(self, i: int, /) -> int: ...
|
||||||
|
|
||||||
|
class SupportsGetItemBuffer(SliceableBuffer, IndexableBuffer, Protocol):
|
||||||
|
def __contains__(self, x: Any, /) -> bool: ...
|
||||||
|
@overload
|
||||||
|
def __getitem__(self, slice: slice, /) -> Sequence[int]: ...
|
||||||
|
@overload
|
||||||
|
def __getitem__(self, i: int, /) -> int: ...
|
||||||
|
|
||||||
|
class SizedBuffer(Sized, Buffer, Protocol): ...
|
||||||
|
|
||||||
|
# for compatibility with third-party stubs that may use this
|
||||||
|
_BufferWithLen: TypeAlias = SizedBuffer # not stable # noqa: Y047
|
||||||
|
|
||||||
|
ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, TracebackType]
|
||||||
|
OptExcInfo: TypeAlias = ExcInfo | tuple[None, None, None]
|
||||||
|
|
||||||
|
# stable
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
from types import NoneType as NoneType
|
||||||
|
else:
|
||||||
|
# Used by type checkers for checks involving None (does not exist at runtime)
|
||||||
|
@final
|
||||||
|
class NoneType:
|
||||||
|
def __bool__(self) -> Literal[False]: ...
|
||||||
|
|
||||||
|
# This is an internal CPython type that is like, but subtly different from, a NamedTuple
|
||||||
|
# Subclasses of this type are found in multiple modules.
|
||||||
|
# In typeshed, `structseq` is only ever used as a mixin in combination with a fixed-length `Tuple`
|
||||||
|
# See discussion at #6546 & #6560
|
||||||
|
# `structseq` classes are unsubclassable, so are all decorated with `@final`.
|
||||||
|
class structseq(Generic[_T_co]):
|
||||||
|
n_fields: Final[int]
|
||||||
|
n_unnamed_fields: Final[int]
|
||||||
|
n_sequence_fields: Final[int]
|
||||||
|
# The first parameter will generally only take an iterable of a specific length.
|
||||||
|
# E.g. `os.uname_result` takes any iterable of length exactly 5.
|
||||||
|
#
|
||||||
|
# The second parameter will accept a dict of any kind without raising an exception,
|
||||||
|
# but only has any meaning if you supply it a dict where the keys are strings.
|
||||||
|
# https://github.com/python/typeshed/pull/6560#discussion_r767149830
|
||||||
|
def __new__(cls: type[Self], sequence: Iterable[_T_co], dict: dict[str, Any] = ...) -> Self: ...
|
||||||
|
|
||||||
|
# Superset of typing.AnyStr that also includes LiteralString
|
||||||
|
AnyOrLiteralStr = TypeVar("AnyOrLiteralStr", str, bytes, LiteralString) # noqa: Y001
|
||||||
|
|
||||||
|
# Represents when str or LiteralStr is acceptable. Useful for string processing
|
||||||
|
# APIs where literalness of return value depends on literalness of inputs
|
||||||
|
StrOrLiteralStr = TypeVar("StrOrLiteralStr", LiteralString, str) # noqa: Y001
|
||||||
|
|
||||||
|
# Objects suitable to be passed to sys.setprofile, threading.setprofile, and similar
|
||||||
|
ProfileFunction: TypeAlias = Callable[[FrameType, str, Any], object]
|
||||||
|
|
||||||
|
# Objects suitable to be passed to sys.settrace, threading.settrace, and similar
|
||||||
|
TraceFunction: TypeAlias = Callable[[FrameType, str, Any], TraceFunction | None]
|
||||||
|
|
||||||
|
# experimental
|
||||||
|
# Might not work as expected for pyright, see
|
||||||
|
# https://github.com/python/typeshed/pull/9362
|
||||||
|
# https://github.com/microsoft/pyright/issues/4339
|
||||||
|
class DataclassInstance(Protocol):
|
||||||
|
__dataclass_fields__: ClassVar[dict[str, Field[Any]]]
|
||||||
|
|
||||||
|
# Anything that can be passed to the int/float constructors
|
||||||
|
ConvertibleToInt: TypeAlias = str | ReadableBuffer | SupportsInt | SupportsIndex | SupportsTrunc
|
||||||
|
ConvertibleToFloat: TypeAlias = str | ReadableBuffer | SupportsFloat | SupportsIndex
|
||||||
|
|
||||||
|
# A few classes updated from Foo(str, Enum) to Foo(StrEnum). This is a convenience so these
|
||||||
|
# can be accurate on all python versions without getting too wordy
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
from enum import StrEnum as StrEnum
|
||||||
|
else:
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
class StrEnum(str, Enum): ...
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
# PEP 249 Database API 2.0 Types
|
||||||
|
# https://www.python.org/dev/peps/pep-0249/
|
||||||
|
|
||||||
|
from collections.abc import Mapping, Sequence
|
||||||
|
from typing import Any, Protocol
|
||||||
|
from typing_extensions import TypeAlias
|
||||||
|
|
||||||
|
DBAPITypeCode: TypeAlias = Any | None
|
||||||
|
# Strictly speaking, this should be a Sequence, but the type system does
|
||||||
|
# not support fixed-length sequences.
|
||||||
|
DBAPIColumnDescription: TypeAlias = tuple[str, DBAPITypeCode, int | None, int | None, int | None, int | None, bool | None]
|
||||||
|
|
||||||
|
class DBAPIConnection(Protocol):
|
||||||
|
def close(self) -> object: ...
|
||||||
|
def commit(self) -> object: ...
|
||||||
|
# optional:
|
||||||
|
# def rollback(self) -> Any: ...
|
||||||
|
def cursor(self) -> DBAPICursor: ...
|
||||||
|
|
||||||
|
class DBAPICursor(Protocol):
|
||||||
|
@property
|
||||||
|
def description(self) -> Sequence[DBAPIColumnDescription] | None: ...
|
||||||
|
@property
|
||||||
|
def rowcount(self) -> int: ...
|
||||||
|
# optional:
|
||||||
|
# def callproc(self, procname: str, parameters: Sequence[Any] = ..., /) -> Sequence[Any]: ...
|
||||||
|
def close(self) -> object: ...
|
||||||
|
def execute(self, operation: str, parameters: Sequence[Any] | Mapping[str, Any] = ..., /) -> object: ...
|
||||||
|
def executemany(self, operation: str, seq_of_parameters: Sequence[Sequence[Any]], /) -> object: ...
|
||||||
|
def fetchone(self) -> Sequence[Any] | None: ...
|
||||||
|
def fetchmany(self, size: int = ..., /) -> Sequence[Sequence[Any]]: ...
|
||||||
|
def fetchall(self) -> Sequence[Sequence[Any]]: ...
|
||||||
|
# optional:
|
||||||
|
# def nextset(self) -> None | Literal[True]: ...
|
||||||
|
arraysize: int
|
||||||
|
def setinputsizes(self, sizes: Sequence[DBAPITypeCode | int | None], /) -> object: ...
|
||||||
|
def setoutputsize(self, size: int, column: int = ..., /) -> object: ...
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
# Types to support PEP 3333 (WSGI)
|
||||||
|
#
|
||||||
|
# Obsolete since Python 3.11: Use wsgiref.types instead.
|
||||||
|
#
|
||||||
|
# See the README.md file in this directory for more information.
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from _typeshed import OptExcInfo
|
||||||
|
from collections.abc import Callable, Iterable, Iterator
|
||||||
|
from typing import Any, Protocol
|
||||||
|
from typing_extensions import TypeAlias
|
||||||
|
|
||||||
|
class _Readable(Protocol):
|
||||||
|
def read(self, size: int = ..., /) -> bytes: ...
|
||||||
|
# Optional: def close(self) -> object: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
from wsgiref.types import *
|
||||||
|
else:
|
||||||
|
# stable
|
||||||
|
class StartResponse(Protocol):
|
||||||
|
def __call__(
|
||||||
|
self, status: str, headers: list[tuple[str, str]], exc_info: OptExcInfo | None = ..., /
|
||||||
|
) -> Callable[[bytes], object]: ...
|
||||||
|
|
||||||
|
WSGIEnvironment: TypeAlias = dict[str, Any] # stable
|
||||||
|
WSGIApplication: TypeAlias = Callable[[WSGIEnvironment, StartResponse], Iterable[bytes]] # stable
|
||||||
|
|
||||||
|
# WSGI input streams per PEP 3333, stable
|
||||||
|
class InputStream(Protocol):
|
||||||
|
def read(self, size: int = ..., /) -> bytes: ...
|
||||||
|
def readline(self, size: int = ..., /) -> bytes: ...
|
||||||
|
def readlines(self, hint: int = ..., /) -> list[bytes]: ...
|
||||||
|
def __iter__(self) -> Iterator[bytes]: ...
|
||||||
|
|
||||||
|
# WSGI error streams per PEP 3333, stable
|
||||||
|
class ErrorStream(Protocol):
|
||||||
|
def flush(self) -> object: ...
|
||||||
|
def write(self, s: str, /) -> object: ...
|
||||||
|
def writelines(self, seq: list[str], /) -> object: ...
|
||||||
|
|
||||||
|
# Optional file wrapper in wsgi.file_wrapper
|
||||||
|
class FileWrapper(Protocol):
|
||||||
|
def __call__(self, file: _Readable, block_size: int = ..., /) -> Iterable[bytes]: ...
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
# See the README.md file in this directory for more information.
|
||||||
|
|
||||||
|
from typing import Any, Protocol
|
||||||
|
|
||||||
|
# As defined https://docs.python.org/3/library/xml.dom.html#domimplementation-objects
|
||||||
|
class DOMImplementation(Protocol):
|
||||||
|
def hasFeature(self, feature: str, version: str | None, /) -> bool: ...
|
||||||
|
def createDocument(self, namespaceUri: str, qualifiedName: str, doctype: Any | None, /) -> Any: ...
|
||||||
|
def createDocumentType(self, qualifiedName: str, publicId: str, systemId: str, /) -> Any: ...
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
import sys
|
||||||
|
from typing import Any, overload
|
||||||
|
|
||||||
|
_defaultaction: str
|
||||||
|
_onceregistry: dict[Any, Any]
|
||||||
|
filters: list[tuple[str, str | None, type[Warning], str | None, int]]
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
@overload
|
||||||
|
def warn(
|
||||||
|
message: str,
|
||||||
|
category: type[Warning] | None = None,
|
||||||
|
stacklevel: int = 1,
|
||||||
|
source: Any | None = None,
|
||||||
|
*,
|
||||||
|
skip_file_prefixes: tuple[str, ...] = (),
|
||||||
|
) -> None: ...
|
||||||
|
@overload
|
||||||
|
def warn(
|
||||||
|
message: Warning,
|
||||||
|
category: Any = None,
|
||||||
|
stacklevel: int = 1,
|
||||||
|
source: Any | None = None,
|
||||||
|
*,
|
||||||
|
skip_file_prefixes: tuple[str, ...] = (),
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
@overload
|
||||||
|
def warn(message: str, category: type[Warning] | None = None, stacklevel: int = 1, source: Any | None = None) -> None: ...
|
||||||
|
@overload
|
||||||
|
def warn(message: Warning, category: Any = None, stacklevel: int = 1, source: Any | None = None) -> None: ...
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def warn_explicit(
|
||||||
|
message: str,
|
||||||
|
category: type[Warning],
|
||||||
|
filename: str,
|
||||||
|
lineno: int,
|
||||||
|
module: str | None = ...,
|
||||||
|
registry: dict[str | tuple[str, type[Warning], int], int] | None = ...,
|
||||||
|
module_globals: dict[str, Any] | None = ...,
|
||||||
|
source: Any | None = ...,
|
||||||
|
) -> None: ...
|
||||||
|
@overload
|
||||||
|
def warn_explicit(
|
||||||
|
message: Warning,
|
||||||
|
category: Any,
|
||||||
|
filename: str,
|
||||||
|
lineno: int,
|
||||||
|
module: str | None = ...,
|
||||||
|
registry: dict[str | tuple[str, type[Warning], int], int] | None = ...,
|
||||||
|
module_globals: dict[str, Any] | None = ...,
|
||||||
|
source: Any | None = ...,
|
||||||
|
) -> None: ...
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
import sys
|
||||||
|
from collections.abc import Callable
|
||||||
|
from typing import Any, Generic, TypeVar, final, overload
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
from types import GenericAlias
|
||||||
|
|
||||||
|
_C = TypeVar("_C", bound=Callable[..., Any])
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
|
||||||
|
@final
|
||||||
|
class CallableProxyType(Generic[_C]): # "weakcallableproxy"
|
||||||
|
def __eq__(self, value: object, /) -> bool: ...
|
||||||
|
def __getattr__(self, attr: str) -> Any: ...
|
||||||
|
__call__: _C
|
||||||
|
|
||||||
|
@final
|
||||||
|
class ProxyType(Generic[_T]): # "weakproxy"
|
||||||
|
def __eq__(self, value: object, /) -> bool: ...
|
||||||
|
def __getattr__(self, attr: str) -> Any: ...
|
||||||
|
|
||||||
|
class ReferenceType(Generic[_T]):
|
||||||
|
__callback__: Callable[[ReferenceType[_T]], Any]
|
||||||
|
def __new__(cls, o: _T, callback: Callable[[ReferenceType[_T]], Any] | None = ..., /) -> Self: ...
|
||||||
|
def __call__(self) -> _T | None: ...
|
||||||
|
def __eq__(self, value: object, /) -> bool: ...
|
||||||
|
def __hash__(self) -> int: ...
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||||
|
|
||||||
|
ref = ReferenceType
|
||||||
|
|
||||||
|
def getweakrefcount(object: Any, /) -> int: ...
|
||||||
|
def getweakrefs(object: Any, /) -> list[Any]: ...
|
||||||
|
|
||||||
|
# Return CallableProxyType if object is callable, ProxyType otherwise
|
||||||
|
@overload
|
||||||
|
def proxy(object: _C, callback: Callable[[_C], Any] | None = None, /) -> CallableProxyType[_C]: ...
|
||||||
|
@overload
|
||||||
|
def proxy(object: _T, callback: Callable[[_T], Any] | None = None, /) -> Any: ...
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
import sys
|
||||||
|
from collections.abc import Iterable, Iterator, MutableSet
|
||||||
|
from typing import Any, TypeVar, overload
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
from types import GenericAlias
|
||||||
|
|
||||||
|
__all__ = ["WeakSet"]
|
||||||
|
|
||||||
|
_S = TypeVar("_S")
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
|
||||||
|
class WeakSet(MutableSet[_T]):
|
||||||
|
@overload
|
||||||
|
def __init__(self, data: None = None) -> None: ...
|
||||||
|
@overload
|
||||||
|
def __init__(self, data: Iterable[_T]) -> None: ...
|
||||||
|
def add(self, item: _T) -> None: ...
|
||||||
|
def discard(self, item: _T) -> None: ...
|
||||||
|
def copy(self) -> Self: ...
|
||||||
|
def remove(self, item: _T) -> None: ...
|
||||||
|
def update(self, other: Iterable[_T]) -> None: ...
|
||||||
|
def __contains__(self, item: object) -> bool: ...
|
||||||
|
def __len__(self) -> int: ...
|
||||||
|
def __iter__(self) -> Iterator[_T]: ...
|
||||||
|
def __ior__(self, other: Iterable[_T]) -> Self: ... # type: ignore[override,misc]
|
||||||
|
def difference(self, other: Iterable[_T]) -> Self: ...
|
||||||
|
def __sub__(self, other: Iterable[Any]) -> Self: ...
|
||||||
|
def difference_update(self, other: Iterable[Any]) -> None: ...
|
||||||
|
def __isub__(self, other: Iterable[Any]) -> Self: ...
|
||||||
|
def intersection(self, other: Iterable[_T]) -> Self: ...
|
||||||
|
def __and__(self, other: Iterable[Any]) -> Self: ...
|
||||||
|
def intersection_update(self, other: Iterable[Any]) -> None: ...
|
||||||
|
def __iand__(self, other: Iterable[Any]) -> Self: ...
|
||||||
|
def issubset(self, other: Iterable[_T]) -> bool: ...
|
||||||
|
def __le__(self, other: Iterable[_T]) -> bool: ...
|
||||||
|
def __lt__(self, other: Iterable[_T]) -> bool: ...
|
||||||
|
def issuperset(self, other: Iterable[_T]) -> bool: ...
|
||||||
|
def __ge__(self, other: Iterable[_T]) -> bool: ...
|
||||||
|
def __gt__(self, other: Iterable[_T]) -> bool: ...
|
||||||
|
def __eq__(self, other: object) -> bool: ...
|
||||||
|
def symmetric_difference(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ...
|
||||||
|
def __xor__(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ...
|
||||||
|
def symmetric_difference_update(self, other: Iterable[_T]) -> None: ...
|
||||||
|
def __ixor__(self, other: Iterable[_T]) -> Self: ... # type: ignore[override,misc]
|
||||||
|
def union(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ...
|
||||||
|
def __or__(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ...
|
||||||
|
def isdisjoint(self, other: Iterable[_T]) -> bool: ...
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||||
|
|
@ -0,0 +1,255 @@
|
||||||
|
import sys
|
||||||
|
from _typeshed import ReadableBuffer
|
||||||
|
from collections.abc import Sequence
|
||||||
|
from typing import Any, Literal, NoReturn, final, overload
|
||||||
|
|
||||||
|
if sys.platform == "win32":
|
||||||
|
ABOVE_NORMAL_PRIORITY_CLASS: Literal[0x8000]
|
||||||
|
BELOW_NORMAL_PRIORITY_CLASS: Literal[0x4000]
|
||||||
|
|
||||||
|
CREATE_BREAKAWAY_FROM_JOB: Literal[0x1000000]
|
||||||
|
CREATE_DEFAULT_ERROR_MODE: Literal[0x4000000]
|
||||||
|
CREATE_NO_WINDOW: Literal[0x8000000]
|
||||||
|
CREATE_NEW_CONSOLE: Literal[0x10]
|
||||||
|
CREATE_NEW_PROCESS_GROUP: Literal[0x200]
|
||||||
|
|
||||||
|
DETACHED_PROCESS: Literal[8]
|
||||||
|
DUPLICATE_CLOSE_SOURCE: Literal[1]
|
||||||
|
DUPLICATE_SAME_ACCESS: Literal[2]
|
||||||
|
|
||||||
|
ERROR_ALREADY_EXISTS: Literal[183]
|
||||||
|
ERROR_BROKEN_PIPE: Literal[109]
|
||||||
|
ERROR_IO_PENDING: Literal[997]
|
||||||
|
ERROR_MORE_DATA: Literal[234]
|
||||||
|
ERROR_NETNAME_DELETED: Literal[64]
|
||||||
|
ERROR_NO_DATA: Literal[232]
|
||||||
|
ERROR_NO_SYSTEM_RESOURCES: Literal[1450]
|
||||||
|
ERROR_OPERATION_ABORTED: Literal[995]
|
||||||
|
ERROR_PIPE_BUSY: Literal[231]
|
||||||
|
ERROR_PIPE_CONNECTED: Literal[535]
|
||||||
|
ERROR_SEM_TIMEOUT: Literal[121]
|
||||||
|
|
||||||
|
FILE_FLAG_FIRST_PIPE_INSTANCE: Literal[0x80000]
|
||||||
|
FILE_FLAG_OVERLAPPED: Literal[0x40000000]
|
||||||
|
|
||||||
|
FILE_GENERIC_READ: Literal[1179785]
|
||||||
|
FILE_GENERIC_WRITE: Literal[1179926]
|
||||||
|
|
||||||
|
FILE_MAP_ALL_ACCESS: Literal[983071]
|
||||||
|
FILE_MAP_COPY: Literal[1]
|
||||||
|
FILE_MAP_EXECUTE: Literal[32]
|
||||||
|
FILE_MAP_READ: Literal[4]
|
||||||
|
FILE_MAP_WRITE: Literal[2]
|
||||||
|
|
||||||
|
FILE_TYPE_CHAR: Literal[2]
|
||||||
|
FILE_TYPE_DISK: Literal[1]
|
||||||
|
FILE_TYPE_PIPE: Literal[3]
|
||||||
|
FILE_TYPE_REMOTE: Literal[32768]
|
||||||
|
FILE_TYPE_UNKNOWN: Literal[0]
|
||||||
|
|
||||||
|
GENERIC_READ: Literal[0x80000000]
|
||||||
|
GENERIC_WRITE: Literal[0x40000000]
|
||||||
|
HIGH_PRIORITY_CLASS: Literal[0x80]
|
||||||
|
INFINITE: Literal[0xFFFFFFFF]
|
||||||
|
# Ignore the Flake8 error -- flake8-pyi assumes
|
||||||
|
# most numbers this long will be implementation details,
|
||||||
|
# but here we can see that it's a power of 2
|
||||||
|
INVALID_HANDLE_VALUE: Literal[0xFFFFFFFFFFFFFFFF] # noqa: Y054
|
||||||
|
IDLE_PRIORITY_CLASS: Literal[0x40]
|
||||||
|
NORMAL_PRIORITY_CLASS: Literal[0x20]
|
||||||
|
REALTIME_PRIORITY_CLASS: Literal[0x100]
|
||||||
|
NMPWAIT_WAIT_FOREVER: Literal[0xFFFFFFFF]
|
||||||
|
|
||||||
|
MEM_COMMIT: Literal[0x1000]
|
||||||
|
MEM_FREE: Literal[0x10000]
|
||||||
|
MEM_IMAGE: Literal[0x1000000]
|
||||||
|
MEM_MAPPED: Literal[0x40000]
|
||||||
|
MEM_PRIVATE: Literal[0x20000]
|
||||||
|
MEM_RESERVE: Literal[0x2000]
|
||||||
|
|
||||||
|
NULL: Literal[0]
|
||||||
|
OPEN_EXISTING: Literal[3]
|
||||||
|
|
||||||
|
PIPE_ACCESS_DUPLEX: Literal[3]
|
||||||
|
PIPE_ACCESS_INBOUND: Literal[1]
|
||||||
|
PIPE_READMODE_MESSAGE: Literal[2]
|
||||||
|
PIPE_TYPE_MESSAGE: Literal[4]
|
||||||
|
PIPE_UNLIMITED_INSTANCES: Literal[255]
|
||||||
|
PIPE_WAIT: Literal[0]
|
||||||
|
|
||||||
|
PAGE_EXECUTE: Literal[0x10]
|
||||||
|
PAGE_EXECUTE_READ: Literal[0x20]
|
||||||
|
PAGE_EXECUTE_READWRITE: Literal[0x40]
|
||||||
|
PAGE_EXECUTE_WRITECOPY: Literal[0x80]
|
||||||
|
PAGE_GUARD: Literal[0x100]
|
||||||
|
PAGE_NOACCESS: Literal[0x1]
|
||||||
|
PAGE_NOCACHE: Literal[0x200]
|
||||||
|
PAGE_READONLY: Literal[0x2]
|
||||||
|
PAGE_READWRITE: Literal[0x4]
|
||||||
|
PAGE_WRITECOMBINE: Literal[0x400]
|
||||||
|
PAGE_WRITECOPY: Literal[0x8]
|
||||||
|
|
||||||
|
PROCESS_ALL_ACCESS: Literal[0x1FFFFF]
|
||||||
|
PROCESS_DUP_HANDLE: Literal[0x40]
|
||||||
|
|
||||||
|
SEC_COMMIT: Literal[0x8000000]
|
||||||
|
SEC_IMAGE: Literal[0x1000000]
|
||||||
|
SEC_LARGE_PAGES: Literal[0x80000000]
|
||||||
|
SEC_NOCACHE: Literal[0x10000000]
|
||||||
|
SEC_RESERVE: Literal[0x4000000]
|
||||||
|
SEC_WRITECOMBINE: Literal[0x40000000]
|
||||||
|
|
||||||
|
STARTF_USESHOWWINDOW: Literal[0x1]
|
||||||
|
STARTF_USESTDHANDLES: Literal[0x100]
|
||||||
|
|
||||||
|
STD_ERROR_HANDLE: Literal[0xFFFFFFF4]
|
||||||
|
STD_OUTPUT_HANDLE: Literal[0xFFFFFFF5]
|
||||||
|
STD_INPUT_HANDLE: Literal[0xFFFFFFF6]
|
||||||
|
|
||||||
|
STILL_ACTIVE: Literal[259]
|
||||||
|
SW_HIDE: Literal[0]
|
||||||
|
SYNCHRONIZE: Literal[0x100000]
|
||||||
|
WAIT_ABANDONED_0: Literal[128]
|
||||||
|
WAIT_OBJECT_0: Literal[0]
|
||||||
|
WAIT_TIMEOUT: Literal[258]
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
LOCALE_NAME_INVARIANT: str
|
||||||
|
LOCALE_NAME_MAX_LENGTH: int
|
||||||
|
LOCALE_NAME_SYSTEM_DEFAULT: str
|
||||||
|
LOCALE_NAME_USER_DEFAULT: str | None
|
||||||
|
|
||||||
|
LCMAP_FULLWIDTH: int
|
||||||
|
LCMAP_HALFWIDTH: int
|
||||||
|
LCMAP_HIRAGANA: int
|
||||||
|
LCMAP_KATAKANA: int
|
||||||
|
LCMAP_LINGUISTIC_CASING: int
|
||||||
|
LCMAP_LOWERCASE: int
|
||||||
|
LCMAP_SIMPLIFIED_CHINESE: int
|
||||||
|
LCMAP_TITLECASE: int
|
||||||
|
LCMAP_TRADITIONAL_CHINESE: int
|
||||||
|
LCMAP_UPPERCASE: int
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
COPYFILE2_CALLBACK_CHUNK_STARTED: Literal[1]
|
||||||
|
COPYFILE2_CALLBACK_CHUNK_FINISHED: Literal[2]
|
||||||
|
COPYFILE2_CALLBACK_STREAM_STARTED: Literal[3]
|
||||||
|
COPYFILE2_CALLBACK_STREAM_FINISHED: Literal[4]
|
||||||
|
COPYFILE2_CALLBACK_POLL_CONTINUE: Literal[5]
|
||||||
|
COPYFILE2_CALLBACK_ERROR: Literal[6]
|
||||||
|
|
||||||
|
COPYFILE2_PROGRESS_CONTINUE: Literal[0]
|
||||||
|
COPYFILE2_PROGRESS_CANCEL: Literal[1]
|
||||||
|
COPYFILE2_PROGRESS_STOP: Literal[2]
|
||||||
|
COPYFILE2_PROGRESS_QUIET: Literal[3]
|
||||||
|
COPYFILE2_PROGRESS_PAUSE: Literal[4]
|
||||||
|
|
||||||
|
COPY_FILE_FAIL_IF_EXISTS: Literal[0x1]
|
||||||
|
COPY_FILE_RESTARTABLE: Literal[0x2]
|
||||||
|
COPY_FILE_OPEN_SOURCE_FOR_WRITE: Literal[0x4]
|
||||||
|
COPY_FILE_ALLOW_DECRYPTED_DESTINATION: Literal[0x8]
|
||||||
|
COPY_FILE_COPY_SYMLINK: Literal[0x800]
|
||||||
|
COPY_FILE_NO_BUFFERING: Literal[0x1000]
|
||||||
|
COPY_FILE_REQUEST_SECURITY_PRIVILEGES: Literal[0x2000]
|
||||||
|
COPY_FILE_RESUME_FROM_PAUSE: Literal[0x4000]
|
||||||
|
COPY_FILE_NO_OFFLOAD: Literal[0x40000]
|
||||||
|
COPY_FILE_REQUEST_COMPRESSED_TRAFFIC: Literal[0x10000000]
|
||||||
|
|
||||||
|
ERROR_ACCESS_DENIED: Literal[5]
|
||||||
|
ERROR_PRIVILEGE_NOT_HELD: Literal[1314]
|
||||||
|
|
||||||
|
def CloseHandle(handle: int, /) -> None: ...
|
||||||
|
@overload
|
||||||
|
def ConnectNamedPipe(handle: int, overlapped: Literal[True]) -> Overlapped: ...
|
||||||
|
@overload
|
||||||
|
def ConnectNamedPipe(handle: int, overlapped: Literal[False] = False) -> None: ...
|
||||||
|
@overload
|
||||||
|
def ConnectNamedPipe(handle: int, overlapped: bool) -> Overlapped | None: ...
|
||||||
|
def CreateFile(
|
||||||
|
file_name: str,
|
||||||
|
desired_access: int,
|
||||||
|
share_mode: int,
|
||||||
|
security_attributes: int,
|
||||||
|
creation_disposition: int,
|
||||||
|
flags_and_attributes: int,
|
||||||
|
template_file: int,
|
||||||
|
/,
|
||||||
|
) -> int: ...
|
||||||
|
def CreateJunction(src_path: str, dst_path: str, /) -> None: ...
|
||||||
|
def CreateNamedPipe(
|
||||||
|
name: str,
|
||||||
|
open_mode: int,
|
||||||
|
pipe_mode: int,
|
||||||
|
max_instances: int,
|
||||||
|
out_buffer_size: int,
|
||||||
|
in_buffer_size: int,
|
||||||
|
default_timeout: int,
|
||||||
|
security_attributes: int,
|
||||||
|
/,
|
||||||
|
) -> int: ...
|
||||||
|
def CreatePipe(pipe_attrs: Any, size: int, /) -> tuple[int, int]: ...
|
||||||
|
def CreateProcess(
|
||||||
|
application_name: str | None,
|
||||||
|
command_line: str | None,
|
||||||
|
proc_attrs: Any,
|
||||||
|
thread_attrs: Any,
|
||||||
|
inherit_handles: bool,
|
||||||
|
creation_flags: int,
|
||||||
|
env_mapping: dict[str, str],
|
||||||
|
current_directory: str | None,
|
||||||
|
startup_info: Any,
|
||||||
|
/,
|
||||||
|
) -> tuple[int, int, int, int]: ...
|
||||||
|
def DuplicateHandle(
|
||||||
|
source_process_handle: int,
|
||||||
|
source_handle: int,
|
||||||
|
target_process_handle: int,
|
||||||
|
desired_access: int,
|
||||||
|
inherit_handle: bool,
|
||||||
|
options: int = 0,
|
||||||
|
/,
|
||||||
|
) -> int: ...
|
||||||
|
def ExitProcess(ExitCode: int, /) -> NoReturn: ...
|
||||||
|
def GetACP() -> int: ...
|
||||||
|
def GetFileType(handle: int) -> int: ...
|
||||||
|
def GetCurrentProcess() -> int: ...
|
||||||
|
def GetExitCodeProcess(process: int, /) -> int: ...
|
||||||
|
def GetLastError() -> int: ...
|
||||||
|
def GetModuleFileName(module_handle: int, /) -> str: ...
|
||||||
|
def GetStdHandle(std_handle: int, /) -> int: ...
|
||||||
|
def GetVersion() -> int: ...
|
||||||
|
def OpenProcess(desired_access: int, inherit_handle: bool, process_id: int, /) -> int: ...
|
||||||
|
def PeekNamedPipe(handle: int, size: int = 0, /) -> tuple[int, int] | tuple[bytes, int, int]: ...
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
def LCMapStringEx(locale: str, flags: int, src: str) -> str: ...
|
||||||
|
def UnmapViewOfFile(address: int, /) -> None: ...
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def ReadFile(handle: int, size: int, overlapped: Literal[True]) -> tuple[Overlapped, int]: ...
|
||||||
|
@overload
|
||||||
|
def ReadFile(handle: int, size: int, overlapped: Literal[False] = False) -> tuple[bytes, int]: ...
|
||||||
|
@overload
|
||||||
|
def ReadFile(handle: int, size: int, overlapped: int | bool) -> tuple[Any, int]: ...
|
||||||
|
def SetNamedPipeHandleState(
|
||||||
|
named_pipe: int, mode: int | None, max_collection_count: int | None, collect_data_timeout: int | None, /
|
||||||
|
) -> None: ...
|
||||||
|
def TerminateProcess(handle: int, exit_code: int, /) -> None: ...
|
||||||
|
def WaitForMultipleObjects(handle_seq: Sequence[int], wait_flag: bool, milliseconds: int = 0xFFFFFFFF, /) -> int: ...
|
||||||
|
def WaitForSingleObject(handle: int, milliseconds: int, /) -> int: ...
|
||||||
|
def WaitNamedPipe(name: str, timeout: int, /) -> None: ...
|
||||||
|
@overload
|
||||||
|
def WriteFile(handle: int, buffer: ReadableBuffer, overlapped: Literal[True]) -> tuple[Overlapped, int]: ...
|
||||||
|
@overload
|
||||||
|
def WriteFile(handle: int, buffer: ReadableBuffer, overlapped: Literal[False] = False) -> tuple[int, int]: ...
|
||||||
|
@overload
|
||||||
|
def WriteFile(handle: int, buffer: ReadableBuffer, overlapped: int | bool) -> tuple[Any, int]: ...
|
||||||
|
@final
|
||||||
|
class Overlapped:
|
||||||
|
event: int
|
||||||
|
def GetOverlappedResult(self, wait: bool, /) -> tuple[int, int]: ...
|
||||||
|
def cancel(self) -> None: ...
|
||||||
|
def getbuffer(self) -> bytes | None: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
def CopyFile2(existing_file_name: str, new_file_name: str, flags: int, progress_routine: int | None = None) -> int: ...
|
||||||
|
def NeedCurrentDirectoryForExePath(exe_name: str, /) -> bool: ...
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
import _typeshed
|
||||||
|
import sys
|
||||||
|
from _typeshed import SupportsWrite
|
||||||
|
from collections.abc import Callable
|
||||||
|
from typing import Any, Literal, TypeVar
|
||||||
|
from typing_extensions import Concatenate, ParamSpec, deprecated
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
_R_co = TypeVar("_R_co", covariant=True)
|
||||||
|
_FuncT = TypeVar("_FuncT", bound=Callable[..., Any])
|
||||||
|
_P = ParamSpec("_P")
|
||||||
|
|
||||||
|
# These definitions have special processing in mypy
|
||||||
|
class ABCMeta(type):
|
||||||
|
__abstractmethods__: frozenset[str]
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
def __new__(
|
||||||
|
mcls: type[_typeshed.Self], name: str, bases: tuple[type, ...], namespace: dict[str, Any], /, **kwargs: Any
|
||||||
|
) -> _typeshed.Self: ...
|
||||||
|
else:
|
||||||
|
def __new__(
|
||||||
|
mcls: type[_typeshed.Self], name: str, bases: tuple[type, ...], namespace: dict[str, Any], **kwargs: Any
|
||||||
|
) -> _typeshed.Self: ...
|
||||||
|
|
||||||
|
def __instancecheck__(cls: ABCMeta, instance: Any) -> bool: ...
|
||||||
|
def __subclasscheck__(cls: ABCMeta, subclass: type) -> bool: ...
|
||||||
|
def _dump_registry(cls: ABCMeta, file: SupportsWrite[str] | None = None) -> None: ...
|
||||||
|
def register(cls: ABCMeta, subclass: type[_T]) -> type[_T]: ...
|
||||||
|
|
||||||
|
def abstractmethod(funcobj: _FuncT) -> _FuncT: ...
|
||||||
|
@deprecated("Deprecated, use 'classmethod' with 'abstractmethod' instead")
|
||||||
|
class abstractclassmethod(classmethod[_T, _P, _R_co]):
|
||||||
|
__isabstractmethod__: Literal[True]
|
||||||
|
def __init__(self, callable: Callable[Concatenate[type[_T], _P], _R_co]) -> None: ...
|
||||||
|
|
||||||
|
@deprecated("Deprecated, use 'staticmethod' with 'abstractmethod' instead")
|
||||||
|
class abstractstaticmethod(staticmethod[_P, _R_co]):
|
||||||
|
__isabstractmethod__: Literal[True]
|
||||||
|
def __init__(self, callable: Callable[_P, _R_co]) -> None: ...
|
||||||
|
|
||||||
|
@deprecated("Deprecated, use 'property' with 'abstractmethod' instead")
|
||||||
|
class abstractproperty(property):
|
||||||
|
__isabstractmethod__: Literal[True]
|
||||||
|
|
||||||
|
class ABC(metaclass=ABCMeta):
|
||||||
|
__slots__ = ()
|
||||||
|
|
||||||
|
def get_cache_token() -> object: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
def update_abstractmethods(cls: type[_T]) -> type[_T]: ...
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
import sys
|
||||||
|
from types import TracebackType
|
||||||
|
from typing import IO, Any, Literal, NamedTuple, overload
|
||||||
|
from typing_extensions import Self, TypeAlias
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
__all__ = ["Error", "open"]
|
||||||
|
else:
|
||||||
|
__all__ = ["Error", "open", "openfp"]
|
||||||
|
|
||||||
|
class Error(Exception): ...
|
||||||
|
|
||||||
|
class _aifc_params(NamedTuple):
|
||||||
|
nchannels: int
|
||||||
|
sampwidth: int
|
||||||
|
framerate: int
|
||||||
|
nframes: int
|
||||||
|
comptype: bytes
|
||||||
|
compname: bytes
|
||||||
|
|
||||||
|
_File: TypeAlias = str | IO[bytes]
|
||||||
|
_Marker: TypeAlias = tuple[int, int, bytes]
|
||||||
|
|
||||||
|
class Aifc_read:
|
||||||
|
def __init__(self, f: _File) -> None: ...
|
||||||
|
def __enter__(self) -> Self: ...
|
||||||
|
def __exit__(
|
||||||
|
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||||
|
) -> None: ...
|
||||||
|
def initfp(self, file: IO[bytes]) -> None: ...
|
||||||
|
def getfp(self) -> IO[bytes]: ...
|
||||||
|
def rewind(self) -> None: ...
|
||||||
|
def close(self) -> None: ...
|
||||||
|
def tell(self) -> int: ...
|
||||||
|
def getnchannels(self) -> int: ...
|
||||||
|
def getnframes(self) -> int: ...
|
||||||
|
def getsampwidth(self) -> int: ...
|
||||||
|
def getframerate(self) -> int: ...
|
||||||
|
def getcomptype(self) -> bytes: ...
|
||||||
|
def getcompname(self) -> bytes: ...
|
||||||
|
def getparams(self) -> _aifc_params: ...
|
||||||
|
def getmarkers(self) -> list[_Marker] | None: ...
|
||||||
|
def getmark(self, id: int) -> _Marker: ...
|
||||||
|
def setpos(self, pos: int) -> None: ...
|
||||||
|
def readframes(self, nframes: int) -> bytes: ...
|
||||||
|
|
||||||
|
class Aifc_write:
|
||||||
|
def __init__(self, f: _File) -> None: ...
|
||||||
|
def __del__(self) -> None: ...
|
||||||
|
def __enter__(self) -> Self: ...
|
||||||
|
def __exit__(
|
||||||
|
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||||
|
) -> None: ...
|
||||||
|
def initfp(self, file: IO[bytes]) -> None: ...
|
||||||
|
def aiff(self) -> None: ...
|
||||||
|
def aifc(self) -> None: ...
|
||||||
|
def setnchannels(self, nchannels: int) -> None: ...
|
||||||
|
def getnchannels(self) -> int: ...
|
||||||
|
def setsampwidth(self, sampwidth: int) -> None: ...
|
||||||
|
def getsampwidth(self) -> int: ...
|
||||||
|
def setframerate(self, framerate: int) -> None: ...
|
||||||
|
def getframerate(self) -> int: ...
|
||||||
|
def setnframes(self, nframes: int) -> None: ...
|
||||||
|
def getnframes(self) -> int: ...
|
||||||
|
def setcomptype(self, comptype: bytes, compname: bytes) -> None: ...
|
||||||
|
def getcomptype(self) -> bytes: ...
|
||||||
|
def getcompname(self) -> bytes: ...
|
||||||
|
def setparams(self, params: tuple[int, int, int, int, bytes, bytes]) -> None: ...
|
||||||
|
def getparams(self) -> _aifc_params: ...
|
||||||
|
def setmark(self, id: int, pos: int, name: bytes) -> None: ...
|
||||||
|
def getmark(self, id: int) -> _Marker: ...
|
||||||
|
def getmarkers(self) -> list[_Marker] | None: ...
|
||||||
|
def tell(self) -> int: ...
|
||||||
|
def writeframesraw(self, data: Any) -> None: ... # Actual type for data is Buffer Protocol
|
||||||
|
def writeframes(self, data: Any) -> None: ...
|
||||||
|
def close(self) -> None: ...
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def open(f: _File, mode: Literal["r", "rb"]) -> Aifc_read: ...
|
||||||
|
@overload
|
||||||
|
def open(f: _File, mode: Literal["w", "wb"]) -> Aifc_write: ...
|
||||||
|
@overload
|
||||||
|
def open(f: _File, mode: str | None = None) -> Any: ...
|
||||||
|
|
||||||
|
if sys.version_info < (3, 9):
|
||||||
|
@overload
|
||||||
|
def openfp(f: _File, mode: Literal["r", "rb"]) -> Aifc_read: ...
|
||||||
|
@overload
|
||||||
|
def openfp(f: _File, mode: Literal["w", "wb"]) -> Aifc_write: ...
|
||||||
|
@overload
|
||||||
|
def openfp(f: _File, mode: str | None = None) -> Any: ...
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
from _typeshed import ReadableBuffer
|
||||||
|
|
||||||
|
def geohash(latitude: float, longitude: float, datedow: ReadableBuffer) -> None: ...
|
||||||
|
|
@ -0,0 +1,595 @@
|
||||||
|
import sys
|
||||||
|
from _typeshed import sentinel
|
||||||
|
from collections.abc import Callable, Generator, Iterable, Sequence
|
||||||
|
from re import Pattern
|
||||||
|
from typing import IO, Any, Generic, Literal, NewType, NoReturn, Protocol, TypeVar, overload
|
||||||
|
from typing_extensions import Self, TypeAlias, deprecated
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"ArgumentParser",
|
||||||
|
"ArgumentError",
|
||||||
|
"ArgumentTypeError",
|
||||||
|
"FileType",
|
||||||
|
"HelpFormatter",
|
||||||
|
"ArgumentDefaultsHelpFormatter",
|
||||||
|
"RawDescriptionHelpFormatter",
|
||||||
|
"RawTextHelpFormatter",
|
||||||
|
"MetavarTypeHelpFormatter",
|
||||||
|
"Namespace",
|
||||||
|
"Action",
|
||||||
|
"ONE_OR_MORE",
|
||||||
|
"OPTIONAL",
|
||||||
|
"PARSER",
|
||||||
|
"REMAINDER",
|
||||||
|
"SUPPRESS",
|
||||||
|
"ZERO_OR_MORE",
|
||||||
|
]
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
__all__ += ["BooleanOptionalAction"]
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
_ActionT = TypeVar("_ActionT", bound=Action)
|
||||||
|
_ArgumentParserT = TypeVar("_ArgumentParserT", bound=ArgumentParser)
|
||||||
|
_N = TypeVar("_N")
|
||||||
|
# more precisely, Literal["store", "store_const", "store_true",
|
||||||
|
# "store_false", "append", "append_const", "count", "help", "version",
|
||||||
|
# "extend"], but using this would make it hard to annotate callers
|
||||||
|
# that don't use a literal argument
|
||||||
|
_ActionStr: TypeAlias = str
|
||||||
|
# more precisely, Literal["?", "*", "+", "...", "A...",
|
||||||
|
# "==SUPPRESS=="], but using this would make it hard to annotate
|
||||||
|
# callers that don't use a literal argument
|
||||||
|
_NArgsStr: TypeAlias = str
|
||||||
|
|
||||||
|
ONE_OR_MORE: Literal["+"]
|
||||||
|
OPTIONAL: Literal["?"]
|
||||||
|
PARSER: Literal["A..."]
|
||||||
|
REMAINDER: Literal["..."]
|
||||||
|
_SUPPRESS_T = NewType("_SUPPRESS_T", str)
|
||||||
|
SUPPRESS: _SUPPRESS_T | str # not using Literal because argparse sometimes compares SUPPRESS with is
|
||||||
|
# the | str is there so that foo = argparse.SUPPRESS; foo = "test" checks out in mypy
|
||||||
|
ZERO_OR_MORE: Literal["*"]
|
||||||
|
_UNRECOGNIZED_ARGS_ATTR: str # undocumented
|
||||||
|
|
||||||
|
class ArgumentError(Exception):
|
||||||
|
argument_name: str | None
|
||||||
|
message: str
|
||||||
|
def __init__(self, argument: Action | None, message: str) -> None: ...
|
||||||
|
|
||||||
|
# undocumented
|
||||||
|
class _AttributeHolder:
|
||||||
|
def _get_kwargs(self) -> list[tuple[str, Any]]: ...
|
||||||
|
def _get_args(self) -> list[Any]: ...
|
||||||
|
|
||||||
|
# undocumented
|
||||||
|
class _ActionsContainer:
|
||||||
|
description: str | None
|
||||||
|
prefix_chars: str
|
||||||
|
argument_default: Any
|
||||||
|
conflict_handler: str
|
||||||
|
|
||||||
|
_registries: dict[str, dict[Any, Any]]
|
||||||
|
_actions: list[Action]
|
||||||
|
_option_string_actions: dict[str, Action]
|
||||||
|
_action_groups: list[_ArgumentGroup]
|
||||||
|
_mutually_exclusive_groups: list[_MutuallyExclusiveGroup]
|
||||||
|
_defaults: dict[str, Any]
|
||||||
|
_negative_number_matcher: Pattern[str]
|
||||||
|
_has_negative_number_optionals: list[bool]
|
||||||
|
def __init__(self, description: str | None, prefix_chars: str, argument_default: Any, conflict_handler: str) -> None: ...
|
||||||
|
def register(self, registry_name: str, value: Any, object: Any) -> None: ...
|
||||||
|
def _registry_get(self, registry_name: str, value: Any, default: Any = None) -> Any: ...
|
||||||
|
def set_defaults(self, **kwargs: Any) -> None: ...
|
||||||
|
def get_default(self, dest: str) -> Any: ...
|
||||||
|
def add_argument(
|
||||||
|
self,
|
||||||
|
*name_or_flags: str,
|
||||||
|
action: _ActionStr | type[Action] = ...,
|
||||||
|
nargs: int | _NArgsStr | _SUPPRESS_T | None = None,
|
||||||
|
const: Any = ...,
|
||||||
|
default: Any = ...,
|
||||||
|
type: Callable[[str], _T] | FileType = ...,
|
||||||
|
choices: Iterable[_T] | None = ...,
|
||||||
|
required: bool = ...,
|
||||||
|
help: str | None = ...,
|
||||||
|
metavar: str | tuple[str, ...] | None = ...,
|
||||||
|
dest: str | None = ...,
|
||||||
|
version: str = ...,
|
||||||
|
**kwargs: Any,
|
||||||
|
) -> Action: ...
|
||||||
|
def add_argument_group(
|
||||||
|
self,
|
||||||
|
title: str | None = None,
|
||||||
|
description: str | None = None,
|
||||||
|
*,
|
||||||
|
prefix_chars: str = ...,
|
||||||
|
argument_default: Any = ...,
|
||||||
|
conflict_handler: str = ...,
|
||||||
|
) -> _ArgumentGroup: ...
|
||||||
|
def add_mutually_exclusive_group(self, *, required: bool = False) -> _MutuallyExclusiveGroup: ...
|
||||||
|
def _add_action(self, action: _ActionT) -> _ActionT: ...
|
||||||
|
def _remove_action(self, action: Action) -> None: ...
|
||||||
|
def _add_container_actions(self, container: _ActionsContainer) -> None: ...
|
||||||
|
def _get_positional_kwargs(self, dest: str, **kwargs: Any) -> dict[str, Any]: ...
|
||||||
|
def _get_optional_kwargs(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ...
|
||||||
|
def _pop_action_class(self, kwargs: Any, default: type[Action] | None = None) -> type[Action]: ...
|
||||||
|
def _get_handler(self) -> Callable[[Action, Iterable[tuple[str, Action]]], Any]: ...
|
||||||
|
def _check_conflict(self, action: Action) -> None: ...
|
||||||
|
def _handle_conflict_error(self, action: Action, conflicting_actions: Iterable[tuple[str, Action]]) -> NoReturn: ...
|
||||||
|
def _handle_conflict_resolve(self, action: Action, conflicting_actions: Iterable[tuple[str, Action]]) -> None: ...
|
||||||
|
|
||||||
|
class _FormatterClass(Protocol):
|
||||||
|
def __call__(self, *, prog: str) -> HelpFormatter: ...
|
||||||
|
|
||||||
|
class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
||||||
|
prog: str
|
||||||
|
usage: str | None
|
||||||
|
epilog: str | None
|
||||||
|
formatter_class: _FormatterClass
|
||||||
|
fromfile_prefix_chars: str | None
|
||||||
|
add_help: bool
|
||||||
|
allow_abbrev: bool
|
||||||
|
|
||||||
|
# undocumented
|
||||||
|
_positionals: _ArgumentGroup
|
||||||
|
_optionals: _ArgumentGroup
|
||||||
|
_subparsers: _ArgumentGroup | None
|
||||||
|
|
||||||
|
# Note: the constructor arguments are also used in _SubParsersAction.add_parser.
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
prog: str | None = None,
|
||||||
|
usage: str | None = None,
|
||||||
|
description: str | None = None,
|
||||||
|
epilog: str | None = None,
|
||||||
|
parents: Sequence[ArgumentParser] = [],
|
||||||
|
formatter_class: _FormatterClass = ...,
|
||||||
|
prefix_chars: str = "-",
|
||||||
|
fromfile_prefix_chars: str | None = None,
|
||||||
|
argument_default: Any = None,
|
||||||
|
conflict_handler: str = "error",
|
||||||
|
add_help: bool = True,
|
||||||
|
allow_abbrev: bool = True,
|
||||||
|
exit_on_error: bool = True,
|
||||||
|
) -> None: ...
|
||||||
|
else:
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
prog: str | None = None,
|
||||||
|
usage: str | None = None,
|
||||||
|
description: str | None = None,
|
||||||
|
epilog: str | None = None,
|
||||||
|
parents: Sequence[ArgumentParser] = [],
|
||||||
|
formatter_class: _FormatterClass = ...,
|
||||||
|
prefix_chars: str = "-",
|
||||||
|
fromfile_prefix_chars: str | None = None,
|
||||||
|
argument_default: Any = None,
|
||||||
|
conflict_handler: str = "error",
|
||||||
|
add_help: bool = True,
|
||||||
|
allow_abbrev: bool = True,
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def parse_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ...
|
||||||
|
@overload
|
||||||
|
def parse_args(self, args: Sequence[str] | None, namespace: _N) -> _N: ...
|
||||||
|
@overload
|
||||||
|
def parse_args(self, *, namespace: _N) -> _N: ...
|
||||||
|
@overload
|
||||||
|
def add_subparsers(
|
||||||
|
self: _ArgumentParserT,
|
||||||
|
*,
|
||||||
|
title: str = ...,
|
||||||
|
description: str | None = ...,
|
||||||
|
prog: str = ...,
|
||||||
|
action: type[Action] = ...,
|
||||||
|
option_string: str = ...,
|
||||||
|
dest: str | None = ...,
|
||||||
|
required: bool = ...,
|
||||||
|
help: str | None = ...,
|
||||||
|
metavar: str | None = ...,
|
||||||
|
) -> _SubParsersAction[_ArgumentParserT]: ...
|
||||||
|
@overload
|
||||||
|
def add_subparsers(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
title: str = ...,
|
||||||
|
description: str | None = ...,
|
||||||
|
prog: str = ...,
|
||||||
|
parser_class: type[_ArgumentParserT],
|
||||||
|
action: type[Action] = ...,
|
||||||
|
option_string: str = ...,
|
||||||
|
dest: str | None = ...,
|
||||||
|
required: bool = ...,
|
||||||
|
help: str | None = ...,
|
||||||
|
metavar: str | None = ...,
|
||||||
|
) -> _SubParsersAction[_ArgumentParserT]: ...
|
||||||
|
def print_usage(self, file: IO[str] | None = None) -> None: ...
|
||||||
|
def print_help(self, file: IO[str] | None = None) -> None: ...
|
||||||
|
def format_usage(self) -> str: ...
|
||||||
|
def format_help(self) -> str: ...
|
||||||
|
@overload
|
||||||
|
def parse_known_args(self, args: Sequence[str] | None = None, namespace: None = None) -> tuple[Namespace, list[str]]: ...
|
||||||
|
@overload
|
||||||
|
def parse_known_args(self, args: Sequence[str] | None, namespace: _N) -> tuple[_N, list[str]]: ...
|
||||||
|
@overload
|
||||||
|
def parse_known_args(self, *, namespace: _N) -> tuple[_N, list[str]]: ...
|
||||||
|
def convert_arg_line_to_args(self, arg_line: str) -> list[str]: ...
|
||||||
|
def exit(self, status: int = 0, message: str | None = None) -> NoReturn: ...
|
||||||
|
def error(self, message: str) -> NoReturn: ...
|
||||||
|
@overload
|
||||||
|
def parse_intermixed_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ...
|
||||||
|
@overload
|
||||||
|
def parse_intermixed_args(self, args: Sequence[str] | None, namespace: _N) -> _N: ...
|
||||||
|
@overload
|
||||||
|
def parse_intermixed_args(self, *, namespace: _N) -> _N: ...
|
||||||
|
@overload
|
||||||
|
def parse_known_intermixed_args(
|
||||||
|
self, args: Sequence[str] | None = None, namespace: None = None
|
||||||
|
) -> tuple[Namespace, list[str]]: ...
|
||||||
|
@overload
|
||||||
|
def parse_known_intermixed_args(self, args: Sequence[str] | None, namespace: _N) -> tuple[_N, list[str]]: ...
|
||||||
|
@overload
|
||||||
|
def parse_known_intermixed_args(self, *, namespace: _N) -> tuple[_N, list[str]]: ...
|
||||||
|
# undocumented
|
||||||
|
def _get_optional_actions(self) -> list[Action]: ...
|
||||||
|
def _get_positional_actions(self) -> list[Action]: ...
|
||||||
|
def _parse_known_args(self, arg_strings: list[str], namespace: Namespace) -> tuple[Namespace, list[str]]: ...
|
||||||
|
def _read_args_from_files(self, arg_strings: list[str]) -> list[str]: ...
|
||||||
|
def _match_argument(self, action: Action, arg_strings_pattern: str) -> int: ...
|
||||||
|
def _match_arguments_partial(self, actions: Sequence[Action], arg_strings_pattern: str) -> list[int]: ...
|
||||||
|
def _parse_optional(self, arg_string: str) -> tuple[Action | None, str, str | None] | None: ...
|
||||||
|
def _get_option_tuples(self, option_string: str) -> list[tuple[Action, str, str | None]]: ...
|
||||||
|
def _get_nargs_pattern(self, action: Action) -> str: ...
|
||||||
|
def _get_values(self, action: Action, arg_strings: list[str]) -> Any: ...
|
||||||
|
def _get_value(self, action: Action, arg_string: str) -> Any: ...
|
||||||
|
def _check_value(self, action: Action, value: Any) -> None: ...
|
||||||
|
def _get_formatter(self) -> HelpFormatter: ...
|
||||||
|
def _print_message(self, message: str, file: IO[str] | None = None) -> None: ...
|
||||||
|
|
||||||
|
class HelpFormatter:
|
||||||
|
# undocumented
|
||||||
|
_prog: str
|
||||||
|
_indent_increment: int
|
||||||
|
_max_help_position: int
|
||||||
|
_width: int
|
||||||
|
_current_indent: int
|
||||||
|
_level: int
|
||||||
|
_action_max_length: int
|
||||||
|
_root_section: _Section
|
||||||
|
_current_section: _Section
|
||||||
|
_whitespace_matcher: Pattern[str]
|
||||||
|
_long_break_matcher: Pattern[str]
|
||||||
|
|
||||||
|
class _Section:
|
||||||
|
formatter: HelpFormatter
|
||||||
|
heading: str | None
|
||||||
|
parent: Self | None
|
||||||
|
items: list[tuple[Callable[..., str], Iterable[Any]]]
|
||||||
|
def __init__(self, formatter: HelpFormatter, parent: Self | None, heading: str | None = None) -> None: ...
|
||||||
|
def format_help(self) -> str: ...
|
||||||
|
|
||||||
|
def __init__(self, prog: str, indent_increment: int = 2, max_help_position: int = 24, width: int | None = None) -> None: ...
|
||||||
|
def _indent(self) -> None: ...
|
||||||
|
def _dedent(self) -> None: ...
|
||||||
|
def _add_item(self, func: Callable[..., str], args: Iterable[Any]) -> None: ...
|
||||||
|
def start_section(self, heading: str | None) -> None: ...
|
||||||
|
def end_section(self) -> None: ...
|
||||||
|
def add_text(self, text: str | None) -> None: ...
|
||||||
|
def add_usage(
|
||||||
|
self, usage: str | None, actions: Iterable[Action], groups: Iterable[_MutuallyExclusiveGroup], prefix: str | None = None
|
||||||
|
) -> None: ...
|
||||||
|
def add_argument(self, action: Action) -> None: ...
|
||||||
|
def add_arguments(self, actions: Iterable[Action]) -> None: ...
|
||||||
|
def format_help(self) -> str: ...
|
||||||
|
def _join_parts(self, part_strings: Iterable[str]) -> str: ...
|
||||||
|
def _format_usage(
|
||||||
|
self, usage: str | None, actions: Iterable[Action], groups: Iterable[_MutuallyExclusiveGroup], prefix: str | None
|
||||||
|
) -> str: ...
|
||||||
|
def _format_actions_usage(self, actions: Iterable[Action], groups: Iterable[_MutuallyExclusiveGroup]) -> str: ...
|
||||||
|
def _format_text(self, text: str) -> str: ...
|
||||||
|
def _format_action(self, action: Action) -> str: ...
|
||||||
|
def _format_action_invocation(self, action: Action) -> str: ...
|
||||||
|
def _metavar_formatter(self, action: Action, default_metavar: str) -> Callable[[int], tuple[str, ...]]: ...
|
||||||
|
def _format_args(self, action: Action, default_metavar: str) -> str: ...
|
||||||
|
def _expand_help(self, action: Action) -> str: ...
|
||||||
|
def _iter_indented_subactions(self, action: Action) -> Generator[Action, None, None]: ...
|
||||||
|
def _split_lines(self, text: str, width: int) -> list[str]: ...
|
||||||
|
def _fill_text(self, text: str, width: int, indent: str) -> str: ...
|
||||||
|
def _get_help_string(self, action: Action) -> str | None: ...
|
||||||
|
def _get_default_metavar_for_optional(self, action: Action) -> str: ...
|
||||||
|
def _get_default_metavar_for_positional(self, action: Action) -> str: ...
|
||||||
|
|
||||||
|
class RawDescriptionHelpFormatter(HelpFormatter): ...
|
||||||
|
class RawTextHelpFormatter(RawDescriptionHelpFormatter): ...
|
||||||
|
class ArgumentDefaultsHelpFormatter(HelpFormatter): ...
|
||||||
|
class MetavarTypeHelpFormatter(HelpFormatter): ...
|
||||||
|
|
||||||
|
class Action(_AttributeHolder):
|
||||||
|
option_strings: Sequence[str]
|
||||||
|
dest: str
|
||||||
|
nargs: int | str | None
|
||||||
|
const: Any
|
||||||
|
default: Any
|
||||||
|
type: Callable[[str], Any] | FileType | None
|
||||||
|
choices: Iterable[Any] | None
|
||||||
|
required: bool
|
||||||
|
help: str | None
|
||||||
|
metavar: str | tuple[str, ...] | None
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
option_strings: Sequence[str],
|
||||||
|
dest: str,
|
||||||
|
nargs: int | str | None = None,
|
||||||
|
const: _T | None = None,
|
||||||
|
default: _T | str | None = None,
|
||||||
|
type: Callable[[str], _T] | FileType | None = None,
|
||||||
|
choices: Iterable[_T] | None = None,
|
||||||
|
required: bool = False,
|
||||||
|
help: str | None = None,
|
||||||
|
metavar: str | tuple[str, ...] | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
def __call__(
|
||||||
|
self, parser: ArgumentParser, namespace: Namespace, values: str | Sequence[Any] | None, option_string: str | None = None
|
||||||
|
) -> None: ...
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
def format_usage(self) -> str: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
class BooleanOptionalAction(Action):
|
||||||
|
@overload
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
option_strings: Sequence[str],
|
||||||
|
dest: str,
|
||||||
|
default: bool | None = None,
|
||||||
|
*,
|
||||||
|
required: bool = False,
|
||||||
|
help: str | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
@overload
|
||||||
|
@deprecated("The `type`, `choices`, and `metavar` parameters are ignored and will be removed in Python 3.14.")
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
option_strings: Sequence[str],
|
||||||
|
dest: str,
|
||||||
|
default: _T | bool | None = None,
|
||||||
|
type: Callable[[str], _T] | FileType | None = sentinel,
|
||||||
|
choices: Iterable[_T] | None = sentinel,
|
||||||
|
required: bool = False,
|
||||||
|
help: str | None = None,
|
||||||
|
metavar: str | tuple[str, ...] | None = sentinel,
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
elif sys.version_info >= (3, 9):
|
||||||
|
class BooleanOptionalAction(Action):
|
||||||
|
@overload
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
option_strings: Sequence[str],
|
||||||
|
dest: str,
|
||||||
|
default: bool | None = None,
|
||||||
|
*,
|
||||||
|
required: bool = False,
|
||||||
|
help: str | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
@overload
|
||||||
|
@deprecated("The `type`, `choices`, and `metavar` parameters are ignored and will be removed in Python 3.14.")
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
option_strings: Sequence[str],
|
||||||
|
dest: str,
|
||||||
|
default: _T | bool | None = None,
|
||||||
|
type: Callable[[str], _T] | FileType | None = None,
|
||||||
|
choices: Iterable[_T] | None = None,
|
||||||
|
required: bool = False,
|
||||||
|
help: str | None = None,
|
||||||
|
metavar: str | tuple[str, ...] | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
class Namespace(_AttributeHolder):
|
||||||
|
def __init__(self, **kwargs: Any) -> None: ...
|
||||||
|
def __getattr__(self, name: str) -> Any: ...
|
||||||
|
def __setattr__(self, name: str, value: Any, /) -> None: ...
|
||||||
|
def __contains__(self, key: str) -> bool: ...
|
||||||
|
def __eq__(self, other: object) -> bool: ...
|
||||||
|
|
||||||
|
class FileType:
|
||||||
|
# undocumented
|
||||||
|
_mode: str
|
||||||
|
_bufsize: int
|
||||||
|
_encoding: str | None
|
||||||
|
_errors: str | None
|
||||||
|
def __init__(self, mode: str = "r", bufsize: int = -1, encoding: str | None = None, errors: str | None = None) -> None: ...
|
||||||
|
def __call__(self, string: str) -> IO[Any]: ...
|
||||||
|
|
||||||
|
# undocumented
|
||||||
|
class _ArgumentGroup(_ActionsContainer):
|
||||||
|
title: str | None
|
||||||
|
_group_actions: list[Action]
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
container: _ActionsContainer,
|
||||||
|
title: str | None = None,
|
||||||
|
description: str | None = None,
|
||||||
|
*,
|
||||||
|
prefix_chars: str = ...,
|
||||||
|
argument_default: Any = ...,
|
||||||
|
conflict_handler: str = ...,
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
# undocumented
|
||||||
|
class _MutuallyExclusiveGroup(_ArgumentGroup):
|
||||||
|
required: bool
|
||||||
|
_container: _ActionsContainer
|
||||||
|
def __init__(self, container: _ActionsContainer, required: bool = False) -> None: ...
|
||||||
|
|
||||||
|
# undocumented
|
||||||
|
class _StoreAction(Action): ...
|
||||||
|
|
||||||
|
# undocumented
|
||||||
|
class _StoreConstAction(Action):
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
option_strings: Sequence[str],
|
||||||
|
dest: str,
|
||||||
|
const: Any | None = None,
|
||||||
|
default: Any = None,
|
||||||
|
required: bool = False,
|
||||||
|
help: str | None = None,
|
||||||
|
metavar: str | tuple[str, ...] | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
else:
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
option_strings: Sequence[str],
|
||||||
|
dest: str,
|
||||||
|
const: Any,
|
||||||
|
default: Any = None,
|
||||||
|
required: bool = False,
|
||||||
|
help: str | None = None,
|
||||||
|
metavar: str | tuple[str, ...] | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
# undocumented
|
||||||
|
class _StoreTrueAction(_StoreConstAction):
|
||||||
|
def __init__(
|
||||||
|
self, option_strings: Sequence[str], dest: str, default: bool = False, required: bool = False, help: str | None = None
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
# undocumented
|
||||||
|
class _StoreFalseAction(_StoreConstAction):
|
||||||
|
def __init__(
|
||||||
|
self, option_strings: Sequence[str], dest: str, default: bool = True, required: bool = False, help: str | None = None
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
# undocumented
|
||||||
|
class _AppendAction(Action): ...
|
||||||
|
|
||||||
|
# undocumented
|
||||||
|
class _ExtendAction(_AppendAction): ...
|
||||||
|
|
||||||
|
# undocumented
|
||||||
|
class _AppendConstAction(Action):
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
option_strings: Sequence[str],
|
||||||
|
dest: str,
|
||||||
|
const: Any | None = None,
|
||||||
|
default: Any = None,
|
||||||
|
required: bool = False,
|
||||||
|
help: str | None = None,
|
||||||
|
metavar: str | tuple[str, ...] | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
else:
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
option_strings: Sequence[str],
|
||||||
|
dest: str,
|
||||||
|
const: Any,
|
||||||
|
default: Any = None,
|
||||||
|
required: bool = False,
|
||||||
|
help: str | None = None,
|
||||||
|
metavar: str | tuple[str, ...] | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
# undocumented
|
||||||
|
class _CountAction(Action):
|
||||||
|
def __init__(
|
||||||
|
self, option_strings: Sequence[str], dest: str, default: Any = None, required: bool = False, help: str | None = None
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
# undocumented
|
||||||
|
class _HelpAction(Action):
|
||||||
|
def __init__(
|
||||||
|
self, option_strings: Sequence[str], dest: str = "==SUPPRESS==", default: str = "==SUPPRESS==", help: str | None = None
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
# undocumented
|
||||||
|
class _VersionAction(Action):
|
||||||
|
version: str | None
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
option_strings: Sequence[str],
|
||||||
|
version: str | None = None,
|
||||||
|
dest: str = "==SUPPRESS==",
|
||||||
|
default: str = "==SUPPRESS==",
|
||||||
|
help: str = "show program's version number and exit",
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
# undocumented
|
||||||
|
class _SubParsersAction(Action, Generic[_ArgumentParserT]):
|
||||||
|
_ChoicesPseudoAction: type[Any] # nested class
|
||||||
|
_prog_prefix: str
|
||||||
|
_parser_class: type[_ArgumentParserT]
|
||||||
|
_name_parser_map: dict[str, _ArgumentParserT]
|
||||||
|
choices: dict[str, _ArgumentParserT]
|
||||||
|
_choices_actions: list[Action]
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
option_strings: Sequence[str],
|
||||||
|
prog: str,
|
||||||
|
parser_class: type[_ArgumentParserT],
|
||||||
|
dest: str = "==SUPPRESS==",
|
||||||
|
required: bool = False,
|
||||||
|
help: str | None = None,
|
||||||
|
metavar: str | tuple[str, ...] | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
# Note: `add_parser` accepts all kwargs of `ArgumentParser.__init__`. It also
|
||||||
|
# accepts its own `help` and `aliases` kwargs.
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
def add_parser(
|
||||||
|
self,
|
||||||
|
name: str,
|
||||||
|
*,
|
||||||
|
help: str | None = ...,
|
||||||
|
aliases: Sequence[str] = ...,
|
||||||
|
# Kwargs from ArgumentParser constructor
|
||||||
|
prog: str | None = ...,
|
||||||
|
usage: str | None = ...,
|
||||||
|
description: str | None = ...,
|
||||||
|
epilog: str | None = ...,
|
||||||
|
parents: Sequence[_ArgumentParserT] = ...,
|
||||||
|
formatter_class: _FormatterClass = ...,
|
||||||
|
prefix_chars: str = ...,
|
||||||
|
fromfile_prefix_chars: str | None = ...,
|
||||||
|
argument_default: Any = ...,
|
||||||
|
conflict_handler: str = ...,
|
||||||
|
add_help: bool = ...,
|
||||||
|
allow_abbrev: bool = ...,
|
||||||
|
exit_on_error: bool = ...,
|
||||||
|
) -> _ArgumentParserT: ...
|
||||||
|
else:
|
||||||
|
def add_parser(
|
||||||
|
self,
|
||||||
|
name: str,
|
||||||
|
*,
|
||||||
|
help: str | None = ...,
|
||||||
|
aliases: Sequence[str] = ...,
|
||||||
|
# Kwargs from ArgumentParser constructor
|
||||||
|
prog: str | None = ...,
|
||||||
|
usage: str | None = ...,
|
||||||
|
description: str | None = ...,
|
||||||
|
epilog: str | None = ...,
|
||||||
|
parents: Sequence[_ArgumentParserT] = ...,
|
||||||
|
formatter_class: _FormatterClass = ...,
|
||||||
|
prefix_chars: str = ...,
|
||||||
|
fromfile_prefix_chars: str | None = ...,
|
||||||
|
argument_default: Any = ...,
|
||||||
|
conflict_handler: str = ...,
|
||||||
|
add_help: bool = ...,
|
||||||
|
allow_abbrev: bool = ...,
|
||||||
|
) -> _ArgumentParserT: ...
|
||||||
|
|
||||||
|
def _get_subactions(self) -> list[Action]: ...
|
||||||
|
|
||||||
|
# undocumented
|
||||||
|
class ArgumentTypeError(Exception): ...
|
||||||
|
|
||||||
|
# undocumented
|
||||||
|
def _get_action_name(argument: Action | None) -> str | None: ...
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
import sys
|
||||||
|
from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite
|
||||||
|
from collections.abc import Iterable
|
||||||
|
|
||||||
|
# pytype crashes if array inherits from collections.abc.MutableSequence instead of typing.MutableSequence
|
||||||
|
from typing import Any, Literal, MutableSequence, SupportsIndex, TypeVar, overload # noqa: Y022
|
||||||
|
from typing_extensions import Self, TypeAlias
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
from types import GenericAlias
|
||||||
|
|
||||||
|
_IntTypeCode: TypeAlias = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"]
|
||||||
|
_FloatTypeCode: TypeAlias = Literal["f", "d"]
|
||||||
|
_UnicodeTypeCode: TypeAlias = Literal["u"]
|
||||||
|
_TypeCode: TypeAlias = _IntTypeCode | _FloatTypeCode | _UnicodeTypeCode
|
||||||
|
|
||||||
|
_T = TypeVar("_T", int, float, str)
|
||||||
|
|
||||||
|
typecodes: str
|
||||||
|
|
||||||
|
class array(MutableSequence[_T]):
|
||||||
|
@property
|
||||||
|
def typecode(self) -> _TypeCode: ...
|
||||||
|
@property
|
||||||
|
def itemsize(self) -> int: ...
|
||||||
|
@overload
|
||||||
|
def __init__(self: array[int], typecode: _IntTypeCode, initializer: bytes | bytearray | Iterable[int] = ..., /) -> None: ...
|
||||||
|
@overload
|
||||||
|
def __init__(
|
||||||
|
self: array[float], typecode: _FloatTypeCode, initializer: bytes | bytearray | Iterable[float] = ..., /
|
||||||
|
) -> None: ...
|
||||||
|
@overload
|
||||||
|
def __init__(
|
||||||
|
self: array[str], typecode: _UnicodeTypeCode, initializer: bytes | bytearray | Iterable[str] = ..., /
|
||||||
|
) -> None: ...
|
||||||
|
@overload
|
||||||
|
def __init__(self, typecode: str, initializer: Iterable[_T], /) -> None: ...
|
||||||
|
@overload
|
||||||
|
def __init__(self, typecode: str, initializer: bytes | bytearray = ..., /) -> None: ...
|
||||||
|
def append(self, v: _T, /) -> None: ...
|
||||||
|
def buffer_info(self) -> tuple[int, int]: ...
|
||||||
|
def byteswap(self) -> None: ...
|
||||||
|
def count(self, v: _T, /) -> int: ...
|
||||||
|
def extend(self, bb: Iterable[_T], /) -> None: ...
|
||||||
|
def frombytes(self, buffer: ReadableBuffer, /) -> None: ...
|
||||||
|
def fromfile(self, f: SupportsRead[bytes], n: int, /) -> None: ...
|
||||||
|
def fromlist(self, list: list[_T], /) -> None: ...
|
||||||
|
def fromunicode(self, ustr: str, /) -> None: ...
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
def index(self, v: _T, start: int = 0, stop: int = sys.maxsize, /) -> int: ...
|
||||||
|
else:
|
||||||
|
def index(self, v: _T, /) -> int: ... # type: ignore[override]
|
||||||
|
|
||||||
|
def insert(self, i: int, v: _T, /) -> None: ...
|
||||||
|
def pop(self, i: int = -1, /) -> _T: ...
|
||||||
|
def remove(self, v: _T, /) -> None: ...
|
||||||
|
def tobytes(self) -> bytes: ...
|
||||||
|
def tofile(self, f: SupportsWrite[bytes], /) -> None: ...
|
||||||
|
def tolist(self) -> list[_T]: ...
|
||||||
|
def tounicode(self) -> str: ...
|
||||||
|
if sys.version_info < (3, 9):
|
||||||
|
def fromstring(self, buffer: str | ReadableBuffer, /) -> None: ...
|
||||||
|
def tostring(self) -> bytes: ...
|
||||||
|
|
||||||
|
def __len__(self) -> int: ...
|
||||||
|
@overload
|
||||||
|
def __getitem__(self, key: SupportsIndex, /) -> _T: ...
|
||||||
|
@overload
|
||||||
|
def __getitem__(self, key: slice, /) -> array[_T]: ...
|
||||||
|
@overload # type: ignore[override]
|
||||||
|
def __setitem__(self, key: SupportsIndex, value: _T, /) -> None: ...
|
||||||
|
@overload
|
||||||
|
def __setitem__(self, key: slice, value: array[_T], /) -> None: ...
|
||||||
|
def __delitem__(self, key: SupportsIndex | slice, /) -> None: ...
|
||||||
|
def __add__(self, value: array[_T], /) -> array[_T]: ...
|
||||||
|
def __eq__(self, value: object, /) -> bool: ...
|
||||||
|
def __ge__(self, value: array[_T], /) -> bool: ...
|
||||||
|
def __gt__(self, value: array[_T], /) -> bool: ...
|
||||||
|
def __iadd__(self, value: array[_T], /) -> Self: ... # type: ignore[override]
|
||||||
|
def __imul__(self, value: int, /) -> Self: ...
|
||||||
|
def __le__(self, value: array[_T], /) -> bool: ...
|
||||||
|
def __lt__(self, value: array[_T], /) -> bool: ...
|
||||||
|
def __mul__(self, value: int, /) -> array[_T]: ...
|
||||||
|
def __rmul__(self, value: int, /) -> array[_T]: ...
|
||||||
|
def __copy__(self) -> array[_T]: ...
|
||||||
|
def __deepcopy__(self, unused: Any, /) -> array[_T]: ...
|
||||||
|
def __buffer__(self, flags: int, /) -> memoryview: ...
|
||||||
|
def __release_buffer__(self, buffer: memoryview, /) -> None: ...
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||||
|
|
||||||
|
ArrayType = array
|
||||||
|
|
@ -0,0 +1,367 @@
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from _ast import *
|
||||||
|
from _typeshed import ReadableBuffer, Unused
|
||||||
|
from collections.abc import Iterator
|
||||||
|
from typing import Any, Literal, TypeVar as _TypeVar, overload
|
||||||
|
from typing_extensions import deprecated
|
||||||
|
|
||||||
|
class _ABC(type):
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
def __init__(cls, *args: Unused) -> None: ...
|
||||||
|
|
||||||
|
@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14")
|
||||||
|
class Num(Constant, metaclass=_ABC):
|
||||||
|
value: int | float | complex
|
||||||
|
|
||||||
|
@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14")
|
||||||
|
class Str(Constant, metaclass=_ABC):
|
||||||
|
value: str
|
||||||
|
# Aliases for value, for backwards compatibility
|
||||||
|
s: str
|
||||||
|
|
||||||
|
@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14")
|
||||||
|
class Bytes(Constant, metaclass=_ABC):
|
||||||
|
value: bytes
|
||||||
|
# Aliases for value, for backwards compatibility
|
||||||
|
s: bytes
|
||||||
|
|
||||||
|
@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14")
|
||||||
|
class NameConstant(Constant, metaclass=_ABC): ...
|
||||||
|
|
||||||
|
@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14")
|
||||||
|
class Ellipsis(Constant, metaclass=_ABC): ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
class slice(AST): ...
|
||||||
|
class ExtSlice(slice): ...
|
||||||
|
class Index(slice): ...
|
||||||
|
class Suite(mod): ...
|
||||||
|
class AugLoad(expr_context): ...
|
||||||
|
class AugStore(expr_context): ...
|
||||||
|
class Param(expr_context): ...
|
||||||
|
|
||||||
|
class NodeVisitor:
|
||||||
|
def visit(self, node: AST) -> Any: ...
|
||||||
|
def generic_visit(self, node: AST) -> Any: ...
|
||||||
|
def visit_Module(self, node: Module) -> Any: ...
|
||||||
|
def visit_Interactive(self, node: Interactive) -> Any: ...
|
||||||
|
def visit_Expression(self, node: Expression) -> Any: ...
|
||||||
|
def visit_FunctionDef(self, node: FunctionDef) -> Any: ...
|
||||||
|
def visit_AsyncFunctionDef(self, node: AsyncFunctionDef) -> Any: ...
|
||||||
|
def visit_ClassDef(self, node: ClassDef) -> Any: ...
|
||||||
|
def visit_Return(self, node: Return) -> Any: ...
|
||||||
|
def visit_Delete(self, node: Delete) -> Any: ...
|
||||||
|
def visit_Assign(self, node: Assign) -> Any: ...
|
||||||
|
def visit_AugAssign(self, node: AugAssign) -> Any: ...
|
||||||
|
def visit_AnnAssign(self, node: AnnAssign) -> Any: ...
|
||||||
|
def visit_For(self, node: For) -> Any: ...
|
||||||
|
def visit_AsyncFor(self, node: AsyncFor) -> Any: ...
|
||||||
|
def visit_While(self, node: While) -> Any: ...
|
||||||
|
def visit_If(self, node: If) -> Any: ...
|
||||||
|
def visit_With(self, node: With) -> Any: ...
|
||||||
|
def visit_AsyncWith(self, node: AsyncWith) -> Any: ...
|
||||||
|
def visit_Raise(self, node: Raise) -> Any: ...
|
||||||
|
def visit_Try(self, node: Try) -> Any: ...
|
||||||
|
def visit_Assert(self, node: Assert) -> Any: ...
|
||||||
|
def visit_Import(self, node: Import) -> Any: ...
|
||||||
|
def visit_ImportFrom(self, node: ImportFrom) -> Any: ...
|
||||||
|
def visit_Global(self, node: Global) -> Any: ...
|
||||||
|
def visit_Nonlocal(self, node: Nonlocal) -> Any: ...
|
||||||
|
def visit_Expr(self, node: Expr) -> Any: ...
|
||||||
|
def visit_Pass(self, node: Pass) -> Any: ...
|
||||||
|
def visit_Break(self, node: Break) -> Any: ...
|
||||||
|
def visit_Continue(self, node: Continue) -> Any: ...
|
||||||
|
def visit_Slice(self, node: Slice) -> Any: ...
|
||||||
|
def visit_BoolOp(self, node: BoolOp) -> Any: ...
|
||||||
|
def visit_BinOp(self, node: BinOp) -> Any: ...
|
||||||
|
def visit_UnaryOp(self, node: UnaryOp) -> Any: ...
|
||||||
|
def visit_Lambda(self, node: Lambda) -> Any: ...
|
||||||
|
def visit_IfExp(self, node: IfExp) -> Any: ...
|
||||||
|
def visit_Dict(self, node: Dict) -> Any: ...
|
||||||
|
def visit_Set(self, node: Set) -> Any: ...
|
||||||
|
def visit_ListComp(self, node: ListComp) -> Any: ...
|
||||||
|
def visit_SetComp(self, node: SetComp) -> Any: ...
|
||||||
|
def visit_DictComp(self, node: DictComp) -> Any: ...
|
||||||
|
def visit_GeneratorExp(self, node: GeneratorExp) -> Any: ...
|
||||||
|
def visit_Await(self, node: Await) -> Any: ...
|
||||||
|
def visit_Yield(self, node: Yield) -> Any: ...
|
||||||
|
def visit_YieldFrom(self, node: YieldFrom) -> Any: ...
|
||||||
|
def visit_Compare(self, node: Compare) -> Any: ...
|
||||||
|
def visit_Call(self, node: Call) -> Any: ...
|
||||||
|
def visit_FormattedValue(self, node: FormattedValue) -> Any: ...
|
||||||
|
def visit_JoinedStr(self, node: JoinedStr) -> Any: ...
|
||||||
|
def visit_Constant(self, node: Constant) -> Any: ...
|
||||||
|
def visit_NamedExpr(self, node: NamedExpr) -> Any: ...
|
||||||
|
def visit_TypeIgnore(self, node: TypeIgnore) -> Any: ...
|
||||||
|
def visit_Attribute(self, node: Attribute) -> Any: ...
|
||||||
|
def visit_Subscript(self, node: Subscript) -> Any: ...
|
||||||
|
def visit_Starred(self, node: Starred) -> Any: ...
|
||||||
|
def visit_Name(self, node: Name) -> Any: ...
|
||||||
|
def visit_List(self, node: List) -> Any: ...
|
||||||
|
def visit_Tuple(self, node: Tuple) -> Any: ...
|
||||||
|
def visit_Del(self, node: Del) -> Any: ...
|
||||||
|
def visit_Load(self, node: Load) -> Any: ...
|
||||||
|
def visit_Store(self, node: Store) -> Any: ...
|
||||||
|
def visit_And(self, node: And) -> Any: ...
|
||||||
|
def visit_Or(self, node: Or) -> Any: ...
|
||||||
|
def visit_Add(self, node: Add) -> Any: ...
|
||||||
|
def visit_BitAnd(self, node: BitAnd) -> Any: ...
|
||||||
|
def visit_BitOr(self, node: BitOr) -> Any: ...
|
||||||
|
def visit_BitXor(self, node: BitXor) -> Any: ...
|
||||||
|
def visit_Div(self, node: Div) -> Any: ...
|
||||||
|
def visit_FloorDiv(self, node: FloorDiv) -> Any: ...
|
||||||
|
def visit_LShift(self, node: LShift) -> Any: ...
|
||||||
|
def visit_Mod(self, node: Mod) -> Any: ...
|
||||||
|
def visit_Mult(self, node: Mult) -> Any: ...
|
||||||
|
def visit_MatMult(self, node: MatMult) -> Any: ...
|
||||||
|
def visit_Pow(self, node: Pow) -> Any: ...
|
||||||
|
def visit_RShift(self, node: RShift) -> Any: ...
|
||||||
|
def visit_Sub(self, node: Sub) -> Any: ...
|
||||||
|
def visit_Invert(self, node: Invert) -> Any: ...
|
||||||
|
def visit_Not(self, node: Not) -> Any: ...
|
||||||
|
def visit_UAdd(self, node: UAdd) -> Any: ...
|
||||||
|
def visit_USub(self, node: USub) -> Any: ...
|
||||||
|
def visit_Eq(self, node: Eq) -> Any: ...
|
||||||
|
def visit_Gt(self, node: Gt) -> Any: ...
|
||||||
|
def visit_GtE(self, node: GtE) -> Any: ...
|
||||||
|
def visit_In(self, node: In) -> Any: ...
|
||||||
|
def visit_Is(self, node: Is) -> Any: ...
|
||||||
|
def visit_IsNot(self, node: IsNot) -> Any: ...
|
||||||
|
def visit_Lt(self, node: Lt) -> Any: ...
|
||||||
|
def visit_LtE(self, node: LtE) -> Any: ...
|
||||||
|
def visit_NotEq(self, node: NotEq) -> Any: ...
|
||||||
|
def visit_NotIn(self, node: NotIn) -> Any: ...
|
||||||
|
def visit_comprehension(self, node: comprehension) -> Any: ...
|
||||||
|
def visit_ExceptHandler(self, node: ExceptHandler) -> Any: ...
|
||||||
|
def visit_arguments(self, node: arguments) -> Any: ...
|
||||||
|
def visit_arg(self, node: arg) -> Any: ...
|
||||||
|
def visit_keyword(self, node: keyword) -> Any: ...
|
||||||
|
def visit_alias(self, node: alias) -> Any: ...
|
||||||
|
def visit_withitem(self, node: withitem) -> Any: ...
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
def visit_Match(self, node: Match) -> Any: ...
|
||||||
|
def visit_match_case(self, node: match_case) -> Any: ...
|
||||||
|
def visit_MatchValue(self, node: MatchValue) -> Any: ...
|
||||||
|
def visit_MatchSequence(self, node: MatchSequence) -> Any: ...
|
||||||
|
def visit_MatchSingleton(self, node: MatchSingleton) -> Any: ...
|
||||||
|
def visit_MatchStar(self, node: MatchStar) -> Any: ...
|
||||||
|
def visit_MatchMapping(self, node: MatchMapping) -> Any: ...
|
||||||
|
def visit_MatchClass(self, node: MatchClass) -> Any: ...
|
||||||
|
def visit_MatchAs(self, node: MatchAs) -> Any: ...
|
||||||
|
def visit_MatchOr(self, node: MatchOr) -> Any: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
def visit_TryStar(self, node: TryStar) -> Any: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
def visit_TypeVar(self, node: TypeVar) -> Any: ...
|
||||||
|
def visit_ParamSpec(self, node: ParamSpec) -> Any: ...
|
||||||
|
def visit_TypeVarTuple(self, node: TypeVarTuple) -> Any: ...
|
||||||
|
def visit_TypeAlias(self, node: TypeAlias) -> Any: ...
|
||||||
|
|
||||||
|
# visit methods for deprecated nodes
|
||||||
|
def visit_ExtSlice(self, node: ExtSlice) -> Any: ...
|
||||||
|
def visit_Index(self, node: Index) -> Any: ...
|
||||||
|
def visit_Suite(self, node: Suite) -> Any: ...
|
||||||
|
def visit_AugLoad(self, node: AugLoad) -> Any: ...
|
||||||
|
def visit_AugStore(self, node: AugStore) -> Any: ...
|
||||||
|
def visit_Param(self, node: Param) -> Any: ...
|
||||||
|
def visit_Num(self, node: Num) -> Any: ...
|
||||||
|
def visit_Str(self, node: Str) -> Any: ...
|
||||||
|
def visit_Bytes(self, node: Bytes) -> Any: ...
|
||||||
|
def visit_NameConstant(self, node: NameConstant) -> Any: ...
|
||||||
|
def visit_Ellipsis(self, node: Ellipsis) -> Any: ...
|
||||||
|
|
||||||
|
class NodeTransformer(NodeVisitor):
|
||||||
|
def generic_visit(self, node: AST) -> AST: ...
|
||||||
|
# TODO: Override the visit_* methods with better return types.
|
||||||
|
# The usual return type is AST | None, but Iterable[AST]
|
||||||
|
# is also allowed in some cases -- this needs to be mapped.
|
||||||
|
|
||||||
|
_T = _TypeVar("_T", bound=AST)
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 13):
|
||||||
|
@overload
|
||||||
|
def parse(
|
||||||
|
source: str | ReadableBuffer,
|
||||||
|
filename: str | ReadableBuffer | os.PathLike[Any] = "<unknown>",
|
||||||
|
mode: Literal["exec"] = "exec",
|
||||||
|
*,
|
||||||
|
type_comments: bool = False,
|
||||||
|
feature_version: None | int | tuple[int, int] = None,
|
||||||
|
optimize: Literal[-1, 0, 1, 2] = -1,
|
||||||
|
) -> Module: ...
|
||||||
|
@overload
|
||||||
|
def parse(
|
||||||
|
source: str | ReadableBuffer,
|
||||||
|
filename: str | ReadableBuffer | os.PathLike[Any],
|
||||||
|
mode: Literal["eval"],
|
||||||
|
*,
|
||||||
|
type_comments: bool = False,
|
||||||
|
feature_version: None | int | tuple[int, int] = None,
|
||||||
|
optimize: Literal[-1, 0, 1, 2] = -1,
|
||||||
|
) -> Expression: ...
|
||||||
|
@overload
|
||||||
|
def parse(
|
||||||
|
source: str | ReadableBuffer,
|
||||||
|
filename: str | ReadableBuffer | os.PathLike[Any],
|
||||||
|
mode: Literal["func_type"],
|
||||||
|
*,
|
||||||
|
type_comments: bool = False,
|
||||||
|
feature_version: None | int | tuple[int, int] = None,
|
||||||
|
optimize: Literal[-1, 0, 1, 2] = -1,
|
||||||
|
) -> FunctionType: ...
|
||||||
|
@overload
|
||||||
|
def parse(
|
||||||
|
source: str | ReadableBuffer,
|
||||||
|
filename: str | ReadableBuffer | os.PathLike[Any],
|
||||||
|
mode: Literal["single"],
|
||||||
|
*,
|
||||||
|
type_comments: bool = False,
|
||||||
|
feature_version: None | int | tuple[int, int] = None,
|
||||||
|
optimize: Literal[-1, 0, 1, 2] = -1,
|
||||||
|
) -> Interactive: ...
|
||||||
|
@overload
|
||||||
|
def parse(
|
||||||
|
source: str | ReadableBuffer,
|
||||||
|
*,
|
||||||
|
mode: Literal["eval"],
|
||||||
|
type_comments: bool = False,
|
||||||
|
feature_version: None | int | tuple[int, int] = None,
|
||||||
|
optimize: Literal[-1, 0, 1, 2] = -1,
|
||||||
|
) -> Expression: ...
|
||||||
|
@overload
|
||||||
|
def parse(
|
||||||
|
source: str | ReadableBuffer,
|
||||||
|
*,
|
||||||
|
mode: Literal["func_type"],
|
||||||
|
type_comments: bool = False,
|
||||||
|
feature_version: None | int | tuple[int, int] = None,
|
||||||
|
optimize: Literal[-1, 0, 1, 2] = -1,
|
||||||
|
) -> FunctionType: ...
|
||||||
|
@overload
|
||||||
|
def parse(
|
||||||
|
source: str | ReadableBuffer,
|
||||||
|
*,
|
||||||
|
mode: Literal["single"],
|
||||||
|
type_comments: bool = False,
|
||||||
|
feature_version: None | int | tuple[int, int] = None,
|
||||||
|
optimize: Literal[-1, 0, 1, 2] = -1,
|
||||||
|
) -> Interactive: ...
|
||||||
|
@overload
|
||||||
|
def parse(
|
||||||
|
source: str | ReadableBuffer,
|
||||||
|
filename: str | ReadableBuffer | os.PathLike[Any] = "<unknown>",
|
||||||
|
mode: str = "exec",
|
||||||
|
*,
|
||||||
|
type_comments: bool = False,
|
||||||
|
feature_version: None | int | tuple[int, int] = None,
|
||||||
|
optimize: Literal[-1, 0, 1, 2] = -1,
|
||||||
|
) -> AST: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
@overload
|
||||||
|
def parse(
|
||||||
|
source: str | ReadableBuffer,
|
||||||
|
filename: str | ReadableBuffer | os.PathLike[Any] = "<unknown>",
|
||||||
|
mode: Literal["exec"] = "exec",
|
||||||
|
*,
|
||||||
|
type_comments: bool = False,
|
||||||
|
feature_version: None | int | tuple[int, int] = None,
|
||||||
|
) -> Module: ...
|
||||||
|
@overload
|
||||||
|
def parse(
|
||||||
|
source: str | ReadableBuffer,
|
||||||
|
filename: str | ReadableBuffer | os.PathLike[Any],
|
||||||
|
mode: Literal["eval"],
|
||||||
|
*,
|
||||||
|
type_comments: bool = False,
|
||||||
|
feature_version: None | int | tuple[int, int] = None,
|
||||||
|
) -> Expression: ...
|
||||||
|
@overload
|
||||||
|
def parse(
|
||||||
|
source: str | ReadableBuffer,
|
||||||
|
filename: str | ReadableBuffer | os.PathLike[Any],
|
||||||
|
mode: Literal["func_type"],
|
||||||
|
*,
|
||||||
|
type_comments: bool = False,
|
||||||
|
feature_version: None | int | tuple[int, int] = None,
|
||||||
|
) -> FunctionType: ...
|
||||||
|
@overload
|
||||||
|
def parse(
|
||||||
|
source: str | ReadableBuffer,
|
||||||
|
filename: str | ReadableBuffer | os.PathLike[Any],
|
||||||
|
mode: Literal["single"],
|
||||||
|
*,
|
||||||
|
type_comments: bool = False,
|
||||||
|
feature_version: None | int | tuple[int, int] = None,
|
||||||
|
) -> Interactive: ...
|
||||||
|
@overload
|
||||||
|
def parse(
|
||||||
|
source: str | ReadableBuffer,
|
||||||
|
*,
|
||||||
|
mode: Literal["eval"],
|
||||||
|
type_comments: bool = False,
|
||||||
|
feature_version: None | int | tuple[int, int] = None,
|
||||||
|
) -> Expression: ...
|
||||||
|
@overload
|
||||||
|
def parse(
|
||||||
|
source: str | ReadableBuffer,
|
||||||
|
*,
|
||||||
|
mode: Literal["func_type"],
|
||||||
|
type_comments: bool = False,
|
||||||
|
feature_version: None | int | tuple[int, int] = None,
|
||||||
|
) -> FunctionType: ...
|
||||||
|
@overload
|
||||||
|
def parse(
|
||||||
|
source: str | ReadableBuffer,
|
||||||
|
*,
|
||||||
|
mode: Literal["single"],
|
||||||
|
type_comments: bool = False,
|
||||||
|
feature_version: None | int | tuple[int, int] = None,
|
||||||
|
) -> Interactive: ...
|
||||||
|
@overload
|
||||||
|
def parse(
|
||||||
|
source: str | ReadableBuffer,
|
||||||
|
filename: str | ReadableBuffer | os.PathLike[Any] = "<unknown>",
|
||||||
|
mode: str = "exec",
|
||||||
|
*,
|
||||||
|
type_comments: bool = False,
|
||||||
|
feature_version: None | int | tuple[int, int] = None,
|
||||||
|
) -> AST: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
def unparse(ast_obj: AST) -> str: ...
|
||||||
|
|
||||||
|
def copy_location(new_node: _T, old_node: AST) -> _T: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 13):
|
||||||
|
def dump(
|
||||||
|
node: AST,
|
||||||
|
annotate_fields: bool = True,
|
||||||
|
include_attributes: bool = False,
|
||||||
|
*,
|
||||||
|
indent: int | str | None = None,
|
||||||
|
show_empty: bool = False,
|
||||||
|
) -> str: ...
|
||||||
|
|
||||||
|
elif sys.version_info >= (3, 9):
|
||||||
|
def dump(
|
||||||
|
node: AST, annotate_fields: bool = True, include_attributes: bool = False, *, indent: int | str | None = None
|
||||||
|
) -> str: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
def dump(node: AST, annotate_fields: bool = True, include_attributes: bool = False) -> str: ...
|
||||||
|
|
||||||
|
def fix_missing_locations(node: _T) -> _T: ...
|
||||||
|
def get_docstring(node: AsyncFunctionDef | FunctionDef | ClassDef | Module, clean: bool = True) -> str | None: ...
|
||||||
|
def increment_lineno(node: _T, n: int = 1) -> _T: ...
|
||||||
|
def iter_child_nodes(node: AST) -> Iterator[AST]: ...
|
||||||
|
def iter_fields(node: AST) -> Iterator[tuple[str, Any]]: ...
|
||||||
|
def literal_eval(node_or_string: str | AST) -> Any: ...
|
||||||
|
def get_source_segment(source: str, node: AST, *, padded: bool = False) -> str | None: ...
|
||||||
|
def walk(node: AST) -> Iterator[AST]: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
def main() -> None: ...
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
import asyncore
|
||||||
|
from abc import abstractmethod
|
||||||
|
|
||||||
|
class simple_producer:
|
||||||
|
def __init__(self, data: bytes, buffer_size: int = 512) -> None: ...
|
||||||
|
def more(self) -> bytes: ...
|
||||||
|
|
||||||
|
class async_chat(asyncore.dispatcher):
|
||||||
|
ac_in_buffer_size: int
|
||||||
|
ac_out_buffer_size: int
|
||||||
|
@abstractmethod
|
||||||
|
def collect_incoming_data(self, data: bytes) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
def found_terminator(self) -> None: ...
|
||||||
|
def set_terminator(self, term: bytes | int | None) -> None: ...
|
||||||
|
def get_terminator(self) -> bytes | int | None: ...
|
||||||
|
def push(self, data: bytes) -> None: ...
|
||||||
|
def push_with_producer(self, producer: simple_producer) -> None: ...
|
||||||
|
def close_when_done(self) -> None: ...
|
||||||
|
def initiate_send(self) -> None: ...
|
||||||
|
def discard_buffers(self) -> None: ...
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
import sys
|
||||||
|
from collections.abc import Awaitable, Coroutine, Generator
|
||||||
|
from typing import Any, TypeVar
|
||||||
|
from typing_extensions import TypeAlias
|
||||||
|
|
||||||
|
# As at runtime, this depends on all submodules defining __all__ accurately.
|
||||||
|
from .base_events import *
|
||||||
|
from .coroutines import *
|
||||||
|
from .events import *
|
||||||
|
from .exceptions import *
|
||||||
|
from .futures import *
|
||||||
|
from .locks import *
|
||||||
|
from .protocols import *
|
||||||
|
from .queues import *
|
||||||
|
from .runners import *
|
||||||
|
from .streams import *
|
||||||
|
from .subprocess import *
|
||||||
|
from .tasks import *
|
||||||
|
from .transports import *
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
from .threads import *
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
from .taskgroups import *
|
||||||
|
from .timeouts import *
|
||||||
|
|
||||||
|
if sys.platform == "win32":
|
||||||
|
from .windows_events import *
|
||||||
|
else:
|
||||||
|
from .unix_events import *
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
|
||||||
|
# Aliases imported by multiple submodules in typeshed
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
_AwaitableLike: TypeAlias = Awaitable[_T] # noqa: Y047
|
||||||
|
_CoroutineLike: TypeAlias = Coroutine[Any, Any, _T] # noqa: Y047
|
||||||
|
else:
|
||||||
|
_AwaitableLike: TypeAlias = Generator[Any, None, _T] | Awaitable[_T]
|
||||||
|
_CoroutineLike: TypeAlias = Generator[Any, None, _T] | Coroutine[Any, Any, _T]
|
||||||
|
|
@ -0,0 +1,440 @@
|
||||||
|
import ssl
|
||||||
|
import sys
|
||||||
|
from _typeshed import FileDescriptorLike, ReadableBuffer, WriteableBuffer
|
||||||
|
from asyncio import _AwaitableLike, _CoroutineLike
|
||||||
|
from asyncio.events import AbstractEventLoop, AbstractServer, Handle, TimerHandle, _TaskFactory
|
||||||
|
from asyncio.futures import Future
|
||||||
|
from asyncio.protocols import BaseProtocol
|
||||||
|
from asyncio.tasks import Task
|
||||||
|
from asyncio.transports import BaseTransport, DatagramTransport, ReadTransport, SubprocessTransport, Transport, WriteTransport
|
||||||
|
from collections.abc import Callable, Iterable, Sequence
|
||||||
|
from contextvars import Context
|
||||||
|
from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket
|
||||||
|
from typing import IO, Any, Literal, TypeVar, overload
|
||||||
|
from typing_extensions import TypeAlias, TypeVarTuple, Unpack
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
__all__ = ("BaseEventLoop", "Server")
|
||||||
|
else:
|
||||||
|
__all__ = ("BaseEventLoop",)
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
_Ts = TypeVarTuple("_Ts")
|
||||||
|
_ProtocolT = TypeVar("_ProtocolT", bound=BaseProtocol)
|
||||||
|
_Context: TypeAlias = dict[str, Any]
|
||||||
|
_ExceptionHandler: TypeAlias = Callable[[AbstractEventLoop, _Context], object]
|
||||||
|
_ProtocolFactory: TypeAlias = Callable[[], BaseProtocol]
|
||||||
|
_SSLContext: TypeAlias = bool | None | ssl.SSLContext
|
||||||
|
|
||||||
|
class Server(AbstractServer):
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
loop: AbstractEventLoop,
|
||||||
|
sockets: Iterable[socket],
|
||||||
|
protocol_factory: _ProtocolFactory,
|
||||||
|
ssl_context: _SSLContext,
|
||||||
|
backlog: int,
|
||||||
|
ssl_handshake_timeout: float | None,
|
||||||
|
ssl_shutdown_timeout: float | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
else:
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
loop: AbstractEventLoop,
|
||||||
|
sockets: Iterable[socket],
|
||||||
|
protocol_factory: _ProtocolFactory,
|
||||||
|
ssl_context: _SSLContext,
|
||||||
|
backlog: int,
|
||||||
|
ssl_handshake_timeout: float | None,
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
def get_loop(self) -> AbstractEventLoop: ...
|
||||||
|
def is_serving(self) -> bool: ...
|
||||||
|
async def start_serving(self) -> None: ...
|
||||||
|
async def serve_forever(self) -> None: ...
|
||||||
|
@property
|
||||||
|
def sockets(self) -> tuple[socket, ...]: ...
|
||||||
|
def close(self) -> None: ...
|
||||||
|
async def wait_closed(self) -> None: ...
|
||||||
|
|
||||||
|
class BaseEventLoop(AbstractEventLoop):
|
||||||
|
def run_forever(self) -> None: ...
|
||||||
|
def run_until_complete(self, future: _AwaitableLike[_T]) -> _T: ...
|
||||||
|
def stop(self) -> None: ...
|
||||||
|
def is_running(self) -> bool: ...
|
||||||
|
def is_closed(self) -> bool: ...
|
||||||
|
def close(self) -> None: ...
|
||||||
|
async def shutdown_asyncgens(self) -> None: ...
|
||||||
|
# Methods scheduling callbacks. All these return Handles.
|
||||||
|
def call_soon(
|
||||||
|
self, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
|
||||||
|
) -> Handle: ...
|
||||||
|
def call_later(
|
||||||
|
self, delay: float, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
|
||||||
|
) -> TimerHandle: ...
|
||||||
|
def call_at(
|
||||||
|
self, when: float, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
|
||||||
|
) -> TimerHandle: ...
|
||||||
|
def time(self) -> float: ...
|
||||||
|
# Future methods
|
||||||
|
def create_future(self) -> Future[Any]: ...
|
||||||
|
# Tasks methods
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
def create_task(self, coro: _CoroutineLike[_T], *, name: object = None, context: Context | None = None) -> Task[_T]: ...
|
||||||
|
else:
|
||||||
|
def create_task(self, coro: _CoroutineLike[_T], *, name: object = None) -> Task[_T]: ...
|
||||||
|
|
||||||
|
def set_task_factory(self, factory: _TaskFactory | None) -> None: ...
|
||||||
|
def get_task_factory(self) -> _TaskFactory | None: ...
|
||||||
|
# Methods for interacting with threads
|
||||||
|
def call_soon_threadsafe(
|
||||||
|
self, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
|
||||||
|
) -> Handle: ...
|
||||||
|
def run_in_executor(self, executor: Any, func: Callable[[Unpack[_Ts]], _T], *args: Unpack[_Ts]) -> Future[_T]: ...
|
||||||
|
def set_default_executor(self, executor: Any) -> None: ...
|
||||||
|
# Network I/O methods returning Futures.
|
||||||
|
async def getaddrinfo(
|
||||||
|
self,
|
||||||
|
host: bytes | str | None,
|
||||||
|
port: bytes | str | int | None,
|
||||||
|
*,
|
||||||
|
family: int = 0,
|
||||||
|
type: int = 0,
|
||||||
|
proto: int = 0,
|
||||||
|
flags: int = 0,
|
||||||
|
) -> list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int]]]: ...
|
||||||
|
async def getnameinfo(self, sockaddr: tuple[str, int] | tuple[str, int, int, int], flags: int = 0) -> tuple[str, str]: ...
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
@overload
|
||||||
|
async def create_connection(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
host: str = ...,
|
||||||
|
port: int = ...,
|
||||||
|
*,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
family: int = 0,
|
||||||
|
proto: int = 0,
|
||||||
|
flags: int = 0,
|
||||||
|
sock: None = None,
|
||||||
|
local_addr: tuple[str, int] | None = None,
|
||||||
|
server_hostname: str | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
ssl_shutdown_timeout: float | None = None,
|
||||||
|
happy_eyeballs_delay: float | None = None,
|
||||||
|
interleave: int | None = None,
|
||||||
|
all_errors: bool = False,
|
||||||
|
) -> tuple[Transport, _ProtocolT]: ...
|
||||||
|
@overload
|
||||||
|
async def create_connection(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
host: None = None,
|
||||||
|
port: None = None,
|
||||||
|
*,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
family: int = 0,
|
||||||
|
proto: int = 0,
|
||||||
|
flags: int = 0,
|
||||||
|
sock: socket,
|
||||||
|
local_addr: None = None,
|
||||||
|
server_hostname: str | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
ssl_shutdown_timeout: float | None = None,
|
||||||
|
happy_eyeballs_delay: float | None = None,
|
||||||
|
interleave: int | None = None,
|
||||||
|
all_errors: bool = False,
|
||||||
|
) -> tuple[Transport, _ProtocolT]: ...
|
||||||
|
elif sys.version_info >= (3, 11):
|
||||||
|
@overload
|
||||||
|
async def create_connection(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
host: str = ...,
|
||||||
|
port: int = ...,
|
||||||
|
*,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
family: int = 0,
|
||||||
|
proto: int = 0,
|
||||||
|
flags: int = 0,
|
||||||
|
sock: None = None,
|
||||||
|
local_addr: tuple[str, int] | None = None,
|
||||||
|
server_hostname: str | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
ssl_shutdown_timeout: float | None = None,
|
||||||
|
happy_eyeballs_delay: float | None = None,
|
||||||
|
interleave: int | None = None,
|
||||||
|
) -> tuple[Transport, _ProtocolT]: ...
|
||||||
|
@overload
|
||||||
|
async def create_connection(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
host: None = None,
|
||||||
|
port: None = None,
|
||||||
|
*,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
family: int = 0,
|
||||||
|
proto: int = 0,
|
||||||
|
flags: int = 0,
|
||||||
|
sock: socket,
|
||||||
|
local_addr: None = None,
|
||||||
|
server_hostname: str | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
ssl_shutdown_timeout: float | None = None,
|
||||||
|
happy_eyeballs_delay: float | None = None,
|
||||||
|
interleave: int | None = None,
|
||||||
|
) -> tuple[Transport, _ProtocolT]: ...
|
||||||
|
else:
|
||||||
|
@overload
|
||||||
|
async def create_connection(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
host: str = ...,
|
||||||
|
port: int = ...,
|
||||||
|
*,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
family: int = 0,
|
||||||
|
proto: int = 0,
|
||||||
|
flags: int = 0,
|
||||||
|
sock: None = None,
|
||||||
|
local_addr: tuple[str, int] | None = None,
|
||||||
|
server_hostname: str | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
happy_eyeballs_delay: float | None = None,
|
||||||
|
interleave: int | None = None,
|
||||||
|
) -> tuple[Transport, _ProtocolT]: ...
|
||||||
|
@overload
|
||||||
|
async def create_connection(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
host: None = None,
|
||||||
|
port: None = None,
|
||||||
|
*,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
family: int = 0,
|
||||||
|
proto: int = 0,
|
||||||
|
flags: int = 0,
|
||||||
|
sock: socket,
|
||||||
|
local_addr: None = None,
|
||||||
|
server_hostname: str | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
happy_eyeballs_delay: float | None = None,
|
||||||
|
interleave: int | None = None,
|
||||||
|
) -> tuple[Transport, _ProtocolT]: ...
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
@overload
|
||||||
|
async def create_server(
|
||||||
|
self,
|
||||||
|
protocol_factory: _ProtocolFactory,
|
||||||
|
host: str | Sequence[str] | None = None,
|
||||||
|
port: int = ...,
|
||||||
|
*,
|
||||||
|
family: int = ...,
|
||||||
|
flags: int = ...,
|
||||||
|
sock: None = None,
|
||||||
|
backlog: int = 100,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
reuse_address: bool | None = None,
|
||||||
|
reuse_port: bool | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
ssl_shutdown_timeout: float | None = None,
|
||||||
|
start_serving: bool = True,
|
||||||
|
) -> Server: ...
|
||||||
|
@overload
|
||||||
|
async def create_server(
|
||||||
|
self,
|
||||||
|
protocol_factory: _ProtocolFactory,
|
||||||
|
host: None = None,
|
||||||
|
port: None = None,
|
||||||
|
*,
|
||||||
|
family: int = ...,
|
||||||
|
flags: int = ...,
|
||||||
|
sock: socket = ...,
|
||||||
|
backlog: int = 100,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
reuse_address: bool | None = None,
|
||||||
|
reuse_port: bool | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
ssl_shutdown_timeout: float | None = None,
|
||||||
|
start_serving: bool = True,
|
||||||
|
) -> Server: ...
|
||||||
|
async def start_tls(
|
||||||
|
self,
|
||||||
|
transport: BaseTransport,
|
||||||
|
protocol: BaseProtocol,
|
||||||
|
sslcontext: ssl.SSLContext,
|
||||||
|
*,
|
||||||
|
server_side: bool = False,
|
||||||
|
server_hostname: str | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
ssl_shutdown_timeout: float | None = None,
|
||||||
|
) -> Transport | None: ...
|
||||||
|
async def connect_accepted_socket(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
sock: socket,
|
||||||
|
*,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
ssl_shutdown_timeout: float | None = None,
|
||||||
|
) -> tuple[Transport, _ProtocolT]: ...
|
||||||
|
else:
|
||||||
|
@overload
|
||||||
|
async def create_server(
|
||||||
|
self,
|
||||||
|
protocol_factory: _ProtocolFactory,
|
||||||
|
host: str | Sequence[str] | None = None,
|
||||||
|
port: int = ...,
|
||||||
|
*,
|
||||||
|
family: int = ...,
|
||||||
|
flags: int = ...,
|
||||||
|
sock: None = None,
|
||||||
|
backlog: int = 100,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
reuse_address: bool | None = None,
|
||||||
|
reuse_port: bool | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
start_serving: bool = True,
|
||||||
|
) -> Server: ...
|
||||||
|
@overload
|
||||||
|
async def create_server(
|
||||||
|
self,
|
||||||
|
protocol_factory: _ProtocolFactory,
|
||||||
|
host: None = None,
|
||||||
|
port: None = None,
|
||||||
|
*,
|
||||||
|
family: int = ...,
|
||||||
|
flags: int = ...,
|
||||||
|
sock: socket = ...,
|
||||||
|
backlog: int = 100,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
reuse_address: bool | None = None,
|
||||||
|
reuse_port: bool | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
start_serving: bool = True,
|
||||||
|
) -> Server: ...
|
||||||
|
async def start_tls(
|
||||||
|
self,
|
||||||
|
transport: BaseTransport,
|
||||||
|
protocol: BaseProtocol,
|
||||||
|
sslcontext: ssl.SSLContext,
|
||||||
|
*,
|
||||||
|
server_side: bool = False,
|
||||||
|
server_hostname: str | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
) -> Transport | None: ...
|
||||||
|
async def connect_accepted_socket(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
sock: socket,
|
||||||
|
*,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
) -> tuple[Transport, _ProtocolT]: ...
|
||||||
|
|
||||||
|
async def sock_sendfile(
|
||||||
|
self, sock: socket, file: IO[bytes], offset: int = 0, count: int | None = None, *, fallback: bool | None = True
|
||||||
|
) -> int: ...
|
||||||
|
async def sendfile(
|
||||||
|
self, transport: WriteTransport, file: IO[bytes], offset: int = 0, count: int | None = None, *, fallback: bool = True
|
||||||
|
) -> int: ...
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
async def create_datagram_endpoint( # type: ignore[override]
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
local_addr: tuple[str, int] | str | None = None,
|
||||||
|
remote_addr: tuple[str, int] | str | None = None,
|
||||||
|
*,
|
||||||
|
family: int = 0,
|
||||||
|
proto: int = 0,
|
||||||
|
flags: int = 0,
|
||||||
|
reuse_port: bool | None = None,
|
||||||
|
allow_broadcast: bool | None = None,
|
||||||
|
sock: socket | None = None,
|
||||||
|
) -> tuple[DatagramTransport, _ProtocolT]: ...
|
||||||
|
else:
|
||||||
|
async def create_datagram_endpoint(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
local_addr: tuple[str, int] | str | None = None,
|
||||||
|
remote_addr: tuple[str, int] | str | None = None,
|
||||||
|
*,
|
||||||
|
family: int = 0,
|
||||||
|
proto: int = 0,
|
||||||
|
flags: int = 0,
|
||||||
|
reuse_address: bool | None = ...,
|
||||||
|
reuse_port: bool | None = None,
|
||||||
|
allow_broadcast: bool | None = None,
|
||||||
|
sock: socket | None = None,
|
||||||
|
) -> tuple[DatagramTransport, _ProtocolT]: ...
|
||||||
|
# Pipes and subprocesses.
|
||||||
|
async def connect_read_pipe(
|
||||||
|
self, protocol_factory: Callable[[], _ProtocolT], pipe: Any
|
||||||
|
) -> tuple[ReadTransport, _ProtocolT]: ...
|
||||||
|
async def connect_write_pipe(
|
||||||
|
self, protocol_factory: Callable[[], _ProtocolT], pipe: Any
|
||||||
|
) -> tuple[WriteTransport, _ProtocolT]: ...
|
||||||
|
async def subprocess_shell(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
cmd: bytes | str,
|
||||||
|
*,
|
||||||
|
stdin: int | IO[Any] | None = -1,
|
||||||
|
stdout: int | IO[Any] | None = -1,
|
||||||
|
stderr: int | IO[Any] | None = -1,
|
||||||
|
universal_newlines: Literal[False] = False,
|
||||||
|
shell: Literal[True] = True,
|
||||||
|
bufsize: Literal[0] = 0,
|
||||||
|
encoding: None = None,
|
||||||
|
errors: None = None,
|
||||||
|
text: Literal[False] | None = None,
|
||||||
|
**kwargs: Any,
|
||||||
|
) -> tuple[SubprocessTransport, _ProtocolT]: ...
|
||||||
|
async def subprocess_exec(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
program: Any,
|
||||||
|
*args: Any,
|
||||||
|
stdin: int | IO[Any] | None = -1,
|
||||||
|
stdout: int | IO[Any] | None = -1,
|
||||||
|
stderr: int | IO[Any] | None = -1,
|
||||||
|
universal_newlines: Literal[False] = False,
|
||||||
|
shell: Literal[False] = False,
|
||||||
|
bufsize: Literal[0] = 0,
|
||||||
|
encoding: None = None,
|
||||||
|
errors: None = None,
|
||||||
|
**kwargs: Any,
|
||||||
|
) -> tuple[SubprocessTransport, _ProtocolT]: ...
|
||||||
|
def add_reader(self, fd: FileDescriptorLike, callback: Callable[[Unpack[_Ts]], Any], *args: Unpack[_Ts]) -> None: ...
|
||||||
|
def remove_reader(self, fd: FileDescriptorLike) -> bool: ...
|
||||||
|
def add_writer(self, fd: FileDescriptorLike, callback: Callable[[Unpack[_Ts]], Any], *args: Unpack[_Ts]) -> None: ...
|
||||||
|
def remove_writer(self, fd: FileDescriptorLike) -> bool: ...
|
||||||
|
# The sock_* methods (and probably some others) are not actually implemented on
|
||||||
|
# BaseEventLoop, only on subclasses. We list them here for now for convenience.
|
||||||
|
async def sock_recv(self, sock: socket, nbytes: int) -> bytes: ...
|
||||||
|
async def sock_recv_into(self, sock: socket, buf: WriteableBuffer) -> int: ...
|
||||||
|
async def sock_sendall(self, sock: socket, data: ReadableBuffer) -> None: ...
|
||||||
|
async def sock_connect(self, sock: socket, address: _Address) -> None: ...
|
||||||
|
async def sock_accept(self, sock: socket) -> tuple[socket, _RetAddress]: ...
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
async def sock_recvfrom(self, sock: socket, bufsize: int) -> tuple[bytes, _RetAddress]: ...
|
||||||
|
async def sock_recvfrom_into(self, sock: socket, buf: WriteableBuffer, nbytes: int = 0) -> tuple[int, _RetAddress]: ...
|
||||||
|
async def sock_sendto(self, sock: socket, data: ReadableBuffer, address: _Address) -> int: ...
|
||||||
|
# Signal handling.
|
||||||
|
def add_signal_handler(self, sig: int, callback: Callable[[Unpack[_Ts]], Any], *args: Unpack[_Ts]) -> None: ...
|
||||||
|
def remove_signal_handler(self, sig: int) -> bool: ...
|
||||||
|
# Error handlers.
|
||||||
|
def set_exception_handler(self, handler: _ExceptionHandler | None) -> None: ...
|
||||||
|
def get_exception_handler(self) -> _ExceptionHandler | None: ...
|
||||||
|
def default_exception_handler(self, context: _Context) -> None: ...
|
||||||
|
def call_exception_handler(self, context: _Context) -> None: ...
|
||||||
|
# Debug flag management.
|
||||||
|
def get_debug(self) -> bool: ...
|
||||||
|
def set_debug(self, enabled: bool) -> None: ...
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
async def shutdown_default_executor(self, timeout: float | None = None) -> None: ...
|
||||||
|
elif sys.version_info >= (3, 9):
|
||||||
|
async def shutdown_default_executor(self) -> None: ...
|
||||||
|
|
||||||
|
def __del__(self) -> None: ...
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
from collections.abc import Callable, Sequence
|
||||||
|
from contextvars import Context
|
||||||
|
from typing import Any, Literal
|
||||||
|
|
||||||
|
from . import futures
|
||||||
|
|
||||||
|
__all__ = ()
|
||||||
|
|
||||||
|
# asyncio defines 'isfuture()' in base_futures.py and re-imports it in futures.py
|
||||||
|
# but it leads to circular import error in pytype tool.
|
||||||
|
# That's why the import order is reversed.
|
||||||
|
from .futures import isfuture as isfuture
|
||||||
|
|
||||||
|
_PENDING: Literal["PENDING"] # undocumented
|
||||||
|
_CANCELLED: Literal["CANCELLED"] # undocumented
|
||||||
|
_FINISHED: Literal["FINISHED"] # undocumented
|
||||||
|
|
||||||
|
def _format_callbacks(cb: Sequence[tuple[Callable[[futures.Future[Any]], None], Context]]) -> str: ... # undocumented
|
||||||
|
def _future_repr_info(future: futures.Future[Any]) -> list[str]: ... # undocumented
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
import subprocess
|
||||||
|
from collections import deque
|
||||||
|
from collections.abc import Callable, Sequence
|
||||||
|
from typing import IO, Any
|
||||||
|
from typing_extensions import TypeAlias
|
||||||
|
|
||||||
|
from . import events, futures, protocols, transports
|
||||||
|
|
||||||
|
_File: TypeAlias = int | IO[Any] | None
|
||||||
|
|
||||||
|
class BaseSubprocessTransport(transports.SubprocessTransport):
|
||||||
|
_closed: bool # undocumented
|
||||||
|
_protocol: protocols.SubprocessProtocol # undocumented
|
||||||
|
_loop: events.AbstractEventLoop # undocumented
|
||||||
|
_proc: subprocess.Popen[Any] | None # undocumented
|
||||||
|
_pid: int | None # undocumented
|
||||||
|
_returncode: int | None # undocumented
|
||||||
|
_exit_waiters: list[futures.Future[Any]] # undocumented
|
||||||
|
_pending_calls: deque[tuple[Callable[..., Any], tuple[Any, ...]]] # undocumented
|
||||||
|
_pipes: dict[int, _File] # undocumented
|
||||||
|
_finished: bool # undocumented
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
loop: events.AbstractEventLoop,
|
||||||
|
protocol: protocols.SubprocessProtocol,
|
||||||
|
args: str | bytes | Sequence[str | bytes],
|
||||||
|
shell: bool,
|
||||||
|
stdin: _File,
|
||||||
|
stdout: _File,
|
||||||
|
stderr: _File,
|
||||||
|
bufsize: int,
|
||||||
|
waiter: futures.Future[Any] | None = None,
|
||||||
|
extra: Any | None = None,
|
||||||
|
**kwargs: Any,
|
||||||
|
) -> None: ...
|
||||||
|
def _start(
|
||||||
|
self,
|
||||||
|
args: str | bytes | Sequence[str | bytes],
|
||||||
|
shell: bool,
|
||||||
|
stdin: _File,
|
||||||
|
stdout: _File,
|
||||||
|
stderr: _File,
|
||||||
|
bufsize: int,
|
||||||
|
**kwargs: Any,
|
||||||
|
) -> None: ... # undocumented
|
||||||
|
def get_pid(self) -> int | None: ... # type: ignore[override]
|
||||||
|
def get_pipe_transport(self, fd: int) -> _File: ... # type: ignore[override]
|
||||||
|
def _check_proc(self) -> None: ... # undocumented
|
||||||
|
def send_signal(self, signal: int) -> None: ...
|
||||||
|
async def _connect_pipes(self, waiter: futures.Future[Any] | None) -> None: ... # undocumented
|
||||||
|
def _call(self, cb: Callable[..., object], *data: Any) -> None: ... # undocumented
|
||||||
|
def _pipe_connection_lost(self, fd: int, exc: BaseException | None) -> None: ... # undocumented
|
||||||
|
def _pipe_data_received(self, fd: int, data: bytes) -> None: ... # undocumented
|
||||||
|
def _process_exited(self, returncode: int) -> None: ... # undocumented
|
||||||
|
async def _wait(self) -> int: ... # undocumented
|
||||||
|
def _try_finish(self) -> None: ... # undocumented
|
||||||
|
def _call_connection_lost(self, exc: BaseException | None) -> None: ... # undocumented
|
||||||
|
def __del__(self) -> None: ...
|
||||||
|
|
||||||
|
class WriteSubprocessPipeProto(protocols.BaseProtocol): # undocumented
|
||||||
|
def __init__(self, proc: BaseSubprocessTransport, fd: int) -> None: ...
|
||||||
|
|
||||||
|
class ReadSubprocessPipeProto(WriteSubprocessPipeProto, protocols.Protocol): ... # undocumented
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
from _typeshed import StrOrBytesPath
|
||||||
|
from types import FrameType
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from . import tasks
|
||||||
|
|
||||||
|
def _task_repr_info(task: tasks.Task[Any]) -> list[str]: ... # undocumented
|
||||||
|
def _task_get_stack(task: tasks.Task[Any], limit: int | None) -> list[FrameType]: ... # undocumented
|
||||||
|
def _task_print_stack(task: tasks.Task[Any], limit: int | None, file: StrOrBytesPath) -> None: ... # undocumented
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
import enum
|
||||||
|
import sys
|
||||||
|
from typing import Literal
|
||||||
|
|
||||||
|
LOG_THRESHOLD_FOR_CONNLOST_WRITES: Literal[5]
|
||||||
|
ACCEPT_RETRY_DELAY: Literal[1]
|
||||||
|
DEBUG_STACK_DEPTH: Literal[10]
|
||||||
|
SSL_HANDSHAKE_TIMEOUT: float
|
||||||
|
SENDFILE_FALLBACK_READBUFFER_SIZE: Literal[262144]
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
SSL_SHUTDOWN_TIMEOUT: float
|
||||||
|
FLOW_CONTROL_HIGH_WATER_SSL_READ: Literal[256]
|
||||||
|
FLOW_CONTROL_HIGH_WATER_SSL_WRITE: Literal[512]
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
THREAD_JOIN_TIMEOUT: Literal[300]
|
||||||
|
|
||||||
|
class _SendfileMode(enum.Enum):
|
||||||
|
UNSUPPORTED = 1
|
||||||
|
TRY_NATIVE = 2
|
||||||
|
FALLBACK = 3
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
import sys
|
||||||
|
from collections.abc import Awaitable, Callable, Coroutine
|
||||||
|
from typing import Any, TypeVar, overload
|
||||||
|
from typing_extensions import ParamSpec, TypeGuard, TypeIs
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
__all__ = ("iscoroutinefunction", "iscoroutine")
|
||||||
|
else:
|
||||||
|
__all__ = ("coroutine", "iscoroutinefunction", "iscoroutine")
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
_FunctionT = TypeVar("_FunctionT", bound=Callable[..., Any])
|
||||||
|
_P = ParamSpec("_P")
|
||||||
|
|
||||||
|
if sys.version_info < (3, 11):
|
||||||
|
def coroutine(func: _FunctionT) -> _FunctionT: ...
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def iscoroutinefunction(func: Callable[..., Coroutine[Any, Any, Any]]) -> bool: ...
|
||||||
|
@overload
|
||||||
|
def iscoroutinefunction(func: Callable[_P, Awaitable[_T]]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, _T]]]: ...
|
||||||
|
@overload
|
||||||
|
def iscoroutinefunction(func: Callable[_P, object]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, Any]]]: ...
|
||||||
|
@overload
|
||||||
|
def iscoroutinefunction(func: object) -> TypeGuard[Callable[..., Coroutine[Any, Any, Any]]]: ...
|
||||||
|
def iscoroutine(obj: object) -> TypeIs[Coroutine[Any, Any, Any]]: ...
|
||||||
|
|
@ -0,0 +1,580 @@
|
||||||
|
import ssl
|
||||||
|
import sys
|
||||||
|
from _typeshed import FileDescriptorLike, ReadableBuffer, StrPath, Unused, WriteableBuffer
|
||||||
|
from abc import ABCMeta, abstractmethod
|
||||||
|
from collections.abc import Callable, Coroutine, Generator, Sequence
|
||||||
|
from contextvars import Context
|
||||||
|
from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket
|
||||||
|
from typing import IO, Any, Literal, Protocol, TypeVar, overload
|
||||||
|
from typing_extensions import Self, TypeAlias, TypeVarTuple, Unpack, deprecated
|
||||||
|
|
||||||
|
from . import _AwaitableLike, _CoroutineLike
|
||||||
|
from .base_events import Server
|
||||||
|
from .futures import Future
|
||||||
|
from .protocols import BaseProtocol
|
||||||
|
from .tasks import Task
|
||||||
|
from .transports import BaseTransport, DatagramTransport, ReadTransport, SubprocessTransport, Transport, WriteTransport
|
||||||
|
from .unix_events import AbstractChildWatcher
|
||||||
|
|
||||||
|
__all__ = (
|
||||||
|
"AbstractEventLoopPolicy",
|
||||||
|
"AbstractEventLoop",
|
||||||
|
"AbstractServer",
|
||||||
|
"Handle",
|
||||||
|
"TimerHandle",
|
||||||
|
"get_event_loop_policy",
|
||||||
|
"set_event_loop_policy",
|
||||||
|
"get_event_loop",
|
||||||
|
"set_event_loop",
|
||||||
|
"new_event_loop",
|
||||||
|
"get_child_watcher",
|
||||||
|
"set_child_watcher",
|
||||||
|
"_set_running_loop",
|
||||||
|
"get_running_loop",
|
||||||
|
"_get_running_loop",
|
||||||
|
)
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
_Ts = TypeVarTuple("_Ts")
|
||||||
|
_ProtocolT = TypeVar("_ProtocolT", bound=BaseProtocol)
|
||||||
|
_Context: TypeAlias = dict[str, Any]
|
||||||
|
_ExceptionHandler: TypeAlias = Callable[[AbstractEventLoop, _Context], object]
|
||||||
|
_ProtocolFactory: TypeAlias = Callable[[], BaseProtocol]
|
||||||
|
_SSLContext: TypeAlias = bool | None | ssl.SSLContext
|
||||||
|
|
||||||
|
class _TaskFactory(Protocol):
|
||||||
|
def __call__(self, loop: AbstractEventLoop, factory: Coroutine[Any, Any, _T] | Generator[Any, None, _T], /) -> Future[_T]: ...
|
||||||
|
|
||||||
|
class Handle:
|
||||||
|
_cancelled: bool
|
||||||
|
_args: Sequence[Any]
|
||||||
|
def __init__(
|
||||||
|
self, callback: Callable[..., object], args: Sequence[Any], loop: AbstractEventLoop, context: Context | None = None
|
||||||
|
) -> None: ...
|
||||||
|
def cancel(self) -> None: ...
|
||||||
|
def _run(self) -> None: ...
|
||||||
|
def cancelled(self) -> bool: ...
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
def get_context(self) -> Context: ...
|
||||||
|
|
||||||
|
class TimerHandle(Handle):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
when: float,
|
||||||
|
callback: Callable[..., object],
|
||||||
|
args: Sequence[Any],
|
||||||
|
loop: AbstractEventLoop,
|
||||||
|
context: Context | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
def __hash__(self) -> int: ...
|
||||||
|
def when(self) -> float: ...
|
||||||
|
def __lt__(self, other: TimerHandle) -> bool: ...
|
||||||
|
def __le__(self, other: TimerHandle) -> bool: ...
|
||||||
|
def __gt__(self, other: TimerHandle) -> bool: ...
|
||||||
|
def __ge__(self, other: TimerHandle) -> bool: ...
|
||||||
|
def __eq__(self, other: object) -> bool: ...
|
||||||
|
|
||||||
|
class AbstractServer:
|
||||||
|
@abstractmethod
|
||||||
|
def close(self) -> None: ...
|
||||||
|
async def __aenter__(self) -> Self: ...
|
||||||
|
async def __aexit__(self, *exc: Unused) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
def get_loop(self) -> AbstractEventLoop: ...
|
||||||
|
@abstractmethod
|
||||||
|
def is_serving(self) -> bool: ...
|
||||||
|
@abstractmethod
|
||||||
|
async def start_serving(self) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
async def serve_forever(self) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
async def wait_closed(self) -> None: ...
|
||||||
|
|
||||||
|
class AbstractEventLoop:
|
||||||
|
slow_callback_duration: float
|
||||||
|
@abstractmethod
|
||||||
|
def run_forever(self) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
def run_until_complete(self, future: _AwaitableLike[_T]) -> _T: ...
|
||||||
|
@abstractmethod
|
||||||
|
def stop(self) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
def is_running(self) -> bool: ...
|
||||||
|
@abstractmethod
|
||||||
|
def is_closed(self) -> bool: ...
|
||||||
|
@abstractmethod
|
||||||
|
def close(self) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
async def shutdown_asyncgens(self) -> None: ...
|
||||||
|
# Methods scheduling callbacks. All these return Handles.
|
||||||
|
if sys.version_info >= (3, 9): # "context" added in 3.9.10/3.10.2
|
||||||
|
@abstractmethod
|
||||||
|
def call_soon(
|
||||||
|
self, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
|
||||||
|
) -> Handle: ...
|
||||||
|
@abstractmethod
|
||||||
|
def call_later(
|
||||||
|
self, delay: float, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
|
||||||
|
) -> TimerHandle: ...
|
||||||
|
@abstractmethod
|
||||||
|
def call_at(
|
||||||
|
self, when: float, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
|
||||||
|
) -> TimerHandle: ...
|
||||||
|
else:
|
||||||
|
@abstractmethod
|
||||||
|
def call_soon(self, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]) -> Handle: ...
|
||||||
|
@abstractmethod
|
||||||
|
def call_later(self, delay: float, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]) -> TimerHandle: ...
|
||||||
|
@abstractmethod
|
||||||
|
def call_at(self, when: float, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]) -> TimerHandle: ...
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def time(self) -> float: ...
|
||||||
|
# Future methods
|
||||||
|
@abstractmethod
|
||||||
|
def create_future(self) -> Future[Any]: ...
|
||||||
|
# Tasks methods
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
@abstractmethod
|
||||||
|
def create_task(
|
||||||
|
self, coro: _CoroutineLike[_T], *, name: str | None = None, context: Context | None = None
|
||||||
|
) -> Task[_T]: ...
|
||||||
|
else:
|
||||||
|
@abstractmethod
|
||||||
|
def create_task(self, coro: _CoroutineLike[_T], *, name: str | None = None) -> Task[_T]: ...
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def set_task_factory(self, factory: _TaskFactory | None) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
def get_task_factory(self) -> _TaskFactory | None: ...
|
||||||
|
# Methods for interacting with threads
|
||||||
|
if sys.version_info >= (3, 9): # "context" added in 3.9.10/3.10.2
|
||||||
|
@abstractmethod
|
||||||
|
def call_soon_threadsafe(
|
||||||
|
self, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
|
||||||
|
) -> Handle: ...
|
||||||
|
else:
|
||||||
|
@abstractmethod
|
||||||
|
def call_soon_threadsafe(self, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]) -> Handle: ...
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def run_in_executor(self, executor: Any, func: Callable[[Unpack[_Ts]], _T], *args: Unpack[_Ts]) -> Future[_T]: ...
|
||||||
|
@abstractmethod
|
||||||
|
def set_default_executor(self, executor: Any) -> None: ...
|
||||||
|
# Network I/O methods returning Futures.
|
||||||
|
@abstractmethod
|
||||||
|
async def getaddrinfo(
|
||||||
|
self,
|
||||||
|
host: bytes | str | None,
|
||||||
|
port: bytes | str | int | None,
|
||||||
|
*,
|
||||||
|
family: int = 0,
|
||||||
|
type: int = 0,
|
||||||
|
proto: int = 0,
|
||||||
|
flags: int = 0,
|
||||||
|
) -> list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int]]]: ...
|
||||||
|
@abstractmethod
|
||||||
|
async def getnameinfo(self, sockaddr: tuple[str, int] | tuple[str, int, int, int], flags: int = 0) -> tuple[str, str]: ...
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
@overload
|
||||||
|
@abstractmethod
|
||||||
|
async def create_connection(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
host: str = ...,
|
||||||
|
port: int = ...,
|
||||||
|
*,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
family: int = 0,
|
||||||
|
proto: int = 0,
|
||||||
|
flags: int = 0,
|
||||||
|
sock: None = None,
|
||||||
|
local_addr: tuple[str, int] | None = None,
|
||||||
|
server_hostname: str | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
ssl_shutdown_timeout: float | None = None,
|
||||||
|
happy_eyeballs_delay: float | None = None,
|
||||||
|
interleave: int | None = None,
|
||||||
|
) -> tuple[Transport, _ProtocolT]: ...
|
||||||
|
@overload
|
||||||
|
@abstractmethod
|
||||||
|
async def create_connection(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
host: None = None,
|
||||||
|
port: None = None,
|
||||||
|
*,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
family: int = 0,
|
||||||
|
proto: int = 0,
|
||||||
|
flags: int = 0,
|
||||||
|
sock: socket,
|
||||||
|
local_addr: None = None,
|
||||||
|
server_hostname: str | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
ssl_shutdown_timeout: float | None = None,
|
||||||
|
happy_eyeballs_delay: float | None = None,
|
||||||
|
interleave: int | None = None,
|
||||||
|
) -> tuple[Transport, _ProtocolT]: ...
|
||||||
|
else:
|
||||||
|
@overload
|
||||||
|
@abstractmethod
|
||||||
|
async def create_connection(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
host: str = ...,
|
||||||
|
port: int = ...,
|
||||||
|
*,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
family: int = 0,
|
||||||
|
proto: int = 0,
|
||||||
|
flags: int = 0,
|
||||||
|
sock: None = None,
|
||||||
|
local_addr: tuple[str, int] | None = None,
|
||||||
|
server_hostname: str | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
happy_eyeballs_delay: float | None = None,
|
||||||
|
interleave: int | None = None,
|
||||||
|
) -> tuple[Transport, _ProtocolT]: ...
|
||||||
|
@overload
|
||||||
|
@abstractmethod
|
||||||
|
async def create_connection(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
host: None = None,
|
||||||
|
port: None = None,
|
||||||
|
*,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
family: int = 0,
|
||||||
|
proto: int = 0,
|
||||||
|
flags: int = 0,
|
||||||
|
sock: socket,
|
||||||
|
local_addr: None = None,
|
||||||
|
server_hostname: str | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
happy_eyeballs_delay: float | None = None,
|
||||||
|
interleave: int | None = None,
|
||||||
|
) -> tuple[Transport, _ProtocolT]: ...
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
@overload
|
||||||
|
@abstractmethod
|
||||||
|
async def create_server(
|
||||||
|
self,
|
||||||
|
protocol_factory: _ProtocolFactory,
|
||||||
|
host: str | Sequence[str] | None = None,
|
||||||
|
port: int = ...,
|
||||||
|
*,
|
||||||
|
family: int = ...,
|
||||||
|
flags: int = ...,
|
||||||
|
sock: None = None,
|
||||||
|
backlog: int = 100,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
reuse_address: bool | None = None,
|
||||||
|
reuse_port: bool | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
ssl_shutdown_timeout: float | None = None,
|
||||||
|
start_serving: bool = True,
|
||||||
|
) -> Server: ...
|
||||||
|
@overload
|
||||||
|
@abstractmethod
|
||||||
|
async def create_server(
|
||||||
|
self,
|
||||||
|
protocol_factory: _ProtocolFactory,
|
||||||
|
host: None = None,
|
||||||
|
port: None = None,
|
||||||
|
*,
|
||||||
|
family: int = ...,
|
||||||
|
flags: int = ...,
|
||||||
|
sock: socket = ...,
|
||||||
|
backlog: int = 100,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
reuse_address: bool | None = None,
|
||||||
|
reuse_port: bool | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
ssl_shutdown_timeout: float | None = None,
|
||||||
|
start_serving: bool = True,
|
||||||
|
) -> Server: ...
|
||||||
|
@abstractmethod
|
||||||
|
async def start_tls(
|
||||||
|
self,
|
||||||
|
transport: WriteTransport,
|
||||||
|
protocol: BaseProtocol,
|
||||||
|
sslcontext: ssl.SSLContext,
|
||||||
|
*,
|
||||||
|
server_side: bool = False,
|
||||||
|
server_hostname: str | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
ssl_shutdown_timeout: float | None = None,
|
||||||
|
) -> Transport | None: ...
|
||||||
|
async def create_unix_server(
|
||||||
|
self,
|
||||||
|
protocol_factory: _ProtocolFactory,
|
||||||
|
path: StrPath | None = None,
|
||||||
|
*,
|
||||||
|
sock: socket | None = None,
|
||||||
|
backlog: int = 100,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
ssl_shutdown_timeout: float | None = None,
|
||||||
|
start_serving: bool = True,
|
||||||
|
) -> Server: ...
|
||||||
|
else:
|
||||||
|
@overload
|
||||||
|
@abstractmethod
|
||||||
|
async def create_server(
|
||||||
|
self,
|
||||||
|
protocol_factory: _ProtocolFactory,
|
||||||
|
host: str | Sequence[str] | None = None,
|
||||||
|
port: int = ...,
|
||||||
|
*,
|
||||||
|
family: int = ...,
|
||||||
|
flags: int = ...,
|
||||||
|
sock: None = None,
|
||||||
|
backlog: int = 100,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
reuse_address: bool | None = None,
|
||||||
|
reuse_port: bool | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
start_serving: bool = True,
|
||||||
|
) -> Server: ...
|
||||||
|
@overload
|
||||||
|
@abstractmethod
|
||||||
|
async def create_server(
|
||||||
|
self,
|
||||||
|
protocol_factory: _ProtocolFactory,
|
||||||
|
host: None = None,
|
||||||
|
port: None = None,
|
||||||
|
*,
|
||||||
|
family: int = ...,
|
||||||
|
flags: int = ...,
|
||||||
|
sock: socket = ...,
|
||||||
|
backlog: int = 100,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
reuse_address: bool | None = None,
|
||||||
|
reuse_port: bool | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
start_serving: bool = True,
|
||||||
|
) -> Server: ...
|
||||||
|
@abstractmethod
|
||||||
|
async def start_tls(
|
||||||
|
self,
|
||||||
|
transport: BaseTransport,
|
||||||
|
protocol: BaseProtocol,
|
||||||
|
sslcontext: ssl.SSLContext,
|
||||||
|
*,
|
||||||
|
server_side: bool = False,
|
||||||
|
server_hostname: str | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
) -> Transport | None: ...
|
||||||
|
async def create_unix_server(
|
||||||
|
self,
|
||||||
|
protocol_factory: _ProtocolFactory,
|
||||||
|
path: StrPath | None = None,
|
||||||
|
*,
|
||||||
|
sock: socket | None = None,
|
||||||
|
backlog: int = 100,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
start_serving: bool = True,
|
||||||
|
) -> Server: ...
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
async def connect_accepted_socket(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
sock: socket,
|
||||||
|
*,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
ssl_shutdown_timeout: float | None = None,
|
||||||
|
) -> tuple[Transport, _ProtocolT]: ...
|
||||||
|
elif sys.version_info >= (3, 10):
|
||||||
|
async def connect_accepted_socket(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
sock: socket,
|
||||||
|
*,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
) -> tuple[Transport, _ProtocolT]: ...
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
async def create_unix_connection(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
path: str | None = None,
|
||||||
|
*,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
sock: socket | None = None,
|
||||||
|
server_hostname: str | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
ssl_shutdown_timeout: float | None = None,
|
||||||
|
) -> tuple[Transport, _ProtocolT]: ...
|
||||||
|
else:
|
||||||
|
async def create_unix_connection(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
path: str | None = None,
|
||||||
|
*,
|
||||||
|
ssl: _SSLContext = None,
|
||||||
|
sock: socket | None = None,
|
||||||
|
server_hostname: str | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
) -> tuple[Transport, _ProtocolT]: ...
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
async def sock_sendfile(
|
||||||
|
self, sock: socket, file: IO[bytes], offset: int = 0, count: int | None = None, *, fallback: bool | None = None
|
||||||
|
) -> int: ...
|
||||||
|
@abstractmethod
|
||||||
|
async def sendfile(
|
||||||
|
self, transport: WriteTransport, file: IO[bytes], offset: int = 0, count: int | None = None, *, fallback: bool = True
|
||||||
|
) -> int: ...
|
||||||
|
@abstractmethod
|
||||||
|
async def create_datagram_endpoint(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
local_addr: tuple[str, int] | str | None = None,
|
||||||
|
remote_addr: tuple[str, int] | str | None = None,
|
||||||
|
*,
|
||||||
|
family: int = 0,
|
||||||
|
proto: int = 0,
|
||||||
|
flags: int = 0,
|
||||||
|
reuse_address: bool | None = None,
|
||||||
|
reuse_port: bool | None = None,
|
||||||
|
allow_broadcast: bool | None = None,
|
||||||
|
sock: socket | None = None,
|
||||||
|
) -> tuple[DatagramTransport, _ProtocolT]: ...
|
||||||
|
# Pipes and subprocesses.
|
||||||
|
@abstractmethod
|
||||||
|
async def connect_read_pipe(
|
||||||
|
self, protocol_factory: Callable[[], _ProtocolT], pipe: Any
|
||||||
|
) -> tuple[ReadTransport, _ProtocolT]: ...
|
||||||
|
@abstractmethod
|
||||||
|
async def connect_write_pipe(
|
||||||
|
self, protocol_factory: Callable[[], _ProtocolT], pipe: Any
|
||||||
|
) -> tuple[WriteTransport, _ProtocolT]: ...
|
||||||
|
@abstractmethod
|
||||||
|
async def subprocess_shell(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
cmd: bytes | str,
|
||||||
|
*,
|
||||||
|
stdin: int | IO[Any] | None = -1,
|
||||||
|
stdout: int | IO[Any] | None = -1,
|
||||||
|
stderr: int | IO[Any] | None = -1,
|
||||||
|
universal_newlines: Literal[False] = False,
|
||||||
|
shell: Literal[True] = True,
|
||||||
|
bufsize: Literal[0] = 0,
|
||||||
|
encoding: None = None,
|
||||||
|
errors: None = None,
|
||||||
|
text: Literal[False] | None = ...,
|
||||||
|
**kwargs: Any,
|
||||||
|
) -> tuple[SubprocessTransport, _ProtocolT]: ...
|
||||||
|
@abstractmethod
|
||||||
|
async def subprocess_exec(
|
||||||
|
self,
|
||||||
|
protocol_factory: Callable[[], _ProtocolT],
|
||||||
|
program: Any,
|
||||||
|
*args: Any,
|
||||||
|
stdin: int | IO[Any] | None = -1,
|
||||||
|
stdout: int | IO[Any] | None = -1,
|
||||||
|
stderr: int | IO[Any] | None = -1,
|
||||||
|
universal_newlines: Literal[False] = False,
|
||||||
|
shell: Literal[False] = False,
|
||||||
|
bufsize: Literal[0] = 0,
|
||||||
|
encoding: None = None,
|
||||||
|
errors: None = None,
|
||||||
|
**kwargs: Any,
|
||||||
|
) -> tuple[SubprocessTransport, _ProtocolT]: ...
|
||||||
|
@abstractmethod
|
||||||
|
def add_reader(self, fd: FileDescriptorLike, callback: Callable[[Unpack[_Ts]], Any], *args: Unpack[_Ts]) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
def remove_reader(self, fd: FileDescriptorLike) -> bool: ...
|
||||||
|
@abstractmethod
|
||||||
|
def add_writer(self, fd: FileDescriptorLike, callback: Callable[[Unpack[_Ts]], Any], *args: Unpack[_Ts]) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
def remove_writer(self, fd: FileDescriptorLike) -> bool: ...
|
||||||
|
@abstractmethod
|
||||||
|
async def sock_recv(self, sock: socket, nbytes: int) -> bytes: ...
|
||||||
|
@abstractmethod
|
||||||
|
async def sock_recv_into(self, sock: socket, buf: WriteableBuffer) -> int: ...
|
||||||
|
@abstractmethod
|
||||||
|
async def sock_sendall(self, sock: socket, data: ReadableBuffer) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
async def sock_connect(self, sock: socket, address: _Address) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
async def sock_accept(self, sock: socket) -> tuple[socket, _RetAddress]: ...
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
@abstractmethod
|
||||||
|
async def sock_recvfrom(self, sock: socket, bufsize: int) -> tuple[bytes, _RetAddress]: ...
|
||||||
|
@abstractmethod
|
||||||
|
async def sock_recvfrom_into(self, sock: socket, buf: WriteableBuffer, nbytes: int = 0) -> tuple[int, _RetAddress]: ...
|
||||||
|
@abstractmethod
|
||||||
|
async def sock_sendto(self, sock: socket, data: ReadableBuffer, address: _Address) -> int: ...
|
||||||
|
# Signal handling.
|
||||||
|
@abstractmethod
|
||||||
|
def add_signal_handler(self, sig: int, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
def remove_signal_handler(self, sig: int) -> bool: ...
|
||||||
|
# Error handlers.
|
||||||
|
@abstractmethod
|
||||||
|
def set_exception_handler(self, handler: _ExceptionHandler | None) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
def get_exception_handler(self) -> _ExceptionHandler | None: ...
|
||||||
|
@abstractmethod
|
||||||
|
def default_exception_handler(self, context: _Context) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
def call_exception_handler(self, context: _Context) -> None: ...
|
||||||
|
# Debug flag management.
|
||||||
|
@abstractmethod
|
||||||
|
def get_debug(self) -> bool: ...
|
||||||
|
@abstractmethod
|
||||||
|
def set_debug(self, enabled: bool) -> None: ...
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
@abstractmethod
|
||||||
|
async def shutdown_default_executor(self) -> None: ...
|
||||||
|
|
||||||
|
class AbstractEventLoopPolicy:
|
||||||
|
@abstractmethod
|
||||||
|
def get_event_loop(self) -> AbstractEventLoop: ...
|
||||||
|
@abstractmethod
|
||||||
|
def set_event_loop(self, loop: AbstractEventLoop | None) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
def new_event_loop(self) -> AbstractEventLoop: ...
|
||||||
|
# Child processes handling (Unix only).
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
@abstractmethod
|
||||||
|
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
|
||||||
|
def get_child_watcher(self) -> AbstractChildWatcher: ...
|
||||||
|
@abstractmethod
|
||||||
|
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
|
||||||
|
def set_child_watcher(self, watcher: AbstractChildWatcher) -> None: ...
|
||||||
|
else:
|
||||||
|
@abstractmethod
|
||||||
|
def get_child_watcher(self) -> AbstractChildWatcher: ...
|
||||||
|
@abstractmethod
|
||||||
|
def set_child_watcher(self, watcher: AbstractChildWatcher) -> None: ...
|
||||||
|
|
||||||
|
class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy, metaclass=ABCMeta):
|
||||||
|
def get_event_loop(self) -> AbstractEventLoop: ...
|
||||||
|
def set_event_loop(self, loop: AbstractEventLoop | None) -> None: ...
|
||||||
|
def new_event_loop(self) -> AbstractEventLoop: ...
|
||||||
|
|
||||||
|
def get_event_loop_policy() -> AbstractEventLoopPolicy: ...
|
||||||
|
def set_event_loop_policy(policy: AbstractEventLoopPolicy | None) -> None: ...
|
||||||
|
def get_event_loop() -> AbstractEventLoop: ...
|
||||||
|
def set_event_loop(loop: AbstractEventLoop | None) -> None: ...
|
||||||
|
def new_event_loop() -> AbstractEventLoop: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
|
||||||
|
def get_child_watcher() -> AbstractChildWatcher: ...
|
||||||
|
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
|
||||||
|
def set_child_watcher(watcher: AbstractChildWatcher) -> None: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
def get_child_watcher() -> AbstractChildWatcher: ...
|
||||||
|
def set_child_watcher(watcher: AbstractChildWatcher) -> None: ...
|
||||||
|
|
||||||
|
def _set_running_loop(loop: AbstractEventLoop | None, /) -> None: ...
|
||||||
|
def _get_running_loop() -> AbstractEventLoop: ...
|
||||||
|
def get_running_loop() -> AbstractEventLoop: ...
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
__all__ = (
|
||||||
|
"BrokenBarrierError",
|
||||||
|
"CancelledError",
|
||||||
|
"InvalidStateError",
|
||||||
|
"TimeoutError",
|
||||||
|
"IncompleteReadError",
|
||||||
|
"LimitOverrunError",
|
||||||
|
"SendfileNotAvailableError",
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
__all__ = (
|
||||||
|
"CancelledError",
|
||||||
|
"InvalidStateError",
|
||||||
|
"TimeoutError",
|
||||||
|
"IncompleteReadError",
|
||||||
|
"LimitOverrunError",
|
||||||
|
"SendfileNotAvailableError",
|
||||||
|
)
|
||||||
|
|
||||||
|
class CancelledError(BaseException): ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
from builtins import TimeoutError as TimeoutError
|
||||||
|
else:
|
||||||
|
class TimeoutError(Exception): ...
|
||||||
|
|
||||||
|
class InvalidStateError(Exception): ...
|
||||||
|
class SendfileNotAvailableError(RuntimeError): ...
|
||||||
|
|
||||||
|
class IncompleteReadError(EOFError):
|
||||||
|
expected: int | None
|
||||||
|
partial: bytes
|
||||||
|
def __init__(self, partial: bytes, expected: int | None) -> None: ...
|
||||||
|
|
||||||
|
class LimitOverrunError(Exception):
|
||||||
|
consumed: int
|
||||||
|
def __init__(self, message: str, consumed: int) -> None: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
class BrokenBarrierError(RuntimeError): ...
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
import functools
|
||||||
|
import traceback
|
||||||
|
from collections.abc import Iterable
|
||||||
|
from types import FrameType, FunctionType
|
||||||
|
from typing import Any, overload
|
||||||
|
from typing_extensions import TypeAlias
|
||||||
|
|
||||||
|
class _HasWrapper:
|
||||||
|
__wrapper__: _HasWrapper | FunctionType
|
||||||
|
|
||||||
|
_FuncType: TypeAlias = FunctionType | _HasWrapper | functools.partial[Any] | functools.partialmethod[Any]
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def _get_function_source(func: _FuncType) -> tuple[str, int]: ...
|
||||||
|
@overload
|
||||||
|
def _get_function_source(func: object) -> tuple[str, int] | None: ...
|
||||||
|
def _format_callback_source(func: object, args: Iterable[Any]) -> str: ...
|
||||||
|
def _format_args_and_kwargs(args: Iterable[Any], kwargs: dict[str, Any]) -> str: ...
|
||||||
|
def _format_callback(func: object, args: Iterable[Any], kwargs: dict[str, Any], suffix: str = "") -> str: ...
|
||||||
|
def extract_stack(f: FrameType | None = None, limit: int | None = None) -> traceback.StackSummary: ...
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
import sys
|
||||||
|
from collections.abc import Awaitable, Callable, Generator, Iterable
|
||||||
|
from concurrent.futures._base import Future as _ConcurrentFuture
|
||||||
|
from contextvars import Context
|
||||||
|
from typing import Any, Literal, TypeVar
|
||||||
|
from typing_extensions import Self, TypeIs
|
||||||
|
|
||||||
|
from .events import AbstractEventLoop
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
from types import GenericAlias
|
||||||
|
|
||||||
|
__all__ = ("Future", "wrap_future", "isfuture")
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
|
||||||
|
# asyncio defines 'isfuture()' in base_futures.py and re-imports it in futures.py
|
||||||
|
# but it leads to circular import error in pytype tool.
|
||||||
|
# That's why the import order is reversed.
|
||||||
|
def isfuture(obj: object) -> TypeIs[Future[Any]]: ...
|
||||||
|
|
||||||
|
class Future(Awaitable[_T], Iterable[_T]):
|
||||||
|
_state: str
|
||||||
|
@property
|
||||||
|
def _exception(self) -> BaseException | None: ...
|
||||||
|
_blocking: bool
|
||||||
|
@property
|
||||||
|
def _log_traceback(self) -> bool: ...
|
||||||
|
@_log_traceback.setter
|
||||||
|
def _log_traceback(self, val: Literal[False]) -> None: ...
|
||||||
|
_asyncio_future_blocking: bool # is a part of duck-typing contract for `Future`
|
||||||
|
def __init__(self, *, loop: AbstractEventLoop | None = ...) -> None: ...
|
||||||
|
def __del__(self) -> None: ...
|
||||||
|
def get_loop(self) -> AbstractEventLoop: ...
|
||||||
|
@property
|
||||||
|
def _callbacks(self) -> list[tuple[Callable[[Self], Any], Context]]: ...
|
||||||
|
def add_done_callback(self, fn: Callable[[Self], object], /, *, context: Context | None = None) -> None: ...
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
def cancel(self, msg: Any | None = None) -> bool: ...
|
||||||
|
else:
|
||||||
|
def cancel(self) -> bool: ...
|
||||||
|
|
||||||
|
def cancelled(self) -> bool: ...
|
||||||
|
def done(self) -> bool: ...
|
||||||
|
def result(self) -> _T: ...
|
||||||
|
def exception(self) -> BaseException | None: ...
|
||||||
|
def remove_done_callback(self, fn: Callable[[Self], object], /) -> int: ...
|
||||||
|
def set_result(self, result: _T, /) -> None: ...
|
||||||
|
def set_exception(self, exception: type | BaseException, /) -> None: ...
|
||||||
|
def __iter__(self) -> Generator[Any, None, _T]: ...
|
||||||
|
def __await__(self) -> Generator[Any, None, _T]: ...
|
||||||
|
@property
|
||||||
|
def _loop(self) -> AbstractEventLoop: ...
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||||
|
|
||||||
|
def wrap_future(future: _ConcurrentFuture[_T] | Future[_T], *, loop: AbstractEventLoop | None = None) -> Future[_T]: ...
|
||||||
|
|
@ -0,0 +1,121 @@
|
||||||
|
import enum
|
||||||
|
import sys
|
||||||
|
from _typeshed import Unused
|
||||||
|
from collections import deque
|
||||||
|
from collections.abc import Callable, Generator
|
||||||
|
from types import TracebackType
|
||||||
|
from typing import Any, Literal, TypeVar
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
from .events import AbstractEventLoop
|
||||||
|
from .futures import Future
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
from .mixins import _LoopBoundMixin
|
||||||
|
else:
|
||||||
|
_LoopBoundMixin = object
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
__all__ = ("Lock", "Event", "Condition", "Semaphore", "BoundedSemaphore", "Barrier")
|
||||||
|
else:
|
||||||
|
__all__ = ("Lock", "Event", "Condition", "Semaphore", "BoundedSemaphore")
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
class _ContextManagerMixin:
|
||||||
|
async def __aenter__(self) -> None: ...
|
||||||
|
async def __aexit__(
|
||||||
|
self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
class _ContextManager:
|
||||||
|
def __init__(self, lock: Lock | Semaphore) -> None: ...
|
||||||
|
def __enter__(self) -> None: ...
|
||||||
|
def __exit__(self, *args: Unused) -> None: ...
|
||||||
|
|
||||||
|
class _ContextManagerMixin:
|
||||||
|
# Apparently this exists to *prohibit* use as a context manager.
|
||||||
|
# def __enter__(self) -> NoReturn: ... see: https://github.com/python/typing/issues/1043
|
||||||
|
# def __exit__(self, *args: Any) -> None: ...
|
||||||
|
def __iter__(self) -> Generator[Any, None, _ContextManager]: ...
|
||||||
|
def __await__(self) -> Generator[Any, None, _ContextManager]: ...
|
||||||
|
async def __aenter__(self) -> None: ...
|
||||||
|
async def __aexit__(
|
||||||
|
self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
class Lock(_ContextManagerMixin, _LoopBoundMixin):
|
||||||
|
_waiters: deque[Future[Any]] | None
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
def __init__(self) -> None: ...
|
||||||
|
else:
|
||||||
|
def __init__(self, *, loop: AbstractEventLoop | None = None) -> None: ...
|
||||||
|
|
||||||
|
def locked(self) -> bool: ...
|
||||||
|
async def acquire(self) -> Literal[True]: ...
|
||||||
|
def release(self) -> None: ...
|
||||||
|
|
||||||
|
class Event(_LoopBoundMixin):
|
||||||
|
_waiters: deque[Future[Any]]
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
def __init__(self) -> None: ...
|
||||||
|
else:
|
||||||
|
def __init__(self, *, loop: AbstractEventLoop | None = None) -> None: ...
|
||||||
|
|
||||||
|
def is_set(self) -> bool: ...
|
||||||
|
def set(self) -> None: ...
|
||||||
|
def clear(self) -> None: ...
|
||||||
|
async def wait(self) -> Literal[True]: ...
|
||||||
|
|
||||||
|
class Condition(_ContextManagerMixin, _LoopBoundMixin):
|
||||||
|
_waiters: deque[Future[Any]]
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
def __init__(self, lock: Lock | None = None) -> None: ...
|
||||||
|
else:
|
||||||
|
def __init__(self, lock: Lock | None = None, *, loop: AbstractEventLoop | None = None) -> None: ...
|
||||||
|
|
||||||
|
def locked(self) -> bool: ...
|
||||||
|
async def acquire(self) -> Literal[True]: ...
|
||||||
|
def release(self) -> None: ...
|
||||||
|
async def wait(self) -> Literal[True]: ...
|
||||||
|
async def wait_for(self, predicate: Callable[[], _T]) -> _T: ...
|
||||||
|
def notify(self, n: int = 1) -> None: ...
|
||||||
|
def notify_all(self) -> None: ...
|
||||||
|
|
||||||
|
class Semaphore(_ContextManagerMixin, _LoopBoundMixin):
|
||||||
|
_value: int
|
||||||
|
_waiters: deque[Future[Any]] | None
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
def __init__(self, value: int = 1) -> None: ...
|
||||||
|
else:
|
||||||
|
def __init__(self, value: int = 1, *, loop: AbstractEventLoop | None = None) -> None: ...
|
||||||
|
|
||||||
|
def locked(self) -> bool: ...
|
||||||
|
async def acquire(self) -> Literal[True]: ...
|
||||||
|
def release(self) -> None: ...
|
||||||
|
def _wake_up_next(self) -> None: ...
|
||||||
|
|
||||||
|
class BoundedSemaphore(Semaphore): ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
class _BarrierState(enum.Enum): # undocumented
|
||||||
|
FILLING = "filling"
|
||||||
|
DRAINING = "draining"
|
||||||
|
RESETTING = "resetting"
|
||||||
|
BROKEN = "broken"
|
||||||
|
|
||||||
|
class Barrier(_LoopBoundMixin):
|
||||||
|
def __init__(self, parties: int) -> None: ...
|
||||||
|
async def __aenter__(self) -> Self: ...
|
||||||
|
async def __aexit__(self, *args: Unused) -> None: ...
|
||||||
|
async def wait(self) -> int: ...
|
||||||
|
async def abort(self) -> None: ...
|
||||||
|
async def reset(self) -> None: ...
|
||||||
|
@property
|
||||||
|
def parties(self) -> int: ...
|
||||||
|
@property
|
||||||
|
def n_waiting(self) -> int: ...
|
||||||
|
@property
|
||||||
|
def broken(self) -> bool: ...
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logger: logging.Logger
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
import sys
|
||||||
|
import threading
|
||||||
|
from typing_extensions import Never
|
||||||
|
|
||||||
|
_global_lock: threading.Lock
|
||||||
|
|
||||||
|
class _LoopBoundMixin:
|
||||||
|
if sys.version_info < (3, 11):
|
||||||
|
def __init__(self, *, loop: Never = ...) -> None: ...
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
import sys
|
||||||
|
from collections.abc import Mapping
|
||||||
|
from socket import socket
|
||||||
|
from typing import Any, ClassVar, Literal
|
||||||
|
|
||||||
|
from . import base_events, constants, events, futures, streams, transports
|
||||||
|
|
||||||
|
__all__ = ("BaseProactorEventLoop",)
|
||||||
|
|
||||||
|
class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTransport):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
loop: events.AbstractEventLoop,
|
||||||
|
sock: socket,
|
||||||
|
protocol: streams.StreamReaderProtocol,
|
||||||
|
waiter: futures.Future[Any] | None = None,
|
||||||
|
extra: Mapping[Any, Any] | None = None,
|
||||||
|
server: events.AbstractServer | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
def __del__(self) -> None: ...
|
||||||
|
|
||||||
|
class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTransport):
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
loop: events.AbstractEventLoop,
|
||||||
|
sock: socket,
|
||||||
|
protocol: streams.StreamReaderProtocol,
|
||||||
|
waiter: futures.Future[Any] | None = None,
|
||||||
|
extra: Mapping[Any, Any] | None = None,
|
||||||
|
server: events.AbstractServer | None = None,
|
||||||
|
buffer_size: int = 65536,
|
||||||
|
) -> None: ...
|
||||||
|
else:
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
loop: events.AbstractEventLoop,
|
||||||
|
sock: socket,
|
||||||
|
protocol: streams.StreamReaderProtocol,
|
||||||
|
waiter: futures.Future[Any] | None = None,
|
||||||
|
extra: Mapping[Any, Any] | None = None,
|
||||||
|
server: events.AbstractServer | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.WriteTransport): ...
|
||||||
|
class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport): ...
|
||||||
|
class _ProactorDuplexPipeTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport): ...
|
||||||
|
|
||||||
|
class _ProactorSocketTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport):
|
||||||
|
_sendfile_compatible: ClassVar[constants._SendfileMode]
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
loop: events.AbstractEventLoop,
|
||||||
|
sock: socket,
|
||||||
|
protocol: streams.StreamReaderProtocol,
|
||||||
|
waiter: futures.Future[Any] | None = None,
|
||||||
|
extra: Mapping[Any, Any] | None = None,
|
||||||
|
server: events.AbstractServer | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
def _set_extra(self, sock: socket) -> None: ...
|
||||||
|
def can_write_eof(self) -> Literal[True]: ...
|
||||||
|
|
||||||
|
class BaseProactorEventLoop(base_events.BaseEventLoop):
|
||||||
|
def __init__(self, proactor: Any) -> None: ...
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
from _typeshed import ReadableBuffer
|
||||||
|
from asyncio import transports
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
__all__ = ("BaseProtocol", "Protocol", "DatagramProtocol", "SubprocessProtocol", "BufferedProtocol")
|
||||||
|
|
||||||
|
class BaseProtocol:
|
||||||
|
def connection_made(self, transport: transports.BaseTransport) -> None: ...
|
||||||
|
def connection_lost(self, exc: Exception | None) -> None: ...
|
||||||
|
def pause_writing(self) -> None: ...
|
||||||
|
def resume_writing(self) -> None: ...
|
||||||
|
|
||||||
|
class Protocol(BaseProtocol):
|
||||||
|
def data_received(self, data: bytes) -> None: ...
|
||||||
|
def eof_received(self) -> bool | None: ...
|
||||||
|
|
||||||
|
class BufferedProtocol(BaseProtocol):
|
||||||
|
def get_buffer(self, sizehint: int) -> ReadableBuffer: ...
|
||||||
|
def buffer_updated(self, nbytes: int) -> None: ...
|
||||||
|
def eof_received(self) -> bool | None: ...
|
||||||
|
|
||||||
|
class DatagramProtocol(BaseProtocol):
|
||||||
|
def connection_made(self, transport: transports.DatagramTransport) -> None: ... # type: ignore[override]
|
||||||
|
# addr can be a tuple[int, int] for some unusual protocols like socket.AF_NETLINK.
|
||||||
|
# Use tuple[str | Any, int] to not cause typechecking issues on most usual cases.
|
||||||
|
# This could be improved by using tuple[AnyOf[str, int], int] if the AnyOf feature is accepted.
|
||||||
|
# See https://github.com/python/typing/issues/566
|
||||||
|
def datagram_received(self, data: bytes, addr: tuple[str | Any, int]) -> None: ...
|
||||||
|
def error_received(self, exc: Exception) -> None: ...
|
||||||
|
|
||||||
|
class SubprocessProtocol(BaseProtocol):
|
||||||
|
def pipe_data_received(self, fd: int, data: bytes) -> None: ...
|
||||||
|
def pipe_connection_lost(self, fd: int, exc: Exception | None) -> None: ...
|
||||||
|
def process_exited(self) -> None: ...
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
import sys
|
||||||
|
from asyncio.events import AbstractEventLoop
|
||||||
|
from typing import Any, Generic, TypeVar
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
from types import GenericAlias
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
from .mixins import _LoopBoundMixin
|
||||||
|
else:
|
||||||
|
_LoopBoundMixin = object
|
||||||
|
|
||||||
|
__all__ = ("Queue", "PriorityQueue", "LifoQueue", "QueueFull", "QueueEmpty")
|
||||||
|
|
||||||
|
class QueueEmpty(Exception): ...
|
||||||
|
class QueueFull(Exception): ...
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
|
||||||
|
# If Generic[_T] is last and _LoopBoundMixin is object, pyright is unhappy.
|
||||||
|
# We can remove the noqa pragma when dropping 3.9 support.
|
||||||
|
class Queue(Generic[_T], _LoopBoundMixin): # noqa: Y059
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
def __init__(self, maxsize: int = 0) -> None: ...
|
||||||
|
else:
|
||||||
|
def __init__(self, maxsize: int = 0, *, loop: AbstractEventLoop | None = None) -> None: ...
|
||||||
|
|
||||||
|
def _init(self, maxsize: int) -> None: ...
|
||||||
|
def _get(self) -> _T: ...
|
||||||
|
def _put(self, item: _T) -> None: ...
|
||||||
|
def _format(self) -> str: ...
|
||||||
|
def qsize(self) -> int: ...
|
||||||
|
@property
|
||||||
|
def maxsize(self) -> int: ...
|
||||||
|
def empty(self) -> bool: ...
|
||||||
|
def full(self) -> bool: ...
|
||||||
|
async def put(self, item: _T) -> None: ...
|
||||||
|
def put_nowait(self, item: _T) -> None: ...
|
||||||
|
async def get(self) -> _T: ...
|
||||||
|
def get_nowait(self) -> _T: ...
|
||||||
|
async def join(self) -> None: ...
|
||||||
|
def task_done(self) -> None: ...
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
def __class_getitem__(cls, type: Any) -> GenericAlias: ...
|
||||||
|
|
||||||
|
class PriorityQueue(Queue[_T]): ...
|
||||||
|
class LifoQueue(Queue[_T]): ...
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
import sys
|
||||||
|
from _typeshed import Unused
|
||||||
|
from collections.abc import Callable, Coroutine
|
||||||
|
from contextvars import Context
|
||||||
|
from typing import Any, TypeVar, final
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
from .events import AbstractEventLoop
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
__all__ = ("Runner", "run")
|
||||||
|
else:
|
||||||
|
__all__ = ("run",)
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
@final
|
||||||
|
class Runner:
|
||||||
|
def __init__(self, *, debug: bool | None = None, loop_factory: Callable[[], AbstractEventLoop] | None = None) -> None: ...
|
||||||
|
def __enter__(self) -> Self: ...
|
||||||
|
def __exit__(self, exc_type: Unused, exc_val: Unused, exc_tb: Unused) -> None: ...
|
||||||
|
def close(self) -> None: ...
|
||||||
|
def get_loop(self) -> AbstractEventLoop: ...
|
||||||
|
def run(self, coro: Coroutine[Any, Any, _T], *, context: Context | None = None) -> _T: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
def run(
|
||||||
|
main: Coroutine[Any, Any, _T], *, debug: bool | None = ..., loop_factory: Callable[[], AbstractEventLoop] | None = ...
|
||||||
|
) -> _T: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
def run(main: Coroutine[Any, Any, _T], *, debug: bool | None = None) -> _T: ...
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
import selectors
|
||||||
|
|
||||||
|
from . import base_events
|
||||||
|
|
||||||
|
__all__ = ("BaseSelectorEventLoop",)
|
||||||
|
|
||||||
|
class BaseSelectorEventLoop(base_events.BaseEventLoop):
|
||||||
|
def __init__(self, selector: selectors.BaseSelector | None = None) -> None: ...
|
||||||
|
|
@ -0,0 +1,165 @@
|
||||||
|
import ssl
|
||||||
|
import sys
|
||||||
|
from collections import deque
|
||||||
|
from collections.abc import Callable
|
||||||
|
from enum import Enum
|
||||||
|
from typing import Any, ClassVar, Literal
|
||||||
|
from typing_extensions import TypeAlias
|
||||||
|
|
||||||
|
from . import constants, events, futures, protocols, transports
|
||||||
|
|
||||||
|
def _create_transport_context(server_side: bool, server_hostname: str | None) -> ssl.SSLContext: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
SSLAgainErrors: tuple[type[ssl.SSLWantReadError], type[ssl.SSLSyscallError]]
|
||||||
|
|
||||||
|
class SSLProtocolState(Enum):
|
||||||
|
UNWRAPPED = "UNWRAPPED"
|
||||||
|
DO_HANDSHAKE = "DO_HANDSHAKE"
|
||||||
|
WRAPPED = "WRAPPED"
|
||||||
|
FLUSHING = "FLUSHING"
|
||||||
|
SHUTDOWN = "SHUTDOWN"
|
||||||
|
|
||||||
|
class AppProtocolState(Enum):
|
||||||
|
STATE_INIT = "STATE_INIT"
|
||||||
|
STATE_CON_MADE = "STATE_CON_MADE"
|
||||||
|
STATE_EOF = "STATE_EOF"
|
||||||
|
STATE_CON_LOST = "STATE_CON_LOST"
|
||||||
|
|
||||||
|
def add_flowcontrol_defaults(high: int | None, low: int | None, kb: int) -> tuple[int, int]: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
_UNWRAPPED: Literal["UNWRAPPED"]
|
||||||
|
_DO_HANDSHAKE: Literal["DO_HANDSHAKE"]
|
||||||
|
_WRAPPED: Literal["WRAPPED"]
|
||||||
|
_SHUTDOWN: Literal["SHUTDOWN"]
|
||||||
|
|
||||||
|
if sys.version_info < (3, 11):
|
||||||
|
class _SSLPipe:
|
||||||
|
max_size: ClassVar[int]
|
||||||
|
|
||||||
|
_context: ssl.SSLContext
|
||||||
|
_server_side: bool
|
||||||
|
_server_hostname: str | None
|
||||||
|
_state: str
|
||||||
|
_incoming: ssl.MemoryBIO
|
||||||
|
_outgoing: ssl.MemoryBIO
|
||||||
|
_sslobj: ssl.SSLObject | None
|
||||||
|
_need_ssldata: bool
|
||||||
|
_handshake_cb: Callable[[BaseException | None], None] | None
|
||||||
|
_shutdown_cb: Callable[[], None] | None
|
||||||
|
def __init__(self, context: ssl.SSLContext, server_side: bool, server_hostname: str | None = None) -> None: ...
|
||||||
|
@property
|
||||||
|
def context(self) -> ssl.SSLContext: ...
|
||||||
|
@property
|
||||||
|
def ssl_object(self) -> ssl.SSLObject | None: ...
|
||||||
|
@property
|
||||||
|
def need_ssldata(self) -> bool: ...
|
||||||
|
@property
|
||||||
|
def wrapped(self) -> bool: ...
|
||||||
|
def do_handshake(self, callback: Callable[[BaseException | None], object] | None = None) -> list[bytes]: ...
|
||||||
|
def shutdown(self, callback: Callable[[], object] | None = None) -> list[bytes]: ...
|
||||||
|
def feed_eof(self) -> None: ...
|
||||||
|
def feed_ssldata(self, data: bytes, only_handshake: bool = False) -> tuple[list[bytes], list[bytes]]: ...
|
||||||
|
def feed_appdata(self, data: bytes, offset: int = 0) -> tuple[list[bytes], int]: ...
|
||||||
|
|
||||||
|
class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport):
|
||||||
|
_sendfile_compatible: ClassVar[constants._SendfileMode]
|
||||||
|
|
||||||
|
_loop: events.AbstractEventLoop
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
_ssl_protocol: SSLProtocol | None
|
||||||
|
else:
|
||||||
|
_ssl_protocol: SSLProtocol
|
||||||
|
_closed: bool
|
||||||
|
def __init__(self, loop: events.AbstractEventLoop, ssl_protocol: SSLProtocol) -> None: ...
|
||||||
|
def get_extra_info(self, name: str, default: Any | None = None) -> dict[str, Any]: ...
|
||||||
|
@property
|
||||||
|
def _protocol_paused(self) -> bool: ...
|
||||||
|
def write(self, data: bytes | bytearray | memoryview) -> None: ...
|
||||||
|
def can_write_eof(self) -> Literal[False]: ...
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
def get_write_buffer_limits(self) -> tuple[int, int]: ...
|
||||||
|
def get_read_buffer_limits(self) -> tuple[int, int]: ...
|
||||||
|
def set_read_buffer_limits(self, high: int | None = None, low: int | None = None) -> None: ...
|
||||||
|
def get_read_buffer_size(self) -> int: ...
|
||||||
|
|
||||||
|
def __del__(self) -> None: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
_SSLProtocolBase: TypeAlias = protocols.BufferedProtocol
|
||||||
|
else:
|
||||||
|
_SSLProtocolBase: TypeAlias = protocols.Protocol
|
||||||
|
|
||||||
|
class SSLProtocol(_SSLProtocolBase):
|
||||||
|
_server_side: bool
|
||||||
|
_server_hostname: str | None
|
||||||
|
_sslcontext: ssl.SSLContext
|
||||||
|
_extra: dict[str, Any]
|
||||||
|
_write_backlog: deque[tuple[bytes, int]]
|
||||||
|
_write_buffer_size: int
|
||||||
|
_waiter: futures.Future[Any]
|
||||||
|
_loop: events.AbstractEventLoop
|
||||||
|
_app_transport: _SSLProtocolTransport
|
||||||
|
_transport: transports.BaseTransport | None
|
||||||
|
_ssl_handshake_timeout: int | None
|
||||||
|
_app_protocol: protocols.BaseProtocol
|
||||||
|
_app_protocol_is_buffer: bool
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
max_size: ClassVar[int]
|
||||||
|
else:
|
||||||
|
_sslpipe: _SSLPipe | None
|
||||||
|
_session_established: bool
|
||||||
|
_call_connection_made: bool
|
||||||
|
_in_handshake: bool
|
||||||
|
_in_shutdown: bool
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
loop: events.AbstractEventLoop,
|
||||||
|
app_protocol: protocols.BaseProtocol,
|
||||||
|
sslcontext: ssl.SSLContext,
|
||||||
|
waiter: futures.Future[Any],
|
||||||
|
server_side: bool = False,
|
||||||
|
server_hostname: str | None = None,
|
||||||
|
call_connection_made: bool = True,
|
||||||
|
ssl_handshake_timeout: int | None = None,
|
||||||
|
ssl_shutdown_timeout: float | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
else:
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
loop: events.AbstractEventLoop,
|
||||||
|
app_protocol: protocols.BaseProtocol,
|
||||||
|
sslcontext: ssl.SSLContext,
|
||||||
|
waiter: futures.Future[Any],
|
||||||
|
server_side: bool = False,
|
||||||
|
server_hostname: str | None = None,
|
||||||
|
call_connection_made: bool = True,
|
||||||
|
ssl_handshake_timeout: int | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
def _set_app_protocol(self, app_protocol: protocols.BaseProtocol) -> None: ...
|
||||||
|
def _wakeup_waiter(self, exc: BaseException | None = None) -> None: ...
|
||||||
|
def connection_lost(self, exc: BaseException | None) -> None: ...
|
||||||
|
def eof_received(self) -> None: ...
|
||||||
|
def _get_extra_info(self, name: str, default: Any | None = None) -> Any: ...
|
||||||
|
def _start_shutdown(self) -> None: ...
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
def _write_appdata(self, list_of_data: list[bytes]) -> None: ...
|
||||||
|
else:
|
||||||
|
def _write_appdata(self, data: bytes) -> None: ...
|
||||||
|
|
||||||
|
def _start_handshake(self) -> None: ...
|
||||||
|
def _check_handshake_timeout(self) -> None: ...
|
||||||
|
def _on_handshake_complete(self, handshake_exc: BaseException | None) -> None: ...
|
||||||
|
def _fatal_error(self, exc: BaseException, message: str = "Fatal error on transport") -> None: ...
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
def _abort(self, exc: BaseException | None) -> None: ...
|
||||||
|
def get_buffer(self, n: int) -> memoryview: ...
|
||||||
|
else:
|
||||||
|
def _abort(self) -> None: ...
|
||||||
|
def _finalize(self) -> None: ...
|
||||||
|
def _process_write_backlog(self) -> None: ...
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
from collections.abc import Awaitable, Callable, Iterable
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from . import events
|
||||||
|
|
||||||
|
__all__ = ("staggered_race",)
|
||||||
|
|
||||||
|
async def staggered_race(
|
||||||
|
coro_fns: Iterable[Callable[[], Awaitable[Any]]], delay: float | None, *, loop: events.AbstractEventLoop | None = None
|
||||||
|
) -> tuple[Any, int | None, list[Exception | None]]: ...
|
||||||
|
|
@ -0,0 +1,153 @@
|
||||||
|
import ssl
|
||||||
|
import sys
|
||||||
|
from _typeshed import ReadableBuffer, StrPath
|
||||||
|
from collections.abc import AsyncIterator, Awaitable, Callable, Iterable, Sequence, Sized
|
||||||
|
from typing import Any, Protocol, SupportsIndex
|
||||||
|
from typing_extensions import Self, TypeAlias
|
||||||
|
|
||||||
|
from . import events, protocols, transports
|
||||||
|
from .base_events import Server
|
||||||
|
|
||||||
|
if sys.platform == "win32":
|
||||||
|
__all__ = ("StreamReader", "StreamWriter", "StreamReaderProtocol", "open_connection", "start_server")
|
||||||
|
else:
|
||||||
|
__all__ = (
|
||||||
|
"StreamReader",
|
||||||
|
"StreamWriter",
|
||||||
|
"StreamReaderProtocol",
|
||||||
|
"open_connection",
|
||||||
|
"start_server",
|
||||||
|
"open_unix_connection",
|
||||||
|
"start_unix_server",
|
||||||
|
)
|
||||||
|
|
||||||
|
_ClientConnectedCallback: TypeAlias = Callable[[StreamReader, StreamWriter], Awaitable[None] | None]
|
||||||
|
|
||||||
|
class _ReaduntilBuffer(ReadableBuffer, Sized, Protocol): ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
async def open_connection(
|
||||||
|
host: str | None = None,
|
||||||
|
port: int | str | None = None,
|
||||||
|
*,
|
||||||
|
limit: int = 65536,
|
||||||
|
ssl_handshake_timeout: float | None = ...,
|
||||||
|
**kwds: Any,
|
||||||
|
) -> tuple[StreamReader, StreamWriter]: ...
|
||||||
|
async def start_server(
|
||||||
|
client_connected_cb: _ClientConnectedCallback,
|
||||||
|
host: str | Sequence[str] | None = None,
|
||||||
|
port: int | str | None = None,
|
||||||
|
*,
|
||||||
|
limit: int = 65536,
|
||||||
|
ssl_handshake_timeout: float | None = ...,
|
||||||
|
**kwds: Any,
|
||||||
|
) -> Server: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
async def open_connection(
|
||||||
|
host: str | None = None,
|
||||||
|
port: int | str | None = None,
|
||||||
|
*,
|
||||||
|
loop: events.AbstractEventLoop | None = None,
|
||||||
|
limit: int = 65536,
|
||||||
|
ssl_handshake_timeout: float | None = ...,
|
||||||
|
**kwds: Any,
|
||||||
|
) -> tuple[StreamReader, StreamWriter]: ...
|
||||||
|
async def start_server(
|
||||||
|
client_connected_cb: _ClientConnectedCallback,
|
||||||
|
host: str | None = None,
|
||||||
|
port: int | str | None = None,
|
||||||
|
*,
|
||||||
|
loop: events.AbstractEventLoop | None = None,
|
||||||
|
limit: int = 65536,
|
||||||
|
ssl_handshake_timeout: float | None = ...,
|
||||||
|
**kwds: Any,
|
||||||
|
) -> Server: ...
|
||||||
|
|
||||||
|
if sys.platform != "win32":
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
async def open_unix_connection(
|
||||||
|
path: StrPath | None = None, *, limit: int = 65536, **kwds: Any
|
||||||
|
) -> tuple[StreamReader, StreamWriter]: ...
|
||||||
|
async def start_unix_server(
|
||||||
|
client_connected_cb: _ClientConnectedCallback, path: StrPath | None = None, *, limit: int = 65536, **kwds: Any
|
||||||
|
) -> Server: ...
|
||||||
|
else:
|
||||||
|
async def open_unix_connection(
|
||||||
|
path: StrPath | None = None, *, loop: events.AbstractEventLoop | None = None, limit: int = 65536, **kwds: Any
|
||||||
|
) -> tuple[StreamReader, StreamWriter]: ...
|
||||||
|
async def start_unix_server(
|
||||||
|
client_connected_cb: _ClientConnectedCallback,
|
||||||
|
path: StrPath | None = None,
|
||||||
|
*,
|
||||||
|
loop: events.AbstractEventLoop | None = None,
|
||||||
|
limit: int = 65536,
|
||||||
|
**kwds: Any,
|
||||||
|
) -> Server: ...
|
||||||
|
|
||||||
|
class FlowControlMixin(protocols.Protocol):
|
||||||
|
def __init__(self, loop: events.AbstractEventLoop | None = None) -> None: ...
|
||||||
|
|
||||||
|
class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
stream_reader: StreamReader,
|
||||||
|
client_connected_cb: _ClientConnectedCallback | None = None,
|
||||||
|
loop: events.AbstractEventLoop | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
def __del__(self) -> None: ...
|
||||||
|
|
||||||
|
class StreamWriter:
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
transport: transports.WriteTransport,
|
||||||
|
protocol: protocols.BaseProtocol,
|
||||||
|
reader: StreamReader | None,
|
||||||
|
loop: events.AbstractEventLoop,
|
||||||
|
) -> None: ...
|
||||||
|
@property
|
||||||
|
def transport(self) -> transports.WriteTransport: ...
|
||||||
|
def write(self, data: bytes | bytearray | memoryview) -> None: ...
|
||||||
|
def writelines(self, data: Iterable[bytes | bytearray | memoryview]) -> None: ...
|
||||||
|
def write_eof(self) -> None: ...
|
||||||
|
def can_write_eof(self) -> bool: ...
|
||||||
|
def close(self) -> None: ...
|
||||||
|
def is_closing(self) -> bool: ...
|
||||||
|
async def wait_closed(self) -> None: ...
|
||||||
|
def get_extra_info(self, name: str, default: Any = None) -> Any: ...
|
||||||
|
async def drain(self) -> None: ...
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
async def start_tls(
|
||||||
|
self,
|
||||||
|
sslcontext: ssl.SSLContext,
|
||||||
|
*,
|
||||||
|
server_hostname: str | None = None,
|
||||||
|
ssl_handshake_timeout: float | None = None,
|
||||||
|
ssl_shutdown_timeout: float | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
elif sys.version_info >= (3, 11):
|
||||||
|
async def start_tls(
|
||||||
|
self, sslcontext: ssl.SSLContext, *, server_hostname: str | None = None, ssl_handshake_timeout: float | None = None
|
||||||
|
) -> None: ...
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
def __del__(self) -> None: ...
|
||||||
|
|
||||||
|
class StreamReader(AsyncIterator[bytes]):
|
||||||
|
def __init__(self, limit: int = 65536, loop: events.AbstractEventLoop | None = None) -> None: ...
|
||||||
|
def exception(self) -> Exception: ...
|
||||||
|
def set_exception(self, exc: Exception) -> None: ...
|
||||||
|
def set_transport(self, transport: transports.BaseTransport) -> None: ...
|
||||||
|
def feed_eof(self) -> None: ...
|
||||||
|
def at_eof(self) -> bool: ...
|
||||||
|
def feed_data(self, data: Iterable[SupportsIndex]) -> None: ...
|
||||||
|
async def readline(self) -> bytes: ...
|
||||||
|
if sys.version_info >= (3, 13):
|
||||||
|
async def readuntil(self, separator: _ReaduntilBuffer | tuple[_ReaduntilBuffer, ...] = b"\n") -> bytes: ...
|
||||||
|
else:
|
||||||
|
async def readuntil(self, separator: _ReaduntilBuffer = b"\n") -> bytes: ...
|
||||||
|
|
||||||
|
async def read(self, n: int = -1) -> bytes: ...
|
||||||
|
async def readexactly(self, n: int) -> bytes: ...
|
||||||
|
def __aiter__(self) -> Self: ...
|
||||||
|
async def __anext__(self) -> bytes: ...
|
||||||
|
|
@ -0,0 +1,229 @@
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from _typeshed import StrOrBytesPath
|
||||||
|
from asyncio import events, protocols, streams, transports
|
||||||
|
from collections.abc import Callable, Collection
|
||||||
|
from typing import IO, Any, Literal
|
||||||
|
|
||||||
|
__all__ = ("create_subprocess_exec", "create_subprocess_shell")
|
||||||
|
|
||||||
|
PIPE: int
|
||||||
|
STDOUT: int
|
||||||
|
DEVNULL: int
|
||||||
|
|
||||||
|
class SubprocessStreamProtocol(streams.FlowControlMixin, protocols.SubprocessProtocol):
|
||||||
|
stdin: streams.StreamWriter | None
|
||||||
|
stdout: streams.StreamReader | None
|
||||||
|
stderr: streams.StreamReader | None
|
||||||
|
def __init__(self, limit: int, loop: events.AbstractEventLoop) -> None: ...
|
||||||
|
def pipe_data_received(self, fd: int, data: bytes | str) -> None: ...
|
||||||
|
|
||||||
|
class Process:
|
||||||
|
stdin: streams.StreamWriter | None
|
||||||
|
stdout: streams.StreamReader | None
|
||||||
|
stderr: streams.StreamReader | None
|
||||||
|
pid: int
|
||||||
|
def __init__(
|
||||||
|
self, transport: transports.BaseTransport, protocol: protocols.BaseProtocol, loop: events.AbstractEventLoop
|
||||||
|
) -> None: ...
|
||||||
|
@property
|
||||||
|
def returncode(self) -> int | None: ...
|
||||||
|
async def wait(self) -> int: ...
|
||||||
|
def send_signal(self, signal: int) -> None: ...
|
||||||
|
def terminate(self) -> None: ...
|
||||||
|
def kill(self) -> None: ...
|
||||||
|
async def communicate(self, input: bytes | bytearray | memoryview | None = None) -> tuple[bytes, bytes]: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
async def create_subprocess_shell(
|
||||||
|
cmd: str | bytes,
|
||||||
|
stdin: int | IO[Any] | None = None,
|
||||||
|
stdout: int | IO[Any] | None = None,
|
||||||
|
stderr: int | IO[Any] | None = None,
|
||||||
|
limit: int = 65536,
|
||||||
|
*,
|
||||||
|
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
|
||||||
|
universal_newlines: Literal[False] = False,
|
||||||
|
shell: Literal[True] = True,
|
||||||
|
bufsize: Literal[0] = 0,
|
||||||
|
encoding: None = None,
|
||||||
|
errors: None = None,
|
||||||
|
text: Literal[False] | None = None,
|
||||||
|
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
|
||||||
|
executable: StrOrBytesPath | None = None,
|
||||||
|
preexec_fn: Callable[[], Any] | None = None,
|
||||||
|
close_fds: bool = True,
|
||||||
|
cwd: StrOrBytesPath | None = None,
|
||||||
|
env: subprocess._ENV | None = None,
|
||||||
|
startupinfo: Any | None = None,
|
||||||
|
creationflags: int = 0,
|
||||||
|
restore_signals: bool = True,
|
||||||
|
start_new_session: bool = False,
|
||||||
|
pass_fds: Collection[int] = ...,
|
||||||
|
group: None | str | int = None,
|
||||||
|
extra_groups: None | Collection[str | int] = None,
|
||||||
|
user: None | str | int = None,
|
||||||
|
umask: int = -1,
|
||||||
|
process_group: int | None = None,
|
||||||
|
pipesize: int = -1,
|
||||||
|
) -> Process: ...
|
||||||
|
async def create_subprocess_exec(
|
||||||
|
program: StrOrBytesPath,
|
||||||
|
*args: StrOrBytesPath,
|
||||||
|
stdin: int | IO[Any] | None = None,
|
||||||
|
stdout: int | IO[Any] | None = None,
|
||||||
|
stderr: int | IO[Any] | None = None,
|
||||||
|
limit: int = 65536,
|
||||||
|
# These parameters are forced to these values by BaseEventLoop.subprocess_exec
|
||||||
|
universal_newlines: Literal[False] = False,
|
||||||
|
shell: Literal[False] = False,
|
||||||
|
bufsize: Literal[0] = 0,
|
||||||
|
encoding: None = None,
|
||||||
|
errors: None = None,
|
||||||
|
text: Literal[False] | None = None,
|
||||||
|
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
|
||||||
|
executable: StrOrBytesPath | None = None,
|
||||||
|
preexec_fn: Callable[[], Any] | None = None,
|
||||||
|
close_fds: bool = True,
|
||||||
|
cwd: StrOrBytesPath | None = None,
|
||||||
|
env: subprocess._ENV | None = None,
|
||||||
|
startupinfo: Any | None = None,
|
||||||
|
creationflags: int = 0,
|
||||||
|
restore_signals: bool = True,
|
||||||
|
start_new_session: bool = False,
|
||||||
|
pass_fds: Collection[int] = ...,
|
||||||
|
group: None | str | int = None,
|
||||||
|
extra_groups: None | Collection[str | int] = None,
|
||||||
|
user: None | str | int = None,
|
||||||
|
umask: int = -1,
|
||||||
|
process_group: int | None = None,
|
||||||
|
pipesize: int = -1,
|
||||||
|
) -> Process: ...
|
||||||
|
|
||||||
|
elif sys.version_info >= (3, 10):
|
||||||
|
async def create_subprocess_shell(
|
||||||
|
cmd: str | bytes,
|
||||||
|
stdin: int | IO[Any] | None = None,
|
||||||
|
stdout: int | IO[Any] | None = None,
|
||||||
|
stderr: int | IO[Any] | None = None,
|
||||||
|
limit: int = 65536,
|
||||||
|
*,
|
||||||
|
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
|
||||||
|
universal_newlines: Literal[False] = False,
|
||||||
|
shell: Literal[True] = True,
|
||||||
|
bufsize: Literal[0] = 0,
|
||||||
|
encoding: None = None,
|
||||||
|
errors: None = None,
|
||||||
|
text: Literal[False] | None = None,
|
||||||
|
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
|
||||||
|
executable: StrOrBytesPath | None = None,
|
||||||
|
preexec_fn: Callable[[], Any] | None = None,
|
||||||
|
close_fds: bool = True,
|
||||||
|
cwd: StrOrBytesPath | None = None,
|
||||||
|
env: subprocess._ENV | None = None,
|
||||||
|
startupinfo: Any | None = None,
|
||||||
|
creationflags: int = 0,
|
||||||
|
restore_signals: bool = True,
|
||||||
|
start_new_session: bool = False,
|
||||||
|
pass_fds: Collection[int] = ...,
|
||||||
|
group: None | str | int = None,
|
||||||
|
extra_groups: None | Collection[str | int] = None,
|
||||||
|
user: None | str | int = None,
|
||||||
|
umask: int = -1,
|
||||||
|
pipesize: int = -1,
|
||||||
|
) -> Process: ...
|
||||||
|
async def create_subprocess_exec(
|
||||||
|
program: StrOrBytesPath,
|
||||||
|
*args: StrOrBytesPath,
|
||||||
|
stdin: int | IO[Any] | None = None,
|
||||||
|
stdout: int | IO[Any] | None = None,
|
||||||
|
stderr: int | IO[Any] | None = None,
|
||||||
|
limit: int = 65536,
|
||||||
|
# These parameters are forced to these values by BaseEventLoop.subprocess_exec
|
||||||
|
universal_newlines: Literal[False] = False,
|
||||||
|
shell: Literal[False] = False,
|
||||||
|
bufsize: Literal[0] = 0,
|
||||||
|
encoding: None = None,
|
||||||
|
errors: None = None,
|
||||||
|
text: Literal[False] | None = None,
|
||||||
|
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
|
||||||
|
executable: StrOrBytesPath | None = None,
|
||||||
|
preexec_fn: Callable[[], Any] | None = None,
|
||||||
|
close_fds: bool = True,
|
||||||
|
cwd: StrOrBytesPath | None = None,
|
||||||
|
env: subprocess._ENV | None = None,
|
||||||
|
startupinfo: Any | None = None,
|
||||||
|
creationflags: int = 0,
|
||||||
|
restore_signals: bool = True,
|
||||||
|
start_new_session: bool = False,
|
||||||
|
pass_fds: Collection[int] = ...,
|
||||||
|
group: None | str | int = None,
|
||||||
|
extra_groups: None | Collection[str | int] = None,
|
||||||
|
user: None | str | int = None,
|
||||||
|
umask: int = -1,
|
||||||
|
pipesize: int = -1,
|
||||||
|
) -> Process: ...
|
||||||
|
|
||||||
|
else: # >= 3.9
|
||||||
|
async def create_subprocess_shell(
|
||||||
|
cmd: str | bytes,
|
||||||
|
stdin: int | IO[Any] | None = None,
|
||||||
|
stdout: int | IO[Any] | None = None,
|
||||||
|
stderr: int | IO[Any] | None = None,
|
||||||
|
loop: events.AbstractEventLoop | None = None,
|
||||||
|
limit: int = 65536,
|
||||||
|
*,
|
||||||
|
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
|
||||||
|
universal_newlines: Literal[False] = False,
|
||||||
|
shell: Literal[True] = True,
|
||||||
|
bufsize: Literal[0] = 0,
|
||||||
|
encoding: None = None,
|
||||||
|
errors: None = None,
|
||||||
|
text: Literal[False] | None = None,
|
||||||
|
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
|
||||||
|
executable: StrOrBytesPath | None = None,
|
||||||
|
preexec_fn: Callable[[], Any] | None = None,
|
||||||
|
close_fds: bool = True,
|
||||||
|
cwd: StrOrBytesPath | None = None,
|
||||||
|
env: subprocess._ENV | None = None,
|
||||||
|
startupinfo: Any | None = None,
|
||||||
|
creationflags: int = 0,
|
||||||
|
restore_signals: bool = True,
|
||||||
|
start_new_session: bool = False,
|
||||||
|
pass_fds: Collection[int] = ...,
|
||||||
|
group: None | str | int = None,
|
||||||
|
extra_groups: None | Collection[str | int] = None,
|
||||||
|
user: None | str | int = None,
|
||||||
|
umask: int = -1,
|
||||||
|
) -> Process: ...
|
||||||
|
async def create_subprocess_exec(
|
||||||
|
program: StrOrBytesPath,
|
||||||
|
*args: StrOrBytesPath,
|
||||||
|
stdin: int | IO[Any] | None = None,
|
||||||
|
stdout: int | IO[Any] | None = None,
|
||||||
|
stderr: int | IO[Any] | None = None,
|
||||||
|
loop: events.AbstractEventLoop | None = None,
|
||||||
|
limit: int = 65536,
|
||||||
|
# These parameters are forced to these values by BaseEventLoop.subprocess_exec
|
||||||
|
universal_newlines: Literal[False] = False,
|
||||||
|
shell: Literal[False] = False,
|
||||||
|
bufsize: Literal[0] = 0,
|
||||||
|
encoding: None = None,
|
||||||
|
errors: None = None,
|
||||||
|
text: Literal[False] | None = None,
|
||||||
|
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
|
||||||
|
executable: StrOrBytesPath | None = None,
|
||||||
|
preexec_fn: Callable[[], Any] | None = None,
|
||||||
|
close_fds: bool = True,
|
||||||
|
cwd: StrOrBytesPath | None = None,
|
||||||
|
env: subprocess._ENV | None = None,
|
||||||
|
startupinfo: Any | None = None,
|
||||||
|
creationflags: int = 0,
|
||||||
|
restore_signals: bool = True,
|
||||||
|
start_new_session: bool = False,
|
||||||
|
pass_fds: Collection[int] = ...,
|
||||||
|
group: None | str | int = None,
|
||||||
|
extra_groups: None | Collection[str | int] = None,
|
||||||
|
user: None | str | int = None,
|
||||||
|
umask: int = -1,
|
||||||
|
) -> Process: ...
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
import sys
|
||||||
|
from contextvars import Context
|
||||||
|
from types import TracebackType
|
||||||
|
from typing import Any, TypeVar
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
from . import _CoroutineLike
|
||||||
|
from .events import AbstractEventLoop
|
||||||
|
from .tasks import Task
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
__all__ = ("TaskGroup",)
|
||||||
|
else:
|
||||||
|
__all__ = ["TaskGroup"]
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
|
||||||
|
class TaskGroup:
|
||||||
|
_loop: AbstractEventLoop | None
|
||||||
|
_tasks: set[Task[Any]]
|
||||||
|
|
||||||
|
async def __aenter__(self) -> Self: ...
|
||||||
|
async def __aexit__(self, et: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None) -> None: ...
|
||||||
|
def create_task(self, coro: _CoroutineLike[_T], *, name: str | None = None, context: Context | None = None) -> Task[_T]: ...
|
||||||
|
def _on_task_done(self, task: Task[object]) -> None: ...
|
||||||
|
|
@ -0,0 +1,497 @@
|
||||||
|
import concurrent.futures
|
||||||
|
import sys
|
||||||
|
from collections.abc import Awaitable, Coroutine, Generator, Iterable, Iterator
|
||||||
|
from types import FrameType
|
||||||
|
from typing import Any, Literal, Protocol, TextIO, TypeVar, overload
|
||||||
|
from typing_extensions import TypeAlias
|
||||||
|
|
||||||
|
from . import _CoroutineLike
|
||||||
|
from .events import AbstractEventLoop
|
||||||
|
from .futures import Future
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
from types import GenericAlias
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
from contextvars import Context
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
__all__ = (
|
||||||
|
"Task",
|
||||||
|
"create_task",
|
||||||
|
"FIRST_COMPLETED",
|
||||||
|
"FIRST_EXCEPTION",
|
||||||
|
"ALL_COMPLETED",
|
||||||
|
"wait",
|
||||||
|
"wait_for",
|
||||||
|
"as_completed",
|
||||||
|
"sleep",
|
||||||
|
"gather",
|
||||||
|
"shield",
|
||||||
|
"ensure_future",
|
||||||
|
"run_coroutine_threadsafe",
|
||||||
|
"current_task",
|
||||||
|
"all_tasks",
|
||||||
|
"create_eager_task_factory",
|
||||||
|
"eager_task_factory",
|
||||||
|
"_register_task",
|
||||||
|
"_unregister_task",
|
||||||
|
"_enter_task",
|
||||||
|
"_leave_task",
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
__all__ = (
|
||||||
|
"Task",
|
||||||
|
"create_task",
|
||||||
|
"FIRST_COMPLETED",
|
||||||
|
"FIRST_EXCEPTION",
|
||||||
|
"ALL_COMPLETED",
|
||||||
|
"wait",
|
||||||
|
"wait_for",
|
||||||
|
"as_completed",
|
||||||
|
"sleep",
|
||||||
|
"gather",
|
||||||
|
"shield",
|
||||||
|
"ensure_future",
|
||||||
|
"run_coroutine_threadsafe",
|
||||||
|
"current_task",
|
||||||
|
"all_tasks",
|
||||||
|
"_register_task",
|
||||||
|
"_unregister_task",
|
||||||
|
"_enter_task",
|
||||||
|
"_leave_task",
|
||||||
|
)
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
_T_co = TypeVar("_T_co", covariant=True)
|
||||||
|
_T1 = TypeVar("_T1")
|
||||||
|
_T2 = TypeVar("_T2")
|
||||||
|
_T3 = TypeVar("_T3")
|
||||||
|
_T4 = TypeVar("_T4")
|
||||||
|
_T5 = TypeVar("_T5")
|
||||||
|
_T6 = TypeVar("_T6")
|
||||||
|
_FT = TypeVar("_FT", bound=Future[Any])
|
||||||
|
_FutureLike: TypeAlias = Future[_T] | Generator[Any, None, _T] | Awaitable[_T]
|
||||||
|
_TaskYieldType: TypeAlias = Future[object] | None
|
||||||
|
|
||||||
|
FIRST_COMPLETED = concurrent.futures.FIRST_COMPLETED
|
||||||
|
FIRST_EXCEPTION = concurrent.futures.FIRST_EXCEPTION
|
||||||
|
ALL_COMPLETED = concurrent.futures.ALL_COMPLETED
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> Iterator[Future[_T]]: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
def as_completed(
|
||||||
|
fs: Iterable[_FutureLike[_T]], *, loop: AbstractEventLoop | None = None, timeout: float | None = None
|
||||||
|
) -> Iterator[Future[_T]]: ...
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def ensure_future(coro_or_future: _FT, *, loop: AbstractEventLoop | None = None) -> _FT: ... # type: ignore[overload-overlap]
|
||||||
|
@overload
|
||||||
|
def ensure_future(coro_or_future: Awaitable[_T], *, loop: AbstractEventLoop | None = None) -> Task[_T]: ...
|
||||||
|
|
||||||
|
# `gather()` actually returns a list with length equal to the number
|
||||||
|
# of tasks passed; however, Tuple is used similar to the annotation for
|
||||||
|
# zip() because typing does not support variadic type variables. See
|
||||||
|
# typing PR #1550 for discussion.
|
||||||
|
#
|
||||||
|
# N.B. Having overlapping overloads is the only way to get acceptable type inference in all edge cases.
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
@overload
|
||||||
|
def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: Literal[False] = False) -> Future[tuple[_T1]]: ... # type: ignore[overload-overlap]
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: Literal[False] = False
|
||||||
|
) -> Future[tuple[_T1, _T2]]: ...
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1],
|
||||||
|
coro_or_future2: _FutureLike[_T2],
|
||||||
|
coro_or_future3: _FutureLike[_T3],
|
||||||
|
/,
|
||||||
|
*,
|
||||||
|
return_exceptions: Literal[False] = False,
|
||||||
|
) -> Future[tuple[_T1, _T2, _T3]]: ...
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1],
|
||||||
|
coro_or_future2: _FutureLike[_T2],
|
||||||
|
coro_or_future3: _FutureLike[_T3],
|
||||||
|
coro_or_future4: _FutureLike[_T4],
|
||||||
|
/,
|
||||||
|
*,
|
||||||
|
return_exceptions: Literal[False] = False,
|
||||||
|
) -> Future[tuple[_T1, _T2, _T3, _T4]]: ...
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1],
|
||||||
|
coro_or_future2: _FutureLike[_T2],
|
||||||
|
coro_or_future3: _FutureLike[_T3],
|
||||||
|
coro_or_future4: _FutureLike[_T4],
|
||||||
|
coro_or_future5: _FutureLike[_T5],
|
||||||
|
/,
|
||||||
|
*,
|
||||||
|
return_exceptions: Literal[False] = False,
|
||||||
|
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ...
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1],
|
||||||
|
coro_or_future2: _FutureLike[_T2],
|
||||||
|
coro_or_future3: _FutureLike[_T3],
|
||||||
|
coro_or_future4: _FutureLike[_T4],
|
||||||
|
coro_or_future5: _FutureLike[_T5],
|
||||||
|
coro_or_future6: _FutureLike[_T6],
|
||||||
|
/,
|
||||||
|
*,
|
||||||
|
return_exceptions: Literal[False] = False,
|
||||||
|
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ...
|
||||||
|
@overload
|
||||||
|
def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: Literal[False] = False) -> Future[list[_T]]: ... # type: ignore[overload-overlap]
|
||||||
|
@overload
|
||||||
|
def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ... # type: ignore[overload-overlap]
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: bool
|
||||||
|
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ...
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1],
|
||||||
|
coro_or_future2: _FutureLike[_T2],
|
||||||
|
coro_or_future3: _FutureLike[_T3],
|
||||||
|
/,
|
||||||
|
*,
|
||||||
|
return_exceptions: bool,
|
||||||
|
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ...
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1],
|
||||||
|
coro_or_future2: _FutureLike[_T2],
|
||||||
|
coro_or_future3: _FutureLike[_T3],
|
||||||
|
coro_or_future4: _FutureLike[_T4],
|
||||||
|
/,
|
||||||
|
*,
|
||||||
|
return_exceptions: bool,
|
||||||
|
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ...
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1],
|
||||||
|
coro_or_future2: _FutureLike[_T2],
|
||||||
|
coro_or_future3: _FutureLike[_T3],
|
||||||
|
coro_or_future4: _FutureLike[_T4],
|
||||||
|
coro_or_future5: _FutureLike[_T5],
|
||||||
|
/,
|
||||||
|
*,
|
||||||
|
return_exceptions: bool,
|
||||||
|
) -> Future[
|
||||||
|
tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]
|
||||||
|
]: ...
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1],
|
||||||
|
coro_or_future2: _FutureLike[_T2],
|
||||||
|
coro_or_future3: _FutureLike[_T3],
|
||||||
|
coro_or_future4: _FutureLike[_T4],
|
||||||
|
coro_or_future5: _FutureLike[_T5],
|
||||||
|
coro_or_future6: _FutureLike[_T6],
|
||||||
|
/,
|
||||||
|
*,
|
||||||
|
return_exceptions: bool,
|
||||||
|
) -> Future[
|
||||||
|
tuple[
|
||||||
|
_T1 | BaseException,
|
||||||
|
_T2 | BaseException,
|
||||||
|
_T3 | BaseException,
|
||||||
|
_T4 | BaseException,
|
||||||
|
_T5 | BaseException,
|
||||||
|
_T6 | BaseException,
|
||||||
|
]
|
||||||
|
]: ...
|
||||||
|
@overload
|
||||||
|
def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: bool) -> Future[list[_T | BaseException]]: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1], /, *, loop: AbstractEventLoop | None = None, return_exceptions: Literal[False] = False
|
||||||
|
) -> Future[tuple[_T1]]: ...
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1],
|
||||||
|
coro_or_future2: _FutureLike[_T2],
|
||||||
|
/,
|
||||||
|
*,
|
||||||
|
loop: AbstractEventLoop | None = None,
|
||||||
|
return_exceptions: Literal[False] = False,
|
||||||
|
) -> Future[tuple[_T1, _T2]]: ...
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1],
|
||||||
|
coro_or_future2: _FutureLike[_T2],
|
||||||
|
coro_or_future3: _FutureLike[_T3],
|
||||||
|
/,
|
||||||
|
*,
|
||||||
|
loop: AbstractEventLoop | None = None,
|
||||||
|
return_exceptions: Literal[False] = False,
|
||||||
|
) -> Future[tuple[_T1, _T2, _T3]]: ...
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1],
|
||||||
|
coro_or_future2: _FutureLike[_T2],
|
||||||
|
coro_or_future3: _FutureLike[_T3],
|
||||||
|
coro_or_future4: _FutureLike[_T4],
|
||||||
|
/,
|
||||||
|
*,
|
||||||
|
loop: AbstractEventLoop | None = None,
|
||||||
|
return_exceptions: Literal[False] = False,
|
||||||
|
) -> Future[tuple[_T1, _T2, _T3, _T4]]: ...
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1],
|
||||||
|
coro_or_future2: _FutureLike[_T2],
|
||||||
|
coro_or_future3: _FutureLike[_T3],
|
||||||
|
coro_or_future4: _FutureLike[_T4],
|
||||||
|
coro_or_future5: _FutureLike[_T5],
|
||||||
|
/,
|
||||||
|
*,
|
||||||
|
loop: AbstractEventLoop | None = None,
|
||||||
|
return_exceptions: Literal[False] = False,
|
||||||
|
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ...
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1],
|
||||||
|
coro_or_future2: _FutureLike[_T2],
|
||||||
|
coro_or_future3: _FutureLike[_T3],
|
||||||
|
coro_or_future4: _FutureLike[_T4],
|
||||||
|
coro_or_future5: _FutureLike[_T5],
|
||||||
|
coro_or_future6: _FutureLike[_T6],
|
||||||
|
/,
|
||||||
|
*,
|
||||||
|
loop: AbstractEventLoop | None = None,
|
||||||
|
return_exceptions: Literal[False] = False,
|
||||||
|
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ...
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
*coros_or_futures: _FutureLike[_T], loop: AbstractEventLoop | None = None, return_exceptions: Literal[False] = False
|
||||||
|
) -> Future[list[_T]]: ...
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1], /, *, loop: AbstractEventLoop | None = None, return_exceptions: bool
|
||||||
|
) -> Future[tuple[_T1 | BaseException]]: ...
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1],
|
||||||
|
coro_or_future2: _FutureLike[_T2],
|
||||||
|
/,
|
||||||
|
*,
|
||||||
|
loop: AbstractEventLoop | None = None,
|
||||||
|
return_exceptions: bool,
|
||||||
|
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ...
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1],
|
||||||
|
coro_or_future2: _FutureLike[_T2],
|
||||||
|
coro_or_future3: _FutureLike[_T3],
|
||||||
|
/,
|
||||||
|
*,
|
||||||
|
loop: AbstractEventLoop | None = None,
|
||||||
|
return_exceptions: bool,
|
||||||
|
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ...
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1],
|
||||||
|
coro_or_future2: _FutureLike[_T2],
|
||||||
|
coro_or_future3: _FutureLike[_T3],
|
||||||
|
coro_or_future4: _FutureLike[_T4],
|
||||||
|
/,
|
||||||
|
*,
|
||||||
|
loop: AbstractEventLoop | None = None,
|
||||||
|
return_exceptions: bool,
|
||||||
|
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ...
|
||||||
|
@overload
|
||||||
|
def gather( # type: ignore[overload-overlap]
|
||||||
|
coro_or_future1: _FutureLike[_T1],
|
||||||
|
coro_or_future2: _FutureLike[_T2],
|
||||||
|
coro_or_future3: _FutureLike[_T3],
|
||||||
|
coro_or_future4: _FutureLike[_T4],
|
||||||
|
coro_or_future5: _FutureLike[_T5],
|
||||||
|
coro_or_future6: _FutureLike[_T6],
|
||||||
|
/,
|
||||||
|
*,
|
||||||
|
loop: AbstractEventLoop | None = None,
|
||||||
|
return_exceptions: bool,
|
||||||
|
) -> Future[
|
||||||
|
tuple[
|
||||||
|
_T1 | BaseException,
|
||||||
|
_T2 | BaseException,
|
||||||
|
_T3 | BaseException,
|
||||||
|
_T4 | BaseException,
|
||||||
|
_T5 | BaseException,
|
||||||
|
_T6 | BaseException,
|
||||||
|
]
|
||||||
|
]: ...
|
||||||
|
@overload
|
||||||
|
def gather(
|
||||||
|
*coros_or_futures: _FutureLike[_T], loop: AbstractEventLoop | None = None, return_exceptions: bool
|
||||||
|
) -> Future[list[_T | BaseException]]: ...
|
||||||
|
|
||||||
|
def run_coroutine_threadsafe(coro: _FutureLike[_T], loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
def shield(arg: _FutureLike[_T]) -> Future[_T]: ...
|
||||||
|
@overload
|
||||||
|
async def sleep(delay: float) -> None: ...
|
||||||
|
@overload
|
||||||
|
async def sleep(delay: float, result: _T) -> _T: ...
|
||||||
|
async def wait_for(fut: _FutureLike[_T], timeout: float | None) -> _T: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
def shield(arg: _FutureLike[_T], *, loop: AbstractEventLoop | None = None) -> Future[_T]: ...
|
||||||
|
@overload
|
||||||
|
async def sleep(delay: float, *, loop: AbstractEventLoop | None = None) -> None: ...
|
||||||
|
@overload
|
||||||
|
async def sleep(delay: float, result: _T, *, loop: AbstractEventLoop | None = None) -> _T: ...
|
||||||
|
async def wait_for(fut: _FutureLike[_T], timeout: float | None, *, loop: AbstractEventLoop | None = None) -> _T: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
@overload
|
||||||
|
async def wait(
|
||||||
|
fs: Iterable[_FT], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED"
|
||||||
|
) -> tuple[set[_FT], set[_FT]]: ...
|
||||||
|
@overload
|
||||||
|
async def wait(
|
||||||
|
fs: Iterable[Task[_T]], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED"
|
||||||
|
) -> tuple[set[Task[_T]], set[Task[_T]]]: ...
|
||||||
|
|
||||||
|
elif sys.version_info >= (3, 10):
|
||||||
|
@overload
|
||||||
|
async def wait( # type: ignore[overload-overlap]
|
||||||
|
fs: Iterable[_FT], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED"
|
||||||
|
) -> tuple[set[_FT], set[_FT]]: ...
|
||||||
|
@overload
|
||||||
|
async def wait(
|
||||||
|
fs: Iterable[Awaitable[_T]], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED"
|
||||||
|
) -> tuple[set[Task[_T]], set[Task[_T]]]: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
@overload
|
||||||
|
async def wait( # type: ignore[overload-overlap]
|
||||||
|
fs: Iterable[_FT],
|
||||||
|
*,
|
||||||
|
loop: AbstractEventLoop | None = None,
|
||||||
|
timeout: float | None = None,
|
||||||
|
return_when: str = "ALL_COMPLETED",
|
||||||
|
) -> tuple[set[_FT], set[_FT]]: ...
|
||||||
|
@overload
|
||||||
|
async def wait(
|
||||||
|
fs: Iterable[Awaitable[_T]],
|
||||||
|
*,
|
||||||
|
loop: AbstractEventLoop | None = None,
|
||||||
|
timeout: float | None = None,
|
||||||
|
return_when: str = "ALL_COMPLETED",
|
||||||
|
) -> tuple[set[Task[_T]], set[Task[_T]]]: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
_TaskCompatibleCoro: TypeAlias = Coroutine[Any, Any, _T_co]
|
||||||
|
elif sys.version_info >= (3, 9):
|
||||||
|
_TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Coroutine[Any, Any, _T_co]
|
||||||
|
else:
|
||||||
|
_TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Awaitable[_T_co]
|
||||||
|
|
||||||
|
# mypy and pyright complain that a subclass of an invariant class shouldn't be covariant.
|
||||||
|
# While this is true in general, here it's sort-of okay to have a covariant subclass,
|
||||||
|
# since the only reason why `asyncio.Future` is invariant is the `set_result()` method,
|
||||||
|
# and `asyncio.Task.set_result()` always raises.
|
||||||
|
class Task(Future[_T_co]): # type: ignore[type-var] # pyright: ignore[reportInvalidTypeArguments]
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
coro: _TaskCompatibleCoro[_T_co],
|
||||||
|
*,
|
||||||
|
loop: AbstractEventLoop = ...,
|
||||||
|
name: str | None = ...,
|
||||||
|
context: Context | None = None,
|
||||||
|
eager_start: bool = False,
|
||||||
|
) -> None: ...
|
||||||
|
elif sys.version_info >= (3, 11):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
coro: _TaskCompatibleCoro[_T_co],
|
||||||
|
*,
|
||||||
|
loop: AbstractEventLoop = ...,
|
||||||
|
name: str | None = ...,
|
||||||
|
context: Context | None = None,
|
||||||
|
) -> None: ...
|
||||||
|
else:
|
||||||
|
def __init__(
|
||||||
|
self, coro: _TaskCompatibleCoro[_T_co], *, loop: AbstractEventLoop = ..., name: str | None = ...
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
def get_coro(self) -> _TaskCompatibleCoro[_T_co]: ...
|
||||||
|
def get_name(self) -> str: ...
|
||||||
|
def set_name(self, value: object, /) -> None: ...
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
def get_context(self) -> Context: ...
|
||||||
|
|
||||||
|
def get_stack(self, *, limit: int | None = None) -> list[FrameType]: ...
|
||||||
|
def print_stack(self, *, limit: int | None = None, file: TextIO | None = None) -> None: ...
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
def cancelling(self) -> int: ...
|
||||||
|
def uncancel(self) -> int: ...
|
||||||
|
if sys.version_info < (3, 9):
|
||||||
|
@classmethod
|
||||||
|
def current_task(cls, loop: AbstractEventLoop | None = None) -> Task[Any] | None: ...
|
||||||
|
@classmethod
|
||||||
|
def all_tasks(cls, loop: AbstractEventLoop | None = None) -> set[Task[Any]]: ...
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
||||||
|
|
||||||
|
def all_tasks(loop: AbstractEventLoop | None = None) -> set[Task[Any]]: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
def create_task(coro: _CoroutineLike[_T], *, name: str | None = None, context: Context | None = None) -> Task[_T]: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
def create_task(coro: _CoroutineLike[_T], *, name: str | None = None) -> Task[_T]: ...
|
||||||
|
|
||||||
|
def current_task(loop: AbstractEventLoop | None = None) -> Task[Any] | None: ...
|
||||||
|
def _enter_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ...
|
||||||
|
def _leave_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
_TaskT_co = TypeVar("_TaskT_co", bound=Task[Any], covariant=True)
|
||||||
|
|
||||||
|
class _CustomTaskConstructor(Protocol[_TaskT_co]):
|
||||||
|
def __call__(
|
||||||
|
self,
|
||||||
|
coro: _TaskCompatibleCoro[Any],
|
||||||
|
/,
|
||||||
|
*,
|
||||||
|
loop: AbstractEventLoop,
|
||||||
|
name: str | None,
|
||||||
|
context: Context | None,
|
||||||
|
eager_start: bool,
|
||||||
|
) -> _TaskT_co: ...
|
||||||
|
|
||||||
|
class _EagerTaskFactoryType(Protocol[_TaskT_co]):
|
||||||
|
def __call__(
|
||||||
|
self,
|
||||||
|
loop: AbstractEventLoop,
|
||||||
|
coro: _TaskCompatibleCoro[Any],
|
||||||
|
*,
|
||||||
|
name: str | None = None,
|
||||||
|
context: Context | None = None,
|
||||||
|
) -> _TaskT_co: ...
|
||||||
|
|
||||||
|
def create_eager_task_factory(
|
||||||
|
custom_task_constructor: _CustomTaskConstructor[_TaskT_co],
|
||||||
|
) -> _EagerTaskFactoryType[_TaskT_co]: ...
|
||||||
|
def eager_task_factory(
|
||||||
|
loop: AbstractEventLoop | None,
|
||||||
|
coro: _TaskCompatibleCoro[_T_co],
|
||||||
|
*,
|
||||||
|
name: str | None = None,
|
||||||
|
context: Context | None = None,
|
||||||
|
) -> Task[_T_co]: ...
|
||||||
|
|
||||||
|
def _register_task(task: Task[Any]) -> None: ...
|
||||||
|
def _unregister_task(task: Task[Any]) -> None: ...
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
from collections.abc import Callable
|
||||||
|
from typing import TypeVar
|
||||||
|
from typing_extensions import ParamSpec
|
||||||
|
|
||||||
|
__all__ = ("to_thread",)
|
||||||
|
_P = ParamSpec("_P")
|
||||||
|
_R = TypeVar("_R")
|
||||||
|
|
||||||
|
async def to_thread(func: Callable[_P, _R], /, *args: _P.args, **kwargs: _P.kwargs) -> _R: ...
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
from types import TracebackType
|
||||||
|
from typing import final
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
__all__ = ("Timeout", "timeout", "timeout_at")
|
||||||
|
|
||||||
|
@final
|
||||||
|
class Timeout:
|
||||||
|
def __init__(self, when: float | None) -> None: ...
|
||||||
|
def when(self) -> float | None: ...
|
||||||
|
def reschedule(self, when: float | None) -> None: ...
|
||||||
|
def expired(self) -> bool: ...
|
||||||
|
async def __aenter__(self) -> Self: ...
|
||||||
|
async def __aexit__(
|
||||||
|
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
def timeout(delay: float | None) -> Timeout: ...
|
||||||
|
def timeout_at(when: float | None) -> Timeout: ...
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
from asyncio.events import AbstractEventLoop
|
||||||
|
from asyncio.protocols import BaseProtocol
|
||||||
|
from collections.abc import Iterable, Mapping
|
||||||
|
from socket import _Address
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
__all__ = ("BaseTransport", "ReadTransport", "WriteTransport", "Transport", "DatagramTransport", "SubprocessTransport")
|
||||||
|
|
||||||
|
class BaseTransport:
|
||||||
|
def __init__(self, extra: Mapping[str, Any] | None = None) -> None: ...
|
||||||
|
def get_extra_info(self, name: str, default: Any = None) -> Any: ...
|
||||||
|
def is_closing(self) -> bool: ...
|
||||||
|
def close(self) -> None: ...
|
||||||
|
def set_protocol(self, protocol: BaseProtocol) -> None: ...
|
||||||
|
def get_protocol(self) -> BaseProtocol: ...
|
||||||
|
|
||||||
|
class ReadTransport(BaseTransport):
|
||||||
|
def is_reading(self) -> bool: ...
|
||||||
|
def pause_reading(self) -> None: ...
|
||||||
|
def resume_reading(self) -> None: ...
|
||||||
|
|
||||||
|
class WriteTransport(BaseTransport):
|
||||||
|
def set_write_buffer_limits(self, high: int | None = None, low: int | None = None) -> None: ...
|
||||||
|
def get_write_buffer_size(self) -> int: ...
|
||||||
|
def get_write_buffer_limits(self) -> tuple[int, int]: ...
|
||||||
|
def write(self, data: bytes | bytearray | memoryview) -> None: ...
|
||||||
|
def writelines(self, list_of_data: Iterable[bytes | bytearray | memoryview]) -> None: ...
|
||||||
|
def write_eof(self) -> None: ...
|
||||||
|
def can_write_eof(self) -> bool: ...
|
||||||
|
def abort(self) -> None: ...
|
||||||
|
|
||||||
|
class Transport(ReadTransport, WriteTransport): ...
|
||||||
|
|
||||||
|
class DatagramTransport(BaseTransport):
|
||||||
|
def sendto(self, data: bytes | bytearray | memoryview, addr: _Address | None = None) -> None: ...
|
||||||
|
def abort(self) -> None: ...
|
||||||
|
|
||||||
|
class SubprocessTransport(BaseTransport):
|
||||||
|
def get_pid(self) -> int: ...
|
||||||
|
def get_returncode(self) -> int | None: ...
|
||||||
|
def get_pipe_transport(self, fd: int) -> BaseTransport | None: ...
|
||||||
|
def send_signal(self, signal: int) -> None: ...
|
||||||
|
def terminate(self) -> None: ...
|
||||||
|
def kill(self) -> None: ...
|
||||||
|
|
||||||
|
class _FlowControlMixin(Transport):
|
||||||
|
def __init__(self, extra: Mapping[str, Any] | None = None, loop: AbstractEventLoop | None = None) -> None: ...
|
||||||
|
|
@ -0,0 +1,94 @@
|
||||||
|
import socket
|
||||||
|
import sys
|
||||||
|
from _typeshed import ReadableBuffer
|
||||||
|
from builtins import type as Type # alias to avoid name clashes with property named "type"
|
||||||
|
from collections.abc import Iterable
|
||||||
|
from types import TracebackType
|
||||||
|
from typing import Any, BinaryIO, NoReturn, overload
|
||||||
|
from typing_extensions import TypeAlias
|
||||||
|
|
||||||
|
# These are based in socket, maybe move them out into _typeshed.pyi or such
|
||||||
|
_Address: TypeAlias = socket._Address
|
||||||
|
_RetAddress: TypeAlias = Any
|
||||||
|
_WriteBuffer: TypeAlias = bytearray | memoryview
|
||||||
|
_CMSG: TypeAlias = tuple[int, int, bytes]
|
||||||
|
|
||||||
|
class TransportSocket:
|
||||||
|
def __init__(self, sock: socket.socket) -> None: ...
|
||||||
|
@property
|
||||||
|
def family(self) -> int: ...
|
||||||
|
@property
|
||||||
|
def type(self) -> int: ...
|
||||||
|
@property
|
||||||
|
def proto(self) -> int: ...
|
||||||
|
def __getstate__(self) -> NoReturn: ...
|
||||||
|
def fileno(self) -> int: ...
|
||||||
|
def dup(self) -> socket.socket: ...
|
||||||
|
def get_inheritable(self) -> bool: ...
|
||||||
|
def shutdown(self, how: int) -> None: ...
|
||||||
|
@overload
|
||||||
|
def getsockopt(self, level: int, optname: int) -> int: ...
|
||||||
|
@overload
|
||||||
|
def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ...
|
||||||
|
@overload
|
||||||
|
def setsockopt(self, level: int, optname: int, value: int | ReadableBuffer) -> None: ...
|
||||||
|
@overload
|
||||||
|
def setsockopt(self, level: int, optname: int, value: None, optlen: int) -> None: ...
|
||||||
|
def getpeername(self) -> _RetAddress: ...
|
||||||
|
def getsockname(self) -> _RetAddress: ...
|
||||||
|
def getsockbyname(self) -> NoReturn: ... # This method doesn't exist on socket, yet is passed through?
|
||||||
|
def settimeout(self, value: float | None) -> None: ...
|
||||||
|
def gettimeout(self) -> float | None: ...
|
||||||
|
def setblocking(self, flag: bool) -> None: ...
|
||||||
|
if sys.version_info < (3, 11):
|
||||||
|
def _na(self, what: str) -> None: ...
|
||||||
|
def accept(self) -> tuple[socket.socket, _RetAddress]: ...
|
||||||
|
def connect(self, address: _Address) -> None: ...
|
||||||
|
def connect_ex(self, address: _Address) -> int: ...
|
||||||
|
def bind(self, address: _Address) -> None: ...
|
||||||
|
if sys.platform == "win32":
|
||||||
|
def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> None: ...
|
||||||
|
else:
|
||||||
|
def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> NoReturn: ...
|
||||||
|
|
||||||
|
def listen(self, backlog: int = ..., /) -> None: ...
|
||||||
|
def makefile(self) -> BinaryIO: ...
|
||||||
|
def sendfile(self, file: BinaryIO, offset: int = ..., count: int | None = ...) -> int: ...
|
||||||
|
def close(self) -> None: ...
|
||||||
|
def detach(self) -> int: ...
|
||||||
|
if sys.platform == "linux":
|
||||||
|
def sendmsg_afalg(
|
||||||
|
self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ...
|
||||||
|
) -> int: ...
|
||||||
|
else:
|
||||||
|
def sendmsg_afalg(
|
||||||
|
self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ...
|
||||||
|
) -> NoReturn: ...
|
||||||
|
|
||||||
|
def sendmsg(
|
||||||
|
self, buffers: Iterable[ReadableBuffer], ancdata: Iterable[_CMSG] = ..., flags: int = ..., address: _Address = ..., /
|
||||||
|
) -> int: ...
|
||||||
|
@overload
|
||||||
|
def sendto(self, data: ReadableBuffer, address: _Address) -> int: ...
|
||||||
|
@overload
|
||||||
|
def sendto(self, data: ReadableBuffer, flags: int, address: _Address) -> int: ...
|
||||||
|
def send(self, data: ReadableBuffer, flags: int = ...) -> int: ...
|
||||||
|
def sendall(self, data: ReadableBuffer, flags: int = ...) -> None: ...
|
||||||
|
def set_inheritable(self, inheritable: bool) -> None: ...
|
||||||
|
if sys.platform == "win32":
|
||||||
|
def share(self, process_id: int) -> bytes: ...
|
||||||
|
else:
|
||||||
|
def share(self, process_id: int) -> NoReturn: ...
|
||||||
|
|
||||||
|
def recv_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> int: ...
|
||||||
|
def recvfrom_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> tuple[int, _RetAddress]: ...
|
||||||
|
def recvmsg_into(
|
||||||
|
self, buffers: Iterable[_WriteBuffer], ancbufsize: int = ..., flags: int = ..., /
|
||||||
|
) -> tuple[int, list[_CMSG], int, Any]: ...
|
||||||
|
def recvmsg(self, bufsize: int, ancbufsize: int = ..., flags: int = ..., /) -> tuple[bytes, list[_CMSG], int, Any]: ...
|
||||||
|
def recvfrom(self, bufsize: int, flags: int = ...) -> tuple[bytes, _RetAddress]: ...
|
||||||
|
def recv(self, bufsize: int, flags: int = ...) -> bytes: ...
|
||||||
|
def __enter__(self) -> socket.socket: ...
|
||||||
|
def __exit__(
|
||||||
|
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||||
|
) -> None: ...
|
||||||
|
|
@ -0,0 +1,196 @@
|
||||||
|
import sys
|
||||||
|
import types
|
||||||
|
from abc import ABCMeta, abstractmethod
|
||||||
|
from collections.abc import Callable
|
||||||
|
from typing import Literal
|
||||||
|
from typing_extensions import Self, TypeVarTuple, Unpack, deprecated
|
||||||
|
|
||||||
|
from .events import AbstractEventLoop, BaseDefaultEventLoopPolicy
|
||||||
|
from .selector_events import BaseSelectorEventLoop
|
||||||
|
|
||||||
|
_Ts = TypeVarTuple("_Ts")
|
||||||
|
|
||||||
|
# This is also technically not available on Win,
|
||||||
|
# but other parts of typeshed need this definition.
|
||||||
|
# So, it is special cased.
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
|
||||||
|
class AbstractChildWatcher:
|
||||||
|
@abstractmethod
|
||||||
|
def add_child_handler(
|
||||||
|
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
|
||||||
|
) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
def remove_child_handler(self, pid: int) -> bool: ...
|
||||||
|
@abstractmethod
|
||||||
|
def attach_loop(self, loop: AbstractEventLoop | None) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
def close(self) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
def __enter__(self) -> Self: ...
|
||||||
|
@abstractmethod
|
||||||
|
def __exit__(
|
||||||
|
self, typ: type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None
|
||||||
|
) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
def is_active(self) -> bool: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
class AbstractChildWatcher:
|
||||||
|
@abstractmethod
|
||||||
|
def add_child_handler(
|
||||||
|
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
|
||||||
|
) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
def remove_child_handler(self, pid: int) -> bool: ...
|
||||||
|
@abstractmethod
|
||||||
|
def attach_loop(self, loop: AbstractEventLoop | None) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
def close(self) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
def __enter__(self) -> Self: ...
|
||||||
|
@abstractmethod
|
||||||
|
def __exit__(
|
||||||
|
self, typ: type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None
|
||||||
|
) -> None: ...
|
||||||
|
@abstractmethod
|
||||||
|
def is_active(self) -> bool: ...
|
||||||
|
|
||||||
|
if sys.platform != "win32":
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
__all__ = (
|
||||||
|
"SelectorEventLoop",
|
||||||
|
"AbstractChildWatcher",
|
||||||
|
"SafeChildWatcher",
|
||||||
|
"FastChildWatcher",
|
||||||
|
"PidfdChildWatcher",
|
||||||
|
"MultiLoopChildWatcher",
|
||||||
|
"ThreadedChildWatcher",
|
||||||
|
"DefaultEventLoopPolicy",
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
__all__ = (
|
||||||
|
"SelectorEventLoop",
|
||||||
|
"AbstractChildWatcher",
|
||||||
|
"SafeChildWatcher",
|
||||||
|
"FastChildWatcher",
|
||||||
|
"MultiLoopChildWatcher",
|
||||||
|
"ThreadedChildWatcher",
|
||||||
|
"DefaultEventLoopPolicy",
|
||||||
|
)
|
||||||
|
|
||||||
|
# Doesn't actually have ABCMeta metaclass at runtime, but mypy complains if we don't have it in the stub.
|
||||||
|
# See discussion in #7412
|
||||||
|
class BaseChildWatcher(AbstractChildWatcher, metaclass=ABCMeta):
|
||||||
|
def close(self) -> None: ...
|
||||||
|
def is_active(self) -> bool: ...
|
||||||
|
def attach_loop(self, loop: AbstractEventLoop | None) -> None: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
|
||||||
|
class SafeChildWatcher(BaseChildWatcher):
|
||||||
|
def __enter__(self) -> Self: ...
|
||||||
|
def __exit__(self, a: type[BaseException] | None, b: BaseException | None, c: types.TracebackType | None) -> None: ...
|
||||||
|
def add_child_handler(
|
||||||
|
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
|
||||||
|
) -> None: ...
|
||||||
|
def remove_child_handler(self, pid: int) -> bool: ...
|
||||||
|
|
||||||
|
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
|
||||||
|
class FastChildWatcher(BaseChildWatcher):
|
||||||
|
def __enter__(self) -> Self: ...
|
||||||
|
def __exit__(self, a: type[BaseException] | None, b: BaseException | None, c: types.TracebackType | None) -> None: ...
|
||||||
|
def add_child_handler(
|
||||||
|
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
|
||||||
|
) -> None: ...
|
||||||
|
def remove_child_handler(self, pid: int) -> bool: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
class SafeChildWatcher(BaseChildWatcher):
|
||||||
|
def __enter__(self) -> Self: ...
|
||||||
|
def __exit__(self, a: type[BaseException] | None, b: BaseException | None, c: types.TracebackType | None) -> None: ...
|
||||||
|
def add_child_handler(
|
||||||
|
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
|
||||||
|
) -> None: ...
|
||||||
|
def remove_child_handler(self, pid: int) -> bool: ...
|
||||||
|
|
||||||
|
class FastChildWatcher(BaseChildWatcher):
|
||||||
|
def __enter__(self) -> Self: ...
|
||||||
|
def __exit__(self, a: type[BaseException] | None, b: BaseException | None, c: types.TracebackType | None) -> None: ...
|
||||||
|
def add_child_handler(
|
||||||
|
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
|
||||||
|
) -> None: ...
|
||||||
|
def remove_child_handler(self, pid: int) -> bool: ...
|
||||||
|
|
||||||
|
class _UnixSelectorEventLoop(BaseSelectorEventLoop): ...
|
||||||
|
|
||||||
|
class _UnixDefaultEventLoopPolicy(BaseDefaultEventLoopPolicy):
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
|
||||||
|
def get_child_watcher(self) -> AbstractChildWatcher: ...
|
||||||
|
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
|
||||||
|
def set_child_watcher(self, watcher: AbstractChildWatcher | None) -> None: ...
|
||||||
|
else:
|
||||||
|
def get_child_watcher(self) -> AbstractChildWatcher: ...
|
||||||
|
def set_child_watcher(self, watcher: AbstractChildWatcher | None) -> None: ...
|
||||||
|
|
||||||
|
SelectorEventLoop = _UnixSelectorEventLoop
|
||||||
|
|
||||||
|
DefaultEventLoopPolicy = _UnixDefaultEventLoopPolicy
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 12):
|
||||||
|
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
|
||||||
|
class MultiLoopChildWatcher(AbstractChildWatcher):
|
||||||
|
def is_active(self) -> bool: ...
|
||||||
|
def close(self) -> None: ...
|
||||||
|
def __enter__(self) -> Self: ...
|
||||||
|
def __exit__(
|
||||||
|
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None
|
||||||
|
) -> None: ...
|
||||||
|
def add_child_handler(
|
||||||
|
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
|
||||||
|
) -> None: ...
|
||||||
|
def remove_child_handler(self, pid: int) -> bool: ...
|
||||||
|
def attach_loop(self, loop: AbstractEventLoop | None) -> None: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
class MultiLoopChildWatcher(AbstractChildWatcher):
|
||||||
|
def is_active(self) -> bool: ...
|
||||||
|
def close(self) -> None: ...
|
||||||
|
def __enter__(self) -> Self: ...
|
||||||
|
def __exit__(
|
||||||
|
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None
|
||||||
|
) -> None: ...
|
||||||
|
def add_child_handler(
|
||||||
|
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
|
||||||
|
) -> None: ...
|
||||||
|
def remove_child_handler(self, pid: int) -> bool: ...
|
||||||
|
def attach_loop(self, loop: AbstractEventLoop | None) -> None: ...
|
||||||
|
|
||||||
|
class ThreadedChildWatcher(AbstractChildWatcher):
|
||||||
|
def is_active(self) -> Literal[True]: ...
|
||||||
|
def close(self) -> None: ...
|
||||||
|
def __enter__(self) -> Self: ...
|
||||||
|
def __exit__(
|
||||||
|
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None
|
||||||
|
) -> None: ...
|
||||||
|
def __del__(self) -> None: ...
|
||||||
|
def add_child_handler(
|
||||||
|
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
|
||||||
|
) -> None: ...
|
||||||
|
def remove_child_handler(self, pid: int) -> bool: ...
|
||||||
|
def attach_loop(self, loop: AbstractEventLoop | None) -> None: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
class PidfdChildWatcher(AbstractChildWatcher):
|
||||||
|
def __enter__(self) -> Self: ...
|
||||||
|
def __exit__(
|
||||||
|
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None
|
||||||
|
) -> None: ...
|
||||||
|
def is_active(self) -> bool: ...
|
||||||
|
def close(self) -> None: ...
|
||||||
|
def attach_loop(self, loop: AbstractEventLoop | None) -> None: ...
|
||||||
|
def add_child_handler(
|
||||||
|
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
|
||||||
|
) -> None: ...
|
||||||
|
def remove_child_handler(self, pid: int) -> bool: ...
|
||||||
|
|
@ -0,0 +1,85 @@
|
||||||
|
import socket
|
||||||
|
import sys
|
||||||
|
from _typeshed import Incomplete, ReadableBuffer, WriteableBuffer
|
||||||
|
from collections.abc import Callable
|
||||||
|
from typing import IO, Any, ClassVar, Literal, NoReturn
|
||||||
|
|
||||||
|
from . import events, futures, proactor_events, selector_events, streams, windows_utils
|
||||||
|
|
||||||
|
if sys.platform == "win32":
|
||||||
|
__all__ = (
|
||||||
|
"SelectorEventLoop",
|
||||||
|
"ProactorEventLoop",
|
||||||
|
"IocpProactor",
|
||||||
|
"DefaultEventLoopPolicy",
|
||||||
|
"WindowsSelectorEventLoopPolicy",
|
||||||
|
"WindowsProactorEventLoopPolicy",
|
||||||
|
)
|
||||||
|
|
||||||
|
NULL: Literal[0]
|
||||||
|
INFINITE: Literal[0xFFFFFFFF]
|
||||||
|
ERROR_CONNECTION_REFUSED: Literal[1225]
|
||||||
|
ERROR_CONNECTION_ABORTED: Literal[1236]
|
||||||
|
CONNECT_PIPE_INIT_DELAY: float
|
||||||
|
CONNECT_PIPE_MAX_DELAY: float
|
||||||
|
|
||||||
|
class PipeServer:
|
||||||
|
def __init__(self, address: str) -> None: ...
|
||||||
|
def __del__(self) -> None: ...
|
||||||
|
def closed(self) -> bool: ...
|
||||||
|
def close(self) -> None: ...
|
||||||
|
|
||||||
|
class _WindowsSelectorEventLoop(selector_events.BaseSelectorEventLoop): ...
|
||||||
|
|
||||||
|
class ProactorEventLoop(proactor_events.BaseProactorEventLoop):
|
||||||
|
def __init__(self, proactor: IocpProactor | None = None) -> None: ...
|
||||||
|
async def create_pipe_connection(
|
||||||
|
self, protocol_factory: Callable[[], streams.StreamReaderProtocol], address: str
|
||||||
|
) -> tuple[proactor_events._ProactorDuplexPipeTransport, streams.StreamReaderProtocol]: ...
|
||||||
|
async def start_serving_pipe(
|
||||||
|
self, protocol_factory: Callable[[], streams.StreamReaderProtocol], address: str
|
||||||
|
) -> list[PipeServer]: ...
|
||||||
|
|
||||||
|
class IocpProactor:
|
||||||
|
def __init__(self, concurrency: int = 0xFFFFFFFF) -> None: ...
|
||||||
|
def __del__(self) -> None: ...
|
||||||
|
def set_loop(self, loop: events.AbstractEventLoop) -> None: ...
|
||||||
|
def select(self, timeout: int | None = None) -> list[futures.Future[Any]]: ...
|
||||||
|
def recv(self, conn: socket.socket, nbytes: int, flags: int = 0) -> futures.Future[bytes]: ...
|
||||||
|
def recv_into(self, conn: socket.socket, buf: WriteableBuffer, flags: int = 0) -> futures.Future[Any]: ...
|
||||||
|
def recvfrom(
|
||||||
|
self, conn: socket.socket, nbytes: int, flags: int = 0
|
||||||
|
) -> futures.Future[tuple[bytes, socket._RetAddress]]: ...
|
||||||
|
def sendto(
|
||||||
|
self, conn: socket.socket, buf: ReadableBuffer, flags: int = 0, addr: socket._Address | None = None
|
||||||
|
) -> futures.Future[int]: ...
|
||||||
|
def send(self, conn: socket.socket, buf: WriteableBuffer, flags: int = 0) -> futures.Future[Any]: ...
|
||||||
|
def accept(self, listener: socket.socket) -> futures.Future[Any]: ...
|
||||||
|
def connect(
|
||||||
|
self,
|
||||||
|
conn: socket.socket,
|
||||||
|
address: tuple[Incomplete, Incomplete] | tuple[Incomplete, Incomplete, Incomplete, Incomplete],
|
||||||
|
) -> futures.Future[Any]: ...
|
||||||
|
def sendfile(self, sock: socket.socket, file: IO[bytes], offset: int, count: int) -> futures.Future[Any]: ...
|
||||||
|
def accept_pipe(self, pipe: socket.socket) -> futures.Future[Any]: ...
|
||||||
|
async def connect_pipe(self, address: str) -> windows_utils.PipeHandle: ...
|
||||||
|
def wait_for_handle(self, handle: windows_utils.PipeHandle, timeout: int | None = None) -> bool: ...
|
||||||
|
def close(self) -> None: ...
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
def recvfrom_into(
|
||||||
|
self, conn: socket.socket, buf: WriteableBuffer, flags: int = 0
|
||||||
|
) -> futures.Future[tuple[int, socket._RetAddress]]: ...
|
||||||
|
|
||||||
|
SelectorEventLoop = _WindowsSelectorEventLoop
|
||||||
|
|
||||||
|
class WindowsSelectorEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
|
||||||
|
_loop_factory: ClassVar[type[SelectorEventLoop]]
|
||||||
|
def get_child_watcher(self) -> NoReturn: ...
|
||||||
|
def set_child_watcher(self, watcher: Any) -> NoReturn: ...
|
||||||
|
|
||||||
|
class WindowsProactorEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
|
||||||
|
_loop_factory: ClassVar[type[ProactorEventLoop]]
|
||||||
|
def get_child_watcher(self) -> NoReturn: ...
|
||||||
|
def set_child_watcher(self, watcher: Any) -> NoReturn: ...
|
||||||
|
|
||||||
|
DefaultEventLoopPolicy = WindowsSelectorEventLoopPolicy
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from collections.abc import Callable
|
||||||
|
from types import TracebackType
|
||||||
|
from typing import Any, AnyStr, Literal
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
if sys.platform == "win32":
|
||||||
|
__all__ = ("pipe", "Popen", "PIPE", "PipeHandle")
|
||||||
|
|
||||||
|
BUFSIZE: Literal[8192]
|
||||||
|
PIPE = subprocess.PIPE
|
||||||
|
STDOUT = subprocess.STDOUT
|
||||||
|
def pipe(*, duplex: bool = False, overlapped: tuple[bool, bool] = (True, True), bufsize: int = 8192) -> tuple[int, int]: ...
|
||||||
|
|
||||||
|
class PipeHandle:
|
||||||
|
def __init__(self, handle: int) -> None: ...
|
||||||
|
def __del__(self) -> None: ...
|
||||||
|
def __enter__(self) -> Self: ...
|
||||||
|
def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
|
||||||
|
@property
|
||||||
|
def handle(self) -> int: ...
|
||||||
|
def fileno(self) -> int: ...
|
||||||
|
def close(self, *, CloseHandle: Callable[[int], object] = ...) -> None: ...
|
||||||
|
|
||||||
|
class Popen(subprocess.Popen[AnyStr]):
|
||||||
|
stdin: PipeHandle | None # type: ignore[assignment]
|
||||||
|
stdout: PipeHandle | None # type: ignore[assignment]
|
||||||
|
stderr: PipeHandle | None # type: ignore[assignment]
|
||||||
|
# For simplicity we omit the full overloaded __new__ signature of
|
||||||
|
# subprocess.Popen. The arguments are mostly the same, but
|
||||||
|
# subprocess.Popen takes other positional-or-keyword arguments before
|
||||||
|
# stdin.
|
||||||
|
def __new__(
|
||||||
|
cls,
|
||||||
|
args: subprocess._CMD,
|
||||||
|
stdin: subprocess._FILE | None = ...,
|
||||||
|
stdout: subprocess._FILE | None = ...,
|
||||||
|
stderr: subprocess._FILE | None = ...,
|
||||||
|
**kwds: Any,
|
||||||
|
) -> Self: ...
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
args: subprocess._CMD,
|
||||||
|
stdin: subprocess._FILE | None = None,
|
||||||
|
stdout: subprocess._FILE | None = None,
|
||||||
|
stderr: subprocess._FILE | None = None,
|
||||||
|
**kwds: Any,
|
||||||
|
) -> None: ...
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
import sys
|
||||||
|
from _typeshed import FileDescriptorLike, ReadableBuffer
|
||||||
|
from socket import socket
|
||||||
|
from typing import Any, overload
|
||||||
|
from typing_extensions import TypeAlias
|
||||||
|
|
||||||
|
# cyclic dependence with asynchat
|
||||||
|
_MapType: TypeAlias = dict[int, Any]
|
||||||
|
_Socket: TypeAlias = socket
|
||||||
|
|
||||||
|
socket_map: _MapType # undocumented
|
||||||
|
|
||||||
|
class ExitNow(Exception): ...
|
||||||
|
|
||||||
|
def read(obj: Any) -> None: ...
|
||||||
|
def write(obj: Any) -> None: ...
|
||||||
|
def readwrite(obj: Any, flags: int) -> None: ...
|
||||||
|
def poll(timeout: float = 0.0, map: _MapType | None = None) -> None: ...
|
||||||
|
def poll2(timeout: float = 0.0, map: _MapType | None = None) -> None: ...
|
||||||
|
|
||||||
|
poll3 = poll2
|
||||||
|
|
||||||
|
def loop(timeout: float = 30.0, use_poll: bool = False, map: _MapType | None = None, count: int | None = None) -> None: ...
|
||||||
|
|
||||||
|
# Not really subclass of socket.socket; it's only delegation.
|
||||||
|
# It is not covariant to it.
|
||||||
|
class dispatcher:
|
||||||
|
debug: bool
|
||||||
|
connected: bool
|
||||||
|
accepting: bool
|
||||||
|
connecting: bool
|
||||||
|
closing: bool
|
||||||
|
ignore_log_types: frozenset[str]
|
||||||
|
socket: _Socket | None
|
||||||
|
def __init__(self, sock: _Socket | None = None, map: _MapType | None = None) -> None: ...
|
||||||
|
def add_channel(self, map: _MapType | None = None) -> None: ...
|
||||||
|
def del_channel(self, map: _MapType | None = None) -> None: ...
|
||||||
|
def create_socket(self, family: int = ..., type: int = ...) -> None: ...
|
||||||
|
def set_socket(self, sock: _Socket, map: _MapType | None = None) -> None: ...
|
||||||
|
def set_reuse_addr(self) -> None: ...
|
||||||
|
def readable(self) -> bool: ...
|
||||||
|
def writable(self) -> bool: ...
|
||||||
|
def listen(self, num: int) -> None: ...
|
||||||
|
def bind(self, addr: tuple[Any, ...] | str) -> None: ...
|
||||||
|
def connect(self, address: tuple[Any, ...] | str) -> None: ...
|
||||||
|
def accept(self) -> tuple[_Socket, Any] | None: ...
|
||||||
|
def send(self, data: ReadableBuffer) -> int: ...
|
||||||
|
def recv(self, buffer_size: int) -> bytes: ...
|
||||||
|
def close(self) -> None: ...
|
||||||
|
def log(self, message: Any) -> None: ...
|
||||||
|
def log_info(self, message: Any, type: str = "info") -> None: ...
|
||||||
|
def handle_read_event(self) -> None: ...
|
||||||
|
def handle_connect_event(self) -> None: ...
|
||||||
|
def handle_write_event(self) -> None: ...
|
||||||
|
def handle_expt_event(self) -> None: ...
|
||||||
|
def handle_error(self) -> None: ...
|
||||||
|
def handle_expt(self) -> None: ...
|
||||||
|
def handle_read(self) -> None: ...
|
||||||
|
def handle_write(self) -> None: ...
|
||||||
|
def handle_connect(self) -> None: ...
|
||||||
|
def handle_accept(self) -> None: ...
|
||||||
|
def handle_close(self) -> None: ...
|
||||||
|
|
||||||
|
class dispatcher_with_send(dispatcher):
|
||||||
|
def initiate_send(self) -> None: ...
|
||||||
|
# incompatible signature:
|
||||||
|
# def send(self, data: bytes) -> int | None: ...
|
||||||
|
|
||||||
|
def compact_traceback() -> tuple[tuple[str, str, str], type, type, str]: ...
|
||||||
|
def close_all(map: _MapType | None = None, ignore_all: bool = False) -> None: ...
|
||||||
|
|
||||||
|
if sys.platform != "win32":
|
||||||
|
class file_wrapper:
|
||||||
|
fd: int
|
||||||
|
def __init__(self, fd: int) -> None: ...
|
||||||
|
def recv(self, bufsize: int, flags: int = ...) -> bytes: ...
|
||||||
|
def send(self, data: bytes, flags: int = ...) -> int: ...
|
||||||
|
@overload
|
||||||
|
def getsockopt(self, level: int, optname: int, buflen: None = None) -> int: ...
|
||||||
|
@overload
|
||||||
|
def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ...
|
||||||
|
def read(self, bufsize: int, flags: int = ...) -> bytes: ...
|
||||||
|
def write(self, data: bytes, flags: int = ...) -> int: ...
|
||||||
|
def close(self) -> None: ...
|
||||||
|
def fileno(self) -> int: ...
|
||||||
|
def __del__(self) -> None: ...
|
||||||
|
|
||||||
|
class file_dispatcher(dispatcher):
|
||||||
|
def __init__(self, fd: FileDescriptorLike, map: _MapType | None = None) -> None: ...
|
||||||
|
def set_file(self, fd: int) -> None: ...
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
from collections.abc import Callable
|
||||||
|
from typing import TypeVar
|
||||||
|
from typing_extensions import ParamSpec
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
_P = ParamSpec("_P")
|
||||||
|
|
||||||
|
def _clear() -> None: ...
|
||||||
|
def _ncallbacks() -> int: ...
|
||||||
|
def _run_exitfuncs() -> None: ...
|
||||||
|
def register(func: Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs) -> Callable[_P, _T]: ...
|
||||||
|
def unregister(func: Callable[..., object]) -> None: ...
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
from typing_extensions import Buffer, TypeAlias
|
||||||
|
|
||||||
|
_AdpcmState: TypeAlias = tuple[int, int]
|
||||||
|
_RatecvState: TypeAlias = tuple[int, tuple[tuple[int, int], ...]]
|
||||||
|
|
||||||
|
class error(Exception): ...
|
||||||
|
|
||||||
|
def add(fragment1: Buffer, fragment2: Buffer, width: int, /) -> bytes: ...
|
||||||
|
def adpcm2lin(fragment: Buffer, width: int, state: _AdpcmState | None, /) -> tuple[bytes, _AdpcmState]: ...
|
||||||
|
def alaw2lin(fragment: Buffer, width: int, /) -> bytes: ...
|
||||||
|
def avg(fragment: Buffer, width: int, /) -> int: ...
|
||||||
|
def avgpp(fragment: Buffer, width: int, /) -> int: ...
|
||||||
|
def bias(fragment: Buffer, width: int, bias: int, /) -> bytes: ...
|
||||||
|
def byteswap(fragment: Buffer, width: int, /) -> bytes: ...
|
||||||
|
def cross(fragment: Buffer, width: int, /) -> int: ...
|
||||||
|
def findfactor(fragment: Buffer, reference: Buffer, /) -> float: ...
|
||||||
|
def findfit(fragment: Buffer, reference: Buffer, /) -> tuple[int, float]: ...
|
||||||
|
def findmax(fragment: Buffer, length: int, /) -> int: ...
|
||||||
|
def getsample(fragment: Buffer, width: int, index: int, /) -> int: ...
|
||||||
|
def lin2adpcm(fragment: Buffer, width: int, state: _AdpcmState | None, /) -> tuple[bytes, _AdpcmState]: ...
|
||||||
|
def lin2alaw(fragment: Buffer, width: int, /) -> bytes: ...
|
||||||
|
def lin2lin(fragment: Buffer, width: int, newwidth: int, /) -> bytes: ...
|
||||||
|
def lin2ulaw(fragment: Buffer, width: int, /) -> bytes: ...
|
||||||
|
def max(fragment: Buffer, width: int, /) -> int: ...
|
||||||
|
def maxpp(fragment: Buffer, width: int, /) -> int: ...
|
||||||
|
def minmax(fragment: Buffer, width: int, /) -> tuple[int, int]: ...
|
||||||
|
def mul(fragment: Buffer, width: int, factor: float, /) -> bytes: ...
|
||||||
|
def ratecv(
|
||||||
|
fragment: Buffer,
|
||||||
|
width: int,
|
||||||
|
nchannels: int,
|
||||||
|
inrate: int,
|
||||||
|
outrate: int,
|
||||||
|
state: _RatecvState | None,
|
||||||
|
weightA: int = 1,
|
||||||
|
weightB: int = 0,
|
||||||
|
/,
|
||||||
|
) -> tuple[bytes, _RatecvState]: ...
|
||||||
|
def reverse(fragment: Buffer, width: int, /) -> bytes: ...
|
||||||
|
def rms(fragment: Buffer, width: int, /) -> int: ...
|
||||||
|
def tomono(fragment: Buffer, width: int, lfactor: float, rfactor: float, /) -> bytes: ...
|
||||||
|
def tostereo(fragment: Buffer, width: int, lfactor: float, rfactor: float, /) -> bytes: ...
|
||||||
|
def ulaw2lin(fragment: Buffer, width: int, /) -> bytes: ...
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
import sys
|
||||||
|
from _typeshed import ReadableBuffer
|
||||||
|
from typing import IO
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"encode",
|
||||||
|
"decode",
|
||||||
|
"encodebytes",
|
||||||
|
"decodebytes",
|
||||||
|
"b64encode",
|
||||||
|
"b64decode",
|
||||||
|
"b32encode",
|
||||||
|
"b32decode",
|
||||||
|
"b16encode",
|
||||||
|
"b16decode",
|
||||||
|
"b85encode",
|
||||||
|
"b85decode",
|
||||||
|
"a85encode",
|
||||||
|
"a85decode",
|
||||||
|
"standard_b64encode",
|
||||||
|
"standard_b64decode",
|
||||||
|
"urlsafe_b64encode",
|
||||||
|
"urlsafe_b64decode",
|
||||||
|
]
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
__all__ += ["b32hexencode", "b32hexdecode"]
|
||||||
|
|
||||||
|
def b64encode(s: ReadableBuffer, altchars: ReadableBuffer | None = None) -> bytes: ...
|
||||||
|
def b64decode(s: str | ReadableBuffer, altchars: str | ReadableBuffer | None = None, validate: bool = False) -> bytes: ...
|
||||||
|
def standard_b64encode(s: ReadableBuffer) -> bytes: ...
|
||||||
|
def standard_b64decode(s: str | ReadableBuffer) -> bytes: ...
|
||||||
|
def urlsafe_b64encode(s: ReadableBuffer) -> bytes: ...
|
||||||
|
def urlsafe_b64decode(s: str | ReadableBuffer) -> bytes: ...
|
||||||
|
def b32encode(s: ReadableBuffer) -> bytes: ...
|
||||||
|
def b32decode(s: str | ReadableBuffer, casefold: bool = False, map01: str | ReadableBuffer | None = None) -> bytes: ...
|
||||||
|
def b16encode(s: ReadableBuffer) -> bytes: ...
|
||||||
|
def b16decode(s: str | ReadableBuffer, casefold: bool = False) -> bytes: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 10):
|
||||||
|
def b32hexencode(s: ReadableBuffer) -> bytes: ...
|
||||||
|
def b32hexdecode(s: str | ReadableBuffer, casefold: bool = False) -> bytes: ...
|
||||||
|
|
||||||
|
def a85encode(
|
||||||
|
b: ReadableBuffer, *, foldspaces: bool = False, wrapcol: int = 0, pad: bool = False, adobe: bool = False
|
||||||
|
) -> bytes: ...
|
||||||
|
def a85decode(
|
||||||
|
b: str | ReadableBuffer, *, foldspaces: bool = False, adobe: bool = False, ignorechars: bytearray | bytes = b" \t\n\r\x0b"
|
||||||
|
) -> bytes: ...
|
||||||
|
def b85encode(b: ReadableBuffer, pad: bool = False) -> bytes: ...
|
||||||
|
def b85decode(b: str | ReadableBuffer) -> bytes: ...
|
||||||
|
def decode(input: IO[bytes], output: IO[bytes]) -> None: ...
|
||||||
|
def encode(input: IO[bytes], output: IO[bytes]) -> None: ...
|
||||||
|
def encodebytes(s: ReadableBuffer) -> bytes: ...
|
||||||
|
def decodebytes(s: ReadableBuffer) -> bytes: ...
|
||||||
|
|
||||||
|
if sys.version_info < (3, 9):
|
||||||
|
def encodestring(s: ReadableBuffer) -> bytes: ...
|
||||||
|
def decodestring(s: ReadableBuffer) -> bytes: ...
|
||||||
|
|
@ -0,0 +1,102 @@
|
||||||
|
import sys
|
||||||
|
from _typeshed import ExcInfo, TraceFunction
|
||||||
|
from collections.abc import Callable, Iterable, Mapping
|
||||||
|
from types import CodeType, FrameType, TracebackType
|
||||||
|
from typing import IO, Any, Literal, SupportsInt, TypeVar
|
||||||
|
from typing_extensions import ParamSpec
|
||||||
|
|
||||||
|
__all__ = ["BdbQuit", "Bdb", "Breakpoint"]
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
_P = ParamSpec("_P")
|
||||||
|
|
||||||
|
GENERATOR_AND_COROUTINE_FLAGS: Literal[672]
|
||||||
|
|
||||||
|
class BdbQuit(Exception): ...
|
||||||
|
|
||||||
|
class Bdb:
|
||||||
|
skip: set[str] | None
|
||||||
|
breaks: dict[str, list[int]]
|
||||||
|
fncache: dict[str, str]
|
||||||
|
frame_returning: FrameType | None
|
||||||
|
botframe: FrameType | None
|
||||||
|
quitting: bool
|
||||||
|
stopframe: FrameType | None
|
||||||
|
returnframe: FrameType | None
|
||||||
|
stoplineno: int
|
||||||
|
def __init__(self, skip: Iterable[str] | None = None) -> None: ...
|
||||||
|
def canonic(self, filename: str) -> str: ...
|
||||||
|
def reset(self) -> None: ...
|
||||||
|
def trace_dispatch(self, frame: FrameType, event: str, arg: Any) -> TraceFunction: ...
|
||||||
|
def dispatch_line(self, frame: FrameType) -> TraceFunction: ...
|
||||||
|
def dispatch_call(self, frame: FrameType, arg: None) -> TraceFunction: ...
|
||||||
|
def dispatch_return(self, frame: FrameType, arg: Any) -> TraceFunction: ...
|
||||||
|
def dispatch_exception(self, frame: FrameType, arg: ExcInfo) -> TraceFunction: ...
|
||||||
|
def is_skipped_module(self, module_name: str) -> bool: ...
|
||||||
|
def stop_here(self, frame: FrameType) -> bool: ...
|
||||||
|
def break_here(self, frame: FrameType) -> bool: ...
|
||||||
|
def do_clear(self, arg: Any) -> bool | None: ...
|
||||||
|
def break_anywhere(self, frame: FrameType) -> bool: ...
|
||||||
|
def user_call(self, frame: FrameType, argument_list: None) -> None: ...
|
||||||
|
def user_line(self, frame: FrameType) -> None: ...
|
||||||
|
def user_return(self, frame: FrameType, return_value: Any) -> None: ...
|
||||||
|
def user_exception(self, frame: FrameType, exc_info: ExcInfo) -> None: ...
|
||||||
|
def set_until(self, frame: FrameType, lineno: int | None = None) -> None: ...
|
||||||
|
def set_step(self) -> None: ...
|
||||||
|
def set_next(self, frame: FrameType) -> None: ...
|
||||||
|
def set_return(self, frame: FrameType) -> None: ...
|
||||||
|
def set_trace(self, frame: FrameType | None = None) -> None: ...
|
||||||
|
def set_continue(self) -> None: ...
|
||||||
|
def set_quit(self) -> None: ...
|
||||||
|
def set_break(
|
||||||
|
self, filename: str, lineno: int, temporary: bool = False, cond: str | None = None, funcname: str | None = None
|
||||||
|
) -> str | None: ...
|
||||||
|
def clear_break(self, filename: str, lineno: int) -> str | None: ...
|
||||||
|
def clear_bpbynumber(self, arg: SupportsInt) -> str | None: ...
|
||||||
|
def clear_all_file_breaks(self, filename: str) -> str | None: ...
|
||||||
|
def clear_all_breaks(self) -> str | None: ...
|
||||||
|
def get_bpbynumber(self, arg: SupportsInt) -> Breakpoint: ...
|
||||||
|
def get_break(self, filename: str, lineno: int) -> bool: ...
|
||||||
|
def get_breaks(self, filename: str, lineno: int) -> list[Breakpoint]: ...
|
||||||
|
def get_file_breaks(self, filename: str) -> list[Breakpoint]: ...
|
||||||
|
def get_all_breaks(self) -> list[Breakpoint]: ...
|
||||||
|
def get_stack(self, f: FrameType | None, t: TracebackType | None) -> tuple[list[tuple[FrameType, int]], int]: ...
|
||||||
|
def format_stack_entry(self, frame_lineno: int, lprefix: str = ": ") -> str: ...
|
||||||
|
def run(
|
||||||
|
self, cmd: str | CodeType, globals: dict[str, Any] | None = None, locals: Mapping[str, Any] | None = None
|
||||||
|
) -> None: ...
|
||||||
|
def runeval(self, expr: str, globals: dict[str, Any] | None = None, locals: Mapping[str, Any] | None = None) -> None: ...
|
||||||
|
def runctx(self, cmd: str | CodeType, globals: dict[str, Any] | None, locals: Mapping[str, Any] | None) -> None: ...
|
||||||
|
def runcall(self, func: Callable[_P, _T], /, *args: _P.args, **kwds: _P.kwargs) -> _T | None: ...
|
||||||
|
|
||||||
|
class Breakpoint:
|
||||||
|
next: int
|
||||||
|
bplist: dict[tuple[str, int], list[Breakpoint]]
|
||||||
|
bpbynumber: list[Breakpoint | None]
|
||||||
|
|
||||||
|
funcname: str | None
|
||||||
|
func_first_executable_line: int | None
|
||||||
|
file: str
|
||||||
|
line: int
|
||||||
|
temporary: bool
|
||||||
|
cond: str | None
|
||||||
|
enabled: bool
|
||||||
|
ignore: int
|
||||||
|
hits: int
|
||||||
|
number: int
|
||||||
|
def __init__(
|
||||||
|
self, file: str, line: int, temporary: bool = False, cond: str | None = None, funcname: str | None = None
|
||||||
|
) -> None: ...
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
@staticmethod
|
||||||
|
def clearBreakpoints() -> None: ...
|
||||||
|
|
||||||
|
def deleteMe(self) -> None: ...
|
||||||
|
def enable(self) -> None: ...
|
||||||
|
def disable(self) -> None: ...
|
||||||
|
def bpprint(self, out: IO[str] | None = None) -> None: ...
|
||||||
|
def bpformat(self) -> str: ...
|
||||||
|
|
||||||
|
def checkfuncname(b: Breakpoint, frame: FrameType) -> bool: ...
|
||||||
|
def effective(file: str, line: int, frame: FrameType) -> tuple[Breakpoint, bool] | tuple[None, None]: ...
|
||||||
|
def set_trace() -> None: ...
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
import sys
|
||||||
|
from _typeshed import ReadableBuffer
|
||||||
|
from typing_extensions import TypeAlias
|
||||||
|
|
||||||
|
# Many functions in binascii accept buffer objects
|
||||||
|
# or ASCII-only strings.
|
||||||
|
_AsciiBuffer: TypeAlias = str | ReadableBuffer
|
||||||
|
|
||||||
|
def a2b_uu(data: _AsciiBuffer, /) -> bytes: ...
|
||||||
|
def b2a_uu(data: ReadableBuffer, /, *, backtick: bool = False) -> bytes: ...
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
|
def a2b_base64(data: _AsciiBuffer, /, *, strict_mode: bool = False) -> bytes: ...
|
||||||
|
|
||||||
|
else:
|
||||||
|
def a2b_base64(data: _AsciiBuffer, /) -> bytes: ...
|
||||||
|
|
||||||
|
def b2a_base64(data: ReadableBuffer, /, *, newline: bool = True) -> bytes: ...
|
||||||
|
def a2b_qp(data: _AsciiBuffer, header: bool = False) -> bytes: ...
|
||||||
|
def b2a_qp(data: ReadableBuffer, quotetabs: bool = False, istext: bool = True, header: bool = False) -> bytes: ...
|
||||||
|
|
||||||
|
if sys.version_info < (3, 11):
|
||||||
|
def a2b_hqx(data: _AsciiBuffer, /) -> bytes: ...
|
||||||
|
def rledecode_hqx(data: ReadableBuffer, /) -> bytes: ...
|
||||||
|
def rlecode_hqx(data: ReadableBuffer, /) -> bytes: ...
|
||||||
|
def b2a_hqx(data: ReadableBuffer, /) -> bytes: ...
|
||||||
|
|
||||||
|
def crc_hqx(data: ReadableBuffer, crc: int, /) -> int: ...
|
||||||
|
def crc32(data: ReadableBuffer, crc: int = 0, /) -> int: ...
|
||||||
|
def b2a_hex(data: ReadableBuffer, sep: str | bytes = ..., bytes_per_sep: int = ...) -> bytes: ...
|
||||||
|
def hexlify(data: ReadableBuffer, sep: str | bytes = ..., bytes_per_sep: int = ...) -> bytes: ...
|
||||||
|
def a2b_hex(hexstr: _AsciiBuffer, /) -> bytes: ...
|
||||||
|
def unhexlify(hexstr: _AsciiBuffer, /) -> bytes: ...
|
||||||
|
|
||||||
|
class Error(ValueError): ...
|
||||||
|
class Incomplete(Exception): ...
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
from _typeshed import SizedBuffer
|
||||||
|
from typing import IO, Any, Literal
|
||||||
|
from typing_extensions import TypeAlias
|
||||||
|
|
||||||
|
__all__ = ["binhex", "hexbin", "Error"]
|
||||||
|
|
||||||
|
class Error(Exception): ...
|
||||||
|
|
||||||
|
REASONABLY_LARGE: Literal[32768]
|
||||||
|
LINELEN: Literal[64]
|
||||||
|
RUNCHAR: Literal[b"\x90"]
|
||||||
|
|
||||||
|
class FInfo:
|
||||||
|
Type: str
|
||||||
|
Creator: str
|
||||||
|
Flags: int
|
||||||
|
|
||||||
|
_FileInfoTuple: TypeAlias = tuple[str, FInfo, int, int]
|
||||||
|
_FileHandleUnion: TypeAlias = str | IO[bytes]
|
||||||
|
|
||||||
|
def getfileinfo(name: str) -> _FileInfoTuple: ...
|
||||||
|
|
||||||
|
class openrsrc:
|
||||||
|
def __init__(self, *args: Any) -> None: ...
|
||||||
|
def read(self, *args: Any) -> bytes: ...
|
||||||
|
def write(self, *args: Any) -> None: ...
|
||||||
|
def close(self) -> None: ...
|
||||||
|
|
||||||
|
class BinHex:
|
||||||
|
def __init__(self, name_finfo_dlen_rlen: _FileInfoTuple, ofp: _FileHandleUnion) -> None: ...
|
||||||
|
def write(self, data: SizedBuffer) -> None: ...
|
||||||
|
def close_data(self) -> None: ...
|
||||||
|
def write_rsrc(self, data: SizedBuffer) -> None: ...
|
||||||
|
def close(self) -> None: ...
|
||||||
|
|
||||||
|
def binhex(inp: str, out: str) -> None: ...
|
||||||
|
|
||||||
|
class HexBin:
|
||||||
|
def __init__(self, ifp: _FileHandleUnion) -> None: ...
|
||||||
|
def read(self, *n: int) -> bytes: ...
|
||||||
|
def close_data(self) -> None: ...
|
||||||
|
def read_rsrc(self, *n: int) -> bytes: ...
|
||||||
|
def close(self) -> None: ...
|
||||||
|
|
||||||
|
def hexbin(inp: str, out: str) -> None: ...
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
from _bisect import *
|
||||||
|
|
||||||
|
bisect = bisect_right
|
||||||
|
insort = insort_right
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,146 @@
|
||||||
|
import _compression
|
||||||
|
import sys
|
||||||
|
from _compression import BaseStream
|
||||||
|
from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer
|
||||||
|
from collections.abc import Iterable
|
||||||
|
from typing import IO, Any, Literal, Protocol, SupportsIndex, TextIO, final, overload
|
||||||
|
from typing_extensions import Self, TypeAlias
|
||||||
|
|
||||||
|
__all__ = ["BZ2File", "BZ2Compressor", "BZ2Decompressor", "open", "compress", "decompress"]
|
||||||
|
|
||||||
|
# The following attributes and methods are optional:
|
||||||
|
# def fileno(self) -> int: ...
|
||||||
|
# def close(self) -> object: ...
|
||||||
|
class _ReadableFileobj(_compression._Reader, Protocol): ...
|
||||||
|
|
||||||
|
class _WritableFileobj(Protocol):
|
||||||
|
def write(self, b: bytes, /) -> object: ...
|
||||||
|
# The following attributes and methods are optional:
|
||||||
|
# def fileno(self) -> int: ...
|
||||||
|
# def close(self) -> object: ...
|
||||||
|
|
||||||
|
def compress(data: ReadableBuffer, compresslevel: int = 9) -> bytes: ...
|
||||||
|
def decompress(data: ReadableBuffer) -> bytes: ...
|
||||||
|
|
||||||
|
_ReadBinaryMode: TypeAlias = Literal["", "r", "rb"]
|
||||||
|
_WriteBinaryMode: TypeAlias = Literal["w", "wb", "x", "xb", "a", "ab"]
|
||||||
|
_ReadTextMode: TypeAlias = Literal["rt"]
|
||||||
|
_WriteTextMode: TypeAlias = Literal["wt", "xt", "at"]
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def open(
|
||||||
|
filename: _ReadableFileobj,
|
||||||
|
mode: _ReadBinaryMode = "rb",
|
||||||
|
compresslevel: int = 9,
|
||||||
|
encoding: None = None,
|
||||||
|
errors: None = None,
|
||||||
|
newline: None = None,
|
||||||
|
) -> BZ2File: ...
|
||||||
|
@overload
|
||||||
|
def open(
|
||||||
|
filename: _ReadableFileobj,
|
||||||
|
mode: _ReadTextMode,
|
||||||
|
compresslevel: int = 9,
|
||||||
|
encoding: str | None = None,
|
||||||
|
errors: str | None = None,
|
||||||
|
newline: str | None = None,
|
||||||
|
) -> TextIO: ...
|
||||||
|
@overload
|
||||||
|
def open(
|
||||||
|
filename: _WritableFileobj,
|
||||||
|
mode: _WriteBinaryMode,
|
||||||
|
compresslevel: int = 9,
|
||||||
|
encoding: None = None,
|
||||||
|
errors: None = None,
|
||||||
|
newline: None = None,
|
||||||
|
) -> BZ2File: ...
|
||||||
|
@overload
|
||||||
|
def open(
|
||||||
|
filename: _WritableFileobj,
|
||||||
|
mode: _WriteTextMode,
|
||||||
|
compresslevel: int = 9,
|
||||||
|
encoding: str | None = None,
|
||||||
|
errors: str | None = None,
|
||||||
|
newline: str | None = None,
|
||||||
|
) -> TextIO: ...
|
||||||
|
@overload
|
||||||
|
def open(
|
||||||
|
filename: StrOrBytesPath,
|
||||||
|
mode: _ReadBinaryMode | _WriteBinaryMode = "rb",
|
||||||
|
compresslevel: int = 9,
|
||||||
|
encoding: None = None,
|
||||||
|
errors: None = None,
|
||||||
|
newline: None = None,
|
||||||
|
) -> BZ2File: ...
|
||||||
|
@overload
|
||||||
|
def open(
|
||||||
|
filename: StrOrBytesPath,
|
||||||
|
mode: _ReadTextMode | _WriteTextMode,
|
||||||
|
compresslevel: int = 9,
|
||||||
|
encoding: str | None = None,
|
||||||
|
errors: str | None = None,
|
||||||
|
newline: str | None = None,
|
||||||
|
) -> TextIO: ...
|
||||||
|
@overload
|
||||||
|
def open(
|
||||||
|
filename: StrOrBytesPath | _ReadableFileobj | _WritableFileobj,
|
||||||
|
mode: str,
|
||||||
|
compresslevel: int = 9,
|
||||||
|
encoding: str | None = None,
|
||||||
|
errors: str | None = None,
|
||||||
|
newline: str | None = None,
|
||||||
|
) -> BZ2File | TextIO: ...
|
||||||
|
|
||||||
|
class BZ2File(BaseStream, IO[bytes]):
|
||||||
|
def __enter__(self) -> Self: ...
|
||||||
|
if sys.version_info >= (3, 9):
|
||||||
|
@overload
|
||||||
|
def __init__(self, filename: _WritableFileobj, mode: _WriteBinaryMode, *, compresslevel: int = 9) -> None: ...
|
||||||
|
@overload
|
||||||
|
def __init__(self, filename: _ReadableFileobj, mode: _ReadBinaryMode = "r", *, compresslevel: int = 9) -> None: ...
|
||||||
|
@overload
|
||||||
|
def __init__(
|
||||||
|
self, filename: StrOrBytesPath, mode: _ReadBinaryMode | _WriteBinaryMode = "r", *, compresslevel: int = 9
|
||||||
|
) -> None: ...
|
||||||
|
else:
|
||||||
|
@overload
|
||||||
|
def __init__(
|
||||||
|
self, filename: _WritableFileobj, mode: _WriteBinaryMode, buffering: Any | None = None, compresslevel: int = 9
|
||||||
|
) -> None: ...
|
||||||
|
@overload
|
||||||
|
def __init__(
|
||||||
|
self, filename: _ReadableFileobj, mode: _ReadBinaryMode = "r", buffering: Any | None = None, compresslevel: int = 9
|
||||||
|
) -> None: ...
|
||||||
|
@overload
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
filename: StrOrBytesPath,
|
||||||
|
mode: _ReadBinaryMode | _WriteBinaryMode = "r",
|
||||||
|
buffering: Any | None = None,
|
||||||
|
compresslevel: int = 9,
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
def read(self, size: int | None = -1) -> bytes: ...
|
||||||
|
def read1(self, size: int = -1) -> bytes: ...
|
||||||
|
def readline(self, size: SupportsIndex = -1) -> bytes: ... # type: ignore[override]
|
||||||
|
def readinto(self, b: WriteableBuffer) -> int: ...
|
||||||
|
def readlines(self, size: SupportsIndex = -1) -> list[bytes]: ...
|
||||||
|
def seek(self, offset: int, whence: int = 0) -> int: ...
|
||||||
|
def write(self, data: ReadableBuffer) -> int: ...
|
||||||
|
def writelines(self, seq: Iterable[ReadableBuffer]) -> None: ...
|
||||||
|
|
||||||
|
@final
|
||||||
|
class BZ2Compressor:
|
||||||
|
def __init__(self, compresslevel: int = ...) -> None: ...
|
||||||
|
def compress(self, data: ReadableBuffer, /) -> bytes: ...
|
||||||
|
def flush(self) -> bytes: ...
|
||||||
|
|
||||||
|
@final
|
||||||
|
class BZ2Decompressor:
|
||||||
|
def decompress(self, data: ReadableBuffer, max_length: int = -1) -> bytes: ...
|
||||||
|
@property
|
||||||
|
def eof(self) -> bool: ...
|
||||||
|
@property
|
||||||
|
def needs_input(self) -> bool: ...
|
||||||
|
@property
|
||||||
|
def unused_data(self) -> bytes: ...
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue