diff --git a/python/helpers/typeshed/.flake8 b/python/helpers/typeshed/.flake8
index cb6908cf9b78..c3f4ab2b86e8 100644
--- a/python/helpers/typeshed/.flake8
+++ b/python/helpers/typeshed/.flake8
@@ -1,7 +1,6 @@
[flake8]
# Y: Flake8 is only used to run flake8-pyi, everything else is in Ruff
-# F821: Typeshed is a testing ground for flake8-pyi, which monkeypatches F821
-select = Y, F821
+select = Y
# Ignore rules normally excluded by default
extend-ignore = Y090,Y091
per-file-ignores =
diff --git a/python/helpers/typeshed/.gitattributes b/python/helpers/typeshed/.gitattributes
index f2de17522641..19c9bb2b07f7 100644
--- a/python/helpers/typeshed/.gitattributes
+++ b/python/helpers/typeshed/.gitattributes
@@ -4,6 +4,5 @@
# Set linguist-language to support comments syntax highlight
**/stubtest_allowlist*.txt linguist-language=ini
**/stubtest_allowlists/*.txt linguist-language=ini
-tests/pytype_exclude_list.txt linguist-language=ini
pyrightconfig*.json linguist-language=jsonc
.vscode/*.json linguist-language=jsonc
diff --git a/python/helpers/typeshed/.github/renovate.json5 b/python/helpers/typeshed/.github/renovate.json5
index 5b0e2d1e7956..0a0312fbc32c 100644
--- a/python/helpers/typeshed/.github/renovate.json5
+++ b/python/helpers/typeshed/.github/renovate.json5
@@ -24,15 +24,15 @@
{
groupName: "most test/lint dependencies",
matchManagers: ["pip_requirements", "pre-commit"],
- matchPackageNames: ["!pytype", "!pyright"],
+ matchPackageNames: ["!pyright"],
description: "Quarterly update of most test dependencies",
schedule: ["every 3 months on the first day of the month"]
},
{
- "groupName": "pytype and pyright",
+ "groupName": "pyright",
"matchManagers": ["pip_requirements"],
- "matchPackageNames": ["pytype", "pyright"],
- "description": "Daily update of pyright and pytype",
+ "matchPackageNames": ["pyright"],
+ "description": "Daily update of pyright",
"schedule": ["before 4am"]
}
]
diff --git a/python/helpers/typeshed/.github/workflows/daily.yml b/python/helpers/typeshed/.github/workflows/daily.yml
index ef19a9129ea6..88e73adec5e5 100644
--- a/python/helpers/typeshed/.github/workflows/daily.yml
+++ b/python/helpers/typeshed/.github/workflows/daily.yml
@@ -80,23 +80,26 @@ jobs:
if [ "${{ runner.os }}" = "Linux" ]; then
if [ -n "$PACKAGES" ]; then
+ printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
fi
PYTHON_EXECUTABLE="xvfb-run python"
else
if [ "${{ runner.os }}" = "macOS" ] && [ -n "$PACKAGES" ]; then
+ printf "Installing Homebrew packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
brew install -q $PACKAGES
fi
if [ "${{ runner.os }}" = "Windows" ] && [ -n "$PACKAGES" ]; then
+ printf "Installing Chocolatey packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
choco install -y $PACKAGES
fi
PYTHON_EXECUTABLE="python"
fi
- $PYTHON_EXECUTABLE tests/stubtest_third_party.py --specified-platforms-only --num-shards 4 --shard-index ${{ matrix.shard-index }}
+ $PYTHON_EXECUTABLE tests/stubtest_third_party.py --ci-platforms-only --num-shards 4 --shard-index ${{ matrix.shard-index }}
stub-uploader:
name: stub_uploader tests
@@ -117,6 +120,8 @@ jobs:
# Keep in sync with stub_uploader's check_scripts.yml workflow.
python-version: "3.13"
- uses: astral-sh/setup-uv@v6
+ with:
+ version-file: "typeshed/requirements-tests.txt"
- name: Run tests
run: |
cd stub_uploader
diff --git a/python/helpers/typeshed/.github/workflows/meta_tests.yml b/python/helpers/typeshed/.github/workflows/meta_tests.yml
index dd368ed0cdde..136979c4074b 100644
--- a/python/helpers/typeshed/.github/workflows/meta_tests.yml
+++ b/python/helpers/typeshed/.github/workflows/meta_tests.yml
@@ -39,7 +39,9 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- - run: curl -LsSf https://astral.sh/uv/install.sh | sh
+ - uses: astral-sh/setup-uv@v6
+ with:
+ version-file: "requirements-tests.txt"
- run: uv pip install -r requirements-tests.txt --system
- run: python ./tests/typecheck_typeshed.py --platform=${{ matrix.platform }}
pyright:
@@ -53,10 +55,10 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
- # TODO: Since pytype is not available for Python 3.13, and
- # pytype_test.py imports pytype, we need to use Python 3.12 for now.
- python-version: "3.12"
- - run: curl -LsSf https://astral.sh/uv/install.sh | sh
+ python-version: "3.13"
+ - uses: astral-sh/setup-uv@v6
+ with:
+ version-file: "requirements-tests.txt"
- run: uv pip install -r requirements-tests.txt --system
- name: Run pyright on typeshed
uses: jakebailey/pyright-action@v2
@@ -73,7 +75,9 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- - run: curl -LsSf https://astral.sh/uv/install.sh | sh
+ - uses: astral-sh/setup-uv@v6
+ with:
+ version-file: "requirements-tests.txt"
- name: Git config
run: |
git config --global user.name stubsabot
diff --git a/python/helpers/typeshed/.github/workflows/stubsabot.yml b/python/helpers/typeshed/.github/workflows/stubsabot.yml
index 3648d5168aba..afe21e71574a 100644
--- a/python/helpers/typeshed/.github/workflows/stubsabot.yml
+++ b/python/helpers/typeshed/.github/workflows/stubsabot.yml
@@ -27,7 +27,9 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- - run: curl -LsSf https://astral.sh/uv/install.sh | sh
+ - uses: astral-sh/setup-uv@v6
+ with:
+ version-file: "requirements-tests.txt"
- name: git config
run: |
git config --global user.name stubsabot
diff --git a/python/helpers/typeshed/.github/workflows/stubtest_third_party.yml b/python/helpers/typeshed/.github/workflows/stubtest_third_party.yml
index 69ec7c6ac625..12ba22e2b85b 100644
--- a/python/helpers/typeshed/.github/workflows/stubtest_third_party.yml
+++ b/python/helpers/typeshed/.github/workflows/stubtest_third_party.yml
@@ -66,26 +66,26 @@ jobs:
if [ "${{ runner.os }}" = "Linux" ]; then
if [ -n "$PACKAGES" ]; then
- echo "Installing apt packages: $PACKAGES"
+ printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
fi
PYTHON_EXECUTABLE="xvfb-run python"
else
if [ "${{ runner.os }}" = "macOS" ] && [ -n "$PACKAGES" ]; then
- echo "Installing Homebrew packages: $PACKAGES"
+ printf "Installing Homebrew packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
brew install -q $PACKAGES
fi
if [ "${{ runner.os }}" = "Windows" ] && [ -n "$PACKAGES" ]; then
- echo "Installing Chocolatey packages: $PACKAGES"
+ printf "Installing Chocolatey packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
choco install -y $PACKAGES
fi
PYTHON_EXECUTABLE="python"
fi
- $PYTHON_EXECUTABLE tests/stubtest_third_party.py --specified-platforms-only $STUBS
+ $PYTHON_EXECUTABLE tests/stubtest_third_party.py --ci-platforms-only $STUBS
else
echo "Nothing to test"
fi
diff --git a/python/helpers/typeshed/.github/workflows/tests.yml b/python/helpers/typeshed/.github/workflows/tests.yml
index dffdbc58e56e..6f5e3d408598 100644
--- a/python/helpers/typeshed/.github/workflows/tests.yml
+++ b/python/helpers/typeshed/.github/workflows/tests.yml
@@ -30,31 +30,12 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- - run: curl -LsSf https://astral.sh/uv/install.sh | sh
+ - uses: astral-sh/setup-uv@v6
+ with:
+ version-file: "requirements-tests.txt"
- run: uv pip install -r requirements-tests.txt --system
- run: python ./tests/check_typeshed_structure.py
- pytype:
- name: "pytype: Check stubs"
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- - uses: actions/setup-python@v5
- with:
- # Max supported Python version as of pytype 2024.10.11
- python-version: "3.12"
- - uses: astral-sh/setup-uv@v6
- - run: uv pip install -r requirements-tests.txt --system
- - name: Install external dependencies for 3rd-party stubs
- run: |
- DEPENDENCIES=$( python tests/get_external_stub_requirements.py )
- if [ -n "$DEPENDENCIES" ]; then
- printf "Installing packages:\n $(echo $DEPENDENCIES | sed 's/ /\n /g')\n"
- uv pip install --system $DEPENDENCIES
- fi
- - run: uv pip freeze
- - run: ./tests/pytype_test.py --print-stderr
-
mypy:
name: "mypy: Check stubs"
runs-on: ubuntu-latest
@@ -69,15 +50,16 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- - run: curl -LsSf https://astral.sh/uv/install.sh | sh
+ - uses: astral-sh/setup-uv@v6
+ with:
+ version-file: "requirements-tests.txt"
- run: uv pip install -r requirements-tests.txt --system
- name: Install required APT packages
run: |
- sudo apt-get update -qy
- DEPENDENCIES=$( python tests/get_external_apt_dependencies.py )
- if [ -n "$DEPENDENCIES" ]; then
- printf "Installing APT packages:\n $(echo $DEPENDENCIES | sed 's/ /\n /g')\n"
- sudo apt-get install -qy $DEPENDENCIES
+ PACKAGES=$(python tests/get_stubtest_system_requirements.py)
+ if [ -n "$PACKAGES" ]; then
+ printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
+ sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
fi
- name: Run mypy_test.py
run: |
@@ -102,7 +84,9 @@ jobs:
# Use py311 for now, as py312 seems to be around 30s slower in CI
# TODO: figure out why that is (#11590)
python-version: "3.11"
- - run: curl -LsSf https://astral.sh/uv/install.sh | sh
+ - uses: astral-sh/setup-uv@v6
+ with:
+ version-file: "requirements-tests.txt"
- run: uv pip install -r requirements-tests.txt --system
- run: python ./tests/regr_test.py --all --verbosity QUIET
@@ -120,25 +104,26 @@ jobs:
with:
python-version: "3.13"
- uses: astral-sh/setup-uv@v6
+ with:
+ version-file: "requirements-tests.txt"
- name: Install typeshed test-suite requirements
- # Install these so we can run `get_external_stub_requirements.py`
+ # Install these so we can run `get_*_requirements.py`
run: uv pip install -r requirements-tests.txt --system
- name: Install required APT packages
run: |
- sudo apt-get update -qy
- DEPENDENCIES=$( python tests/get_external_apt_dependencies.py )
- if [ -n "$DEPENDENCIES" ]; then
- printf "Installing APT packages:\n $(echo $DEPENDENCIES | sed 's/ /\n /g')\n"
- sudo apt-get install -qy $DEPENDENCIES
+ PACKAGES=$(python tests/get_stubtest_system_requirements.py)
+ if [ -n "$PACKAGES" ]; then
+ printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
+ sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
fi
- name: Create an isolated venv for testing
run: uv venv .venv
- name: Install 3rd-party stub dependencies
run: |
- DEPENDENCIES=$( python tests/get_external_stub_requirements.py )
- if [ -n "$DEPENDENCIES" ]; then
- printf "Installing packages:\n $(echo $DEPENDENCIES | sed 's/ /\n /g')\n"
- uv pip install --python-version ${{ matrix.python-version }} $DEPENDENCIES
+ PACKAGES=$(python tests/get_external_stub_requirements.py)
+ if [ -n "$PACKAGES" ]; then
+ printf "Installing python packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
+ uv pip install --python-version ${{ matrix.python-version }} $PACKAGES
fi
- name: Activate the isolated venv for the rest of the job
run: echo "$PWD/.venv/bin" >> $GITHUB_PATH
@@ -186,6 +171,8 @@ jobs:
# Keep in sync with stub_uploader's check_scripts.yml workflow.
python-version: "3.13"
- uses: astral-sh/setup-uv@v6
+ with:
+ version-file: "typeshed/requirements-tests.txt"
- name: Run tests
run: |
cd stub_uploader
diff --git a/python/helpers/typeshed/.pre-commit-config.yaml b/python/helpers/typeshed/.pre-commit-config.yaml
index 133c3c6fcdd2..123a94d3013d 100644
--- a/python/helpers/typeshed/.pre-commit-config.yaml
+++ b/python/helpers/typeshed/.pre-commit-config.yaml
@@ -11,7 +11,7 @@ repos:
args: [--fix=lf]
- id: check-case-conflict
- repo: https://github.com/astral-sh/ruff-pre-commit
- rev: v0.11.4 # must match requirements-tests.txt
+ rev: v0.12.2 # must match requirements-tests.txt
hooks:
- id: ruff
name: Run ruff on stubs, tests and scripts
@@ -31,7 +31,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
- rev: 7.2.0
+ rev: 7.3.0
hooks:
- id: flake8
language: python
diff --git a/python/helpers/typeshed/CONTRIBUTING.md b/python/helpers/typeshed/CONTRIBUTING.md
index 1df9c33807e7..0b87fec53767 100644
--- a/python/helpers/typeshed/CONTRIBUTING.md
+++ b/python/helpers/typeshed/CONTRIBUTING.md
@@ -77,19 +77,12 @@ Note that some tests require extra setup steps to install the required dependenc
Run the following commands from a Windows terminal to install all requirements:
```powershell
- > python -m venv .venv
+ > py -m venv .venv
> .venv\Scripts\activate
- (.venv) > pip install -U pip
+ (.venv) > python -m pip install -U pip
(.venv) > pip install -r requirements-tests.txt
```
- To be able to run pytype tests, you'll also need to install it manually
-as it's currently excluded from the requirements file:
-
- ```powershell
- (.venv) > pip install -U pytype
- ```
-
@@ -104,10 +97,6 @@ as it's currently excluded from the requirements file:
uv pip install -r requirements-tests.txt
```
- ```shell
- uv pip install -U pytype
- ```
-
@@ -224,18 +213,22 @@ This has the following keys:
that need to be installed for stubtest to run successfully
* `choco_dependencies` (default: `[]`): A list of Windows Chocolatey packages
that need to be installed for stubtest to run successfully
-* `platforms` (default: `["linux"]`): A list of OSes on which to run stubtest.
- Can contain `win32`, `linux`, and `darwin` values.
- If not specified, stubtest is run only on `linux`.
- Only add extra OSes to the test
- if there are platform-specific branches in a stubs package.
+* `supported_platforms` (default: all platforms): A list of OSes on which
+ stubtest can be run. When a package is not platform-specific, this should
+ not be set. If the package is platform-specific, this should usually be set
+ to the supported platforms, unless stubtest is known to fail on a
+ specific platform.
+* `ci_platforms` (default: `["linux"]`): A list of OSes on which to run
+ stubtest as part of our continuous integration (CI) tests. Can contain
+ `win32`, `linux`, and `darwin` values. If not specified, stubtest is run
+ only on `linux`. Only add extra OSes to the test if there are
+ platform-specific branches in a stubs package.
* `mypy_plugins` (default: `[]`): A list of Python modules to use as mypy plugins
when running stubtest. For example: `mypy_plugins = ["mypy_django_plugin.main"]`
* `mypy_plugins_config` (default: `{}`): A dictionary mapping plugin names to their
configuration dictionaries for use by mypy plugins. For example:
`mypy_plugins_config = {"django-stubs" = {"django_settings_module" = "@tests.django_settings"}}`
-
`*_dependencies` are usually packages needed to `pip install` the implementation
distribution.
@@ -463,7 +456,8 @@ steps:
4. When a new version of the package was automatically uploaded to PyPI
(which can take up to a day), open a PR to remove the stubs.
-If feeling kindly, please update [mypy](https://github.com/python/mypy/blob/master/mypy/stubinfo.py)
+Don't forget to make sure the library is not in the [`pyrightconfig.stricter.json`](./pyrightconfig.stricter.json)
+exclusion list. If feeling kindly, please update [mypy](https://github.com/python/mypy/blob/master/mypy/stubinfo.py)
for any stub obsoletions or removals.
### Marking PRs as "deferred"
diff --git a/python/helpers/typeshed/MAINTAINERS.md b/python/helpers/typeshed/MAINTAINERS.md
index 52e86aeaf8ea..d99e7601d070 100644
--- a/python/helpers/typeshed/MAINTAINERS.md
+++ b/python/helpers/typeshed/MAINTAINERS.md
@@ -5,6 +5,7 @@ At present the active maintainers are (alphabetically):
* Ivan Levkivskyi (@ilevkivskyi)
* Sebastian Rittau (@srittau)
* Guido van Rossum (@gvanrossum)
+* Brian Schubert (@brianschubert)
* Shantanu (@hauntsaninja)
* Nikita Sobolev (@sobolevn)
* Samuel Therrien (@Avasam)
diff --git a/python/helpers/typeshed/README.md b/python/helpers/typeshed/README.md
index ee09529b967a..1467aa20b4af 100644
--- a/python/helpers/typeshed/README.md
+++ b/python/helpers/typeshed/README.md
@@ -25,9 +25,9 @@ Typeshed supports Python versions 3.9 to 3.14.
## 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
+If you're just using a type checker (e.g. [mypy](https://github.com/python/mypy/),
+[pyright](https://github.com/microsoft/pyright), or PyCharm's built-in type
+checker), 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
diff --git a/python/helpers/typeshed/lib/ts_utils/metadata.py b/python/helpers/typeshed/lib/ts_utils/metadata.py
index da1a15af0f30..1b700021640c 100644
--- a/python/helpers/typeshed/lib/ts_utils/metadata.py
+++ b/python/helpers/typeshed/lib/ts_utils/metadata.py
@@ -5,8 +5,10 @@
from __future__ import annotations
+import datetime
import functools
import re
+import sys
import urllib.parse
from collections.abc import Mapping
from dataclasses import dataclass
@@ -14,10 +16,15 @@ from pathlib import Path
from typing import Annotated, Any, Final, NamedTuple, final
from typing_extensions import TypeGuard
-import tomli
+if sys.version_info >= (3, 11):
+ import tomllib
+else:
+ import tomli as tomllib
+
import tomlkit
from packaging.requirements import Requirement
from packaging.specifiers import Specifier
+from tomlkit.items import String
from .paths import PYPROJECT_PATH, STUBS_PATH, distribution_path
@@ -26,12 +33,14 @@ __all__ = [
"PackageDependencies",
"StubMetadata",
"StubtestSettings",
+ "get_oldest_supported_python",
"get_recursive_requirements",
"read_dependencies",
"read_metadata",
"read_stubtest_settings",
]
+DEFAULT_STUBTEST_PLATFORMS = ["linux"]
_STUBTEST_PLATFORM_MAPPING: Final = {"linux": "apt_dependencies", "darwin": "brew_dependencies", "win32": "choco_dependencies"}
# Some older websites have a bad pattern of using query params for navigation.
@@ -49,7 +58,7 @@ def _is_nested_dict(obj: object) -> TypeGuard[dict[str, dict[str, Any]]]:
@functools.cache
def get_oldest_supported_python() -> str:
with PYPROJECT_PATH.open("rb") as config:
- val = tomli.load(config)["tool"]["typeshed"]["oldest_supported_python"]
+ val = tomllib.load(config)["tool"]["typeshed"]["oldest_supported_python"]
assert type(val) is str
return val
@@ -73,7 +82,8 @@ class StubtestSettings:
choco_dependencies: list[str]
extras: list[str]
ignore_missing_stub: bool
- platforms: list[str]
+ supported_platforms: list[str] | None # None means all platforms
+ ci_platforms: list[str]
stubtest_requirements: list[str]
mypy_plugins: list[str]
mypy_plugins_config: dict[str, dict[str, Any]]
@@ -89,7 +99,7 @@ class StubtestSettings:
def read_stubtest_settings(distribution: str) -> StubtestSettings:
"""Return an object describing the stubtest settings for a single stubs distribution."""
with metadata_path(distribution).open("rb") as f:
- data: dict[str, object] = tomli.load(f).get("tool", {}).get("stubtest", {})
+ data: dict[str, object] = tomllib.load(f).get("tool", {}).get("stubtest", {})
skip: object = data.get("skip", False)
apt_dependencies: object = data.get("apt_dependencies", [])
@@ -97,7 +107,8 @@ def read_stubtest_settings(distribution: str) -> StubtestSettings:
choco_dependencies: object = data.get("choco_dependencies", [])
extras: object = data.get("extras", [])
ignore_missing_stub: object = data.get("ignore_missing_stub", False)
- specified_platforms: object = data.get("platforms", ["linux"])
+ supported_platforms: object = data.get("supported_platforms")
+ ci_platforms: object = data.get("ci_platforms", DEFAULT_STUBTEST_PLATFORMS)
stubtest_requirements: object = data.get("stubtest_requirements", [])
mypy_plugins: object = data.get("mypy_plugins", [])
mypy_plugins_config: object = data.get("mypy_plugins_config", {})
@@ -106,7 +117,8 @@ def read_stubtest_settings(distribution: str) -> StubtestSettings:
assert type(ignore_missing_stub) is bool
# It doesn't work for type-narrowing if we use a for loop here...
- assert _is_list_of_strings(specified_platforms)
+ assert supported_platforms is None or _is_list_of_strings(supported_platforms)
+ assert _is_list_of_strings(ci_platforms)
assert _is_list_of_strings(apt_dependencies)
assert _is_list_of_strings(brew_dependencies)
assert _is_list_of_strings(choco_dependencies)
@@ -115,11 +127,16 @@ def read_stubtest_settings(distribution: str) -> StubtestSettings:
assert _is_list_of_strings(mypy_plugins)
assert _is_nested_dict(mypy_plugins_config)
- unrecognised_platforms = set(specified_platforms) - _STUBTEST_PLATFORM_MAPPING.keys()
- assert not unrecognised_platforms, f"Unrecognised platforms specified for {distribution!r}: {unrecognised_platforms}"
+ unrecognised_platforms = set(ci_platforms) - _STUBTEST_PLATFORM_MAPPING.keys()
+ assert not unrecognised_platforms, f"Unrecognised ci_platforms specified for {distribution!r}: {unrecognised_platforms}"
+
+ if supported_platforms is not None:
+ assert set(ci_platforms).issubset(
+ supported_platforms
+ ), f"ci_platforms must be a subset of supported_platforms for {distribution!r}"
for platform, dep_key in _STUBTEST_PLATFORM_MAPPING.items():
- if platform not in specified_platforms:
+ if platform not in ci_platforms:
assert dep_key not in data, (
f"Stubtest is not run on {platform} in CI for {distribution!r}, "
f"but {dep_key!r} are specified in METADATA.toml"
@@ -132,13 +149,21 @@ def read_stubtest_settings(distribution: str) -> StubtestSettings:
choco_dependencies=choco_dependencies,
extras=extras,
ignore_missing_stub=ignore_missing_stub,
- platforms=specified_platforms,
+ supported_platforms=supported_platforms,
+ ci_platforms=ci_platforms,
stubtest_requirements=stubtest_requirements,
mypy_plugins=mypy_plugins,
mypy_plugins_config=mypy_plugins_config,
)
+@final
+@dataclass(frozen=True)
+class ObsoleteMetadata:
+ since_version: Annotated[str, "A string representing a specific version"]
+ since_date: Annotated[datetime.date, "A date when the package became obsolete"]
+
+
@final
@dataclass(frozen=True)
class StubMetadata:
@@ -153,7 +178,7 @@ class StubMetadata:
extra_description: str | None
stub_distribution: Annotated[str, "The name under which the distribution is uploaded to PyPI"]
upstream_repository: Annotated[str, "The URL of the upstream repository"] | None
- obsolete_since: Annotated[str, "A string representing a specific version"] | None
+ obsolete: Annotated[ObsoleteMetadata, "Metadata indicating when the stubs package became obsolete"] | None
no_longer_updated: bool
uploaded_to_pypi: Annotated[bool, "Whether or not a distribution is uploaded to PyPI"]
partial_stub: Annotated[bool, "Whether this is a partial type stub package as per PEP 561."]
@@ -162,7 +187,7 @@ class StubMetadata:
@property
def is_obsolete(self) -> bool:
- return self.obsolete_since is not None
+ return self.obsolete is not None
_KNOWN_METADATA_FIELDS: Final = frozenset(
@@ -189,7 +214,8 @@ _KNOWN_METADATA_TOOL_FIELDS: Final = {
"choco_dependencies",
"extras",
"ignore_missing_stub",
- "platforms",
+ "supported_platforms",
+ "ci_platforms",
"stubtest_requirements",
"mypy_plugins",
"mypy_plugins_config",
@@ -213,7 +239,7 @@ def read_metadata(distribution: str) -> StubMetadata:
"""
try:
with metadata_path(distribution).open("rb") as f:
- data: dict[str, object] = tomli.load(f)
+ data = tomlkit.load(f)
except FileNotFoundError:
raise NoSuchStubError(f"Typeshed has no stubs for {distribution!r}!") from None
@@ -221,7 +247,7 @@ def read_metadata(distribution: str) -> StubMetadata:
assert not unknown_metadata_fields, f"Unexpected keys in METADATA.toml for {distribution!r}: {unknown_metadata_fields}"
assert "version" in data, f"Missing 'version' field in METADATA.toml for {distribution!r}"
- version = data["version"]
+ version: object = data.get("version") # pyright: ignore[reportUnknownMemberType]
assert isinstance(version, str) and len(version) > 0, f"Invalid 'version' field in METADATA.toml for {distribution!r}"
# Check that the version spec parses
if version[0].isdigit():
@@ -229,11 +255,11 @@ def read_metadata(distribution: str) -> StubMetadata:
version_spec = Specifier(version)
assert version_spec.operator in {"==", "~="}, f"Invalid 'version' field in METADATA.toml for {distribution!r}"
- requires_s: object = data.get("requires", [])
+ requires_s: object = data.get("requires", []) # pyright: ignore[reportUnknownMemberType]
assert isinstance(requires_s, list)
requires = [parse_requires(distribution, req) for req in requires_s]
- extra_description: object = data.get("extra_description")
+ extra_description: object = data.get("extra_description") # pyright: ignore[reportUnknownMemberType]
assert isinstance(extra_description, (str, type(None)))
if "stub_distribution" in data:
@@ -243,7 +269,7 @@ def read_metadata(distribution: str) -> StubMetadata:
else:
stub_distribution = f"types-{distribution}"
- upstream_repository: object = data.get("upstream_repository")
+ upstream_repository: object = data.get("upstream_repository") # pyright: ignore[reportUnknownMemberType]
assert isinstance(upstream_repository, (str, type(None)))
if isinstance(upstream_repository, str):
parsed_url = urllib.parse.urlsplit(upstream_repository)
@@ -267,21 +293,28 @@ def read_metadata(distribution: str) -> StubMetadata:
)
assert num_url_path_parts == 2, bad_github_url_msg
- obsolete_since: object = data.get("obsolete_since")
- assert isinstance(obsolete_since, (str, type(None)))
- no_longer_updated: object = data.get("no_longer_updated", False)
+ obsolete_since: object = data.get("obsolete_since") # pyright: ignore[reportUnknownMemberType]
+ assert isinstance(obsolete_since, (String, type(None)))
+ if obsolete_since:
+ comment = obsolete_since.trivia.comment
+ since_date_string = comment.removeprefix("# Released on ")
+ since_date = datetime.date.fromisoformat(since_date_string)
+ obsolete = ObsoleteMetadata(since_version=obsolete_since, since_date=since_date)
+ else:
+ obsolete = None
+ no_longer_updated: object = data.get("no_longer_updated", False) # pyright: ignore[reportUnknownMemberType]
assert type(no_longer_updated) is bool
- uploaded_to_pypi: object = data.get("upload", True)
+ uploaded_to_pypi: object = data.get("upload", True) # pyright: ignore[reportUnknownMemberType]
assert type(uploaded_to_pypi) is bool
- partial_stub: object = data.get("partial_stub", True)
+ partial_stub: object = data.get("partial_stub", True) # pyright: ignore[reportUnknownMemberType]
assert type(partial_stub) is bool
- requires_python_str: object = data.get("requires_python")
+ requires_python_str: object = data.get("requires_python") # pyright: ignore[reportUnknownMemberType]
oldest_supported_python = get_oldest_supported_python()
oldest_supported_python_specifier = Specifier(f">={oldest_supported_python}")
if requires_python_str is None:
requires_python = oldest_supported_python_specifier
else:
- assert type(requires_python_str) is str
+ assert isinstance(requires_python_str, str)
requires_python = Specifier(requires_python_str)
assert requires_python != oldest_supported_python_specifier, f'requires_python="{requires_python}" is redundant'
# Check minimum Python version is not less than the oldest version of Python supported by typeshed
@@ -291,7 +324,7 @@ def read_metadata(distribution: str) -> StubMetadata:
assert requires_python.operator == ">=", "'requires_python' should be a minimum version specifier, use '>=3.x'"
empty_tools: dict[object, object] = {}
- tools_settings: object = data.get("tool", empty_tools)
+ tools_settings: object = data.get("tool", empty_tools) # pyright: ignore[reportUnknownMemberType]
assert isinstance(tools_settings, dict)
assert tools_settings.keys() <= _KNOWN_METADATA_TOOL_FIELDS.keys(), f"Unrecognised tool for {distribution!r}"
for tool, tk in _KNOWN_METADATA_TOOL_FIELDS.items():
@@ -307,7 +340,7 @@ def read_metadata(distribution: str) -> StubMetadata:
extra_description=extra_description,
stub_distribution=stub_distribution,
upstream_repository=upstream_repository,
- obsolete_since=obsolete_since,
+ obsolete=obsolete,
no_longer_updated=no_longer_updated,
uploaded_to_pypi=uploaded_to_pypi,
partial_stub=partial_stub,
diff --git a/python/helpers/typeshed/lib/ts_utils/mypy.py b/python/helpers/typeshed/lib/ts_utils/mypy.py
index 39f4255ec011..5bfcfc1528c8 100644
--- a/python/helpers/typeshed/lib/ts_utils/mypy.py
+++ b/python/helpers/typeshed/lib/ts_utils/mypy.py
@@ -1,10 +1,14 @@
from __future__ import annotations
+import sys
from collections.abc import Generator, Iterable
from contextlib import contextmanager
from typing import Any, NamedTuple
-import tomli
+if sys.version_info >= (3, 11):
+ import tomllib
+else:
+ import tomli as tomllib
from ts_utils.metadata import StubtestSettings, metadata_path
from ts_utils.utils import NamedTemporaryFile, TemporaryFileWrapper
@@ -26,7 +30,7 @@ class MypyDistConf(NamedTuple):
def mypy_configuration_from_distribution(distribution: str) -> list[MypyDistConf]:
with metadata_path(distribution).open("rb") as f:
- data = tomli.load(f)
+ data = tomllib.load(f)
# TODO: This could be added to ts_utils.metadata
mypy_tests_conf: dict[str, dict[str, Any]] = data.get("mypy-tests", {})
diff --git a/python/helpers/typeshed/lib/ts_utils/paths.py b/python/helpers/typeshed/lib/ts_utils/paths.py
index 568a091a5ae6..3a9a65e32181 100644
--- a/python/helpers/typeshed/lib/ts_utils/paths.py
+++ b/python/helpers/typeshed/lib/ts_utils/paths.py
@@ -12,6 +12,7 @@ STUBS_PATH: Final = TS_BASE_PATH / "stubs"
PYPROJECT_PATH: Final = TS_BASE_PATH / "pyproject.toml"
REQUIREMENTS_PATH: Final = TS_BASE_PATH / "requirements-tests.txt"
GITIGNORE_PATH: Final = TS_BASE_PATH / ".gitignore"
+PYRIGHT_CONFIG: Final = TS_BASE_PATH / "pyrightconfig.stricter.json"
TESTS_DIR: Final = "@tests"
TEST_CASES_DIR: Final = "test_cases"
diff --git a/python/helpers/typeshed/lib/ts_utils/requirements.py b/python/helpers/typeshed/lib/ts_utils/requirements.py
index e1af0f1ea290..e592bd73ad54 100644
--- a/python/helpers/typeshed/lib/ts_utils/requirements.py
+++ b/python/helpers/typeshed/lib/ts_utils/requirements.py
@@ -18,11 +18,12 @@ def get_external_stub_requirements(distributions: Iterable[str] = ()) -> set[Req
return set(itertools.chain.from_iterable([read_dependencies(distribution).external_pkgs for distribution in distributions]))
-def get_stubtest_system_requirements(distributions: Iterable[str] = (), platform: str = sys.platform) -> list[str]:
+def get_stubtest_system_requirements(distributions: Iterable[str] = (), platform: str = sys.platform) -> set[str]:
if not distributions:
distributions = os.listdir(STUBS_PATH)
- requirements: list[str] = []
- for distribution in distributions:
- requirements.extend(read_stubtest_settings(distribution).system_requirements_for_platform(platform))
- return requirements
+ return set(
+ itertools.chain.from_iterable(
+ [read_stubtest_settings(distribution).system_requirements_for_platform(platform) for distribution in distributions]
+ )
+ )
diff --git a/python/helpers/typeshed/lib/ts_utils/utils.py b/python/helpers/typeshed/lib/ts_utils/utils.py
index 11d47acdfaff..94936cd92057 100644
--- a/python/helpers/typeshed/lib/ts_utils/utils.py
+++ b/python/helpers/typeshed/lib/ts_utils/utils.py
@@ -50,6 +50,10 @@ def print_info(message: str) -> None:
print(colored(message, "blue"))
+def print_warning(message: str) -> None:
+ print(colored(message, "yellow"))
+
+
def print_error(error: str, end: str = "\n", fix_path: tuple[str, str] = ("", "")) -> None:
error_split = error.split("\n")
old, new = fix_path
diff --git a/python/helpers/typeshed/pyproject.toml b/python/helpers/typeshed/pyproject.toml
index b4a430f7510c..c523ec07b934 100644
--- a/python/helpers/typeshed/pyproject.toml
+++ b/python/helpers/typeshed/pyproject.toml
@@ -23,7 +23,6 @@ exclude = [
# cache directories, etc.:
".git",
".mypy_cache",
- ".pytype",
]
[tool.ruff.lint]
@@ -159,6 +158,8 @@ ignore = [
# Used for direct, non-subclass type comparison, for example: `type(val) is str`
# see https://github.com/astral-sh/ruff/issues/6465
"E721", # Do not compare types, use `isinstance()`
+ # Highly opinionated, and it's often necessary to violate it
+ "PLC0415", # `import` should be at the top-level of a file
# Leave the size and complexity of tests to human interpretation
"PLR09", # Too many ...
# Too many magic number "2" that are preferable inline. https://github.com/astral-sh/ruff/issues/10009
@@ -176,6 +177,7 @@ ignore = [
"TRY003", # Avoid specifying long messages outside the exception class
# Slower and more verbose https://github.com/astral-sh/ruff/issues/7871
"UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)`
+ "PLC0205", # Sometimes __slots__ really is a string at runtime
###
# False-positives, but already checked by type-checkers
###
diff --git a/python/helpers/typeshed/pyrightconfig.stricter.json b/python/helpers/typeshed/pyrightconfig.stricter.json
index 9682568f3f9c..99c3312723cc 100644
--- a/python/helpers/typeshed/pyrightconfig.stricter.json
+++ b/python/helpers/typeshed/pyrightconfig.stricter.json
@@ -18,28 +18,22 @@
"stdlib/optparse.pyi",
"stdlib/_tkinter.pyi",
"stdlib/tkinter/__init__.pyi",
- "stdlib/tkinter/commondialog.pyi",
"stdlib/tkinter/filedialog.pyi",
"stdlib/tkinter/dialog.pyi",
- "stdlib/tkinter/messagebox.pyi",
"stdlib/tkinter/scrolledtext.pyi",
"stdlib/tkinter/tix.pyi",
"stdlib/tkinter/ttk.pyi",
- "stubs/aiofiles",
"stubs/antlr4-python3-runtime",
"stubs/auth0-python",
"stubs/Authlib",
"stubs/aws-xray-sdk",
- "stubs/beautifulsoup4",
"stubs/boltons",
"stubs/braintree",
"stubs/cffi",
- "stubs/click-web",
"stubs/dateparser",
"stubs/defusedxml",
"stubs/docker",
"stubs/docutils",
- "stubs/flake8-typing-imports",
"stubs/Flask-SocketIO",
"stubs/fpdf2",
"stubs/gdb",
@@ -55,11 +49,10 @@
"stubs/httplib2",
"stubs/hvac",
"stubs/icalendar",
- "stubs/jmespath",
"stubs/jsonschema",
"stubs/jwcrypto",
"stubs/ldap3",
- "stubs/m3u8",
+ "stubs/m3u8/m3u8/model.pyi",
"stubs/Markdown",
"stubs/mock/mock/mock.pyi",
"stubs/mysqlclient",
@@ -76,6 +69,7 @@
"stubs/peewee",
"stubs/pexpect",
"stubs/pika",
+ "stubs/pony",
"stubs/protobuf",
"stubs/psutil",
"stubs/psycopg2",
@@ -83,14 +77,10 @@
"stubs/pycurl",
"stubs/Pygments",
"stubs/PyMySQL",
- "stubs/python-crontab",
- "stubs/python-datemath",
"stubs/python-dateutil",
- "stubs/python-http-client",
"stubs/python-jose",
"stubs/pytz/pytz/lazy.pyi",
"stubs/pywin32",
- "stubs/pyxdg",
"stubs/PyYAML",
"stubs/reportlab",
"stubs/requests",
@@ -102,7 +92,6 @@
"stubs/tqdm",
"stubs/vobject",
"stubs/workalendar",
- "stubs/wurlitzer",
],
"typeCheckingMode": "strict",
// TODO: Complete incomplete stubs
diff --git a/python/helpers/typeshed/requirements-tests.txt b/python/helpers/typeshed/requirements-tests.txt
index 33ec06e6fd8c..8fe57cf3624a 100644
--- a/python/helpers/typeshed/requirements-tests.txt
+++ b/python/helpers/typeshed/requirements-tests.txt
@@ -1,30 +1,28 @@
# Type checkers that we test our stubs against. These should always
# be pinned to a specific version to make failure reproducible.
-mypy==1.16.0
-pyright==1.1.400
-# pytype can be installed on Windows, but requires building wheels, let's not do that on the CI
-pytype==2024.10.11; platform_system != "Windows" and python_version >= "3.10" and python_version < "3.13"
+mypy==1.17.1
+pyright==1.1.404
# Libraries used by our various scripts.
# TODO (2025-05-09): Installing this on Python 3.14 on Windows fails at
# the moment.
-aiohttp==3.11.15; python_version < "3.14"
+aiohttp==3.12.14; python_version < "3.14"
# TODO (2025-05-09): No wheels exist for Python 3.14 yet, slowing down CI
# considerably and prone to fail.
grpcio-tools>=1.66.2; python_version < "3.14" # For grpc_tools.protoc
mypy-protobuf==3.6.0
-packaging==24.2
+packaging==25.0
pathspec>=0.11.1
pre-commit
# Required by create_baseline_stubs.py. Must match .pre-commit-config.yaml.
-ruff==0.11.4
+ruff==0.12.2
# TODO (2025-05-07): Dependency libcst doesn't support Python 3.14 yet.
stubdefaulter==0.1.0; python_version < "3.14"
termcolor>=2.3
-tomli==2.2.1
-tomlkit==0.13.2
-typing_extensions>=4.14.0rc1
-uv==0.7.4
+tomli==2.2.1; python_version < "3.11"
+tomlkit==0.13.3
+typing_extensions>=4.15.0rc1
+uv==0.8.6
# Utilities for typeshed infrastructure scripts.
ts_utils @ file:lib
diff --git a/python/helpers/typeshed/scripts/create_baseline_stubs.py b/python/helpers/typeshed/scripts/create_baseline_stubs.py
old mode 100755
new mode 100644
index db4fd9f3bf08..2928bb943b6e
--- a/python/helpers/typeshed/scripts/create_baseline_stubs.py
+++ b/python/helpers/typeshed/scripts/create_baseline_stubs.py
@@ -23,9 +23,7 @@ from pathlib import Path
import aiohttp
import termcolor
-from ts_utils.paths import STDLIB_PATH, STUBS_PATH
-
-PYRIGHT_CONFIG = Path("pyrightconfig.stricter.json")
+from ts_utils.paths import PYRIGHT_CONFIG, STDLIB_PATH, STUBS_PATH
def search_pip_freeze_output(project: str, output: str) -> tuple[str, str] | None:
diff --git a/python/helpers/typeshed/scripts/stubsabot.py b/python/helpers/typeshed/scripts/stubsabot.py
old mode 100755
new mode 100644
index 1ce147b0be65..03db0a667fe8
--- a/python/helpers/typeshed/scripts/stubsabot.py
+++ b/python/helpers/typeshed/scripts/stubsabot.py
@@ -3,6 +3,7 @@ from __future__ import annotations
import argparse
import asyncio
+import calendar
import contextlib
import datetime
import enum
@@ -10,33 +11,41 @@ import functools
import io
import os
import re
+import shutil
import subprocess
import sys
import tarfile
import textwrap
import urllib.parse
import zipfile
-from collections.abc import Iterator, Mapping, Sequence
+from collections.abc import Callable, Iterator, Mapping, Sequence
from dataclasses import dataclass, field
from http import HTTPStatus
from pathlib import Path
-from typing import Annotated, Any, ClassVar, NamedTuple
+from typing import Annotated, Any, ClassVar, Literal, NamedTuple, TypedDict, TypeVar
from typing_extensions import Self, TypeAlias
+if sys.version_info >= (3, 11):
+ import tomllib
+else:
+ import tomli as tomllib
+
import aiohttp
import packaging.version
import tomlkit
from packaging.specifiers import Specifier
from termcolor import colored
-from ts_utils.metadata import StubMetadata, read_metadata, update_metadata
-from ts_utils.paths import STUBS_PATH, distribution_path
+from ts_utils.metadata import ObsoleteMetadata, StubMetadata, read_metadata, update_metadata
+from ts_utils.paths import PYRIGHT_CONFIG, STUBS_PATH, distribution_path
TYPESHED_OWNER = "python"
TYPESHED_API_URL = f"https://api.github.com/repos/{TYPESHED_OWNER}/typeshed"
STUBSABOT_LABEL = "bot: stubsabot"
+POLICY_MONTHS_DELTA = 6
+
class ActionLevel(enum.IntEnum):
def __new__(cls, value: int, doc: str) -> Self:
@@ -128,7 +137,7 @@ class Update:
diff_analysis: DiffAnalysis | None
def __str__(self) -> str:
- return f"Updating {self.distribution} from {self.old_version_spec!r} to {self.new_version_spec!r}"
+ return f"{colored('updating', 'yellow')} from '{self.old_version_spec}' to '{self.new_version_spec}'"
@property
def new_version(self) -> str:
@@ -146,7 +155,17 @@ class Obsolete:
links: dict[str, str]
def __str__(self) -> str:
- return f"Marking {self.distribution} as obsolete since {self.obsolete_since_version!r}"
+ return f"{colored('marking as obsolete', 'yellow')} since {self.obsolete_since_version!r}"
+
+
+@dataclass
+class Remove:
+ distribution: str
+ reason: str
+ links: dict[str, str]
+
+ def __str__(self) -> str:
+ return f"{colored('removing', 'yellow')} ({self.reason})"
@dataclass
@@ -155,7 +174,48 @@ class NoUpdate:
reason: str
def __str__(self) -> str:
- return f"Skipping {self.distribution}: {self.reason}"
+ return f"{colored('skipping', 'green')} ({self.reason})"
+
+
+@dataclass
+class Error:
+ distribution: str
+ message: str
+
+ def __str__(self) -> str:
+ return f"{colored('error', 'red')} ({self.message})"
+
+
+_T = TypeVar("_T")
+
+
+async def with_extracted_archive(
+ release_to_download: PypiReleaseDownload,
+ *,
+ session: aiohttp.ClientSession,
+ handler: Callable[[zipfile.ZipFile | tarfile.TarFile], _T],
+) -> _T:
+ async with session.get(release_to_download.url) as response:
+ body = io.BytesIO(await response.read())
+
+ packagetype = release_to_download.packagetype
+ if packagetype == "bdist_wheel":
+ assert release_to_download.filename.endswith(".whl")
+ with zipfile.ZipFile(body) as zf:
+ return handler(zf)
+ elif packagetype == "sdist":
+ # sdist defaults to `.tar.gz` on Lunix and to `.zip` on Windows:
+ # https://docs.python.org/3.11/distutils/sourcedist.html
+ if release_to_download.filename.endswith(".tar.gz"):
+ with tarfile.open(fileobj=body, mode="r:gz") as zf:
+ return handler(zf)
+ elif release_to_download.filename.endswith(".zip"):
+ with zipfile.ZipFile(body) as zf:
+ return handler(zf)
+ else:
+ raise AssertionError(f"Package file {release_to_download.filename!r} does not end with '.tar.gz' or '.zip'")
+ else:
+ raise AssertionError(f"Unknown package type for {release_to_download.distribution}: {packagetype!r}")
def all_py_files_in_source_are_in_py_typed_dirs(source: zipfile.ZipFile | tarfile.TarFile) -> bool:
@@ -207,27 +267,7 @@ def all_py_files_in_source_are_in_py_typed_dirs(source: zipfile.ZipFile | tarfil
async def release_contains_py_typed(release_to_download: PypiReleaseDownload, *, session: aiohttp.ClientSession) -> bool:
- async with session.get(release_to_download.url) as response:
- body = io.BytesIO(await response.read())
-
- packagetype = release_to_download.packagetype
- if packagetype == "bdist_wheel":
- assert release_to_download.filename.endswith(".whl")
- with zipfile.ZipFile(body) as zf:
- return all_py_files_in_source_are_in_py_typed_dirs(zf)
- elif packagetype == "sdist":
- # sdist defaults to `.tar.gz` on Lunix and to `.zip` on Windows:
- # https://docs.python.org/3.11/distutils/sourcedist.html
- if release_to_download.filename.endswith(".tar.gz"):
- with tarfile.open(fileobj=body, mode="r:gz") as zf:
- return all_py_files_in_source_are_in_py_typed_dirs(zf)
- elif release_to_download.filename.endswith(".zip"):
- with zipfile.ZipFile(body) as zf:
- return all_py_files_in_source_are_in_py_typed_dirs(zf)
- else:
- raise AssertionError(f"Package file {release_to_download.filename!r} does not end with '.tar.gz' or '.zip'")
- else:
- raise AssertionError(f"Unknown package type for {release_to_download.distribution}: {packagetype!r}")
+ return await with_extracted_archive(release_to_download, session=session, handler=all_py_files_in_source_are_in_py_typed_dirs)
async def find_first_release_with_py_typed(pypi_info: PypiInfo, *, session: aiohttp.ClientSession) -> PypiReleaseDownload | None:
@@ -286,57 +326,80 @@ def get_github_api_headers() -> Mapping[str, str]:
return headers
+GitHost: TypeAlias = Literal["github", "gitlab"]
+
+
@dataclass
-class GitHubInfo:
+class GitHostInfo:
+ host: GitHost
repo_path: str
- tags: list[dict[str, Any]] = field(repr=False)
+ tags: list[str] = field(repr=False)
-async def get_github_repo_info(session: aiohttp.ClientSession, stub_info: StubMetadata) -> GitHubInfo | None:
+async def get_host_repo_info(session: aiohttp.ClientSession, stub_info: StubMetadata) -> GitHostInfo | None:
"""
- If the project represented by `stub_info` is hosted on GitHub,
- return information regarding the project as it exists on GitHub.
+ If the project represented by `stub_info` is publicly hosted (e.g. on GitHub)
+ return information regarding the project as it exists on the public host.
Else, return None.
"""
- if stub_info.upstream_repository:
- # We have various sanity checks for the upstream_repository field in ts_utils.metadata,
- # so no need to repeat all of them here
- split_url = urllib.parse.urlsplit(stub_info.upstream_repository)
- if split_url.netloc == "github.com":
- url_path = split_url.path.strip("/")
- assert len(Path(url_path).parts) == 2
- github_tags_info_url = f"https://api.github.com/repos/{url_path}/tags"
- async with session.get(github_tags_info_url, headers=get_github_api_headers()) as response:
- if response.status == HTTPStatus.OK:
- tags: list[dict[str, Any]] = await response.json()
- assert isinstance(tags, list)
- return GitHubInfo(repo_path=url_path, tags=tags)
+ if not stub_info.upstream_repository:
+ return None
+ # We have various sanity checks for the upstream_repository field in ts_utils.metadata,
+ # so no need to repeat all of them here
+ split_url = urllib.parse.urlsplit(stub_info.upstream_repository)
+ host = split_url.netloc.removesuffix(".com")
+ if host not in ("github", "gitlab"):
+ return None
+ url_path = split_url.path.strip("/")
+ assert len(Path(url_path).parts) == 2
+ if host == "github":
+ # https://docs.github.com/en/rest/git/tags
+ info_url = f"https://api.github.com/repos/{url_path}/tags"
+ headers = get_github_api_headers()
+ else:
+ assert host == "gitlab"
+ # https://docs.gitlab.com/api/tags/
+ project_id = urllib.parse.quote(url_path, safe="")
+ info_url = f"https://gitlab.com/api/v4/projects/{project_id}/repository/tags"
+ headers = None
+ async with session.get(info_url, headers=headers) as response:
+ if response.status == HTTPStatus.OK:
+ # Conveniently both GitHub and GitLab use the same key name.
+ tags = [tag["name"] for tag in await response.json()]
+ return GitHostInfo(host=host, repo_path=url_path, tags=tags) # type: ignore[arg-type]
return None
-class GitHubDiffInfo(NamedTuple):
+class GitHostDiffInfo(NamedTuple):
+ host: GitHost
repo_path: str
old_tag: str
new_tag: str
- diff_url: str
+
+ @property
+ def diff_url(self) -> str:
+ if self.host == "github":
+ return f"https://github.com/{self.repo_path}/compare/{self.old_tag}...{self.new_tag}"
+ else:
+ assert self.host == "gitlab"
+ return f"https://gitlab.com/{self.repo_path}/-/compare/{self.old_tag}...{self.new_tag}"
async def get_diff_info(
session: aiohttp.ClientSession, stub_info: StubMetadata, pypi_version: packaging.version.Version
-) -> GitHubDiffInfo | None:
+) -> GitHostDiffInfo | None:
"""Return a tuple giving info about the diff between two releases, if possible.
Return `None` if the project isn't hosted on GitHub,
or if a link pointing to the diff couldn't be found for any other reason.
"""
- github_info = await get_github_repo_info(session, stub_info)
- if github_info is None:
+ host_info = await get_host_repo_info(session, stub_info)
+ if host_info is None:
return None
versions_to_tags: dict[packaging.version.Version, str] = {}
- for tag in github_info.tags:
- tag_name = tag["name"]
+ for tag_name in host_info.tags:
# Some packages in typeshed have tag names
# that are invalid to be passed to the Version() constructor,
# e.g. v.1.4.2
@@ -355,11 +418,17 @@ async def get_diff_info(
else:
old_tag = versions_to_tags[old_version]
- diff_url = f"https://github.com/{github_info.repo_path}/compare/{old_tag}...{new_tag}"
- return GitHubDiffInfo(repo_path=github_info.repo_path, old_tag=old_tag, new_tag=new_tag, diff_url=diff_url)
+ return GitHostDiffInfo(host=host_info.host, repo_path=host_info.repo_path, old_tag=old_tag, new_tag=new_tag)
-FileInfo: TypeAlias = dict[str, Any]
+FileStatus: TypeAlias = Literal["added", "modified", "removed", "renamed"]
+
+
+class FileInfo(TypedDict):
+ filename: str
+ status: FileStatus
+ additions: int
+ deletions: int
def _plural_s(num: int, /) -> str:
@@ -454,10 +523,10 @@ class DiffAnalysis:
return "Stubsabot analysis of the diff between the two releases:\n - " + "\n - ".join(data_points)
-async def analyze_diff(
- github_repo_path: str, distribution: str, old_tag: str, new_tag: str, *, session: aiohttp.ClientSession
+async def analyze_github_diff(
+ repo_path: str, distribution: str, old_tag: str, new_tag: str, *, session: aiohttp.ClientSession
) -> DiffAnalysis | None:
- url = f"https://api.github.com/repos/{github_repo_path}/compare/{old_tag}...{new_tag}"
+ url = f"https://api.github.com/repos/{repo_path}/compare/{old_tag}...{new_tag}"
async with session.get(url, headers=get_github_api_headers()) as response:
response.raise_for_status()
json_resp: dict[str, list[FileInfo]] = await response.json()
@@ -470,12 +539,124 @@ async def analyze_diff(
return DiffAnalysis(py_files=py_files, py_files_stubbed_in_typeshed=py_files_stubbed_in_typeshed)
-async def determine_action(distribution: str, session: aiohttp.ClientSession) -> Update | NoUpdate | Obsolete:
+async def analyze_gitlab_diff(
+ repo_path: str, distribution: str, old_tag: str, new_tag: str, *, session: aiohttp.ClientSession
+) -> DiffAnalysis | None:
+ # https://docs.gitlab.com/api/repositories/#compare-branches-tags-or-commits
+ project_id = urllib.parse.quote(repo_path, safe="")
+ url = f"https://gitlab.com/api/v4/projects/{project_id}/repository/compare?from={old_tag}&to={new_tag}"
+ async with session.get(url) as response:
+ response.raise_for_status()
+ json_resp: dict[str, Any] = await response.json()
+ assert isinstance(json_resp, dict)
+
+ py_files: list[FileInfo] = []
+ for file_diff in json_resp["diffs"]:
+ filename = file_diff["new_path"]
+ if Path(filename).suffix != ".py":
+ continue
+ status: FileStatus
+ if file_diff["new_file"]:
+ status = "added"
+ elif file_diff["renamed_file"]:
+ status = "renamed"
+ elif file_diff["deleted_file"]:
+ status = "removed"
+ else:
+ status = "modified"
+ diff_lines = file_diff["diff"].splitlines()
+ additions = sum(1 for ln in diff_lines if ln.startswith("+"))
+ deletions = sum(1 for ln in diff_lines if ln.startswith("-"))
+ py_files.append(FileInfo(filename=filename, status=status, additions=additions, deletions=deletions))
+
+ stub_path = distribution_path(distribution)
+ files_in_typeshed = set(stub_path.rglob("*.pyi"))
+ py_files_stubbed_in_typeshed = [file for file in py_files if (stub_path / f"{file['filename']}i") in files_in_typeshed]
+ return DiffAnalysis(py_files=py_files, py_files_stubbed_in_typeshed=py_files_stubbed_in_typeshed)
+
+
+def _add_months(date: datetime.date, months: int) -> datetime.date:
+ month = date.month - 1 + months
+ year = date.year + month // 12
+ month = month % 12 + 1
+ day = min(date.day, calendar.monthrange(year, month)[1])
+ return datetime.date(year, month, day)
+
+
+def obsolete_more_than_n_months(since_date: datetime.date) -> bool:
+ remove_date = _add_months(since_date, POLICY_MONTHS_DELTA)
+ today = datetime.datetime.now(tz=datetime.timezone.utc).date()
+ return remove_date <= today
+
+
+def parse_no_longer_updated_from_archive(source: zipfile.ZipFile | tarfile.TarFile) -> bool:
+ if isinstance(source, zipfile.ZipFile):
+ try:
+ file = source.open("METADATA.toml", "r")
+ except KeyError:
+ return False
+ else:
+ try:
+ tarinfo = source.getmember("METADATA.toml")
+ file = source.extractfile(tarinfo) # type: ignore[assignment]
+ if file is None:
+ return False
+ except KeyError:
+ return False
+
+ with file as f:
+ toml_data: dict[str, object] = tomllib.load(f)
+
+ no_longer_updated = toml_data.get("no_longer_updated", False)
+ assert type(no_longer_updated) is bool
+ return bool(no_longer_updated)
+
+
+async def has_no_longer_updated_release(release_to_download: PypiReleaseDownload, *, session: aiohttp.ClientSession) -> bool:
+ """
+ Return `True` if the `no_longer_updated` field exists and the value is
+ `True` in the `METADATA.toml` file of latest `types-{distribution}` pypi release.
+ """
+ return await with_extracted_archive(release_to_download, session=session, handler=parse_no_longer_updated_from_archive)
+
+
+async def determine_action(distribution: str, session: aiohttp.ClientSession) -> Update | NoUpdate | Obsolete | Remove | Error:
+ try:
+ return await determine_action_no_error_handling(distribution, session)
+ except Exception as exc:
+ return Error(distribution, str(exc))
+
+
+async def determine_action_no_error_handling(
+ distribution: str, session: aiohttp.ClientSession
+) -> Update | NoUpdate | Obsolete | Remove:
stub_info = read_metadata(distribution)
if stub_info.is_obsolete:
- return NoUpdate(stub_info.distribution, "obsolete")
+ assert type(stub_info.obsolete) is ObsoleteMetadata
+ since_date = stub_info.obsolete.since_date
+
+ if obsolete_more_than_n_months(since_date):
+ pypi_info = await fetch_pypi_info(f"types-{stub_info.distribution}", session)
+ latest_release = pypi_info.get_latest_release()
+ links = {
+ "Typeshed release": f"{pypi_info.pypi_root}",
+ "Typeshed stubs": f"https://github.com/{TYPESHED_OWNER}/typeshed/tree/main/stubs/{stub_info.distribution}",
+ }
+ return Remove(stub_info.distribution, reason="older than 6 months", links=links)
+ else:
+ return NoUpdate(stub_info.distribution, "obsolete")
if stub_info.no_longer_updated:
- return NoUpdate(stub_info.distribution, "no longer updated")
+ pypi_info = await fetch_pypi_info(f"types-{stub_info.distribution}", session)
+ latest_release = pypi_info.get_latest_release()
+
+ if await has_no_longer_updated_release(latest_release, session=session):
+ links = {
+ "Typeshed release": f"{pypi_info.pypi_root}",
+ "Typeshed stubs": f"https://github.com/{TYPESHED_OWNER}/typeshed/tree/main/stubs/{stub_info.distribution}",
+ }
+ return Remove(stub_info.distribution, reason="no longer updated", links=links)
+ else:
+ return NoUpdate(stub_info.distribution, "no longer updated")
pypi_info = await fetch_pypi_info(stub_info.distribution, session)
latest_release = pypi_info.get_latest_release()
@@ -511,8 +692,9 @@ async def determine_action(distribution: str, session: aiohttp.ClientSession) ->
if diff_info is None:
diff_analysis: DiffAnalysis | None = None
else:
+ analyze_diff = {"github": analyze_github_diff, "gitlab": analyze_gitlab_diff}[diff_info.host]
diff_analysis = await analyze_diff(
- github_repo_path=diff_info.repo_path,
+ repo_path=diff_info.repo_path,
distribution=distribution,
old_tag=diff_info.old_tag,
new_tag=diff_info.new_tag,
@@ -683,6 +865,22 @@ def get_update_pr_body(update: Update, metadata: Mapping[str, Any]) -> str:
return body
+def remove_stubs(distribution: str) -> None:
+ stub_path = distribution_path(distribution)
+ target_path_prefix = f'"stubs/{distribution}'
+
+ if stub_path.exists() and stub_path.is_dir():
+ shutil.rmtree(stub_path)
+
+ with PYRIGHT_CONFIG.open("r", encoding="UTF-8") as f:
+ lines = f.readlines()
+
+ lines = [line for line in lines if not line.lstrip().startswith(target_path_prefix)]
+
+ with PYRIGHT_CONFIG.open("w", encoding="UTF-8") as f:
+ f.writelines(lines)
+
+
async def suggest_typeshed_update(update: Update, session: aiohttp.ClientSession, action_level: ActionLevel) -> None:
if action_level <= ActionLevel.nothing:
return
@@ -729,7 +927,29 @@ async def suggest_typeshed_obsolete(obsolete: Obsolete, session: aiohttp.ClientS
await create_or_update_pull_request(title=title, body=body, branch_name=branch_name, session=session)
-async def main() -> None:
+async def suggest_typeshed_remove(remove: Remove, session: aiohttp.ClientSession, action_level: ActionLevel) -> None:
+ if action_level <= ActionLevel.nothing:
+ return
+ title = f"[stubsabot] Remove {remove.distribution} as {remove.reason}"
+ async with _repo_lock:
+ branch_name = f"{BRANCH_PREFIX}/{normalize(remove.distribution)}"
+ subprocess.check_call(["git", "checkout", "-B", branch_name, "origin/main"])
+ remove_stubs(remove.distribution)
+ body = "\n".join(f"{k}: {v}" for k, v in remove.links.items())
+ subprocess.check_call(["git", "commit", "--all", "-m", f"{title}\n\n{body}"])
+ if action_level <= ActionLevel.local:
+ return
+ if not latest_commit_is_different_to_last_commit_on_origin(branch_name):
+ print(f"No pushing to origin required: origin/{branch_name} exists and requires no changes!")
+ return
+ somewhat_safe_force_push(branch_name)
+ if action_level <= ActionLevel.fork:
+ return
+
+ await create_or_update_pull_request(title=title, body=body, branch_name=branch_name, session=session)
+
+
+async def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument(
"--action-level",
@@ -758,11 +978,11 @@ async def main() -> None:
print("Unexpected exception!")
print(diff_result.stdout)
print(diff_result.stderr)
- sys.exit(diff_result.returncode)
+ return diff_result.returncode
if diff_result.stdout:
changed_files = ", ".join(repr(line) for line in diff_result.stdout.split("\n") if line)
print(f"Cannot run stubsabot, as uncommitted changes are present in {changed_files}!")
- sys.exit(1)
+ return 1
if args.action_level > ActionLevel.fork:
if os.environ.get("GITHUB_TOKEN") is None:
@@ -777,6 +997,8 @@ async def main() -> None:
if args.action_level >= ActionLevel.local:
subprocess.check_call(["git", "fetch", "--prune", "--all"])
+ error = False
+
try:
conn = aiohttp.TCPConnector(limit_per_host=10)
async with aiohttp.ClientSession(connector=conn) as session:
@@ -789,10 +1011,14 @@ async def main() -> None:
action_count = 0
for task in asyncio.as_completed(tasks):
update = await task
+ print(f"{update.distribution}... ", end="")
print(update)
if isinstance(update, NoUpdate):
continue
+ if isinstance(update, Error):
+ error = True
+ continue
if args.action_count_limit is not None and action_count >= args.action_count_limit:
print(colored("... but we've reached action count limit", "red"))
@@ -803,10 +1029,13 @@ async def main() -> None:
if isinstance(update, Update):
await suggest_typeshed_update(update, session, action_level=args.action_level)
continue
- # Redundant, but keeping for extra runtime validation
- if isinstance(update, Obsolete): # pyright: ignore[reportUnnecessaryIsInstance]
+ if isinstance(update, Obsolete):
await suggest_typeshed_obsolete(update, session, action_level=args.action_level)
continue
+ # Redundant, but keeping for extra runtime validation
+ if isinstance(update, Remove): # pyright: ignore[reportUnnecessaryIsInstance]
+ await suggest_typeshed_remove(update, session, action_level=args.action_level)
+ continue
except RemoteConflictError as e:
print(colored(f"... but ran into {type(e).__qualname__}: {e}", "red"))
continue
@@ -817,6 +1046,8 @@ async def main() -> None:
if args.action_level >= ActionLevel.local and original_branch:
subprocess.check_call(["git", "checkout", original_branch])
+ return 1 if error else 0
+
if __name__ == "__main__":
- asyncio.run(main())
+ sys.exit(asyncio.run(main()))
diff --git a/python/helpers/typeshed/scripts/sync_protobuf/google_protobuf.py b/python/helpers/typeshed/scripts/sync_protobuf/google_protobuf.py
old mode 100755
new mode 100644
diff --git a/python/helpers/typeshed/scripts/sync_protobuf/s2clientprotocol.py b/python/helpers/typeshed/scripts/sync_protobuf/s2clientprotocol.py
old mode 100755
new mode 100644
diff --git a/python/helpers/typeshed/scripts/sync_protobuf/tensorflow.py b/python/helpers/typeshed/scripts/sync_protobuf/tensorflow.py
old mode 100755
new mode 100644
diff --git a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/common.txt b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/common.txt
index 130c6d2b8285..4462ada9107e 100644
--- a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/common.txt
+++ b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/common.txt
@@ -195,6 +195,10 @@ _frozen_importlib_external.FileLoader.get_filename
_frozen_importlib_external.FileLoader.get_resource_reader
_frozen_importlib_external.FileLoader.load_module
+# Mismatch of default values of `report` parameter:
+_markupbase.ParserBase.parse_comment
+_markupbase.ParserBase.parse_marked_section
+
_pydecimal.* # See comments in file
_typeshed.* # Utility types for typeshed, doesn't exist at runtime
argparse.ArgumentParser.__init__ # stubtest doesn't recognise the runtime default (a class) as being compatible with a callback protocol (the stub annotation)
@@ -307,6 +311,7 @@ functools._lru_cache_wrapper.cache_parameters # Cannot be detected statically
functools.cached_property.__set__ # doesn't exist, but cached_property is settable by another mechanism
hmac.new # Raises TypeError if optional argument digestmod is not provided
+html.parser.HTMLParser.parse_bogus_comment # default values mismatch
http.HTTPStatus.description # set in __new__; work-around for enum wierdness
http.HTTPStatus.phrase # set in __new__; work-around for enum wierdness
imaplib.IMAP4_SSL.ssl # Depends on the existence and flags of SSL
@@ -461,11 +466,9 @@ typing._Final.__init_subclass__
typing\.Protocol
typing(_extensions)?\._TypedDict
typing(_extensions)?\.Any.*
-typing(_extensions)?\.Generic
typing(_extensions)?\.TypedDict
typing_extensions\.ParamSpec.*
typing_extensions\.TypeVar.*
-typing_extensions\._SpecialForm.*
# Special primitives
typing(_extensions)?\.AbstractSet
@@ -494,7 +497,6 @@ typing(_extensions)?\.Reversible
typing(_extensions)?\.Sequence
typing(_extensions)?\.Sized
typing(_extensions)?\.ValuesView
-typing_extensions\.Final
typing_extensions\.LiteralString
# Typing-related weirdness
diff --git a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/darwin-py310.txt b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/darwin-py310.txt
index 4b6bd6e0eea7..cc1ebe489923 100644
--- a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/darwin-py310.txt
+++ b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/darwin-py310.txt
@@ -1,6 +1,6 @@
-# ===========
-# 3.9 to 3.11
-# ===========
+# =======
+# <= 3.11
+# =======
# Added in Python 3.10.15
email._header_value_parser.NLSET
@@ -41,6 +41,7 @@ xml.etree.cElementTree.XMLPullParser.flush
xml.parsers.expat.XMLParserType.GetReparseDeferralEnabled
xml.parsers.expat.XMLParserType.SetReparseDeferralEnabled
xml.sax.expatreader.ExpatParser.flush
+zipfile.ZipInfo.__slots__
# =============================================================
diff --git a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/darwin-py311.txt b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/darwin-py311.txt
index 4a9eceb7b7d4..b778aba53259 100644
--- a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/darwin-py311.txt
+++ b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/darwin-py311.txt
@@ -8,12 +8,11 @@ fcntl.F_OFD_SETLK
fcntl.F_OFD_SETLKW
-# ===========
-# 3.9 to 3.11
-# ===========
+# =======
+# <= 3.11
+# =======
-# Incompatible changes introduced in Python 3.11.10
-# (Remove once 3.11.10 becomes available for MacOS)
+# Added in Python 3.11.10
email._header_value_parser.NLSET
email._header_value_parser.SPECIALSNL
email.errors.HeaderWriteError
diff --git a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/darwin-py314.txt b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/darwin-py314.txt
index 6db5ea944e34..bb7f4bba4c2f 100644
--- a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/darwin-py314.txt
+++ b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/darwin-py314.txt
@@ -1,10 +1,3 @@
-# ====================================================================
-# TODO: New errors in Python 3.14 that need to be fixed or moved below
-# ====================================================================
-
-asyncio.tools
-
-
# =======
# >= 3.13
# =======
diff --git a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/darwin-py39.txt b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/darwin-py39.txt
index 8deeed14226e..e11829830070 100644
--- a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/darwin-py39.txt
+++ b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/darwin-py39.txt
@@ -1,6 +1,6 @@
-# ===========
-# 3.9 to 3.11
-# ===========
+# =======
+# <= 3.11
+# =======
# Added in Python 3.9.20
email._header_value_parser.NLSET
@@ -50,6 +50,7 @@ xml.etree.cElementTree.XMLPullParser.flush
xml.parsers.expat.XMLParserType.GetReparseDeferralEnabled
xml.parsers.expat.XMLParserType.SetReparseDeferralEnabled
xml.sax.expatreader.ExpatParser.flush
+zipfile.ZipInfo.__slots__
# =============================================================
diff --git a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/linux-py314.txt b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/linux-py314.txt
deleted file mode 100644
index d2f10ffdcef1..000000000000
--- a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/linux-py314.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-# ====================================================================
-# TODO: New errors in Python 3.14 that need to be fixed or moved below
-# ====================================================================
-
-asyncio.tools
diff --git a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py310.txt b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py310.txt
index d2030f8713be..c21927d632f9 100644
--- a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py310.txt
+++ b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py310.txt
@@ -70,22 +70,11 @@ importlib.metadata._meta.SimplePath.__truediv__ # Runtime definition of protoco
# ===================================
-# ===========
-# 3.9 to 3.10
-# ===========
-
-builtins.float.__setformat__ # Internal method for CPython test suite
-typing._SpecialForm.__mro_entries__ # Exists at runtime, but missing from stubs
-
-# Will always raise. Not included to avoid type checkers inferring that
-# Sentinel instances are callable.
-typing_extensions.Sentinel.__call__
-
-
# =======
# <= 3.10
# =======
+builtins.float.__setformat__ # Internal method for CPython test suite
email.contentmanager.typ
gettext.install # codeset default value is ['unspecified'] so can't be specified
gettext.translation # codeset default value is ['unspecified'] so can't be specified
@@ -100,6 +89,11 @@ tempfile.SpooledTemporaryFile.seekable
tempfile.SpooledTemporaryFile.writable
tkinter.Tk.split # Exists at runtime, but missing from stubs
+typing._SpecialForm.__mro_entries__ # Exists at runtime, but missing from stubs
+
+# Will always raise. Not included to avoid type checkers inferring that
+# Sentinel instances are callable.
+typing_extensions.Sentinel.__call__
# =======
@@ -107,13 +101,14 @@ tkinter.Tk.split # Exists at runtime, but missing from stubs
# =======
_?bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
-configparser.ParsingError.filename
enum.Enum._generate_next_value_
importlib.abc.Finder.find_module
urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ # Args are passed as is to super, so super args are specified
xml.etree.ElementTree.Element.__bool__ # Doesn't really exist; see comments in stub
xml.etree.cElementTree.Element.__bool__ # Doesn't really exist; see comments in stub
+platform.platform # runtime default is 0, we pretend it's a bool
+
# =======
# <= 3.12
@@ -163,11 +158,7 @@ tkinter.tix.TkVersion
# because it's not an ABC that makes any sense and was deprecated in 3.12
_collections_abc.ByteString
-ast.Bytes.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
-ast.Ellipsis.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
-ast.NameConstant.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
-ast.Num.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
-ast.Str.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
+ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
@@ -215,13 +206,6 @@ importlib.metadata.DeprecatedList.sort
typing.ParamSpec(Args|Kwargs).__origin__
-# =================================================================
-# Allowlist entries that cannot or should not be fixed; 3.9 to 3.12
-# =================================================================
-
-typing\.Annotated # Super-special typing primitive
-
-
# =============================================================
# Allowlist entries that cannot or should not be fixed; <= 3.10
# =============================================================
@@ -276,6 +260,11 @@ typing_extensions\.TypeAliasType\.__(parameters|type_params|name|module|value)__
unittest.test # Modules that exist at runtime, but shouldn't be added to typeshed
unittest\.test\..+ # Modules that exist at runtime, but shouldn't be added to typeshed
+# Incompatible changes introduced in Python 3.10.17
+# (Remove once 3.10.17 becomes available for all platforms)
+(email._header_value_parser.get_encoded_word)?
+(email._header_value_parser.make_quoted_pairs)?
+
# =============================================================
# Allowlist entries that cannot or should not be fixed; <= 3.12
@@ -320,11 +309,7 @@ sunau.Au_write.initfp
threading.Lock # Factory function at runtime, but that wouldn't let us use it in type hints
types.SimpleNamespace.__init__ # class doesn't accept positional arguments but has default C signature
typing_extensions\.Annotated # Undocumented implementation details
-
-# Incompatible changes introduced in Python 3.10.17
-# (Remove once 3.10.17 becomes available for all platforms)
-(email._header_value_parser.get_encoded_word)?
-(email._header_value_parser.make_quoted_pairs)?
+typing\.Annotated # Super-special typing primitive
# These methods have no default implementation for Python < 3.13.
_pickle.Pickler.persistent_id
diff --git a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py311.txt b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py311.txt
index e4c26ccfcf1f..1072213189d8 100644
--- a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py311.txt
+++ b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py311.txt
@@ -7,7 +7,6 @@
# >= 3.11
# =======
-enum.Enum.__init__
typing.NewType.__mro_entries__
@@ -70,13 +69,14 @@ importlib.metadata._meta.SimplePath.__truediv__ # Runtime definition of protoco
# =======
_?bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
-configparser.ParsingError.filename
enum.Enum._generate_next_value_
importlib.abc.Finder.find_module
urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ # Args are passed as is to super, so super args are specified
xml.etree.ElementTree.Element.__bool__ # Doesn't really exist; see comments in stub
xml.etree.cElementTree.Element.__bool__ # Doesn't really exist; see comments in stub
+platform.platform # runtime default is 0, we pretend it's a bool
+
# =======
# <= 3.12
@@ -126,11 +126,7 @@ tkinter.tix.TkVersion
# because it's not an ABC that makes any sense and was deprecated in 3.12
_collections_abc.ByteString
-ast.Bytes.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
-ast.Ellipsis.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
-ast.NameConstant.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
-ast.Num.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
-ast.Str.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
+ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
@@ -143,11 +139,17 @@ typing\.ByteString
typing_extensions.TypeAliasType.__call__
+# ============
+# 3.11 to 3.13
+# ============
+
+enum.Enum.__init__
+
+
# =============================================================
# Allowlist entries that cannot or should not be fixed; >= 3.11
# =============================================================
-argparse._MutuallyExclusiveGroup.add_mutually_exclusive_group # deprecated, forwards arguments to super
enum.auto.__init__ # The stub for enum.auto is nothing like the implementation
enum.auto.value # The stub for enum.auto is nothing like the implementation
http.HTTPMethod.description # mutable instance attribute at runtime but we pretend it's a property
@@ -201,11 +203,11 @@ importlib.metadata.DeprecatedList.sort
typing.ParamSpec(Args|Kwargs).__origin__
-# =================================================================
-# Allowlist entries that cannot or should not be fixed; 3.9 to 3.12
-# =================================================================
+# ==================================================================
+# Allowlist entries that cannot or should not be fixed; 3.11 to 3.13
+# ==================================================================
-typing\.Annotated # Super-special typing primitive
+argparse._MutuallyExclusiveGroup.add_mutually_exclusive_group # deprecated, forwards arguments to super
# =============================================================
@@ -236,6 +238,11 @@ typing_extensions\.TypeAliasType\.__(parameters|type_params|name|module|value)__
unittest.test # Modules that exist at runtime, but shouldn't be added to typeshed
unittest\.test\..+ # Modules that exist at runtime, but shouldn't be added to typeshed
+# Incompatible changes introduced in Python 3.11.12
+# (Remove once 3.11.12 becomes available for all platforms)
+(email._header_value_parser.get_encoded_word)?
+(email._header_value_parser.make_quoted_pairs)?
+
# =============================================================
# Allowlist entries that cannot or should not be fixed; <= 3.12
@@ -280,11 +287,7 @@ sunau.Au_write.initfp
threading.Lock # Factory function at runtime, but that wouldn't let us use it in type hints
types.SimpleNamespace.__init__ # class doesn't accept positional arguments but has default C signature
typing_extensions\.Annotated # Undocumented implementation details
-
-# Incompatible changes introduced in Python 3.11.12
-# (Remove once 3.11.12 becomes available for all platforms)
-(email._header_value_parser.get_encoded_word)?
-(email._header_value_parser.make_quoted_pairs)?
+typing\.Annotated # Super-special typing primitive
# These methods have no default implementation for Python < 3.13.
_pickle.Pickler.persistent_id
diff --git a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py312.txt b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py312.txt
index 685a1bf41e75..079b286a0016 100644
--- a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py312.txt
+++ b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py312.txt
@@ -7,15 +7,20 @@
# >= 3.12
# =======
-# Initialized at runtime
-typing_extensions.TypeAliasType.__parameters__
-typing_extensions.TypeAliasType.__value__
-
# Types that require `__setattr__` and `__delattr__` for typing purposes:
types.SimpleNamespace.__setattr__
types.SimpleNamespace.__delattr__
+# ============
+# 3.12 to 3.13
+# ============
+
+# Initialized at runtime
+typing_extensions.TypeAliasType.__parameters__
+typing_extensions.TypeAliasType.__value__
+
+
# ====================================
# Pre-existing errors from Python 3.11
# ====================================
@@ -25,10 +30,16 @@ types.SimpleNamespace.__delattr__
# >= 3.11
# =======
-enum.Enum.__init__
typing.NewType.__mro_entries__
+# ============
+# 3.11 to 3.13
+# ============
+
+enum.Enum.__init__
+
+
# =======
# >= 3.10
# =======
@@ -111,11 +122,7 @@ tkinter.tix.TkVersion
# because it's not an ABC that makes any sense and was deprecated in 3.12
_collections_abc.ByteString
-ast.Bytes.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
-ast.Ellipsis.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
-ast.NameConstant.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
-ast.Num.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
-ast.Str.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
+ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
@@ -165,7 +172,6 @@ typing_extensions.SupportsRound.__type_params__
# Allowlist entries that cannot or should not be fixed; >= 3.11
# =============================================================
-argparse._MutuallyExclusiveGroup.add_mutually_exclusive_group # deprecated, forwards arguments to super
enum.auto.__init__ # The stub for enum.auto is nothing like the implementation
enum.auto.value # The stub for enum.auto is nothing like the implementation
http.HTTPMethod.description # mutable instance attribute at runtime but we pretend it's a property
@@ -175,6 +181,13 @@ typing\._SpecialForm.* # Super-special typing primitive
typing\.LiteralString # Super-special typing primitive
+# ==================================================================
+# Allowlist entries that cannot or should not be fixed; 3.11 to 3.13
+# ==================================================================
+
+argparse._MutuallyExclusiveGroup.add_mutually_exclusive_group # deprecated, forwards arguments to super
+
+
# =============================================================
# Allowlist entries that cannot or should not be fixed; >= 3.10
# =============================================================
@@ -206,13 +219,6 @@ ctypes._endian.SIZEOF_TIME_T # Incorrectly star import.
configparser.LegacyInterpolation.__init__ # runtime is *args, **kwargs, but it's just a passthrough
-# =================================================================
-# Allowlist entries that cannot or should not be fixed; 3.9 to 3.12
-# =================================================================
-
-typing\.Annotated # Super-special typing primitive
-
-
# =============================================================
# Allowlist entries that cannot or should not be fixed; <= 3.12
# =============================================================
@@ -256,6 +262,7 @@ sunau.Au_write.initfp
threading.Lock # Factory function at runtime, but that wouldn't let us use it in type hints
types.SimpleNamespace.__init__ # class doesn't accept positional arguments but has default C signature
typing_extensions\.Annotated # Undocumented implementation details
+typing\.Annotated # Super-special typing primitive
# These methods have no default implementation for Python < 3.13.
_pickle.Pickler.persistent_id
diff --git a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py313.txt b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py313.txt
index 282b91348758..4e5b4733e620 100644
--- a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py313.txt
+++ b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py313.txt
@@ -12,23 +12,34 @@
# >= 3.12
# =======
-# Initialized at runtime
-typing_extensions.TypeAliasType.__parameters__
-typing_extensions.TypeAliasType.__value__
-
# Types that require `__setattr__` and `__delattr__` for typing purposes:
types.SimpleNamespace.__setattr__
types.SimpleNamespace.__delattr__
+# ============
+# 3.12 to 3.13
+# ============
+
+# Initialized at runtime
+typing_extensions.TypeAliasType.__parameters__
+typing_extensions.TypeAliasType.__value__
+
+
# =======
# >= 3.11
# =======
-enum.Enum.__init__
typing.NewType.__mro_entries__
+# ============
+# 3.11 to 3.13
+# ============
+
+enum.Enum.__init__
+
+
# =======
# >= 3.10
# =======
@@ -72,11 +83,7 @@ typing(_extensions)?\.IO\.writelines
# because it's not an ABC that makes any sense and was deprecated in 3.12
_collections_abc.ByteString
-ast.Bytes.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
-ast.Ellipsis.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
-ast.NameConstant.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
-ast.Num.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
-ast.Str.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
+ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
@@ -155,7 +162,6 @@ typing_extensions.SupportsRound.__type_params__
# Allowlist entries that cannot or should not be fixed; >= 3.11
# =============================================================
-argparse._MutuallyExclusiveGroup.add_mutually_exclusive_group # deprecated, forwards arguments to super
enum.auto.__init__ # The stub for enum.auto is nothing like the implementation
enum.auto.value # The stub for enum.auto is nothing like the implementation
http.HTTPMethod.description # mutable instance attribute at runtime but we pretend it's a property
@@ -165,6 +171,13 @@ typing\._SpecialForm.* # Super-special typing primitive
typing\.LiteralString # Super-special typing primitive
+# ==================================================================
+# Allowlist entries that cannot or should not be fixed; 3.11 to 3.13
+# ==================================================================
+
+argparse._MutuallyExclusiveGroup.add_mutually_exclusive_group # deprecated, forwards arguments to super
+
+
# =============================================================
# Allowlist entries that cannot or should not be fixed; >= 3.10
# =============================================================
diff --git a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py314.txt b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py314.txt
index 788b34694be0..4c8421a6959a 100644
--- a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py314.txt
+++ b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py314.txt
@@ -12,13 +12,12 @@ multiprocessing.managers._BaseDictProxy.__ror__
multiprocessing.managers._BaseDictProxy.fromkeys
multiprocessing.process.BaseProcess.interrupt
multiprocessing.synchronize.SemLock.locked
-tarfile.TarFile.zstopen
+
# =========================
# New errors in Python 3.14
# =========================
-
# Union and UnionType are aliases in 3.14 but type checkers need some changes
typing_extensions.Union
typing.Union
@@ -30,6 +29,18 @@ types.UnionType.__qualname__
# Assigning `__new__` causes `func` not to get recognized.
functools.partialmethod.__new__
+# decorator approximated by classmethod
+concurrent.interpreters._crossinterp.classonly.*
+
+# object() sentinels at runtime represented by NewTypes in the stubs
+concurrent.interpreters._crossinterp.UNBOUND_ERROR
+concurrent.interpreters._crossinterp.UNBOUND_REMOVE
+concurrent.interpreters._queues.UNBOUND_ERROR
+concurrent.interpreters._queues.UNBOUND_REMOVE
+
+importlib.util.Loader.exec_module # See Lib/importlib/_abc.py. Might be defined for backwards compatibility
+
+
# ====================================
# Pre-existing errors from Python 3.13
# ====================================
@@ -57,7 +68,6 @@ typing.NewType.__mro_entries__
builtins.ellipsis # type is not exposed anywhere
importlib._abc.Loader.exec_module # See Lib/importlib/_abc.py. Might be defined for backwards compatibility
-importlib.util.Loader.exec_module
# positional-only complaints caused by differences between typing aliases and the "real" classes in the stdlib
_collections_abc.Coroutine.send
@@ -85,6 +95,7 @@ typing(_extensions)?\.IO\.truncate
typing(_extensions)?\.IO\.write
typing(_extensions)?\.IO\.writelines
+
# =============================================================
# Allowlist entries that cannot or should not be fixed; >= 3.14
# =============================================================
@@ -107,6 +118,45 @@ typing(_extensions)?\.IO\.writelines
(io|typing_extensions)\.Writer\.write
+# These multiprocessing proxy methods have *args, **kwargs signatures at runtime,
+# But have more precise (accurate) signatures in the stub
+multiprocessing.managers._BaseSetProxy.__iter__
+multiprocessing.managers._BaseSetProxy.__len__
+multiprocessing.managers._BaseSetProxy.clear
+multiprocessing.managers._BaseSetProxy.copy
+multiprocessing.managers._BaseSetProxy.pop
+
+
+# Changes from patch releases to be introduced in Python 3.14.0b3
+# (Remove once 3.14.0b3 becomes available for all platforms)
+(genericpath.__all__)?
+(genericpath.ALLOW_MISSING)?
+(ntpath.__all__)?
+(ntpath.ALLOW_MISSING)?
+(os.path.__all__)?
+(os.path.ALLOW_MISSING)?
+(os.path.realpath)?
+(posixpath.__all__)?
+(posixpath.ALLOW_MISSING)?
+(tarfile.__all__)?
+(tarfile.LinkFallbackError)?
+(tarfile.TarFile._extract_member)?
+(tarfile.TarFile.makelink_with_filter)?
+(_?hashlib.new)?
+(_?hashlib.(openssl_)?md5)?
+(_?hashlib.(openssl_)?sha1)?
+(_?hashlib.(openssl_)?sha224)?
+(_?hashlib.(openssl_)?sha256)?
+(_?hashlib.(openssl_)?sha384)?
+(_?hashlib.(openssl_)?sha3_224)?
+(_?hashlib.(openssl_)?sha3_256)?
+(_?hashlib.(openssl_)?sha3_384)?
+(_?hashlib.(openssl_)?sha3_512)?
+(_?hashlib.(openssl_)?sha512)?
+(_?hashlib.(openssl_)?shake_128)?
+(_?hashlib.(openssl_)?shake_256)?
+
+
# =============================================================
# Allowlist entries that cannot or should not be fixed; >= 3.13
# =============================================================
@@ -130,12 +180,6 @@ multiprocessing.managers._BaseDictProxy.keys
multiprocessing.managers._BaseDictProxy.popitem
multiprocessing.managers._BaseDictProxy.values
-multiprocessing.managers._BaseSetProxy.__iter__
-multiprocessing.managers._BaseSetProxy.__len__
-multiprocessing.managers._BaseSetProxy.clear
-multiprocessing.managers._BaseSetProxy.copy
-multiprocessing.managers._BaseSetProxy.pop
-
# To match `dict`, we lie about the runtime, but use overloads to match the correct behavior
types.MappingProxyType.get
@@ -202,32 +246,3 @@ builtins.property.__set_name__ # Doesn't actually exist
collections\.UserList\.index # ignoring pos-or-keyword parameter
dataclasses.KW_ONLY # white lies around defaults
importlib.metadata._meta.SimplePath.joinpath # Runtime definition of protocol is incorrect
-
-# Changes from patch releases to be introduced in Python 3.14.0b3
-# (Remove once 3.14.0b3 becomes available for all platforms)
-(genericpath.__all__)?
-(genericpath.ALLOW_MISSING)?
-(ntpath.__all__)?
-(ntpath.ALLOW_MISSING)?
-(os.path.__all__)?
-(os.path.ALLOW_MISSING)?
-(os.path.realpath)?
-(posixpath.__all__)?
-(posixpath.ALLOW_MISSING)?
-(tarfile.__all__)?
-(tarfile.LinkFallbackError)?
-(tarfile.TarFile._extract_member)?
-(tarfile.TarFile.makelink_with_filter)?
-(_?hashlib.new)?
-(_?hashlib.(openssl_)?md5)?
-(_?hashlib.(openssl_)?sha1)?
-(_?hashlib.(openssl_)?sha224)?
-(_?hashlib.(openssl_)?sha256)?
-(_?hashlib.(openssl_)?sha384)?
-(_?hashlib.(openssl_)?sha3_224)?
-(_?hashlib.(openssl_)?sha3_256)?
-(_?hashlib.(openssl_)?sha3_384)?
-(_?hashlib.(openssl_)?sha3_512)?
-(_?hashlib.(openssl_)?sha512)?
-(_?hashlib.(openssl_)?shake_128)?
-(_?hashlib.(openssl_)?shake_256)?
diff --git a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py39.txt b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py39.txt
index 37c1ec2ad171..8be1a91e8475 100644
--- a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py39.txt
+++ b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/py39.txt
@@ -23,12 +23,12 @@ collections.Callable
collections.Mapping.get # Adding None to the Union messed up mypy
collections.Sequence.index # Supporting None in end is not mandatory
-# ===========
+
+# =======
# <= 3.10
-# ===========
+# =======
builtins.float.__setformat__ # Internal method for CPython test suite
-typing._SpecialForm.__mro_entries__ # Exists at runtime, but missing from stubs
email.contentmanager.typ
gettext.install # codeset default value is ['unspecified'] so can't be specified
gettext.translation # codeset default value is ['unspecified'] so can't be specified
@@ -43,6 +43,7 @@ tempfile.SpooledTemporaryFile.seekable
tempfile.SpooledTemporaryFile.writable
tkinter.Tk.split # Exists at runtime, but missing from stubs
+typing._SpecialForm.__mro_entries__ # Exists at runtime, but missing from stubs
# Will always raise. Not included to avoid type checkers inferring that
# Sentinel instances are callable.
@@ -54,13 +55,14 @@ typing_extensions.Sentinel.__call__
# =======
_?bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
-configparser.ParsingError.filename
enum.Enum._generate_next_value_
importlib.abc.Finder.find_module
urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ # Args are passed as is to super, so super args are specified
xml.etree.ElementTree.Element.__bool__ # Doesn't really exist; see comments in stub
xml.etree.cElementTree.Element.__bool__ # Doesn't really exist; see comments in stub
+platform.platform # runtime default is 0, we pretend it's a bool
+
# =======
# <= 3.12
@@ -110,11 +112,7 @@ tkinter.tix.TkVersion
# because it's not an ABC that makes any sense and was deprecated in 3.12
_collections_abc.ByteString
-ast.Bytes.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
-ast.Ellipsis.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
-ast.NameConstant.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
-ast.Num.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
-ast.Str.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
+ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
@@ -134,18 +132,6 @@ typing_extensions.TypeAliasType.__call__
ast.FormattedValue.conversion # None on the class, but never None on instances
_ast.FormattedValue.conversion # None on the class, but never None on instances
-
-# =================================================================
-# Allowlist entries that cannot or should not be fixed; 3.9 to 3.12
-# =================================================================
-
-typing\.Annotated # Super-special typing primitive
-
-
-# ============================================================
-# Allowlist entries that cannot or should not be fixed; <= 3.9
-# ============================================================
-
_ssl.RAND_egd # Depends on the existence and flags of SSL
builtins.classmethod.__get__ # Runtime signature is incorrect (https://github.com/python/cpython/issues/93021)
builtins.property.__get__ # Runtime signature is incorrect (https://github.com/python/cpython/issues/93021)
@@ -227,6 +213,14 @@ typing_extensions\.TypeAliasType\.__(parameters|type_params|name|module|value)__
unittest.test # Modules that exist at runtime, but shouldn't be added to typeshed
unittest\.test\..+ # Modules that exist at runtime, but shouldn't be added to typeshed
+# Incompatible changes introduced in Python 3.9.22
+# (Remove once 3.9.22 becomes available for all platforms)
+(email._header_value_parser.get_encoded_word)?
+
+# Incompatible changes introduced in Python 3.9.23
+# (Remove once 3.9.23 becomes available for all platforms)
+(email._header_value_parser.make_quoted_pairs)?
+
# =============================================================
# Allowlist entries that cannot or should not be fixed; <= 3.12
@@ -271,10 +265,7 @@ sunau.Au_write.initfp
threading.Lock # Factory function at runtime, but that wouldn't let us use it in type hints
types.SimpleNamespace.__init__ # class doesn't accept positional arguments but has default C signature
typing_extensions\.Annotated # Undocumented implementation details
-
-# Incompatible changes introduced in Python 3.9.22
-# (Remove once 3.9.22 becomes available for all platforms)
-(email._header_value_parser.get_encoded_word)?
+typing\.Annotated # Super-special typing primitive
# These methods have no default implementation for Python < 3.13.
_pickle.Pickler.persistent_id
@@ -284,7 +275,6 @@ pickle.Unpickler.persistent_load
# Incompatible changes introduced in Python 3.9.23
# (Remove once 3.9.23 becomes available for all platforms)
-(email._header_value_parser.make_quoted_pairs)?
(genericpath.__all__)?
(genericpath.ALLOW_MISSING)?
(ntpath.__all__)?
diff --git a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/win32-py310.txt b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/win32-py310.txt
index 15005e65d04a..fea9f4e62e98 100644
--- a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/win32-py310.txt
+++ b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/win32-py310.txt
@@ -1,6 +1,6 @@
-# ===========
-# 3.9 to 3.11
-# ===========
+# =======
+# <= 3.11
+# =======
# Incompatible changes introduced in Python 3.10.15
# (Remove once 3.10.15 becomes available for Windows)
@@ -42,7 +42,7 @@ xml.etree.cElementTree.XMLPullParser.flush
xml.parsers.expat.XMLParserType.GetReparseDeferralEnabled
xml.parsers.expat.XMLParserType.SetReparseDeferralEnabled
xml.sax.expatreader.ExpatParser.flush
-
+zipfile.ZipInfo.__slots__
# =============================================================
# Allowlist entries that cannot or should not be fixed; <= 3.12
diff --git a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/win32-py311.txt b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/win32-py311.txt
index 5e882c194a66..fe33c11f3b6c 100644
--- a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/win32-py311.txt
+++ b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/win32-py311.txt
@@ -1,6 +1,6 @@
-# ===========
-# 3.9 to 3.11
-# ===========
+# =======
+# <= 3.11
+# =======
# Incompatible changes introduced in Python 3.11.10
# (Remove once 3.11.10 becomes available for Windows)
diff --git a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/win32-py314.txt b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/win32-py314.txt
index 055f91f97b78..070fce3e9c49 100644
--- a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/win32-py314.txt
+++ b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/win32-py314.txt
@@ -1,16 +1,3 @@
-# ====================================================================
-# TODO: New errors in Python 3.14 that need to be fixed or moved below
-# ====================================================================
-
-_winapi.COPY_FILE_DIRECTORY
-compression.zlib.ZLIBNG_VERSION
-encodings.win32_code_page_search_function
-nt.readinto
-pathlib.Path.group
-pathlib.Path.owner
-zlib.ZLIBNG_VERSION
-
-
# =======
# >= 3.12
# =======
diff --git a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/win32-py39.txt b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/win32-py39.txt
index 2d712bda1e01..9c12db83aa25 100644
--- a/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/win32-py39.txt
+++ b/python/helpers/typeshed/stdlib/@tests/stubtest_allowlists/win32-py39.txt
@@ -1,6 +1,6 @@
-# ===========
-# 3.9 to 3.11
-# ===========
+# =======
+# <= 3.11
+# =======
# Incompatible changes introduced in Python 3.9.20
# (Remove once 3.9.20 becomes available for Windows)
@@ -51,7 +51,7 @@ xml.etree.cElementTree.XMLPullParser.flush
xml.parsers.expat.XMLParserType.GetReparseDeferralEnabled
xml.parsers.expat.XMLParserType.SetReparseDeferralEnabled
xml.sax.expatreader.ExpatParser.flush
-
+zipfile.ZipInfo.__slots__
# =============================================================
# Allowlist entries that cannot or should not be fixed; <= 3.12
diff --git a/python/helpers/typeshed/stdlib/@tests/test_cases/builtins/check_dict.py b/python/helpers/typeshed/stdlib/@tests/test_cases/builtins/check_dict.py
index 2944730c7c67..fe74ad49408e 100644
--- a/python/helpers/typeshed/stdlib/@tests/test_cases/builtins/check_dict.py
+++ b/python/helpers/typeshed/stdlib/@tests/test_cases/builtins/check_dict.py
@@ -4,6 +4,10 @@ import os
from typing import Any, Dict, Generic, Iterable, Mapping, TypeVar, Union
from typing_extensions import Self, assert_type
+###################################################################
+# Note: tests for `dict.update()` are in `check_MutableMapping.py`.
+###################################################################
+
# These do follow `__init__` overloads order:
# mypy and pyright have different opinions about this one:
# mypy raises: 'Need type annotation for "bad"'
diff --git a/python/helpers/typeshed/stdlib/@tests/test_cases/builtins/check_min.py b/python/helpers/typeshed/stdlib/@tests/test_cases/builtins/check_min.py
new file mode 100644
index 000000000000..a300ad45c482
--- /dev/null
+++ b/python/helpers/typeshed/stdlib/@tests/test_cases/builtins/check_min.py
@@ -0,0 +1,94 @@
+from typing_extensions import assert_type
+
+
+def test_min_builtin() -> None:
+ # legal comparisons that succeed at runtime
+ b1, b2 = bool(True), bool(False)
+ i1, i2 = int(1), int(2)
+ s1, s2 = str("a"), str("b")
+ f1, f2 = float(0.5), float(2.3)
+ l1, l2 = list[int]([1, 2]), list[int]([3, 4])
+ t1, t2 = tuple[str, str](("A", "B")), tuple[str, str](("C", "D"))
+ tN = tuple[str, ...](["A", "B", "C"])
+
+ assert_type(min(b1, b2), bool)
+ assert_type(min(i1, i2), int)
+ assert_type(min(s1, s2), str)
+ assert_type(min(f1, f2), float)
+
+ # mixed numerical types (note: float = int or float)
+ assert_type(min(b1, i1), int)
+ assert_type(min(i1, b1), int)
+
+ assert_type(min(b1, f1), float)
+ assert_type(min(f1, b1), float)
+
+ assert_type(min(i1, f1), float)
+ assert_type(min(f1, i1), float)
+
+ # comparisons with lists and tuples
+ assert_type(min(l1, l2), list[int])
+ assert_type(min(t1, t2), tuple[str, str])
+ assert_type(min(tN, t2), tuple[str, ...])
+
+
+def test_min_bad_builtin() -> None:
+ # illegal comparisons that fail at runtime
+ i1 = int(1)
+ s1 = str("a")
+ f1 = float(1.0)
+ c1, c2 = complex(1.0, 2.0), complex(3.0, 4.0)
+ list_str = list[str](["A", "B"])
+ list_int = list[int]([2, 3])
+ tup_str = tuple[str, str](("A", "B"))
+ tup_int = tuple[int, int]((2, 3))
+
+ # True negatives.
+ min(c1, c2) # type: ignore
+
+ # FIXME: False negatives.
+ min(i1, s1)
+ min(s1, f1)
+ min(f1, list_str)
+ min(list_str, list_int)
+ min(tup_str, tup_int)
+
+
+def test_min_custom_comparison() -> None:
+ class BoolScalar:
+ def __bool__(self) -> bool: ...
+
+ class FloatScalar:
+ def __float__(self) -> float: ...
+ def __ge__(self, other: "FloatScalar") -> BoolScalar: ...
+ def __gt__(self, other: "FloatScalar") -> BoolScalar: ...
+ def __lt__(self, other: "FloatScalar") -> BoolScalar: ...
+ def __le__(self, other: "FloatScalar") -> BoolScalar: ...
+
+ f1 = FloatScalar()
+ f2 = FloatScalar()
+
+ assert_type(min(f1, f2), FloatScalar)
+
+
+def test_min_bad_custom_type() -> None:
+ class FloatScalar:
+ def __float__(self) -> float: ...
+ def __ge__(self, other: "FloatScalar") -> object:
+ return object()
+
+ def __gt__(self, other: "FloatScalar") -> object:
+ return object()
+
+ def __lt__(self, other: "FloatScalar") -> object:
+ return object()
+
+ def __le__(self, other: "FloatScalar") -> object:
+ return object()
+
+ f1 = FloatScalar()
+ f2 = FloatScalar()
+
+ # Note: min(f1, f2) works at runtime, but always returns the second argument.
+ # therefore, we require returning a boolean-like type for comparisons.
+ min(f1, f2) # type: ignore
diff --git a/python/helpers/typeshed/stdlib/@tests/test_cases/check_concurrent_futures.py b/python/helpers/typeshed/stdlib/@tests/test_cases/check_concurrent_futures.py
index ba6ca0845719..51a94b09d386 100644
--- a/python/helpers/typeshed/stdlib/@tests/test_cases/check_concurrent_futures.py
+++ b/python/helpers/typeshed/stdlib/@tests/test_cases/check_concurrent_futures.py
@@ -47,11 +47,11 @@ if sys.version_info >= (3, 14):
with InterpreterPoolExecutor(initializer=_initializer, initargs=("x",)): # type: ignore
...
- context = InterpreterPoolExecutor.prepare_context(initializer=_initializer, initargs=(1,), shared={})
+ context = InterpreterPoolExecutor.prepare_context(initializer=_initializer, initargs=(1,))
worker_context = context[0]()
assert_type(worker_context, concurrent.futures.interpreter.WorkerContext)
resolve_task = context[1]
- # Function should enfore that the arguments are correct.
+ # Function should enforce that the arguments are correct.
res = resolve_task(_initializer, 1)
assert_type(res, tuple[bytes, Literal["function"]])
# When the function is a script, the arguments should be a string.
diff --git a/python/helpers/typeshed/stdlib/@tests/test_cases/check_unittest.py b/python/helpers/typeshed/stdlib/@tests/test_cases/check_unittest.py
index 40c6efaa8ca0..d717e99a3f8d 100644
--- a/python/helpers/typeshed/stdlib/@tests/test_cases/check_unittest.py
+++ b/python/helpers/typeshed/stdlib/@tests/test_cases/check_unittest.py
@@ -5,9 +5,9 @@ from collections.abc import Iterator, Mapping
from datetime import datetime, timedelta
from decimal import Decimal
from fractions import Fraction
-from typing import TypedDict
+from typing import TypedDict, Union
from typing_extensions import assert_type
-from unittest.mock import MagicMock, Mock, patch
+from unittest.mock import AsyncMock, MagicMock, Mock, patch
case = unittest.TestCase()
@@ -154,10 +154,17 @@ def f_explicit_new(i: int) -> str:
return "asdf"
+@patch("sys.exit", new_callable=lambda: 42)
+def f_explicit_new_callable(i: int, new_callable_ret: int) -> str:
+ return "asdf"
+
+
assert_type(f_default_new(1), str)
f_default_new("a") # Not an error due to ParamSpec limitations
assert_type(f_explicit_new(1), str)
f_explicit_new("a") # type: ignore[arg-type]
+assert_type(f_explicit_new_callable(1), str)
+f_explicit_new_callable("a") # Same as default new
@patch("sys.exit", new=Mock())
@@ -171,3 +178,51 @@ class TestXYZ(unittest.TestCase):
assert_type(TestXYZ.attr, int)
assert_type(TestXYZ.method(), int)
+
+
+with patch("sys.exit") as default_new_enter:
+ assert_type(default_new_enter, Union[MagicMock, AsyncMock])
+
+with patch("sys.exit", new=42) as explicit_new_enter:
+ assert_type(explicit_new_enter, int)
+
+with patch("sys.exit", new_callable=lambda: 42) as explicit_new_callable_enter:
+ assert_type(explicit_new_callable_enter, int)
+
+
+###
+# Tests for mock.patch.object
+###
+
+
+@patch.object(Decimal, "exp")
+def obj_f_default_new(i: int, mock: MagicMock) -> str:
+ return "asdf"
+
+
+@patch.object(Decimal, "exp", new=42)
+def obj_f_explicit_new(i: int) -> str:
+ return "asdf"
+
+
+@patch.object(Decimal, "exp", new_callable=lambda: 42)
+def obj_f_explicit_new_callable(i: int, new_callable_ret: int) -> str:
+ return "asdf"
+
+
+assert_type(obj_f_default_new(1), str)
+obj_f_default_new("a") # Not an error due to ParamSpec limitations
+assert_type(obj_f_explicit_new(1), str)
+obj_f_explicit_new("a") # type: ignore[arg-type]
+assert_type(obj_f_explicit_new_callable(1), str)
+obj_f_explicit_new_callable("a") # Same as default new
+
+
+with patch.object(Decimal, "exp") as obj_default_new_enter:
+ assert_type(obj_default_new_enter, Union[MagicMock, AsyncMock])
+
+with patch.object(Decimal, "exp", new=42) as obj_explicit_new_enter:
+ assert_type(obj_explicit_new_enter, int)
+
+with patch.object(Decimal, "exp", new_callable=lambda: 42) as obj_explicit_new_callable_enter:
+ assert_type(obj_explicit_new_callable_enter, int)
diff --git a/python/helpers/typeshed/stdlib/@tests/test_cases/typing/check_MutableMapping.py b/python/helpers/typeshed/stdlib/@tests/test_cases/typing/check_MutableMapping.py
index d4f951060b35..1e9d747fc8f6 100644
--- a/python/helpers/typeshed/stdlib/@tests/test_cases/typing/check_MutableMapping.py
+++ b/python/helpers/typeshed/stdlib/@tests/test_cases/typing/check_MutableMapping.py
@@ -1,6 +1,6 @@
from __future__ import annotations
-from typing import Any, Union
+from typing import Any, Hashable, Sequence, Union
from typing_extensions import assert_type
@@ -30,6 +30,15 @@ def check_update_method__str_key() -> None:
d.update([("", "")]) # type: ignore
+def test_keywords_allowed_on_dict_update_where_key_type_is_str_supertype(
+ a: dict[object, Any], b: dict[Hashable, Any], c: dict[Sequence[str], Any], d: dict[str, Any]
+) -> None:
+ a.update(keyword_args_are_accepted="whatever")
+ b.update(here_too="whooo")
+ c.update(and_here="hooray")
+ d.update(also_here="yay")
+
+
def check_setdefault_method() -> None:
d: dict[int, str] = {}
d2: dict[int, str | None] = {}
diff --git a/python/helpers/typeshed/stdlib/VERSIONS b/python/helpers/typeshed/stdlib/VERSIONS
index c86bbb314667..6fcf0161790d 100644
--- a/python/helpers/typeshed/stdlib/VERSIONS
+++ b/python/helpers/typeshed/stdlib/VERSIONS
@@ -95,6 +95,7 @@ asyncio.staggered: 3.8-
asyncio.taskgroups: 3.11-
asyncio.threads: 3.9-
asyncio.timeouts: 3.11-
+asyncio.tools: 3.14-
asyncio.trsock: 3.8-
asyncore: 3.0-3.11
atexit: 3.0-
@@ -123,6 +124,7 @@ compileall: 3.0-
compression: 3.14-
concurrent: 3.2-
concurrent.futures.interpreter: 3.14-
+concurrent.interpreters: 3.14-
configparser: 3.0-
contextlib: 3.0-
contextvars: 3.7-
diff --git a/python/helpers/typeshed/stdlib/_ast.pyi b/python/helpers/typeshed/stdlib/_ast.pyi
index 00c6b357f7d8..d8d5a1829991 100644
--- a/python/helpers/typeshed/stdlib/_ast.pyi
+++ b/python/helpers/typeshed/stdlib/_ast.pyi
@@ -108,7 +108,7 @@ from ast import (
unaryop as unaryop,
withitem as withitem,
)
-from typing import Literal
+from typing import Final
if sys.version_info >= (3, 12):
from ast import (
@@ -137,9 +137,9 @@ if sys.version_info >= (3, 10):
pattern as pattern,
)
-PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192]
-PyCF_ONLY_AST: Literal[1024]
-PyCF_TYPE_COMMENTS: Literal[4096]
+PyCF_ALLOW_TOP_LEVEL_AWAIT: Final = 8192
+PyCF_ONLY_AST: Final = 1024
+PyCF_TYPE_COMMENTS: Final = 4096
if sys.version_info >= (3, 13):
- PyCF_OPTIMIZED_AST: Literal[33792]
+ PyCF_OPTIMIZED_AST: Final = 33792
diff --git a/python/helpers/typeshed/stdlib/_blake2.pyi b/python/helpers/typeshed/stdlib/_blake2.pyi
index d578df55c2fa..d2a5d572328b 100644
--- a/python/helpers/typeshed/stdlib/_blake2.pyi
+++ b/python/helpers/typeshed/stdlib/_blake2.pyi
@@ -1,15 +1,15 @@
from _typeshed import ReadableBuffer
-from typing import ClassVar, final
+from typing import ClassVar, Final, final
from typing_extensions import Self
-BLAKE2B_MAX_DIGEST_SIZE: int = 64
-BLAKE2B_MAX_KEY_SIZE: int = 64
-BLAKE2B_PERSON_SIZE: int = 16
-BLAKE2B_SALT_SIZE: int = 16
-BLAKE2S_MAX_DIGEST_SIZE: int = 32
-BLAKE2S_MAX_KEY_SIZE: int = 32
-BLAKE2S_PERSON_SIZE: int = 8
-BLAKE2S_SALT_SIZE: int = 8
+BLAKE2B_MAX_DIGEST_SIZE: Final = 64
+BLAKE2B_MAX_KEY_SIZE: Final = 64
+BLAKE2B_PERSON_SIZE: Final = 16
+BLAKE2B_SALT_SIZE: Final = 16
+BLAKE2S_MAX_DIGEST_SIZE: Final = 32
+BLAKE2S_MAX_KEY_SIZE: Final = 32
+BLAKE2S_PERSON_SIZE: Final = 8
+BLAKE2S_SALT_SIZE: Final = 8
@final
class blake2b:
diff --git a/python/helpers/typeshed/stdlib/_collections_abc.pyi b/python/helpers/typeshed/stdlib/_collections_abc.pyi
index b099bdd98f3c..c63606a13ca9 100644
--- a/python/helpers/typeshed/stdlib/_collections_abc.pyi
+++ b/python/helpers/typeshed/stdlib/_collections_abc.pyi
@@ -103,5 +103,6 @@ class dict_items(ItemsView[_KT_co, _VT_co]): # undocumented
if sys.version_info >= (3, 12):
@runtime_checkable
class Buffer(Protocol):
+ __slots__ = ()
@abstractmethod
def __buffer__(self, flags: int, /) -> memoryview: ...
diff --git a/python/helpers/typeshed/stdlib/_compat_pickle.pyi b/python/helpers/typeshed/stdlib/_compat_pickle.pyi
index 50fb22442cc9..32c0b542d991 100644
--- a/python/helpers/typeshed/stdlib/_compat_pickle.pyi
+++ b/python/helpers/typeshed/stdlib/_compat_pickle.pyi
@@ -1,8 +1,10 @@
-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, ...]
+from typing import Final
+
+IMPORT_MAPPING: Final[dict[str, str]]
+NAME_MAPPING: Final[dict[tuple[str, str], tuple[str, str]]]
+PYTHON2_EXCEPTIONS: Final[tuple[str, ...]]
+MULTIPROCESSING_EXCEPTIONS: Final[tuple[str, ...]]
+REVERSE_IMPORT_MAPPING: Final[dict[str, str]]
+REVERSE_NAME_MAPPING: Final[dict[tuple[str, str], tuple[str, str]]]
+PYTHON3_OSERROR_EXCEPTIONS: Final[tuple[str, ...]]
+PYTHON3_IMPORTERROR_EXCEPTIONS: Final[tuple[str, ...]]
diff --git a/python/helpers/typeshed/stdlib/_compression.pyi b/python/helpers/typeshed/stdlib/_compression.pyi
index 80d38b4db824..aa67df2ab478 100644
--- a/python/helpers/typeshed/stdlib/_compression.pyi
+++ b/python/helpers/typeshed/stdlib/_compression.pyi
@@ -3,10 +3,11 @@
from _typeshed import Incomplete, WriteableBuffer
from collections.abc import Callable
from io import DEFAULT_BUFFER_SIZE, BufferedIOBase, RawIOBase
-from typing import Any, Protocol
+from typing import Any, Protocol, type_check_only
BUFFER_SIZE = DEFAULT_BUFFER_SIZE
+@type_check_only
class _Reader(Protocol):
def read(self, n: int, /) -> bytes: ...
def seekable(self) -> bool: ...
diff --git a/python/helpers/typeshed/stdlib/_contextvars.pyi b/python/helpers/typeshed/stdlib/_contextvars.pyi
index e2e2e4df9d08..0ddeca7882cd 100644
--- a/python/helpers/typeshed/stdlib/_contextvars.pyi
+++ b/python/helpers/typeshed/stdlib/_contextvars.pyi
@@ -39,7 +39,7 @@ class Token(Generic[_T]):
if sys.version_info >= (3, 14):
def __enter__(self) -> Self: ...
def __exit__(
- self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
+ self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None, /
) -> None: ...
def copy_context() -> Context: ...
diff --git a/python/helpers/typeshed/stdlib/_csv.pyi b/python/helpers/typeshed/stdlib/_csv.pyi
index ecea4878907c..efe9ad69bd31 100644
--- a/python/helpers/typeshed/stdlib/_csv.pyi
+++ b/python/helpers/typeshed/stdlib/_csv.pyi
@@ -90,6 +90,7 @@ else:
def writer(
csvfile: SupportsWrite[str],
+ /,
dialect: _DialectLike = "excel",
*,
delimiter: str = ",",
@@ -103,6 +104,7 @@ def writer(
) -> _writer: ...
def reader(
csvfile: Iterable[str],
+ /,
dialect: _DialectLike = "excel",
*,
delimiter: str = ",",
diff --git a/python/helpers/typeshed/stdlib/_ctypes.pyi b/python/helpers/typeshed/stdlib/_ctypes.pyi
index 35c77619d474..c87cf5e326ca 100644
--- a/python/helpers/typeshed/stdlib/_ctypes.pyi
+++ b/python/helpers/typeshed/stdlib/_ctypes.pyi
@@ -5,24 +5,24 @@ from abc import abstractmethod
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from ctypes import CDLL, ArgumentError as ArgumentError, c_void_p
from types import GenericAlias
-from typing import Any, ClassVar, Generic, TypeVar, final, overload, type_check_only
+from typing import Any, ClassVar, Final, Generic, TypeVar, final, overload, type_check_only
from typing_extensions import Self, TypeAlias
_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
+FUNCFLAG_CDECL: Final = 0x1
+FUNCFLAG_PYTHONAPI: Final = 0x4
+FUNCFLAG_USE_ERRNO: Final = 0x8
+FUNCFLAG_USE_LASTERROR: Final = 0x10
+RTLD_GLOBAL: Final[int]
+RTLD_LOCAL: Final[int]
if sys.version_info >= (3, 11):
- CTYPES_MAX_ARGCOUNT: int
+ CTYPES_MAX_ARGCOUNT: Final[int]
if sys.version_info >= (3, 12):
- SIZEOF_TIME_T: int
+ SIZEOF_TIME_T: Final[int]
if sys.platform == "win32":
# Description, Source, HelpFile, HelpContext, scode
@@ -37,8 +37,8 @@ if sys.platform == "win32":
def CopyComPointer(src: _PointerLike, dst: _PointerLike | _CArgObject) -> int: ...
- FUNCFLAG_HRESULT: int
- FUNCFLAG_STDCALL: int
+ FUNCFLAG_HRESULT: Final = 0x2
+ FUNCFLAG_STDCALL: Final = 0x0
def FormatError(code: int = ...) -> str: ...
def get_last_error() -> int: ...
@@ -103,7 +103,10 @@ class _SimpleCData(_CData, Generic[_T], metaclass=_PyCSimpleType):
def __init__(self, value: _T = ...) -> None: ... # pyright: ignore[reportInvalidTypeVarUse]
def __ctypes_from_outparam__(self, /) -> _T: ... # type: ignore[override]
+@type_check_only
class _CanCastTo(_CData): ...
+
+@type_check_only
class _PointerLike(_CanCastTo): ...
# This type is not exposed. It calls itself _ctypes.PyCPointerType.
@@ -114,7 +117,7 @@ class _PyCPointerType(_CTypeBaseType):
def from_buffer_copy(self: type[_typeshed.Self], buffer: ReadableBuffer, offset: int = 0, /) -> _typeshed.Self: ...
def from_param(self: type[_typeshed.Self], value: Any, /) -> _typeshed.Self | _CArgObject: ...
def in_dll(self: type[_typeshed.Self], dll: CDLL, name: str, /) -> _typeshed.Self: ...
- def set_type(self, type: Any, /) -> None: ...
+ def set_type(self, type: _CTypeBaseType, /) -> None: ...
if sys.version_info < (3, 13):
# Inherited from CType_Type starting on 3.13
def __mul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
diff --git a/python/helpers/typeshed/stdlib/_curses.pyi b/python/helpers/typeshed/stdlib/_curses.pyi
index f21a9ca60270..852657448be8 100644
--- a/python/helpers/typeshed/stdlib/_curses.pyi
+++ b/python/helpers/typeshed/stdlib/_curses.pyi
@@ -1,7 +1,7 @@
import sys
from _typeshed import ReadOnlyBuffer, SupportsRead, SupportsWrite
from curses import _ncurses_version
-from typing import Any, final, overload
+from typing import Any, Final, final, overload
from typing_extensions import TypeAlias
# NOTE: This module is ordinarily only available on Unix, but the windows-curses
@@ -11,270 +11,270 @@ from typing_extensions import TypeAlias
_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
-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
+ACS_BBSS: Final[int]
+ACS_BLOCK: Final[int]
+ACS_BOARD: Final[int]
+ACS_BSBS: Final[int]
+ACS_BSSB: Final[int]
+ACS_BSSS: Final[int]
+ACS_BTEE: Final[int]
+ACS_BULLET: Final[int]
+ACS_CKBOARD: Final[int]
+ACS_DARROW: Final[int]
+ACS_DEGREE: Final[int]
+ACS_DIAMOND: Final[int]
+ACS_GEQUAL: Final[int]
+ACS_HLINE: Final[int]
+ACS_LANTERN: Final[int]
+ACS_LARROW: Final[int]
+ACS_LEQUAL: Final[int]
+ACS_LLCORNER: Final[int]
+ACS_LRCORNER: Final[int]
+ACS_LTEE: Final[int]
+ACS_NEQUAL: Final[int]
+ACS_PI: Final[int]
+ACS_PLMINUS: Final[int]
+ACS_PLUS: Final[int]
+ACS_RARROW: Final[int]
+ACS_RTEE: Final[int]
+ACS_S1: Final[int]
+ACS_S3: Final[int]
+ACS_S7: Final[int]
+ACS_S9: Final[int]
+ACS_SBBS: Final[int]
+ACS_SBSB: Final[int]
+ACS_SBSS: Final[int]
+ACS_SSBB: Final[int]
+ACS_SSBS: Final[int]
+ACS_SSSB: Final[int]
+ACS_SSSS: Final[int]
+ACS_STERLING: Final[int]
+ACS_TTEE: Final[int]
+ACS_UARROW: Final[int]
+ACS_ULCORNER: Final[int]
+ACS_URCORNER: Final[int]
+ACS_VLINE: Final[int]
+ALL_MOUSE_EVENTS: Final[int]
+A_ALTCHARSET: Final[int]
+A_ATTRIBUTES: Final[int]
+A_BLINK: Final[int]
+A_BOLD: Final[int]
+A_CHARTEXT: Final[int]
+A_COLOR: Final[int]
+A_DIM: Final[int]
+A_HORIZONTAL: Final[int]
+A_INVIS: Final[int]
+A_ITALIC: Final[int]
+A_LEFT: Final[int]
+A_LOW: Final[int]
+A_NORMAL: Final[int]
+A_PROTECT: Final[int]
+A_REVERSE: Final[int]
+A_RIGHT: Final[int]
+A_STANDOUT: Final[int]
+A_TOP: Final[int]
+A_UNDERLINE: Final[int]
+A_VERTICAL: Final[int]
+BUTTON1_CLICKED: Final[int]
+BUTTON1_DOUBLE_CLICKED: Final[int]
+BUTTON1_PRESSED: Final[int]
+BUTTON1_RELEASED: Final[int]
+BUTTON1_TRIPLE_CLICKED: Final[int]
+BUTTON2_CLICKED: Final[int]
+BUTTON2_DOUBLE_CLICKED: Final[int]
+BUTTON2_PRESSED: Final[int]
+BUTTON2_RELEASED: Final[int]
+BUTTON2_TRIPLE_CLICKED: Final[int]
+BUTTON3_CLICKED: Final[int]
+BUTTON3_DOUBLE_CLICKED: Final[int]
+BUTTON3_PRESSED: Final[int]
+BUTTON3_RELEASED: Final[int]
+BUTTON3_TRIPLE_CLICKED: Final[int]
+BUTTON4_CLICKED: Final[int]
+BUTTON4_DOUBLE_CLICKED: Final[int]
+BUTTON4_PRESSED: Final[int]
+BUTTON4_RELEASED: Final[int]
+BUTTON4_TRIPLE_CLICKED: Final[int]
# Darwin ncurses doesn't provide BUTTON5_* constants prior to 3.12.10 and 3.13.3
if sys.version_info >= (3, 10):
if sys.version_info >= (3, 12) or 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
+ BUTTON5_PRESSED: Final[int]
+ BUTTON5_RELEASED: Final[int]
+ BUTTON5_CLICKED: Final[int]
+ BUTTON5_DOUBLE_CLICKED: Final[int]
+ BUTTON5_TRIPLE_CLICKED: Final[int]
+BUTTON_ALT: Final[int]
+BUTTON_CTRL: Final[int]
+BUTTON_SHIFT: Final[int]
+COLOR_BLACK: Final[int]
+COLOR_BLUE: Final[int]
+COLOR_CYAN: Final[int]
+COLOR_GREEN: Final[int]
+COLOR_MAGENTA: Final[int]
+COLOR_RED: Final[int]
+COLOR_WHITE: Final[int]
+COLOR_YELLOW: Final[int]
+ERR: Final[int]
+KEY_A1: Final[int]
+KEY_A3: Final[int]
+KEY_B2: Final[int]
+KEY_BACKSPACE: Final[int]
+KEY_BEG: Final[int]
+KEY_BREAK: Final[int]
+KEY_BTAB: Final[int]
+KEY_C1: Final[int]
+KEY_C3: Final[int]
+KEY_CANCEL: Final[int]
+KEY_CATAB: Final[int]
+KEY_CLEAR: Final[int]
+KEY_CLOSE: Final[int]
+KEY_COMMAND: Final[int]
+KEY_COPY: Final[int]
+KEY_CREATE: Final[int]
+KEY_CTAB: Final[int]
+KEY_DC: Final[int]
+KEY_DL: Final[int]
+KEY_DOWN: Final[int]
+KEY_EIC: Final[int]
+KEY_END: Final[int]
+KEY_ENTER: Final[int]
+KEY_EOL: Final[int]
+KEY_EOS: Final[int]
+KEY_EXIT: Final[int]
+KEY_F0: Final[int]
+KEY_F1: Final[int]
+KEY_F10: Final[int]
+KEY_F11: Final[int]
+KEY_F12: Final[int]
+KEY_F13: Final[int]
+KEY_F14: Final[int]
+KEY_F15: Final[int]
+KEY_F16: Final[int]
+KEY_F17: Final[int]
+KEY_F18: Final[int]
+KEY_F19: Final[int]
+KEY_F2: Final[int]
+KEY_F20: Final[int]
+KEY_F21: Final[int]
+KEY_F22: Final[int]
+KEY_F23: Final[int]
+KEY_F24: Final[int]
+KEY_F25: Final[int]
+KEY_F26: Final[int]
+KEY_F27: Final[int]
+KEY_F28: Final[int]
+KEY_F29: Final[int]
+KEY_F3: Final[int]
+KEY_F30: Final[int]
+KEY_F31: Final[int]
+KEY_F32: Final[int]
+KEY_F33: Final[int]
+KEY_F34: Final[int]
+KEY_F35: Final[int]
+KEY_F36: Final[int]
+KEY_F37: Final[int]
+KEY_F38: Final[int]
+KEY_F39: Final[int]
+KEY_F4: Final[int]
+KEY_F40: Final[int]
+KEY_F41: Final[int]
+KEY_F42: Final[int]
+KEY_F43: Final[int]
+KEY_F44: Final[int]
+KEY_F45: Final[int]
+KEY_F46: Final[int]
+KEY_F47: Final[int]
+KEY_F48: Final[int]
+KEY_F49: Final[int]
+KEY_F5: Final[int]
+KEY_F50: Final[int]
+KEY_F51: Final[int]
+KEY_F52: Final[int]
+KEY_F53: Final[int]
+KEY_F54: Final[int]
+KEY_F55: Final[int]
+KEY_F56: Final[int]
+KEY_F57: Final[int]
+KEY_F58: Final[int]
+KEY_F59: Final[int]
+KEY_F6: Final[int]
+KEY_F60: Final[int]
+KEY_F61: Final[int]
+KEY_F62: Final[int]
+KEY_F63: Final[int]
+KEY_F7: Final[int]
+KEY_F8: Final[int]
+KEY_F9: Final[int]
+KEY_FIND: Final[int]
+KEY_HELP: Final[int]
+KEY_HOME: Final[int]
+KEY_IC: Final[int]
+KEY_IL: Final[int]
+KEY_LEFT: Final[int]
+KEY_LL: Final[int]
+KEY_MARK: Final[int]
+KEY_MAX: Final[int]
+KEY_MESSAGE: Final[int]
+KEY_MIN: Final[int]
+KEY_MOUSE: Final[int]
+KEY_MOVE: Final[int]
+KEY_NEXT: Final[int]
+KEY_NPAGE: Final[int]
+KEY_OPEN: Final[int]
+KEY_OPTIONS: Final[int]
+KEY_PPAGE: Final[int]
+KEY_PREVIOUS: Final[int]
+KEY_PRINT: Final[int]
+KEY_REDO: Final[int]
+KEY_REFERENCE: Final[int]
+KEY_REFRESH: Final[int]
+KEY_REPLACE: Final[int]
+KEY_RESET: Final[int]
+KEY_RESIZE: Final[int]
+KEY_RESTART: Final[int]
+KEY_RESUME: Final[int]
+KEY_RIGHT: Final[int]
+KEY_SAVE: Final[int]
+KEY_SBEG: Final[int]
+KEY_SCANCEL: Final[int]
+KEY_SCOMMAND: Final[int]
+KEY_SCOPY: Final[int]
+KEY_SCREATE: Final[int]
+KEY_SDC: Final[int]
+KEY_SDL: Final[int]
+KEY_SELECT: Final[int]
+KEY_SEND: Final[int]
+KEY_SEOL: Final[int]
+KEY_SEXIT: Final[int]
+KEY_SF: Final[int]
+KEY_SFIND: Final[int]
+KEY_SHELP: Final[int]
+KEY_SHOME: Final[int]
+KEY_SIC: Final[int]
+KEY_SLEFT: Final[int]
+KEY_SMESSAGE: Final[int]
+KEY_SMOVE: Final[int]
+KEY_SNEXT: Final[int]
+KEY_SOPTIONS: Final[int]
+KEY_SPREVIOUS: Final[int]
+KEY_SPRINT: Final[int]
+KEY_SR: Final[int]
+KEY_SREDO: Final[int]
+KEY_SREPLACE: Final[int]
+KEY_SRESET: Final[int]
+KEY_SRIGHT: Final[int]
+KEY_SRSUME: Final[int]
+KEY_SSAVE: Final[int]
+KEY_SSUSPEND: Final[int]
+KEY_STAB: Final[int]
+KEY_SUNDO: Final[int]
+KEY_SUSPEND: Final[int]
+KEY_UNDO: Final[int]
+KEY_UP: Final[int]
+OK: Final[int]
+REPORT_MOUSE_POSITION: Final[int]
_C_API: Any
-version: bytes
+version: Final[bytes]
def baudrate() -> int: ...
def beep() -> None: ...
@@ -394,8 +394,8 @@ class window: # undocumented
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 bkgd(self, ch: _ChType, attr: int = 0, /) -> None: ...
+ def bkgdset(self, ch: _ChType, attr: int = 0, /) -> None: ...
def border(
self,
ls: _ChType = ...,
@@ -433,7 +433,7 @@ class window: # undocumented
def derwin(self, begin_y: int, begin_x: int) -> window: ...
@overload
def derwin(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> window: ...
- def echochar(self, ch: _ChType, attr: int = ..., /) -> None: ...
+ def echochar(self, ch: _ChType, attr: int = 0, /) -> None: ...
def enclose(self, y: int, x: int, /) -> bool: ...
def erase(self) -> None: ...
def getbegyx(self) -> tuple[int, int]: ...
diff --git a/python/helpers/typeshed/stdlib/_curses_panel.pyi b/python/helpers/typeshed/stdlib/_curses_panel.pyi
index ddec22236b96..a552a151ddf1 100644
--- a/python/helpers/typeshed/stdlib/_curses_panel.pyi
+++ b/python/helpers/typeshed/stdlib/_curses_panel.pyi
@@ -1,8 +1,8 @@
from _curses import window
-from typing import final
+from typing import Final, final
-__version__: str
-version: str
+__version__: Final[str]
+version: Final[str]
class error(Exception): ...
diff --git a/python/helpers/typeshed/stdlib/_dbm.pyi b/python/helpers/typeshed/stdlib/_dbm.pyi
index 7e53cca3c704..759a2a43bed1 100644
--- a/python/helpers/typeshed/stdlib/_dbm.pyi
+++ b/python/helpers/typeshed/stdlib/_dbm.pyi
@@ -1,7 +1,7 @@
import sys
from _typeshed import ReadOnlyBuffer, StrOrBytesPath
from types import TracebackType
-from typing import TypeVar, final, overload, type_check_only
+from typing import Final, TypeVar, final, overload, type_check_only
from typing_extensions import Self, TypeAlias
if sys.platform != "win32":
@@ -10,7 +10,7 @@ if sys.platform != "win32":
_ValueType: TypeAlias = str | ReadOnlyBuffer
class error(OSError): ...
- library: str
+ library: Final[str]
# Actual typename dbm, not exposed by the implementation
@final
diff --git a/python/helpers/typeshed/stdlib/_frozen_importlib.pyi b/python/helpers/typeshed/stdlib/_frozen_importlib.pyi
index 3dbc8c6b52f0..93aaed82e2e1 100644
--- a/python/helpers/typeshed/stdlib/_frozen_importlib.pyi
+++ b/python/helpers/typeshed/stdlib/_frozen_importlib.pyi
@@ -6,6 +6,7 @@ from _typeshed.importlib import LoaderProtocol
from collections.abc import Mapping, Sequence
from types import ModuleType
from typing import Any, ClassVar
+from typing_extensions import deprecated
# Signature of `builtins.__import__` should be kept identical to `importlib.__import__`
def __import__(
@@ -49,6 +50,7 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader)
# MetaPathFinder
if sys.version_info < (3, 12):
@classmethod
+ @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.")
def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ...
@classmethod
@@ -67,6 +69,10 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader)
# Loader
if sys.version_info < (3, 12):
@staticmethod
+ @deprecated(
+ "Deprecated since Python 3.4; removed in Python 3.12. "
+ "The module spec is now used by the import machinery to generate a module repr."
+ )
def module_repr(module: types.ModuleType) -> str: ...
if sys.version_info >= (3, 10):
@staticmethod
@@ -83,6 +89,7 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader):
# MetaPathFinder
if sys.version_info < (3, 12):
@classmethod
+ @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.")
def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ...
@classmethod
@@ -101,6 +108,10 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader):
# Loader
if sys.version_info < (3, 12):
@staticmethod
+ @deprecated(
+ "Deprecated since Python 3.4; removed in Python 3.12. "
+ "The module spec is now used by the import machinery to generate a module repr."
+ )
def module_repr(m: types.ModuleType) -> str: ...
if sys.version_info >= (3, 10):
@staticmethod
diff --git a/python/helpers/typeshed/stdlib/_frozen_importlib_external.pyi b/python/helpers/typeshed/stdlib/_frozen_importlib_external.pyi
index edad50a8d858..71642c65dc07 100644
--- a/python/helpers/typeshed/stdlib/_frozen_importlib_external.pyi
+++ b/python/helpers/typeshed/stdlib/_frozen_importlib_external.pyi
@@ -9,7 +9,7 @@ from _typeshed.importlib import LoaderProtocol
from collections.abc import Callable, Iterable, Iterator, Mapping, MutableSequence, Sequence
from importlib.machinery import ModuleSpec
from importlib.metadata import DistributionFinder, PathDistribution
-from typing import Any, Literal
+from typing import Any, Final, Literal
from typing_extensions import Self, deprecated
if sys.version_info >= (3, 10):
@@ -24,7 +24,7 @@ else:
path_sep: Literal["/"]
path_sep_tuple: tuple[Literal["/"]]
-MAGIC_NUMBER: bytes
+MAGIC_NUMBER: Final[bytes]
def cache_from_source(path: StrPath, debug_override: bool | None = None, *, optimization: Any | None = None) -> str: ...
def source_from_cache(path: StrPath) -> str: ...
@@ -37,12 +37,13 @@ def spec_from_file_location(
submodule_search_locations: list[str] | None = ...,
) -> importlib.machinery.ModuleSpec | None: ...
@deprecated(
- "Deprecated as of Python 3.6: Use site configuration instead. "
+ "Deprecated since Python 3.6. Use site configuration instead. "
"Future versions of Python may not enable this finder by default."
)
class WindowsRegistryFinder(importlib.abc.MetaPathFinder):
if sys.version_info < (3, 12):
@classmethod
+ @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.")
def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ...
@classmethod
@@ -70,13 +71,14 @@ class PathFinder(importlib.abc.MetaPathFinder):
) -> ModuleSpec | None: ...
if sys.version_info < (3, 12):
@classmethod
+ @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.")
def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ...
-SOURCE_SUFFIXES: list[str]
-DEBUG_BYTECODE_SUFFIXES: list[str]
-OPTIMIZED_BYTECODE_SUFFIXES: list[str]
-BYTECODE_SUFFIXES: list[str]
-EXTENSION_SUFFIXES: list[str]
+SOURCE_SUFFIXES: Final[list[str]]
+DEBUG_BYTECODE_SUFFIXES: Final = [".pyc"]
+OPTIMIZED_BYTECODE_SUFFIXES: Final = [".pyc"]
+BYTECODE_SUFFIXES: Final = [".pyc"]
+EXTENSION_SUFFIXES: Final[list[str]]
class FileFinder(importlib.abc.PathEntryFinder):
path: str
@@ -153,12 +155,15 @@ if sys.version_info >= (3, 11):
def get_code(self, fullname: str) -> types.CodeType: ...
def create_module(self, spec: ModuleSpec) -> None: ...
def exec_module(self, module: types.ModuleType) -> None: ...
- @deprecated("load_module() is deprecated; use exec_module() instead")
+ @deprecated("Deprecated since Python 3.10; will be removed in Python 3.15. Use `exec_module()` instead.")
def load_module(self, fullname: str) -> types.ModuleType: ...
def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.NamespaceReader: ...
if sys.version_info < (3, 12):
@staticmethod
- @deprecated("module_repr() is deprecated, and has been removed in Python 3.12")
+ @deprecated(
+ "Deprecated since Python 3.4; removed in Python 3.12. "
+ "The module spec is now used by the import machinery to generate a module repr."
+ )
def module_repr(module: types.ModuleType) -> str: ...
_NamespaceLoader = NamespaceLoader
@@ -172,16 +177,23 @@ else:
def get_code(self, fullname: str) -> types.CodeType: ...
def create_module(self, spec: ModuleSpec) -> None: ...
def exec_module(self, module: types.ModuleType) -> None: ...
- @deprecated("load_module() is deprecated; use exec_module() instead")
- def load_module(self, fullname: str) -> types.ModuleType: ...
if sys.version_info >= (3, 10):
+ @deprecated("Deprecated since Python 3.10; will be removed in Python 3.15. Use `exec_module()` instead.")
+ def load_module(self, fullname: str) -> types.ModuleType: ...
@staticmethod
- @deprecated("module_repr() is deprecated, and has been removed in Python 3.12")
+ @deprecated(
+ "Deprecated since Python 3.4; removed in Python 3.12. "
+ "The module spec is now used by the import machinery to generate a module repr."
+ )
def module_repr(module: types.ModuleType) -> str: ...
def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.NamespaceReader: ...
else:
+ def load_module(self, fullname: str) -> types.ModuleType: ...
@classmethod
- @deprecated("module_repr() is deprecated, and has been removed in Python 3.12")
+ @deprecated(
+ "Deprecated since Python 3.4; removed in Python 3.12. "
+ "The module spec is now used by the import machinery to generate a module repr."
+ )
def module_repr(cls, module: types.ModuleType) -> str: ...
if sys.version_info >= (3, 13):
diff --git a/python/helpers/typeshed/stdlib/_gdbm.pyi b/python/helpers/typeshed/stdlib/_gdbm.pyi
index 1d1d541f5477..2cb5fba29dfa 100644
--- a/python/helpers/typeshed/stdlib/_gdbm.pyi
+++ b/python/helpers/typeshed/stdlib/_gdbm.pyi
@@ -1,7 +1,7 @@
import sys
from _typeshed import ReadOnlyBuffer, StrOrBytesPath
from types import TracebackType
-from typing import TypeVar, overload
+from typing import TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias
if sys.platform != "win32":
@@ -13,6 +13,7 @@ if sys.platform != "win32":
class error(OSError): ...
# Actual typename gdbm, not exposed by the implementation
+ @type_check_only
class _gdbm:
def firstkey(self) -> bytes | None: ...
def nextkey(self, key: _KeyType) -> bytes | None: ...
diff --git a/python/helpers/typeshed/stdlib/_heapq.pyi b/python/helpers/typeshed/stdlib/_heapq.pyi
index 3363fbcd7e74..4d7d6aba3241 100644
--- a/python/helpers/typeshed/stdlib/_heapq.pyi
+++ b/python/helpers/typeshed/stdlib/_heapq.pyi
@@ -1,18 +1,17 @@
import sys
-from typing import Any, Final, TypeVar
-
-_T = TypeVar("_T") # list items must be comparable
+from _typeshed import SupportsRichComparisonT as _T # All type variable use in this module requires comparability.
+from typing import Final
__about__: Final[str]
-def heapify(heap: list[Any], /) -> None: ... # list items must be comparable
+def heapify(heap: list[_T], /) -> 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: ...
if sys.version_info >= (3, 14):
- def heapify_max(heap: list[Any], /) -> None: ... # list items must be comparable
+ def heapify_max(heap: list[_T], /) -> None: ...
def heappop_max(heap: list[_T], /) -> _T: ...
def heappush_max(heap: list[_T], item: _T, /) -> None: ...
def heappushpop_max(heap: list[_T], item: _T, /) -> _T: ...
diff --git a/python/helpers/typeshed/stdlib/_interpchannels.pyi b/python/helpers/typeshed/stdlib/_interpchannels.pyi
index c03496044df0..a631a6f16616 100644
--- a/python/helpers/typeshed/stdlib/_interpchannels.pyi
+++ b/python/helpers/typeshed/stdlib/_interpchannels.pyi
@@ -17,15 +17,15 @@ class ChannelID:
def send(self) -> Self: ...
@property
def recv(self) -> Self: ...
- def __eq__(self, other: object) -> bool: ...
- def __ge__(self, other: ChannelID) -> bool: ...
- def __gt__(self, other: ChannelID) -> bool: ...
+ def __eq__(self, other: object, /) -> bool: ...
+ def __ge__(self, other: ChannelID, /) -> bool: ...
+ def __gt__(self, other: ChannelID, /) -> bool: ...
def __hash__(self) -> int: ...
def __index__(self) -> int: ...
def __int__(self) -> int: ...
- def __le__(self, other: ChannelID) -> bool: ...
- def __lt__(self, other: ChannelID) -> bool: ...
- def __ne__(self, other: object) -> bool: ...
+ def __le__(self, other: ChannelID, /) -> bool: ...
+ def __lt__(self, other: ChannelID, /) -> bool: ...
+ def __ne__(self, other: object, /) -> bool: ...
@final
class ChannelInfo(structseq[int], tuple[bool, bool, bool, int, int, int, int, int]):
diff --git a/python/helpers/typeshed/stdlib/_interpreters.pyi b/python/helpers/typeshed/stdlib/_interpreters.pyi
index caa1115e9d3d..2c604b30f5aa 100644
--- a/python/helpers/typeshed/stdlib/_interpreters.pyi
+++ b/python/helpers/typeshed/stdlib/_interpreters.pyi
@@ -1,9 +1,12 @@
import types
-from collections.abc import Callable, Mapping
-from typing import Final, Literal, SupportsIndex
+from collections.abc import Callable
+from typing import Any, Final, Literal, SupportsIndex, TypeVar, overload
from typing_extensions import TypeAlias
+_R = TypeVar("_R")
+
_Configs: TypeAlias = Literal["default", "isolated", "legacy", "empty", ""]
+_SharedDict: TypeAlias = dict[str, Any] # many objects can be shared
class InterpreterError(Exception): ...
class InterpreterNotFoundError(InterpreterError): ...
@@ -15,35 +18,40 @@ class CrossInterpreterBufferView:
def new_config(name: _Configs = "isolated", /, **overides: object) -> types.SimpleNamespace: ...
def create(config: types.SimpleNamespace | _Configs | None = "isolated", *, reqrefs: bool = False) -> int: ...
def destroy(id: SupportsIndex, *, restrict: bool = False) -> None: ...
-def list_all(*, require_ready: bool) -> list[tuple[int, int]]: ...
-def get_current() -> tuple[int, int]: ...
-def get_main() -> tuple[int, int]: ...
+def list_all(*, require_ready: bool = False) -> list[tuple[int, _Whence]]: ...
+def get_current() -> tuple[int, _Whence]: ...
+def get_main() -> tuple[int, _Whence]: ...
def is_running(id: SupportsIndex, *, restrict: bool = False) -> bool: ...
def get_config(id: SupportsIndex, *, restrict: bool = False) -> types.SimpleNamespace: ...
-def whence(id: SupportsIndex) -> int: ...
+def whence(id: SupportsIndex) -> _Whence: ...
def exec(
- id: SupportsIndex, code: str | types.CodeType | Callable[[], object], shared: bool | None = None, *, restrict: bool = False
+ id: SupportsIndex, code: str | types.CodeType | Callable[[], object], shared: _SharedDict = {}, *, restrict: bool = False
) -> None | types.SimpleNamespace: ...
def call(
id: SupportsIndex,
- callable: Callable[..., object],
- args: tuple[object, ...] | None = None,
- kwargs: dict[str, object] | None = None,
+ callable: Callable[..., _R],
+ args: tuple[Any, ...] = (),
+ kwargs: dict[str, Any] = {},
*,
+ preserve_exc: bool = False,
restrict: bool = False,
-) -> object: ...
+) -> tuple[_R, types.SimpleNamespace]: ...
def run_string(
- id: SupportsIndex, script: str | types.CodeType | Callable[[], object], shared: bool | None = None, *, restrict: bool = False
+ id: SupportsIndex, script: str | types.CodeType | Callable[[], object], shared: _SharedDict = {}, *, restrict: bool = False
) -> None: ...
def run_func(
- id: SupportsIndex, func: types.CodeType | Callable[[], object], shared: bool | None = None, *, restrict: bool = False
+ id: SupportsIndex, func: types.CodeType | Callable[[], object], shared: _SharedDict = {}, *, restrict: bool = False
) -> None: ...
-def set___main___attrs(id: SupportsIndex, updates: Mapping[str, object], *, restrict: bool = False) -> None: ...
+def set___main___attrs(id: SupportsIndex, updates: _SharedDict, *, restrict: bool = False) -> None: ...
def incref(id: SupportsIndex, *, implieslink: bool = False, restrict: bool = False) -> None: ...
def decref(id: SupportsIndex, *, restrict: bool = False) -> None: ...
def is_shareable(obj: object) -> bool: ...
-def capture_exception(exc: BaseException | None = None) -> types.SimpleNamespace: ...
+@overload
+def capture_exception(exc: BaseException) -> types.SimpleNamespace: ...
+@overload
+def capture_exception(exc: None = None) -> types.SimpleNamespace | None: ...
+_Whence: TypeAlias = Literal[0, 1, 2, 3, 4, 5]
WHENCE_UNKNOWN: Final = 0
WHENCE_RUNTIME: Final = 1
WHENCE_LEGACY_CAPI: Final = 2
diff --git a/python/helpers/typeshed/stdlib/_io.pyi b/python/helpers/typeshed/stdlib/_io.pyi
index c77d75287c25..e368ddef7f4e 100644
--- a/python/helpers/typeshed/stdlib/_io.pyi
+++ b/python/helpers/typeshed/stdlib/_io.pyi
@@ -88,6 +88,7 @@ class BytesIO(BufferedIOBase, _BufferedIOBase, BinaryIO): # type: ignore[misc]
def readlines(self, size: int | None = None, /) -> list[bytes]: ...
def seek(self, pos: int, whence: int = 0, /) -> int: ...
+@type_check_only
class _BufferedReaderStream(Protocol):
def read(self, n: int = ..., /) -> bytes: ...
# Optional: def readall(self) -> bytes: ...
diff --git a/python/helpers/typeshed/stdlib/_json.pyi b/python/helpers/typeshed/stdlib/_json.pyi
index 5296b8e62a02..4a77e5be594a 100644
--- a/python/helpers/typeshed/stdlib/_json.pyi
+++ b/python/helpers/typeshed/stdlib/_json.pyi
@@ -11,7 +11,7 @@ class make_encoder:
@property
def key_separator(self) -> str: ...
@property
- def indent(self) -> int | None: ...
+ def indent(self) -> str | None: ...
@property
def markers(self) -> dict[int, Any] | None: ...
@property
@@ -25,7 +25,7 @@ class make_encoder:
markers: dict[int, Any] | None,
default: Callable[[Any], Any],
encoder: Callable[[str], str],
- indent: int | None,
+ indent: str | None,
key_separator: str,
item_separator: str,
sort_keys: bool,
@@ -48,4 +48,4 @@ class make_scanner:
def encode_basestring(s: str, /) -> str: ...
def encode_basestring_ascii(s: str, /) -> str: ...
-def scanstring(string: str, end: int, strict: bool = ...) -> tuple[str, int]: ...
+def scanstring(string: str, end: int, strict: bool = True) -> tuple[str, int]: ...
diff --git a/python/helpers/typeshed/stdlib/_lzma.pyi b/python/helpers/typeshed/stdlib/_lzma.pyi
index 1a27c7428e8e..a234e383d28f 100644
--- a/python/helpers/typeshed/stdlib/_lzma.pyi
+++ b/python/helpers/typeshed/stdlib/_lzma.pyi
@@ -16,7 +16,7 @@ CHECK_CRC64: Final = 4
CHECK_SHA256: Final = 10
CHECK_ID_MAX: Final = 15
CHECK_UNKNOWN: Final = 16
-FILTER_LZMA1: int # v big number
+FILTER_LZMA1: Final[int] # v big number
FILTER_LZMA2: Final = 33
FILTER_DELTA: Final = 3
FILTER_X86: Final = 4
@@ -33,7 +33,7 @@ MF_BT4: Final = 20
MODE_FAST: Final = 1
MODE_NORMAL: Final = 2
PRESET_DEFAULT: Final = 6
-PRESET_EXTREME: int # v big number
+PRESET_EXTREME: Final[int] # v big number
@final
class LZMADecompressor:
diff --git a/python/helpers/typeshed/stdlib/_markupbase.pyi b/python/helpers/typeshed/stdlib/_markupbase.pyi
index 62bad25e5ccc..597bd09b700b 100644
--- a/python/helpers/typeshed/stdlib/_markupbase.pyi
+++ b/python/helpers/typeshed/stdlib/_markupbase.pyi
@@ -5,9 +5,9 @@ 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_comment(self, i: int, report: bool = True) -> int: ... # undocumented
def parse_declaration(self, i: int) -> int: ... # undocumented
- def parse_marked_section(self, i: int, report: int = 1) -> int: ... # undocumented
+ def parse_marked_section(self, i: int, report: bool = True) -> 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
diff --git a/python/helpers/typeshed/stdlib/_msi.pyi b/python/helpers/typeshed/stdlib/_msi.pyi
index 779fda3b67fe..edceed51bf9d 100644
--- a/python/helpers/typeshed/stdlib/_msi.pyi
+++ b/python/helpers/typeshed/stdlib/_msi.pyi
@@ -1,8 +1,10 @@
import sys
+from typing import Final, type_check_only
if sys.platform == "win32":
class MSIError(Exception): ...
# Actual typename View, not exposed by the implementation
+ @type_check_only
class _View:
def Execute(self, params: _Record | None = ...) -> None: ...
def GetColumnInfo(self, kind: int) -> _Record: ...
@@ -14,6 +16,7 @@ if sys.platform == "win32":
__init__: None # type: ignore[assignment]
# Actual typename SummaryInformation, not exposed by the implementation
+ @type_check_only
class _SummaryInformation:
def GetProperty(self, field: int) -> int | bytes | None: ...
def GetPropertyCount(self) -> int: ...
@@ -24,6 +27,7 @@ if sys.platform == "win32":
__init__: None # type: ignore[assignment]
# Actual typename Database, not exposed by the implementation
+ @type_check_only
class _Database:
def OpenView(self, sql: str) -> _View: ...
def Commit(self) -> None: ...
@@ -34,6 +38,7 @@ if sys.platform == "win32":
__init__: None # type: ignore[assignment]
# Actual typename Record, not exposed by the implementation
+ @type_check_only
class _Record:
def GetFieldCount(self) -> int: ...
def GetInteger(self, field: int) -> int: ...
@@ -51,42 +56,42 @@ if sys.platform == "win32":
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
+ MSICOLINFO_NAMES: Final[int]
+ MSICOLINFO_TYPES: Final[int]
+ MSIDBOPEN_CREATE: Final[int]
+ MSIDBOPEN_CREATEDIRECT: Final[int]
+ MSIDBOPEN_DIRECT: Final[int]
+ MSIDBOPEN_PATCHFILE: Final[int]
+ MSIDBOPEN_READONLY: Final[int]
+ MSIDBOPEN_TRANSACT: Final[int]
+ MSIMODIFY_ASSIGN: Final[int]
+ MSIMODIFY_DELETE: Final[int]
+ MSIMODIFY_INSERT: Final[int]
+ MSIMODIFY_INSERT_TEMPORARY: Final[int]
+ MSIMODIFY_MERGE: Final[int]
+ MSIMODIFY_REFRESH: Final[int]
+ MSIMODIFY_REPLACE: Final[int]
+ MSIMODIFY_SEEK: Final[int]
+ MSIMODIFY_UPDATE: Final[int]
+ MSIMODIFY_VALIDATE: Final[int]
+ MSIMODIFY_VALIDATE_DELETE: Final[int]
+ MSIMODIFY_VALIDATE_FIELD: Final[int]
+ MSIMODIFY_VALIDATE_NEW: Final[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
+ PID_APPNAME: Final[int]
+ PID_AUTHOR: Final[int]
+ PID_CHARCOUNT: Final[int]
+ PID_CODEPAGE: Final[int]
+ PID_COMMENTS: Final[int]
+ PID_CREATE_DTM: Final[int]
+ PID_KEYWORDS: Final[int]
+ PID_LASTAUTHOR: Final[int]
+ PID_LASTPRINTED: Final[int]
+ PID_LASTSAVE_DTM: Final[int]
+ PID_PAGECOUNT: Final[int]
+ PID_REVNUMBER: Final[int]
+ PID_SECURITY: Final[int]
+ PID_SUBJECT: Final[int]
+ PID_TEMPLATE: Final[int]
+ PID_TITLE: Final[int]
+ PID_WORDCOUNT: Final[int]
diff --git a/python/helpers/typeshed/stdlib/_operator.pyi b/python/helpers/typeshed/stdlib/_operator.pyi
index 967215d8fa21..cb1c1bcfc4aa 100644
--- a/python/helpers/typeshed/stdlib/_operator.pyi
+++ b/python/helpers/typeshed/stdlib/_operator.pyi
@@ -2,7 +2,7 @@ import sys
from _typeshed import SupportsGetItem
from collections.abc import Callable, Container, Iterable, MutableMapping, MutableSequence, Sequence
from operator import attrgetter as attrgetter, itemgetter as itemgetter, methodcaller as methodcaller
-from typing import Any, AnyStr, Protocol, SupportsAbs, SupportsIndex, TypeVar, overload
+from typing import Any, AnyStr, Protocol, SupportsAbs, SupportsIndex, TypeVar, overload, type_check_only
from typing_extensions import ParamSpec, TypeAlias, TypeIs
_R = TypeVar("_R")
@@ -16,26 +16,33 @@ _P = ParamSpec("_P")
# operators can be overloaded to return an arbitrary object. For example,
# the numpy.array comparison dunders return another numpy.array.
+@type_check_only
class _SupportsDunderLT(Protocol):
def __lt__(self, other: Any, /) -> Any: ...
+@type_check_only
class _SupportsDunderGT(Protocol):
def __gt__(self, other: Any, /) -> Any: ...
+@type_check_only
class _SupportsDunderLE(Protocol):
def __le__(self, other: Any, /) -> Any: ...
+@type_check_only
class _SupportsDunderGE(Protocol):
def __ge__(self, other: Any, /) -> Any: ...
_SupportsComparison: TypeAlias = _SupportsDunderLE | _SupportsDunderGE | _SupportsDunderGT | _SupportsDunderLT
+@type_check_only
class _SupportsInversion(Protocol[_T_co]):
def __invert__(self) -> _T_co: ...
+@type_check_only
class _SupportsNeg(Protocol[_T_co]):
def __neg__(self) -> _T_co: ...
+@type_check_only
class _SupportsPos(Protocol[_T_co]):
def __pos__(self) -> _T_co: ...
diff --git a/python/helpers/typeshed/stdlib/_pickle.pyi b/python/helpers/typeshed/stdlib/_pickle.pyi
index 8e8afb600efa..03051bb09d3c 100644
--- a/python/helpers/typeshed/stdlib/_pickle.pyi
+++ b/python/helpers/typeshed/stdlib/_pickle.pyi
@@ -4,6 +4,7 @@ from pickle import PickleBuffer as PickleBuffer
from typing import Any, Protocol, type_check_only
from typing_extensions import TypeAlias
+@type_check_only
class _ReadableFileobj(Protocol):
def read(self, n: int, /) -> bytes: ...
def readline(self) -> bytes: ...
diff --git a/python/helpers/typeshed/stdlib/_socket.pyi b/python/helpers/typeshed/stdlib/_socket.pyi
index 41fdce87ec14..9c153a3a6ba0 100644
--- a/python/helpers/typeshed/stdlib/_socket.pyi
+++ b/python/helpers/typeshed/stdlib/_socket.pyi
@@ -2,7 +2,7 @@ import sys
from _typeshed import ReadableBuffer, WriteableBuffer
from collections.abc import Iterable
from socket import error as error, gaierror as gaierror, herror as herror, timeout as timeout
-from typing import Any, SupportsIndex, overload
+from typing import Any, Final, SupportsIndex, overload
from typing_extensions import CapsuleType, TypeAlias
_CMSG: TypeAlias = tuple[int, int, bytes]
@@ -19,23 +19,23 @@ _RetAddress: TypeAlias = Any
# https://docs.python.org/3/library/socket.html#constants
if sys.platform != "win32":
- AF_UNIX: int
+ AF_UNIX: Final[int]
-AF_INET: int
-AF_INET6: int
+AF_INET: Final[int]
+AF_INET6: Final[int]
-AF_UNSPEC: int
+AF_UNSPEC: Final[int]
-SOCK_STREAM: int
-SOCK_DGRAM: int
-SOCK_RAW: int
-SOCK_RDM: int
-SOCK_SEQPACKET: int
+SOCK_STREAM: Final[int]
+SOCK_DGRAM: Final[int]
+SOCK_RAW: Final[int]
+SOCK_RDM: Final[int]
+SOCK_SEQPACKET: Final[int]
if sys.platform == "linux":
# Availability: Linux >= 2.6.27
- SOCK_CLOEXEC: int
- SOCK_NONBLOCK: int
+ SOCK_CLOEXEC: Final[int]
+ SOCK_NONBLOCK: Final[int]
# --------------------
# Many constants of these forms, documented in the Unix documentation on
@@ -56,329 +56,329 @@ if sys.platform == "linux":
# 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_ACCEPTCONN: Final[int]
+SO_BROADCAST: Final[int]
+SO_DEBUG: Final[int]
+SO_DONTROUTE: Final[int]
+SO_ERROR: Final[int]
+SO_KEEPALIVE: Final[int]
+SO_LINGER: Final[int]
+SO_OOBINLINE: Final[int]
+SO_RCVBUF: Final[int]
+SO_RCVLOWAT: Final[int]
+SO_RCVTIMEO: Final[int]
+SO_REUSEADDR: Final[int]
+SO_SNDBUF: Final[int]
+SO_SNDLOWAT: Final[int]
+SO_SNDTIMEO: Final[int]
+SO_TYPE: Final[int]
if sys.platform != "linux":
- SO_USELOOPBACK: int
+ SO_USELOOPBACK: Final[int]
if sys.platform == "win32":
- SO_EXCLUSIVEADDRUSE: int
+ SO_EXCLUSIVEADDRUSE: Final[int]
if sys.platform != "win32":
- SO_REUSEPORT: int
+ SO_REUSEPORT: Final[int]
if sys.platform != "darwin" or sys.version_info >= (3, 13):
- SO_BINDTODEVICE: int
+ SO_BINDTODEVICE: Final[int]
if sys.platform != "win32" and sys.platform != "darwin":
- 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_DOMAIN: Final[int]
+ SO_MARK: Final[int]
+ SO_PASSCRED: Final[int]
+ SO_PASSSEC: Final[int]
+ SO_PEERCRED: Final[int]
+ SO_PEERSEC: Final[int]
+ SO_PRIORITY: Final[int]
+ SO_PROTOCOL: Final[int]
if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux":
- SO_SETFIB: int
+ SO_SETFIB: Final[int]
if sys.platform == "linux" and sys.version_info >= (3, 13):
- SO_BINDTOIFINDEX: int
+ SO_BINDTOIFINDEX: Final[int]
-SOMAXCONN: int
+SOMAXCONN: Final[int]
-MSG_CTRUNC: int
-MSG_DONTROUTE: int
-MSG_OOB: int
-MSG_PEEK: int
-MSG_TRUNC: int
-MSG_WAITALL: int
+MSG_CTRUNC: Final[int]
+MSG_DONTROUTE: Final[int]
+MSG_OOB: Final[int]
+MSG_PEEK: Final[int]
+MSG_TRUNC: Final[int]
+MSG_WAITALL: Final[int]
if sys.platform != "win32":
- MSG_DONTWAIT: int
- MSG_EOR: int
- MSG_NOSIGNAL: int # Sometimes this exists on darwin, sometimes not
+ MSG_DONTWAIT: Final[int]
+ MSG_EOR: Final[int]
+ MSG_NOSIGNAL: Final[int] # Sometimes this exists on darwin, sometimes not
if sys.platform != "darwin":
- MSG_ERRQUEUE: int
+ MSG_ERRQUEUE: Final[int]
if sys.platform == "win32":
- MSG_BCAST: int
- MSG_MCAST: int
+ MSG_BCAST: Final[int]
+ MSG_MCAST: Final[int]
if sys.platform != "win32" and sys.platform != "darwin":
- MSG_CMSG_CLOEXEC: int
- MSG_CONFIRM: int
- MSG_FASTOPEN: int
- MSG_MORE: int
+ MSG_CMSG_CLOEXEC: Final[int]
+ MSG_CONFIRM: Final[int]
+ MSG_FASTOPEN: Final[int]
+ MSG_MORE: Final[int]
if sys.platform != "win32" and sys.platform != "linux":
- MSG_EOF: int
+ MSG_EOF: Final[int]
if sys.platform != "win32" and sys.platform != "linux" and sys.platform != "darwin":
- MSG_NOTIFICATION: int
- MSG_BTAG: int # Not FreeBSD either
- MSG_ETAG: int # Not FreeBSD either
+ MSG_NOTIFICATION: Final[int]
+ MSG_BTAG: Final[int] # Not FreeBSD either
+ MSG_ETAG: Final[int] # Not FreeBSD either
-SOL_IP: int
-SOL_SOCKET: int
-SOL_TCP: int
-SOL_UDP: int
+SOL_IP: Final[int]
+SOL_SOCKET: Final[int]
+SOL_TCP: Final[int]
+SOL_UDP: Final[int]
if sys.platform != "win32" and sys.platform != "darwin":
# Defined in socket.h for Linux, but these aren't always present for
# some reason.
- SOL_ATALK: int
- SOL_AX25: int
- SOL_HCI: int
- SOL_IPX: int
- SOL_NETROM: int
- SOL_ROSE: int
+ SOL_ATALK: Final[int]
+ SOL_AX25: Final[int]
+ SOL_HCI: Final[int]
+ SOL_IPX: Final[int]
+ SOL_NETROM: Final[int]
+ SOL_ROSE: Final[int]
if sys.platform != "win32":
- SCM_RIGHTS: int
+ SCM_RIGHTS: Final[int]
if sys.platform != "win32" and sys.platform != "darwin":
- SCM_CREDENTIALS: int
+ SCM_CREDENTIALS: Final[int]
if sys.platform != "win32" and sys.platform != "linux":
- SCM_CREDS: int
+ SCM_CREDS: Final[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_HOPOPTS: int
-IPPROTO_ICMPV6: int
-IPPROTO_IDP: int
-IPPROTO_IGMP: int
-IPPROTO_IPV6: int
-IPPROTO_NONE: int
-IPPROTO_PIM: int
-IPPROTO_PUP: int
-IPPROTO_ROUTING: int
-IPPROTO_SCTP: int
+IPPROTO_ICMP: Final[int]
+IPPROTO_IP: Final[int]
+IPPROTO_RAW: Final[int]
+IPPROTO_TCP: Final[int]
+IPPROTO_UDP: Final[int]
+IPPROTO_AH: Final[int]
+IPPROTO_DSTOPTS: Final[int]
+IPPROTO_EGP: Final[int]
+IPPROTO_ESP: Final[int]
+IPPROTO_FRAGMENT: Final[int]
+IPPROTO_HOPOPTS: Final[int]
+IPPROTO_ICMPV6: Final[int]
+IPPROTO_IDP: Final[int]
+IPPROTO_IGMP: Final[int]
+IPPROTO_IPV6: Final[int]
+IPPROTO_NONE: Final[int]
+IPPROTO_PIM: Final[int]
+IPPROTO_PUP: Final[int]
+IPPROTO_ROUTING: Final[int]
+IPPROTO_SCTP: Final[int]
if sys.platform != "linux":
- IPPROTO_GGP: int
- IPPROTO_IPV4: int
- IPPROTO_MAX: int
- IPPROTO_ND: int
+ IPPROTO_GGP: Final[int]
+ IPPROTO_IPV4: Final[int]
+ IPPROTO_MAX: Final[int]
+ IPPROTO_ND: Final[int]
if sys.platform == "win32":
- IPPROTO_CBT: int
- IPPROTO_ICLFXBM: int
- IPPROTO_IGP: int
- IPPROTO_L2TP: int
- IPPROTO_PGM: int
- IPPROTO_RDP: int
- IPPROTO_ST: int
+ IPPROTO_CBT: Final[int]
+ IPPROTO_ICLFXBM: Final[int]
+ IPPROTO_IGP: Final[int]
+ IPPROTO_L2TP: Final[int]
+ IPPROTO_PGM: Final[int]
+ IPPROTO_RDP: Final[int]
+ IPPROTO_ST: Final[int]
if sys.platform != "win32":
- IPPROTO_GRE: int
- IPPROTO_IPIP: int
- IPPROTO_RSVP: int
- IPPROTO_TP: int
+ IPPROTO_GRE: Final[int]
+ IPPROTO_IPIP: Final[int]
+ IPPROTO_RSVP: Final[int]
+ IPPROTO_TP: Final[int]
if sys.platform != "win32" and sys.platform != "linux":
- IPPROTO_EON: int
- IPPROTO_HELLO: int
- IPPROTO_IPCOMP: int
- IPPROTO_XTP: int
+ IPPROTO_EON: Final[int]
+ IPPROTO_HELLO: Final[int]
+ IPPROTO_IPCOMP: Final[int]
+ IPPROTO_XTP: Final[int]
if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux":
- IPPROTO_BIP: int # Not FreeBSD either
- IPPROTO_MOBILE: int # Not FreeBSD either
- IPPROTO_VRRP: int # Not FreeBSD either
+ IPPROTO_BIP: Final[int] # Not FreeBSD either
+ IPPROTO_MOBILE: Final[int] # Not FreeBSD either
+ IPPROTO_VRRP: Final[int] # Not FreeBSD either
if sys.platform == "linux":
# Availability: Linux >= 2.6.20, FreeBSD >= 10.1
- IPPROTO_UDPLITE: int
+ IPPROTO_UDPLITE: Final[int]
if sys.version_info >= (3, 10) and sys.platform == "linux":
- IPPROTO_MPTCP: int
+ IPPROTO_MPTCP: Final[int]
-IPPORT_RESERVED: int
-IPPORT_USERRESERVED: int
+IPPORT_RESERVED: Final[int]
+IPPORT_USERRESERVED: Final[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
+INADDR_ALLHOSTS_GROUP: Final[int]
+INADDR_ANY: Final[int]
+INADDR_BROADCAST: Final[int]
+INADDR_LOOPBACK: Final[int]
+INADDR_MAX_LOCAL_GROUP: Final[int]
+INADDR_NONE: Final[int]
+INADDR_UNSPEC_GROUP: Final[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_ADD_MEMBERSHIP: Final[int]
+IP_DROP_MEMBERSHIP: Final[int]
+IP_HDRINCL: Final[int]
+IP_MULTICAST_IF: Final[int]
+IP_MULTICAST_LOOP: Final[int]
+IP_MULTICAST_TTL: Final[int]
+IP_OPTIONS: Final[int]
if sys.platform != "linux":
- IP_RECVDSTADDR: int
+ IP_RECVDSTADDR: Final[int]
if sys.version_info >= (3, 10):
- IP_RECVTOS: int
-IP_TOS: int
-IP_TTL: int
+ IP_RECVTOS: Final[int]
+IP_TOS: Final[int]
+IP_TTL: Final[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
+ IP_DEFAULT_MULTICAST_LOOP: Final[int]
+ IP_DEFAULT_MULTICAST_TTL: Final[int]
+ IP_MAX_MEMBERSHIPS: Final[int]
+ IP_RECVOPTS: Final[int]
+ IP_RECVRETOPTS: Final[int]
+ IP_RETOPTS: Final[int]
if sys.version_info >= (3, 13) and sys.platform == "linux":
- CAN_RAW_ERR_FILTER: int
+ CAN_RAW_ERR_FILTER: Final[int]
if sys.version_info >= (3, 14):
- IP_RECVTTL: int
+ IP_RECVTTL: Final[int]
if sys.platform == "win32" or sys.platform == "linux":
- IPV6_RECVERR: int
- IP_RECVERR: int
- SO_ORIGINAL_DST: int
+ IPV6_RECVERR: Final[int]
+ IP_RECVERR: Final[int]
+ SO_ORIGINAL_DST: Final[int]
if sys.platform == "win32":
- SOL_RFCOMM: int
- SO_BTH_ENCRYPT: int
- SO_BTH_MTU: int
- SO_BTH_MTU_MAX: int
- SO_BTH_MTU_MIN: int
- TCP_QUICKACK: int
+ SOL_RFCOMM: Final[int]
+ SO_BTH_ENCRYPT: Final[int]
+ SO_BTH_MTU: Final[int]
+ SO_BTH_MTU_MAX: Final[int]
+ SO_BTH_MTU_MIN: Final[int]
+ TCP_QUICKACK: Final[int]
if sys.platform == "linux":
- IP_FREEBIND: int
- IP_RECVORIGDSTADDR: int
- VMADDR_CID_LOCAL: int
+ IP_FREEBIND: Final[int]
+ IP_RECVORIGDSTADDR: Final[int]
+ VMADDR_CID_LOCAL: Final[int]
if sys.platform != "win32" and sys.platform != "darwin":
- IP_TRANSPARENT: int
+ IP_TRANSPARENT: Final[int]
if sys.platform != "win32" and sys.platform != "darwin" and sys.version_info >= (3, 11):
- IP_BIND_ADDRESS_NO_PORT: int
+ IP_BIND_ADDRESS_NO_PORT: Final[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
+ IP_ADD_SOURCE_MEMBERSHIP: Final[int]
+ IP_BLOCK_SOURCE: Final[int]
+ IP_DROP_SOURCE_MEMBERSHIP: Final[int]
+ IP_PKTINFO: Final[int]
+ IP_UNBLOCK_SOURCE: Final[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
-IPV6_DONTFRAG: int
-IPV6_HOPLIMIT: int
-IPV6_HOPOPTS: int
-IPV6_PKTINFO: int
-IPV6_RECVRTHDR: int
-IPV6_RTHDR: int
+IPV6_CHECKSUM: Final[int]
+IPV6_JOIN_GROUP: Final[int]
+IPV6_LEAVE_GROUP: Final[int]
+IPV6_MULTICAST_HOPS: Final[int]
+IPV6_MULTICAST_IF: Final[int]
+IPV6_MULTICAST_LOOP: Final[int]
+IPV6_RECVTCLASS: Final[int]
+IPV6_TCLASS: Final[int]
+IPV6_UNICAST_HOPS: Final[int]
+IPV6_V6ONLY: Final[int]
+IPV6_DONTFRAG: Final[int]
+IPV6_HOPLIMIT: Final[int]
+IPV6_HOPOPTS: Final[int]
+IPV6_PKTINFO: Final[int]
+IPV6_RECVRTHDR: Final[int]
+IPV6_RTHDR: Final[int]
if sys.platform != "win32":
- IPV6_RTHDR_TYPE_0: int
- 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_RTHDR_TYPE_0: Final[int]
+ IPV6_DSTOPTS: Final[int]
+ IPV6_NEXTHOP: Final[int]
+ IPV6_PATHMTU: Final[int]
+ IPV6_RECVDSTOPTS: Final[int]
+ IPV6_RECVHOPLIMIT: Final[int]
+ IPV6_RECVHOPOPTS: Final[int]
+ IPV6_RECVPATHMTU: Final[int]
+ IPV6_RECVPKTINFO: Final[int]
+ IPV6_RTHDRDSTOPTS: Final[int]
if sys.platform != "win32" and sys.platform != "linux":
- IPV6_USE_MIN_MTU: int
+ IPV6_USE_MIN_MTU: Final[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
+EAI_AGAIN: Final[int]
+EAI_BADFLAGS: Final[int]
+EAI_FAIL: Final[int]
+EAI_FAMILY: Final[int]
+EAI_MEMORY: Final[int]
+EAI_NODATA: Final[int]
+EAI_NONAME: Final[int]
+EAI_SERVICE: Final[int]
+EAI_SOCKTYPE: Final[int]
if sys.platform != "win32":
- EAI_ADDRFAMILY: int
- EAI_OVERFLOW: int
- EAI_SYSTEM: int
+ EAI_ADDRFAMILY: Final[int]
+ EAI_OVERFLOW: Final[int]
+ EAI_SYSTEM: Final[int]
if sys.platform != "win32" and sys.platform != "linux":
- EAI_BADHINTS: int
- EAI_MAX: int
- EAI_PROTOCOL: int
+ EAI_BADHINTS: Final[int]
+ EAI_MAX: Final[int]
+ EAI_PROTOCOL: Final[int]
-AI_ADDRCONFIG: int
-AI_ALL: int
-AI_CANONNAME: int
-AI_NUMERICHOST: int
-AI_NUMERICSERV: int
-AI_PASSIVE: int
-AI_V4MAPPED: int
+AI_ADDRCONFIG: Final[int]
+AI_ALL: Final[int]
+AI_CANONNAME: Final[int]
+AI_NUMERICHOST: Final[int]
+AI_NUMERICSERV: Final[int]
+AI_PASSIVE: Final[int]
+AI_V4MAPPED: Final[int]
if sys.platform != "win32" and sys.platform != "linux":
- AI_DEFAULT: int
- AI_MASK: int
- AI_V4MAPPED_CFG: int
+ AI_DEFAULT: Final[int]
+ AI_MASK: Final[int]
+ AI_V4MAPPED_CFG: Final[int]
-NI_DGRAM: int
-NI_MAXHOST: int
-NI_MAXSERV: int
-NI_NAMEREQD: int
-NI_NOFQDN: int
-NI_NUMERICHOST: int
-NI_NUMERICSERV: int
+NI_DGRAM: Final[int]
+NI_MAXHOST: Final[int]
+NI_MAXSERV: Final[int]
+NI_NAMEREQD: Final[int]
+NI_NOFQDN: Final[int]
+NI_NUMERICHOST: Final[int]
+NI_NUMERICSERV: Final[int]
if sys.platform == "linux" and sys.version_info >= (3, 13):
- NI_IDN: int
+ NI_IDN: Final[int]
-TCP_FASTOPEN: int
-TCP_KEEPCNT: int
-TCP_KEEPINTVL: int
-TCP_MAXSEG: int
-TCP_NODELAY: int
+TCP_FASTOPEN: Final[int]
+TCP_KEEPCNT: Final[int]
+TCP_KEEPINTVL: Final[int]
+TCP_MAXSEG: Final[int]
+TCP_NODELAY: Final[int]
if sys.platform != "win32":
- TCP_NOTSENT_LOWAT: int
+ TCP_NOTSENT_LOWAT: Final[int]
if sys.platform != "darwin":
- TCP_KEEPIDLE: int
+ TCP_KEEPIDLE: Final[int]
if sys.version_info >= (3, 10) and sys.platform == "darwin":
- TCP_KEEPALIVE: int
+ TCP_KEEPALIVE: Final[int]
if sys.version_info >= (3, 11) and sys.platform == "darwin":
- TCP_CONNECTION_INFO: int
+ TCP_CONNECTION_INFO: Final[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
+ TCP_CONGESTION: Final[int]
+ TCP_CORK: Final[int]
+ TCP_DEFER_ACCEPT: Final[int]
+ TCP_INFO: Final[int]
+ TCP_LINGER2: Final[int]
+ TCP_QUICKACK: Final[int]
+ TCP_SYNCNT: Final[int]
+ TCP_USER_TIMEOUT: Final[int]
+ TCP_WINDOW_CLAMP: Final[int]
if sys.platform == "linux" and sys.version_info >= (3, 12):
- TCP_CC_INFO: int
- TCP_FASTOPEN_CONNECT: int
- TCP_FASTOPEN_KEY: int
- TCP_FASTOPEN_NO_COOKIE: int
- TCP_INQ: int
- TCP_MD5SIG: int
- TCP_MD5SIG_EXT: int
- TCP_QUEUE_SEQ: int
- TCP_REPAIR: int
- TCP_REPAIR_OPTIONS: int
- TCP_REPAIR_QUEUE: int
- TCP_REPAIR_WINDOW: int
- TCP_SAVED_SYN: int
- TCP_SAVE_SYN: int
- TCP_THIN_DUPACK: int
- TCP_THIN_LINEAR_TIMEOUTS: int
- TCP_TIMESTAMP: int
- TCP_TX_DELAY: int
- TCP_ULP: int
- TCP_ZEROCOPY_RECEIVE: int
+ TCP_CC_INFO: Final[int]
+ TCP_FASTOPEN_CONNECT: Final[int]
+ TCP_FASTOPEN_KEY: Final[int]
+ TCP_FASTOPEN_NO_COOKIE: Final[int]
+ TCP_INQ: Final[int]
+ TCP_MD5SIG: Final[int]
+ TCP_MD5SIG_EXT: Final[int]
+ TCP_QUEUE_SEQ: Final[int]
+ TCP_REPAIR: Final[int]
+ TCP_REPAIR_OPTIONS: Final[int]
+ TCP_REPAIR_QUEUE: Final[int]
+ TCP_REPAIR_WINDOW: Final[int]
+ TCP_SAVED_SYN: Final[int]
+ TCP_SAVE_SYN: Final[int]
+ TCP_THIN_DUPACK: Final[int]
+ TCP_THIN_LINEAR_TIMEOUTS: Final[int]
+ TCP_TIMESTAMP: Final[int]
+ TCP_TX_DELAY: Final[int]
+ TCP_ULP: Final[int]
+ TCP_ZEROCOPY_RECEIVE: Final[int]
# --------------------
# Specifically documented constants
@@ -386,250 +386,250 @@ if sys.platform == "linux" and sys.version_info >= (3, 12):
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_FILTER: int
- CAN_RAW_LOOPBACK: int
- CAN_RAW_RECV_OWN_MSGS: int
- CAN_RTR_FLAG: int
- CAN_SFF_MASK: int
+ AF_CAN: Final[int]
+ PF_CAN: Final[int]
+ SOL_CAN_BASE: Final[int]
+ SOL_CAN_RAW: Final[int]
+ CAN_EFF_FLAG: Final[int]
+ CAN_EFF_MASK: Final[int]
+ CAN_ERR_FLAG: Final[int]
+ CAN_ERR_MASK: Final[int]
+ CAN_RAW: Final[int]
+ CAN_RAW_FILTER: Final[int]
+ CAN_RAW_LOOPBACK: Final[int]
+ CAN_RAW_RECV_OWN_MSGS: Final[int]
+ CAN_RTR_FLAG: Final[int]
+ CAN_SFF_MASK: Final[int]
if sys.version_info < (3, 11):
- CAN_RAW_ERR_FILTER: int
+ CAN_RAW_ERR_FILTER: Final[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
+ CAN_BCM: Final[int]
+ CAN_BCM_TX_SETUP: Final[int]
+ CAN_BCM_TX_DELETE: Final[int]
+ CAN_BCM_TX_READ: Final[int]
+ CAN_BCM_TX_SEND: Final[int]
+ CAN_BCM_RX_SETUP: Final[int]
+ CAN_BCM_RX_DELETE: Final[int]
+ CAN_BCM_RX_READ: Final[int]
+ CAN_BCM_TX_STATUS: Final[int]
+ CAN_BCM_TX_EXPIRED: Final[int]
+ CAN_BCM_RX_STATUS: Final[int]
+ CAN_BCM_RX_TIMEOUT: Final[int]
+ CAN_BCM_RX_CHANGED: Final[int]
+ CAN_BCM_SETTIMER: Final[int]
+ CAN_BCM_STARTTIMER: Final[int]
+ CAN_BCM_TX_COUNTEVT: Final[int]
+ CAN_BCM_TX_ANNOUNCE: Final[int]
+ CAN_BCM_TX_CP_CAN_ID: Final[int]
+ CAN_BCM_RX_FILTER_ID: Final[int]
+ CAN_BCM_RX_CHECK_DLC: Final[int]
+ CAN_BCM_RX_NO_AUTOTIMER: Final[int]
+ CAN_BCM_RX_ANNOUNCE_RESUME: Final[int]
+ CAN_BCM_TX_RESET_MULTI_IDX: Final[int]
+ CAN_BCM_RX_RTR_FRAME: Final[int]
+ CAN_BCM_CAN_FD_FRAME: Final[int]
if sys.platform == "linux":
# Availability: Linux >= 3.6
- CAN_RAW_FD_FRAMES: int
+ CAN_RAW_FD_FRAMES: Final[int]
# Availability: Linux >= 4.1
- CAN_RAW_JOIN_FILTERS: int
+ CAN_RAW_JOIN_FILTERS: Final[int]
# Availability: Linux >= 2.6.25
- CAN_ISOTP: int
+ CAN_ISOTP: Final[int]
# Availability: Linux >= 5.4
- CAN_J1939: int
+ CAN_J1939: Final[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
+ J1939_MAX_UNICAST_ADDR: Final[int]
+ J1939_IDLE_ADDR: Final[int]
+ J1939_NO_ADDR: Final[int]
+ J1939_NO_NAME: Final[int]
+ J1939_PGN_REQUEST: Final[int]
+ J1939_PGN_ADDRESS_CLAIMED: Final[int]
+ J1939_PGN_ADDRESS_COMMANDED: Final[int]
+ J1939_PGN_PDU1_MAX: Final[int]
+ J1939_PGN_MAX: Final[int]
+ J1939_NO_PGN: Final[int]
- SO_J1939_FILTER: int
- SO_J1939_PROMISC: int
- SO_J1939_SEND_PRIO: int
- SO_J1939_ERRQUEUE: int
+ SO_J1939_FILTER: Final[int]
+ SO_J1939_PROMISC: Final[int]
+ SO_J1939_SEND_PRIO: Final[int]
+ SO_J1939_ERRQUEUE: Final[int]
- SCM_J1939_DEST_ADDR: int
- SCM_J1939_DEST_NAME: int
- SCM_J1939_PRIO: int
- SCM_J1939_ERRQUEUE: int
+ SCM_J1939_DEST_ADDR: Final[int]
+ SCM_J1939_DEST_NAME: Final[int]
+ SCM_J1939_PRIO: Final[int]
+ SCM_J1939_ERRQUEUE: Final[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
+ J1939_NLA_PAD: Final[int]
+ J1939_NLA_BYTES_ACKED: Final[int]
+ J1939_EE_INFO_NONE: Final[int]
+ J1939_EE_INFO_TX_ABORT: Final[int]
+ J1939_FILTER_MAX: Final[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
+ AF_DIVERT: Final[int]
+ PF_DIVERT: Final[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
+ AF_PACKET: Final[int]
+ PF_PACKET: Final[int]
+ PACKET_BROADCAST: Final[int]
+ PACKET_FASTROUTE: Final[int]
+ PACKET_HOST: Final[int]
+ PACKET_LOOPBACK: Final[int]
+ PACKET_MULTICAST: Final[int]
+ PACKET_OTHERHOST: Final[int]
+ PACKET_OUTGOING: Final[int]
if sys.version_info >= (3, 12) and sys.platform == "linux":
- ETH_P_ALL: int
+ ETH_P_ALL: Final[int]
if sys.platform == "linux":
# Availability: Linux >= 2.6.30
- AF_RDS: int
- PF_RDS: int
- SOL_RDS: int
+ AF_RDS: Final[int]
+ PF_RDS: Final[int]
+ SOL_RDS: Final[int]
# These are present in include/linux/rds.h but don't always show up
# here.
- 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_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
+ RDS_CANCEL_SENT_TO: Final[int]
+ RDS_CMSG_RDMA_ARGS: Final[int]
+ RDS_CMSG_RDMA_DEST: Final[int]
+ RDS_CMSG_RDMA_MAP: Final[int]
+ RDS_CMSG_RDMA_STATUS: Final[int]
+ RDS_CONG_MONITOR: Final[int]
+ RDS_FREE_MR: Final[int]
+ RDS_GET_MR: Final[int]
+ RDS_GET_MR_FOR_DEST: Final[int]
+ RDS_RDMA_DONTWAIT: Final[int]
+ RDS_RDMA_FENCE: Final[int]
+ RDS_RDMA_INVALIDATE: Final[int]
+ RDS_RDMA_NOTIFY_ME: Final[int]
+ RDS_RDMA_READWRITE: Final[int]
+ RDS_RDMA_SILENT: Final[int]
+ RDS_RDMA_USE_ONCE: Final[int]
+ RDS_RECVERR: Final[int]
# This is supported by CPython but doesn't seem to be a real thing.
# The closest existing constant in rds.h is RDS_CMSG_CONG_UPDATE
- # RDS_CMSG_RDMA_UPDATE: int
+ # RDS_CMSG_RDMA_UPDATE: Final[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
+ SIO_RCVALL: Final[int]
+ SIO_KEEPALIVE_VALS: Final[int]
+ SIO_LOOPBACK_FAST_PATH: Final[int]
+ RCVALL_MAX: Final[int]
+ RCVALL_OFF: Final[int]
+ RCVALL_ON: Final[int]
+ RCVALL_SOCKETLEVELONLY: Final[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
+ AF_TIPC: Final[int]
+ SOL_TIPC: Final[int]
+ TIPC_ADDR_ID: Final[int]
+ TIPC_ADDR_NAME: Final[int]
+ TIPC_ADDR_NAMESEQ: Final[int]
+ TIPC_CFG_SRV: Final[int]
+ TIPC_CLUSTER_SCOPE: Final[int]
+ TIPC_CONN_TIMEOUT: Final[int]
+ TIPC_CRITICAL_IMPORTANCE: Final[int]
+ TIPC_DEST_DROPPABLE: Final[int]
+ TIPC_HIGH_IMPORTANCE: Final[int]
+ TIPC_IMPORTANCE: Final[int]
+ TIPC_LOW_IMPORTANCE: Final[int]
+ TIPC_MEDIUM_IMPORTANCE: Final[int]
+ TIPC_NODE_SCOPE: Final[int]
+ TIPC_PUBLISHED: Final[int]
+ TIPC_SRC_DROPPABLE: Final[int]
+ TIPC_SUBSCR_TIMEOUT: Final[int]
+ TIPC_SUB_CANCEL: Final[int]
+ TIPC_SUB_PORTS: Final[int]
+ TIPC_SUB_SERVICE: Final[int]
+ TIPC_TOP_SRV: Final[int]
+ TIPC_WAIT_FOREVER: Final[int]
+ TIPC_WITHDRAWN: Final[int]
+ TIPC_ZONE_SCOPE: Final[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
+ AF_ALG: Final[int]
+ SOL_ALG: Final[int]
+ ALG_OP_DECRYPT: Final[int]
+ ALG_OP_ENCRYPT: Final[int]
+ ALG_OP_SIGN: Final[int]
+ ALG_OP_VERIFY: Final[int]
+ ALG_SET_AEAD_ASSOCLEN: Final[int]
+ ALG_SET_AEAD_AUTHSIZE: Final[int]
+ ALG_SET_IV: Final[int]
+ ALG_SET_KEY: Final[int]
+ ALG_SET_OP: Final[int]
+ ALG_SET_PUBKEY: Final[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
+ AF_VSOCK: Final[int]
+ IOCTL_VM_SOCKETS_GET_LOCAL_CID: Final = 0x7B9
+ VMADDR_CID_ANY: Final = 0xFFFFFFFF
+ VMADDR_CID_HOST: Final = 2
+ VMADDR_PORT_ANY: Final = 0xFFFFFFFF
+ SO_VM_SOCKETS_BUFFER_MAX_SIZE: Final = 2
+ SO_VM_SOCKETS_BUFFER_SIZE: Final = 0
+ SO_VM_SOCKETS_BUFFER_MIN_SIZE: Final = 1
+ VM_SOCKETS_INVALID_VERSION: Final = 0xFFFFFFFF # undocumented
# Documented as only available on BSD, macOS, but empirically sometimes
# available on Windows
if sys.platform != "linux":
- AF_LINK: int
+ AF_LINK: Final[int]
has_ipv6: bool
if sys.platform != "darwin" and sys.platform != "linux":
- BDADDR_ANY: str
- BDADDR_LOCAL: str
+ BDADDR_ANY: Final = "00:00:00:00:00:00"
+ BDADDR_LOCAL: Final = "00:00:00:FF:FF:FF"
if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux":
- 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
+ HCI_FILTER: Final[int] # not in NetBSD or DragonFlyBSD
+ HCI_TIME_STAMP: Final[int] # not in FreeBSD, NetBSD, or DragonFlyBSD
+ HCI_DATA_DIR: Final[int] # not in FreeBSD, NetBSD, or DragonFlyBSD
if sys.platform == "linux":
- AF_QIPCRTR: int # Availability: Linux >= 4.7
+ AF_QIPCRTR: Final[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
+ SCM_CREDS2: Final[int]
+ LOCAL_CREDS: Final[int]
+ LOCAL_CREDS_PERSISTENT: Final[int]
if sys.version_info >= (3, 11) and sys.platform == "linux":
- SO_INCOMING_CPU: int # Availability: Linux >= 3.9
+ SO_INCOMING_CPU: Final[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
+ AF_HYPERV: Final[int]
+ HV_PROTOCOL_RAW: Final[int]
+ HVSOCKET_CONNECT_TIMEOUT: Final[int]
+ HVSOCKET_CONNECT_TIMEOUT_MAX: Final[int]
+ HVSOCKET_CONNECTED_SUSPEND: Final[int]
+ HVSOCKET_ADDRESS_FLAG_PASSTHRU: Final[int]
+ HV_GUID_ZERO: Final = "00000000-0000-0000-0000-000000000000"
+ HV_GUID_WILDCARD: Final = "00000000-0000-0000-0000-000000000000"
+ HV_GUID_BROADCAST: Final = "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"
+ HV_GUID_CHILDREN: Final = "90DB8B89-0D35-4F79-8CE9-49EA0AC8B7CD"
+ HV_GUID_LOOPBACK: Final = "E0E16197-DD56-4A10-9195-5EE7A155A838"
+ HV_GUID_PARENT: Final = "A42E7CDA-D03F-480C-9CC2-A4DE20ABB878"
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
+ ETHERTYPE_ARP: Final[int]
+ ETHERTYPE_IP: Final[int]
+ ETHERTYPE_IPV6: Final[int]
+ ETHERTYPE_VLAN: Final[int]
# --------------------
# Semi-documented constants
@@ -639,95 +639,95 @@ if sys.version_info >= (3, 12):
if sys.platform == "linux":
# Netlink is defined by Linux
- AF_NETLINK: int
- NETLINK_CRYPTO: int
- NETLINK_DNRTMSG: int
- NETLINK_FIREWALL: int
- NETLINK_IP6_FW: int
- NETLINK_NFLOG: int
- NETLINK_ROUTE: int
- NETLINK_USERSOCK: int
- NETLINK_XFRM: int
+ AF_NETLINK: Final[int]
+ NETLINK_CRYPTO: Final[int]
+ NETLINK_DNRTMSG: Final[int]
+ NETLINK_FIREWALL: Final[int]
+ NETLINK_IP6_FW: Final[int]
+ NETLINK_NFLOG: Final[int]
+ NETLINK_ROUTE: Final[int]
+ NETLINK_USERSOCK: Final[int]
+ NETLINK_XFRM: Final[int]
# Technically still supported by CPython
- # NETLINK_ARPD: int # linux 2.0 to 2.6.12 (EOL August 2005)
- # NETLINK_ROUTE6: int # linux 2.2 to 2.6.12 (EOL August 2005)
- # NETLINK_SKIP: int # linux 2.0 to 2.6.12 (EOL August 2005)
- # NETLINK_TAPBASE: int # linux 2.2 to 2.6.12 (EOL August 2005)
- # NETLINK_TCPDIAG: int # linux 2.6.0 to 2.6.13 (EOL December 2005)
- # NETLINK_W1: int # linux 2.6.13 to 2.6.17 (EOL October 2006)
+ # NETLINK_ARPD: Final[int] # linux 2.0 to 2.6.12 (EOL August 2005)
+ # NETLINK_ROUTE6: Final[int] # linux 2.2 to 2.6.12 (EOL August 2005)
+ # NETLINK_SKIP: Final[int] # linux 2.0 to 2.6.12 (EOL August 2005)
+ # NETLINK_TAPBASE: Final[int] # linux 2.2 to 2.6.12 (EOL August 2005)
+ # NETLINK_TCPDIAG: Final[int] # linux 2.6.0 to 2.6.13 (EOL December 2005)
+ # NETLINK_W1: Final[int] # linux 2.6.13 to 2.6.17 (EOL October 2006)
if sys.platform == "darwin":
- PF_SYSTEM: int
- SYSPROTO_CONTROL: int
+ PF_SYSTEM: Final[int]
+ SYSPROTO_CONTROL: Final[int]
if sys.platform != "darwin" and sys.platform != "linux":
- AF_BLUETOOTH: int
+ AF_BLUETOOTH: Final[int]
if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux":
# 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
+ BTPROTO_HCI: Final[int]
+ BTPROTO_L2CAP: Final[int]
+ BTPROTO_SCO: Final[int] # not in FreeBSD
if sys.platform != "darwin" and sys.platform != "linux":
- BTPROTO_RFCOMM: int
+ BTPROTO_RFCOMM: Final[int]
if sys.platform == "linux":
- UDPLITE_RECV_CSCOV: int
- UDPLITE_SEND_CSCOV: int
+ UDPLITE_RECV_CSCOV: Final[int]
+ UDPLITE_SEND_CSCOV: Final[int]
# --------------------
# Documented under socket.shutdown
# --------------------
-SHUT_RD: int
-SHUT_RDWR: int
-SHUT_WR: int
+SHUT_RD: Final[int]
+SHUT_RDWR: Final[int]
+SHUT_WR: Final[int]
# --------------------
# Undocumented constants
# --------------------
# Undocumented address families
-AF_APPLETALK: int
-AF_DECnet: int
-AF_IPX: int
-AF_SNA: int
+AF_APPLETALK: Final[int]
+AF_DECnet: Final[int]
+AF_IPX: Final[int]
+AF_SNA: Final[int]
if sys.platform != "win32":
- AF_ROUTE: int
+ AF_ROUTE: Final[int]
if sys.platform == "darwin":
- AF_SYSTEM: int
+ AF_SYSTEM: Final[int]
if sys.platform != "darwin":
- AF_IRDA: int
+ AF_IRDA: Final[int]
if sys.platform != "win32" and sys.platform != "darwin":
- 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
+ AF_ASH: Final[int]
+ AF_ATMPVC: Final[int]
+ AF_ATMSVC: Final[int]
+ AF_AX25: Final[int]
+ AF_BRIDGE: Final[int]
+ AF_ECONET: Final[int]
+ AF_KEY: Final[int]
+ AF_LLC: Final[int]
+ AF_NETBEUI: Final[int]
+ AF_NETROM: Final[int]
+ AF_PPPOX: Final[int]
+ AF_ROSE: Final[int]
+ AF_SECURITY: Final[int]
+ AF_WANPIPE: Final[int]
+ AF_X25: Final[int]
# Miscellaneous undocumented
if sys.platform != "win32" and sys.platform != "linux":
- LOCAL_PEERCRED: int
+ LOCAL_PEERCRED: Final[int]
if sys.platform != "win32" and sys.platform != "darwin":
# Defined in linux socket.h, but this isn't always present for
# some reason.
- IPX_TYPE: int
+ IPX_TYPE: Final[int]
# ===== Classes =====
@@ -743,10 +743,10 @@ class socket:
def timeout(self) -> float | None: ... # noqa: F811
if sys.platform == "win32":
def __init__(
- self, family: int = ..., type: int = ..., proto: int = ..., fileno: SupportsIndex | bytes | None = ...
+ self, family: int = ..., type: int = ..., proto: int = ..., fileno: SupportsIndex | bytes | None = None
) -> None: ...
else:
- def __init__(self, family: int = ..., type: int = ..., proto: int = ..., fileno: SupportsIndex | None = ...) -> None: ...
+ def __init__(self, family: int = ..., type: int = ..., proto: int = ..., fileno: SupportsIndex | None = None) -> None: ...
def bind(self, address: _Address, /) -> None: ...
def close(self) -> None: ...
@@ -766,18 +766,18 @@ class socket:
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]: ...
+ def recv(self, bufsize: int, flags: int = 0, /) -> bytes: ...
+ def recvfrom(self, bufsize: int, flags: int = 0, /) -> tuple[bytes, _RetAddress]: ...
if sys.platform != "win32":
- def recvmsg(self, bufsize: int, ancbufsize: int = ..., flags: int = ..., /) -> tuple[bytes, list[_CMSG], int, Any]: ...
+ def recvmsg(self, bufsize: int, ancbufsize: int = 0, flags: int = 0, /) -> tuple[bytes, list[_CMSG], int, Any]: ...
def recvmsg_into(
- self, buffers: Iterable[WriteableBuffer], ancbufsize: int = ..., flags: int = ..., /
+ self, buffers: Iterable[WriteableBuffer], ancbufsize: int = 0, flags: int = 0, /
) -> 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: ...
+ def recvfrom_into(self, buffer: WriteableBuffer, nbytes: int = 0, flags: int = 0) -> tuple[int, _RetAddress]: ...
+ def recv_into(self, buffer: WriteableBuffer, nbytes: int = 0, flags: int = 0) -> int: ...
+ def send(self, data: ReadableBuffer, flags: int = 0, /) -> int: ...
+ def sendall(self, data: ReadableBuffer, flags: int = 0, /) -> None: ...
@overload
def sendto(self, data: ReadableBuffer, address: _Address, /) -> int: ...
@overload
@@ -787,13 +787,13 @@ class socket:
self,
buffers: Iterable[ReadableBuffer],
ancdata: Iterable[_CMSGArg] = ...,
- flags: int = ...,
- address: _Address | None = ...,
+ flags: int = 0,
+ address: _Address | None = None,
/,
) -> int: ...
if sys.platform == "linux":
def sendmsg_afalg(
- self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ...
+ self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = 0
) -> int: ...
def setblocking(self, flag: bool, /) -> None: ...
@@ -816,12 +816,7 @@ 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 = ...,
+ host: bytes | str | None, port: bytes | str | int | None, family: int = ..., type: int = 0, proto: int = 0, flags: int = 0
) -> list[tuple[int, int, int, str, tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes]]]: ...
def gethostbyname(hostname: str, /) -> str: ...
def gethostbyname_ex(hostname: str, /) -> tuple[str, list[str], list[str]]: ...
@@ -848,7 +843,7 @@ 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 socketpair(family: int = ..., type: int = ..., proto: int = 0, /) -> tuple[socket, socket]: ...
def if_nameindex() -> list[tuple[int, str]]: ...
def if_nametoindex(oname: str, /) -> int: ...
diff --git a/python/helpers/typeshed/stdlib/_sqlite3.pyi b/python/helpers/typeshed/stdlib/_sqlite3.pyi
index 6f06542c1ba7..50006dcf4032 100644
--- a/python/helpers/typeshed/stdlib/_sqlite3.pyi
+++ b/python/helpers/typeshed/stdlib/_sqlite3.pyi
@@ -16,6 +16,7 @@ from sqlite3 import (
ProgrammingError as ProgrammingError,
Row as Row,
Warning as Warning,
+ _IsolationLevel,
)
from typing import Any, Final, Literal, TypeVar, overload
from typing_extensions import TypeAlias
@@ -29,45 +30,45 @@ _SqliteData: TypeAlias = str | ReadableBuffer | int | float | None
_Adapter: TypeAlias = Callable[[_T], _SqliteData]
_Converter: TypeAlias = Callable[[bytes], Any]
-PARSE_COLNAMES: Final[int]
-PARSE_DECLTYPES: Final[int]
-SQLITE_ALTER_TABLE: Final[int]
-SQLITE_ANALYZE: Final[int]
-SQLITE_ATTACH: Final[int]
-SQLITE_CREATE_INDEX: Final[int]
-SQLITE_CREATE_TABLE: Final[int]
-SQLITE_CREATE_TEMP_INDEX: Final[int]
-SQLITE_CREATE_TEMP_TABLE: Final[int]
-SQLITE_CREATE_TEMP_TRIGGER: Final[int]
-SQLITE_CREATE_TEMP_VIEW: Final[int]
-SQLITE_CREATE_TRIGGER: Final[int]
-SQLITE_CREATE_VIEW: Final[int]
-SQLITE_CREATE_VTABLE: Final[int]
-SQLITE_DELETE: Final[int]
-SQLITE_DENY: Final[int]
-SQLITE_DETACH: Final[int]
-SQLITE_DONE: Final[int]
-SQLITE_DROP_INDEX: Final[int]
-SQLITE_DROP_TABLE: Final[int]
-SQLITE_DROP_TEMP_INDEX: Final[int]
-SQLITE_DROP_TEMP_TABLE: Final[int]
-SQLITE_DROP_TEMP_TRIGGER: Final[int]
-SQLITE_DROP_TEMP_VIEW: Final[int]
-SQLITE_DROP_TRIGGER: Final[int]
-SQLITE_DROP_VIEW: Final[int]
-SQLITE_DROP_VTABLE: Final[int]
-SQLITE_FUNCTION: Final[int]
-SQLITE_IGNORE: Final[int]
-SQLITE_INSERT: Final[int]
-SQLITE_OK: Final[int]
-SQLITE_PRAGMA: Final[int]
-SQLITE_READ: Final[int]
-SQLITE_RECURSIVE: Final[int]
-SQLITE_REINDEX: Final[int]
-SQLITE_SAVEPOINT: Final[int]
-SQLITE_SELECT: Final[int]
-SQLITE_TRANSACTION: Final[int]
-SQLITE_UPDATE: Final[int]
+PARSE_COLNAMES: Final = 2
+PARSE_DECLTYPES: Final = 1
+SQLITE_ALTER_TABLE: Final = 26
+SQLITE_ANALYZE: Final = 28
+SQLITE_ATTACH: Final = 24
+SQLITE_CREATE_INDEX: Final = 1
+SQLITE_CREATE_TABLE: Final = 2
+SQLITE_CREATE_TEMP_INDEX: Final = 3
+SQLITE_CREATE_TEMP_TABLE: Final = 4
+SQLITE_CREATE_TEMP_TRIGGER: Final = 5
+SQLITE_CREATE_TEMP_VIEW: Final = 6
+SQLITE_CREATE_TRIGGER: Final = 7
+SQLITE_CREATE_VIEW: Final = 8
+SQLITE_CREATE_VTABLE: Final = 29
+SQLITE_DELETE: Final = 9
+SQLITE_DENY: Final = 1
+SQLITE_DETACH: Final = 25
+SQLITE_DONE: Final = 101
+SQLITE_DROP_INDEX: Final = 10
+SQLITE_DROP_TABLE: Final = 11
+SQLITE_DROP_TEMP_INDEX: Final = 12
+SQLITE_DROP_TEMP_TABLE: Final = 13
+SQLITE_DROP_TEMP_TRIGGER: Final = 14
+SQLITE_DROP_TEMP_VIEW: Final = 15
+SQLITE_DROP_TRIGGER: Final = 16
+SQLITE_DROP_VIEW: Final = 17
+SQLITE_DROP_VTABLE: Final = 30
+SQLITE_FUNCTION: Final = 31
+SQLITE_IGNORE: Final = 2
+SQLITE_INSERT: Final = 18
+SQLITE_OK: Final = 0
+SQLITE_PRAGMA: Final = 19
+SQLITE_READ: Final = 20
+SQLITE_RECURSIVE: Final = 33
+SQLITE_REINDEX: Final = 27
+SQLITE_SAVEPOINT: Final = 32
+SQLITE_SELECT: Final = 21
+SQLITE_TRANSACTION: Final = 22
+SQLITE_UPDATE: Final = 23
adapters: dict[tuple[type[Any], type[Any]], _Adapter[Any]]
converters: dict[str, _Converter]
sqlite_version: str
@@ -76,141 +77,141 @@ if sys.version_info < (3, 12):
version: str
if sys.version_info >= (3, 12):
- LEGACY_TRANSACTION_CONTROL: Final[int]
- SQLITE_DBCONFIG_DEFENSIVE: Final[int]
- SQLITE_DBCONFIG_DQS_DDL: Final[int]
- SQLITE_DBCONFIG_DQS_DML: Final[int]
- SQLITE_DBCONFIG_ENABLE_FKEY: Final[int]
- SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER: Final[int]
- SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION: Final[int]
- SQLITE_DBCONFIG_ENABLE_QPSG: Final[int]
- SQLITE_DBCONFIG_ENABLE_TRIGGER: Final[int]
- SQLITE_DBCONFIG_ENABLE_VIEW: Final[int]
- SQLITE_DBCONFIG_LEGACY_ALTER_TABLE: Final[int]
- SQLITE_DBCONFIG_LEGACY_FILE_FORMAT: Final[int]
- SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE: Final[int]
- SQLITE_DBCONFIG_RESET_DATABASE: Final[int]
- SQLITE_DBCONFIG_TRIGGER_EQP: Final[int]
- SQLITE_DBCONFIG_TRUSTED_SCHEMA: Final[int]
- SQLITE_DBCONFIG_WRITABLE_SCHEMA: Final[int]
+ LEGACY_TRANSACTION_CONTROL: Final = -1
+ SQLITE_DBCONFIG_DEFENSIVE: Final = 1010
+ SQLITE_DBCONFIG_DQS_DDL: Final = 1014
+ SQLITE_DBCONFIG_DQS_DML: Final = 1013
+ SQLITE_DBCONFIG_ENABLE_FKEY: Final = 1002
+ SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER: Final = 1004
+ SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION: Final = 1005
+ SQLITE_DBCONFIG_ENABLE_QPSG: Final = 1007
+ SQLITE_DBCONFIG_ENABLE_TRIGGER: Final = 1003
+ SQLITE_DBCONFIG_ENABLE_VIEW: Final = 1015
+ SQLITE_DBCONFIG_LEGACY_ALTER_TABLE: Final = 1012
+ SQLITE_DBCONFIG_LEGACY_FILE_FORMAT: Final = 1016
+ SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE: Final = 1006
+ SQLITE_DBCONFIG_RESET_DATABASE: Final = 1009
+ SQLITE_DBCONFIG_TRIGGER_EQP: Final = 1008
+ SQLITE_DBCONFIG_TRUSTED_SCHEMA: Final = 1017
+ SQLITE_DBCONFIG_WRITABLE_SCHEMA: Final = 1011
if sys.version_info >= (3, 11):
- SQLITE_ABORT: Final[int]
- SQLITE_ABORT_ROLLBACK: Final[int]
- SQLITE_AUTH: Final[int]
- SQLITE_AUTH_USER: Final[int]
- SQLITE_BUSY: Final[int]
- SQLITE_BUSY_RECOVERY: Final[int]
- SQLITE_BUSY_SNAPSHOT: Final[int]
- SQLITE_BUSY_TIMEOUT: Final[int]
- SQLITE_CANTOPEN: Final[int]
- SQLITE_CANTOPEN_CONVPATH: Final[int]
- SQLITE_CANTOPEN_DIRTYWAL: Final[int]
- SQLITE_CANTOPEN_FULLPATH: Final[int]
- SQLITE_CANTOPEN_ISDIR: Final[int]
- SQLITE_CANTOPEN_NOTEMPDIR: Final[int]
- SQLITE_CANTOPEN_SYMLINK: Final[int]
- SQLITE_CONSTRAINT: Final[int]
- SQLITE_CONSTRAINT_CHECK: Final[int]
- SQLITE_CONSTRAINT_COMMITHOOK: Final[int]
- SQLITE_CONSTRAINT_FOREIGNKEY: Final[int]
- SQLITE_CONSTRAINT_FUNCTION: Final[int]
- SQLITE_CONSTRAINT_NOTNULL: Final[int]
- SQLITE_CONSTRAINT_PINNED: Final[int]
- SQLITE_CONSTRAINT_PRIMARYKEY: Final[int]
- SQLITE_CONSTRAINT_ROWID: Final[int]
- SQLITE_CONSTRAINT_TRIGGER: Final[int]
- SQLITE_CONSTRAINT_UNIQUE: Final[int]
- SQLITE_CONSTRAINT_VTAB: Final[int]
- SQLITE_CORRUPT: Final[int]
- SQLITE_CORRUPT_INDEX: Final[int]
- SQLITE_CORRUPT_SEQUENCE: Final[int]
- SQLITE_CORRUPT_VTAB: Final[int]
- SQLITE_EMPTY: Final[int]
- SQLITE_ERROR: Final[int]
- SQLITE_ERROR_MISSING_COLLSEQ: Final[int]
- SQLITE_ERROR_RETRY: Final[int]
- SQLITE_ERROR_SNAPSHOT: Final[int]
- SQLITE_FORMAT: Final[int]
- SQLITE_FULL: Final[int]
- SQLITE_INTERNAL: Final[int]
- SQLITE_INTERRUPT: Final[int]
- SQLITE_IOERR: Final[int]
- SQLITE_IOERR_ACCESS: Final[int]
- SQLITE_IOERR_AUTH: Final[int]
- SQLITE_IOERR_BEGIN_ATOMIC: Final[int]
- SQLITE_IOERR_BLOCKED: Final[int]
- SQLITE_IOERR_CHECKRESERVEDLOCK: Final[int]
- SQLITE_IOERR_CLOSE: Final[int]
- SQLITE_IOERR_COMMIT_ATOMIC: Final[int]
- SQLITE_IOERR_CONVPATH: Final[int]
- SQLITE_IOERR_CORRUPTFS: Final[int]
- SQLITE_IOERR_DATA: Final[int]
- SQLITE_IOERR_DELETE: Final[int]
- SQLITE_IOERR_DELETE_NOENT: Final[int]
- SQLITE_IOERR_DIR_CLOSE: Final[int]
- SQLITE_IOERR_DIR_FSYNC: Final[int]
- SQLITE_IOERR_FSTAT: Final[int]
- SQLITE_IOERR_FSYNC: Final[int]
- SQLITE_IOERR_GETTEMPPATH: Final[int]
- SQLITE_IOERR_LOCK: Final[int]
- SQLITE_IOERR_MMAP: Final[int]
- SQLITE_IOERR_NOMEM: Final[int]
- SQLITE_IOERR_RDLOCK: Final[int]
- SQLITE_IOERR_READ: Final[int]
- SQLITE_IOERR_ROLLBACK_ATOMIC: Final[int]
- SQLITE_IOERR_SEEK: Final[int]
- SQLITE_IOERR_SHMLOCK: Final[int]
- SQLITE_IOERR_SHMMAP: Final[int]
- SQLITE_IOERR_SHMOPEN: Final[int]
- SQLITE_IOERR_SHMSIZE: Final[int]
- SQLITE_IOERR_SHORT_READ: Final[int]
- SQLITE_IOERR_TRUNCATE: Final[int]
- SQLITE_IOERR_UNLOCK: Final[int]
- SQLITE_IOERR_VNODE: Final[int]
- SQLITE_IOERR_WRITE: Final[int]
- SQLITE_LIMIT_ATTACHED: Final[int]
- SQLITE_LIMIT_COLUMN: Final[int]
- SQLITE_LIMIT_COMPOUND_SELECT: Final[int]
- SQLITE_LIMIT_EXPR_DEPTH: Final[int]
- SQLITE_LIMIT_FUNCTION_ARG: Final[int]
- SQLITE_LIMIT_LENGTH: Final[int]
- SQLITE_LIMIT_LIKE_PATTERN_LENGTH: Final[int]
- SQLITE_LIMIT_SQL_LENGTH: Final[int]
- SQLITE_LIMIT_TRIGGER_DEPTH: Final[int]
- SQLITE_LIMIT_VARIABLE_NUMBER: Final[int]
- SQLITE_LIMIT_VDBE_OP: Final[int]
- SQLITE_LIMIT_WORKER_THREADS: Final[int]
- SQLITE_LOCKED: Final[int]
- SQLITE_LOCKED_SHAREDCACHE: Final[int]
- SQLITE_LOCKED_VTAB: Final[int]
- SQLITE_MISMATCH: Final[int]
- SQLITE_MISUSE: Final[int]
- SQLITE_NOLFS: Final[int]
- SQLITE_NOMEM: Final[int]
- SQLITE_NOTADB: Final[int]
- SQLITE_NOTFOUND: Final[int]
- SQLITE_NOTICE: Final[int]
- SQLITE_NOTICE_RECOVER_ROLLBACK: Final[int]
- SQLITE_NOTICE_RECOVER_WAL: Final[int]
- SQLITE_OK_LOAD_PERMANENTLY: Final[int]
- SQLITE_OK_SYMLINK: Final[int]
- SQLITE_PERM: Final[int]
- SQLITE_PROTOCOL: Final[int]
- SQLITE_RANGE: Final[int]
- SQLITE_READONLY: Final[int]
- SQLITE_READONLY_CANTINIT: Final[int]
- SQLITE_READONLY_CANTLOCK: Final[int]
- SQLITE_READONLY_DBMOVED: Final[int]
- SQLITE_READONLY_DIRECTORY: Final[int]
- SQLITE_READONLY_RECOVERY: Final[int]
- SQLITE_READONLY_ROLLBACK: Final[int]
- SQLITE_ROW: Final[int]
- SQLITE_SCHEMA: Final[int]
- SQLITE_TOOBIG: Final[int]
- SQLITE_WARNING: Final[int]
- SQLITE_WARNING_AUTOINDEX: Final[int]
- threadsafety: Final[int]
+ SQLITE_ABORT: Final = 4
+ SQLITE_ABORT_ROLLBACK: Final = 516
+ SQLITE_AUTH: Final = 23
+ SQLITE_AUTH_USER: Final = 279
+ SQLITE_BUSY: Final = 5
+ SQLITE_BUSY_RECOVERY: Final = 261
+ SQLITE_BUSY_SNAPSHOT: Final = 517
+ SQLITE_BUSY_TIMEOUT: Final = 773
+ SQLITE_CANTOPEN: Final = 14
+ SQLITE_CANTOPEN_CONVPATH: Final = 1038
+ SQLITE_CANTOPEN_DIRTYWAL: Final = 1294
+ SQLITE_CANTOPEN_FULLPATH: Final = 782
+ SQLITE_CANTOPEN_ISDIR: Final = 526
+ SQLITE_CANTOPEN_NOTEMPDIR: Final = 270
+ SQLITE_CANTOPEN_SYMLINK: Final = 1550
+ SQLITE_CONSTRAINT: Final = 19
+ SQLITE_CONSTRAINT_CHECK: Final = 275
+ SQLITE_CONSTRAINT_COMMITHOOK: Final = 531
+ SQLITE_CONSTRAINT_FOREIGNKEY: Final = 787
+ SQLITE_CONSTRAINT_FUNCTION: Final = 1043
+ SQLITE_CONSTRAINT_NOTNULL: Final = 1299
+ SQLITE_CONSTRAINT_PINNED: Final = 2835
+ SQLITE_CONSTRAINT_PRIMARYKEY: Final = 1555
+ SQLITE_CONSTRAINT_ROWID: Final = 2579
+ SQLITE_CONSTRAINT_TRIGGER: Final = 1811
+ SQLITE_CONSTRAINT_UNIQUE: Final = 2067
+ SQLITE_CONSTRAINT_VTAB: Final = 2323
+ SQLITE_CORRUPT: Final = 11
+ SQLITE_CORRUPT_INDEX: Final = 779
+ SQLITE_CORRUPT_SEQUENCE: Final = 523
+ SQLITE_CORRUPT_VTAB: Final = 267
+ SQLITE_EMPTY: Final = 16
+ SQLITE_ERROR: Final = 1
+ SQLITE_ERROR_MISSING_COLLSEQ: Final = 257
+ SQLITE_ERROR_RETRY: Final = 513
+ SQLITE_ERROR_SNAPSHOT: Final = 769
+ SQLITE_FORMAT: Final = 24
+ SQLITE_FULL: Final = 13
+ SQLITE_INTERNAL: Final = 2
+ SQLITE_INTERRUPT: Final = 9
+ SQLITE_IOERR: Final = 10
+ SQLITE_IOERR_ACCESS: Final = 3338
+ SQLITE_IOERR_AUTH: Final = 7178
+ SQLITE_IOERR_BEGIN_ATOMIC: Final = 7434
+ SQLITE_IOERR_BLOCKED: Final = 2826
+ SQLITE_IOERR_CHECKRESERVEDLOCK: Final = 3594
+ SQLITE_IOERR_CLOSE: Final = 4106
+ SQLITE_IOERR_COMMIT_ATOMIC: Final = 7690
+ SQLITE_IOERR_CONVPATH: Final = 6666
+ SQLITE_IOERR_CORRUPTFS: Final = 8458
+ SQLITE_IOERR_DATA: Final = 8202
+ SQLITE_IOERR_DELETE: Final = 2570
+ SQLITE_IOERR_DELETE_NOENT: Final = 5898
+ SQLITE_IOERR_DIR_CLOSE: Final = 4362
+ SQLITE_IOERR_DIR_FSYNC: Final = 1290
+ SQLITE_IOERR_FSTAT: Final = 1802
+ SQLITE_IOERR_FSYNC: Final = 1034
+ SQLITE_IOERR_GETTEMPPATH: Final = 6410
+ SQLITE_IOERR_LOCK: Final = 3850
+ SQLITE_IOERR_MMAP: Final = 6154
+ SQLITE_IOERR_NOMEM: Final = 3082
+ SQLITE_IOERR_RDLOCK: Final = 2314
+ SQLITE_IOERR_READ: Final = 266
+ SQLITE_IOERR_ROLLBACK_ATOMIC: Final = 7946
+ SQLITE_IOERR_SEEK: Final = 5642
+ SQLITE_IOERR_SHMLOCK: Final = 5130
+ SQLITE_IOERR_SHMMAP: Final = 5386
+ SQLITE_IOERR_SHMOPEN: Final = 4618
+ SQLITE_IOERR_SHMSIZE: Final = 4874
+ SQLITE_IOERR_SHORT_READ: Final = 522
+ SQLITE_IOERR_TRUNCATE: Final = 1546
+ SQLITE_IOERR_UNLOCK: Final = 2058
+ SQLITE_IOERR_VNODE: Final = 6922
+ SQLITE_IOERR_WRITE: Final = 778
+ SQLITE_LIMIT_ATTACHED: Final = 7
+ SQLITE_LIMIT_COLUMN: Final = 22
+ SQLITE_LIMIT_COMPOUND_SELECT: Final = 4
+ SQLITE_LIMIT_EXPR_DEPTH: Final = 3
+ SQLITE_LIMIT_FUNCTION_ARG: Final = 6
+ SQLITE_LIMIT_LENGTH: Final = 0
+ SQLITE_LIMIT_LIKE_PATTERN_LENGTH: Final = 8
+ SQLITE_LIMIT_SQL_LENGTH: Final = 1
+ SQLITE_LIMIT_TRIGGER_DEPTH: Final = 10
+ SQLITE_LIMIT_VARIABLE_NUMBER: Final = 9
+ SQLITE_LIMIT_VDBE_OP: Final = 5
+ SQLITE_LIMIT_WORKER_THREADS: Final = 11
+ SQLITE_LOCKED: Final = 6
+ SQLITE_LOCKED_SHAREDCACHE: Final = 262
+ SQLITE_LOCKED_VTAB: Final = 518
+ SQLITE_MISMATCH: Final = 20
+ SQLITE_MISUSE: Final = 21
+ SQLITE_NOLFS: Final = 22
+ SQLITE_NOMEM: Final = 7
+ SQLITE_NOTADB: Final = 26
+ SQLITE_NOTFOUND: Final = 12
+ SQLITE_NOTICE: Final = 27
+ SQLITE_NOTICE_RECOVER_ROLLBACK: Final = 539
+ SQLITE_NOTICE_RECOVER_WAL: Final = 283
+ SQLITE_OK_LOAD_PERMANENTLY: Final = 256
+ SQLITE_OK_SYMLINK: Final = 512
+ SQLITE_PERM: Final = 3
+ SQLITE_PROTOCOL: Final = 15
+ SQLITE_RANGE: Final = 25
+ SQLITE_READONLY: Final = 8
+ SQLITE_READONLY_CANTINIT: Final = 1288
+ SQLITE_READONLY_CANTLOCK: Final = 520
+ SQLITE_READONLY_DBMOVED: Final = 1032
+ SQLITE_READONLY_DIRECTORY: Final = 1544
+ SQLITE_READONLY_RECOVERY: Final = 264
+ SQLITE_READONLY_ROLLBACK: Final = 776
+ SQLITE_ROW: Final = 100
+ SQLITE_SCHEMA: Final = 17
+ SQLITE_TOOBIG: Final = 18
+ SQLITE_WARNING: Final = 28
+ SQLITE_WARNING_AUTOINDEX: Final = 284
+ threadsafety: Literal[0, 1, 3]
# Can take or return anything depending on what's in the registry.
@overload
@@ -225,7 +226,7 @@ if sys.version_info >= (3, 12):
database: StrOrBytesPath,
timeout: float = 5.0,
detect_types: int = 0,
- isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None = "DEFERRED",
+ isolation_level: _IsolationLevel = "DEFERRED",
check_same_thread: bool = True,
cached_statements: int = 128,
uri: bool = False,
@@ -237,7 +238,7 @@ if sys.version_info >= (3, 12):
database: StrOrBytesPath,
timeout: float,
detect_types: int,
- isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None,
+ isolation_level: _IsolationLevel,
check_same_thread: bool,
factory: type[_ConnectionT],
cached_statements: int = 128,
@@ -250,7 +251,7 @@ if sys.version_info >= (3, 12):
database: StrOrBytesPath,
timeout: float = 5.0,
detect_types: int = 0,
- isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None = "DEFERRED",
+ isolation_level: _IsolationLevel = "DEFERRED",
check_same_thread: bool = True,
*,
factory: type[_ConnectionT],
@@ -265,7 +266,7 @@ else:
database: StrOrBytesPath,
timeout: float = 5.0,
detect_types: int = 0,
- isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None = "DEFERRED",
+ isolation_level: _IsolationLevel = "DEFERRED",
check_same_thread: bool = True,
cached_statements: int = 128,
uri: bool = False,
@@ -275,7 +276,7 @@ else:
database: StrOrBytesPath,
timeout: float,
detect_types: int,
- isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None,
+ isolation_level: _IsolationLevel,
check_same_thread: bool,
factory: type[_ConnectionT],
cached_statements: int = 128,
@@ -286,7 +287,7 @@ else:
database: StrOrBytesPath,
timeout: float = 5.0,
detect_types: int = 0,
- isolation_level: Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None = "DEFERRED",
+ isolation_level: _IsolationLevel = "DEFERRED",
check_same_thread: bool = True,
*,
factory: type[_ConnectionT],
diff --git a/python/helpers/typeshed/stdlib/_ssl.pyi b/python/helpers/typeshed/stdlib/_ssl.pyi
index 7ab880e4def7..8afa3e5297bd 100644
--- a/python/helpers/typeshed/stdlib/_ssl.pyi
+++ b/python/helpers/typeshed/stdlib/_ssl.pyi
@@ -12,14 +12,15 @@ from ssl import (
SSLWantWriteError as SSLWantWriteError,
SSLZeroReturnError as SSLZeroReturnError,
)
-from typing import Any, ClassVar, Literal, TypedDict, final, overload
-from typing_extensions import NotRequired, Self, TypeAlias
+from typing import Any, ClassVar, Final, Literal, TypedDict, final, overload, type_check_only
+from typing_extensions import NotRequired, Self, TypeAlias, deprecated
_PasswordType: TypeAlias = Callable[[], str | bytes | bytearray] | str | bytes | bytearray
_PCTRTT: TypeAlias = tuple[tuple[str, str], ...]
_PCTRTTT: TypeAlias = tuple[_PCTRTT, ...]
_PeerCertRetDictType: TypeAlias = dict[str, str | _PCTRTTT | _PCTRTT]
+@type_check_only
class _Cipher(TypedDict):
aead: bool
alg_bits: int
@@ -33,6 +34,7 @@ class _Cipher(TypedDict):
strength_bits: int
symmetric: str
+@type_check_only
class _CertInfo(TypedDict):
subject: tuple[tuple[tuple[str, str], ...], ...]
issuer: tuple[tuple[tuple[str, str], ...], ...]
@@ -49,6 +51,7 @@ def RAND_add(string: str | ReadableBuffer, entropy: float, /) -> None: ...
def RAND_bytes(n: int, /) -> bytes: ...
if sys.version_info < (3, 12):
+ @deprecated("Deprecated since Python 3.6; removed in Python 3.12. Use `ssl.RAND_bytes()` instead.")
def RAND_pseudo_bytes(n: int, /) -> tuple[bytes, bool]: ...
if sys.version_info < (3, 10):
@@ -159,135 +162,134 @@ if sys.version_info < (3, 12):
err_names_to_codes: dict[str, tuple[int, int]]
lib_codes_to_names: dict[int, str]
-_DEFAULT_CIPHERS: str
+_DEFAULT_CIPHERS: Final[str]
# SSL error numbers
-SSL_ERROR_ZERO_RETURN: int
-SSL_ERROR_WANT_READ: int
-SSL_ERROR_WANT_WRITE: int
-SSL_ERROR_WANT_X509_LOOKUP: int
-SSL_ERROR_SYSCALL: int
-SSL_ERROR_SSL: int
-SSL_ERROR_WANT_CONNECT: int
-SSL_ERROR_EOF: int
-SSL_ERROR_INVALID_ERROR_CODE: int
+SSL_ERROR_ZERO_RETURN: Final = 6
+SSL_ERROR_WANT_READ: Final = 2
+SSL_ERROR_WANT_WRITE: Final = 3
+SSL_ERROR_WANT_X509_LOOKUP: Final = 4
+SSL_ERROR_SYSCALL: Final = 5
+SSL_ERROR_SSL: Final = 1
+SSL_ERROR_WANT_CONNECT: Final = 7
+SSL_ERROR_EOF: Final = 8
+SSL_ERROR_INVALID_ERROR_CODE: Final = 10
# verify modes
-CERT_NONE: int
-CERT_OPTIONAL: int
-CERT_REQUIRED: int
+CERT_NONE: Final = 0
+CERT_OPTIONAL: Final = 1
+CERT_REQUIRED: Final = 2
# verify flags
-VERIFY_DEFAULT: int
-VERIFY_CRL_CHECK_LEAF: int
-VERIFY_CRL_CHECK_CHAIN: int
-VERIFY_X509_STRICT: int
-VERIFY_X509_TRUSTED_FIRST: int
+VERIFY_DEFAULT: Final = 0
+VERIFY_CRL_CHECK_LEAF: Final = 0x4
+VERIFY_CRL_CHECK_CHAIN: Final = 0x8
+VERIFY_X509_STRICT: Final = 0x20
+VERIFY_X509_TRUSTED_FIRST: Final = 0x8000
if sys.version_info >= (3, 10):
- VERIFY_ALLOW_PROXY_CERTS: int
- VERIFY_X509_PARTIAL_CHAIN: int
+ VERIFY_ALLOW_PROXY_CERTS: Final = 0x40
+ VERIFY_X509_PARTIAL_CHAIN: Final = 0x80000
# alert descriptions
-ALERT_DESCRIPTION_CLOSE_NOTIFY: int
-ALERT_DESCRIPTION_UNEXPECTED_MESSAGE: int
-ALERT_DESCRIPTION_BAD_RECORD_MAC: int
-ALERT_DESCRIPTION_RECORD_OVERFLOW: int
-ALERT_DESCRIPTION_DECOMPRESSION_FAILURE: int
-ALERT_DESCRIPTION_HANDSHAKE_FAILURE: int
-ALERT_DESCRIPTION_BAD_CERTIFICATE: int
-ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE: int
-ALERT_DESCRIPTION_CERTIFICATE_REVOKED: int
-ALERT_DESCRIPTION_CERTIFICATE_EXPIRED: int
-ALERT_DESCRIPTION_CERTIFICATE_UNKNOWN: int
-ALERT_DESCRIPTION_ILLEGAL_PARAMETER: int
-ALERT_DESCRIPTION_UNKNOWN_CA: int
-ALERT_DESCRIPTION_ACCESS_DENIED: int
-ALERT_DESCRIPTION_DECODE_ERROR: int
-ALERT_DESCRIPTION_DECRYPT_ERROR: int
-ALERT_DESCRIPTION_PROTOCOL_VERSION: int
-ALERT_DESCRIPTION_INSUFFICIENT_SECURITY: int
-ALERT_DESCRIPTION_INTERNAL_ERROR: int
-ALERT_DESCRIPTION_USER_CANCELLED: int
-ALERT_DESCRIPTION_NO_RENEGOTIATION: int
-ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION: int
-ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE: int
-ALERT_DESCRIPTION_UNRECOGNIZED_NAME: int
-ALERT_DESCRIPTION_BAD_CERTIFICATE_STATUS_RESPONSE: int
-ALERT_DESCRIPTION_BAD_CERTIFICATE_HASH_VALUE: int
-ALERT_DESCRIPTION_UNKNOWN_PSK_IDENTITY: int
+ALERT_DESCRIPTION_CLOSE_NOTIFY: Final = 0
+ALERT_DESCRIPTION_UNEXPECTED_MESSAGE: Final = 10
+ALERT_DESCRIPTION_BAD_RECORD_MAC: Final = 20
+ALERT_DESCRIPTION_RECORD_OVERFLOW: Final = 22
+ALERT_DESCRIPTION_DECOMPRESSION_FAILURE: Final = 30
+ALERT_DESCRIPTION_HANDSHAKE_FAILURE: Final = 40
+ALERT_DESCRIPTION_BAD_CERTIFICATE: Final = 42
+ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE: Final = 43
+ALERT_DESCRIPTION_CERTIFICATE_REVOKED: Final = 44
+ALERT_DESCRIPTION_CERTIFICATE_EXPIRED: Final = 45
+ALERT_DESCRIPTION_CERTIFICATE_UNKNOWN: Final = 46
+ALERT_DESCRIPTION_ILLEGAL_PARAMETER: Final = 47
+ALERT_DESCRIPTION_UNKNOWN_CA: Final = 48
+ALERT_DESCRIPTION_ACCESS_DENIED: Final = 49
+ALERT_DESCRIPTION_DECODE_ERROR: Final = 50
+ALERT_DESCRIPTION_DECRYPT_ERROR: Final = 51
+ALERT_DESCRIPTION_PROTOCOL_VERSION: Final = 70
+ALERT_DESCRIPTION_INSUFFICIENT_SECURITY: Final = 71
+ALERT_DESCRIPTION_INTERNAL_ERROR: Final = 80
+ALERT_DESCRIPTION_USER_CANCELLED: Final = 90
+ALERT_DESCRIPTION_NO_RENEGOTIATION: Final = 100
+ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION: Final = 110
+ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE: Final = 111
+ALERT_DESCRIPTION_UNRECOGNIZED_NAME: Final = 112
+ALERT_DESCRIPTION_BAD_CERTIFICATE_STATUS_RESPONSE: Final = 113
+ALERT_DESCRIPTION_BAD_CERTIFICATE_HASH_VALUE: Final = 114
+ALERT_DESCRIPTION_UNKNOWN_PSK_IDENTITY: Final = 115
# protocol versions
-PROTOCOL_SSLv23: int
-PROTOCOL_TLS: int
-PROTOCOL_TLS_CLIENT: int
-PROTOCOL_TLS_SERVER: int
-PROTOCOL_TLSv1: int
-PROTOCOL_TLSv1_1: int
-PROTOCOL_TLSv1_2: int
+PROTOCOL_SSLv23: Final = 2
+PROTOCOL_TLS: Final = 2
+PROTOCOL_TLS_CLIENT: Final = 16
+PROTOCOL_TLS_SERVER: Final = 17
+PROTOCOL_TLSv1: Final = 3
+PROTOCOL_TLSv1_1: Final = 4
+PROTOCOL_TLSv1_2: Final = 5
# protocol options
-OP_ALL: int
-OP_NO_SSLv2: int
-OP_NO_SSLv3: int
-OP_NO_TLSv1: int
-OP_NO_TLSv1_1: int
-OP_NO_TLSv1_2: int
-OP_NO_TLSv1_3: int
-OP_CIPHER_SERVER_PREFERENCE: int
-OP_SINGLE_DH_USE: int
-OP_NO_TICKET: int
-OP_SINGLE_ECDH_USE: int
-OP_NO_COMPRESSION: int
-OP_ENABLE_MIDDLEBOX_COMPAT: int
-OP_NO_RENEGOTIATION: int
+OP_ALL: Final = 0x80000050
+OP_NO_SSLv2: Final = 0x0
+OP_NO_SSLv3: Final = 0x2000000
+OP_NO_TLSv1: Final = 0x4000000
+OP_NO_TLSv1_1: Final = 0x10000000
+OP_NO_TLSv1_2: Final = 0x8000000
+OP_NO_TLSv1_3: Final = 0x20000000
+OP_CIPHER_SERVER_PREFERENCE: Final = 0x400000
+OP_SINGLE_DH_USE: Final = 0x0
+OP_NO_TICKET: Final = 0x4000
+OP_SINGLE_ECDH_USE: Final = 0x0
+OP_NO_COMPRESSION: Final = 0x20000
+OP_ENABLE_MIDDLEBOX_COMPAT: Final = 0x100000
+OP_NO_RENEGOTIATION: Final = 0x40000000
if sys.version_info >= (3, 11) or sys.platform == "linux":
- OP_IGNORE_UNEXPECTED_EOF: int
+ OP_IGNORE_UNEXPECTED_EOF: Final = 0x80
if sys.version_info >= (3, 12):
- OP_LEGACY_SERVER_CONNECT: int
- OP_ENABLE_KTLS: int
+ OP_LEGACY_SERVER_CONNECT: Final = 0x4
+ OP_ENABLE_KTLS: Final = 0x8
# host flags
-HOSTFLAG_ALWAYS_CHECK_SUBJECT: int
-HOSTFLAG_NEVER_CHECK_SUBJECT: int
-HOSTFLAG_NO_WILDCARDS: int
-HOSTFLAG_NO_PARTIAL_WILDCARDS: int
-HOSTFLAG_MULTI_LABEL_WILDCARDS: int
-HOSTFLAG_SINGLE_LABEL_SUBDOMAINS: int
+HOSTFLAG_ALWAYS_CHECK_SUBJECT: Final = 0x1
+HOSTFLAG_NEVER_CHECK_SUBJECT: Final = 0x20
+HOSTFLAG_NO_WILDCARDS: Final = 0x2
+HOSTFLAG_NO_PARTIAL_WILDCARDS: Final = 0x4
+HOSTFLAG_MULTI_LABEL_WILDCARDS: Final = 0x8
+HOSTFLAG_SINGLE_LABEL_SUBDOMAINS: Final = 0x10
if sys.version_info >= (3, 10):
# certificate file types
- # Typed as Literal so the overload on Certificate.public_bytes can work properly.
- ENCODING_PEM: Literal[1]
- ENCODING_DER: Literal[2]
+ ENCODING_PEM: Final = 1
+ ENCODING_DER: Final = 2
# protocol versions
-PROTO_MINIMUM_SUPPORTED: int
-PROTO_MAXIMUM_SUPPORTED: int
-PROTO_SSLv3: int
-PROTO_TLSv1: int
-PROTO_TLSv1_1: int
-PROTO_TLSv1_2: int
-PROTO_TLSv1_3: int
+PROTO_MINIMUM_SUPPORTED: Final = -2
+PROTO_MAXIMUM_SUPPORTED: Final = -1
+PROTO_SSLv3: Final[int]
+PROTO_TLSv1: Final[int]
+PROTO_TLSv1_1: Final[int]
+PROTO_TLSv1_2: Final[int]
+PROTO_TLSv1_3: Final[int]
# feature support
-HAS_SNI: bool
-HAS_TLS_UNIQUE: bool
-HAS_ECDH: bool
-HAS_NPN: bool
+HAS_SNI: Final[bool]
+HAS_TLS_UNIQUE: Final[bool]
+HAS_ECDH: Final[bool]
+HAS_NPN: Final[bool]
if sys.version_info >= (3, 13):
- HAS_PSK: bool
-HAS_ALPN: bool
-HAS_SSLv2: bool
-HAS_SSLv3: bool
-HAS_TLSv1: bool
-HAS_TLSv1_1: bool
-HAS_TLSv1_2: bool
-HAS_TLSv1_3: bool
+ HAS_PSK: Final[bool]
+HAS_ALPN: Final[bool]
+HAS_SSLv2: Final[bool]
+HAS_SSLv3: Final[bool]
+HAS_TLSv1: Final[bool]
+HAS_TLSv1_1: Final[bool]
+HAS_TLSv1_2: Final[bool]
+HAS_TLSv1_3: Final[bool]
if sys.version_info >= (3, 14):
- HAS_PHA: bool
+ HAS_PHA: Final[bool]
# version info
-OPENSSL_VERSION_NUMBER: int
-OPENSSL_VERSION_INFO: tuple[int, int, int, int, int]
-OPENSSL_VERSION: str
-_OPENSSL_API_VERSION: tuple[int, int, int, int, int]
+OPENSSL_VERSION_NUMBER: Final[int]
+OPENSSL_VERSION_INFO: Final[tuple[int, int, int, int, int]]
+OPENSSL_VERSION: Final[str]
+_OPENSSL_API_VERSION: Final[tuple[int, int, int, int, int]]
diff --git a/python/helpers/typeshed/stdlib/_thread.pyi b/python/helpers/typeshed/stdlib/_thread.pyi
index 9cfbe55b4fe3..fb9a3eeb9857 100644
--- a/python/helpers/typeshed/stdlib/_thread.pyi
+++ b/python/helpers/typeshed/stdlib/_thread.pyi
@@ -73,7 +73,7 @@ def start_new(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]
def start_new(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ...
if sys.version_info >= (3, 10):
- def interrupt_main(signum: signal.Signals = ..., /) -> None: ...
+ def interrupt_main(signum: signal.Signals = signal.SIGINT, /) -> None: ...
else:
def interrupt_main() -> None: ...
@@ -85,7 +85,7 @@ def allocate() -> LockType: ... # Obsolete synonym for allocate_lock()
def get_ident() -> int: ...
def stack_size(size: int = 0, /) -> int: ...
-TIMEOUT_MAX: float
+TIMEOUT_MAX: Final[float]
def get_native_id() -> int: ... # only available on some platforms
@final
diff --git a/python/helpers/typeshed/stdlib/_threading_local.pyi b/python/helpers/typeshed/stdlib/_threading_local.pyi
index 07a825f0d816..5f6acaf840aa 100644
--- a/python/helpers/typeshed/stdlib/_threading_local.pyi
+++ b/python/helpers/typeshed/stdlib/_threading_local.pyi
@@ -7,6 +7,7 @@ __all__ = ["local"]
_LocalDict: TypeAlias = dict[Any, Any]
class _localimpl:
+ __slots__ = ("key", "dicts", "localargs", "locallock", "__weakref__")
key: str
dicts: dict[int, tuple[ReferenceType[Any], _LocalDict]]
# Keep localargs in sync with the *args, **kwargs annotation on local.__new__
@@ -16,6 +17,7 @@ class _localimpl:
def create_dict(self) -> _LocalDict: ...
class local:
+ __slots__ = ("_local__impl", "__dict__")
def __new__(cls, /, *args: Any, **kw: Any) -> Self: ...
def __getattribute__(self, name: str) -> Any: ...
def __setattr__(self, name: str, value: Any) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/_tkinter.pyi b/python/helpers/typeshed/stdlib/_tkinter.pyi
index 08eb00ca442b..46366ccc1740 100644
--- a/python/helpers/typeshed/stdlib/_tkinter.pyi
+++ b/python/helpers/typeshed/stdlib/_tkinter.pyi
@@ -1,7 +1,7 @@
import sys
from collections.abc import Callable
from typing import Any, ClassVar, Final, final
-from typing_extensions import TypeAlias
+from typing_extensions import TypeAlias, deprecated
# _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
@@ -84,6 +84,7 @@ class TkappType:
def record(self, script, /): ...
def setvar(self, *ags, **kwargs): ...
if sys.version_info < (3, 11):
+ @deprecated("Deprecated since Python 3.9; removed in Python 3.11. Use `splitlist()` instead.")
def split(self, arg, /): ...
def splitlist(self, arg, /): ...
diff --git a/python/helpers/typeshed/stdlib/_typeshed/__init__.pyi b/python/helpers/typeshed/stdlib/_typeshed/__init__.pyi
index f322244016dd..2cfd8173afd1 100644
--- a/python/helpers/typeshed/stdlib/_typeshed/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/_typeshed/__init__.pyi
@@ -3,7 +3,7 @@
# 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 collections.abc import Awaitable, Callable, Iterable, Iterator, Sequence, Set as AbstractSet, Sized
from dataclasses import Field
from os import PathLike
from types import FrameType, TracebackType
@@ -65,10 +65,10 @@ MaybeNone: TypeAlias = Any # stable
# 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
+# _SentinelType = NewType("_SentinelType", object) # does not exist at runtime
+# sentinel: Final[_SentinelType]
# def foo(x: int | None | _SentinelType = ...) -> None: ...
-sentinel: Any
+sentinel: Any # stable
# stable
class IdentityFunction(Protocol):
@@ -82,19 +82,21 @@ class SupportsNext(Protocol[_T_co]):
class SupportsAnext(Protocol[_T_co]):
def __anext__(self) -> Awaitable[_T_co]: ...
-# Comparison protocols
+class SupportsBool(Protocol):
+ def __bool__(self) -> bool: ...
+# Comparison protocols
class SupportsDunderLT(Protocol[_T_contra]):
- def __lt__(self, other: _T_contra, /) -> bool: ...
+ def __lt__(self, other: _T_contra, /) -> SupportsBool: ...
class SupportsDunderGT(Protocol[_T_contra]):
- def __gt__(self, other: _T_contra, /) -> bool: ...
+ def __gt__(self, other: _T_contra, /) -> SupportsBool: ...
class SupportsDunderLE(Protocol[_T_contra]):
- def __le__(self, other: _T_contra, /) -> bool: ...
+ def __le__(self, other: _T_contra, /) -> SupportsBool: ...
class SupportsDunderGE(Protocol[_T_contra]):
- def __ge__(self, other: _T_contra, /) -> bool: ...
+ def __ge__(self, other: _T_contra, /) -> SupportsBool: ...
class SupportsAllComparisons(
SupportsDunderLT[Any], SupportsDunderGT[Any], SupportsDunderLE[Any], SupportsDunderGE[Any], Protocol
@@ -273,6 +275,16 @@ class SupportsWrite(Protocol[_T_contra]):
class SupportsFlush(Protocol):
def flush(self) -> object: ...
+# Suitable for dictionary view objects
+class Viewable(Protocol[_T_co]):
+ def __len__(self) -> int: ...
+ def __iter__(self) -> Iterator[_T_co]: ...
+
+class SupportsGetItemViewable(Protocol[_KT, _VT_co]):
+ def __len__(self) -> int: ...
+ def __iter__(self) -> Iterator[_KT]: ...
+ def __getitem__(self, key: _KT, /) -> _VT_co: ...
+
# 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
diff --git a/python/helpers/typeshed/stdlib/_winapi.pyi b/python/helpers/typeshed/stdlib/_winapi.pyi
index 0f71a0687748..d9e2c377b115 100644
--- a/python/helpers/typeshed/stdlib/_winapi.pyi
+++ b/python/helpers/typeshed/stdlib/_winapi.pyi
@@ -128,21 +128,21 @@ if sys.platform == "win32":
WAIT_TIMEOUT: Final = 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
+ LOCALE_NAME_INVARIANT: Final[str]
+ LOCALE_NAME_MAX_LENGTH: Final[int]
+ LOCALE_NAME_SYSTEM_DEFAULT: Final[str]
+ LOCALE_NAME_USER_DEFAULT: Final[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
+ LCMAP_FULLWIDTH: Final[int]
+ LCMAP_HALFWIDTH: Final[int]
+ LCMAP_HIRAGANA: Final[int]
+ LCMAP_KATAKANA: Final[int]
+ LCMAP_LINGUISTIC_CASING: Final[int]
+ LCMAP_LOWERCASE: Final[int]
+ LCMAP_SIMPLIFIED_CHINESE: Final[int]
+ LCMAP_TITLECASE: Final[int]
+ LCMAP_TRADITIONAL_CHINESE: Final[int]
+ LCMAP_UPPERCASE: Final[int]
if sys.version_info >= (3, 12):
COPYFILE2_CALLBACK_CHUNK_STARTED: Final = 1
@@ -172,6 +172,9 @@ if sys.platform == "win32":
ERROR_ACCESS_DENIED: Final = 5
ERROR_PRIVILEGE_NOT_HELD: Final = 1314
+ if sys.version_info >= (3, 14):
+ COPY_FILE_DIRECTORY: Final = 0x00000080
+
def CloseHandle(handle: int, /) -> None: ...
@overload
def ConnectNamedPipe(handle: int, overlapped: Literal[True]) -> Overlapped: ...
diff --git a/python/helpers/typeshed/stdlib/_zstd.pyi b/python/helpers/typeshed/stdlib/_zstd.pyi
index 0648d898448b..2730232528fc 100644
--- a/python/helpers/typeshed/stdlib/_zstd.pyi
+++ b/python/helpers/typeshed/stdlib/_zstd.pyi
@@ -52,6 +52,7 @@ class ZstdCompressor:
self, /, data: ReadableBuffer, mode: _ZstdCompressorContinue | _ZstdCompressorFlushBlock | _ZstdCompressorFlushFrame = 0
) -> bytes: ...
def flush(self, /, mode: _ZstdCompressorFlushBlock | _ZstdCompressorFlushFrame = 2) -> bytes: ...
+ def set_pledged_input_size(self, size: int | None, /) -> None: ...
@property
def last_mode(self) -> _ZstdCompressorContinue | _ZstdCompressorFlushBlock | _ZstdCompressorFlushFrame: ...
diff --git a/python/helpers/typeshed/stdlib/abc.pyi b/python/helpers/typeshed/stdlib/abc.pyi
index fdca48ac7aaf..c8cd549e30ec 100644
--- a/python/helpers/typeshed/stdlib/abc.pyi
+++ b/python/helpers/typeshed/stdlib/abc.pyi
@@ -28,17 +28,17 @@ class ABCMeta(type):
def register(cls: ABCMeta, subclass: type[_T]) -> type[_T]: ...
def abstractmethod(funcobj: _FuncT) -> _FuncT: ...
-@deprecated("Use 'classmethod' with 'abstractmethod' instead")
+@deprecated("Deprecated since Python 3.3. Use `@classmethod` stacked on top of `@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("Use 'staticmethod' with 'abstractmethod' instead")
+@deprecated("Deprecated since Python 3.3. Use `@staticmethod` stacked on top of `@abstractmethod` instead.")
class abstractstaticmethod(staticmethod[_P, _R_co]):
__isabstractmethod__: Literal[True]
def __init__(self, callable: Callable[_P, _R_co]) -> None: ...
-@deprecated("Use 'property' with 'abstractmethod' instead")
+@deprecated("Deprecated since Python 3.3. Use `@property` stacked on top of `@abstractmethod` instead.")
class abstractproperty(property):
__isabstractmethod__: Literal[True]
diff --git a/python/helpers/typeshed/stdlib/annotationlib.pyi b/python/helpers/typeshed/stdlib/annotationlib.pyi
index 7590c632d785..c87f4ec6df8f 100644
--- a/python/helpers/typeshed/stdlib/annotationlib.pyi
+++ b/python/helpers/typeshed/stdlib/annotationlib.pyi
@@ -64,7 +64,7 @@ if sys.version_info >= (3, 14):
owner: object = None,
format: Format = Format.VALUE, # noqa: Y011
) -> AnnotationForm: ...
- @deprecated("Use ForwardRef.evaluate() or typing.evaluate_forward_ref() instead.")
+ @deprecated("Use `ForwardRef.evaluate()` or `typing.evaluate_forward_ref()` instead.")
def _evaluate(
self,
globalns: dict[str, Any] | None,
diff --git a/python/helpers/typeshed/stdlib/argparse.pyi b/python/helpers/typeshed/stdlib/argparse.pyi
index 312093c0aa55..8a8cc047f8fe 100644
--- a/python/helpers/typeshed/stdlib/argparse.pyi
+++ b/python/helpers/typeshed/stdlib/argparse.pyi
@@ -2,7 +2,7 @@ import sys
from _typeshed import SupportsWrite, sentinel
from collections.abc import Callable, Generator, Iterable, Sequence
from re import Pattern
-from typing import IO, Any, ClassVar, Final, Generic, NoReturn, Protocol, TypeVar, overload
+from typing import IO, Any, ClassVar, Final, Generic, NoReturn, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias, deprecated
__all__ = [
@@ -112,6 +112,7 @@ class _ActionsContainer:
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: ...
+@type_check_only
class _FormatterClass(Protocol):
def __call__(self, *, prog: str) -> HelpFormatter: ...
@@ -281,7 +282,7 @@ class HelpFormatter:
if sys.version_info >= (3, 14):
def __init__(
- self, prog: str, indent_increment: int = 2, max_help_position: int = 24, width: int | None = None, color: bool = False
+ self, prog: str, indent_increment: int = 2, max_help_position: int = 24, width: int | None = None, color: bool = True
) -> None: ...
else:
def __init__(
@@ -467,7 +468,7 @@ class Namespace(_AttributeHolder):
__hash__: ClassVar[None] # type: ignore[assignment]
if sys.version_info >= (3, 14):
- @deprecated("Deprecated in Python 3.14; Simply open files after parsing arguments")
+ @deprecated("Deprecated since Python 3.14. Open files after parsing arguments instead.")
class FileType:
# undocumented
_mode: str
@@ -495,16 +496,40 @@ else:
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: ...
+ if sys.version_info >= (3, 14):
+ @overload
+ def __init__(
+ self,
+ container: _ActionsContainer,
+ title: str | None = None,
+ description: str | None = None,
+ *,
+ argument_default: Any = ...,
+ conflict_handler: str = ...,
+ ) -> None: ...
+ @overload
+ @deprecated("Undocumented `prefix_chars` parameter is deprecated since Python 3.14.")
+ def __init__(
+ self,
+ container: _ActionsContainer,
+ title: str | None = None,
+ description: str | None = None,
+ *,
+ prefix_chars: str,
+ argument_default: Any = ...,
+ conflict_handler: str = ...,
+ ) -> None: ...
+ else:
+ 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):
@@ -738,9 +763,9 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]):
fromfile_prefix_chars: str | None = ...,
argument_default: Any = ...,
conflict_handler: str = ...,
- add_help: bool = ...,
- allow_abbrev: bool = ...,
- exit_on_error: bool = ...,
+ add_help: bool = True,
+ allow_abbrev: bool = True,
+ exit_on_error: bool = True,
suggest_on_error: bool = False,
color: bool = False,
**kwargs: Any, # Accepting any additional kwargs for custom parser classes
@@ -764,9 +789,9 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]):
fromfile_prefix_chars: str | None = ...,
argument_default: Any = ...,
conflict_handler: str = ...,
- add_help: bool = ...,
- allow_abbrev: bool = ...,
- exit_on_error: bool = ...,
+ add_help: bool = True,
+ allow_abbrev: bool = True,
+ exit_on_error: bool = True,
**kwargs: Any, # Accepting any additional kwargs for custom parser classes
) -> _ArgumentParserT: ...
else:
@@ -787,9 +812,9 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]):
fromfile_prefix_chars: str | None = ...,
argument_default: Any = ...,
conflict_handler: str = ...,
- add_help: bool = ...,
- allow_abbrev: bool = ...,
- exit_on_error: bool = ...,
+ add_help: bool = True,
+ allow_abbrev: bool = True,
+ exit_on_error: bool = True,
**kwargs: Any, # Accepting any additional kwargs for custom parser classes
) -> _ArgumentParserT: ...
diff --git a/python/helpers/typeshed/stdlib/array.pyi b/python/helpers/typeshed/stdlib/array.pyi
index bd96c9bc2d31..ccb7f1b98ef3 100644
--- a/python/helpers/typeshed/stdlib/array.pyi
+++ b/python/helpers/typeshed/stdlib/array.pyi
@@ -3,11 +3,14 @@ from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite
from collections.abc import Iterable, MutableSequence
from types import GenericAlias
from typing import Any, ClassVar, Literal, SupportsIndex, TypeVar, overload
-from typing_extensions import Self, TypeAlias
+from typing_extensions import Self, TypeAlias, deprecated
_IntTypeCode: TypeAlias = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"]
_FloatTypeCode: TypeAlias = Literal["f", "d"]
-_UnicodeTypeCode: TypeAlias = Literal["u"]
+if sys.version_info >= (3, 13):
+ _UnicodeTypeCode: TypeAlias = Literal["u", "w"]
+else:
+ _UnicodeTypeCode: TypeAlias = Literal["u"]
_TypeCode: TypeAlias = _IntTypeCode | _FloatTypeCode | _UnicodeTypeCode
_T = TypeVar("_T", int, float, str)
@@ -27,10 +30,23 @@ class array(MutableSequence[_T]):
def __new__(
cls: type[array[float]], typecode: _FloatTypeCode, initializer: bytes | bytearray | Iterable[float] = ..., /
) -> array[float]: ...
- @overload
- def __new__(
- cls: type[array[str]], typecode: _UnicodeTypeCode, initializer: bytes | bytearray | Iterable[str] = ..., /
- ) -> array[str]: ...
+ if sys.version_info >= (3, 13):
+ @overload
+ def __new__(
+ cls: type[array[str]], typecode: Literal["w"], initializer: bytes | bytearray | Iterable[str] = ..., /
+ ) -> array[str]: ...
+ @overload
+ @deprecated("Deprecated since Python 3.3; will be removed in Python 3.16. Use 'w' typecode instead.")
+ def __new__(
+ cls: type[array[str]], typecode: Literal["u"], initializer: bytes | bytearray | Iterable[str] = ..., /
+ ) -> array[str]: ...
+ else:
+ @overload
+ @deprecated("Deprecated since Python 3.3; will be removed in Python 3.16.")
+ def __new__(
+ cls: type[array[str]], typecode: Literal["u"], initializer: bytes | bytearray | Iterable[str] = ..., /
+ ) -> array[str]: ...
+
@overload
def __new__(cls, typecode: str, initializer: Iterable[_T], /) -> Self: ...
@overload
@@ -58,6 +74,7 @@ class array(MutableSequence[_T]):
def tounicode(self) -> str: ...
__hash__: ClassVar[None] # type: ignore[assignment]
+ def __contains__(self, value: object, /) -> bool: ...
def __len__(self) -> int: ...
@overload
def __getitem__(self, key: SupportsIndex, /) -> _T: ...
diff --git a/python/helpers/typeshed/stdlib/ast.pyi b/python/helpers/typeshed/stdlib/ast.pyi
index af9d20d086b3..62cc931ff5c7 100644
--- a/python/helpers/typeshed/stdlib/ast.pyi
+++ b/python/helpers/typeshed/stdlib/ast.pyi
@@ -1,3 +1,4 @@
+import ast
import builtins
import os
import sys
@@ -9,7 +10,7 @@ from _ast import (
)
from _typeshed import ReadableBuffer, Unused
from collections.abc import Iterable, Iterator, Sequence
-from typing import Any, ClassVar, Generic, Literal, TypedDict, TypeVar as _TypeVar, overload
+from typing import Any, ClassVar, Generic, Literal, TypedDict, TypeVar as _TypeVar, overload, type_check_only
from typing_extensions import Self, Unpack, deprecated
if sys.version_info >= (3, 13):
@@ -19,6 +20,7 @@ if sys.version_info >= (3, 13):
_EndPositionT = typing_extensions.TypeVar("_EndPositionT", int, int | None, default=int | None)
# Corresponds to the names in the `_attributes` class variable which is non-empty in certain AST nodes
+@type_check_only
class _Attributes(TypedDict, Generic[_EndPositionT], total=False):
lineno: int
col_offset: int
@@ -623,21 +625,6 @@ class AsyncWith(stmt):
**kwargs: Unpack[_Attributes],
) -> Self: ...
-if sys.version_info >= (3, 10):
- class Match(stmt):
- __match_args__ = ("subject", "cases")
- subject: expr
- cases: list[match_case]
- if sys.version_info >= (3, 13):
- def __init__(self, subject: expr, cases: list[match_case] = ..., **kwargs: Unpack[_Attributes]) -> None: ...
- else:
- def __init__(self, subject: expr, cases: list[match_case], **kwargs: Unpack[_Attributes]) -> None: ...
-
- if sys.version_info >= (3, 14):
- def __replace__(
- self, *, subject: expr = ..., cases: list[match_case] = ..., **kwargs: Unpack[_Attributes]
- ) -> Self: ...
-
class Raise(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("exc", "cause")
@@ -1076,13 +1063,13 @@ if sys.version_info >= (3, 14):
value: expr
str: builtins.str
conversion: int
- format_spec: builtins.str | None = None
+ format_spec: expr | None = None
def __init__(
self,
value: expr = ...,
str: builtins.str = ...,
conversion: int = ...,
- format_spec: builtins.str | None = ...,
+ format_spec: expr | None = ...,
**kwargs: Unpack[_Attributes],
) -> None: ...
def __replace__(
@@ -1091,7 +1078,7 @@ if sys.version_info >= (3, 14):
value: expr = ...,
str: builtins.str = ...,
conversion: int = ...,
- format_spec: builtins.str | None = ...,
+ format_spec: expr | None = ...,
**kwargs: Unpack[_Attributes],
) -> Self: ...
@@ -1110,8 +1097,18 @@ class Constant(expr):
kind: str | None
if sys.version_info < (3, 14):
# Aliases for value, for backwards compatibility
- s: _ConstantValue
- n: _ConstantValue
+ @property
+ @deprecated("Removed in Python 3.14. Use `value` instead.")
+ def n(self) -> _ConstantValue: ...
+ @n.setter
+ @deprecated("Removed in Python 3.14. Use `value` instead.")
+ def n(self, value: _ConstantValue) -> None: ...
+ @property
+ @deprecated("Removed in Python 3.14. Use `value` instead.")
+ def s(self) -> _ConstantValue: ...
+ @s.setter
+ @deprecated("Removed in Python 3.14. Use `value` instead.")
+ def s(self, value: _ConstantValue) -> None: ...
def __init__(self, value: _ConstantValue, kind: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ...
@@ -1135,13 +1132,13 @@ class Subscript(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("value", "slice", "ctx")
value: expr
- slice: _Slice
+ slice: expr
ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__`
- def __init__(self, value: expr, slice: _Slice, ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ...
+ def __init__(self, value: expr, slice: expr, ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ...
if sys.version_info >= (3, 14):
def __replace__(
- self, *, value: expr = ..., slice: _Slice = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]
+ self, *, value: expr = ..., slice: expr = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]
) -> Self: ...
class Starred(expr):
@@ -1194,36 +1191,28 @@ class Tuple(expr):
@deprecated("Deprecated since Python 3.9.")
class slice(AST): ...
-_Slice: typing_extensions.TypeAlias = expr
-_SliceAttributes: typing_extensions.TypeAlias = _Attributes
-
-class Slice(_Slice):
+class Slice(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("lower", "upper", "step")
lower: expr | None
upper: expr | None
step: expr | None
def __init__(
- self, lower: expr | None = None, upper: expr | None = None, step: expr | None = None, **kwargs: Unpack[_SliceAttributes]
+ self, lower: expr | None = None, upper: expr | None = None, step: expr | None = None, **kwargs: Unpack[_Attributes]
) -> None: ...
if sys.version_info >= (3, 14):
def __replace__(
- self,
- *,
- lower: expr | None = ...,
- upper: expr | None = ...,
- step: expr | None = ...,
- **kwargs: Unpack[_SliceAttributes],
+ self, *, lower: expr | None = ..., upper: expr | None = ..., step: expr | None = ..., **kwargs: Unpack[_Attributes]
) -> Self: ...
-@deprecated("Deprecated since Python 3.9. Use ast.Tuple instead.")
+@deprecated("Deprecated since Python 3.9. Use `ast.Tuple` instead.")
class ExtSlice(slice):
- def __new__(cls, dims: Iterable[slice] = (), **kwargs: Unpack[_SliceAttributes]) -> Tuple: ... # type: ignore[misc]
+ def __new__(cls, dims: Iterable[slice] = (), **kwargs: Unpack[_Attributes]) -> Tuple: ... # type: ignore[misc]
@deprecated("Deprecated since Python 3.9. Use the index value directly instead.")
class Index(slice):
- def __new__(cls, value: expr, **kwargs: Unpack[_SliceAttributes]) -> expr: ... # type: ignore[misc]
+ def __new__(cls, value: expr, **kwargs: Unpack[_Attributes]) -> expr: ... # type: ignore[misc]
class expr_context(AST): ...
@@ -1465,22 +1454,6 @@ class withitem(AST):
def __replace__(self, *, context_expr: expr = ..., optional_vars: expr | None = ...) -> Self: ...
if sys.version_info >= (3, 10):
- class match_case(AST):
- __match_args__ = ("pattern", "guard", "body")
- pattern: _Pattern
- guard: expr | None
- body: list[stmt]
- if sys.version_info >= (3, 13):
- def __init__(self, pattern: _Pattern, guard: expr | None = None, body: list[stmt] = ...) -> None: ...
- else:
- @overload
- def __init__(self, pattern: _Pattern, guard: expr | None, body: list[stmt]) -> None: ...
- @overload
- def __init__(self, pattern: _Pattern, guard: expr | None = None, *, body: list[stmt]) -> None: ...
-
- if sys.version_info >= (3, 14):
- def __replace__(self, *, pattern: _Pattern = ..., guard: expr | None = ..., body: list[stmt] = ...) -> Self: ...
-
class pattern(AST):
lineno: int
col_offset: int
@@ -1493,8 +1466,35 @@ if sys.version_info >= (3, 10):
self, *, lineno: int = ..., col_offset: int = ..., end_lineno: int = ..., end_col_offset: int = ...
) -> Self: ...
- # 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: ast.pattern
+ guard: expr | None
+ body: list[stmt]
+ if sys.version_info >= (3, 13):
+ def __init__(self, pattern: ast.pattern, guard: expr | None = None, body: list[stmt] = ...) -> None: ...
+ elif sys.version_info >= (3, 10):
+ @overload
+ def __init__(self, pattern: ast.pattern, guard: expr | None, body: list[stmt]) -> None: ...
+ @overload
+ def __init__(self, pattern: ast.pattern, guard: expr | None = None, *, body: list[stmt]) -> None: ...
+
+ if sys.version_info >= (3, 14):
+ def __replace__(self, *, pattern: ast.pattern = ..., guard: expr | None = ..., body: list[stmt] = ...) -> Self: ...
+
+ class Match(stmt):
+ __match_args__ = ("subject", "cases")
+ subject: expr
+ cases: list[match_case]
+ if sys.version_info >= (3, 13):
+ def __init__(self, subject: expr, cases: list[match_case] = ..., **kwargs: Unpack[_Attributes]) -> None: ...
+ else:
+ def __init__(self, subject: expr, cases: list[match_case], **kwargs: Unpack[_Attributes]) -> None: ...
+
+ if sys.version_info >= (3, 14):
+ def __replace__(
+ self, *, subject: expr = ..., cases: list[match_case] = ..., **kwargs: Unpack[_Attributes]
+ ) -> Self: ...
class MatchValue(pattern):
__match_args__ = ("value",)
@@ -1506,11 +1506,11 @@ if sys.version_info >= (3, 10):
class MatchSingleton(pattern):
__match_args__ = ("value",)
- value: Literal[True, False] | None
- def __init__(self, value: Literal[True, False] | None, **kwargs: Unpack[_Attributes[int]]) -> None: ...
+ value: bool | None
+ def __init__(self, value: bool | None, **kwargs: Unpack[_Attributes[int]]) -> None: ...
if sys.version_info >= (3, 14):
- def __replace__(self, *, value: Literal[True, False] | None = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ...
+ def __replace__(self, *, value: bool | None = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ...
class MatchSequence(pattern):
__match_args__ = ("patterns",)
@@ -1590,22 +1590,22 @@ if sys.version_info >= (3, 10):
class MatchStar(pattern):
__match_args__ = ("name",)
name: str | None
- def __init__(self, name: str | None, **kwargs: Unpack[_Attributes[int]]) -> None: ...
+ def __init__(self, name: str | None = None, **kwargs: Unpack[_Attributes[int]]) -> None: ...
if sys.version_info >= (3, 14):
def __replace__(self, *, name: str | None = ..., **kwargs: Unpack[_Attributes[int]]) -> Self: ...
class MatchAs(pattern):
__match_args__ = ("pattern", "name")
- pattern: _Pattern | None
+ pattern: ast.pattern | None
name: str | None
def __init__(
- self, pattern: _Pattern | None = None, name: str | None = None, **kwargs: Unpack[_Attributes[int]]
+ self, pattern: ast.pattern | None = None, name: str | None = None, **kwargs: Unpack[_Attributes[int]]
) -> None: ...
if sys.version_info >= (3, 14):
def __replace__(
- self, *, pattern: _Pattern | None = ..., name: str | None = ..., **kwargs: Unpack[_Attributes[int]]
+ self, *, pattern: ast.pattern | None = ..., name: str | None = ..., **kwargs: Unpack[_Attributes[int]]
) -> Self: ...
class MatchOr(pattern):
@@ -1701,31 +1701,35 @@ if sys.version_info >= (3, 12):
self, *, name: str = ..., default_value: expr | None = ..., **kwargs: Unpack[_Attributes[int]]
) -> Self: ...
-class _ABC(type):
- def __init__(cls, *args: Unused) -> None: ...
+if sys.version_info >= (3, 14):
+ @type_check_only
+ class _ABC(type):
+ def __init__(cls, *args: Unused) -> None: ...
+
+else:
+ class _ABC(type):
+ def __init__(cls, *args: Unused) -> None: ...
if sys.version_info < (3, 14):
- @deprecated("Replaced by ast.Constant; removed in Python 3.14")
+ @deprecated("Removed in Python 3.14. Use `ast.Constant` instead.")
class Num(Constant, metaclass=_ABC):
- value: int | float | complex
+ def __new__(cls, n: complex, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] # pyright: ignore[reportInconsistentConstructor]
- @deprecated("Replaced by ast.Constant; removed in Python 3.14")
+ @deprecated("Removed in Python 3.14. Use `ast.Constant` instead.")
class Str(Constant, metaclass=_ABC):
- value: str
- # Aliases for value, for backwards compatibility
- s: str
+ def __new__(cls, s: str, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] # pyright: ignore[reportInconsistentConstructor]
- @deprecated("Replaced by ast.Constant; removed in Python 3.14")
+ @deprecated("Removed in Python 3.14. Use `ast.Constant` instead.")
class Bytes(Constant, metaclass=_ABC):
- value: bytes
- # Aliases for value, for backwards compatibility
- s: bytes
+ def __new__(cls, s: bytes, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] # pyright: ignore[reportInconsistentConstructor]
- @deprecated("Replaced by ast.Constant; removed in Python 3.14")
- class NameConstant(Constant, metaclass=_ABC): ...
+ @deprecated("Removed in Python 3.14. Use `ast.Constant` instead.")
+ class NameConstant(Constant, metaclass=_ABC):
+ def __new__(cls, value: _ConstantValue, kind: str | None, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] # pyright: ignore[reportInconsistentConstructor]
- @deprecated("Replaced by ast.Constant; removed in Python 3.14")
- class Ellipsis(Constant, metaclass=_ABC): ...
+ @deprecated("Removed in Python 3.14. Use `ast.Constant` instead.")
+ class Ellipsis(Constant, metaclass=_ABC):
+ def __new__(cls, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] # pyright: ignore[reportInconsistentConstructor]
# everything below here is defined in ast.py
@@ -1808,7 +1812,7 @@ if sys.version_info >= (3, 13):
type_comments: bool = False,
feature_version: None | int | tuple[int, int] = None,
optimize: Literal[-1, 0, 1, 2] = -1,
- ) -> AST: ...
+ ) -> mod: ...
else:
@overload
@@ -1879,7 +1883,7 @@ else:
*,
type_comments: bool = False,
feature_version: None | int | tuple[int, int] = None,
- ) -> AST: ...
+ ) -> mod: ...
def literal_eval(node_or_string: str | AST) -> Any: ...
@@ -2042,15 +2046,15 @@ class NodeVisitor:
def visit_Param(self, node: Param) -> Any: ...
if sys.version_info < (3, 14):
- @deprecated("Replaced by visit_Constant; removed in Python 3.14")
+ @deprecated("Removed in Python 3.14. Use `visit_Constant` instead.")
def visit_Num(self, node: Num) -> Any: ... # type: ignore[deprecated]
- @deprecated("Replaced by visit_Constant; removed in Python 3.14")
+ @deprecated("Removed in Python 3.14. Use `visit_Constant` instead.")
def visit_Str(self, node: Str) -> Any: ... # type: ignore[deprecated]
- @deprecated("Replaced by visit_Constant; removed in Python 3.14")
+ @deprecated("Removed in Python 3.14. Use `visit_Constant` instead.")
def visit_Bytes(self, node: Bytes) -> Any: ... # type: ignore[deprecated]
- @deprecated("Replaced by visit_Constant; removed in Python 3.14")
+ @deprecated("Removed in Python 3.14. Use `visit_Constant` instead.")
def visit_NameConstant(self, node: NameConstant) -> Any: ... # type: ignore[deprecated]
- @deprecated("Replaced by visit_Constant; removed in Python 3.14")
+ @deprecated("Removed in Python 3.14. Use `visit_Constant` instead.")
def visit_Ellipsis(self, node: Ellipsis) -> Any: ... # type: ignore[deprecated]
class NodeTransformer(NodeVisitor):
diff --git a/python/helpers/typeshed/stdlib/asyncio/__init__.pyi b/python/helpers/typeshed/stdlib/asyncio/__init__.pyi
index 68e44a88face..23cf57aaac33 100644
--- a/python/helpers/typeshed/stdlib/asyncio/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/asyncio/__init__.pyi
@@ -1,4 +1,4 @@
-# ruff: noqa: PLR5501 # This condition is so big, it's clearer to keep to platform condition in two blocks
+# This condition is so big, it's clearer to keep to platform condition in two blocks
# Can't NOQA on a specific line: https://github.com/plinss/flake8-noqa/issues/22
import sys
from collections.abc import Awaitable, Coroutine, Generator
@@ -41,14 +41,11 @@ if sys.platform == "win32":
"Server", # from base_events
"iscoroutinefunction", # from coroutines
"iscoroutine", # from coroutines
- "_AbstractEventLoopPolicy", # from events
"AbstractEventLoop", # from events
"AbstractServer", # from events
"Handle", # from events
"TimerHandle", # from events
- "_get_event_loop_policy", # from events
"get_event_loop_policy", # from events
- "_set_event_loop_policy", # from events
"set_event_loop_policy", # from events
"get_event_loop", # from events
"set_event_loop", # from events
@@ -517,14 +514,11 @@ else:
"Server", # from base_events
"iscoroutinefunction", # from coroutines
"iscoroutine", # from coroutines
- "_AbstractEventLoopPolicy", # from events
"AbstractEventLoop", # from events
"AbstractServer", # from events
"Handle", # from events
"TimerHandle", # from events
- "_get_event_loop_policy", # from events
"get_event_loop_policy", # from events
- "_set_event_loop_policy", # from events
"set_event_loop_policy", # from events
"get_event_loop", # from events
"set_event_loop", # from events
@@ -610,7 +604,6 @@ else:
"DatagramTransport", # from transports
"SubprocessTransport", # from transports
"SelectorEventLoop", # from unix_events
- "_DefaultEventLoopPolicy", # from unix_events
"EventLoop", # from unix_events
)
elif sys.version_info >= (3, 13):
diff --git a/python/helpers/typeshed/stdlib/asyncio/base_futures.pyi b/python/helpers/typeshed/stdlib/asyncio/base_futures.pyi
index 55d2fbdbdb62..2cd0f2e3a7e4 100644
--- a/python/helpers/typeshed/stdlib/asyncio/base_futures.pyi
+++ b/python/helpers/typeshed/stdlib/asyncio/base_futures.pyi
@@ -1,19 +1,17 @@
+from _asyncio import Future
from collections.abc import Callable, Sequence
from contextvars import Context
from typing import Any, Final
+from typing_extensions import TypeIs
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: Final = "PENDING" # undocumented
_CANCELLED: Final = "CANCELLED" # undocumented
_FINISHED: Final = "FINISHED" # undocumented
+def isfuture(obj: object) -> TypeIs[Future[Any]]: ...
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
diff --git a/python/helpers/typeshed/stdlib/asyncio/coroutines.pyi b/python/helpers/typeshed/stdlib/asyncio/coroutines.pyi
index 8ef30b3d3198..59212f4ec398 100644
--- a/python/helpers/typeshed/stdlib/asyncio/coroutines.pyi
+++ b/python/helpers/typeshed/stdlib/asyncio/coroutines.pyi
@@ -1,7 +1,7 @@
import sys
from collections.abc import Awaitable, Callable, Coroutine
from typing import Any, TypeVar, overload
-from typing_extensions import ParamSpec, TypeGuard, TypeIs
+from typing_extensions import ParamSpec, TypeGuard, TypeIs, deprecated
# Keep asyncio.__all__ updated with any changes to __all__ here
if sys.version_info >= (3, 11):
@@ -14,6 +14,7 @@ _FunctionT = TypeVar("_FunctionT", bound=Callable[..., Any])
_P = ParamSpec("_P")
if sys.version_info < (3, 11):
+ @deprecated("Deprecated since Python 3.8; removed in Python 3.11. Use `async def` instead.")
def coroutine(func: _FunctionT) -> _FunctionT: ...
@overload
diff --git a/python/helpers/typeshed/stdlib/asyncio/events.pyi b/python/helpers/typeshed/stdlib/asyncio/events.pyi
index 688ef3ed0879..5a6b0f31d369 100644
--- a/python/helpers/typeshed/stdlib/asyncio/events.pyi
+++ b/python/helpers/typeshed/stdlib/asyncio/events.pyi
@@ -12,7 +12,7 @@ from collections.abc import Callable, Sequence
from concurrent.futures import Executor
from contextvars import Context
from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket
-from typing import IO, Any, Literal, Protocol, TypeVar, overload
+from typing import IO, Any, Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias, TypeVarTuple, Unpack, deprecated
from . import _AwaitableLike, _CoroutineLike
@@ -28,14 +28,11 @@ if sys.version_info < (3, 14):
# Keep asyncio.__all__ updated with any changes to __all__ here
if sys.version_info >= (3, 14):
__all__ = (
- "_AbstractEventLoopPolicy",
"AbstractEventLoop",
"AbstractServer",
"Handle",
"TimerHandle",
- "_get_event_loop_policy",
"get_event_loop_policy",
- "_set_event_loop_policy",
"set_event_loop_policy",
"get_event_loop",
"set_event_loop",
@@ -71,10 +68,12 @@ _ExceptionHandler: TypeAlias = Callable[[AbstractEventLoop, _Context], object]
_ProtocolFactory: TypeAlias = Callable[[], BaseProtocol]
_SSLContext: TypeAlias = bool | None | ssl.SSLContext
+@type_check_only
class _TaskFactory(Protocol):
def __call__(self, loop: AbstractEventLoop, factory: _CoroutineLike[_T], /) -> Future[_T]: ...
class Handle:
+ __slots__ = ("_callback", "_args", "_cancelled", "_loop", "_source_traceback", "_repr", "__weakref__", "_context")
_cancelled: bool
_args: Sequence[Any]
def __init__(
@@ -87,6 +86,7 @@ class Handle:
def get_context(self) -> Context: ...
class TimerHandle(Handle):
+ __slots__ = ["_scheduled", "_when"]
def __init__(
self,
when: float,
@@ -602,6 +602,9 @@ class AbstractEventLoop:
@abstractmethod
async def shutdown_default_executor(self) -> None: ...
+# This class does not exist at runtime, but stubtest complains if it's marked as
+# @type_check_only because it has an alias that does exist at runtime. See mypy#19568.
+# @type_check_only
class _AbstractEventLoopPolicy:
@abstractmethod
def get_event_loop(self) -> AbstractEventLoop: ...
@@ -613,10 +616,10 @@ class _AbstractEventLoopPolicy:
if sys.version_info < (3, 14):
if sys.version_info >= (3, 12):
@abstractmethod
- @deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
+ @deprecated("Deprecated since Python 3.12; 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")
+ @deprecated("Deprecated since Python 3.12; removed in Python 3.14.")
def set_child_watcher(self, watcher: AbstractChildWatcher) -> None: ...
else:
@abstractmethod
@@ -642,9 +645,9 @@ else:
if sys.version_info >= (3, 14):
def _get_event_loop_policy() -> _AbstractEventLoopPolicy: ...
def _set_event_loop_policy(policy: _AbstractEventLoopPolicy | None) -> None: ...
- @deprecated("Deprecated as of Python 3.14; will be removed in Python 3.16")
+ @deprecated("Deprecated since Python 3.14; will be removed in Python 3.16.")
def get_event_loop_policy() -> _AbstractEventLoopPolicy: ...
- @deprecated("Deprecated as of Python 3.14; will be removed in Python 3.16")
+ @deprecated("Deprecated since Python 3.14; will be removed in Python 3.16.")
def set_event_loop_policy(policy: _AbstractEventLoopPolicy | None) -> None: ...
else:
@@ -656,9 +659,9 @@ def new_event_loop() -> AbstractEventLoop: ...
if sys.version_info < (3, 14):
if sys.version_info >= (3, 12):
- @deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
+ @deprecated("Deprecated since Python 3.12; removed in Python 3.14.")
def get_child_watcher() -> AbstractChildWatcher: ...
- @deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
+ @deprecated("Deprecated since Python 3.12; removed in Python 3.14.")
def set_child_watcher(watcher: AbstractChildWatcher) -> None: ...
else:
diff --git a/python/helpers/typeshed/stdlib/asyncio/format_helpers.pyi b/python/helpers/typeshed/stdlib/asyncio/format_helpers.pyi
index 41505b14cd08..597eb9e56e1a 100644
--- a/python/helpers/typeshed/stdlib/asyncio/format_helpers.pyi
+++ b/python/helpers/typeshed/stdlib/asyncio/format_helpers.pyi
@@ -3,9 +3,10 @@ import sys
import traceback
from collections.abc import Iterable
from types import FrameType, FunctionType
-from typing import Any, overload
+from typing import Any, overload, type_check_only
from typing_extensions import TypeAlias
+@type_check_only
class _HasWrapper:
__wrapper__: _HasWrapper | FunctionType
diff --git a/python/helpers/typeshed/stdlib/asyncio/futures.pyi b/python/helpers/typeshed/stdlib/asyncio/futures.pyi
index 644d2d0e94ca..c907c7036b04 100644
--- a/python/helpers/typeshed/stdlib/asyncio/futures.pyi
+++ b/python/helpers/typeshed/stdlib/asyncio/futures.pyi
@@ -1,9 +1,9 @@
import sys
from _asyncio import Future as Future
from concurrent.futures._base import Future as _ConcurrentFuture
-from typing import Any, TypeVar
-from typing_extensions import TypeIs
+from typing import TypeVar
+from .base_futures import isfuture as isfuture
from .events import AbstractEventLoop
# Keep asyncio.__all__ updated with any changes to __all__ here
@@ -16,8 +16,4 @@ else:
_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]]: ...
def wrap_future(future: _ConcurrentFuture[_T] | Future[_T], *, loop: AbstractEventLoop | None = None) -> Future[_T]: ...
diff --git a/python/helpers/typeshed/stdlib/asyncio/protocols.pyi b/python/helpers/typeshed/stdlib/asyncio/protocols.pyi
index 5425336c49a8..2c52ad4be410 100644
--- a/python/helpers/typeshed/stdlib/asyncio/protocols.pyi
+++ b/python/helpers/typeshed/stdlib/asyncio/protocols.pyi
@@ -6,21 +6,26 @@ from typing import Any
__all__ = ("BaseProtocol", "Protocol", "DatagramProtocol", "SubprocessProtocol", "BufferedProtocol")
class BaseProtocol:
+ __slots__ = ()
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):
+ # Need annotation or mypy will complain about 'Cannot determine type of "__slots__" in base class'
+ __slots__: tuple[()] = ()
def data_received(self, data: bytes) -> None: ...
def eof_received(self) -> bool | None: ...
class BufferedProtocol(BaseProtocol):
+ __slots__ = ()
def get_buffer(self, sizehint: int) -> ReadableBuffer: ...
def buffer_updated(self, nbytes: int) -> None: ...
def eof_received(self) -> bool | None: ...
class DatagramProtocol(BaseProtocol):
+ __slots__ = ()
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.
@@ -30,6 +35,7 @@ class DatagramProtocol(BaseProtocol):
def error_received(self, exc: Exception) -> None: ...
class SubprocessProtocol(BaseProtocol):
+ __slots__: tuple[()] = ()
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: ...
diff --git a/python/helpers/typeshed/stdlib/asyncio/queues.pyi b/python/helpers/typeshed/stdlib/asyncio/queues.pyi
index 63cd98f53da3..2fa2226d0e6a 100644
--- a/python/helpers/typeshed/stdlib/asyncio/queues.pyi
+++ b/python/helpers/typeshed/stdlib/asyncio/queues.pyi
@@ -1,4 +1,5 @@
import sys
+from _typeshed import SupportsRichComparisonT
from asyncio.events import AbstractEventLoop
from types import GenericAlias
from typing import Any, Generic, TypeVar
@@ -50,5 +51,5 @@ class Queue(Generic[_T], _LoopBoundMixin): # noqa: Y059
if sys.version_info >= (3, 13):
def shutdown(self, immediate: bool = False) -> None: ...
-class PriorityQueue(Queue[_T]): ...
+class PriorityQueue(Queue[SupportsRichComparisonT]): ...
class LifoQueue(Queue[_T]): ...
diff --git a/python/helpers/typeshed/stdlib/asyncio/runners.pyi b/python/helpers/typeshed/stdlib/asyncio/runners.pyi
index caf5e4996cf4..919e6521f8a1 100644
--- a/python/helpers/typeshed/stdlib/asyncio/runners.pyi
+++ b/python/helpers/typeshed/stdlib/asyncio/runners.pyi
@@ -26,7 +26,7 @@ if sys.version_info >= (3, 11):
if sys.version_info >= (3, 12):
def run(
- main: Coroutine[Any, Any, _T], *, debug: bool | None = ..., loop_factory: Callable[[], AbstractEventLoop] | None = ...
+ main: Coroutine[Any, Any, _T], *, debug: bool | None = None, loop_factory: Callable[[], AbstractEventLoop] | None = None
) -> _T: ...
else:
diff --git a/python/helpers/typeshed/stdlib/asyncio/streams.pyi b/python/helpers/typeshed/stdlib/asyncio/streams.pyi
index 43df5ae2d0c8..bf8db0246ee2 100644
--- a/python/helpers/typeshed/stdlib/asyncio/streams.pyi
+++ b/python/helpers/typeshed/stdlib/asyncio/streams.pyi
@@ -3,7 +3,7 @@ import sys
from _typeshed import ReadableBuffer, StrPath
from collections.abc import Awaitable, Callable, Iterable, Sequence, Sized
from types import ModuleType
-from typing import Any, Protocol, SupportsIndex
+from typing import Any, Protocol, SupportsIndex, type_check_only
from typing_extensions import Self, TypeAlias
from . import events, protocols, transports
@@ -25,6 +25,7 @@ else:
_ClientConnectedCallback: TypeAlias = Callable[[StreamReader, StreamWriter], Awaitable[None] | None]
+@type_check_only
class _ReaduntilBuffer(ReadableBuffer, Sized, Protocol): ...
if sys.version_info >= (3, 10):
diff --git a/python/helpers/typeshed/stdlib/asyncio/tasks.pyi b/python/helpers/typeshed/stdlib/asyncio/tasks.pyi
index a088e95af653..1442f7400a9c 100644
--- a/python/helpers/typeshed/stdlib/asyncio/tasks.pyi
+++ b/python/helpers/typeshed/stdlib/asyncio/tasks.pyi
@@ -8,7 +8,7 @@ from _asyncio import (
_unregister_task as _unregister_task,
)
from collections.abc import AsyncIterator, Awaitable, Coroutine, Generator, Iterable, Iterator
-from typing import Any, Literal, Protocol, TypeVar, overload
+from typing import Any, Final, Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
from . import _CoroutineLike
@@ -82,11 +82,12 @@ else:
_TaskYieldType: TypeAlias = Future[object] | None
-FIRST_COMPLETED = concurrent.futures.FIRST_COMPLETED
-FIRST_EXCEPTION = concurrent.futures.FIRST_EXCEPTION
-ALL_COMPLETED = concurrent.futures.ALL_COMPLETED
+FIRST_COMPLETED: Final = concurrent.futures.FIRST_COMPLETED
+FIRST_EXCEPTION: Final = concurrent.futures.FIRST_EXCEPTION
+ALL_COMPLETED: Final = concurrent.futures.ALL_COMPLETED
if sys.version_info >= (3, 13):
+ @type_check_only
class _SyncAndAsyncIterator(Iterator[_T_co], AsyncIterator[_T_co], Protocol[_T_co]): ...
def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> _SyncAndAsyncIterator[Future[_T]]: ...
@@ -445,6 +446,7 @@ elif sys.version_info >= (3, 12):
if sys.version_info >= (3, 12):
_TaskT_co = TypeVar("_TaskT_co", bound=Task[Any], covariant=True)
+ @type_check_only
class _CustomTaskConstructor(Protocol[_TaskT_co]):
def __call__(
self,
@@ -457,6 +459,7 @@ if sys.version_info >= (3, 12):
eager_start: bool,
) -> _TaskT_co: ...
+ @type_check_only
class _EagerTaskFactoryType(Protocol[_TaskT_co]):
def __call__(
self,
diff --git a/python/helpers/typeshed/stdlib/asyncio/tools.pyi b/python/helpers/typeshed/stdlib/asyncio/tools.pyi
new file mode 100644
index 000000000000..65c7f27e0b85
--- /dev/null
+++ b/python/helpers/typeshed/stdlib/asyncio/tools.pyi
@@ -0,0 +1,41 @@
+from collections.abc import Iterable
+from enum import Enum
+from typing import NamedTuple, SupportsIndex, type_check_only
+
+@type_check_only
+class _AwaitedInfo(NamedTuple): # AwaitedInfo_Type from _remote_debugging
+ thread_id: int
+ awaited_by: list[_TaskInfo]
+
+@type_check_only
+class _TaskInfo(NamedTuple): # TaskInfo_Type from _remote_debugging
+ task_id: int
+ task_name: str
+ coroutine_stack: list[_CoroInfo]
+ awaited_by: list[_CoroInfo]
+
+@type_check_only
+class _CoroInfo(NamedTuple): # CoroInfo_Type from _remote_debugging
+ call_stack: list[_FrameInfo]
+ task_name: int | str
+
+@type_check_only
+class _FrameInfo(NamedTuple): # FrameInfo_Type from _remote_debugging
+ filename: str
+ lineno: int
+ funcname: str
+
+class NodeType(Enum):
+ COROUTINE = 1
+ TASK = 2
+
+class CycleFoundException(Exception):
+ cycles: list[list[int]]
+ id2name: dict[int, str]
+ def __init__(self, cycles: list[list[int]], id2name: dict[int, str]) -> None: ...
+
+def get_all_awaited_by(pid: SupportsIndex) -> list[_AwaitedInfo]: ...
+def build_async_tree(result: Iterable[_AwaitedInfo], task_emoji: str = "(T)", cor_emoji: str = "") -> list[list[str]]: ...
+def build_task_table(result: Iterable[_AwaitedInfo]) -> list[list[int | str]]: ...
+def display_awaited_by_tasks_table(pid: SupportsIndex) -> None: ...
+def display_awaited_by_tasks_tree(pid: SupportsIndex) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/asyncio/transports.pyi b/python/helpers/typeshed/stdlib/asyncio/transports.pyi
index bce54897f18f..cc870d5e0b9a 100644
--- a/python/helpers/typeshed/stdlib/asyncio/transports.pyi
+++ b/python/helpers/typeshed/stdlib/asyncio/transports.pyi
@@ -8,6 +8,7 @@ from typing import Any
__all__ = ("BaseTransport", "ReadTransport", "WriteTransport", "Transport", "DatagramTransport", "SubprocessTransport")
class BaseTransport:
+ __slots__ = ("_extra",)
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: ...
@@ -16,11 +17,13 @@ class BaseTransport:
def get_protocol(self) -> BaseProtocol: ...
class ReadTransport(BaseTransport):
+ __slots__ = ()
def is_reading(self) -> bool: ...
def pause_reading(self) -> None: ...
def resume_reading(self) -> None: ...
class WriteTransport(BaseTransport):
+ __slots__ = ()
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]: ...
@@ -32,13 +35,16 @@ class WriteTransport(BaseTransport):
def can_write_eof(self) -> bool: ...
def abort(self) -> None: ...
-class Transport(ReadTransport, WriteTransport): ...
+class Transport(ReadTransport, WriteTransport):
+ __slots__ = ()
class DatagramTransport(BaseTransport):
+ __slots__ = ()
def sendto(self, data: bytes | bytearray | memoryview, addr: _Address | None = None) -> None: ...
def abort(self) -> None: ...
class SubprocessTransport(BaseTransport):
+ __slots__ = ()
def get_pid(self) -> int: ...
def get_returncode(self) -> int | None: ...
def get_pipe_transport(self, fd: int) -> BaseTransport | None: ...
@@ -47,4 +53,5 @@ class SubprocessTransport(BaseTransport):
def kill(self) -> None: ...
class _FlowControlMixin(Transport):
+ __slots__ = ("_loop", "_protocol_paused", "_high_water", "_low_water")
def __init__(self, extra: Mapping[str, Any] | None = None, loop: AbstractEventLoop | None = None) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/asyncio/trsock.pyi b/python/helpers/typeshed/stdlib/asyncio/trsock.pyi
index e74cf6fd4e05..8f4f8f9ccb30 100644
--- a/python/helpers/typeshed/stdlib/asyncio/trsock.pyi
+++ b/python/helpers/typeshed/stdlib/asyncio/trsock.pyi
@@ -5,7 +5,7 @@ from builtins import type as Type # alias to avoid name clashes with property n
from collections.abc import Iterable
from types import TracebackType
from typing import Any, BinaryIO, NoReturn, overload
-from typing_extensions import TypeAlias
+from typing_extensions import TypeAlias, deprecated
# These are based in socket, maybe move them out into _typeshed.pyi or such
_Address: TypeAlias = socket._Address
@@ -14,6 +14,7 @@ _WriteBuffer: TypeAlias = bytearray | memoryview
_CMSG: TypeAlias = tuple[int, int, bytes]
class TransportSocket:
+ __slots__ = ("_sock",)
def __init__(self, sock: socket.socket) -> None: ...
@property
def family(self) -> int: ...
@@ -42,53 +43,82 @@ class TransportSocket:
def setblocking(self, flag: bool) -> None: ...
if sys.version_info < (3, 11):
def _na(self, what: str) -> None: ...
+ @deprecated("Removed in Python 3.11")
def accept(self) -> tuple[socket.socket, _RetAddress]: ...
+ @deprecated("Removed in Python 3.11")
def connect(self, address: _Address) -> None: ...
+ @deprecated("Removed in Python 3.11")
def connect_ex(self, address: _Address) -> int: ...
+ @deprecated("Removed in Python 3.11")
def bind(self, address: _Address) -> None: ...
if sys.platform == "win32":
+ @deprecated("Removed in Python 3.11")
def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> None: ...
else:
+ @deprecated("Removed in Python 3.11")
def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> NoReturn: ...
+ @deprecated("Removed in Python 3.11")
def listen(self, backlog: int = ..., /) -> None: ...
+ @deprecated("Removed in Python 3.11")
def makefile(self) -> BinaryIO: ...
+ @deprecated("Rmoved in Python 3.11")
def sendfile(self, file: BinaryIO, offset: int = ..., count: int | None = ...) -> int: ...
+ @deprecated("Removed in Python 3.11")
def close(self) -> None: ...
+ @deprecated("Removed in Python 3.11")
def detach(self) -> int: ...
if sys.platform == "linux":
+ @deprecated("Removed in Python 3.11")
def sendmsg_afalg(
self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ...
) -> int: ...
else:
+ @deprecated("Removed in Python 3.11.")
def sendmsg_afalg(
self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = ...
) -> NoReturn: ...
+ @deprecated("Removed in Python 3.11.")
def sendmsg(
self, buffers: Iterable[ReadableBuffer], ancdata: Iterable[_CMSG] = ..., flags: int = ..., address: _Address = ..., /
) -> int: ...
@overload
+ @deprecated("Removed in Python 3.11.")
def sendto(self, data: ReadableBuffer, address: _Address) -> int: ...
@overload
+ @deprecated("Removed in Python 3.11.")
def sendto(self, data: ReadableBuffer, flags: int, address: _Address) -> int: ...
+ @deprecated("Removed in Python 3.11.")
def send(self, data: ReadableBuffer, flags: int = ...) -> int: ...
+ @deprecated("Removed in Python 3.11.")
def sendall(self, data: ReadableBuffer, flags: int = ...) -> None: ...
+ @deprecated("Removed in Python 3.11.")
def set_inheritable(self, inheritable: bool) -> None: ...
if sys.platform == "win32":
+ @deprecated("Removed in Python 3.11.")
def share(self, process_id: int) -> bytes: ...
else:
+ @deprecated("Removed in Python 3.11.")
def share(self, process_id: int) -> NoReturn: ...
+ @deprecated("Removed in Python 3.11.")
def recv_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> int: ...
+ @deprecated("Removed in Python 3.11.")
def recvfrom_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> tuple[int, _RetAddress]: ...
+ @deprecated("Removed in Python 3.11.")
def recvmsg_into(
self, buffers: Iterable[_WriteBuffer], ancbufsize: int = ..., flags: int = ..., /
) -> tuple[int, list[_CMSG], int, Any]: ...
+ @deprecated("Removed in Python 3.11.")
def recvmsg(self, bufsize: int, ancbufsize: int = ..., flags: int = ..., /) -> tuple[bytes, list[_CMSG], int, Any]: ...
+ @deprecated("Removed in Python 3.11.")
def recvfrom(self, bufsize: int, flags: int = ...) -> tuple[bytes, _RetAddress]: ...
+ @deprecated("Removed in Python 3.11.")
def recv(self, bufsize: int, flags: int = ...) -> bytes: ...
+ @deprecated("Removed in Python 3.11.")
def __enter__(self) -> socket.socket: ...
+ @deprecated("Removed in Python 3.11.")
def __exit__(
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/asyncio/unix_events.pyi b/python/helpers/typeshed/stdlib/asyncio/unix_events.pyi
index 49f200dcdcae..9071ee9a2fa7 100644
--- a/python/helpers/typeshed/stdlib/asyncio/unix_events.pyi
+++ b/python/helpers/typeshed/stdlib/asyncio/unix_events.pyi
@@ -16,7 +16,7 @@ _Ts = TypeVarTuple("_Ts")
# Keep asyncio.__all__ updated with any changes to __all__ here
if sys.platform != "win32":
if sys.version_info >= (3, 14):
- __all__ = ("SelectorEventLoop", "_DefaultEventLoopPolicy", "EventLoop")
+ __all__ = ("SelectorEventLoop", "EventLoop")
elif sys.version_info >= (3, 13):
# Adds EventLoop
__all__ = (
@@ -48,7 +48,7 @@ if sys.platform != "win32":
# So, it is special cased.
if sys.version_info < (3, 14):
if sys.version_info >= (3, 12):
- @deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
+ @deprecated("Deprecated since Python 3.12; removed in Python 3.14.")
class AbstractChildWatcher:
@abstractmethod
def add_child_handler(
@@ -100,7 +100,7 @@ if sys.platform != "win32":
def is_active(self) -> bool: ...
def attach_loop(self, loop: events.AbstractEventLoop | None) -> None: ...
- @deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
+ @deprecated("Deprecated since Python 3.12; removed in Python 3.14.")
class SafeChildWatcher(BaseChildWatcher):
def __enter__(self) -> Self: ...
def __exit__(
@@ -111,7 +111,7 @@ if sys.platform != "win32":
) -> None: ...
def remove_child_handler(self, pid: int) -> bool: ...
- @deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
+ @deprecated("Deprecated since Python 3.12; removed in Python 3.14.")
class FastChildWatcher(BaseChildWatcher):
def __enter__(self) -> Self: ...
def __exit__(
@@ -171,9 +171,9 @@ if sys.platform != "win32":
else:
class _UnixDefaultEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
if sys.version_info >= (3, 12):
- @deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
+ @deprecated("Deprecated since Python 3.12; 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")
+ @deprecated("Deprecated since Python 3.12; removed in Python 3.14.")
def set_child_watcher(self, watcher: AbstractChildWatcher | None) -> None: ...
else:
def get_child_watcher(self) -> AbstractChildWatcher: ...
@@ -191,7 +191,7 @@ if sys.platform != "win32":
if sys.version_info < (3, 14):
if sys.version_info >= (3, 12):
- @deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
+ @deprecated("Deprecated since Python 3.12; removed in Python 3.14.")
class MultiLoopChildWatcher(AbstractChildWatcher):
def is_active(self) -> bool: ...
def close(self) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/asyncio/windows_utils.pyi b/python/helpers/typeshed/stdlib/asyncio/windows_utils.pyi
index 4fa014532376..75d27d4fefc4 100644
--- a/python/helpers/typeshed/stdlib/asyncio/windows_utils.pyi
+++ b/python/helpers/typeshed/stdlib/asyncio/windows_utils.pyi
@@ -9,8 +9,8 @@ if sys.platform == "win32":
__all__ = ("pipe", "Popen", "PIPE", "PipeHandle")
BUFSIZE: Final = 8192
- PIPE = subprocess.PIPE
- STDOUT = subprocess.STDOUT
+ PIPE: Final = subprocess.PIPE
+ STDOUT: Final = subprocess.STDOUT
def pipe(*, duplex: bool = False, overlapped: tuple[bool, bool] = (True, True), bufsize: int = 8192) -> tuple[int, int]: ...
class PipeHandle:
diff --git a/python/helpers/typeshed/stdlib/bdb.pyi b/python/helpers/typeshed/stdlib/bdb.pyi
index b73f894093ce..b6be2210ffe2 100644
--- a/python/helpers/typeshed/stdlib/bdb.pyi
+++ b/python/helpers/typeshed/stdlib/bdb.pyi
@@ -81,8 +81,8 @@ class Bdb:
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_file_breaks(self, filename: str) -> list[int]: ...
+ def get_all_breaks(self) -> dict[str, list[int]]: ...
def get_stack(self, f: FrameType | None, t: TracebackType | None) -> tuple[list[tuple[FrameType, int]], int]: ...
def format_stack_entry(self, frame_lineno: tuple[FrameType, int], lprefix: str = ": ") -> str: ...
def run(
diff --git a/python/helpers/typeshed/stdlib/binascii.pyi b/python/helpers/typeshed/stdlib/binascii.pyi
index 32e018c653cb..e09d335596fc 100644
--- a/python/helpers/typeshed/stdlib/binascii.pyi
+++ b/python/helpers/typeshed/stdlib/binascii.pyi
@@ -1,6 +1,6 @@
import sys
from _typeshed import ReadableBuffer
-from typing_extensions import TypeAlias
+from typing_extensions import TypeAlias, deprecated
# Many functions in binascii accept buffer objects
# or ASCII-only strings.
@@ -20,9 +20,13 @@ 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):
+ @deprecated("Deprecated since Python 3.9; removed in Python 3.11.")
def a2b_hqx(data: _AsciiBuffer, /) -> bytes: ...
+ @deprecated("Deprecated since Python 3.9; removed in Python 3.11.")
def rledecode_hqx(data: ReadableBuffer, /) -> bytes: ...
+ @deprecated("Deprecated since Python 3.9; removed in Python 3.11.")
def rlecode_hqx(data: ReadableBuffer, /) -> bytes: ...
+ @deprecated("Deprecated since Python 3.9; removed in Python 3.11.")
def b2a_hqx(data: ReadableBuffer, /) -> bytes: ...
def crc_hqx(data: ReadableBuffer, crc: int, /) -> int: ...
diff --git a/python/helpers/typeshed/stdlib/builtins.pyi b/python/helpers/typeshed/stdlib/builtins.pyi
index 8de58f1a3d43..c7ab95482f6b 100644
--- a/python/helpers/typeshed/stdlib/builtins.pyi
+++ b/python/helpers/typeshed/stdlib/builtins.pyi
@@ -349,6 +349,7 @@ class int:
def __hash__(self) -> int: ...
def __bool__(self) -> bool: ...
def __index__(self) -> int: ...
+ def __format__(self, format_spec: str, /) -> str: ...
class float:
def __new__(cls, x: ConvertibleToFloat = ..., /) -> Self: ...
@@ -410,6 +411,7 @@ class float:
def __abs__(self) -> float: ...
def __hash__(self) -> int: ...
def __bool__(self) -> bool: ...
+ def __format__(self, format_spec: str, /) -> str: ...
if sys.version_info >= (3, 14):
@classmethod
def from_number(cls, number: float | SupportsIndex | SupportsFloat, /) -> Self: ...
@@ -446,15 +448,18 @@ class complex:
def __abs__(self) -> float: ...
def __hash__(self) -> int: ...
def __bool__(self) -> bool: ...
+ def __format__(self, format_spec: str, /) -> str: ...
if sys.version_info >= (3, 11):
def __complex__(self) -> complex: ...
if sys.version_info >= (3, 14):
@classmethod
def from_number(cls, number: complex | SupportsComplex | SupportsFloat | SupportsIndex, /) -> Self: ...
+@type_check_only
class _FormatMapMapping(Protocol):
def __getitem__(self, key: str, /) -> Any: ...
+@type_check_only
class _TranslateTable(Protocol):
def __getitem__(self, key: int, /) -> str | int | None: ...
@@ -640,6 +645,7 @@ class str(Sequence[str]):
@overload
def __rmul__(self, value: SupportsIndex, /) -> str: ... # type: ignore[misc]
def __getnewargs__(self) -> tuple[str]: ...
+ def __format__(self, format_spec: str, /) -> str: ...
class bytes(Sequence[int]):
@overload
@@ -707,7 +713,7 @@ class bytes(Sequence[int]):
def strip(self, bytes: ReadableBuffer | None = None, /) -> bytes: ...
def swapcase(self) -> bytes: ...
def title(self) -> bytes: ...
- def translate(self, table: ReadableBuffer | None, /, delete: bytes = b"") -> bytes: ...
+ def translate(self, table: ReadableBuffer | None, /, delete: ReadableBuffer = b"") -> bytes: ...
def upper(self) -> bytes: ...
def zfill(self, width: SupportsIndex, /) -> bytes: ...
@classmethod
@@ -1338,6 +1344,9 @@ class property:
def __set__(self, instance: Any, value: Any, /) -> None: ...
def __delete__(self, instance: Any, /) -> None: ...
+# This class does not exist at runtime, but stubtest complains if it's marked as
+# @type_check_only because it has an alias that does exist at runtime. See mypy#19568.
+# @type_check_only
@final
class _NotImplementedType(Any):
__call__: None
@@ -1355,7 +1364,7 @@ def chr(i: int | SupportsIndex, /) -> str: ...
if sys.version_info >= (3, 10):
def aiter(async_iterable: SupportsAiter[_SupportsAnextT_co], /) -> _SupportsAnextT_co: ...
-
+ @type_check_only
class _SupportsSynchronousAnext(Protocol[_AwaitableT_co]):
def __anext__(self) -> _AwaitableT_co: ...
@@ -1511,7 +1520,7 @@ help: _sitebuiltins._Helper
def hex(number: int | SupportsIndex, /) -> str: ...
def id(obj: object, /) -> int: ...
def input(prompt: object = "", /) -> str: ...
-
+@type_check_only
class _GetItemIterable(Protocol[_T_co]):
def __getitem__(self, i: int, /) -> _T_co: ...
@@ -1524,7 +1533,6 @@ def iter(object: Callable[[], _T | None], sentinel: None, /) -> Iterator[_T]: ..
@overload
def iter(object: Callable[[], _T], sentinel: object, /) -> Iterator[_T]: ...
-# Keep this alias in sync with unittest.case._ClassInfo
if sys.version_info >= (3, 10):
_ClassInfo: TypeAlias = type | types.UnionType | tuple[_ClassInfo, ...]
else:
@@ -1767,7 +1775,7 @@ def open(
opener: _Opener | None = None,
) -> IO[Any]: ...
def ord(c: str | bytes | bytearray, /) -> int: ...
-
+@type_check_only
class _SupportsWriteAndFlush(SupportsWrite[_T_contra], SupportsFlush, Protocol[_T_contra]): ...
@overload
@@ -1786,12 +1794,15 @@ def print(
_E_contra = TypeVar("_E_contra", contravariant=True)
_M_contra = TypeVar("_M_contra", contravariant=True)
+@type_check_only
class _SupportsPow2(Protocol[_E_contra, _T_co]):
def __pow__(self, other: _E_contra, /) -> _T_co: ...
+@type_check_only
class _SupportsPow3NoneOnly(Protocol[_E_contra, _T_co]):
def __pow__(self, other: _E_contra, modulo: None = None, /) -> _T_co: ...
+@type_check_only
class _SupportsPow3(Protocol[_E_contra, _M_contra, _T_co]):
def __pow__(self, other: _E_contra, modulo: _M_contra, /) -> _T_co: ...
@@ -1856,9 +1867,11 @@ def repr(obj: object, /) -> str: ...
# and https://github.com/python/typeshed/pull/9151
# on why we don't use `SupportsRound` from `typing.pyi`
+@type_check_only
class _SupportsRound1(Protocol[_T_co]):
def __round__(self) -> _T_co: ...
+@type_check_only
class _SupportsRound2(Protocol[_T_co]):
def __round__(self, ndigits: int, /) -> _T_co: ...
@@ -1880,6 +1893,7 @@ def sorted(iterable: Iterable[_T], /, *, key: Callable[[_T], SupportsRichCompari
_AddableT1 = TypeVar("_AddableT1", bound=SupportsAdd[Any, Any])
_AddableT2 = TypeVar("_AddableT2", bound=SupportsAdd[Any, Any])
+@type_check_only
class _SupportsSumWithNoDefaultGiven(SupportsAdd[Any, Any], SupportsRAdd[int, Any], Protocol): ...
_SupportsSumNoDefaultT = TypeVar("_SupportsSumNoDefaultT", bound=_SupportsSumWithNoDefaultGiven)
diff --git a/python/helpers/typeshed/stdlib/bz2.pyi b/python/helpers/typeshed/stdlib/bz2.pyi
index dce6187a2da1..7bd829d040cb 100644
--- a/python/helpers/typeshed/stdlib/bz2.pyi
+++ b/python/helpers/typeshed/stdlib/bz2.pyi
@@ -3,7 +3,7 @@ from _bz2 import BZ2Compressor as BZ2Compressor, BZ2Decompressor as BZ2Decompres
from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer
from collections.abc import Iterable
from io import TextIOWrapper
-from typing import IO, Literal, Protocol, SupportsIndex, overload
+from typing import IO, Literal, Protocol, SupportsIndex, overload, type_check_only
from typing_extensions import Self, TypeAlias
if sys.version_info >= (3, 14):
@@ -16,8 +16,10 @@ __all__ = ["BZ2File", "BZ2Compressor", "BZ2Decompressor", "open", "compress", "d
# The following attributes and methods are optional:
# def fileno(self) -> int: ...
# def close(self) -> object: ...
+@type_check_only
class _ReadableFileobj(_Reader, Protocol): ...
+@type_check_only
class _WritableFileobj(Protocol):
def write(self, b: bytes, /) -> object: ...
# The following attributes and methods are optional:
diff --git a/python/helpers/typeshed/stdlib/calendar.pyi b/python/helpers/typeshed/stdlib/calendar.pyi
index cabf3b881c30..d00f0d5d2bce 100644
--- a/python/helpers/typeshed/stdlib/calendar.pyi
+++ b/python/helpers/typeshed/stdlib/calendar.pyi
@@ -167,18 +167,18 @@ if sys.version_info >= (3, 12):
NOVEMBER = 11
DECEMBER = 12
- JANUARY = Month.JANUARY
- FEBRUARY = Month.FEBRUARY
- MARCH = Month.MARCH
- APRIL = Month.APRIL
- MAY = Month.MAY
- JUNE = Month.JUNE
- JULY = Month.JULY
- AUGUST = Month.AUGUST
- SEPTEMBER = Month.SEPTEMBER
- OCTOBER = Month.OCTOBER
- NOVEMBER = Month.NOVEMBER
- DECEMBER = Month.DECEMBER
+ JANUARY: Final = Month.JANUARY
+ FEBRUARY: Final = Month.FEBRUARY
+ MARCH: Final = Month.MARCH
+ APRIL: Final = Month.APRIL
+ MAY: Final = Month.MAY
+ JUNE: Final = Month.JUNE
+ JULY: Final = Month.JULY
+ AUGUST: Final = Month.AUGUST
+ SEPTEMBER: Final = Month.SEPTEMBER
+ OCTOBER: Final = Month.OCTOBER
+ NOVEMBER: Final = Month.NOVEMBER
+ DECEMBER: Final = Month.DECEMBER
class Day(enum.IntEnum):
MONDAY = 0
@@ -189,13 +189,13 @@ if sys.version_info >= (3, 12):
SATURDAY = 5
SUNDAY = 6
- MONDAY = Day.MONDAY
- TUESDAY = Day.TUESDAY
- WEDNESDAY = Day.WEDNESDAY
- THURSDAY = Day.THURSDAY
- FRIDAY = Day.FRIDAY
- SATURDAY = Day.SATURDAY
- SUNDAY = Day.SUNDAY
+ MONDAY: Final = Day.MONDAY
+ TUESDAY: Final = Day.TUESDAY
+ WEDNESDAY: Final = Day.WEDNESDAY
+ THURSDAY: Final = Day.THURSDAY
+ FRIDAY: Final = Day.FRIDAY
+ SATURDAY: Final = Day.SATURDAY
+ SUNDAY: Final = Day.SUNDAY
else:
MONDAY: Final = 0
TUESDAY: Final = 1
diff --git a/python/helpers/typeshed/stdlib/cgi.pyi b/python/helpers/typeshed/stdlib/cgi.pyi
index 3a2e2a91b241..a7a95a139330 100644
--- a/python/helpers/typeshed/stdlib/cgi.pyi
+++ b/python/helpers/typeshed/stdlib/cgi.pyi
@@ -3,7 +3,7 @@ from builtins import list as _list, type as _type
from collections.abc import Iterable, Iterator, Mapping
from email.message import Message
from types import TracebackType
-from typing import IO, Any, Protocol
+from typing import IO, Any, Protocol, type_check_only
from typing_extensions import Self
__all__ = [
@@ -31,7 +31,7 @@ def parse(
def parse_multipart(
fp: IO[Any], pdict: SupportsGetItem[str, bytes], encoding: str = "utf-8", errors: str = "replace", separator: str = "&"
) -> dict[str, list[Any]]: ...
-
+@type_check_only
class _Environ(Protocol):
def __getitem__(self, k: str, /) -> str: ...
def keys(self) -> Iterable[str]: ...
diff --git a/python/helpers/typeshed/stdlib/codecs.pyi b/python/helpers/typeshed/stdlib/codecs.pyi
index 579d09c66a1b..15e184fc1038 100644
--- a/python/helpers/typeshed/stdlib/codecs.pyi
+++ b/python/helpers/typeshed/stdlib/codecs.pyi
@@ -3,7 +3,7 @@ from _codecs import *
from _typeshed import ReadableBuffer
from abc import abstractmethod
from collections.abc import Callable, Generator, Iterable
-from typing import Any, BinaryIO, ClassVar, Final, Literal, Protocol, TextIO, overload
+from typing import Any, BinaryIO, ClassVar, Final, Literal, Protocol, TextIO, overload, type_check_only
from typing_extensions import Self, TypeAlias
__all__ = [
@@ -73,16 +73,19 @@ _BufferedEncoding: TypeAlias = Literal[
"utf-8-sig",
]
+@type_check_only
class _WritableStream(Protocol):
def write(self, data: bytes, /) -> object: ...
def seek(self, offset: int, whence: int, /) -> object: ...
def close(self) -> object: ...
+@type_check_only
class _ReadableStream(Protocol):
def read(self, size: int = ..., /) -> bytes: ...
def seek(self, offset: int, whence: int, /) -> object: ...
def close(self) -> object: ...
+@type_check_only
class _Stream(_WritableStream, _ReadableStream, Protocol): ...
# TODO: this only satisfies the most common interface, where
@@ -91,24 +94,31 @@ class _Stream(_WritableStream, _ReadableStream, Protocol): ...
# There *are* bytes->bytes and str->str encodings in the standard library.
# They were much more common in Python 2 than in Python 3.
+@type_check_only
class _Encoder(Protocol):
def __call__(self, input: str, errors: str = ..., /) -> tuple[bytes, int]: ... # signature of Codec().encode
+@type_check_only
class _Decoder(Protocol):
def __call__(self, input: ReadableBuffer, errors: str = ..., /) -> tuple[str, int]: ... # signature of Codec().decode
+@type_check_only
class _StreamReader(Protocol):
def __call__(self, stream: _ReadableStream, errors: str = ..., /) -> StreamReader: ...
+@type_check_only
class _StreamWriter(Protocol):
def __call__(self, stream: _WritableStream, errors: str = ..., /) -> StreamWriter: ...
+@type_check_only
class _IncrementalEncoder(Protocol):
def __call__(self, errors: str = ...) -> IncrementalEncoder: ...
+@type_check_only
class _IncrementalDecoder(Protocol):
def __call__(self, errors: str = ...) -> IncrementalDecoder: ...
+@type_check_only
class _BufferedIncrementalDecoder(Protocol):
def __call__(self, errors: str = ...) -> BufferedIncrementalDecoder: ...
diff --git a/python/helpers/typeshed/stdlib/collections/__init__.pyi b/python/helpers/typeshed/stdlib/collections/__init__.pyi
index a095ba78cc3c..df9449ef4c9b 100644
--- a/python/helpers/typeshed/stdlib/collections/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/collections/__init__.pyi
@@ -2,21 +2,21 @@ import sys
from _collections_abc import dict_items, dict_keys, dict_values
from _typeshed import SupportsItems, SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT
from types import GenericAlias
-from typing import Any, ClassVar, Generic, NoReturn, SupportsIndex, TypeVar, final, overload
+from typing import Any, ClassVar, Generic, NoReturn, SupportsIndex, TypeVar, final, overload, type_check_only
from typing_extensions import Self
if sys.version_info >= (3, 10):
from collections.abc import (
- Callable as Callable,
- ItemsView as ItemsView,
- Iterable as Iterable,
- Iterator as Iterator,
- KeysView as KeysView,
- Mapping as Mapping,
- MutableMapping as MutableMapping,
- MutableSequence as MutableSequence,
- Sequence as Sequence,
- ValuesView as ValuesView,
+ Callable,
+ ItemsView,
+ Iterable,
+ Iterator,
+ KeysView,
+ Mapping,
+ MutableMapping,
+ MutableSequence,
+ Sequence,
+ ValuesView,
)
else:
from _collections_abc import *
@@ -108,6 +108,8 @@ class UserDict(MutableMapping[_KT, _VT]):
@overload
def get(self, key: _KT, default: None = None) -> _VT | None: ...
@overload
+ def get(self, key: _KT, default: _VT) -> _VT: ...
+ @overload
def get(self, key: _KT, default: _T) -> _VT | _T: ...
class UserList(MutableSequence[_T]):
@@ -340,14 +342,17 @@ class _OrderedDictValuesView(ValuesView[_VT_co]):
# but they are not exposed anywhere)
# pyright doesn't have a specific error code for subclassing error!
@final
+@type_check_only
class _odict_keys(dict_keys[_KT_co, _VT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
def __reversed__(self) -> Iterator[_KT_co]: ...
@final
+@type_check_only
class _odict_items(dict_items[_KT_co, _VT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...
@final
+@type_check_only
class _odict_values(dict_values[_KT_co, _VT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
def __reversed__(self) -> Iterator[_VT_co]: ...
@@ -452,6 +457,8 @@ class ChainMap(MutableMapping[_KT, _VT]):
@overload
def get(self, key: _KT, default: None = None) -> _VT | None: ...
@overload
+ def get(self, key: _KT, default: _VT) -> _VT: ...
+ @overload
def get(self, key: _KT, default: _T) -> _VT | _T: ...
def __missing__(self, key: _KT) -> _VT: ... # undocumented
def __bool__(self) -> bool: ...
diff --git a/python/helpers/typeshed/stdlib/colorsys.pyi b/python/helpers/typeshed/stdlib/colorsys.pyi
index 7842f80284ef..4afcb5392b58 100644
--- a/python/helpers/typeshed/stdlib/colorsys.pyi
+++ b/python/helpers/typeshed/stdlib/colorsys.pyi
@@ -1,3 +1,5 @@
+from typing import Final
+
__all__ = ["rgb_to_yiq", "yiq_to_rgb", "rgb_to_hls", "hls_to_rgb", "rgb_to_hsv", "hsv_to_rgb"]
def rgb_to_yiq(r: float, g: float, b: float) -> tuple[float, float, float]: ...
@@ -8,6 +10,6 @@ def rgb_to_hsv(r: float, g: float, b: float) -> tuple[float, float, float]: ...
def hsv_to_rgb(h: float, s: float, v: float) -> tuple[float, float, float]: ...
# TODO: undocumented
-ONE_SIXTH: float
-ONE_THIRD: float
-TWO_THIRD: float
+ONE_SIXTH: Final[float]
+ONE_THIRD: Final[float]
+TWO_THIRD: Final[float]
diff --git a/python/helpers/typeshed/stdlib/compileall.pyi b/python/helpers/typeshed/stdlib/compileall.pyi
index a599b1b23540..8972d50a4a63 100644
--- a/python/helpers/typeshed/stdlib/compileall.pyi
+++ b/python/helpers/typeshed/stdlib/compileall.pyi
@@ -1,10 +1,11 @@
import sys
from _typeshed import StrPath
from py_compile import PycInvalidationMode
-from typing import Any, Protocol
+from typing import Any, Protocol, type_check_only
__all__ = ["compile_dir", "compile_file", "compile_path"]
+@type_check_only
class _SupportsSearch(Protocol):
def search(self, string: str, /) -> Any: ...
diff --git a/python/helpers/typeshed/stdlib/compression/bz2/__init__.pyi b/python/helpers/typeshed/stdlib/compression/bz2.pyi
similarity index 100%
rename from python/helpers/typeshed/stdlib/compression/bz2/__init__.pyi
rename to python/helpers/typeshed/stdlib/compression/bz2.pyi
diff --git a/python/helpers/typeshed/stdlib/compression/gzip/__init__.pyi b/python/helpers/typeshed/stdlib/compression/gzip.pyi
similarity index 100%
rename from python/helpers/typeshed/stdlib/compression/gzip/__init__.pyi
rename to python/helpers/typeshed/stdlib/compression/gzip.pyi
diff --git a/python/helpers/typeshed/stdlib/compression/lzma/__init__.pyi b/python/helpers/typeshed/stdlib/compression/lzma.pyi
similarity index 100%
rename from python/helpers/typeshed/stdlib/compression/lzma/__init__.pyi
rename to python/helpers/typeshed/stdlib/compression/lzma.pyi
diff --git a/python/helpers/typeshed/stdlib/compression/zlib/__init__.pyi b/python/helpers/typeshed/stdlib/compression/zlib.pyi
similarity index 100%
rename from python/helpers/typeshed/stdlib/compression/zlib/__init__.pyi
rename to python/helpers/typeshed/stdlib/compression/zlib.pyi
diff --git a/python/helpers/typeshed/stdlib/compression/zstd/_zstdfile.pyi b/python/helpers/typeshed/stdlib/compression/zstd/_zstdfile.pyi
index 045b2d35acfe..e67b3d992f2f 100644
--- a/python/helpers/typeshed/stdlib/compression/zstd/_zstdfile.pyi
+++ b/python/helpers/typeshed/stdlib/compression/zstd/_zstdfile.pyi
@@ -3,7 +3,7 @@ from collections.abc import Mapping
from compression._common import _streams
from compression.zstd import ZstdDict
from io import TextIOWrapper, _WrappedBuffer
-from typing import Literal, overload, type_check_only
+from typing import Literal, Protocol, overload, type_check_only
from typing_extensions import TypeAlias
from _zstd import ZstdCompressor, _ZstdCompressorFlushBlock, _ZstdCompressorFlushFrame
@@ -16,11 +16,11 @@ _ReadTextMode: TypeAlias = Literal["rt"]
_WriteTextMode: TypeAlias = Literal["wt", "xt", "at"]
@type_check_only
-class _FileBinaryRead(_streams._Reader):
+class _FileBinaryRead(_streams._Reader, Protocol):
def close(self) -> None: ...
@type_check_only
-class _FileBinaryWrite(SupportsWrite[bytes]):
+class _FileBinaryWrite(SupportsWrite[bytes], Protocol):
def close(self) -> None: ...
class ZstdFile(_streams.BaseStream):
diff --git a/python/helpers/typeshed/stdlib/concurrent/futures/__init__.pyi b/python/helpers/typeshed/stdlib/concurrent/futures/__init__.pyi
index dd1f6da80c4d..ad4d20ea5445 100644
--- a/python/helpers/typeshed/stdlib/concurrent/futures/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/concurrent/futures/__init__.pyi
@@ -19,7 +19,7 @@ from .thread import ThreadPoolExecutor as ThreadPoolExecutor
if sys.version_info >= (3, 14):
from .interpreter import InterpreterPoolExecutor as InterpreterPoolExecutor
- __all__ = (
+ __all__ = [
"FIRST_COMPLETED",
"FIRST_EXCEPTION",
"ALL_COMPLETED",
@@ -34,7 +34,7 @@ if sys.version_info >= (3, 14):
"ProcessPoolExecutor",
"ThreadPoolExecutor",
"InterpreterPoolExecutor",
- )
+ ]
elif sys.version_info >= (3, 13):
__all__ = (
diff --git a/python/helpers/typeshed/stdlib/concurrent/futures/_base.pyi b/python/helpers/typeshed/stdlib/concurrent/futures/_base.pyi
index fbf07a3fc78f..be48a6e4289c 100644
--- a/python/helpers/typeshed/stdlib/concurrent/futures/_base.pyi
+++ b/python/helpers/typeshed/stdlib/concurrent/futures/_base.pyi
@@ -4,7 +4,7 @@ from _typeshed import Unused
from collections.abc import Callable, Iterable, Iterator
from logging import Logger
from types import GenericAlias, TracebackType
-from typing import Any, Final, Generic, NamedTuple, Protocol, TypeVar
+from typing import Any, Final, Generic, NamedTuple, Protocol, TypeVar, type_check_only
from typing_extensions import ParamSpec, Self
FIRST_COMPLETED: Final = "FIRST_COMPLETED"
@@ -15,8 +15,7 @@ RUNNING: Final = "RUNNING"
CANCELLED: Final = "CANCELLED"
CANCELLED_AND_NOTIFIED: Final = "CANCELLED_AND_NOTIFIED"
FINISHED: Final = "FINISHED"
-_FUTURE_STATES: list[str]
-_STATE_TO_DESCRIPTION_MAP: dict[str, str]
+_STATE_TO_DESCRIPTION_MAP: Final[dict[str, str]]
LOGGER: Logger
class Error(Exception): ...
@@ -74,6 +73,7 @@ class Executor:
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> bool | None: ...
+@type_check_only
class _AsCompletedFuture(Protocol[_T_co]):
# as_completed only mutates non-generic aspects of passed Futures and does not do any nominal
# checks. Therefore, we can use a Protocol here to allow as_completed to act covariantly.
diff --git a/python/helpers/typeshed/stdlib/concurrent/futures/interpreter.pyi b/python/helpers/typeshed/stdlib/concurrent/futures/interpreter.pyi
index 9c1078983d8c..e101022babcb 100644
--- a/python/helpers/typeshed/stdlib/concurrent/futures/interpreter.pyi
+++ b/python/helpers/typeshed/stdlib/concurrent/futures/interpreter.pyi
@@ -1,10 +1,13 @@
import sys
-from collections.abc import Callable, Mapping
+from collections.abc import Callable
from concurrent.futures import ThreadPoolExecutor
-from typing import Literal, Protocol, overload, type_check_only
+from typing import Any, Literal, Protocol, overload, type_check_only
from typing_extensions import ParamSpec, Self, TypeAlias, TypeVar, TypeVarTuple, Unpack
_Task: TypeAlias = tuple[bytes, Literal["function", "script"]]
+_Ts = TypeVarTuple("_Ts")
+_P = ParamSpec("_P")
+_R = TypeVar("_R")
@type_check_only
class _TaskFunc(Protocol):
@@ -13,62 +16,41 @@ class _TaskFunc(Protocol):
@overload
def __call__(self, fn: str) -> tuple[bytes, Literal["script"]]: ...
-_Ts = TypeVarTuple("_Ts")
-_P = ParamSpec("_P")
-_R = TypeVar("_R")
-
-# A `type.simplenamespace` with `__name__` attribute.
-@type_check_only
-class _HasName(Protocol):
- __name__: str
-
-# `_interpreters.exec` technically gives us a simple namespace.
-@type_check_only
-class _ExcInfo(Protocol):
- formatted: str
- msg: str
- type: _HasName
-
if sys.version_info >= (3, 14):
from concurrent.futures.thread import BrokenThreadPool, WorkerContext as ThreadWorkerContext
+ from concurrent.interpreters import Interpreter, Queue
- from _interpreters import InterpreterError
-
- class ExecutionFailed(InterpreterError):
- def __init__(self, excinfo: _ExcInfo) -> None: ... # type: ignore[override]
+ def do_call(results: Queue, func: Callable[..., _R], args: tuple[Any, ...], kwargs: dict[str, Any]) -> _R: ...
class WorkerContext(ThreadWorkerContext):
- # Parent class doesn't have `shared` argument,
- @overload # type: ignore[override]
+ interp: Interpreter | None
+ results: Queue | None
+ @overload # type: ignore[override]
@classmethod
def prepare(
- cls, initializer: Callable[[Unpack[_Ts]], object], initargs: tuple[Unpack[_Ts]], shared: Mapping[str, object]
+ cls, initializer: Callable[[Unpack[_Ts]], object], initargs: tuple[Unpack[_Ts]]
) -> tuple[Callable[[], Self], _TaskFunc]: ...
- @overload # type: ignore[override]
+ @overload
@classmethod
- def prepare(
- cls, initializer: Callable[[], object], initargs: tuple[()], shared: Mapping[str, object]
- ) -> tuple[Callable[[], Self], _TaskFunc]: ...
- def __init__(
- self, initdata: tuple[bytes, Literal["function", "script"]], shared: Mapping[str, object] | None = None
- ) -> None: ... # type: ignore[override]
+ def prepare(cls, initializer: Callable[[], object], initargs: tuple[()]) -> tuple[Callable[[], Self], _TaskFunc]: ...
+ def __init__(self, initdata: _Task) -> None: ...
def __del__(self) -> None: ...
- def run(self, task: _Task) -> None: ... # type: ignore[override]
+ def run(self, task: _Task) -> None: ... # type: ignore[override]
class BrokenInterpreterPool(BrokenThreadPool): ...
class InterpreterPoolExecutor(ThreadPoolExecutor):
BROKEN: type[BrokenInterpreterPool]
- @overload # type: ignore[override]
+ @overload # type: ignore[override]
@classmethod
def prepare_context(
- cls, initializer: Callable[[], object], initargs: tuple[()], shared: Mapping[str, object]
+ cls, initializer: Callable[[], object], initargs: tuple[()]
) -> tuple[Callable[[], WorkerContext], _TaskFunc]: ...
- @overload # type: ignore[override]
+ @overload
@classmethod
def prepare_context(
- cls, initializer: Callable[[Unpack[_Ts]], object], initargs: tuple[Unpack[_Ts]], shared: Mapping[str, object]
+ cls, initializer: Callable[[Unpack[_Ts]], object], initargs: tuple[Unpack[_Ts]]
) -> tuple[Callable[[], WorkerContext], _TaskFunc]: ...
@overload
def __init__(
@@ -77,7 +59,6 @@ if sys.version_info >= (3, 14):
thread_name_prefix: str = "",
initializer: Callable[[], object] | None = None,
initargs: tuple[()] = (),
- shared: Mapping[str, object] | None = None,
) -> None: ...
@overload
def __init__(
@@ -87,7 +68,6 @@ if sys.version_info >= (3, 14):
*,
initializer: Callable[[Unpack[_Ts]], object],
initargs: tuple[Unpack[_Ts]],
- shared: Mapping[str, object] | None = None,
) -> None: ...
@overload
def __init__(
@@ -96,5 +76,4 @@ if sys.version_info >= (3, 14):
thread_name_prefix: str,
initializer: Callable[[Unpack[_Ts]], object],
initargs: tuple[Unpack[_Ts]],
- shared: Mapping[str, object] | None = None,
) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/concurrent/futures/process.pyi b/python/helpers/typeshed/stdlib/concurrent/futures/process.pyi
index 607990100369..071b3aba5d33 100644
--- a/python/helpers/typeshed/stdlib/concurrent/futures/process.pyi
+++ b/python/helpers/typeshed/stdlib/concurrent/futures/process.pyi
@@ -5,7 +5,7 @@ from multiprocessing.context import BaseContext, Process
from multiprocessing.queues import Queue, SimpleQueue
from threading import Lock, Semaphore, Thread
from types import TracebackType
-from typing import Any, Generic, TypeVar, overload
+from typing import Any, Final, Generic, TypeVar, overload
from typing_extensions import TypeVarTuple, Unpack
from weakref import ref
@@ -28,9 +28,9 @@ class _ThreadWakeup:
def _python_exit() -> None: ...
-EXTRA_QUEUED_CALLS: int
+EXTRA_QUEUED_CALLS: Final = 1
-_MAX_WINDOWS_WORKERS: int
+_MAX_WINDOWS_WORKERS: Final = 61
class _RemoteTraceback(Exception):
tb: str
diff --git a/python/helpers/typeshed/stdlib/concurrent/futures/thread.pyi b/python/helpers/typeshed/stdlib/concurrent/futures/thread.pyi
index 22df0dca5a3f..50a6a9c6f43e 100644
--- a/python/helpers/typeshed/stdlib/concurrent/futures/thread.pyi
+++ b/python/helpers/typeshed/stdlib/concurrent/futures/thread.pyi
@@ -91,8 +91,12 @@ class ThreadPoolExecutor(Executor):
_shutdown: bool
_shutdown_lock: Lock
_thread_name_prefix: str | None
- _initializer: Callable[..., None] | None
- _initargs: tuple[Any, ...]
+ if sys.version_info >= (3, 14):
+ _create_worker_context: Callable[[], WorkerContext]
+ _resolve_work_item_task: _ResolveTaskFunc
+ else:
+ _initializer: Callable[..., None] | None
+ _initargs: tuple[Any, ...]
_work_queue: queue.SimpleQueue[_WorkItem[Any]]
if sys.version_info >= (3, 14):
@@ -100,12 +104,12 @@ class ThreadPoolExecutor(Executor):
@classmethod
def prepare_context(
cls, initializer: Callable[[], object], initargs: tuple[()]
- ) -> tuple[Callable[[], Self], _ResolveTaskFunc]: ...
+ ) -> tuple[Callable[[], WorkerContext], _ResolveTaskFunc]: ...
@overload
@classmethod
def prepare_context(
cls, initializer: Callable[[Unpack[_Ts]], object], initargs: tuple[Unpack[_Ts]]
- ) -> tuple[Callable[[], Self], _ResolveTaskFunc]: ...
+ ) -> tuple[Callable[[], WorkerContext], _ResolveTaskFunc]: ...
@overload
def __init__(
diff --git a/python/helpers/typeshed/stdlib/concurrent/interpreters/__init__.pyi b/python/helpers/typeshed/stdlib/concurrent/interpreters/__init__.pyi
new file mode 100644
index 000000000000..3839e6bef09b
--- /dev/null
+++ b/python/helpers/typeshed/stdlib/concurrent/interpreters/__init__.pyi
@@ -0,0 +1,68 @@
+import sys
+import threading
+import types
+from collections.abc import Callable
+from typing import Any, Literal, TypeVar
+from typing_extensions import ParamSpec, Self
+
+if sys.version_info >= (3, 13): # needed to satisfy pyright checks for Python <3.13
+ from _interpreters import (
+ InterpreterError as InterpreterError,
+ InterpreterNotFoundError as InterpreterNotFoundError,
+ NotShareableError as NotShareableError,
+ _SharedDict,
+ _Whence,
+ is_shareable as is_shareable,
+ )
+
+ from ._queues import Queue as Queue, QueueEmpty as QueueEmpty, QueueFull as QueueFull, create as create_queue
+
+ __all__ = [
+ "ExecutionFailed",
+ "Interpreter",
+ "InterpreterError",
+ "InterpreterNotFoundError",
+ "NotShareableError",
+ "Queue",
+ "QueueEmpty",
+ "QueueFull",
+ "create",
+ "create_queue",
+ "get_current",
+ "get_main",
+ "is_shareable",
+ "list_all",
+ ]
+
+ _R = TypeVar("_R")
+ _P = ParamSpec("_P")
+
+ class ExecutionFailed(InterpreterError):
+ excinfo: types.SimpleNamespace
+
+ def __init__(self, excinfo: types.SimpleNamespace) -> None: ...
+
+ def create() -> Interpreter: ...
+ def list_all() -> list[Interpreter]: ...
+ def get_current() -> Interpreter: ...
+ def get_main() -> Interpreter: ...
+
+ class Interpreter:
+ def __new__(cls, id: int, /, _whence: _Whence | None = None, _ownsref: bool | None = None) -> Self: ...
+ def __reduce__(self) -> tuple[type[Self], int]: ...
+ def __hash__(self) -> int: ...
+ def __del__(self) -> None: ...
+ @property
+ def id(self) -> int: ...
+ @property
+ def whence(
+ self,
+ ) -> Literal["unknown", "runtime init", "legacy C-API", "C-API", "cross-interpreter C-API", "_interpreters module"]: ...
+ def is_running(self) -> bool: ...
+ def close(self) -> None: ...
+ def prepare_main(
+ self, ns: _SharedDict | None = None, /, **kwargs: Any
+ ) -> None: ... # kwargs has same value restrictions as _SharedDict
+ def exec(self, code: str | types.CodeType | Callable[[], object], /) -> None: ...
+ def call(self, callable: Callable[_P, _R], /, *args: _P.args, **kwargs: _P.kwargs) -> _R: ...
+ def call_in_thread(self, callable: Callable[_P, object], /, *args: _P.args, **kwargs: _P.kwargs) -> threading.Thread: ...
diff --git a/python/helpers/typeshed/stdlib/concurrent/interpreters/_crossinterp.pyi b/python/helpers/typeshed/stdlib/concurrent/interpreters/_crossinterp.pyi
new file mode 100644
index 000000000000..b073aefa7ca7
--- /dev/null
+++ b/python/helpers/typeshed/stdlib/concurrent/interpreters/_crossinterp.pyi
@@ -0,0 +1,29 @@
+import sys
+from collections.abc import Callable
+from typing import Final, NewType
+from typing_extensions import Never, Self, TypeAlias
+
+if sys.version_info >= (3, 13): # needed to satisfy pyright checks for Python <3.13
+ from _interpqueues import _UnboundOp
+
+ class ItemInterpreterDestroyed(Exception): ...
+ # Actually a descriptor that behaves similarly to classmethod but prevents
+ # access from instances.
+ classonly = classmethod
+
+ class UnboundItem:
+ def __new__(cls) -> Never: ...
+ @classonly
+ def singleton(cls, kind: str, module: str, name: str = "UNBOUND") -> Self: ...
+
+ # Sentinel types and alias that don't exist at runtime.
+ _UnboundErrorType = NewType("_UnboundErrorType", object)
+ _UnboundRemoveType = NewType("_UnboundRemoveType", object)
+ _AnyUnbound: TypeAlias = _UnboundErrorType | _UnboundRemoveType | UnboundItem
+
+ UNBOUND_ERROR: Final[_UnboundErrorType]
+ UNBOUND_REMOVE: Final[_UnboundRemoveType]
+ UNBOUND: Final[UnboundItem] # analogous to UNBOUND_REPLACE in C
+
+ def serialize_unbound(unbound: _AnyUnbound) -> tuple[_UnboundOp]: ...
+ def resolve_unbound(flag: _UnboundOp, exctype_destroyed: Callable[[str], BaseException]) -> UnboundItem: ...
diff --git a/python/helpers/typeshed/stdlib/concurrent/interpreters/_queues.pyi b/python/helpers/typeshed/stdlib/concurrent/interpreters/_queues.pyi
new file mode 100644
index 000000000000..39a057ee9a7b
--- /dev/null
+++ b/python/helpers/typeshed/stdlib/concurrent/interpreters/_queues.pyi
@@ -0,0 +1,58 @@
+import queue
+import sys
+from typing import Final, SupportsIndex
+from typing_extensions import Self
+
+if sys.version_info >= (3, 13): # needed to satisfy pyright checks for Python <3.13
+ from _interpqueues import QueueError as QueueError, QueueNotFoundError as QueueNotFoundError
+
+ from . import _crossinterp
+ from ._crossinterp import UNBOUND_ERROR as UNBOUND_ERROR, UNBOUND_REMOVE as UNBOUND_REMOVE, UnboundItem, _AnyUnbound
+
+ __all__ = [
+ "UNBOUND",
+ "UNBOUND_ERROR",
+ "UNBOUND_REMOVE",
+ "ItemInterpreterDestroyed",
+ "Queue",
+ "QueueEmpty",
+ "QueueError",
+ "QueueFull",
+ "QueueNotFoundError",
+ "create",
+ "list_all",
+ ]
+
+ class QueueEmpty(QueueError, queue.Empty): ...
+ class QueueFull(QueueError, queue.Full): ...
+ class ItemInterpreterDestroyed(QueueError, _crossinterp.ItemInterpreterDestroyed): ...
+ UNBOUND: Final[UnboundItem]
+
+ def create(maxsize: int = 0, *, unbounditems: _AnyUnbound = ...) -> Queue: ...
+ def list_all() -> list[Queue]: ...
+
+ class Queue:
+ def __new__(cls, id: int, /) -> Self: ...
+ def __del__(self) -> None: ...
+ def __hash__(self) -> int: ...
+ def __reduce__(self) -> tuple[type[Self], int]: ...
+ @property
+ def id(self) -> int: ...
+ @property
+ def unbounditems(self) -> _AnyUnbound: ...
+ @property
+ def maxsize(self) -> int: ...
+ def empty(self) -> bool: ...
+ def full(self) -> bool: ...
+ def qsize(self) -> int: ...
+ def put(
+ self,
+ obj: object,
+ timeout: SupportsIndex | None = None,
+ *,
+ unbounditems: _AnyUnbound | None = None,
+ _delay: float = ...,
+ ) -> None: ...
+ def put_nowait(self, obj: object, *, unbounditems: _AnyUnbound | None = None) -> None: ...
+ def get(self, timeout: SupportsIndex | None = None, *, _delay: float = ...) -> object: ...
+ def get_nowait(self) -> object: ...
diff --git a/python/helpers/typeshed/stdlib/configparser.pyi b/python/helpers/typeshed/stdlib/configparser.pyi
index 15c564c02589..764a8a965ea2 100644
--- a/python/helpers/typeshed/stdlib/configparser.pyi
+++ b/python/helpers/typeshed/stdlib/configparser.pyi
@@ -2,8 +2,8 @@ import sys
from _typeshed import MaybeNone, StrOrBytesPath, SupportsWrite
from collections.abc import Callable, ItemsView, Iterable, Iterator, Mapping, MutableMapping, Sequence
from re import Pattern
-from typing import Any, ClassVar, Final, Literal, TypeVar, overload
-from typing_extensions import TypeAlias
+from typing import Any, ClassVar, Final, Literal, TypeVar, overload, type_check_only
+from typing_extensions import TypeAlias, deprecated
if sys.version_info >= (3, 14):
__all__ = (
@@ -104,7 +104,9 @@ else:
]
if sys.version_info >= (3, 13):
+ @type_check_only
class _UNNAMED_SECTION: ...
+
UNNAMED_SECTION: _UNNAMED_SECTION
_SectionName: TypeAlias = str | _UNNAMED_SECTION
@@ -135,6 +137,9 @@ class BasicInterpolation(Interpolation): ...
class ExtendedInterpolation(Interpolation): ...
if sys.version_info < (3, 13):
+ @deprecated(
+ "Deprecated since Python 3.2; removed in Python 3.13. Use `BasicInterpolation` or `ExtendedInterpolation` instead."
+ )
class LegacyInterpolation(Interpolation):
def before_get(self, parser: _Parser, section: _SectionName, option: str, value: str, vars: _Section) -> str: ...
@@ -269,6 +274,7 @@ class RawConfigParser(_Parser):
def read_string(self, string: str, source: str = "") -> None: ...
def read_dict(self, dictionary: Mapping[str, Mapping[str, Any]], source: str = "") -> None: ...
if sys.version_info < (3, 12):
+ @deprecated("Deprecated since Python 3.2; removed in Python 3.12. Use `parser.read_file()` instead.")
def readfp(self, fp: Iterable[str], filename: str | None = None) -> None: ...
# These get* methods are partially applied (with the same names) in
# SectionProxy; the stubs should be kept updated together
@@ -329,7 +335,8 @@ class ConfigParser(RawConfigParser):
) -> str | _T: ...
if sys.version_info < (3, 12):
- class SafeConfigParser(ConfigParser): ... # deprecated alias
+ @deprecated("Deprecated since Python 3.2; removed in Python 3.12. Use `ConfigParser` instead.")
+ class SafeConfigParser(ConfigParser): ...
class SectionProxy(MutableMapping[str, str]):
def __init__(self, parser: RawConfigParser, name: str) -> None: ...
@@ -369,17 +376,17 @@ class SectionProxy(MutableMapping[str, str]):
# These are partially-applied version of the methods with the same names in
# RawConfigParser; the stubs should be kept updated together
@overload
- def getint(self, option: str, *, raw: bool = ..., vars: _Section | None = ...) -> int | None: ...
+ def getint(self, option: str, *, raw: bool = False, vars: _Section | None = None) -> int | None: ...
@overload
- def getint(self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: _Section | None = ...) -> int | _T: ...
+ def getint(self, option: str, fallback: _T = ..., *, raw: bool = False, vars: _Section | None = None) -> int | _T: ...
@overload
- def getfloat(self, option: str, *, raw: bool = ..., vars: _Section | None = ...) -> float | None: ...
+ def getfloat(self, option: str, *, raw: bool = False, vars: _Section | None = None) -> float | None: ...
@overload
- def getfloat(self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: _Section | None = ...) -> float | _T: ...
+ def getfloat(self, option: str, fallback: _T = ..., *, raw: bool = False, vars: _Section | None = None) -> float | _T: ...
@overload
- def getboolean(self, option: str, *, raw: bool = ..., vars: _Section | None = ...) -> bool | None: ...
+ def getboolean(self, option: str, *, raw: bool = False, vars: _Section | None = None) -> bool | None: ...
@overload
- def getboolean(self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: _Section | None = ...) -> bool | _T: ...
+ def getboolean(self, option: str, fallback: _T = ..., *, raw: bool = False, vars: _Section | None = None) -> bool | _T: ...
# SectionProxy can have arbitrary attributes when custom converters are used
def __getattr__(self, key: str) -> Callable[..., Any]: ...
@@ -441,10 +448,25 @@ class ParsingError(Error):
elif sys.version_info >= (3, 12):
def __init__(self, source: str) -> None: ...
else:
- def __init__(self, source: str | None = None, filename: str | None = None) -> None: ...
+ @overload
+ def __init__(self, source: str) -> None: ...
+ @overload
+ @deprecated("The `filename` parameter removed in Python 3.12. Use `source` instead.")
+ def __init__(self, source: None, filename: str | None) -> None: ...
+ @overload
+ @deprecated("The `filename` parameter removed in Python 3.12. Use `source` instead.")
+ def __init__(self, source: None = None, *, filename: str | None) -> None: ...
def append(self, lineno: int, line: str) -> None: ...
+ if sys.version_info < (3, 12):
+ @property
+ @deprecated("Deprecated since Python 3.2; removed in Python 3.12. Use `source` instead.")
+ def filename(self) -> str: ...
+ @filename.setter
+ @deprecated("Deprecated since Python 3.2; removed in Python 3.12. Use `source` instead.")
+ def filename(self, value: str) -> None: ...
+
class MissingSectionHeaderError(ParsingError):
lineno: int
line: str
diff --git a/python/helpers/typeshed/stdlib/contextlib.pyi b/python/helpers/typeshed/stdlib/contextlib.pyi
index 4663b448c79c..383a1b7f334b 100644
--- a/python/helpers/typeshed/stdlib/contextlib.pyi
+++ b/python/helpers/typeshed/stdlib/contextlib.pyi
@@ -4,7 +4,7 @@ from _typeshed import FileDescriptorOrPath, Unused
from abc import ABC, abstractmethod
from collections.abc import AsyncGenerator, AsyncIterator, Awaitable, Callable, Generator, Iterator
from types import TracebackType
-from typing import IO, Any, Generic, Protocol, TypeVar, overload, runtime_checkable
+from typing import IO, Any, Generic, Protocol, TypeVar, overload, runtime_checkable, type_check_only
from typing_extensions import ParamSpec, Self, TypeAlias
__all__ = [
@@ -47,6 +47,7 @@ _CM_EF = TypeVar("_CM_EF", bound=AbstractContextManager[Any, Any] | _ExitFunc)
# allowlist for use as a Protocol.
@runtime_checkable
class AbstractContextManager(ABC, Protocol[_T_co, _ExitT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
+ __slots__ = ()
def __enter__(self) -> _T_co: ...
@abstractmethod
def __exit__(
@@ -58,6 +59,7 @@ class AbstractContextManager(ABC, Protocol[_T_co, _ExitT_co]): # type: ignore[m
# allowlist for use as a Protocol.
@runtime_checkable
class AbstractAsyncContextManager(ABC, Protocol[_T_co, _ExitT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
+ __slots__ = ()
async def __aenter__(self) -> _T_co: ...
@abstractmethod
async def __aexit__(
@@ -112,7 +114,7 @@ else:
) -> bool | None: ...
def asynccontextmanager(func: Callable[_P, AsyncIterator[_T_co]]) -> Callable[_P, _AsyncGeneratorContextManager[_T_co]]: ...
-
+@type_check_only
class _SupportsClose(Protocol):
def close(self) -> object: ...
@@ -123,6 +125,7 @@ class closing(AbstractContextManager[_SupportsCloseT, None]):
def __exit__(self, *exc_info: Unused) -> None: ...
if sys.version_info >= (3, 10):
+ @type_check_only
class _SupportsAclose(Protocol):
def aclose(self) -> Awaitable[object]: ...
diff --git a/python/helpers/typeshed/stdlib/copy.pyi b/python/helpers/typeshed/stdlib/copy.pyi
index 2cceec6a2250..10d2f0ae3710 100644
--- a/python/helpers/typeshed/stdlib/copy.pyi
+++ b/python/helpers/typeshed/stdlib/copy.pyi
@@ -1,5 +1,5 @@
import sys
-from typing import Any, Protocol, TypeVar
+from typing import Any, Protocol, TypeVar, type_check_only
from typing_extensions import Self
__all__ = ["Error", "copy", "deepcopy"]
@@ -7,6 +7,7 @@ __all__ = ["Error", "copy", "deepcopy"]
_T = TypeVar("_T")
_SR = TypeVar("_SR", bound=_SupportsReplace)
+@type_check_only
class _SupportsReplace(Protocol):
# In reality doesn't support args, but there's no other great way to express this.
def __replace__(self, *args: Any, **kwargs: Any) -> Self: ...
diff --git a/python/helpers/typeshed/stdlib/ctypes/__init__.pyi b/python/helpers/typeshed/stdlib/ctypes/__init__.pyi
index 0b14bd856784..9da972240abb 100644
--- a/python/helpers/typeshed/stdlib/ctypes/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/ctypes/__init__.pyi
@@ -11,6 +11,7 @@ from _ctypes import (
_CData as _CData,
_CDataType as _CDataType,
_CField as _CField,
+ _CTypeBaseType,
_Pointer as _Pointer,
_PointerLike as _PointerLike,
_SimpleCData as _SimpleCData,
@@ -25,14 +26,14 @@ from _ctypes import (
from _typeshed import StrPath
from ctypes._endian import BigEndianStructure as BigEndianStructure, LittleEndianStructure as LittleEndianStructure
from types import GenericAlias
-from typing import Any, ClassVar, Generic, Literal, TypeVar, overload, type_check_only
+from typing import Any, ClassVar, Final, Generic, Literal, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias, deprecated
if sys.platform == "win32":
from _ctypes import FormatError as FormatError, get_last_error as get_last_error, set_last_error as set_last_error
if sys.version_info >= (3, 14):
- from _ctypes import COMError as COMError
+ from _ctypes import COMError as COMError, CopyComPointer as CopyComPointer
if sys.version_info >= (3, 11):
from ctypes._endian import BigEndianUnion as BigEndianUnion, LittleEndianUnion as LittleEndianUnion
@@ -54,7 +55,7 @@ if sys.version_info >= (3, 14):
else:
from _ctypes import POINTER as POINTER, pointer as pointer
-DEFAULT_MODE: int
+DEFAULT_MODE: Final[int]
class ArgumentError(Exception): ...
@@ -161,8 +162,14 @@ def create_string_buffer(init: int | bytes, size: int | None = None) -> Array[c_
c_buffer = create_string_buffer
def create_unicode_buffer(init: int | str, size: int | None = None) -> Array[c_wchar]: ...
-@deprecated("Deprecated in Python 3.13; removal scheduled for Python 3.15")
-def SetPointerType(pointer: type[_Pointer[Any]], cls: Any) -> None: ...
+
+if sys.version_info >= (3, 13):
+ @deprecated("Deprecated since Python 3.13; will be removed in Python 3.15.")
+ def SetPointerType(pointer: type[_Pointer[Any]], cls: _CTypeBaseType) -> None: ...
+
+else:
+ def SetPointerType(pointer: type[_Pointer[Any]], cls: _CTypeBaseType) -> None: ...
+
def ARRAY(typ: _CT, len: int) -> Array[_CT]: ... # Soft Deprecated, no plans to remove
if sys.platform == "win32":
diff --git a/python/helpers/typeshed/stdlib/ctypes/_endian.pyi b/python/helpers/typeshed/stdlib/ctypes/_endian.pyi
index 144f5ba5dd40..97852f67aa6e 100644
--- a/python/helpers/typeshed/stdlib/ctypes/_endian.pyi
+++ b/python/helpers/typeshed/stdlib/ctypes/_endian.pyi
@@ -3,10 +3,14 @@ from ctypes import Structure, Union
# At runtime, the native endianness is an alias for Structure,
# while the other is a subclass with a metaclass added in.
-class BigEndianStructure(Structure): ...
+class BigEndianStructure(Structure):
+ __slots__ = ()
+
class LittleEndianStructure(Structure): ...
# Same thing for these: one is an alias of Union at runtime
if sys.version_info >= (3, 11):
- class BigEndianUnion(Union): ...
+ class BigEndianUnion(Union):
+ __slots__ = ()
+
class LittleEndianUnion(Union): ...
diff --git a/python/helpers/typeshed/stdlib/ctypes/macholib/__init__.pyi b/python/helpers/typeshed/stdlib/ctypes/macholib/__init__.pyi
index bda5b5a7f4cc..c5dd95466063 100644
--- a/python/helpers/typeshed/stdlib/ctypes/macholib/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/ctypes/macholib/__init__.pyi
@@ -1 +1,3 @@
-__version__: str
+from typing import Final
+
+__version__: Final[str]
diff --git a/python/helpers/typeshed/stdlib/ctypes/wintypes.pyi b/python/helpers/typeshed/stdlib/ctypes/wintypes.pyi
index e9ed0df24dd1..0f0d61a396d5 100644
--- a/python/helpers/typeshed/stdlib/ctypes/wintypes.pyi
+++ b/python/helpers/typeshed/stdlib/ctypes/wintypes.pyi
@@ -21,7 +21,7 @@ from ctypes import (
c_wchar,
c_wchar_p,
)
-from typing import Any, TypeVar
+from typing import Any, Final, TypeVar
from typing_extensions import Self, TypeAlias
if sys.version_info >= (3, 12):
@@ -177,7 +177,7 @@ class MSG(Structure):
pt: _CField[POINT, POINT, POINT]
tagMSG = MSG
-MAX_PATH: int
+MAX_PATH: Final = 260
class WIN32_FIND_DATAA(Structure):
dwFileAttributes: _CIntLikeField[DWORD]
diff --git a/python/helpers/typeshed/stdlib/curses/__init__.pyi b/python/helpers/typeshed/stdlib/curses/__init__.pyi
index 5c157fd7c2f6..2c0231c13087 100644
--- a/python/helpers/typeshed/stdlib/curses/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/curses/__init__.pyi
@@ -14,12 +14,12 @@ _T = TypeVar("_T")
_P = ParamSpec("_P")
# available after calling `curses.initscr()`
-LINES: int
-COLS: int
+LINES: Final[int]
+COLS: Final[int]
# available after calling `curses.start_color()`
-COLORS: int
-COLOR_PAIRS: int
+COLORS: Final[int]
+COLOR_PAIRS: Final[int]
def wrapper(func: Callable[Concatenate[window, _P], _T], /, *arg: _P.args, **kwds: _P.kwargs) -> _T: ...
diff --git a/python/helpers/typeshed/stdlib/curses/ascii.pyi b/python/helpers/typeshed/stdlib/curses/ascii.pyi
index 66efbe36a7df..0234434b8c3d 100644
--- a/python/helpers/typeshed/stdlib/curses/ascii.pyi
+++ b/python/helpers/typeshed/stdlib/curses/ascii.pyi
@@ -1,45 +1,45 @@
-from typing import TypeVar
+from typing import Final, TypeVar
_CharT = TypeVar("_CharT", str, int)
-NUL: int
-SOH: int
-STX: int
-ETX: int
-EOT: int
-ENQ: int
-ACK: int
-BEL: int
-BS: int
-TAB: int
-HT: int
-LF: int
-NL: int
-VT: int
-FF: int
-CR: int
-SO: int
-SI: int
-DLE: int
-DC1: int
-DC2: int
-DC3: int
-DC4: int
-NAK: int
-SYN: int
-ETB: int
-CAN: int
-EM: int
-SUB: int
-ESC: int
-FS: int
-GS: int
-RS: int
-US: int
-SP: int
-DEL: int
+NUL: Final = 0x00
+SOH: Final = 0x01
+STX: Final = 0x02
+ETX: Final = 0x03
+EOT: Final = 0x04
+ENQ: Final = 0x05
+ACK: Final = 0x06
+BEL: Final = 0x07
+BS: Final = 0x08
+TAB: Final = 0x09
+HT: Final = 0x09
+LF: Final = 0x0A
+NL: Final = 0x0A
+VT: Final = 0x0B
+FF: Final = 0x0C
+CR: Final = 0x0D
+SO: Final = 0x0E
+SI: Final = 0x0F
+DLE: Final = 0x10
+DC1: Final = 0x11
+DC2: Final = 0x12
+DC3: Final = 0x13
+DC4: Final = 0x14
+NAK: Final = 0x15
+SYN: Final = 0x16
+ETB: Final = 0x17
+CAN: Final = 0x18
+EM: Final = 0x19
+SUB: Final = 0x1A
+ESC: Final = 0x1B
+FS: Final = 0x1C
+GS: Final = 0x1D
+RS: Final = 0x1E
+US: Final = 0x1F
+SP: Final = 0x20
+DEL: Final = 0x7F
-controlnames: list[int]
+controlnames: Final[list[int]]
def isalnum(c: str | int) -> bool: ...
def isalpha(c: str | int) -> bool: ...
diff --git a/python/helpers/typeshed/stdlib/dataclasses.pyi b/python/helpers/typeshed/stdlib/dataclasses.pyi
index c76b0b0e61e2..3a1c8cb5d62d 100644
--- a/python/helpers/typeshed/stdlib/dataclasses.pyi
+++ b/python/helpers/typeshed/stdlib/dataclasses.pyi
@@ -5,7 +5,7 @@ from _typeshed import DataclassInstance
from builtins import type as Type # alias to avoid name clashes with fields named "type"
from collections.abc import Callable, Iterable, Mapping
from types import GenericAlias
-from typing import Any, Generic, Literal, Protocol, TypeVar, overload, type_check_only
+from typing import Any, Final, Generic, Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Never, TypeIs
_T = TypeVar("_T")
@@ -58,7 +58,7 @@ class _DataclassFactory(Protocol):
class _MISSING_TYPE(enum.Enum):
MISSING = enum.auto()
-MISSING = _MISSING_TYPE.MISSING
+MISSING: Final = _MISSING_TYPE.MISSING
if sys.version_info >= (3, 10):
class KW_ONLY: ...
@@ -165,10 +165,42 @@ else:
) -> Callable[[type[_T]], type[_T]]: ...
# See https://github.com/python/mypy/issues/10750
+@type_check_only
class _DefaultFactory(Protocol[_T_co]):
def __call__(self) -> _T_co: ...
class Field(Generic[_T]):
+ if sys.version_info >= (3, 14):
+ __slots__ = (
+ "name",
+ "type",
+ "default",
+ "default_factory",
+ "repr",
+ "hash",
+ "init",
+ "compare",
+ "metadata",
+ "kw_only",
+ "doc",
+ "_field_type",
+ )
+ elif sys.version_info >= (3, 10):
+ __slots__ = (
+ "name",
+ "type",
+ "default",
+ "default_factory",
+ "repr",
+ "hash",
+ "init",
+ "compare",
+ "metadata",
+ "kw_only",
+ "_field_type",
+ )
+ else:
+ __slots__ = ("name", "type", "default", "default_factory", "repr", "hash", "init", "compare", "metadata", "_field_type")
name: str
type: Type[_T] | str | Any
default: _T | Literal[_MISSING_TYPE.MISSING]
@@ -354,6 +386,7 @@ def is_dataclass(obj: object) -> TypeIs[DataclassInstance | type[DataclassInstan
class FrozenInstanceError(AttributeError): ...
class InitVar(Generic[_T]):
+ __slots__ = ("type",)
type: Type[_T]
def __init__(self, type: Type[_T]) -> None: ...
@overload
diff --git a/python/helpers/typeshed/stdlib/datetime.pyi b/python/helpers/typeshed/stdlib/datetime.pyi
index 37d6a06dfff9..c54de6159b51 100644
--- a/python/helpers/typeshed/stdlib/datetime.pyi
+++ b/python/helpers/typeshed/stdlib/datetime.pyi
@@ -118,13 +118,13 @@ class time:
resolution: ClassVar[timedelta]
def __new__(
cls,
- hour: SupportsIndex = ...,
- minute: SupportsIndex = ...,
- second: SupportsIndex = ...,
- microsecond: SupportsIndex = ...,
- tzinfo: _TzInfo | None = ...,
+ hour: SupportsIndex = 0,
+ minute: SupportsIndex = 0,
+ second: SupportsIndex = 0,
+ microsecond: SupportsIndex = 0,
+ tzinfo: _TzInfo | None = None,
*,
- fold: int = ...,
+ fold: int = 0,
) -> Self: ...
@property
def hour(self) -> int: ...
@@ -144,7 +144,7 @@ class time:
def __gt__(self, value: time, /) -> bool: ...
def __eq__(self, value: object, /) -> bool: ...
def __hash__(self) -> int: ...
- def isoformat(self, timespec: str = ...) -> str: ...
+ def isoformat(self, timespec: str = "auto") -> str: ...
@classmethod
def fromisoformat(cls, time_string: str, /) -> Self: ...
@@ -197,13 +197,13 @@ class timedelta:
resolution: ClassVar[timedelta]
def __new__(
cls,
- days: float = ...,
- seconds: float = ...,
- microseconds: float = ...,
- milliseconds: float = ...,
- minutes: float = ...,
- hours: float = ...,
- weeks: float = ...,
+ days: float = 0,
+ seconds: float = 0,
+ microseconds: float = 0,
+ milliseconds: float = 0,
+ minutes: float = 0,
+ hours: float = 0,
+ weeks: float = 0,
) -> Self: ...
@property
def days(self) -> int: ...
@@ -247,13 +247,13 @@ class datetime(date):
year: SupportsIndex,
month: SupportsIndex,
day: SupportsIndex,
- hour: SupportsIndex = ...,
- minute: SupportsIndex = ...,
- second: SupportsIndex = ...,
- microsecond: SupportsIndex = ...,
- tzinfo: _TzInfo | None = ...,
+ hour: SupportsIndex = 0,
+ minute: SupportsIndex = 0,
+ second: SupportsIndex = 0,
+ microsecond: SupportsIndex = 0,
+ tzinfo: _TzInfo | None = None,
*,
- fold: int = ...,
+ fold: int = 0,
) -> Self: ...
@property
def hour(self) -> int: ...
@@ -272,10 +272,10 @@ class datetime(date):
# meaning it is only *safe* to pass it as a keyword argument on 3.12+
if sys.version_info >= (3, 12):
@classmethod
- def fromtimestamp(cls, timestamp: float, tz: _TzInfo | None = ...) -> Self: ...
+ def fromtimestamp(cls, timestamp: float, tz: _TzInfo | None = None) -> Self: ...
else:
@classmethod
- def fromtimestamp(cls, timestamp: float, /, tz: _TzInfo | None = ...) -> Self: ...
+ def fromtimestamp(cls, timestamp: float, /, tz: _TzInfo | None = None) -> Self: ...
@classmethod
@deprecated("Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .fromtimestamp(datetime.timezone.utc)")
@@ -321,8 +321,8 @@ class datetime(date):
*,
fold: int = ...,
) -> Self: ...
- def astimezone(self, tz: _TzInfo | None = ...) -> Self: ...
- def isoformat(self, sep: str = ..., timespec: str = ...) -> str: ...
+ def astimezone(self, tz: _TzInfo | None = None) -> Self: ...
+ def isoformat(self, sep: str = "T", timespec: str = "auto") -> str: ...
@classmethod
def strptime(cls, date_string: str, format: str, /) -> Self: ...
def utcoffset(self) -> timedelta | None: ...
diff --git a/python/helpers/typeshed/stdlib/dbm/__init__.pyi b/python/helpers/typeshed/stdlib/dbm/__init__.pyi
index 7f344060f9ab..7cbb63cf2f06 100644
--- a/python/helpers/typeshed/stdlib/dbm/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/dbm/__init__.pyi
@@ -76,6 +76,7 @@ _TFlags: TypeAlias = Literal[
"nusf",
]
+@type_check_only
class _Database(MutableMapping[_KeyType, bytes]):
def close(self) -> None: ...
def __getitem__(self, key: _KeyType) -> bytes: ...
diff --git a/python/helpers/typeshed/stdlib/difflib.pyi b/python/helpers/typeshed/stdlib/difflib.pyi
index 18583a3acfe9..6efe68322bb6 100644
--- a/python/helpers/typeshed/stdlib/difflib.pyi
+++ b/python/helpers/typeshed/stdlib/difflib.pyi
@@ -1,3 +1,5 @@
+import re
+import sys
from collections.abc import Callable, Iterable, Iterator, Sequence
from types import GenericAlias
from typing import Any, AnyStr, Generic, Literal, NamedTuple, TypeVar, overload
@@ -60,7 +62,12 @@ class Differ:
def __init__(self, linejunk: Callable[[str], bool] | None = None, charjunk: Callable[[str], bool] | None = None) -> None: ...
def compare(self, a: Sequence[str], b: Sequence[str]) -> Iterator[str]: ...
-def IS_LINE_JUNK(line: str, pat: Any = ...) -> bool: ... # pat is undocumented
+if sys.version_info >= (3, 14):
+ def IS_LINE_JUNK(line: str, pat: Callable[[str], re.Match[str] | None] | None = None) -> bool: ...
+
+else:
+ def IS_LINE_JUNK(line: str, pat: Callable[[str], re.Match[str] | None] = ...) -> bool: ...
+
def IS_CHARACTER_JUNK(ch: str, ws: str = " \t") -> bool: ... # ws is undocumented
def unified_diff(
a: Sequence[str],
diff --git a/python/helpers/typeshed/stdlib/dis.pyi b/python/helpers/typeshed/stdlib/dis.pyi
index 86b6d01e3120..1c32925caf4b 100644
--- a/python/helpers/typeshed/stdlib/dis.pyi
+++ b/python/helpers/typeshed/stdlib/dis.pyi
@@ -2,7 +2,7 @@ import sys
import types
from collections.abc import Callable, Iterator
from opcode import * # `dis` re-exports it as a part of public API
-from typing import IO, Any, NamedTuple
+from typing import IO, Any, Final, NamedTuple
from typing_extensions import Self, TypeAlias
__all__ = [
@@ -178,7 +178,7 @@ class Bytecode:
def info(self) -> str: ...
def dis(self) -> str: ...
-COMPILER_FLAG_NAMES: dict[int, str]
+COMPILER_FLAG_NAMES: Final[dict[int, str]]
def findlabels(code: _HaveCodeType) -> list[int]: ...
def findlinestarts(code: _HaveCodeType) -> Iterator[tuple[int, int]]: ...
diff --git a/python/helpers/typeshed/stdlib/doctest.pyi b/python/helpers/typeshed/stdlib/doctest.pyi
index 562b5a5bdac9..1bb96e1a7786 100644
--- a/python/helpers/typeshed/stdlib/doctest.pyi
+++ b/python/helpers/typeshed/stdlib/doctest.pyi
@@ -3,7 +3,7 @@ import types
import unittest
from _typeshed import ExcInfo
from collections.abc import Callable
-from typing import Any, NamedTuple, type_check_only
+from typing import Any, Final, NamedTuple, type_check_only
from typing_extensions import Self, TypeAlias
__all__ = [
@@ -57,29 +57,29 @@ else:
failed: int
attempted: int
-OPTIONFLAGS_BY_NAME: dict[str, int]
+OPTIONFLAGS_BY_NAME: Final[dict[str, int]]
def register_optionflag(name: str) -> int: ...
-DONT_ACCEPT_TRUE_FOR_1: int
-DONT_ACCEPT_BLANKLINE: int
-NORMALIZE_WHITESPACE: int
-ELLIPSIS: int
-SKIP: int
-IGNORE_EXCEPTION_DETAIL: int
+DONT_ACCEPT_TRUE_FOR_1: Final = 1
+DONT_ACCEPT_BLANKLINE: Final = 2
+NORMALIZE_WHITESPACE: Final = 4
+ELLIPSIS: Final = 8
+SKIP: Final = 16
+IGNORE_EXCEPTION_DETAIL: Final = 32
-COMPARISON_FLAGS: int
+COMPARISON_FLAGS: Final = 63
-REPORT_UDIFF: int
-REPORT_CDIFF: int
-REPORT_NDIFF: int
-REPORT_ONLY_FIRST_FAILURE: int
-FAIL_FAST: int
+REPORT_UDIFF: Final = 64
+REPORT_CDIFF: Final = 128
+REPORT_NDIFF: Final = 256
+REPORT_ONLY_FIRST_FAILURE: Final = 512
+FAIL_FAST: Final = 1024
-REPORTING_FLAGS: int
+REPORTING_FLAGS: Final = 1984
-BLANKLINE_MARKER: str
-ELLIPSIS_MARKER: str
+BLANKLINE_MARKER: Final = ""
+ELLIPSIS_MARKER: Final = "..."
class Example:
source: str
diff --git a/python/helpers/typeshed/stdlib/email/_header_value_parser.pyi b/python/helpers/typeshed/stdlib/email/_header_value_parser.pyi
index 95ada186c4ec..dededd006e5b 100644
--- a/python/helpers/typeshed/stdlib/email/_header_value_parser.pyi
+++ b/python/helpers/typeshed/stdlib/email/_header_value_parser.pyi
@@ -25,7 +25,7 @@ SPECIALSNL: Final[set[str]]
def make_quoted_pairs(value: Any) -> str: ...
def quote_string(value: Any) -> str: ...
-rfc2047_matcher: Pattern[str]
+rfc2047_matcher: Final[Pattern[str]]
class TokenList(list[TokenList | Terminal]):
token_type: str | None
diff --git a/python/helpers/typeshed/stdlib/email/charset.pyi b/python/helpers/typeshed/stdlib/email/charset.pyi
index 683daa468cf3..e1930835bbd1 100644
--- a/python/helpers/typeshed/stdlib/email/charset.pyi
+++ b/python/helpers/typeshed/stdlib/email/charset.pyi
@@ -4,9 +4,16 @@ from typing import ClassVar, Final, overload
__all__ = ["Charset", "add_alias", "add_charset", "add_codec"]
-QP: Final[int] # undocumented
-BASE64: Final[int] # undocumented
-SHORTEST: Final[int] # undocumented
+QP: Final = 1 # undocumented
+BASE64: Final = 2 # undocumented
+SHORTEST: Final = 3 # undocumented
+RFC2047_CHROME_LEN: Final = 7 # undocumented
+DEFAULT_CHARSET: Final = "us-ascii" # undocumented
+UNKNOWN8BIT: Final = "unknown-8bit" # undocumented
+EMPTYSTRING: Final = "" # undocumented
+CHARSETS: Final[dict[str, tuple[int | None, int | None, str | None]]]
+ALIASES: Final[dict[str, str]]
+CODEC_MAP: Final[dict[str, str | None]] # undocumented
class Charset:
input_charset: str
diff --git a/python/helpers/typeshed/stdlib/email/headerregistry.pyi b/python/helpers/typeshed/stdlib/email/headerregistry.pyi
index dc641c8c952b..dff9593b731f 100644
--- a/python/helpers/typeshed/stdlib/email/headerregistry.pyi
+++ b/python/helpers/typeshed/stdlib/email/headerregistry.pyi
@@ -13,7 +13,7 @@ from email._header_value_parser import (
)
from email.errors import MessageDefect
from email.policy import Policy
-from typing import Any, ClassVar, Literal, Protocol
+from typing import Any, ClassVar, Literal, Protocol, type_check_only
from typing_extensions import Self
class BaseHeader(str):
@@ -137,6 +137,7 @@ class MessageIDHeader:
@staticmethod
def value_parser(value: str) -> MessageID: ...
+@type_check_only
class _HeaderParser(Protocol):
max_count: ClassVar[Literal[1] | None]
@staticmethod
diff --git a/python/helpers/typeshed/stdlib/email/message.pyi b/python/helpers/typeshed/stdlib/email/message.pyi
index e4d14992168a..794882b140e6 100644
--- a/python/helpers/typeshed/stdlib/email/message.pyi
+++ b/python/helpers/typeshed/stdlib/email/message.pyi
@@ -5,7 +5,7 @@ from email.charset import Charset
from email.contentmanager import ContentManager
from email.errors import MessageDefect
from email.policy import Policy
-from typing import Any, Generic, Literal, Protocol, TypeVar, overload
+from typing import Any, Generic, Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias
__all__ = ["Message", "EmailMessage"]
@@ -24,9 +24,11 @@ _EncodedPayloadType: TypeAlias = Message | bytes
_MultipartPayloadType: TypeAlias = list[_PayloadType]
_CharsetType: TypeAlias = Charset | str | None
+@type_check_only
class _SupportsEncodeToPayload(Protocol):
def encode(self, encoding: str, /) -> _PayloadType | _MultipartPayloadType | _SupportsDecodeToPayload: ...
+@type_check_only
class _SupportsDecodeToPayload(Protocol):
def decode(self, encoding: str, errors: str, /) -> _PayloadType | _MultipartPayloadType: ...
diff --git a/python/helpers/typeshed/stdlib/encodings/__init__.pyi b/python/helpers/typeshed/stdlib/encodings/__init__.pyi
index 12ec6792d49b..61f86d243c72 100644
--- a/python/helpers/typeshed/stdlib/encodings/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/encodings/__init__.pyi
@@ -1,3 +1,4 @@
+import sys
from codecs import CodecInfo
class CodecRegistryError(LookupError, SystemError): ...
@@ -5,5 +6,8 @@ class CodecRegistryError(LookupError, SystemError): ...
def normalize_encoding(encoding: str | bytes) -> str: ...
def search_function(encoding: str) -> CodecInfo | None: ...
+if sys.version_info >= (3, 14) and sys.platform == "win32":
+ def win32_code_page_search_function(encoding: str) -> CodecInfo | None: ...
+
# Needed for submodules
def __getattr__(name: str): ... # incomplete module
diff --git a/python/helpers/typeshed/stdlib/enum.pyi b/python/helpers/typeshed/stdlib/enum.pyi
index 327b135459a0..82054f284949 100644
--- a/python/helpers/typeshed/stdlib/enum.pyi
+++ b/python/helpers/typeshed/stdlib/enum.pyi
@@ -4,7 +4,7 @@ import types
from _typeshed import SupportsKeysAndGetItem, Unused
from builtins import property as _builtins_property
from collections.abc import Callable, Iterable, Iterator, Mapping
-from typing import Any, Generic, Literal, TypeVar, overload
+from typing import Any, Final, Generic, Literal, TypeVar, overload
from typing_extensions import Self, TypeAlias
__all__ = ["EnumMeta", "Enum", "IntEnum", "Flag", "IntFlag", "auto", "unique"]
@@ -219,6 +219,11 @@ class Enum(metaclass=EnumMeta):
if sys.version_info >= (3, 12) and sys.version_info < (3, 14):
@classmethod
def __signature__(cls) -> str: ...
+ if sys.version_info >= (3, 13):
+ # Value may be any type, even in special enums. Enabling Enum parsing from
+ # multiple value types
+ def _add_value_alias_(self, value: Any) -> None: ...
+ def _add_alias_(self, name: str) -> None: ...
if sys.version_info >= (3, 11):
class ReprEnum(Enum): ...
@@ -272,9 +277,9 @@ if sys.version_info >= (3, 11):
NAMED_FLAGS = "multi-flag aliases may not contain unnamed flags"
UNIQUE = "one name per value"
- CONTINUOUS = EnumCheck.CONTINUOUS
- NAMED_FLAGS = EnumCheck.NAMED_FLAGS
- UNIQUE = EnumCheck.UNIQUE
+ CONTINUOUS: Final = EnumCheck.CONTINUOUS
+ NAMED_FLAGS: Final = EnumCheck.NAMED_FLAGS
+ UNIQUE: Final = EnumCheck.UNIQUE
class verify:
def __init__(self, *checks: EnumCheck) -> None: ...
@@ -286,10 +291,10 @@ if sys.version_info >= (3, 11):
EJECT = "eject"
KEEP = "keep"
- STRICT = FlagBoundary.STRICT
- CONFORM = FlagBoundary.CONFORM
- EJECT = FlagBoundary.EJECT
- KEEP = FlagBoundary.KEEP
+ STRICT: Final = FlagBoundary.STRICT
+ CONFORM: Final = FlagBoundary.CONFORM
+ EJECT: Final = FlagBoundary.EJECT
+ KEEP: Final = FlagBoundary.KEEP
def global_str(self: Enum) -> str: ...
def global_enum(cls: _EnumerationT, update_str: bool = False) -> _EnumerationT: ...
diff --git a/python/helpers/typeshed/stdlib/errno.pyi b/python/helpers/typeshed/stdlib/errno.pyi
index 3ba8b66d2865..4f19b5aee87e 100644
--- a/python/helpers/typeshed/stdlib/errno.pyi
+++ b/python/helpers/typeshed/stdlib/errno.pyi
@@ -1,225 +1,226 @@
import sys
from collections.abc import Mapping
+from typing import Final
errorcode: Mapping[int, str]
-EPERM: int
-ENOENT: int
-ESRCH: int
-EINTR: int
-EIO: int
-ENXIO: int
-E2BIG: int
-ENOEXEC: int
-EBADF: int
-ECHILD: int
-EAGAIN: int
-ENOMEM: int
-EACCES: int
-EFAULT: int
-EBUSY: int
-EEXIST: int
-EXDEV: int
-ENODEV: int
-ENOTDIR: int
-EISDIR: int
-EINVAL: int
-ENFILE: int
-EMFILE: int
-ENOTTY: int
-ETXTBSY: int
-EFBIG: int
-ENOSPC: int
-ESPIPE: int
-EROFS: int
-EMLINK: int
-EPIPE: int
-EDOM: int
-ERANGE: int
-EDEADLK: int
-ENAMETOOLONG: int
-ENOLCK: int
-ENOSYS: int
-ENOTEMPTY: int
-ELOOP: int
-EWOULDBLOCK: int
-ENOMSG: int
-EIDRM: int
-ENOSTR: int
-ENODATA: int
-ETIME: int
-ENOSR: int
-EREMOTE: int
-ENOLINK: int
-EPROTO: int
-EBADMSG: int
-EOVERFLOW: int
-EILSEQ: int
-EUSERS: int
-ENOTSOCK: int
-EDESTADDRREQ: int
-EMSGSIZE: int
-EPROTOTYPE: int
-ENOPROTOOPT: int
-EPROTONOSUPPORT: int
-ESOCKTNOSUPPORT: int
-ENOTSUP: int
-EOPNOTSUPP: int
-EPFNOSUPPORT: int
-EAFNOSUPPORT: int
-EADDRINUSE: int
-EADDRNOTAVAIL: int
-ENETDOWN: int
-ENETUNREACH: int
-ENETRESET: int
-ECONNABORTED: int
-ECONNRESET: int
-ENOBUFS: int
-EISCONN: int
-ENOTCONN: int
-ESHUTDOWN: int
-ETOOMANYREFS: int
-ETIMEDOUT: int
-ECONNREFUSED: int
-EHOSTDOWN: int
-EHOSTUNREACH: int
-EALREADY: int
-EINPROGRESS: int
-ESTALE: int
-EDQUOT: int
-ECANCELED: int # undocumented
-ENOTRECOVERABLE: int # undocumented
-EOWNERDEAD: int # undocumented
+EPERM: Final[int]
+ENOENT: Final[int]
+ESRCH: Final[int]
+EINTR: Final[int]
+EIO: Final[int]
+ENXIO: Final[int]
+E2BIG: Final[int]
+ENOEXEC: Final[int]
+EBADF: Final[int]
+ECHILD: Final[int]
+EAGAIN: Final[int]
+ENOMEM: Final[int]
+EACCES: Final[int]
+EFAULT: Final[int]
+EBUSY: Final[int]
+EEXIST: Final[int]
+EXDEV: Final[int]
+ENODEV: Final[int]
+ENOTDIR: Final[int]
+EISDIR: Final[int]
+EINVAL: Final[int]
+ENFILE: Final[int]
+EMFILE: Final[int]
+ENOTTY: Final[int]
+ETXTBSY: Final[int]
+EFBIG: Final[int]
+ENOSPC: Final[int]
+ESPIPE: Final[int]
+EROFS: Final[int]
+EMLINK: Final[int]
+EPIPE: Final[int]
+EDOM: Final[int]
+ERANGE: Final[int]
+EDEADLK: Final[int]
+ENAMETOOLONG: Final[int]
+ENOLCK: Final[int]
+ENOSYS: Final[int]
+ENOTEMPTY: Final[int]
+ELOOP: Final[int]
+EWOULDBLOCK: Final[int]
+ENOMSG: Final[int]
+EIDRM: Final[int]
+ENOSTR: Final[int]
+ENODATA: Final[int]
+ETIME: Final[int]
+ENOSR: Final[int]
+EREMOTE: Final[int]
+ENOLINK: Final[int]
+EPROTO: Final[int]
+EBADMSG: Final[int]
+EOVERFLOW: Final[int]
+EILSEQ: Final[int]
+EUSERS: Final[int]
+ENOTSOCK: Final[int]
+EDESTADDRREQ: Final[int]
+EMSGSIZE: Final[int]
+EPROTOTYPE: Final[int]
+ENOPROTOOPT: Final[int]
+EPROTONOSUPPORT: Final[int]
+ESOCKTNOSUPPORT: Final[int]
+ENOTSUP: Final[int]
+EOPNOTSUPP: Final[int]
+EPFNOSUPPORT: Final[int]
+EAFNOSUPPORT: Final[int]
+EADDRINUSE: Final[int]
+EADDRNOTAVAIL: Final[int]
+ENETDOWN: Final[int]
+ENETUNREACH: Final[int]
+ENETRESET: Final[int]
+ECONNABORTED: Final[int]
+ECONNRESET: Final[int]
+ENOBUFS: Final[int]
+EISCONN: Final[int]
+ENOTCONN: Final[int]
+ESHUTDOWN: Final[int]
+ETOOMANYREFS: Final[int]
+ETIMEDOUT: Final[int]
+ECONNREFUSED: Final[int]
+EHOSTDOWN: Final[int]
+EHOSTUNREACH: Final[int]
+EALREADY: Final[int]
+EINPROGRESS: Final[int]
+ESTALE: Final[int]
+EDQUOT: Final[int]
+ECANCELED: Final[int] # undocumented
+ENOTRECOVERABLE: Final[int] # undocumented
+EOWNERDEAD: Final[int] # undocumented
if sys.platform == "sunos5" or sys.platform == "solaris": # noqa: Y008
- ELOCKUNMAPPED: int
- ENOTACTIVE: int
+ ELOCKUNMAPPED: Final[int]
+ ENOTACTIVE: Final[int]
if sys.platform != "win32":
- ENOTBLK: int
- EMULTIHOP: int
+ ENOTBLK: Final[int]
+ EMULTIHOP: Final[int]
if sys.platform == "darwin":
# All of the below are undocumented
- EAUTH: int
- EBADARCH: int
- EBADEXEC: int
- EBADMACHO: int
- EBADRPC: int
- EDEVERR: int
- EFTYPE: int
- ENEEDAUTH: int
- ENOATTR: int
- ENOPOLICY: int
- EPROCLIM: int
- EPROCUNAVAIL: int
- EPROGMISMATCH: int
- EPROGUNAVAIL: int
- EPWROFF: int
- ERPCMISMATCH: int
- ESHLIBVERS: int
+ EAUTH: Final[int]
+ EBADARCH: Final[int]
+ EBADEXEC: Final[int]
+ EBADMACHO: Final[int]
+ EBADRPC: Final[int]
+ EDEVERR: Final[int]
+ EFTYPE: Final[int]
+ ENEEDAUTH: Final[int]
+ ENOATTR: Final[int]
+ ENOPOLICY: Final[int]
+ EPROCLIM: Final[int]
+ EPROCUNAVAIL: Final[int]
+ EPROGMISMATCH: Final[int]
+ EPROGUNAVAIL: Final[int]
+ EPWROFF: Final[int]
+ ERPCMISMATCH: Final[int]
+ ESHLIBVERS: Final[int]
if sys.version_info >= (3, 11):
- EQFULL: int
+ EQFULL: Final[int]
if sys.platform != "darwin":
- EDEADLOCK: int
+ EDEADLOCK: Final[int]
if sys.platform != "win32" and sys.platform != "darwin":
- ECHRNG: int
- EL2NSYNC: int
- EL3HLT: int
- EL3RST: int
- ELNRNG: int
- EUNATCH: int
- ENOCSI: int
- EL2HLT: int
- EBADE: int
- EBADR: int
- EXFULL: int
- ENOANO: int
- EBADRQC: int
- EBADSLT: int
- EBFONT: int
- ENONET: int
- ENOPKG: int
- EADV: int
- ESRMNT: int
- ECOMM: int
- EDOTDOT: int
- ENOTUNIQ: int
- EBADFD: int
- EREMCHG: int
- ELIBACC: int
- ELIBBAD: int
- ELIBSCN: int
- ELIBMAX: int
- ELIBEXEC: int
- ERESTART: int
- ESTRPIPE: int
- EUCLEAN: int
- ENOTNAM: int
- ENAVAIL: int
- EISNAM: int
- EREMOTEIO: int
+ ECHRNG: Final[int]
+ EL2NSYNC: Final[int]
+ EL3HLT: Final[int]
+ EL3RST: Final[int]
+ ELNRNG: Final[int]
+ EUNATCH: Final[int]
+ ENOCSI: Final[int]
+ EL2HLT: Final[int]
+ EBADE: Final[int]
+ EBADR: Final[int]
+ EXFULL: Final[int]
+ ENOANO: Final[int]
+ EBADRQC: Final[int]
+ EBADSLT: Final[int]
+ EBFONT: Final[int]
+ ENONET: Final[int]
+ ENOPKG: Final[int]
+ EADV: Final[int]
+ ESRMNT: Final[int]
+ ECOMM: Final[int]
+ EDOTDOT: Final[int]
+ ENOTUNIQ: Final[int]
+ EBADFD: Final[int]
+ EREMCHG: Final[int]
+ ELIBACC: Final[int]
+ ELIBBAD: Final[int]
+ ELIBSCN: Final[int]
+ ELIBMAX: Final[int]
+ ELIBEXEC: Final[int]
+ ERESTART: Final[int]
+ ESTRPIPE: Final[int]
+ EUCLEAN: Final[int]
+ ENOTNAM: Final[int]
+ ENAVAIL: Final[int]
+ EISNAM: Final[int]
+ EREMOTEIO: Final[int]
# All of the below are undocumented
- EKEYEXPIRED: int
- EKEYREJECTED: int
- EKEYREVOKED: int
- EMEDIUMTYPE: int
- ENOKEY: int
- ENOMEDIUM: int
- ERFKILL: int
+ EKEYEXPIRED: Final[int]
+ EKEYREJECTED: Final[int]
+ EKEYREVOKED: Final[int]
+ EMEDIUMTYPE: Final[int]
+ ENOKEY: Final[int]
+ ENOMEDIUM: Final[int]
+ ERFKILL: Final[int]
if sys.version_info >= (3, 14):
- EHWPOISON: int
+ EHWPOISON: Final[int]
if sys.platform == "win32":
# All of these are undocumented
- WSABASEERR: int
- WSAEACCES: int
- WSAEADDRINUSE: int
- WSAEADDRNOTAVAIL: int
- WSAEAFNOSUPPORT: int
- WSAEALREADY: int
- WSAEBADF: int
- WSAECONNABORTED: int
- WSAECONNREFUSED: int
- WSAECONNRESET: int
- WSAEDESTADDRREQ: int
- WSAEDISCON: int
- WSAEDQUOT: int
- WSAEFAULT: int
- WSAEHOSTDOWN: int
- WSAEHOSTUNREACH: int
- WSAEINPROGRESS: int
- WSAEINTR: int
- WSAEINVAL: int
- WSAEISCONN: int
- WSAELOOP: int
- WSAEMFILE: int
- WSAEMSGSIZE: int
- WSAENAMETOOLONG: int
- WSAENETDOWN: int
- WSAENETRESET: int
- WSAENETUNREACH: int
- WSAENOBUFS: int
- WSAENOPROTOOPT: int
- WSAENOTCONN: int
- WSAENOTEMPTY: int
- WSAENOTSOCK: int
- WSAEOPNOTSUPP: int
- WSAEPFNOSUPPORT: int
- WSAEPROCLIM: int
- WSAEPROTONOSUPPORT: int
- WSAEPROTOTYPE: int
- WSAEREMOTE: int
- WSAESHUTDOWN: int
- WSAESOCKTNOSUPPORT: int
- WSAESTALE: int
- WSAETIMEDOUT: int
- WSAETOOMANYREFS: int
- WSAEUSERS: int
- WSAEWOULDBLOCK: int
- WSANOTINITIALISED: int
- WSASYSNOTREADY: int
- WSAVERNOTSUPPORTED: int
+ WSABASEERR: Final[int]
+ WSAEACCES: Final[int]
+ WSAEADDRINUSE: Final[int]
+ WSAEADDRNOTAVAIL: Final[int]
+ WSAEAFNOSUPPORT: Final[int]
+ WSAEALREADY: Final[int]
+ WSAEBADF: Final[int]
+ WSAECONNABORTED: Final[int]
+ WSAECONNREFUSED: Final[int]
+ WSAECONNRESET: Final[int]
+ WSAEDESTADDRREQ: Final[int]
+ WSAEDISCON: Final[int]
+ WSAEDQUOT: Final[int]
+ WSAEFAULT: Final[int]
+ WSAEHOSTDOWN: Final[int]
+ WSAEHOSTUNREACH: Final[int]
+ WSAEINPROGRESS: Final[int]
+ WSAEINTR: Final[int]
+ WSAEINVAL: Final[int]
+ WSAEISCONN: Final[int]
+ WSAELOOP: Final[int]
+ WSAEMFILE: Final[int]
+ WSAEMSGSIZE: Final[int]
+ WSAENAMETOOLONG: Final[int]
+ WSAENETDOWN: Final[int]
+ WSAENETRESET: Final[int]
+ WSAENETUNREACH: Final[int]
+ WSAENOBUFS: Final[int]
+ WSAENOPROTOOPT: Final[int]
+ WSAENOTCONN: Final[int]
+ WSAENOTEMPTY: Final[int]
+ WSAENOTSOCK: Final[int]
+ WSAEOPNOTSUPP: Final[int]
+ WSAEPFNOSUPPORT: Final[int]
+ WSAEPROCLIM: Final[int]
+ WSAEPROTONOSUPPORT: Final[int]
+ WSAEPROTOTYPE: Final[int]
+ WSAEREMOTE: Final[int]
+ WSAESHUTDOWN: Final[int]
+ WSAESOCKTNOSUPPORT: Final[int]
+ WSAESTALE: Final[int]
+ WSAETIMEDOUT: Final[int]
+ WSAETOOMANYREFS: Final[int]
+ WSAEUSERS: Final[int]
+ WSAEWOULDBLOCK: Final[int]
+ WSANOTINITIALISED: Final[int]
+ WSASYSNOTREADY: Final[int]
+ WSAVERNOTSUPPORTED: Final[int]
diff --git a/python/helpers/typeshed/stdlib/fcntl.pyi b/python/helpers/typeshed/stdlib/fcntl.pyi
index 2fe64eb53201..5a3e89b0c676 100644
--- a/python/helpers/typeshed/stdlib/fcntl.pyi
+++ b/python/helpers/typeshed/stdlib/fcntl.pyi
@@ -4,107 +4,107 @@ from typing import Any, Final, Literal, overload
from typing_extensions import Buffer
if sys.platform != "win32":
- FASYNC: int
- FD_CLOEXEC: int
- F_DUPFD: int
- F_DUPFD_CLOEXEC: int
- F_GETFD: int
- F_GETFL: int
- F_GETLK: int
- F_GETOWN: int
- F_RDLCK: int
- F_SETFD: int
- F_SETFL: int
- F_SETLK: int
- F_SETLKW: int
- F_SETOWN: int
- F_UNLCK: int
- F_WRLCK: int
+ FASYNC: Final[int]
+ FD_CLOEXEC: Final[int]
+ F_DUPFD: Final[int]
+ F_DUPFD_CLOEXEC: Final[int]
+ F_GETFD: Final[int]
+ F_GETFL: Final[int]
+ F_GETLK: Final[int]
+ F_GETOWN: Final[int]
+ F_RDLCK: Final[int]
+ F_SETFD: Final[int]
+ F_SETFL: Final[int]
+ F_SETLK: Final[int]
+ F_SETLKW: Final[int]
+ F_SETOWN: Final[int]
+ F_UNLCK: Final[int]
+ F_WRLCK: Final[int]
- F_GETLEASE: int
- F_SETLEASE: int
+ F_GETLEASE: Final[int]
+ F_SETLEASE: Final[int]
if sys.platform == "darwin":
- F_FULLFSYNC: int
- F_NOCACHE: int
- F_GETPATH: int
+ F_FULLFSYNC: Final[int]
+ F_NOCACHE: Final[int]
+ F_GETPATH: Final[int]
if sys.platform == "linux":
- F_SETLKW64: int
- F_SETSIG: int
- F_SHLCK: int
- F_SETLK64: int
- F_GETSIG: int
- F_NOTIFY: int
- F_EXLCK: int
- F_GETLK64: int
- F_ADD_SEALS: int
- F_GET_SEALS: int
- F_SEAL_GROW: int
- F_SEAL_SEAL: int
- F_SEAL_SHRINK: int
- F_SEAL_WRITE: int
+ F_SETLKW64: Final[int]
+ F_SETSIG: Final[int]
+ F_SHLCK: Final[int]
+ F_SETLK64: Final[int]
+ F_GETSIG: Final[int]
+ F_NOTIFY: Final[int]
+ F_EXLCK: Final[int]
+ F_GETLK64: Final[int]
+ F_ADD_SEALS: Final[int]
+ F_GET_SEALS: Final[int]
+ F_SEAL_GROW: Final[int]
+ F_SEAL_SEAL: Final[int]
+ F_SEAL_SHRINK: Final[int]
+ F_SEAL_WRITE: Final[int]
F_OFD_GETLK: Final[int]
F_OFD_SETLK: Final[int]
F_OFD_SETLKW: Final[int]
if sys.version_info >= (3, 10):
- F_GETPIPE_SZ: int
- F_SETPIPE_SZ: int
+ F_GETPIPE_SZ: Final[int]
+ F_SETPIPE_SZ: Final[int]
- DN_ACCESS: int
- DN_ATTRIB: int
- DN_CREATE: int
- DN_DELETE: int
- DN_MODIFY: int
- DN_MULTISHOT: int
- DN_RENAME: int
+ DN_ACCESS: Final[int]
+ DN_ATTRIB: Final[int]
+ DN_CREATE: Final[int]
+ DN_DELETE: Final[int]
+ DN_MODIFY: Final[int]
+ DN_MULTISHOT: Final[int]
+ DN_RENAME: Final[int]
- LOCK_EX: int
- LOCK_NB: int
- LOCK_SH: int
- LOCK_UN: int
+ LOCK_EX: Final[int]
+ LOCK_NB: Final[int]
+ LOCK_SH: Final[int]
+ LOCK_UN: Final[int]
if sys.platform == "linux":
- LOCK_MAND: int
- LOCK_READ: int
- LOCK_RW: int
- LOCK_WRITE: int
+ LOCK_MAND: Final[int]
+ LOCK_READ: Final[int]
+ LOCK_RW: Final[int]
+ LOCK_WRITE: Final[int]
if sys.platform == "linux":
# Constants for the POSIX STREAMS interface. Present in glibc until 2.29 (released February 2019).
# Never implemented on BSD, and considered "obsolescent" starting in POSIX 2008.
# Probably still used on Solaris.
- I_ATMARK: int
- I_CANPUT: int
- I_CKBAND: int
- I_FDINSERT: int
- I_FIND: int
- I_FLUSH: int
- I_FLUSHBAND: int
- I_GETBAND: int
- I_GETCLTIME: int
- I_GETSIG: int
- I_GRDOPT: int
- I_GWROPT: int
- I_LINK: int
- I_LIST: int
- I_LOOK: int
- I_NREAD: int
- I_PEEK: int
- I_PLINK: int
- I_POP: int
- I_PUNLINK: int
- I_PUSH: int
- I_RECVFD: int
- I_SENDFD: int
- I_SETCLTIME: int
- I_SETSIG: int
- I_SRDOPT: int
- I_STR: int
- I_SWROPT: int
- I_UNLINK: int
+ I_ATMARK: Final[int]
+ I_CANPUT: Final[int]
+ I_CKBAND: Final[int]
+ I_FDINSERT: Final[int]
+ I_FIND: Final[int]
+ I_FLUSH: Final[int]
+ I_FLUSHBAND: Final[int]
+ I_GETBAND: Final[int]
+ I_GETCLTIME: Final[int]
+ I_GETSIG: Final[int]
+ I_GRDOPT: Final[int]
+ I_GWROPT: Final[int]
+ I_LINK: Final[int]
+ I_LIST: Final[int]
+ I_LOOK: Final[int]
+ I_NREAD: Final[int]
+ I_PEEK: Final[int]
+ I_PLINK: Final[int]
+ I_POP: Final[int]
+ I_PUNLINK: Final[int]
+ I_PUSH: Final[int]
+ I_RECVFD: Final[int]
+ I_SENDFD: Final[int]
+ I_SETCLTIME: Final[int]
+ I_SETSIG: Final[int]
+ I_SRDOPT: Final[int]
+ I_STR: Final[int]
+ I_SWROPT: Final[int]
+ I_UNLINK: Final[int]
if sys.version_info >= (3, 12) and sys.platform == "linux":
- FICLONE: int
- FICLONERANGE: int
+ FICLONE: Final[int]
+ FICLONERANGE: Final[int]
if sys.version_info >= (3, 13) and sys.platform == "linux":
F_OWNER_TID: Final = 0
diff --git a/python/helpers/typeshed/stdlib/filecmp.pyi b/python/helpers/typeshed/stdlib/filecmp.pyi
index a2a2b235fdad..620cc177a415 100644
--- a/python/helpers/typeshed/stdlib/filecmp.pyi
+++ b/python/helpers/typeshed/stdlib/filecmp.pyi
@@ -6,7 +6,7 @@ from typing import Any, AnyStr, Final, Generic, Literal
__all__ = ["clear_cache", "cmp", "dircmp", "cmpfiles", "DEFAULT_IGNORES"]
-DEFAULT_IGNORES: list[str]
+DEFAULT_IGNORES: Final[list[str]]
BUFSIZE: Final = 8192
def cmp(f1: StrOrBytesPath, f2: StrOrBytesPath, shallow: bool | Literal[0, 1] = True) -> bool: ...
diff --git a/python/helpers/typeshed/stdlib/fileinput.pyi b/python/helpers/typeshed/stdlib/fileinput.pyi
index 948b39ea1e1c..910d63814275 100644
--- a/python/helpers/typeshed/stdlib/fileinput.pyi
+++ b/python/helpers/typeshed/stdlib/fileinput.pyi
@@ -2,7 +2,7 @@ import sys
from _typeshed import AnyStr_co, StrOrBytesPath
from collections.abc import Callable, Iterable
from types import GenericAlias, TracebackType
-from typing import IO, Any, AnyStr, Generic, Literal, Protocol, overload
+from typing import IO, Any, AnyStr, Generic, Literal, Protocol, overload, type_check_only
from typing_extensions import Self, TypeAlias
__all__ = [
@@ -25,6 +25,7 @@ if sys.version_info >= (3, 11):
else:
_TextMode: TypeAlias = Literal["r", "rU", "U"]
+@type_check_only
class _HasReadlineAndFileno(Protocol[AnyStr_co]):
def readline(self) -> AnyStr_co: ...
def fileno(self) -> int: ...
diff --git a/python/helpers/typeshed/stdlib/fractions.pyi b/python/helpers/typeshed/stdlib/fractions.pyi
index 16259fcfadc7..ef4066aa65b5 100644
--- a/python/helpers/typeshed/stdlib/fractions.pyi
+++ b/python/helpers/typeshed/stdlib/fractions.pyi
@@ -2,17 +2,19 @@ import sys
from collections.abc import Callable
from decimal import Decimal
from numbers import Rational, Real
-from typing import Any, Literal, Protocol, SupportsIndex, overload
+from typing import Any, Literal, Protocol, SupportsIndex, overload, type_check_only
from typing_extensions import Self, TypeAlias
_ComparableNum: TypeAlias = int | float | Decimal | Real
__all__ = ["Fraction"]
+@type_check_only
class _ConvertibleToIntegerRatio(Protocol):
def as_integer_ratio(self) -> tuple[int | Rational, int | Rational]: ...
class Fraction(Rational):
+ __slots__ = ("_numerator", "_denominator")
@overload
def __new__(cls, numerator: int | Rational = 0, denominator: int | Rational | None = None) -> Self: ...
@overload
diff --git a/python/helpers/typeshed/stdlib/functools.pyi b/python/helpers/typeshed/stdlib/functools.pyi
index e31399fb8705..e41eb4c2b65d 100644
--- a/python/helpers/typeshed/stdlib/functools.pyi
+++ b/python/helpers/typeshed/stdlib/functools.pyi
@@ -3,7 +3,7 @@ import types
from _typeshed import SupportsAllComparisons, SupportsItems
from collections.abc import Callable, Hashable, Iterable, Sized
from types import GenericAlias
-from typing import Any, Final, Generic, Literal, NamedTuple, TypedDict, TypeVar, final, overload
+from typing import Any, Final, Generic, Literal, NamedTuple, TypedDict, TypeVar, final, overload, type_check_only
from typing_extensions import ParamSpec, Self, TypeAlias
__all__ = [
@@ -48,6 +48,7 @@ class _CacheInfo(NamedTuple):
maxsize: int | None
currsize: int
+@type_check_only
class _CacheParameters(TypedDict):
maxsize: int
typed: bool
@@ -94,8 +95,9 @@ else:
tuple[Literal["__module__"], Literal["__name__"], Literal["__qualname__"], Literal["__doc__"], Literal["__annotations__"]]
]
-WRAPPER_UPDATES: tuple[Literal["__dict__"]]
+WRAPPER_UPDATES: Final[tuple[Literal["__dict__"]]]
+@type_check_only
class _Wrapped(Generic[_PWrapped, _RWrapped, _PWrapper, _RWrapper]):
__wrapped__: Callable[_PWrapped, _RWrapped]
def __call__(self, *args: _PWrapper.args, **kwargs: _PWrapper.kwargs) -> _RWrapper: ...
@@ -103,6 +105,7 @@ class _Wrapped(Generic[_PWrapped, _RWrapped, _PWrapper, _RWrapper]):
__name__: str
__qualname__: str
+@type_check_only
class _Wrapper(Generic[_PWrapped, _RWrapped]):
def __call__(self, f: Callable[_PWrapper, _RWrapper]) -> _Wrapped[_PWrapped, _RWrapped, _PWrapper, _RWrapper]: ...
@@ -180,6 +183,7 @@ if sys.version_info >= (3, 11):
else:
_RegType: TypeAlias = type[Any]
+@type_check_only
class _SingleDispatchCallable(Generic[_T]):
registry: types.MappingProxyType[Any, Callable[..., _T]]
def dispatch(self, cls: Any) -> Callable[..., _T]: ...
diff --git a/python/helpers/typeshed/stdlib/gettext.pyi b/python/helpers/typeshed/stdlib/gettext.pyi
index d8fd92a00e13..937aece03437 100644
--- a/python/helpers/typeshed/stdlib/gettext.pyi
+++ b/python/helpers/typeshed/stdlib/gettext.pyi
@@ -2,7 +2,8 @@ import io
import sys
from _typeshed import StrPath
from collections.abc import Callable, Container, Iterable, Sequence
-from typing import Any, Final, Literal, Protocol, TypeVar, overload
+from typing import Any, Final, Literal, Protocol, TypeVar, overload, type_check_only
+from typing_extensions import deprecated
__all__ = [
"NullTranslations",
@@ -26,6 +27,7 @@ __all__ = [
if sys.version_info < (3, 11):
__all__ += ["bind_textdomain_codeset", "ldgettext", "ldngettext", "lgettext", "lngettext"]
+@type_check_only
class _TranslationsReader(Protocol):
def read(self) -> bytes: ...
# optional:
@@ -42,9 +44,13 @@ class NullTranslations:
def info(self) -> dict[str, str]: ...
def charset(self) -> str | None: ...
if sys.version_info < (3, 11):
+ @deprecated("Deprecated since Python 3.8; removed in Python 3.11.")
def output_charset(self) -> str | None: ...
+ @deprecated("Deprecated since Python 3.8; removed in Python 3.11.")
def set_output_charset(self, charset: str) -> None: ...
+ @deprecated("Deprecated since Python 3.8; removed in Python 3.11. Use `gettext()` instead.")
def lgettext(self, message: str) -> str: ...
+ @deprecated("Deprecated since Python 3.8; removed in Python 3.11. Use `ngettext()` instead.")
def lngettext(self, msgid1: str, msgid2: str, n: int) -> str: ...
def install(self, names: Container[str] | None = None) -> None: ...
@@ -144,9 +150,16 @@ else:
fallback: bool = False,
codeset: str | None = None,
) -> NullTranslations: ...
+ @overload
def install(
- domain: str, localedir: StrPath | None = None, codeset: str | None = None, names: Container[str] | None = None
+ domain: str, localedir: StrPath | None = None, codeset: None = None, names: Container[str] | None = None
) -> None: ...
+ @overload
+ @deprecated("The `codeset` parameter is deprecated since Python 3.8; removed in Python 3.11.")
+ def install(domain: str, localedir: StrPath | None, codeset: str, /, names: Container[str] | None = None) -> None: ...
+ @overload
+ @deprecated("The `codeset` parameter is deprecated since Python 3.8; removed in Python 3.11.")
+ def install(domain: str, localedir: StrPath | None = None, *, codeset: str, names: Container[str] | None = None) -> None: ...
def textdomain(domain: str | None = None) -> str: ...
def bindtextdomain(domain: str, localedir: StrPath | None = None) -> str: ...
@@ -160,10 +173,15 @@ def npgettext(context: str, msgid1: str, msgid2: str, n: int) -> str: ...
def dnpgettext(domain: str, context: str, msgid1: str, msgid2: str, n: int) -> str: ...
if sys.version_info < (3, 11):
+ @deprecated("Deprecated since Python 3.8; removed in Python 3.11. Use `gettext()` instead.")
def lgettext(message: str) -> str: ...
+ @deprecated("Deprecated since Python 3.8; removed in Python 3.11. Use `dgettext()` instead.")
def ldgettext(domain: str, message: str) -> str: ...
+ @deprecated("Deprecated since Python 3.8; removed in Python 3.11. Use `ngettext()` instead.")
def lngettext(msgid1: str, msgid2: str, n: int) -> str: ...
+ @deprecated("Deprecated since Python 3.8; removed in Python 3.11. Use `dngettext()` instead.")
def ldngettext(domain: str, msgid1: str, msgid2: str, n: int) -> str: ...
+ @deprecated("Deprecated since Python 3.8; removed in Python 3.11. Use `bindtextdomain()` instead.")
def bind_textdomain_codeset(domain: str, codeset: str | None = None) -> str: ...
Catalog = translation
diff --git a/python/helpers/typeshed/stdlib/glob.pyi b/python/helpers/typeshed/stdlib/glob.pyi
index 03cb5418e256..942fd7396196 100644
--- a/python/helpers/typeshed/stdlib/glob.pyi
+++ b/python/helpers/typeshed/stdlib/glob.pyi
@@ -2,14 +2,26 @@ import sys
from _typeshed import StrOrBytesPath
from collections.abc import Iterator, Sequence
from typing import AnyStr
+from typing_extensions import deprecated
__all__ = ["escape", "glob", "iglob"]
if sys.version_info >= (3, 13):
__all__ += ["translate"]
-def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ...
-def glob1(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ...
+if sys.version_info >= (3, 10):
+ @deprecated(
+ "Deprecated since Python 3.10; will be removed in Python 3.15. Use `glob.glob()` with the *root_dir* argument instead."
+ )
+ def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ...
+ @deprecated(
+ "Deprecated since Python 3.10; will be removed in Python 3.15. Use `glob.glob()` with the *root_dir* argument instead."
+ )
+ def glob1(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ...
+
+else:
+ def glob0(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ...
+ def glob1(dirname: AnyStr, pattern: AnyStr) -> list[AnyStr]: ...
if sys.version_info >= (3, 11):
def glob(
diff --git a/python/helpers/typeshed/stdlib/gzip.pyi b/python/helpers/typeshed/stdlib/gzip.pyi
index 34ae92b4d8ed..b18f76f06e3e 100644
--- a/python/helpers/typeshed/stdlib/gzip.pyi
+++ b/python/helpers/typeshed/stdlib/gzip.pyi
@@ -2,8 +2,8 @@ import sys
import zlib
from _typeshed import ReadableBuffer, SizedBuffer, StrOrBytesPath, WriteableBuffer
from io import FileIO, TextIOWrapper
-from typing import Final, Literal, Protocol, overload
-from typing_extensions import TypeAlias
+from typing import Final, Literal, Protocol, overload, type_check_only
+from typing_extensions import TypeAlias, deprecated
if sys.version_info >= (3, 14):
from compression._common._streams import BaseStream, DecompressReader
@@ -25,6 +25,7 @@ FEXTRA: Final[int] # actually Literal[4] # undocumented
FNAME: Final[int] # actually Literal[8] # undocumented
FCOMMENT: Final[int] # actually Literal[16] # undocumented
+@type_check_only
class _ReadableFileobj(Protocol):
def read(self, n: int, /) -> bytes: ...
def seek(self, n: int, /) -> object: ...
@@ -33,6 +34,7 @@ class _ReadableFileobj(Protocol):
# mode: str
# def fileno() -> int: ...
+@type_check_only
class _WritableFileobj(Protocol):
def write(self, b: bytes, /) -> object: ...
def flush(self) -> object: ...
@@ -141,6 +143,7 @@ class GzipFile(BaseStream):
) -> None: ...
if sys.version_info < (3, 12):
@property
+ @deprecated("Deprecated since Python 2.6; removed in Python 3.12. Use `name` attribute instead.")
def filename(self) -> str: ...
@property
diff --git a/python/helpers/typeshed/stdlib/hashlib.pyi b/python/helpers/typeshed/stdlib/hashlib.pyi
index b32c0e992574..924136301b21 100644
--- a/python/helpers/typeshed/stdlib/hashlib.pyi
+++ b/python/helpers/typeshed/stdlib/hashlib.pyi
@@ -20,7 +20,7 @@ from _hashlib import (
)
from _typeshed import ReadableBuffer
from collections.abc import Callable, Set as AbstractSet
-from typing import Protocol
+from typing import Protocol, type_check_only
if sys.version_info >= (3, 11):
__all__ = (
@@ -72,9 +72,11 @@ algorithms_guaranteed: AbstractSet[str]
algorithms_available: AbstractSet[str]
if sys.version_info >= (3, 11):
+ @type_check_only
class _BytesIOLike(Protocol):
def getbuffer(self) -> ReadableBuffer: ...
+ @type_check_only
class _FileDigestFileObj(Protocol):
def readinto(self, buf: bytearray, /) -> int: ...
def readable(self) -> bool: ...
diff --git a/python/helpers/typeshed/stdlib/hmac.pyi b/python/helpers/typeshed/stdlib/hmac.pyi
index 300ed9eb26d8..070c59b1c166 100644
--- a/python/helpers/typeshed/stdlib/hmac.pyi
+++ b/python/helpers/typeshed/stdlib/hmac.pyi
@@ -20,6 +20,7 @@ def new(key: bytes | bytearray, msg: ReadableBuffer | None, digestmod: _DigestMo
def new(key: bytes | bytearray, *, digestmod: _DigestMod) -> HMAC: ...
class HMAC:
+ __slots__ = ("_hmac", "_inner", "_outer", "block_size", "digest_size")
digest_size: int
block_size: int
@property
diff --git a/python/helpers/typeshed/stdlib/html/entities.pyi b/python/helpers/typeshed/stdlib/html/entities.pyi
index be83fd1135be..e5890d1ecfbd 100644
--- a/python/helpers/typeshed/stdlib/html/entities.pyi
+++ b/python/helpers/typeshed/stdlib/html/entities.pyi
@@ -1,6 +1,8 @@
+from typing import Final
+
__all__ = ["html5", "name2codepoint", "codepoint2name", "entitydefs"]
-name2codepoint: dict[str, int]
-html5: dict[str, str]
-codepoint2name: dict[int, str]
-entitydefs: dict[str, str]
+name2codepoint: Final[dict[str, int]]
+html5: Final[dict[str, str]]
+codepoint2name: Final[dict[int, str]]
+entitydefs: Final[dict[str, str]]
diff --git a/python/helpers/typeshed/stdlib/html/parser.pyi b/python/helpers/typeshed/stdlib/html/parser.pyi
index d322ade965d9..8b3fce0010b7 100644
--- a/python/helpers/typeshed/stdlib/html/parser.pyi
+++ b/python/helpers/typeshed/stdlib/html/parser.pyi
@@ -1,9 +1,16 @@
+import sys
from _markupbase import ParserBase
from re import Pattern
+from typing import Final
__all__ = ["HTMLParser"]
class HTMLParser(ParserBase):
+ CDATA_CONTENT_ELEMENTS: Final[tuple[str, ...]]
+ if sys.version_info >= (3, 13):
+ # Added in 3.13.6
+ RCDATA_CONTENT_ELEMENTS: Final[tuple[str, ...]]
+
def __init__(self, *, convert_charrefs: bool = True) -> None: ...
def feed(self, data: str) -> None: ...
def close(self) -> None: ...
@@ -17,16 +24,19 @@ class HTMLParser(ParserBase):
def handle_comment(self, data: str) -> None: ...
def handle_decl(self, decl: str) -> None: ...
def handle_pi(self, data: str) -> None: ...
- CDATA_CONTENT_ELEMENTS: tuple[str, ...]
def check_for_whole_start_tag(self, i: int) -> int: ... # undocumented
def clear_cdata_mode(self) -> None: ... # undocumented
def goahead(self, end: bool) -> None: ... # undocumented
- def parse_bogus_comment(self, i: int, report: bool = ...) -> int: ... # undocumented
+ def parse_bogus_comment(self, i: int, report: bool = True) -> int: ... # undocumented
def parse_endtag(self, i: int) -> int: ... # undocumented
def parse_html_declaration(self, i: int) -> int: ... # undocumented
def parse_pi(self, i: int) -> int: ... # undocumented
def parse_starttag(self, i: int) -> int: ... # undocumented
- def set_cdata_mode(self, elem: str) -> None: ... # undocumented
+ if sys.version_info >= (3, 13):
+ # `escapable` parameter added in 3.13.6
+ def set_cdata_mode(self, elem: str, *, escapable: bool = False) -> None: ... # undocumented
+ else:
+ def set_cdata_mode(self, elem: str) -> None: ... # undocumented
rawdata: str # undocumented
cdata_elem: str | None # undocumented
convert_charrefs: bool # undocumented
diff --git a/python/helpers/typeshed/stdlib/http/client.pyi b/python/helpers/typeshed/stdlib/http/client.pyi
index 5c35dff28d43..d259e84e6f2a 100644
--- a/python/helpers/typeshed/stdlib/http/client.pyi
+++ b/python/helpers/typeshed/stdlib/http/client.pyi
@@ -7,7 +7,7 @@ from _typeshed import MaybeNone, ReadableBuffer, SupportsRead, SupportsReadline,
from collections.abc import Callable, Iterable, Iterator, Mapping
from email._policybase import _MessageT
from socket import socket
-from typing import BinaryIO, Literal, TypeVar, overload
+from typing import BinaryIO, Final, TypeVar, overload
from typing_extensions import Self, TypeAlias
__all__ = [
@@ -36,85 +36,85 @@ _DataType: TypeAlias = SupportsRead[bytes] | Iterable[ReadableBuffer] | Readable
_T = TypeVar("_T")
_HeaderValue: TypeAlias = ReadableBuffer | str | int
-HTTP_PORT: int
-HTTPS_PORT: int
+HTTP_PORT: Final = 80
+HTTPS_PORT: Final = 443
# Keep these global constants in sync with http.HTTPStatus (http/__init__.pyi).
# They are present for backward compatibility reasons.
-CONTINUE: Literal[100]
-SWITCHING_PROTOCOLS: Literal[101]
-PROCESSING: Literal[102]
-EARLY_HINTS: Literal[103]
+CONTINUE: Final = 100
+SWITCHING_PROTOCOLS: Final = 101
+PROCESSING: Final = 102
+EARLY_HINTS: Final = 103
-OK: Literal[200]
-CREATED: Literal[201]
-ACCEPTED: Literal[202]
-NON_AUTHORITATIVE_INFORMATION: Literal[203]
-NO_CONTENT: Literal[204]
-RESET_CONTENT: Literal[205]
-PARTIAL_CONTENT: Literal[206]
-MULTI_STATUS: Literal[207]
-ALREADY_REPORTED: Literal[208]
-IM_USED: Literal[226]
+OK: Final = 200
+CREATED: Final = 201
+ACCEPTED: Final = 202
+NON_AUTHORITATIVE_INFORMATION: Final = 203
+NO_CONTENT: Final = 204
+RESET_CONTENT: Final = 205
+PARTIAL_CONTENT: Final = 206
+MULTI_STATUS: Final = 207
+ALREADY_REPORTED: Final = 208
+IM_USED: Final = 226
-MULTIPLE_CHOICES: Literal[300]
-MOVED_PERMANENTLY: Literal[301]
-FOUND: Literal[302]
-SEE_OTHER: Literal[303]
-NOT_MODIFIED: Literal[304]
-USE_PROXY: Literal[305]
-TEMPORARY_REDIRECT: Literal[307]
-PERMANENT_REDIRECT: Literal[308]
+MULTIPLE_CHOICES: Final = 300
+MOVED_PERMANENTLY: Final = 301
+FOUND: Final = 302
+SEE_OTHER: Final = 303
+NOT_MODIFIED: Final = 304
+USE_PROXY: Final = 305
+TEMPORARY_REDIRECT: Final = 307
+PERMANENT_REDIRECT: Final = 308
-BAD_REQUEST: Literal[400]
-UNAUTHORIZED: Literal[401]
-PAYMENT_REQUIRED: Literal[402]
-FORBIDDEN: Literal[403]
-NOT_FOUND: Literal[404]
-METHOD_NOT_ALLOWED: Literal[405]
-NOT_ACCEPTABLE: Literal[406]
-PROXY_AUTHENTICATION_REQUIRED: Literal[407]
-REQUEST_TIMEOUT: Literal[408]
-CONFLICT: Literal[409]
-GONE: Literal[410]
-LENGTH_REQUIRED: Literal[411]
-PRECONDITION_FAILED: Literal[412]
+BAD_REQUEST: Final = 400
+UNAUTHORIZED: Final = 401
+PAYMENT_REQUIRED: Final = 402
+FORBIDDEN: Final = 403
+NOT_FOUND: Final = 404
+METHOD_NOT_ALLOWED: Final = 405
+NOT_ACCEPTABLE: Final = 406
+PROXY_AUTHENTICATION_REQUIRED: Final = 407
+REQUEST_TIMEOUT: Final = 408
+CONFLICT: Final = 409
+GONE: Final = 410
+LENGTH_REQUIRED: Final = 411
+PRECONDITION_FAILED: Final = 412
if sys.version_info >= (3, 13):
- CONTENT_TOO_LARGE: Literal[413]
-REQUEST_ENTITY_TOO_LARGE: Literal[413]
+ CONTENT_TOO_LARGE: Final = 413
+REQUEST_ENTITY_TOO_LARGE: Final = 413
if sys.version_info >= (3, 13):
- URI_TOO_LONG: Literal[414]
-REQUEST_URI_TOO_LONG: Literal[414]
-UNSUPPORTED_MEDIA_TYPE: Literal[415]
+ URI_TOO_LONG: Final = 414
+REQUEST_URI_TOO_LONG: Final = 414
+UNSUPPORTED_MEDIA_TYPE: Final = 415
if sys.version_info >= (3, 13):
- RANGE_NOT_SATISFIABLE: Literal[416]
-REQUESTED_RANGE_NOT_SATISFIABLE: Literal[416]
-EXPECTATION_FAILED: Literal[417]
-IM_A_TEAPOT: Literal[418]
-MISDIRECTED_REQUEST: Literal[421]
+ RANGE_NOT_SATISFIABLE: Final = 416
+REQUESTED_RANGE_NOT_SATISFIABLE: Final = 416
+EXPECTATION_FAILED: Final = 417
+IM_A_TEAPOT: Final = 418
+MISDIRECTED_REQUEST: Final = 421
if sys.version_info >= (3, 13):
- UNPROCESSABLE_CONTENT: Literal[422]
-UNPROCESSABLE_ENTITY: Literal[422]
-LOCKED: Literal[423]
-FAILED_DEPENDENCY: Literal[424]
-TOO_EARLY: Literal[425]
-UPGRADE_REQUIRED: Literal[426]
-PRECONDITION_REQUIRED: Literal[428]
-TOO_MANY_REQUESTS: Literal[429]
-REQUEST_HEADER_FIELDS_TOO_LARGE: Literal[431]
-UNAVAILABLE_FOR_LEGAL_REASONS: Literal[451]
+ UNPROCESSABLE_CONTENT: Final = 422
+UNPROCESSABLE_ENTITY: Final = 422
+LOCKED: Final = 423
+FAILED_DEPENDENCY: Final = 424
+TOO_EARLY: Final = 425
+UPGRADE_REQUIRED: Final = 426
+PRECONDITION_REQUIRED: Final = 428
+TOO_MANY_REQUESTS: Final = 429
+REQUEST_HEADER_FIELDS_TOO_LARGE: Final = 431
+UNAVAILABLE_FOR_LEGAL_REASONS: Final = 451
-INTERNAL_SERVER_ERROR: Literal[500]
-NOT_IMPLEMENTED: Literal[501]
-BAD_GATEWAY: Literal[502]
-SERVICE_UNAVAILABLE: Literal[503]
-GATEWAY_TIMEOUT: Literal[504]
-HTTP_VERSION_NOT_SUPPORTED: Literal[505]
-VARIANT_ALSO_NEGOTIATES: Literal[506]
-INSUFFICIENT_STORAGE: Literal[507]
-LOOP_DETECTED: Literal[508]
-NOT_EXTENDED: Literal[510]
-NETWORK_AUTHENTICATION_REQUIRED: Literal[511]
+INTERNAL_SERVER_ERROR: Final = 500
+NOT_IMPLEMENTED: Final = 501
+BAD_GATEWAY: Final = 502
+SERVICE_UNAVAILABLE: Final = 503
+GATEWAY_TIMEOUT: Final = 504
+HTTP_VERSION_NOT_SUPPORTED: Final = 505
+VARIANT_ALSO_NEGOTIATES: Final = 506
+INSUFFICIENT_STORAGE: Final = 507
+LOOP_DETECTED: Final = 508
+NOT_EXTENDED: Final = 510
+NETWORK_AUTHENTICATION_REQUIRED: Final = 511
responses: dict[int, str]
diff --git a/python/helpers/typeshed/stdlib/http/server.pyi b/python/helpers/typeshed/stdlib/http/server.pyi
index 429bb65bb0ef..2c1a374331bc 100644
--- a/python/helpers/typeshed/stdlib/http/server.pyi
+++ b/python/helpers/typeshed/stdlib/http/server.pyi
@@ -119,12 +119,24 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
def guess_type(self, path: StrPath) -> str: ... # undocumented
def executable(path: StrPath) -> bool: ... # undocumented
-@deprecated("Deprecated in Python 3.13; removal scheduled for Python 3.15")
-class CGIHTTPRequestHandler(SimpleHTTPRequestHandler):
- cgi_directories: list[str]
- have_fork: bool # undocumented
- def do_POST(self) -> None: ...
- def is_cgi(self) -> bool: ... # undocumented
- def is_executable(self, path: StrPath) -> bool: ... # undocumented
- def is_python(self, path: StrPath) -> bool: ... # undocumented
- def run_cgi(self) -> None: ... # undocumented
+
+if sys.version_info >= (3, 13):
+ @deprecated("Deprecated since Python 3.13; will be removed in Python 3.15.")
+ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler):
+ cgi_directories: list[str]
+ have_fork: bool # undocumented
+ def do_POST(self) -> None: ...
+ def is_cgi(self) -> bool: ... # undocumented
+ def is_executable(self, path: StrPath) -> bool: ... # undocumented
+ def is_python(self, path: StrPath) -> bool: ... # undocumented
+ def run_cgi(self) -> None: ... # undocumented
+
+else:
+ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler):
+ cgi_directories: list[str]
+ have_fork: bool # undocumented
+ def do_POST(self) -> None: ...
+ def is_cgi(self) -> bool: ... # undocumented
+ def is_executable(self, path: StrPath) -> bool: ... # undocumented
+ def is_python(self, path: StrPath) -> bool: ... # undocumented
+ def run_cgi(self) -> None: ... # undocumented
diff --git a/python/helpers/typeshed/stdlib/imghdr.pyi b/python/helpers/typeshed/stdlib/imghdr.pyi
index 6e1b858b8f32..e45ca3eb5bdb 100644
--- a/python/helpers/typeshed/stdlib/imghdr.pyi
+++ b/python/helpers/typeshed/stdlib/imghdr.pyi
@@ -1,9 +1,10 @@
from _typeshed import StrPath
from collections.abc import Callable
-from typing import Any, BinaryIO, Protocol, overload
+from typing import Any, BinaryIO, Protocol, overload, type_check_only
__all__ = ["what"]
+@type_check_only
class _ReadableBinary(Protocol):
def tell(self) -> int: ...
def read(self, size: int, /) -> bytes: ...
diff --git a/python/helpers/typeshed/stdlib/imp.pyi b/python/helpers/typeshed/stdlib/imp.pyi
index ee5a0cd7bc72..b5b4223aa58e 100644
--- a/python/helpers/typeshed/stdlib/imp.pyi
+++ b/python/helpers/typeshed/stdlib/imp.pyi
@@ -13,18 +13,18 @@ from _imp import (
from _typeshed import StrPath
from os import PathLike
from types import TracebackType
-from typing import IO, Any, Protocol
+from typing import IO, Any, Final, Protocol, type_check_only
-SEARCH_ERROR: int
-PY_SOURCE: int
-PY_COMPILED: int
-C_EXTENSION: int
-PY_RESOURCE: int
-PKG_DIRECTORY: int
-C_BUILTIN: int
-PY_FROZEN: int
-PY_CODERESOURCE: int
-IMP_HOOK: int
+SEARCH_ERROR: Final = 0
+PY_SOURCE: Final = 1
+PY_COMPILED: Final = 2
+C_EXTENSION: Final = 3
+PY_RESOURCE: Final = 4
+PKG_DIRECTORY: Final = 5
+C_BUILTIN: Final = 6
+PY_FROZEN: Final = 7
+PY_CODERESOURCE: Final = 8
+IMP_HOOK: Final = 9
def new_module(name: str) -> types.ModuleType: ...
def get_magic() -> bytes: ...
@@ -39,6 +39,7 @@ class NullImporter:
# Technically, a text file has to support a slightly different set of operations than a binary file,
# but we ignore that here.
+@type_check_only
class _FileLike(Protocol):
closed: bool
mode: str
diff --git a/python/helpers/typeshed/stdlib/importlib/__init__.pyi b/python/helpers/typeshed/stdlib/importlib/__init__.pyi
index cab81512e92f..d60f90adee19 100644
--- a/python/helpers/typeshed/stdlib/importlib/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/importlib/__init__.pyi
@@ -2,6 +2,7 @@ import sys
from importlib._bootstrap import __import__ as __import__
from importlib.abc import Loader
from types import ModuleType
+from typing_extensions import deprecated
__all__ = ["__import__", "import_module", "invalidate_caches", "reload"]
@@ -9,6 +10,7 @@ __all__ = ["__import__", "import_module", "invalidate_caches", "reload"]
def import_module(name: str, package: str | None = None) -> ModuleType: ...
if sys.version_info < (3, 12):
+ @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `importlib.util.find_spec()` instead.")
def find_loader(name: str, path: str | None = None) -> Loader | None: ...
def invalidate_caches() -> None: ...
diff --git a/python/helpers/typeshed/stdlib/importlib/_abc.pyi b/python/helpers/typeshed/stdlib/importlib/_abc.pyi
index 1a21b9a72cd8..90ab34021917 100644
--- a/python/helpers/typeshed/stdlib/importlib/_abc.pyi
+++ b/python/helpers/typeshed/stdlib/importlib/_abc.pyi
@@ -2,11 +2,16 @@ import sys
import types
from abc import ABCMeta
from importlib.machinery import ModuleSpec
+from typing_extensions import deprecated
if sys.version_info >= (3, 10):
class Loader(metaclass=ABCMeta):
def load_module(self, fullname: str) -> types.ModuleType: ...
if sys.version_info < (3, 12):
+ @deprecated(
+ "Deprecated since Python 3.4; removed in Python 3.12. "
+ "The module spec is now used by the import machinery to generate a module repr."
+ )
def module_repr(self, module: types.ModuleType) -> str: ...
def create_module(self, spec: ModuleSpec) -> types.ModuleType | None: ...
diff --git a/python/helpers/typeshed/stdlib/importlib/abc.pyi b/python/helpers/typeshed/stdlib/importlib/abc.pyi
index cf0fd0807b7b..72031e0e3bd2 100644
--- a/python/helpers/typeshed/stdlib/importlib/abc.pyi
+++ b/python/helpers/typeshed/stdlib/importlib/abc.pyi
@@ -37,9 +37,10 @@ else:
def exec_module(self, module: types.ModuleType) -> None: ...
if sys.version_info < (3, 12):
+ @deprecated("Deprecated since Python 3.3; removed in Python 3.12. Use `MetaPathFinder` or `PathEntryFinder` instead.")
class Finder(metaclass=ABCMeta): ...
-@deprecated("Deprecated as of Python 3.7: Use importlib.resources.abc.TraversableResources instead.")
+@deprecated("Deprecated since Python 3.7. Use `importlib.resources.abc.TraversableResources` instead.")
class ResourceLoader(Loader):
@abstractmethod
def get_data(self, path: str) -> bytes: ...
@@ -60,7 +61,7 @@ class ExecutionLoader(InspectLoader):
def get_filename(self, fullname: str) -> str: ...
class SourceLoader(_bootstrap_external.SourceLoader, ResourceLoader, ExecutionLoader, metaclass=ABCMeta): # type: ignore[misc] # incompatible definitions of source_to_code in the base classes
- @deprecated("Deprecated as of Python 3.3: Use importlib.resources.abc.SourceLoader.path_stats instead.")
+ @deprecated("Deprecated since Python 3.3. Use `importlib.resources.abc.SourceLoader.path_stats` instead.")
def path_mtime(self, path: str) -> float: ...
def set_data(self, path: str, data: bytes) -> None: ...
def get_source(self, fullname: str) -> str | None: ...
@@ -71,6 +72,7 @@ if sys.version_info >= (3, 10):
# Please keep in sync with _typeshed.importlib.MetaPathFinderProtocol
class MetaPathFinder(metaclass=ABCMeta):
if sys.version_info < (3, 12):
+ @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `MetaPathFinder.find_spec()` instead.")
def find_module(self, fullname: str, path: Sequence[str] | None) -> Loader | None: ...
def invalidate_caches(self) -> None: ...
@@ -81,7 +83,9 @@ if sys.version_info >= (3, 10):
class PathEntryFinder(metaclass=ABCMeta):
if sys.version_info < (3, 12):
+ @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `PathEntryFinder.find_spec()` instead.")
def find_module(self, fullname: str) -> Loader | None: ...
+ @deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.")
def find_loader(self, fullname: str) -> tuple[Loader | None, Sequence[str]]: ...
def invalidate_caches(self) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/importlib/metadata/__init__.pyi b/python/helpers/typeshed/stdlib/importlib/metadata/__init__.pyi
index 15d8b50b09d2..f9d3792565cb 100644
--- a/python/helpers/typeshed/stdlib/importlib/metadata/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/importlib/metadata/__init__.pyi
@@ -11,7 +11,7 @@ from os import PathLike
from pathlib import Path
from re import Pattern
from typing import Any, ClassVar, Generic, NamedTuple, TypeVar, overload
-from typing_extensions import Self, TypeAlias
+from typing_extensions import Self, TypeAlias, deprecated
_T = TypeVar("_T")
_KT = TypeVar("_KT")
@@ -89,14 +89,15 @@ class EntryPoint(_EntryPointBase):
) -> bool: ... # undocumented
def __hash__(self) -> int: ...
- def __eq__(self, other: object) -> bool: ...
if sys.version_info >= (3, 11):
+ def __eq__(self, other: object) -> bool: ...
def __lt__(self, other: object) -> bool: ...
if sys.version_info < (3, 12):
def __iter__(self) -> Iterator[Any]: ... # result of iter((str, Self)), really
if sys.version_info >= (3, 12):
class EntryPoints(tuple[EntryPoint, ...]):
+ __slots__ = ()
def __getitem__(self, name: str) -> EntryPoint: ... # type: ignore[override]
def select(
self,
@@ -140,12 +141,15 @@ if sys.version_info >= (3, 10) and sys.version_info < (3, 12):
@overload
def get(self, name: _KT, default: None = None) -> _VT | None: ...
@overload
+ def get(self, name: _KT, default: _VT) -> _VT: ...
+ @overload
def get(self, name: _KT, default: _T) -> _VT | _T: ...
def __iter__(self) -> Iterator[_KT]: ...
def __contains__(self, *args: object) -> bool: ...
def keys(self) -> dict_keys[_KT, _VT]: ...
def values(self) -> dict_values[_KT, _VT]: ...
+ @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `select` instead.")
class SelectableGroups(Deprecated[str, EntryPoints], dict[str, EntryPoints]): # use as dict is deprecated since 3.10
@classmethod
def load(cls, eps: Iterable[EntryPoint]) -> Self: ...
diff --git a/python/helpers/typeshed/stdlib/importlib/resources/abc.pyi b/python/helpers/typeshed/stdlib/importlib/resources/abc.pyi
index fe0fe64dba0d..80d92a608604 100644
--- a/python/helpers/typeshed/stdlib/importlib/resources/abc.pyi
+++ b/python/helpers/typeshed/stdlib/importlib/resources/abc.pyi
@@ -10,13 +10,8 @@ if sys.version_info >= (3, 11):
def open_resource(self, resource: str) -> IO[bytes]: ...
@abstractmethod
def resource_path(self, resource: str) -> str: ...
- if sys.version_info >= (3, 10):
- @abstractmethod
- def is_resource(self, path: str) -> bool: ...
- else:
- @abstractmethod
- def is_resource(self, name: str) -> bool: ...
-
+ @abstractmethod
+ def is_resource(self, path: str) -> bool: ...
@abstractmethod
def contents(self) -> Iterator[str]: ...
@@ -28,12 +23,8 @@ if sys.version_info >= (3, 11):
def is_file(self) -> bool: ...
@abstractmethod
def iterdir(self) -> Iterator[Traversable]: ...
- if sys.version_info >= (3, 11):
- @abstractmethod
- def joinpath(self, *descendants: str) -> Traversable: ...
- else:
- @abstractmethod
- def joinpath(self, child: str, /) -> Traversable: ...
+ @abstractmethod
+ def joinpath(self, *descendants: str) -> Traversable: ...
# The documentation and runtime protocol allows *args, **kwargs arguments,
# but this would mean that all implementers would have to support them,
@@ -47,12 +38,7 @@ if sys.version_info >= (3, 11):
@property
@abstractmethod
def name(self) -> str: ...
- if sys.version_info >= (3, 10):
- def __truediv__(self, child: str, /) -> Traversable: ...
- else:
- @abstractmethod
- def __truediv__(self, child: str, /) -> Traversable: ...
-
+ def __truediv__(self, child: str, /) -> Traversable: ...
@abstractmethod
def read_bytes(self) -> bytes: ...
@abstractmethod
diff --git a/python/helpers/typeshed/stdlib/importlib/util.pyi b/python/helpers/typeshed/stdlib/importlib/util.pyi
index 370a08623842..05c4d0d1edb3 100644
--- a/python/helpers/typeshed/stdlib/importlib/util.pyi
+++ b/python/helpers/typeshed/stdlib/importlib/util.pyi
@@ -12,13 +12,25 @@ from importlib._bootstrap_external import (
spec_from_file_location as spec_from_file_location,
)
from importlib.abc import Loader
-from typing_extensions import ParamSpec
+from typing_extensions import ParamSpec, deprecated
_P = ParamSpec("_P")
if sys.version_info < (3, 12):
+ @deprecated(
+ "Deprecated since Python 3.4; removed in Python 3.12. "
+ "`__name__`, `__package__` and `__loader__` are now set automatically."
+ )
def module_for_loader(fxn: Callable[_P, types.ModuleType]) -> Callable[_P, types.ModuleType]: ...
+ @deprecated(
+ "Deprecated since Python 3.4; removed in Python 3.12. "
+ "`__name__`, `__package__` and `__loader__` are now set automatically."
+ )
def set_loader(fxn: Callable[_P, types.ModuleType]) -> Callable[_P, types.ModuleType]: ...
+ @deprecated(
+ "Deprecated since Python 3.4; removed in Python 3.12. "
+ "`__name__`, `__package__` and `__loader__` are now set automatically."
+ )
def set_package(fxn: Callable[_P, types.ModuleType]) -> Callable[_P, types.ModuleType]: ...
def resolve_name(name: str, package: str | None) -> str: ...
diff --git a/python/helpers/typeshed/stdlib/inspect.pyi b/python/helpers/typeshed/stdlib/inspect.pyi
index e19c2a634aa0..1ff1c47caefa 100644
--- a/python/helpers/typeshed/stdlib/inspect.pyi
+++ b/python/helpers/typeshed/stdlib/inspect.pyi
@@ -25,8 +25,8 @@ from types import (
TracebackType,
WrapperDescriptorType,
)
-from typing import Any, ClassVar, Final, Literal, NamedTuple, Protocol, TypeVar, overload
-from typing_extensions import ParamSpec, Self, TypeAlias, TypeGuard, TypeIs
+from typing import Any, ClassVar, Final, Literal, NamedTuple, Protocol, TypeVar, overload, type_check_only
+from typing_extensions import ParamSpec, Self, TypeAlias, TypeGuard, TypeIs, deprecated
if sys.version_info >= (3, 14):
from annotationlib import Format
@@ -240,10 +240,11 @@ def isasyncgenfunction(obj: Callable[..., AsyncGenerator[Any, Any]]) -> bool: ..
def isasyncgenfunction(obj: Callable[_P, Any]) -> TypeGuard[Callable[_P, AsyncGeneratorType[Any, Any]]]: ...
@overload
def isasyncgenfunction(obj: object) -> TypeGuard[Callable[..., AsyncGeneratorType[Any, Any]]]: ...
-
+@type_check_only
class _SupportsSet(Protocol[_T_contra, _V_contra]):
def __set__(self, instance: _T_contra, value: _V_contra, /) -> None: ...
+@type_check_only
class _SupportsDelete(Protocol[_T_contra]):
def __delete__(self, instance: _T_contra, /) -> None: ...
@@ -335,6 +336,7 @@ class _void: ...
class _empty: ...
class Signature:
+ __slots__ = ("_return_annotation", "_parameters")
def __init__(
self, parameters: Sequence[Parameter] | None = None, *, return_annotation: Any = ..., __validate_parameters__: bool = True
) -> None: ...
@@ -415,6 +417,7 @@ if sys.version_info >= (3, 12):
def getasyncgenlocals(agen: AsyncGeneratorType[Any, Any]) -> dict[str, Any]: ...
class Parameter:
+ __slots__ = ("_name", "_kind", "_default", "_annotation")
def __init__(self, name: str, kind: _ParameterKind, *, default: Any = ..., annotation: Any = ...) -> None: ...
empty = _empty
@@ -446,6 +449,7 @@ class Parameter:
def __hash__(self) -> int: ...
class BoundArguments:
+ __slots__ = ("arguments", "_signature", "__weakref__")
arguments: OrderedDict[str, Any]
@property
def args(self) -> tuple[Any, ...]: ...
@@ -475,12 +479,14 @@ class Arguments(NamedTuple):
def getargs(co: CodeType) -> Arguments: ...
if sys.version_info < (3, 11):
+ @deprecated("Deprecated since Python 3.0; removed in Python 3.11.")
class ArgSpec(NamedTuple):
args: list[str]
varargs: str | None
keywords: str | None
defaults: tuple[Any, ...]
+ @deprecated("Deprecated since Python 3.0; removed in Python 3.11. Use `inspect.signature()` instead.")
def getargspec(func: object) -> ArgSpec: ...
class FullArgSpec(NamedTuple):
@@ -511,6 +517,9 @@ else:
def formatannotationrelativeto(object: object) -> Callable[[object], str]: ...
if sys.version_info < (3, 11):
+ @deprecated(
+ "Deprecated since Python 3.5; removed in Python 3.11. Use `inspect.signature()` and the `Signature` class instead."
+ )
def formatargspec(
args: list[str],
varargs: str | None = None,
diff --git a/python/helpers/typeshed/stdlib/ipaddress.pyi b/python/helpers/typeshed/stdlib/ipaddress.pyi
index 9df6bab7c167..d09804cb9342 100644
--- a/python/helpers/typeshed/stdlib/ipaddress.pyi
+++ b/python/helpers/typeshed/stdlib/ipaddress.pyi
@@ -22,6 +22,7 @@ def ip_interface(
) -> IPv4Interface | IPv6Interface: ...
class _IPAddressBase:
+ __slots__ = ()
@property
def compressed(self) -> str: ...
@property
@@ -33,6 +34,7 @@ class _IPAddressBase:
def version(self) -> int: ...
class _BaseAddress(_IPAddressBase):
+ __slots__ = ()
def __add__(self, other: int) -> Self: ...
def __hash__(self) -> int: ...
def __int__(self) -> int: ...
@@ -105,6 +107,7 @@ class _BaseNetwork(_IPAddressBase, Generic[_A]):
def hostmask(self) -> _A: ...
class _BaseV4:
+ __slots__ = ()
if sys.version_info >= (3, 14):
version: Final = 4
max_prefixlen: Final = 32
@@ -115,6 +118,7 @@ class _BaseV4:
def max_prefixlen(self) -> Literal[32]: ...
class IPv4Address(_BaseV4, _BaseAddress):
+ __slots__ = ("_ip", "__weakref__")
def __init__(self, address: object) -> None: ...
@property
def is_global(self) -> bool: ...
@@ -137,7 +141,7 @@ class IPv4Address(_BaseV4, _BaseAddress):
def ipv6_mapped(self) -> IPv6Address: ...
class IPv4Network(_BaseV4, _BaseNetwork[IPv4Address]):
- def __init__(self, address: object, strict: bool = ...) -> None: ...
+ def __init__(self, address: object, strict: bool = True) -> None: ...
class IPv4Interface(IPv4Address):
netmask: IPv4Address
@@ -156,6 +160,7 @@ class IPv4Interface(IPv4Address):
def with_prefixlen(self) -> str: ...
class _BaseV6:
+ __slots__ = ()
if sys.version_info >= (3, 14):
version: Final = 6
max_prefixlen: Final = 128
@@ -166,6 +171,7 @@ class _BaseV6:
def max_prefixlen(self) -> Literal[128]: ...
class IPv6Address(_BaseV6, _BaseAddress):
+ __slots__ = ("_ip", "_scope_id", "__weakref__")
def __init__(self, address: object) -> None: ...
@property
def is_global(self) -> bool: ...
@@ -197,7 +203,7 @@ class IPv6Address(_BaseV6, _BaseAddress):
def __eq__(self, other: object) -> bool: ...
class IPv6Network(_BaseV6, _BaseNetwork[IPv6Address]):
- def __init__(self, address: object, strict: bool = ...) -> None: ...
+ def __init__(self, address: object, strict: bool = True) -> None: ...
@property
def is_site_local(self) -> bool: ...
diff --git a/python/helpers/typeshed/stdlib/lib2to3/fixes/fix_tuple_params.pyi b/python/helpers/typeshed/stdlib/lib2to3/fixes/fix_tuple_params.pyi
index bfaa9970c996..7f4f7f4e8656 100644
--- a/python/helpers/typeshed/stdlib/lib2to3/fixes/fix_tuple_params.pyi
+++ b/python/helpers/typeshed/stdlib/lib2to3/fixes/fix_tuple_params.pyi
@@ -1,4 +1,3 @@
-from _typeshed import Incomplete
from typing import ClassVar, Literal
from .. import fixer_base
@@ -13,5 +12,5 @@ class FixTupleParams(fixer_base.BaseFix):
def simplify_args(node): ...
def find_params(node): ...
-def map_to_index(param_list, prefix=..., d: Incomplete | None = ...): ...
+def map_to_index(param_list, prefix=[], d=None): ...
def tuple_name(param_list): ...
diff --git a/python/helpers/typeshed/stdlib/locale.pyi b/python/helpers/typeshed/stdlib/locale.pyi
index 58de65449572..fae9f849b637 100644
--- a/python/helpers/typeshed/stdlib/locale.pyi
+++ b/python/helpers/typeshed/stdlib/locale.pyi
@@ -18,6 +18,7 @@ from builtins import str as _str
from collections.abc import Callable, Iterable
from decimal import Decimal
from typing import Any
+from typing_extensions import deprecated
if sys.version_info >= (3, 11):
from _locale import getencoding as getencoding
@@ -137,9 +138,14 @@ def getpreferredencoding(do_setlocale: bool = True) -> _str: ...
def normalize(localename: _str) -> _str: ...
if sys.version_info < (3, 13):
- def resetlocale(category: int = ...) -> None: ...
+ if sys.version_info >= (3, 11):
+ @deprecated("Deprecated since Python 3.11; removed in Python 3.13. Use `locale.setlocale(locale.LC_ALL, '')` instead.")
+ def resetlocale(category: int = ...) -> None: ...
+ else:
+ def resetlocale(category: int = ...) -> None: ...
if sys.version_info < (3, 12):
+ @deprecated("Deprecated since Python 3.7; removed in Python 3.12. Use `locale.format_string()` instead.")
def format(
percent: _str, value: float | Decimal, grouping: bool = False, monetary: bool = False, *additional: Any
) -> _str: ...
diff --git a/python/helpers/typeshed/stdlib/logging/__init__.pyi b/python/helpers/typeshed/stdlib/logging/__init__.pyi
index 24529bd48d6a..8248f82ea87a 100644
--- a/python/helpers/typeshed/stdlib/logging/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/logging/__init__.pyi
@@ -7,7 +7,7 @@ from re import Pattern
from string import Template
from time import struct_time
from types import FrameType, GenericAlias, TracebackType
-from typing import Any, ClassVar, Final, Generic, Literal, Protocol, TextIO, TypeVar, overload
+from typing import Any, ClassVar, Final, Generic, Literal, Protocol, TextIO, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias, deprecated
__all__ = [
@@ -67,11 +67,13 @@ _Level: TypeAlias = int | str
_FormatStyle: TypeAlias = Literal["%", "{", "$"]
if sys.version_info >= (3, 12):
+ @type_check_only
class _SupportsFilter(Protocol):
def filter(self, record: LogRecord, /) -> bool | LogRecord: ...
_FilterType: TypeAlias = Filter | Callable[[LogRecord], bool | LogRecord] | _SupportsFilter
else:
+ @type_check_only
class _SupportsFilter(Protocol):
def filter(self, record: LogRecord, /) -> bool: ...
@@ -153,7 +155,7 @@ class Logger(Filterer):
stacklevel: int = 1,
extra: Mapping[str, object] | None = None,
) -> None: ...
- @deprecated("Deprecated; use warning() instead.")
+ @deprecated("Deprecated since Python 3.3. Use `Logger.warning()` instead.")
def warn(
self,
msg: object,
@@ -407,7 +409,7 @@ class LoggerAdapter(Generic[_L]):
extra: Mapping[str, object] | None = None,
**kwargs: object,
) -> None: ...
- @deprecated("Deprecated; use warning() instead.")
+ @deprecated("Deprecated since Python 3.3. Use `LoggerAdapter.warning()` instead.")
def warn(
self,
msg: object,
@@ -517,7 +519,7 @@ def warning(
stacklevel: int = 1,
extra: Mapping[str, object] | None = None,
) -> None: ...
-@deprecated("Deprecated; use warning() instead.")
+@deprecated("Deprecated since Python 3.3. Use `warning()` instead.")
def warn(
msg: object,
*args: object,
@@ -657,4 +659,4 @@ class StringTemplateStyle(PercentStyle): # undocumented
_STYLES: Final[dict[str, tuple[PercentStyle, str]]]
-BASIC_FORMAT: Final[str]
+BASIC_FORMAT: Final = "%(levelname)s:%(name)s:%(message)s"
diff --git a/python/helpers/typeshed/stdlib/logging/config.pyi b/python/helpers/typeshed/stdlib/logging/config.pyi
index 000ba1ebb06e..40ee87486144 100644
--- a/python/helpers/typeshed/stdlib/logging/config.pyi
+++ b/python/helpers/typeshed/stdlib/logging/config.pyi
@@ -9,7 +9,7 @@ from typing_extensions import Required, TypeAlias
from . import Filter, Filterer, Formatter, Handler, Logger, _FilterType, _FormatStyle, _Level
-DEFAULT_LOGGING_CONFIG_PORT: int
+DEFAULT_LOGGING_CONFIG_PORT: Final = 9030
RESET_ERROR: Final[int] # undocumented
IDENTIFIER: Final[Pattern[str]] # undocumented
@@ -106,7 +106,7 @@ class ConvertingTuple(tuple[Any, ...], ConvertingMixin): # undocumented
@overload
def __getitem__(self, key: slice) -> Any: ...
-class BaseConfigurator: # undocumented
+class BaseConfigurator:
CONVERT_PATTERN: Pattern[str]
WORD_PATTERN: Pattern[str]
DOT_PATTERN: Pattern[str]
@@ -115,6 +115,8 @@ class BaseConfigurator: # undocumented
value_converters: dict[str, str]
importer: Callable[..., Any]
+ config: dict[str, Any] # undocumented
+
def __init__(self, config: _DictConfigArgs | dict[str, Any]) -> None: ...
def resolve(self, s: str) -> Any: ...
def ext_convert(self, value: str) -> Any: ...
diff --git a/python/helpers/typeshed/stdlib/logging/handlers.pyi b/python/helpers/typeshed/stdlib/logging/handlers.pyi
index 9636b81dc4f3..535f1c685183 100644
--- a/python/helpers/typeshed/stdlib/logging/handlers.pyi
+++ b/python/helpers/typeshed/stdlib/logging/handlers.pyi
@@ -9,17 +9,17 @@ from re import Pattern
from socket import SocketKind, socket
from threading import Thread
from types import TracebackType
-from typing import Any, ClassVar, Final, Protocol, TypeVar
+from typing import Any, ClassVar, Final, Protocol, TypeVar, type_check_only
from typing_extensions import Self
_T = TypeVar("_T")
-DEFAULT_TCP_LOGGING_PORT: Final[int]
-DEFAULT_UDP_LOGGING_PORT: Final[int]
-DEFAULT_HTTP_LOGGING_PORT: Final[int]
-DEFAULT_SOAP_LOGGING_PORT: Final[int]
-SYSLOG_UDP_PORT: Final[int]
-SYSLOG_TCP_PORT: Final[int]
+DEFAULT_TCP_LOGGING_PORT: Final = 9020
+DEFAULT_UDP_LOGGING_PORT: Final = 9021
+DEFAULT_HTTP_LOGGING_PORT: Final = 9022
+DEFAULT_SOAP_LOGGING_PORT: Final = 9023
+SYSLOG_UDP_PORT: Final = 514
+SYSLOG_TCP_PORT: Final = 514
class WatchedFileHandler(FileHandler):
dev: int # undocumented
@@ -225,6 +225,7 @@ class HTTPHandler(Handler):
def mapLogRecord(self, record: LogRecord) -> dict[str, Any]: ...
def getConnection(self, host: str, secure: bool) -> http.client.HTTPConnection: ... # undocumented
+@type_check_only
class _QueueLike(Protocol[_T]):
def get(self) -> _T: ...
def put_nowait(self, item: _T, /) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/mailbox.pyi b/python/helpers/typeshed/stdlib/mailbox.pyi
index ff605c0661fb..89bd998b4dfe 100644
--- a/python/helpers/typeshed/stdlib/mailbox.pyi
+++ b/python/helpers/typeshed/stdlib/mailbox.pyi
@@ -6,7 +6,7 @@ from abc import ABCMeta, abstractmethod
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from email._policybase import _MessageT
from types import GenericAlias, TracebackType
-from typing import IO, Any, AnyStr, Generic, Literal, Protocol, TypeVar, overload
+from typing import IO, Any, AnyStr, Generic, Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias
__all__ = [
@@ -31,13 +31,16 @@ __all__ = [
_T = TypeVar("_T")
+@type_check_only
class _SupportsReadAndReadline(SupportsRead[bytes], SupportsNoArgReadline[bytes], Protocol): ...
_MessageData: TypeAlias = email.message.Message | bytes | str | io.StringIO | _SupportsReadAndReadline
+@type_check_only
class _HasIteritems(Protocol):
def iteritems(self) -> Iterator[tuple[str, _MessageData]]: ...
+@type_check_only
class _HasItems(Protocol):
def items(self) -> Iterator[tuple[str, _MessageData]]: ...
diff --git a/python/helpers/typeshed/stdlib/math.pyi b/python/helpers/typeshed/stdlib/math.pyi
index 9e77f0cd7e06..1903d488f7bb 100644
--- a/python/helpers/typeshed/stdlib/math.pyi
+++ b/python/helpers/typeshed/stdlib/math.pyi
@@ -1,7 +1,7 @@
import sys
from _typeshed import SupportsMul, SupportsRMul
from collections.abc import Iterable
-from typing import Any, Final, Literal, Protocol, SupportsFloat, SupportsIndex, TypeVar, overload
+from typing import Any, Final, Literal, Protocol, SupportsFloat, SupportsIndex, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
_T = TypeVar("_T")
@@ -26,6 +26,7 @@ def atanh(x: _SupportsFloatOrIndex, /) -> float: ...
if sys.version_info >= (3, 11):
def cbrt(x: _SupportsFloatOrIndex, /) -> float: ...
+@type_check_only
class _SupportsCeil(Protocol[_T_co]):
def __ceil__(self) -> _T_co: ...
@@ -49,7 +50,7 @@ if sys.version_info >= (3, 11):
def expm1(x: _SupportsFloatOrIndex, /) -> float: ...
def fabs(x: _SupportsFloatOrIndex, /) -> float: ...
def factorial(x: SupportsIndex, /) -> int: ...
-
+@type_check_only
class _SupportsFloor(Protocol[_T_co]):
def __floor__(self) -> _T_co: ...
@@ -99,6 +100,7 @@ _LiteralInteger = _PositiveInteger | _NegativeInteger | Literal[0] # noqa: Y026
_MultiplicableT1 = TypeVar("_MultiplicableT1", bound=SupportsMul[Any, Any])
_MultiplicableT2 = TypeVar("_MultiplicableT2", bound=SupportsMul[Any, Any])
+@type_check_only
class _SupportsProdWithNoDefaultGiven(SupportsMul[Any, Any], SupportsRMul[int, Any], Protocol): ...
_SupportsProdNoDefaultT = TypeVar("_SupportsProdNoDefaultT", bound=_SupportsProdWithNoDefaultGiven)
@@ -127,6 +129,7 @@ def tan(x: _SupportsFloatOrIndex, /) -> float: ...
def tanh(x: _SupportsFloatOrIndex, /) -> float: ...
# Is different from `_typeshed.SupportsTrunc`, which is not generic
+@type_check_only
class _SupportsTrunc(Protocol[_T_co]):
def __trunc__(self) -> _T_co: ...
diff --git a/python/helpers/typeshed/stdlib/mmap.pyi b/python/helpers/typeshed/stdlib/mmap.pyi
index c9b8358cde6c..261a2bfdfc44 100644
--- a/python/helpers/typeshed/stdlib/mmap.pyi
+++ b/python/helpers/typeshed/stdlib/mmap.pyi
@@ -1,38 +1,39 @@
+import os
import sys
from _typeshed import ReadableBuffer, Unused
from collections.abc import Iterator
from typing import Final, Literal, NoReturn, overload
from typing_extensions import Self
-ACCESS_DEFAULT: int
-ACCESS_READ: int
-ACCESS_WRITE: int
-ACCESS_COPY: int
+ACCESS_DEFAULT: Final = 0
+ACCESS_READ: Final = 1
+ACCESS_WRITE: Final = 2
+ACCESS_COPY: Final = 3
-ALLOCATIONGRANULARITY: int
+ALLOCATIONGRANULARITY: Final[int]
if sys.platform == "linux":
- MAP_DENYWRITE: int
- MAP_EXECUTABLE: int
+ MAP_DENYWRITE: Final[int]
+ MAP_EXECUTABLE: Final[int]
if sys.version_info >= (3, 10):
- MAP_POPULATE: int
+ MAP_POPULATE: Final[int]
if sys.version_info >= (3, 11) and sys.platform != "win32" and sys.platform != "darwin":
- MAP_STACK: int
+ MAP_STACK: Final[int]
if sys.platform != "win32":
- MAP_ANON: int
- MAP_ANONYMOUS: int
- MAP_PRIVATE: int
- MAP_SHARED: int
- PROT_EXEC: int
- PROT_READ: int
- PROT_WRITE: int
+ MAP_ANON: Final[int]
+ MAP_ANONYMOUS: Final[int]
+ MAP_PRIVATE: Final[int]
+ MAP_SHARED: Final[int]
+ PROT_EXEC: Final[int]
+ PROT_READ: Final[int]
+ PROT_WRITE: Final[int]
-PAGESIZE: int
+PAGESIZE: Final[int]
class mmap:
if sys.platform == "win32":
- def __init__(self, fileno: int, length: int, tagname: str | None = ..., access: int = ..., offset: int = ...) -> None: ...
+ def __init__(self, fileno: int, length: int, tagname: str | None = None, access: int = 0, offset: int = 0) -> None: ...
else:
if sys.version_info >= (3, 13):
def __new__(
@@ -41,34 +42,38 @@ class mmap:
length: int,
flags: int = ...,
prot: int = ...,
- access: int = ...,
- offset: int = ...,
+ access: int = 0,
+ offset: int = 0,
*,
trackfd: bool = True,
) -> Self: ...
else:
def __new__(
- cls, fileno: int, length: int, flags: int = ..., prot: int = ..., access: int = ..., offset: int = ...
+ cls, fileno: int, length: int, flags: int = ..., prot: int = ..., access: int = 0, offset: int = 0
) -> Self: ...
def close(self) -> None: ...
- def flush(self, offset: int = ..., size: int = ...) -> None: ...
+ def flush(self, offset: int = 0, size: int = ...) -> None: ...
def move(self, dest: int, src: int, count: int) -> None: ...
def read_byte(self) -> int: ...
def readline(self) -> bytes: ...
def resize(self, newsize: int) -> None: ...
- def seek(self, pos: int, whence: int = ...) -> None: ...
+ if sys.platform != "win32":
+ def seek(self, pos: int, whence: Literal[0, 1, 2, 3, 4] = os.SEEK_SET) -> None: ...
+ else:
+ def seek(self, pos: int, whence: Literal[0, 1, 2] = os.SEEK_SET) -> None: ...
+
def size(self) -> int: ...
def tell(self) -> int: ...
def write_byte(self, byte: int) -> None: ...
def __len__(self) -> int: ...
closed: bool
if sys.platform != "win32":
- def madvise(self, option: int, start: int = ..., length: int = ...) -> None: ...
+ def madvise(self, option: int, start: int = 0, length: int = ...) -> None: ...
def find(self, sub: ReadableBuffer, start: int = ..., stop: int = ...) -> int: ...
def rfind(self, sub: ReadableBuffer, start: int = ..., stop: int = ...) -> int: ...
- def read(self, n: int | None = ...) -> bytes: ...
+ def read(self, n: int | None = None) -> bytes: ...
def write(self, bytes: ReadableBuffer) -> int: ...
@overload
def __getitem__(self, key: int, /) -> int: ...
@@ -93,42 +98,42 @@ class mmap:
def seekable(self) -> Literal[True]: ...
if sys.platform != "win32":
- MADV_NORMAL: int
- MADV_RANDOM: int
- MADV_SEQUENTIAL: int
- MADV_WILLNEED: int
- MADV_DONTNEED: int
- MADV_FREE: int
+ MADV_NORMAL: Final[int]
+ MADV_RANDOM: Final[int]
+ MADV_SEQUENTIAL: Final[int]
+ MADV_WILLNEED: Final[int]
+ MADV_DONTNEED: Final[int]
+ MADV_FREE: Final[int]
if sys.platform == "linux":
- MADV_REMOVE: int
- MADV_DONTFORK: int
- MADV_DOFORK: int
- MADV_HWPOISON: int
- MADV_MERGEABLE: int
- MADV_UNMERGEABLE: int
+ MADV_REMOVE: Final[int]
+ MADV_DONTFORK: Final[int]
+ MADV_DOFORK: Final[int]
+ MADV_HWPOISON: Final[int]
+ MADV_MERGEABLE: Final[int]
+ MADV_UNMERGEABLE: Final[int]
# Seems like this constant is not defined in glibc.
# See https://github.com/python/typeshed/pull/5360 for details
- # MADV_SOFT_OFFLINE: int
- MADV_HUGEPAGE: int
- MADV_NOHUGEPAGE: int
- MADV_DONTDUMP: int
- MADV_DODUMP: int
+ # MADV_SOFT_OFFLINE: Final[int]
+ MADV_HUGEPAGE: Final[int]
+ MADV_NOHUGEPAGE: Final[int]
+ MADV_DONTDUMP: Final[int]
+ MADV_DODUMP: Final[int]
# This Values are defined for FreeBSD but type checkers do not support conditions for these
if sys.platform != "linux" and sys.platform != "darwin" and sys.platform != "win32":
- MADV_NOSYNC: int
- MADV_AUTOSYNC: int
- MADV_NOCORE: int
- MADV_CORE: int
- MADV_PROTECT: int
+ MADV_NOSYNC: Final[int]
+ MADV_AUTOSYNC: Final[int]
+ MADV_NOCORE: Final[int]
+ MADV_CORE: Final[int]
+ MADV_PROTECT: Final[int]
if sys.version_info >= (3, 10) and sys.platform == "darwin":
- MADV_FREE_REUSABLE: int
- MADV_FREE_REUSE: int
+ MADV_FREE_REUSABLE: Final[int]
+ MADV_FREE_REUSE: Final[int]
if sys.version_info >= (3, 13) and sys.platform != "win32":
- MAP_32BIT: Final = 32768
+ MAP_32BIT: Final[int]
if sys.version_info >= (3, 13) and sys.platform == "darwin":
MAP_NORESERVE: Final = 64
diff --git a/python/helpers/typeshed/stdlib/msilib/__init__.pyi b/python/helpers/typeshed/stdlib/msilib/__init__.pyi
index 3e43cbc44f52..622f585f5bee 100644
--- a/python/helpers/typeshed/stdlib/msilib/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/msilib/__init__.pyi
@@ -1,26 +1,26 @@
import sys
from collections.abc import Container, Iterable, Sequence
from types import ModuleType
-from typing import Any, Literal
+from typing import Any, Final
if sys.platform == "win32":
from _msi import *
from _msi import _Database
- AMD64: bool
- Win64: bool
+ AMD64: Final[bool]
+ Win64: Final[bool]
- datasizemask: Literal[0x00FF]
- type_valid: Literal[0x0100]
- type_localizable: Literal[0x0200]
- typemask: Literal[0x0C00]
- type_long: Literal[0x0000]
- type_short: Literal[0x0400]
- type_string: Literal[0x0C00]
- type_binary: Literal[0x0800]
- type_nullable: Literal[0x1000]
- type_key: Literal[0x2000]
- knownbits: Literal[0x3FFF]
+ datasizemask: Final = 0x00FF
+ type_valid: Final = 0x0100
+ type_localizable: Final = 0x0200
+ typemask: Final = 0x0C00
+ type_long: Final = 0x0000
+ type_short: Final = 0x0400
+ type_string: Final = 0x0C00
+ type_binary: Final = 0x0800
+ type_nullable: Final = 0x1000
+ type_key: Final = 0x2000
+ knownbits: Final = 0x3FFF
class Table:
name: str
diff --git a/python/helpers/typeshed/stdlib/msilib/schema.pyi b/python/helpers/typeshed/stdlib/msilib/schema.pyi
index 4ad9a1783fcd..3bbdc41a1e8e 100644
--- a/python/helpers/typeshed/stdlib/msilib/schema.pyi
+++ b/python/helpers/typeshed/stdlib/msilib/schema.pyi
@@ -1,4 +1,5 @@
import sys
+from typing import Final
if sys.platform == "win32":
from . import Table
@@ -89,6 +90,6 @@ if sys.platform == "win32":
Upgrade: Table
Verb: Table
- tables: list[Table]
+ tables: Final[list[Table]]
_Validation_records: list[tuple[str, str, str, int | None, int | None, str | None, int | None, str | None, str | None, str]]
diff --git a/python/helpers/typeshed/stdlib/msilib/sequence.pyi b/python/helpers/typeshed/stdlib/msilib/sequence.pyi
index b8af09f46e65..a9f5c24717bd 100644
--- a/python/helpers/typeshed/stdlib/msilib/sequence.pyi
+++ b/python/helpers/typeshed/stdlib/msilib/sequence.pyi
@@ -1,13 +1,14 @@
import sys
+from typing import Final
from typing_extensions import TypeAlias
if sys.platform == "win32":
_SequenceType: TypeAlias = list[tuple[str, str | None, int]]
- AdminExecuteSequence: _SequenceType
- AdminUISequence: _SequenceType
- AdvtExecuteSequence: _SequenceType
- InstallExecuteSequence: _SequenceType
- InstallUISequence: _SequenceType
+ AdminExecuteSequence: Final[_SequenceType]
+ AdminUISequence: Final[_SequenceType]
+ AdvtExecuteSequence: Final[_SequenceType]
+ InstallExecuteSequence: Final[_SequenceType]
+ InstallUISequence: Final[_SequenceType]
- tables: list[str]
+ tables: Final[list[str]]
diff --git a/python/helpers/typeshed/stdlib/msilib/text.pyi b/python/helpers/typeshed/stdlib/msilib/text.pyi
index 441c843ca6cf..da3c5fd0fb7a 100644
--- a/python/helpers/typeshed/stdlib/msilib/text.pyi
+++ b/python/helpers/typeshed/stdlib/msilib/text.pyi
@@ -1,7 +1,8 @@
import sys
+from typing import Final
if sys.platform == "win32":
- ActionText: list[tuple[str, str, str | None]]
- UIText: list[tuple[str, str | None]]
+ ActionText: Final[list[tuple[str, str, str | None]]]
+ UIText: Final[list[tuple[str, str | None]]]
dirname: str
- tables: list[str]
+ tables: Final[list[str]]
diff --git a/python/helpers/typeshed/stdlib/msvcrt.pyi b/python/helpers/typeshed/stdlib/msvcrt.pyi
index 403a5d933522..5feca8eab5c1 100644
--- a/python/helpers/typeshed/stdlib/msvcrt.pyi
+++ b/python/helpers/typeshed/stdlib/msvcrt.pyi
@@ -9,10 +9,10 @@ if sys.platform == "win32":
LK_NBLCK: Final = 2
LK_RLCK: Final = 3
LK_NBRLCK: Final = 4
- SEM_FAILCRITICALERRORS: int
- SEM_NOALIGNMENTFAULTEXCEPT: int
- SEM_NOGPFAULTERRORBOX: int
- SEM_NOOPENFILEERRORBOX: int
+ SEM_FAILCRITICALERRORS: Final = 0x0001
+ SEM_NOALIGNMENTFAULTEXCEPT: Final = 0x0004
+ SEM_NOGPFAULTERRORBOX: Final = 0x0002
+ SEM_NOOPENFILEERRORBOX: Final = 0x8000
def locking(fd: int, mode: int, nbytes: int, /) -> None: ...
def setmode(fd: int, mode: int, /) -> int: ...
def open_osfhandle(handle: int, flags: int, /) -> int: ...
diff --git a/python/helpers/typeshed/stdlib/multiprocessing/heap.pyi b/python/helpers/typeshed/stdlib/multiprocessing/heap.pyi
index b5e2ced5e8ee..38191a099f1e 100644
--- a/python/helpers/typeshed/stdlib/multiprocessing/heap.pyi
+++ b/python/helpers/typeshed/stdlib/multiprocessing/heap.pyi
@@ -2,7 +2,7 @@ import sys
from _typeshed import Incomplete
from collections.abc import Callable
from mmap import mmap
-from typing import Protocol
+from typing import Protocol, type_check_only
from typing_extensions import TypeAlias
__all__ = ["BufferWrapper"]
@@ -20,6 +20,7 @@ class Arena:
_Block: TypeAlias = tuple[Arena, int, int]
if sys.platform != "win32":
+ @type_check_only
class _SupportsDetach(Protocol):
def detach(self) -> int: ...
diff --git a/python/helpers/typeshed/stdlib/multiprocessing/managers.pyi b/python/helpers/typeshed/stdlib/multiprocessing/managers.pyi
index b0ccac41b925..5efe69a97377 100644
--- a/python/helpers/typeshed/stdlib/multiprocessing/managers.pyi
+++ b/python/helpers/typeshed/stdlib/multiprocessing/managers.pyi
@@ -38,6 +38,7 @@ class Namespace:
_Namespace: TypeAlias = Namespace
class Token:
+ __slots__ = ("typeid", "address", "id")
typeid: str | bytes | None
address: _Address | None
id: str | bytes | int | None
diff --git a/python/helpers/typeshed/stdlib/multiprocessing/sharedctypes.pyi b/python/helpers/typeshed/stdlib/multiprocessing/sharedctypes.pyi
index 5283445d8545..e2ec15f05ea2 100644
--- a/python/helpers/typeshed/stdlib/multiprocessing/sharedctypes.pyi
+++ b/python/helpers/typeshed/stdlib/multiprocessing/sharedctypes.pyi
@@ -5,7 +5,7 @@ from ctypes import _SimpleCData, c_char
from multiprocessing.context import BaseContext
from multiprocessing.synchronize import _LockLike
from types import TracebackType
-from typing import Any, Generic, Literal, Protocol, TypeVar, overload
+from typing import Any, Generic, Literal, Protocol, TypeVar, overload, type_check_only
__all__ = ["RawValue", "RawArray", "Value", "Array", "copy", "synchronized"]
@@ -81,7 +81,7 @@ def synchronized(
) -> SynchronizedArray[_T]: ...
@overload
def synchronized(obj: _CT, lock: _LockLike | None = None, ctx: Any | None = None) -> SynchronizedBase[_CT]: ...
-
+@type_check_only
class _AcquireFunc(Protocol):
def __call__(self, block: bool = ..., timeout: float | None = ..., /) -> bool: ...
diff --git a/python/helpers/typeshed/stdlib/multiprocessing/util.pyi b/python/helpers/typeshed/stdlib/multiprocessing/util.pyi
index ecb4a7ddec7d..3583194c77e2 100644
--- a/python/helpers/typeshed/stdlib/multiprocessing/util.pyi
+++ b/python/helpers/typeshed/stdlib/multiprocessing/util.pyi
@@ -52,7 +52,7 @@ def get_logger() -> Logger: ...
def log_to_stderr(level: _LoggingLevel | None = None) -> Logger: ...
def is_abstract_socket_namespace(address: str | bytes | None) -> bool: ...
-abstract_sockets_supported: bool
+abstract_sockets_supported: Final[bool]
def get_temp_dir() -> str: ...
def register_after_fork(obj: _T, func: Callable[[_T], object]) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/nt.pyi b/python/helpers/typeshed/stdlib/nt.pyi
index 3ed8f8af379b..0c87444d18f4 100644
--- a/python/helpers/typeshed/stdlib/nt.pyi
+++ b/python/helpers/typeshed/stdlib/nt.pyi
@@ -110,4 +110,7 @@ if sys.platform == "win32":
if sys.version_info >= (3, 13):
from os import fchmod as fchmod, lchmod as lchmod
+ if sys.version_info >= (3, 14):
+ from os import readinto as readinto
+
environ: dict[str, str]
diff --git a/python/helpers/typeshed/stdlib/nturl2path.pyi b/python/helpers/typeshed/stdlib/nturl2path.pyi
index c38a359469d2..014af8a0fd2e 100644
--- a/python/helpers/typeshed/stdlib/nturl2path.pyi
+++ b/python/helpers/typeshed/stdlib/nturl2path.pyi
@@ -2,9 +2,9 @@ import sys
from typing_extensions import deprecated
if sys.version_info >= (3, 14):
- @deprecated("nturl2path module was deprecated since Python 3.14")
+ @deprecated("The `nturl2path` module is deprecated since Python 3.14.")
def url2pathname(url: str) -> str: ...
- @deprecated("nturl2path module was deprecated since Python 3.14")
+ @deprecated("The `nturl2path` module is deprecated since Python 3.14.")
def pathname2url(p: str) -> str: ...
else:
diff --git a/python/helpers/typeshed/stdlib/numbers.pyi b/python/helpers/typeshed/stdlib/numbers.pyi
index 02d469ce0ee5..64fb16581e95 100644
--- a/python/helpers/typeshed/stdlib/numbers.pyi
+++ b/python/helpers/typeshed/stdlib/numbers.pyi
@@ -8,7 +8,7 @@
# nor `float` as a subtype of `numbers.Real`, etc.)
from abc import ABCMeta, abstractmethod
-from typing import ClassVar, Literal, Protocol, overload
+from typing import ClassVar, Literal, Protocol, overload, type_check_only
__all__ = ["Number", "Complex", "Real", "Rational", "Integral"]
@@ -22,6 +22,7 @@ __all__ = ["Number", "Complex", "Real", "Rational", "Integral"]
# NOTE: We can't include `__complex__` here,
# as we want `int` to be seen as a subtype of `_ComplexLike`,
# and `int.__complex__` does not exist :(
+@type_check_only
class _ComplexLike(Protocol):
def __neg__(self) -> _ComplexLike: ...
def __pos__(self) -> _ComplexLike: ...
@@ -29,6 +30,7 @@ class _ComplexLike(Protocol):
# _RealLike is a structural-typing approximation
# of the `Real` ABC, which is not (and cannot be) a protocol
+@type_check_only
class _RealLike(_ComplexLike, Protocol):
def __trunc__(self) -> _IntegralLike: ...
def __floor__(self) -> _IntegralLike: ...
@@ -41,6 +43,7 @@ class _RealLike(_ComplexLike, Protocol):
# _IntegralLike is a structural-typing approximation
# of the `Integral` ABC, which is not (and cannot be) a protocol
+@type_check_only
class _IntegralLike(_RealLike, Protocol):
def __invert__(self) -> _IntegralLike: ...
def __int__(self) -> int: ...
@@ -58,12 +61,14 @@ class _IntegralLike(_RealLike, Protocol):
#################
class Number(metaclass=ABCMeta):
+ __slots__ = ()
@abstractmethod
def __hash__(self) -> int: ...
# See comment at the top of the file
# for why some of these return types are purposefully vague
class Complex(Number, _ComplexLike):
+ __slots__ = ()
@abstractmethod
def __complex__(self) -> complex: ...
def __bool__(self) -> bool: ...
@@ -106,6 +111,7 @@ class Complex(Number, _ComplexLike):
# See comment at the top of the file
# for why some of these return types are purposefully vague
class Real(Complex, _RealLike):
+ __slots__ = ()
@abstractmethod
def __float__(self) -> float: ...
@abstractmethod
@@ -150,6 +156,7 @@ class Real(Complex, _RealLike):
# See comment at the top of the file
# for why some of these return types are purposefully vague
class Rational(Real):
+ __slots__ = ()
@property
@abstractmethod
def numerator(self) -> _IntegralLike: ...
@@ -161,6 +168,7 @@ class Rational(Real):
# See comment at the top of the file
# for why some of these return types are purposefully vague
class Integral(Rational, _IntegralLike):
+ __slots__ = ()
@abstractmethod
def __int__(self) -> int: ...
def __index__(self) -> int: ...
diff --git a/python/helpers/typeshed/stdlib/opcode.pyi b/python/helpers/typeshed/stdlib/opcode.pyi
index a5a3a79c323b..ed0e96ef1cb9 100644
--- a/python/helpers/typeshed/stdlib/opcode.pyi
+++ b/python/helpers/typeshed/stdlib/opcode.pyi
@@ -1,5 +1,5 @@
import sys
-from typing import Literal
+from typing import Final, Literal
__all__ = [
"cmp_op",
@@ -24,24 +24,24 @@ if sys.version_info >= (3, 13):
__all__ += ["hasjump"]
cmp_op: tuple[Literal["<"], Literal["<="], Literal["=="], Literal["!="], Literal[">"], Literal[">="]]
-hasconst: list[int]
-hasname: list[int]
-hasjrel: list[int]
-hasjabs: list[int]
-haslocal: list[int]
-hascompare: list[int]
-hasfree: list[int]
+hasconst: Final[list[int]]
+hasname: Final[list[int]]
+hasjrel: Final[list[int]]
+hasjabs: Final[list[int]]
+haslocal: Final[list[int]]
+hascompare: Final[list[int]]
+hasfree: Final[list[int]]
if sys.version_info >= (3, 12):
- hasarg: list[int]
- hasexc: list[int]
+ hasarg: Final[list[int]]
+ hasexc: Final[list[int]]
else:
- hasnargs: list[int]
+ hasnargs: Final[list[int]]
if sys.version_info >= (3, 13):
- hasjump: list[int]
-opname: list[str]
+ hasjump: Final[list[int]]
+opname: Final[list[str]]
-opmap: dict[str, int]
-HAVE_ARGUMENT: int
-EXTENDED_ARG: int
+opmap: Final[dict[str, int]]
+HAVE_ARGUMENT: Final = 43
+EXTENDED_ARG: Final = 69
def stack_effect(opcode: int, oparg: int | None = None, /, *, jump: bool | None = None) -> int: ...
diff --git a/python/helpers/typeshed/stdlib/optparse.pyi b/python/helpers/typeshed/stdlib/optparse.pyi
index 8b7fcd82e5a5..c52291799280 100644
--- a/python/helpers/typeshed/stdlib/optparse.pyi
+++ b/python/helpers/typeshed/stdlib/optparse.pyi
@@ -24,8 +24,7 @@ __all__ = [
"BadOptionError",
"check_choice",
]
-# pytype is not happy with `NO_DEFAULT: Final = ("NO", "DEFAULT")`
-NO_DEFAULT: Final[tuple[Literal["NO"], Literal["DEFAULT"]]]
+NO_DEFAULT: Final = ("NO", "DEFAULT")
SUPPRESS_HELP: Final = "SUPPRESSHELP"
SUPPRESS_USAGE: Final = "SUPPRESSUSAGE"
diff --git a/python/helpers/typeshed/stdlib/os/__init__.pyi b/python/helpers/typeshed/stdlib/os/__init__.pyi
index 5286c76d1b06..71c79dfac399 100644
--- a/python/helpers/typeshed/stdlib/os/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/os/__init__.pyi
@@ -39,6 +39,7 @@ from typing import (
final,
overload,
runtime_checkable,
+ type_check_only,
)
from typing_extensions import Self, TypeAlias, Unpack, deprecated
@@ -508,22 +509,22 @@ supports_follow_symlinks: set[Callable[..., Any]]
if sys.platform != "win32":
# Unix only
- PRIO_PROCESS: int
- PRIO_PGRP: int
- PRIO_USER: int
+ PRIO_PROCESS: Final[int]
+ PRIO_PGRP: Final[int]
+ PRIO_USER: Final[int]
- F_LOCK: int
- F_TLOCK: int
- F_ULOCK: int
- F_TEST: int
+ F_LOCK: Final[int]
+ F_TLOCK: Final[int]
+ F_ULOCK: Final[int]
+ F_TEST: Final[int]
if sys.platform != "darwin":
- POSIX_FADV_NORMAL: int
- POSIX_FADV_SEQUENTIAL: int
- POSIX_FADV_RANDOM: int
- POSIX_FADV_NOREUSE: int
- POSIX_FADV_WILLNEED: int
- POSIX_FADV_DONTNEED: int
+ POSIX_FADV_NORMAL: Final[int]
+ POSIX_FADV_SEQUENTIAL: Final[int]
+ POSIX_FADV_RANDOM: Final[int]
+ POSIX_FADV_NOREUSE: Final[int]
+ POSIX_FADV_WILLNEED: Final[int]
+ POSIX_FADV_DONTNEED: Final[int]
if sys.platform != "linux" and sys.platform != "darwin":
# In the os-module docs, these are marked as being available
@@ -533,145 +534,145 @@ if sys.platform != "win32":
# so the sys-module docs recommend doing `if sys.platform.startswith('freebsd')`
# to detect FreeBSD builds. Unfortunately that would be too dynamic
# for type checkers, however.
- SF_NODISKIO: int
- SF_MNOWAIT: int
- SF_SYNC: int
+ SF_NODISKIO: Final[int]
+ SF_MNOWAIT: Final[int]
+ SF_SYNC: Final[int]
if sys.version_info >= (3, 11):
- SF_NOCACHE: int
+ SF_NOCACHE: Final[int]
if sys.platform == "linux":
- XATTR_SIZE_MAX: int
- XATTR_CREATE: int
- XATTR_REPLACE: int
+ XATTR_SIZE_MAX: Final[int]
+ XATTR_CREATE: Final[int]
+ XATTR_REPLACE: Final[int]
- P_PID: int
- P_PGID: int
- P_ALL: int
+ P_PID: Final[int]
+ P_PGID: Final[int]
+ P_ALL: Final[int]
if sys.platform == "linux":
- P_PIDFD: int
+ P_PIDFD: Final[int]
- WEXITED: int
- WSTOPPED: int
- WNOWAIT: int
+ WEXITED: Final[int]
+ WSTOPPED: Final[int]
+ WNOWAIT: Final[int]
- CLD_EXITED: int
- CLD_DUMPED: int
- CLD_TRAPPED: int
- CLD_CONTINUED: int
- CLD_KILLED: int
- CLD_STOPPED: int
+ CLD_EXITED: Final[int]
+ CLD_DUMPED: Final[int]
+ CLD_TRAPPED: Final[int]
+ CLD_CONTINUED: Final[int]
+ CLD_KILLED: Final[int]
+ CLD_STOPPED: Final[int]
- SCHED_OTHER: int
- SCHED_FIFO: int
- SCHED_RR: int
+ SCHED_OTHER: Final[int]
+ SCHED_FIFO: Final[int]
+ SCHED_RR: Final[int]
if sys.platform != "darwin" and sys.platform != "linux":
- SCHED_SPORADIC: int
+ SCHED_SPORADIC: Final[int]
if sys.platform == "linux":
- SCHED_BATCH: int
- SCHED_IDLE: int
- SCHED_RESET_ON_FORK: int
+ SCHED_BATCH: Final[int]
+ SCHED_IDLE: Final[int]
+ SCHED_RESET_ON_FORK: Final[int]
if sys.version_info >= (3, 14) and sys.platform == "linux":
- SCHED_DEADLINE: int
- SCHED_NORMAL: int
+ SCHED_DEADLINE: Final[int]
+ SCHED_NORMAL: Final[int]
if sys.platform != "win32":
- RTLD_LAZY: int
- RTLD_NOW: int
- RTLD_GLOBAL: int
- RTLD_LOCAL: int
- RTLD_NODELETE: int
- RTLD_NOLOAD: int
+ RTLD_LAZY: Final[int]
+ RTLD_NOW: Final[int]
+ RTLD_GLOBAL: Final[int]
+ RTLD_LOCAL: Final[int]
+ RTLD_NODELETE: Final[int]
+ RTLD_NOLOAD: Final[int]
if sys.platform == "linux":
- RTLD_DEEPBIND: int
- GRND_NONBLOCK: int
- GRND_RANDOM: int
+ RTLD_DEEPBIND: Final[int]
+ GRND_NONBLOCK: Final[int]
+ GRND_RANDOM: Final[int]
if sys.platform == "darwin" and sys.version_info >= (3, 12):
- PRIO_DARWIN_BG: int
- PRIO_DARWIN_NONUI: int
- PRIO_DARWIN_PROCESS: int
- PRIO_DARWIN_THREAD: int
+ PRIO_DARWIN_BG: Final[int]
+ PRIO_DARWIN_NONUI: Final[int]
+ PRIO_DARWIN_PROCESS: Final[int]
+ PRIO_DARWIN_THREAD: Final[int]
-SEEK_SET: int
-SEEK_CUR: int
-SEEK_END: int
+SEEK_SET: Final = 0
+SEEK_CUR: Final = 1
+SEEK_END: Final = 2
if sys.platform != "win32":
- SEEK_DATA: int
- SEEK_HOLE: int
+ SEEK_DATA: Final = 3
+ SEEK_HOLE: Final = 4
-O_RDONLY: int
-O_WRONLY: int
-O_RDWR: int
-O_APPEND: int
-O_CREAT: int
-O_EXCL: int
-O_TRUNC: int
+O_RDONLY: Final[int]
+O_WRONLY: Final[int]
+O_RDWR: Final[int]
+O_APPEND: Final[int]
+O_CREAT: Final[int]
+O_EXCL: Final[int]
+O_TRUNC: Final[int]
if sys.platform == "win32":
- O_BINARY: int
- O_NOINHERIT: int
- O_SHORT_LIVED: int
- O_TEMPORARY: int
- O_RANDOM: int
- O_SEQUENTIAL: int
- O_TEXT: int
+ O_BINARY: Final[int]
+ O_NOINHERIT: Final[int]
+ O_SHORT_LIVED: Final[int]
+ O_TEMPORARY: Final[int]
+ O_RANDOM: Final[int]
+ O_SEQUENTIAL: Final[int]
+ O_TEXT: Final[int]
if sys.platform != "win32":
- O_DSYNC: int
- O_SYNC: int
- O_NDELAY: int
- O_NONBLOCK: int
- O_NOCTTY: int
- O_CLOEXEC: int
- O_ASYNC: int # Gnu extension if in C library
- O_DIRECTORY: int # Gnu extension if in C library
- O_NOFOLLOW: int # Gnu extension if in C library
- O_ACCMODE: int # TODO: when does this exist?
+ O_DSYNC: Final[int]
+ O_SYNC: Final[int]
+ O_NDELAY: Final[int]
+ O_NONBLOCK: Final[int]
+ O_NOCTTY: Final[int]
+ O_CLOEXEC: Final[int]
+ O_ASYNC: Final[int] # Gnu extension if in C library
+ O_DIRECTORY: Final[int] # Gnu extension if in C library
+ O_NOFOLLOW: Final[int] # Gnu extension if in C library
+ O_ACCMODE: Final[int] # TODO: when does this exist?
if sys.platform == "linux":
- O_RSYNC: int
- O_DIRECT: int # Gnu extension if in C library
- O_NOATIME: int # Gnu extension if in C library
- O_PATH: int # Gnu extension if in C library
- O_TMPFILE: int # Gnu extension if in C library
- O_LARGEFILE: int # Gnu extension if in C library
+ O_RSYNC: Final[int]
+ O_DIRECT: Final[int] # Gnu extension if in C library
+ O_NOATIME: Final[int] # Gnu extension if in C library
+ O_PATH: Final[int] # Gnu extension if in C library
+ O_TMPFILE: Final[int] # Gnu extension if in C library
+ O_LARGEFILE: Final[int] # Gnu extension if in C library
if sys.platform != "linux" and sys.platform != "win32":
- O_SHLOCK: int
- O_EXLOCK: int
+ O_SHLOCK: Final[int]
+ O_EXLOCK: Final[int]
if sys.platform == "darwin" and sys.version_info >= (3, 10):
- O_EVTONLY: int
- O_NOFOLLOW_ANY: int
- O_SYMLINK: int
+ O_EVTONLY: Final[int]
+ O_NOFOLLOW_ANY: Final[int]
+ O_SYMLINK: Final[int]
if sys.platform != "win32" and sys.version_info >= (3, 10):
- O_FSYNC: int
+ O_FSYNC: Final[int]
if sys.platform != "linux" and sys.platform != "win32" and sys.version_info >= (3, 13):
- O_EXEC: int
- O_SEARCH: int
+ O_EXEC: Final[int]
+ O_SEARCH: Final[int]
if sys.platform != "win32" and sys.platform != "darwin":
# posix, but apparently missing on macos
- ST_APPEND: int
- ST_MANDLOCK: int
- ST_NOATIME: int
- ST_NODEV: int
- ST_NODIRATIME: int
- ST_NOEXEC: int
- ST_RELATIME: int
- ST_SYNCHRONOUS: int
- ST_WRITE: int
+ ST_APPEND: Final[int]
+ ST_MANDLOCK: Final[int]
+ ST_NOATIME: Final[int]
+ ST_NODEV: Final[int]
+ ST_NODIRATIME: Final[int]
+ ST_NOEXEC: Final[int]
+ ST_RELATIME: Final[int]
+ ST_SYNCHRONOUS: Final[int]
+ ST_WRITE: Final[int]
if sys.platform != "win32":
- NGROUPS_MAX: int
- ST_NOSUID: int
- ST_RDONLY: int
+ NGROUPS_MAX: Final[int]
+ ST_NOSUID: Final[int]
+ ST_RDONLY: Final[int]
curdir: str
pardir: str
@@ -683,14 +684,14 @@ else:
extsep: str
pathsep: str
defpath: str
-linesep: str
+linesep: Literal["\n", "\r\n"]
devnull: str
name: str
-F_OK: int
-R_OK: int
-W_OK: int
-X_OK: int
+F_OK: Final = 0
+R_OK: Final = 4
+W_OK: Final = 2
+X_OK: Final = 1
_EnvironCodeFunc: TypeAlias = Callable[[AnyStr], AnyStr]
@@ -729,47 +730,47 @@ if sys.platform != "win32":
environb: _Environ[bytes]
if sys.version_info >= (3, 11) or sys.platform != "win32":
- EX_OK: int
+ EX_OK: Final[int]
if sys.platform != "win32":
confstr_names: dict[str, int]
pathconf_names: dict[str, int]
sysconf_names: dict[str, int]
- EX_USAGE: int
- EX_DATAERR: int
- EX_NOINPUT: int
- EX_NOUSER: int
- EX_NOHOST: int
- EX_UNAVAILABLE: int
- EX_SOFTWARE: int
- EX_OSERR: int
- EX_OSFILE: int
- EX_CANTCREAT: int
- EX_IOERR: int
- EX_TEMPFAIL: int
- EX_PROTOCOL: int
- EX_NOPERM: int
- EX_CONFIG: int
+ EX_USAGE: Final[int]
+ EX_DATAERR: Final[int]
+ EX_NOINPUT: Final[int]
+ EX_NOUSER: Final[int]
+ EX_NOHOST: Final[int]
+ EX_UNAVAILABLE: Final[int]
+ EX_SOFTWARE: Final[int]
+ EX_OSERR: Final[int]
+ EX_OSFILE: Final[int]
+ EX_CANTCREAT: Final[int]
+ EX_IOERR: Final[int]
+ EX_TEMPFAIL: Final[int]
+ EX_PROTOCOL: Final[int]
+ EX_NOPERM: Final[int]
+ EX_CONFIG: Final[int]
# Exists on some Unix platforms, e.g. Solaris.
if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux":
- EX_NOTFOUND: int
+ EX_NOTFOUND: Final[int]
-P_NOWAIT: int
-P_NOWAITO: int
-P_WAIT: int
+P_NOWAIT: Final[int]
+P_NOWAITO: Final[int]
+P_WAIT: Final[int]
if sys.platform == "win32":
- P_DETACH: int
- P_OVERLAY: int
+ P_DETACH: Final[int]
+ P_OVERLAY: Final[int]
# wait()/waitpid() options
if sys.platform != "win32":
- WNOHANG: int # Unix only
- WCONTINUED: int # some Unix systems
- WUNTRACED: int # Unix only
+ WNOHANG: Final[int] # Unix only
+ WCONTINUED: Final[int] # some Unix systems
+ WUNTRACED: Final[int] # Unix only
-TMP_MAX: int # Undocumented, but used by tempfile
+TMP_MAX: Final[int] # Undocumented, but used by tempfile
# ----- os classes (structures) -----
@final
@@ -861,6 +862,7 @@ In the future, this property will contain the last metadata change time."""
# on the allowlist for use as a Protocol starting in 3.14.
@runtime_checkable
class PathLike(ABC, Protocol[AnyStr_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
+ __slots__ = ()
@abstractmethod
def __fspath__(self) -> AnyStr_co: ...
@@ -1135,11 +1137,11 @@ if sys.platform != "win32":
def pwritev(fd: int, buffers: SupportsLenAndGetItem[ReadableBuffer], offset: int, flags: int = 0, /) -> int: ...
if sys.platform != "darwin":
if sys.version_info >= (3, 10):
- RWF_APPEND: int # docs say available on 3.7+, stubtest says otherwise
- RWF_DSYNC: int
- RWF_SYNC: int
- RWF_HIPRI: int
- RWF_NOWAIT: int
+ RWF_APPEND: Final[int] # docs say available on 3.7+, stubtest says otherwise
+ RWF_DSYNC: Final[int]
+ RWF_SYNC: Final[int]
+ RWF_HIPRI: Final[int]
+ RWF_NOWAIT: Final[int]
if sys.platform == "linux":
def sendfile(out_fd: FileDescriptor, in_fd: FileDescriptor, offset: int | None, count: int) -> int: ...
@@ -1149,8 +1151,8 @@ if sys.platform != "win32":
in_fd: FileDescriptor,
offset: int,
count: int,
- headers: Sequence[ReadableBuffer] = ...,
- trailers: Sequence[ReadableBuffer] = ...,
+ headers: Sequence[ReadableBuffer] = (),
+ trailers: Sequence[ReadableBuffer] = (),
flags: int = 0,
) -> int: ... # FreeBSD and Mac OS X only
@@ -1195,7 +1197,7 @@ if sys.platform != "win32":
def getcwd() -> str: ...
def getcwdb() -> bytes: ...
-def chmod(path: FileDescriptorOrPath, mode: int, *, dir_fd: int | None = None, follow_symlinks: bool = ...) -> None: ...
+def chmod(path: FileDescriptorOrPath, mode: int, *, dir_fd: int | None = None, follow_symlinks: bool = True) -> None: ...
if sys.platform != "win32" and sys.platform != "linux":
def chflags(path: StrOrBytesPath, flags: int, follow_symlinks: bool = True) -> None: ... # some flavors of Unix
@@ -1241,6 +1243,7 @@ def replace(
) -> None: ...
def rmdir(path: StrOrBytesPath, *, dir_fd: int | None = None) -> None: ...
@final
+@type_check_only
class _ScandirIterator(Generic[AnyStr]):
def __del__(self) -> None: ...
def __iter__(self) -> Self: ...
@@ -1497,9 +1500,9 @@ else:
setsigdef: Iterable[int] = ...,
scheduler: tuple[Any, sched_param] | None = ...,
) -> int: ...
- POSIX_SPAWN_OPEN: int
- POSIX_SPAWN_CLOSE: int
- POSIX_SPAWN_DUP2: int
+ POSIX_SPAWN_OPEN: Final = 0
+ POSIX_SPAWN_CLOSE: Final = 1
+ POSIX_SPAWN_DUP2: Final = 2
if sys.platform != "win32":
@final
@@ -1563,23 +1566,23 @@ if sys.platform == "win32":
def add_dll_directory(path: str) -> _AddedDllDirectory: ...
if sys.platform == "linux":
- MFD_CLOEXEC: int
- MFD_ALLOW_SEALING: int
- MFD_HUGETLB: int
- MFD_HUGE_SHIFT: int
- MFD_HUGE_MASK: int
- MFD_HUGE_64KB: int
- MFD_HUGE_512KB: int
- MFD_HUGE_1MB: int
- MFD_HUGE_2MB: int
- MFD_HUGE_8MB: int
- MFD_HUGE_16MB: int
- MFD_HUGE_32MB: int
- MFD_HUGE_256MB: int
- MFD_HUGE_512MB: int
- MFD_HUGE_1GB: int
- MFD_HUGE_2GB: int
- MFD_HUGE_16GB: int
+ MFD_CLOEXEC: Final[int]
+ MFD_ALLOW_SEALING: Final[int]
+ MFD_HUGETLB: Final[int]
+ MFD_HUGE_SHIFT: Final[int]
+ MFD_HUGE_MASK: Final[int]
+ MFD_HUGE_64KB: Final[int]
+ MFD_HUGE_512KB: Final[int]
+ MFD_HUGE_1MB: Final[int]
+ MFD_HUGE_2MB: Final[int]
+ MFD_HUGE_8MB: Final[int]
+ MFD_HUGE_16MB: Final[int]
+ MFD_HUGE_32MB: Final[int]
+ MFD_HUGE_256MB: Final[int]
+ MFD_HUGE_512MB: Final[int]
+ MFD_HUGE_1GB: Final[int]
+ MFD_HUGE_2GB: Final[int]
+ MFD_HUGE_16GB: Final[int]
def memfd_create(name: str, flags: int = ...) -> int: ...
def copy_file_range(src: int, dst: int, count: int, offset_src: int | None = ..., offset_dst: int | None = ...) -> int: ...
@@ -1597,12 +1600,12 @@ if sys.version_info >= (3, 12) and sys.platform == "win32":
def listvolumes() -> list[str]: ...
if sys.version_info >= (3, 10) and sys.platform == "linux":
- EFD_CLOEXEC: int
- EFD_NONBLOCK: int
- EFD_SEMAPHORE: int
- SPLICE_F_MORE: int
- SPLICE_F_MOVE: int
- SPLICE_F_NONBLOCK: int
+ EFD_CLOEXEC: Final[int]
+ EFD_NONBLOCK: Final[int]
+ EFD_SEMAPHORE: Final[int]
+ SPLICE_F_MORE: Final[int]
+ SPLICE_F_MOVE: Final[int]
+ SPLICE_F_NONBLOCK: Final[int]
def eventfd(initval: int, flags: int = 524288) -> FileDescriptor: ...
def eventfd_read(fd: FileDescriptor) -> int: ...
def eventfd_write(fd: FileDescriptor, value: int) -> None: ...
@@ -1616,20 +1619,20 @@ if sys.version_info >= (3, 10) and sys.platform == "linux":
) -> int: ...
if sys.version_info >= (3, 12) and sys.platform == "linux":
- CLONE_FILES: int
- CLONE_FS: int
- CLONE_NEWCGROUP: int # Linux 4.6+
- CLONE_NEWIPC: int # Linux 2.6.19+
- CLONE_NEWNET: int # Linux 2.6.24+
- CLONE_NEWNS: int
- CLONE_NEWPID: int # Linux 3.8+
- CLONE_NEWTIME: int # Linux 5.6+
- CLONE_NEWUSER: int # Linux 3.8+
- CLONE_NEWUTS: int # Linux 2.6.19+
- CLONE_SIGHAND: int
- CLONE_SYSVSEM: int # Linux 2.6.26+
- CLONE_THREAD: int
- CLONE_VM: int
+ CLONE_FILES: Final[int]
+ CLONE_FS: Final[int]
+ CLONE_NEWCGROUP: Final[int] # Linux 4.6+
+ CLONE_NEWIPC: Final[int] # Linux 2.6.19+
+ CLONE_NEWNET: Final[int] # Linux 2.6.24+
+ CLONE_NEWNS: Final[int]
+ CLONE_NEWPID: Final[int] # Linux 3.8+
+ CLONE_NEWTIME: Final[int] # Linux 5.6+
+ CLONE_NEWUSER: Final[int] # Linux 3.8+
+ CLONE_NEWUTS: Final[int] # Linux 2.6.19+
+ CLONE_SIGHAND: Final[int]
+ CLONE_SYSVSEM: Final[int] # Linux 2.6.26+
+ CLONE_THREAD: Final[int]
+ CLONE_VM: Final[int]
def unshare(flags: int) -> None: ...
def setns(fd: FileDescriptorLike, nstype: int = 0) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/ossaudiodev.pyi b/python/helpers/typeshed/stdlib/ossaudiodev.pyi
index b9ee3edab033..f8230b4f0212 100644
--- a/python/helpers/typeshed/stdlib/ossaudiodev.pyi
+++ b/python/helpers/typeshed/stdlib/ossaudiodev.pyi
@@ -1,119 +1,120 @@
import sys
-from typing import Any, Literal, overload
+from typing import Any, Final, Literal, overload
if sys.platform != "win32" and sys.platform != "darwin":
- AFMT_AC3: int
- AFMT_A_LAW: int
- AFMT_IMA_ADPCM: int
- AFMT_MPEG: int
- AFMT_MU_LAW: int
- AFMT_QUERY: int
- AFMT_S16_BE: int
- AFMT_S16_LE: int
- AFMT_S16_NE: int
- AFMT_S8: int
- AFMT_U16_BE: int
- AFMT_U16_LE: int
- AFMT_U8: int
- SNDCTL_COPR_HALT: int
- SNDCTL_COPR_LOAD: int
- SNDCTL_COPR_RCODE: int
- SNDCTL_COPR_RCVMSG: int
- SNDCTL_COPR_RDATA: int
- SNDCTL_COPR_RESET: int
- SNDCTL_COPR_RUN: int
- SNDCTL_COPR_SENDMSG: int
- SNDCTL_COPR_WCODE: int
- SNDCTL_COPR_WDATA: int
- SNDCTL_DSP_BIND_CHANNEL: int
- SNDCTL_DSP_CHANNELS: int
- SNDCTL_DSP_GETBLKSIZE: int
- SNDCTL_DSP_GETCAPS: int
- SNDCTL_DSP_GETCHANNELMASK: int
- SNDCTL_DSP_GETFMTS: int
- SNDCTL_DSP_GETIPTR: int
- SNDCTL_DSP_GETISPACE: int
- SNDCTL_DSP_GETODELAY: int
- SNDCTL_DSP_GETOPTR: int
- SNDCTL_DSP_GETOSPACE: int
- SNDCTL_DSP_GETSPDIF: int
- SNDCTL_DSP_GETTRIGGER: int
- SNDCTL_DSP_MAPINBUF: int
- SNDCTL_DSP_MAPOUTBUF: int
- SNDCTL_DSP_NONBLOCK: int
- SNDCTL_DSP_POST: int
- SNDCTL_DSP_PROFILE: int
- SNDCTL_DSP_RESET: int
- SNDCTL_DSP_SAMPLESIZE: int
- SNDCTL_DSP_SETDUPLEX: int
- SNDCTL_DSP_SETFMT: int
- SNDCTL_DSP_SETFRAGMENT: int
- SNDCTL_DSP_SETSPDIF: int
- SNDCTL_DSP_SETSYNCRO: int
- SNDCTL_DSP_SETTRIGGER: int
- SNDCTL_DSP_SPEED: int
- SNDCTL_DSP_STEREO: int
- SNDCTL_DSP_SUBDIVIDE: int
- SNDCTL_DSP_SYNC: int
- SNDCTL_FM_4OP_ENABLE: int
- SNDCTL_FM_LOAD_INSTR: int
- SNDCTL_MIDI_INFO: int
- SNDCTL_MIDI_MPUCMD: int
- SNDCTL_MIDI_MPUMODE: int
- SNDCTL_MIDI_PRETIME: int
- SNDCTL_SEQ_CTRLRATE: int
- SNDCTL_SEQ_GETINCOUNT: int
- SNDCTL_SEQ_GETOUTCOUNT: int
- SNDCTL_SEQ_GETTIME: int
- SNDCTL_SEQ_NRMIDIS: int
- SNDCTL_SEQ_NRSYNTHS: int
- SNDCTL_SEQ_OUTOFBAND: int
- SNDCTL_SEQ_PANIC: int
- SNDCTL_SEQ_PERCMODE: int
- SNDCTL_SEQ_RESET: int
- SNDCTL_SEQ_RESETSAMPLES: int
- SNDCTL_SEQ_SYNC: int
- SNDCTL_SEQ_TESTMIDI: int
- SNDCTL_SEQ_THRESHOLD: int
- SNDCTL_SYNTH_CONTROL: int
- SNDCTL_SYNTH_ID: int
- SNDCTL_SYNTH_INFO: int
- SNDCTL_SYNTH_MEMAVL: int
- SNDCTL_SYNTH_REMOVESAMPLE: int
- SNDCTL_TMR_CONTINUE: int
- SNDCTL_TMR_METRONOME: int
- SNDCTL_TMR_SELECT: int
- SNDCTL_TMR_SOURCE: int
- SNDCTL_TMR_START: int
- SNDCTL_TMR_STOP: int
- SNDCTL_TMR_TEMPO: int
- SNDCTL_TMR_TIMEBASE: int
- SOUND_MIXER_ALTPCM: int
- SOUND_MIXER_BASS: int
- SOUND_MIXER_CD: int
- SOUND_MIXER_DIGITAL1: int
- SOUND_MIXER_DIGITAL2: int
- SOUND_MIXER_DIGITAL3: int
- SOUND_MIXER_IGAIN: int
- SOUND_MIXER_IMIX: int
- SOUND_MIXER_LINE: int
- SOUND_MIXER_LINE1: int
- SOUND_MIXER_LINE2: int
- SOUND_MIXER_LINE3: int
- SOUND_MIXER_MIC: int
- SOUND_MIXER_MONITOR: int
- SOUND_MIXER_NRDEVICES: int
- SOUND_MIXER_OGAIN: int
- SOUND_MIXER_PCM: int
- SOUND_MIXER_PHONEIN: int
- SOUND_MIXER_PHONEOUT: int
- SOUND_MIXER_RADIO: int
- SOUND_MIXER_RECLEV: int
- SOUND_MIXER_SPEAKER: int
- SOUND_MIXER_SYNTH: int
- SOUND_MIXER_TREBLE: int
- SOUND_MIXER_VIDEO: int
- SOUND_MIXER_VOLUME: int
+ # Depends on soundcard.h
+ AFMT_AC3: Final[int]
+ AFMT_A_LAW: Final[int]
+ AFMT_IMA_ADPCM: Final[int]
+ AFMT_MPEG: Final[int]
+ AFMT_MU_LAW: Final[int]
+ AFMT_QUERY: Final[int]
+ AFMT_S16_BE: Final[int]
+ AFMT_S16_LE: Final[int]
+ AFMT_S16_NE: Final[int]
+ AFMT_S8: Final[int]
+ AFMT_U16_BE: Final[int]
+ AFMT_U16_LE: Final[int]
+ AFMT_U8: Final[int]
+ SNDCTL_COPR_HALT: Final[int]
+ SNDCTL_COPR_LOAD: Final[int]
+ SNDCTL_COPR_RCODE: Final[int]
+ SNDCTL_COPR_RCVMSG: Final[int]
+ SNDCTL_COPR_RDATA: Final[int]
+ SNDCTL_COPR_RESET: Final[int]
+ SNDCTL_COPR_RUN: Final[int]
+ SNDCTL_COPR_SENDMSG: Final[int]
+ SNDCTL_COPR_WCODE: Final[int]
+ SNDCTL_COPR_WDATA: Final[int]
+ SNDCTL_DSP_BIND_CHANNEL: Final[int]
+ SNDCTL_DSP_CHANNELS: Final[int]
+ SNDCTL_DSP_GETBLKSIZE: Final[int]
+ SNDCTL_DSP_GETCAPS: Final[int]
+ SNDCTL_DSP_GETCHANNELMASK: Final[int]
+ SNDCTL_DSP_GETFMTS: Final[int]
+ SNDCTL_DSP_GETIPTR: Final[int]
+ SNDCTL_DSP_GETISPACE: Final[int]
+ SNDCTL_DSP_GETODELAY: Final[int]
+ SNDCTL_DSP_GETOPTR: Final[int]
+ SNDCTL_DSP_GETOSPACE: Final[int]
+ SNDCTL_DSP_GETSPDIF: Final[int]
+ SNDCTL_DSP_GETTRIGGER: Final[int]
+ SNDCTL_DSP_MAPINBUF: Final[int]
+ SNDCTL_DSP_MAPOUTBUF: Final[int]
+ SNDCTL_DSP_NONBLOCK: Final[int]
+ SNDCTL_DSP_POST: Final[int]
+ SNDCTL_DSP_PROFILE: Final[int]
+ SNDCTL_DSP_RESET: Final[int]
+ SNDCTL_DSP_SAMPLESIZE: Final[int]
+ SNDCTL_DSP_SETDUPLEX: Final[int]
+ SNDCTL_DSP_SETFMT: Final[int]
+ SNDCTL_DSP_SETFRAGMENT: Final[int]
+ SNDCTL_DSP_SETSPDIF: Final[int]
+ SNDCTL_DSP_SETSYNCRO: Final[int]
+ SNDCTL_DSP_SETTRIGGER: Final[int]
+ SNDCTL_DSP_SPEED: Final[int]
+ SNDCTL_DSP_STEREO: Final[int]
+ SNDCTL_DSP_SUBDIVIDE: Final[int]
+ SNDCTL_DSP_SYNC: Final[int]
+ SNDCTL_FM_4OP_ENABLE: Final[int]
+ SNDCTL_FM_LOAD_INSTR: Final[int]
+ SNDCTL_MIDI_INFO: Final[int]
+ SNDCTL_MIDI_MPUCMD: Final[int]
+ SNDCTL_MIDI_MPUMODE: Final[int]
+ SNDCTL_MIDI_PRETIME: Final[int]
+ SNDCTL_SEQ_CTRLRATE: Final[int]
+ SNDCTL_SEQ_GETINCOUNT: Final[int]
+ SNDCTL_SEQ_GETOUTCOUNT: Final[int]
+ SNDCTL_SEQ_GETTIME: Final[int]
+ SNDCTL_SEQ_NRMIDIS: Final[int]
+ SNDCTL_SEQ_NRSYNTHS: Final[int]
+ SNDCTL_SEQ_OUTOFBAND: Final[int]
+ SNDCTL_SEQ_PANIC: Final[int]
+ SNDCTL_SEQ_PERCMODE: Final[int]
+ SNDCTL_SEQ_RESET: Final[int]
+ SNDCTL_SEQ_RESETSAMPLES: Final[int]
+ SNDCTL_SEQ_SYNC: Final[int]
+ SNDCTL_SEQ_TESTMIDI: Final[int]
+ SNDCTL_SEQ_THRESHOLD: Final[int]
+ SNDCTL_SYNTH_CONTROL: Final[int]
+ SNDCTL_SYNTH_ID: Final[int]
+ SNDCTL_SYNTH_INFO: Final[int]
+ SNDCTL_SYNTH_MEMAVL: Final[int]
+ SNDCTL_SYNTH_REMOVESAMPLE: Final[int]
+ SNDCTL_TMR_CONTINUE: Final[int]
+ SNDCTL_TMR_METRONOME: Final[int]
+ SNDCTL_TMR_SELECT: Final[int]
+ SNDCTL_TMR_SOURCE: Final[int]
+ SNDCTL_TMR_START: Final[int]
+ SNDCTL_TMR_STOP: Final[int]
+ SNDCTL_TMR_TEMPO: Final[int]
+ SNDCTL_TMR_TIMEBASE: Final[int]
+ SOUND_MIXER_ALTPCM: Final[int]
+ SOUND_MIXER_BASS: Final[int]
+ SOUND_MIXER_CD: Final[int]
+ SOUND_MIXER_DIGITAL1: Final[int]
+ SOUND_MIXER_DIGITAL2: Final[int]
+ SOUND_MIXER_DIGITAL3: Final[int]
+ SOUND_MIXER_IGAIN: Final[int]
+ SOUND_MIXER_IMIX: Final[int]
+ SOUND_MIXER_LINE: Final[int]
+ SOUND_MIXER_LINE1: Final[int]
+ SOUND_MIXER_LINE2: Final[int]
+ SOUND_MIXER_LINE3: Final[int]
+ SOUND_MIXER_MIC: Final[int]
+ SOUND_MIXER_MONITOR: Final[int]
+ SOUND_MIXER_NRDEVICES: Final[int]
+ SOUND_MIXER_OGAIN: Final[int]
+ SOUND_MIXER_PCM: Final[int]
+ SOUND_MIXER_PHONEIN: Final[int]
+ SOUND_MIXER_PHONEOUT: Final[int]
+ SOUND_MIXER_RADIO: Final[int]
+ SOUND_MIXER_RECLEV: Final[int]
+ SOUND_MIXER_SPEAKER: Final[int]
+ SOUND_MIXER_SYNTH: Final[int]
+ SOUND_MIXER_TREBLE: Final[int]
+ SOUND_MIXER_VIDEO: Final[int]
+ SOUND_MIXER_VOLUME: Final[int]
control_labels: list[str]
control_names: list[str]
diff --git a/python/helpers/typeshed/stdlib/pathlib/__init__.pyi b/python/helpers/typeshed/stdlib/pathlib/__init__.pyi
index b84fc69313a1..93420e63aff6 100644
--- a/python/helpers/typeshed/stdlib/pathlib/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/pathlib/__init__.pyi
@@ -29,6 +29,31 @@ if sys.version_info >= (3, 13):
__all__ += ["UnsupportedOperation"]
class PurePath(PathLike[str]):
+ if sys.version_info >= (3, 13):
+ __slots__ = (
+ "_raw_paths",
+ "_drv",
+ "_root",
+ "_tail_cached",
+ "_str",
+ "_str_normcase_cached",
+ "_parts_normcase_cached",
+ "_hash",
+ )
+ elif sys.version_info >= (3, 12):
+ __slots__ = (
+ "_raw_paths",
+ "_drv",
+ "_root",
+ "_tail_cached",
+ "_str",
+ "_str_normcase_cached",
+ "_parts_normcase_cached",
+ "_lines_cached",
+ "_hash",
+ )
+ else:
+ __slots__ = ("_drv", "_root", "_parts", "_str", "_hash", "_pparts", "_cached_cparts")
if sys.version_info >= (3, 13):
parser: ClassVar[types.ModuleType]
def full_match(self, pattern: StrPath, *, case_sensitive: bool | None = None) -> bool: ...
@@ -67,7 +92,14 @@ class PurePath(PathLike[str]):
def as_posix(self) -> str: ...
def as_uri(self) -> str: ...
def is_absolute(self) -> bool: ...
- def is_reserved(self) -> bool: ...
+ if sys.version_info >= (3, 13):
+ @deprecated(
+ "Deprecated since Python 3.13; will be removed in Python 3.15. "
+ "Use `os.path.isreserved()` to detect reserved paths on Windows."
+ )
+ def is_reserved(self) -> bool: ...
+ else:
+ def is_reserved(self) -> bool: ...
if sys.version_info >= (3, 14):
def is_relative_to(self, other: StrPath) -> bool: ...
elif sys.version_info >= (3, 12):
@@ -101,10 +133,19 @@ class PurePath(PathLike[str]):
if sys.version_info >= (3, 12):
def with_segments(self, *args: StrPath) -> Self: ...
-class PurePosixPath(PurePath): ...
-class PureWindowsPath(PurePath): ...
+class PurePosixPath(PurePath):
+ __slots__ = ()
+
+class PureWindowsPath(PurePath):
+ __slots__ = ()
class Path(PurePath):
+ if sys.version_info >= (3, 14):
+ __slots__ = ("_info",)
+ elif sys.version_info >= (3, 10):
+ __slots__ = ()
+ else:
+ __slots__ = ("_accessor",)
if sys.version_info >= (3, 12):
def __new__(cls, *args: StrPath, **kwargs: Unused) -> Self: ... # pyright: ignore[reportInconsistentConstructor]
else:
@@ -163,7 +204,6 @@ class Path(PurePath):
def mkdir(self, mode: int = 0o777, parents: bool = False, exist_ok: bool = False) -> None: ...
if sys.version_info >= (3, 14):
-
@property
def info(self) -> PathInfo: ...
@overload
@@ -239,9 +279,13 @@ class Path(PurePath):
self, mode: str, buffering: int = -1, encoding: str | None = None, errors: str | None = None, newline: str | None = None
) -> IO[Any]: ...
- # These methods do "exist" on Windows on <3.13, but they always raise NotImplementedError.
+ # These methods do "exist" on Windows, but they always raise NotImplementedError.
if sys.platform == "win32":
- if sys.version_info < (3, 13):
+ if sys.version_info >= (3, 13):
+ # raises UnsupportedOperation:
+ def owner(self: Never, *, follow_symlinks: bool = True) -> str: ... # type: ignore[misc]
+ def group(self: Never, *, follow_symlinks: bool = True) -> str: ... # type: ignore[misc]
+ else:
def owner(self: Never) -> str: ... # type: ignore[misc]
def group(self: Never) -> str: ... # type: ignore[misc]
else:
@@ -291,17 +335,20 @@ class Path(PurePath):
def write_text(self, data: str, encoding: str | None = None, errors: str | None = None) -> int: ...
if sys.version_info < (3, 12):
if sys.version_info >= (3, 10):
- @deprecated("Deprecated as of Python 3.10 and removed in Python 3.12. Use hardlink_to() instead.")
+ @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `hardlink_to()` instead.")
def link_to(self, target: StrOrBytesPath) -> None: ...
else:
def link_to(self, target: StrOrBytesPath) -> None: ...
if sys.version_info >= (3, 12):
def walk(
- self, top_down: bool = ..., on_error: Callable[[OSError], object] | None = ..., follow_symlinks: bool = ...
+ self, top_down: bool = True, on_error: Callable[[OSError], object] | None = None, follow_symlinks: bool = False
) -> Iterator[tuple[Self, list[str], list[str]]]: ...
-class PosixPath(Path, PurePosixPath): ...
-class WindowsPath(Path, PureWindowsPath): ...
+class PosixPath(Path, PurePosixPath):
+ __slots__ = ()
+
+class WindowsPath(Path, PureWindowsPath):
+ __slots__ = ()
if sys.version_info >= (3, 13):
class UnsupportedOperation(NotImplementedError): ...
diff --git a/python/helpers/typeshed/stdlib/pdb.pyi b/python/helpers/typeshed/stdlib/pdb.pyi
index ad69fcab16de..fb6c486abb39 100644
--- a/python/helpers/typeshed/stdlib/pdb.pyi
+++ b/python/helpers/typeshed/stdlib/pdb.pyi
@@ -17,7 +17,7 @@ _T = TypeVar("_T")
_P = ParamSpec("_P")
_Mode: TypeAlias = Literal["inline", "cli"]
-line_prefix: str # undocumented
+line_prefix: Final[str] # undocumented
class Restart(Exception): ...
diff --git a/python/helpers/typeshed/stdlib/pickle.pyi b/python/helpers/typeshed/stdlib/pickle.pyi
index 2d80d61645e0..d94fe208f446 100644
--- a/python/helpers/typeshed/stdlib/pickle.pyi
+++ b/python/helpers/typeshed/stdlib/pickle.pyi
@@ -14,7 +14,7 @@ from _pickle import (
)
from _typeshed import ReadableBuffer, SupportsWrite
from collections.abc import Callable, Iterable, Mapping
-from typing import Any, ClassVar, SupportsBytes, SupportsIndex, final
+from typing import Any, ClassVar, Final, SupportsBytes, SupportsIndex, final
from typing_extensions import Self
__all__ = [
@@ -102,8 +102,8 @@ __all__ = [
"UNICODE",
]
-HIGHEST_PROTOCOL: int
-DEFAULT_PROTOCOL: int
+HIGHEST_PROTOCOL: Final = 5
+DEFAULT_PROTOCOL: Final = 5
bytes_types: tuple[type[Any], ...] # undocumented
@@ -115,85 +115,85 @@ class PickleBuffer:
def __buffer__(self, flags: int, /) -> memoryview: ...
def __release_buffer__(self, buffer: memoryview, /) -> None: ...
-MARK: bytes
-STOP: bytes
-POP: bytes
-POP_MARK: bytes
-DUP: bytes
-FLOAT: bytes
-INT: bytes
-BININT: bytes
-BININT1: bytes
-LONG: bytes
-BININT2: bytes
-NONE: bytes
-PERSID: bytes
-BINPERSID: bytes
-REDUCE: bytes
-STRING: bytes
-BINSTRING: bytes
-SHORT_BINSTRING: bytes
-UNICODE: bytes
-BINUNICODE: bytes
-APPEND: bytes
-BUILD: bytes
-GLOBAL: bytes
-DICT: bytes
-EMPTY_DICT: bytes
-APPENDS: bytes
-GET: bytes
-BINGET: bytes
-INST: bytes
-LONG_BINGET: bytes
-LIST: bytes
-EMPTY_LIST: bytes
-OBJ: bytes
-PUT: bytes
-BINPUT: bytes
-LONG_BINPUT: bytes
-SETITEM: bytes
-TUPLE: bytes
-EMPTY_TUPLE: bytes
-SETITEMS: bytes
-BINFLOAT: bytes
+MARK: Final = b"("
+STOP: Final = b"."
+POP: Final = b"0"
+POP_MARK: Final = b"1"
+DUP: Final = b"2"
+FLOAT: Final = b"F"
+INT: Final = b"I"
+BININT: Final = b"J"
+BININT1: Final = b"K"
+LONG: Final = b"L"
+BININT2: Final = b"M"
+NONE: Final = b"N"
+PERSID: Final = b"P"
+BINPERSID: Final = b"Q"
+REDUCE: Final = b"R"
+STRING: Final = b"S"
+BINSTRING: Final = b"T"
+SHORT_BINSTRING: Final = b"U"
+UNICODE: Final = b"V"
+BINUNICODE: Final = b"X"
+APPEND: Final = b"a"
+BUILD: Final = b"b"
+GLOBAL: Final = b"c"
+DICT: Final = b"d"
+EMPTY_DICT: Final = b"}"
+APPENDS: Final = b"e"
+GET: Final = b"g"
+BINGET: Final = b"h"
+INST: Final = b"i"
+LONG_BINGET: Final = b"j"
+LIST: Final = b"l"
+EMPTY_LIST: Final = b"]"
+OBJ: Final = b"o"
+PUT: Final = b"p"
+BINPUT: Final = b"q"
+LONG_BINPUT: Final = b"r"
+SETITEM: Final = b"s"
+TUPLE: Final = b"t"
+EMPTY_TUPLE: Final = b")"
+SETITEMS: Final = b"u"
+BINFLOAT: Final = b"G"
-TRUE: bytes
-FALSE: bytes
+TRUE: Final = b"I01\n"
+FALSE: Final = b"I00\n"
# protocol 2
-PROTO: bytes
-NEWOBJ: bytes
-EXT1: bytes
-EXT2: bytes
-EXT4: bytes
-TUPLE1: bytes
-TUPLE2: bytes
-TUPLE3: bytes
-NEWTRUE: bytes
-NEWFALSE: bytes
-LONG1: bytes
-LONG4: bytes
+PROTO: Final = b"\x80"
+NEWOBJ: Final = b"\x81"
+EXT1: Final = b"\x82"
+EXT2: Final = b"\x83"
+EXT4: Final = b"\x84"
+TUPLE1: Final = b"\x85"
+TUPLE2: Final = b"\x86"
+TUPLE3: Final = b"\x87"
+NEWTRUE: Final = b"\x88"
+NEWFALSE: Final = b"\x89"
+LONG1: Final = b"\x8a"
+LONG4: Final = b"\x8b"
# protocol 3
-BINBYTES: bytes
-SHORT_BINBYTES: bytes
+BINBYTES: Final = b"B"
+SHORT_BINBYTES: Final = b"C"
# protocol 4
-SHORT_BINUNICODE: bytes
-BINUNICODE8: bytes
-BINBYTES8: bytes
-EMPTY_SET: bytes
-ADDITEMS: bytes
-FROZENSET: bytes
-NEWOBJ_EX: bytes
-STACK_GLOBAL: bytes
-MEMOIZE: bytes
-FRAME: bytes
+SHORT_BINUNICODE: Final = b"\x8c"
+BINUNICODE8: Final = b"\x8d"
+BINBYTES8: Final = b"\x8e"
+EMPTY_SET: Final = b"\x8f"
+ADDITEMS: Final = b"\x90"
+FROZENSET: Final = b"\x91"
+NEWOBJ_EX: Final = b"\x92"
+STACK_GLOBAL: Final = b"\x93"
+MEMOIZE: Final = b"\x94"
+FRAME: Final = b"\x95"
# protocol 5
-BYTEARRAY8: bytes
-NEXT_BUFFER: bytes
-READONLY_BUFFER: bytes
+BYTEARRAY8: Final = b"\x96"
+NEXT_BUFFER: Final = b"\x97"
+READONLY_BUFFER: Final = b"\x98"
def encode_long(x: int) -> bytes: ... # undocumented
def decode_long(data: Iterable[SupportsIndex] | SupportsBytes | ReadableBuffer) -> int: ... # undocumented
diff --git a/python/helpers/typeshed/stdlib/pickletools.pyi b/python/helpers/typeshed/stdlib/pickletools.pyi
index cdade08d39a8..8bbfaba31b67 100644
--- a/python/helpers/typeshed/stdlib/pickletools.pyi
+++ b/python/helpers/typeshed/stdlib/pickletools.pyi
@@ -1,6 +1,6 @@
import sys
from collections.abc import Callable, Iterator, MutableMapping
-from typing import IO, Any
+from typing import IO, Any, Final
from typing_extensions import TypeAlias
__all__ = ["dis", "genops", "optimize"]
@@ -8,13 +8,14 @@ __all__ = ["dis", "genops", "optimize"]
_Reader: TypeAlias = Callable[[IO[bytes]], Any]
bytes_types: tuple[type[Any], ...]
-UP_TO_NEWLINE: int
-TAKEN_FROM_ARGUMENT1: int
-TAKEN_FROM_ARGUMENT4: int
-TAKEN_FROM_ARGUMENT4U: int
-TAKEN_FROM_ARGUMENT8U: int
+UP_TO_NEWLINE: Final = -1
+TAKEN_FROM_ARGUMENT1: Final = -2
+TAKEN_FROM_ARGUMENT4: Final = -3
+TAKEN_FROM_ARGUMENT4U: Final = -4
+TAKEN_FROM_ARGUMENT8U: Final = -5
class ArgumentDescriptor:
+ __slots__ = ("name", "n", "reader", "doc")
name: str
n: int
reader: _Reader
@@ -118,6 +119,7 @@ def read_long4(f: IO[bytes]) -> int: ...
long4: ArgumentDescriptor
class StackObject:
+ __slots__ = ("name", "obtype", "doc")
name: str
obtype: type[Any] | tuple[type[Any], ...]
doc: str
@@ -143,6 +145,7 @@ markobject: StackObject
stackslice: StackObject
class OpcodeInfo:
+ __slots__ = ("name", "code", "arg", "stack_before", "stack_after", "proto", "doc")
name: str
code: str
arg: ArgumentDescriptor | None
diff --git a/python/helpers/typeshed/stdlib/pkgutil.pyi b/python/helpers/typeshed/stdlib/pkgutil.pyi
index e764d08e79f8..7c70dcc4c5ab 100644
--- a/python/helpers/typeshed/stdlib/pkgutil.pyi
+++ b/python/helpers/typeshed/stdlib/pkgutil.pyi
@@ -30,17 +30,23 @@ class ModuleInfo(NamedTuple):
def extend_path(path: _PathT, name: str) -> _PathT: ...
if sys.version_info < (3, 12):
+ @deprecated("Deprecated since Python 3.3; removed in Python 3.12. Use the `importlib` module instead.")
class ImpImporter:
def __init__(self, path: StrOrBytesPath | None = None) -> None: ...
+ @deprecated("Deprecated since Python 3.3; removed in Python 3.12. Use the `importlib` module instead.")
class ImpLoader:
def __init__(self, fullname: str, file: IO[str], filename: StrOrBytesPath, etc: tuple[str, str, int]) -> None: ...
if sys.version_info < (3, 14):
- @deprecated("Use importlib.util.find_spec() instead. Will be removed in Python 3.14.")
- def find_loader(fullname: str) -> LoaderProtocol | None: ...
- @deprecated("Use importlib.util.find_spec() instead. Will be removed in Python 3.14.")
- def get_loader(module_or_name: str) -> LoaderProtocol | None: ...
+ if sys.version_info >= (3, 12):
+ @deprecated("Deprecated since Python 3.12; removed in Python 3.14. Use `importlib.util.find_spec()` instead.")
+ def find_loader(fullname: str) -> LoaderProtocol | None: ...
+ @deprecated("Deprecated since Python 3.12; removed in Python 3.14. Use `importlib.util.find_spec()` instead.")
+ def get_loader(module_or_name: str) -> LoaderProtocol | None: ...
+ else:
+ def find_loader(fullname: str) -> LoaderProtocol | None: ...
+ def get_loader(module_or_name: str) -> LoaderProtocol | None: ...
def get_importer(path_item: StrOrBytesPath) -> PathEntryFinderProtocol | None: ...
def iter_importers(fullname: str = "") -> Iterator[MetaPathFinderProtocol | PathEntryFinderProtocol]: ...
diff --git a/python/helpers/typeshed/stdlib/platform.pyi b/python/helpers/typeshed/stdlib/platform.pyi
index fbc73c6c9177..a45d1d1186b6 100644
--- a/python/helpers/typeshed/stdlib/platform.pyi
+++ b/python/helpers/typeshed/stdlib/platform.pyi
@@ -1,6 +1,6 @@
import sys
from typing import NamedTuple, type_check_only
-from typing_extensions import Self
+from typing_extensions import Self, deprecated
def libc_ver(executable: str | None = None, lib: str = "", version: str = "", chunksize: int = 16384) -> tuple[str, str]: ...
def win32_ver(release: str = "", version: str = "", csd: str = "", ptype: str = "") -> tuple[str, str, str, str]: ...
@@ -9,9 +9,24 @@ def win32_is_iot() -> bool: ...
def mac_ver(
release: str = "", versioninfo: tuple[str, str, str] = ("", "", ""), machine: str = ""
) -> tuple[str, tuple[str, str, str], str]: ...
-def java_ver(
- release: str = "", vendor: str = "", vminfo: tuple[str, str, str] = ("", "", ""), osinfo: tuple[str, str, str] = ("", "", "")
-) -> tuple[str, str, tuple[str, str, str], tuple[str, str, str]]: ...
+
+if sys.version_info >= (3, 13):
+ @deprecated("Deprecated since Python 3.13; will be removed in Python 3.15.")
+ def java_ver(
+ release: str = "",
+ vendor: str = "",
+ vminfo: tuple[str, str, str] = ("", "", ""),
+ osinfo: tuple[str, str, str] = ("", "", ""),
+ ) -> tuple[str, str, tuple[str, str, str], tuple[str, str, str]]: ...
+
+else:
+ def java_ver(
+ release: str = "",
+ vendor: str = "",
+ vminfo: tuple[str, str, str] = ("", "", ""),
+ osinfo: tuple[str, str, str] = ("", "", ""),
+ ) -> tuple[str, str, tuple[str, str, str], tuple[str, str, str]]: ...
+
def system_alias(system: str, release: str, version: str) -> tuple[str, str, str]: ...
def architecture(executable: str = sys.executable, bits: str = "", linkage: str = "") -> tuple[str, str]: ...
@@ -53,7 +68,7 @@ def python_branch() -> str: ...
def python_revision() -> str: ...
def python_build() -> tuple[str, str]: ...
def python_compiler() -> str: ...
-def platform(aliased: bool = ..., terse: bool = ...) -> str: ...
+def platform(aliased: bool = False, terse: bool = False) -> str: ...
if sys.version_info >= (3, 10):
def freedesktop_os_release() -> dict[str, str]: ...
diff --git a/python/helpers/typeshed/stdlib/plistlib.pyi b/python/helpers/typeshed/stdlib/plistlib.pyi
index 8b39b4217eae..dc3247ee47fb 100644
--- a/python/helpers/typeshed/stdlib/plistlib.pyi
+++ b/python/helpers/typeshed/stdlib/plistlib.pyi
@@ -3,7 +3,7 @@ from _typeshed import ReadableBuffer
from collections.abc import Mapping, MutableMapping
from datetime import datetime
from enum import Enum
-from typing import IO, Any
+from typing import IO, Any, Final
from typing_extensions import Self
__all__ = ["InvalidFileException", "FMT_XML", "FMT_BINARY", "load", "dump", "loads", "dumps", "UID"]
@@ -12,8 +12,8 @@ class PlistFormat(Enum):
FMT_XML = 1
FMT_BINARY = 2
-FMT_XML = PlistFormat.FMT_XML
-FMT_BINARY = PlistFormat.FMT_BINARY
+FMT_XML: Final = PlistFormat.FMT_XML
+FMT_BINARY: Final = PlistFormat.FMT_BINARY
if sys.version_info >= (3, 13):
def load(
fp: IO[bytes],
diff --git a/python/helpers/typeshed/stdlib/poplib.pyi b/python/helpers/typeshed/stdlib/poplib.pyi
index a1e41be86a7f..9ff2b764aeb6 100644
--- a/python/helpers/typeshed/stdlib/poplib.pyi
+++ b/python/helpers/typeshed/stdlib/poplib.pyi
@@ -17,7 +17,7 @@ POP3_SSL_PORT: Final = 995
CR: Final = b"\r"
LF: Final = b"\n"
CRLF: Final = b"\r\n"
-HAVE_SSL: bool
+HAVE_SSL: Final[bool]
class POP3:
encoding: str
diff --git a/python/helpers/typeshed/stdlib/pprint.pyi b/python/helpers/typeshed/stdlib/pprint.pyi
index 171878f4165d..1e80462e2565 100644
--- a/python/helpers/typeshed/stdlib/pprint.pyi
+++ b/python/helpers/typeshed/stdlib/pprint.pyi
@@ -1,4 +1,6 @@
import sys
+from _typeshed import SupportsWrite
+from collections import deque
from typing import IO
__all__ = ["pprint", "pformat", "isreadable", "isrecursive", "saferepr", "PrettyPrinter", "pp"]
@@ -29,25 +31,25 @@ else:
if sys.version_info >= (3, 10):
def pp(
object: object,
- stream: IO[str] | None = ...,
- indent: int = ...,
- width: int = ...,
- depth: int | None = ...,
+ stream: IO[str] | None = None,
+ indent: int = 1,
+ width: int = 80,
+ depth: int | None = None,
*,
- compact: bool = ...,
+ compact: bool = False,
sort_dicts: bool = False,
- underscore_numbers: bool = ...,
+ underscore_numbers: bool = False,
) -> None: ...
else:
def pp(
object: object,
- stream: IO[str] | None = ...,
- indent: int = ...,
- width: int = ...,
- depth: int | None = ...,
+ stream: IO[str] | None = None,
+ indent: int = 1,
+ width: int = 80,
+ depth: int | None = None,
*,
- compact: bool = ...,
+ compact: bool = False,
sort_dicts: bool = False,
) -> None: ...
@@ -110,3 +112,48 @@ class PrettyPrinter:
def isreadable(self, object: object) -> bool: ...
def isrecursive(self, object: object) -> bool: ...
def format(self, object: object, context: dict[int, int], maxlevels: int, level: int) -> tuple[str, bool, bool]: ...
+ def _format(
+ self, object: object, stream: SupportsWrite[str], indent: int, allowance: int, context: dict[int, int], level: int
+ ) -> None: ...
+ def _pprint_dict(
+ self,
+ object: dict[object, object],
+ stream: SupportsWrite[str],
+ indent: int,
+ allowance: int,
+ context: dict[int, int],
+ level: int,
+ ) -> None: ...
+ def _pprint_list(
+ self, object: list[object], stream: SupportsWrite[str], indent: int, allowance: int, context: dict[int, int], level: int
+ ) -> None: ...
+ def _pprint_tuple(
+ self,
+ object: tuple[object, ...],
+ stream: SupportsWrite[str],
+ indent: int,
+ allowance: int,
+ context: dict[int, int],
+ level: int,
+ ) -> None: ...
+ def _pprint_set(
+ self, object: set[object], stream: SupportsWrite[str], indent: int, allowance: int, context: dict[int, int], level: int
+ ) -> None: ...
+ def _pprint_deque(
+ self, object: deque[object], stream: SupportsWrite[str], indent: int, allowance: int, context: dict[int, int], level: int
+ ) -> None: ...
+ def _format_dict_items(
+ self,
+ items: list[tuple[object, object]],
+ stream: SupportsWrite[str],
+ indent: int,
+ allowance: int,
+ context: dict[int, int],
+ level: int,
+ ) -> None: ...
+ def _format_items(
+ self, items: list[object], stream: SupportsWrite[str], indent: int, allowance: int, context: dict[int, int], level: int
+ ) -> None: ...
+ def _repr(self, object: object, context: dict[int, int], level: int) -> str: ...
+ if sys.version_info >= (3, 10):
+ def _safe_repr(self, object: object, context: dict[int, int], maxlevels: int, level: int) -> tuple[str, bool, bool]: ...
diff --git a/python/helpers/typeshed/stdlib/pty.pyi b/python/helpers/typeshed/stdlib/pty.pyi
index 941915179c4a..d1c78f9e3dd6 100644
--- a/python/helpers/typeshed/stdlib/pty.pyi
+++ b/python/helpers/typeshed/stdlib/pty.pyi
@@ -15,10 +15,14 @@ if sys.platform != "win32":
def openpty() -> tuple[int, int]: ...
if sys.version_info < (3, 14):
- @deprecated("Deprecated in 3.12, to be removed in 3.14; use openpty() instead")
- def master_open() -> tuple[int, str]: ...
- @deprecated("Deprecated in 3.12, to be removed in 3.14; use openpty() instead")
- def slave_open(tty_name: str) -> int: ...
+ if sys.version_info >= (3, 12):
+ @deprecated("Deprecated since Python 3.12; removed in Python 3.14. Use `openpty()` instead.")
+ def master_open() -> tuple[int, str]: ...
+ @deprecated("Deprecated since Python 3.12; removed in Python 3.14. Use `openpty()` instead.")
+ def slave_open(tty_name: str) -> int: ...
+ else:
+ def master_open() -> tuple[int, str]: ...
+ def slave_open(tty_name: str) -> int: ...
def fork() -> tuple[int, int]: ...
def spawn(argv: str | Iterable[str], master_read: _Reader = ..., stdin_read: _Reader = ...) -> int: ...
diff --git a/python/helpers/typeshed/stdlib/pydoc.pyi b/python/helpers/typeshed/stdlib/pydoc.pyi
index f14b9d1bb699..935f9420f88c 100644
--- a/python/helpers/typeshed/stdlib/pydoc.pyi
+++ b/python/helpers/typeshed/stdlib/pydoc.pyi
@@ -5,7 +5,7 @@ from builtins import list as _list # "list" conflicts with method name
from collections.abc import Callable, Container, Mapping, MutableMapping
from reprlib import Repr
from types import MethodType, ModuleType, TracebackType
-from typing import IO, Any, AnyStr, Final, NoReturn, Protocol, TypeVar
+from typing import IO, Any, AnyStr, Final, NoReturn, Protocol, TypeVar, type_check_only
from typing_extensions import TypeGuard, deprecated
__all__ = ["help"]
@@ -17,6 +17,7 @@ __date__: Final[str]
__version__: Final[str]
__credits__: Final[str]
+@type_check_only
class _Pager(Protocol):
def __call__(self, text: str, title: str = "") -> None: ...
@@ -33,11 +34,11 @@ def visiblename(name: str, all: Container[str] | None = None, obj: object = None
def classify_class_attrs(object: object) -> list[tuple[str, str, type, str]]: ...
if sys.version_info >= (3, 13):
- @deprecated("Deprecated in Python 3.13.")
- def ispackage(path: str) -> bool: ...
+ @deprecated("Deprecated since Python 3.13.")
+ def ispackage(path: str) -> bool: ... # undocumented
else:
- def ispackage(path: str) -> bool: ...
+ def ispackage(path: str) -> bool: ... # undocumented
def source_synopsis(file: IO[AnyStr]) -> AnyStr | None: ...
def synopsis(filename: str, cache: MutableMapping[str, tuple[int, str]] = {}) -> str | None: ...
diff --git a/python/helpers/typeshed/stdlib/pydoc_data/topics.pyi b/python/helpers/typeshed/stdlib/pydoc_data/topics.pyi
index 091d34300106..ce907a41c005 100644
--- a/python/helpers/typeshed/stdlib/pydoc_data/topics.pyi
+++ b/python/helpers/typeshed/stdlib/pydoc_data/topics.pyi
@@ -1 +1,3 @@
-topics: dict[str, str]
+from typing import Final
+
+topics: Final[dict[str, str]]
diff --git a/python/helpers/typeshed/stdlib/queue.pyi b/python/helpers/typeshed/stdlib/queue.pyi
index f5d9179e079d..65e2ac1559ad 100644
--- a/python/helpers/typeshed/stdlib/queue.pyi
+++ b/python/helpers/typeshed/stdlib/queue.pyi
@@ -1,5 +1,6 @@
import sys
from _queue import Empty as Empty, SimpleQueue as SimpleQueue
+from _typeshed import SupportsRichComparisonT
from threading import Condition, Lock
from types import GenericAlias
from typing import Any, Generic, TypeVar
@@ -47,8 +48,8 @@ class Queue(Generic[_T]):
def task_done(self) -> None: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
-class PriorityQueue(Queue[_T]):
- queue: list[_T]
+class PriorityQueue(Queue[SupportsRichComparisonT]):
+ queue: list[SupportsRichComparisonT]
class LifoQueue(Queue[_T]):
queue: list[_T]
diff --git a/python/helpers/typeshed/stdlib/quopri.pyi b/python/helpers/typeshed/stdlib/quopri.pyi
index b652e139bd0e..be6892fcbcd7 100644
--- a/python/helpers/typeshed/stdlib/quopri.pyi
+++ b/python/helpers/typeshed/stdlib/quopri.pyi
@@ -1,8 +1,9 @@
from _typeshed import ReadableBuffer, SupportsNoArgReadline, SupportsRead, SupportsWrite
-from typing import Protocol
+from typing import Protocol, type_check_only
__all__ = ["encode", "decode", "encodestring", "decodestring"]
+@type_check_only
class _Input(SupportsRead[bytes], SupportsNoArgReadline[bytes], Protocol): ...
def encode(input: _Input, output: SupportsWrite[bytes], quotetabs: int, header: bool = False) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/re.pyi b/python/helpers/typeshed/stdlib/re.pyi
index f25a0a376704..fb2a06d5e4c8 100644
--- a/python/helpers/typeshed/stdlib/re.pyi
+++ b/python/helpers/typeshed/stdlib/re.pyi
@@ -6,7 +6,7 @@ from _typeshed import MaybeNone, ReadableBuffer
from collections.abc import Callable, Iterator, Mapping
from types import GenericAlias
from typing import Any, AnyStr, Final, Generic, Literal, TypeVar, final, overload
-from typing_extensions import TypeAlias
+from typing_extensions import TypeAlias, deprecated
__all__ = [
"match",
@@ -239,9 +239,7 @@ if sys.version_info < (3, 13):
T: Final = RegexFlag.T
TEMPLATE: Final = RegexFlag.TEMPLATE
if sys.version_info >= (3, 11):
- # pytype chokes on `NOFLAG: Final = RegexFlag.NOFLAG` with `LiteralValueError`
- # mypy chokes on `NOFLAG: Final[Literal[RegexFlag.NOFLAG]]` with `Literal[...] is invalid`
- NOFLAG = RegexFlag.NOFLAG
+ NOFLAG: Final = RegexFlag.NOFLAG
_FlagsType: TypeAlias = int | RegexFlag
# Type-wise the compile() overloads are unnecessary, they could also be modeled using
@@ -309,4 +307,8 @@ def escape(pattern: AnyStr) -> AnyStr: ...
def purge() -> None: ...
if sys.version_info < (3, 13):
- def template(pattern: AnyStr | Pattern[AnyStr], flags: _FlagsType = 0) -> Pattern[AnyStr]: ...
+ if sys.version_info >= (3, 11):
+ @deprecated("Deprecated since Python 3.11; removed in Python 3.13. Use `re.compile()` instead.")
+ def template(pattern: AnyStr | Pattern[AnyStr], flags: _FlagsType = 0) -> Pattern[AnyStr]: ... # undocumented
+ else:
+ def template(pattern: AnyStr | Pattern[AnyStr], flags: _FlagsType = 0) -> Pattern[AnyStr]: ... # undocumented
diff --git a/python/helpers/typeshed/stdlib/resource.pyi b/python/helpers/typeshed/stdlib/resource.pyi
index 5e468c2cead5..f99cd5b08805 100644
--- a/python/helpers/typeshed/stdlib/resource.pyi
+++ b/python/helpers/typeshed/stdlib/resource.pyi
@@ -3,27 +3,28 @@ from _typeshed import structseq
from typing import Final, final
if sys.platform != "win32":
- RLIMIT_AS: int
- RLIMIT_CORE: int
- RLIMIT_CPU: int
- RLIMIT_DATA: int
- RLIMIT_FSIZE: int
- RLIMIT_MEMLOCK: int
- RLIMIT_NOFILE: int
- RLIMIT_NPROC: int
- RLIMIT_RSS: int
- RLIMIT_STACK: int
- RLIM_INFINITY: int
- RUSAGE_CHILDREN: int
- RUSAGE_SELF: int
+ # Depends on resource.h
+ RLIMIT_AS: Final[int]
+ RLIMIT_CORE: Final[int]
+ RLIMIT_CPU: Final[int]
+ RLIMIT_DATA: Final[int]
+ RLIMIT_FSIZE: Final[int]
+ RLIMIT_MEMLOCK: Final[int]
+ RLIMIT_NOFILE: Final[int]
+ RLIMIT_NPROC: Final[int]
+ RLIMIT_RSS: Final[int]
+ RLIMIT_STACK: Final[int]
+ RLIM_INFINITY: Final[int]
+ RUSAGE_CHILDREN: Final[int]
+ RUSAGE_SELF: Final[int]
if sys.platform == "linux":
- RLIMIT_MSGQUEUE: int
- RLIMIT_NICE: int
- RLIMIT_OFILE: int
- RLIMIT_RTPRIO: int
- RLIMIT_RTTIME: int
- RLIMIT_SIGPENDING: int
- RUSAGE_THREAD: int
+ RLIMIT_MSGQUEUE: Final[int]
+ RLIMIT_NICE: Final[int]
+ RLIMIT_OFILE: Final[int]
+ RLIMIT_RTPRIO: Final[int]
+ RLIMIT_RTTIME: Final[int]
+ RLIMIT_SIGPENDING: Final[int]
+ RUSAGE_THREAD: Final[int]
@final
class struct_rusage(
diff --git a/python/helpers/typeshed/stdlib/select.pyi b/python/helpers/typeshed/stdlib/select.pyi
index 023547390273..be8a7a7ab8b9 100644
--- a/python/helpers/typeshed/stdlib/select.pyi
+++ b/python/helpers/typeshed/stdlib/select.pyi
@@ -2,25 +2,25 @@ import sys
from _typeshed import FileDescriptorLike
from collections.abc import Iterable
from types import TracebackType
-from typing import Any, ClassVar, final
+from typing import Any, ClassVar, Final, final
from typing_extensions import Self
if sys.platform != "win32":
- PIPE_BUF: int
- POLLERR: int
- POLLHUP: int
- POLLIN: int
+ PIPE_BUF: Final[int]
+ POLLERR: Final[int]
+ POLLHUP: Final[int]
+ POLLIN: Final[int]
if sys.platform == "linux":
- POLLMSG: int
- POLLNVAL: int
- POLLOUT: int
- POLLPRI: int
- POLLRDBAND: int
+ POLLMSG: Final[int]
+ POLLNVAL: Final[int]
+ POLLOUT: Final[int]
+ POLLPRI: Final[int]
+ POLLRDBAND: Final[int]
if sys.platform == "linux":
- POLLRDHUP: int
- POLLRDNORM: int
- POLLWRBAND: int
- POLLWRNORM: int
+ POLLRDHUP: Final[int]
+ POLLRDNORM: Final[int]
+ POLLWRBAND: Final[int]
+ POLLWRNORM: Final[int]
# This is actually a function that returns an instance of a class.
# The class is not accessible directly, and also calls itself select.poll.
@@ -71,45 +71,45 @@ if sys.platform != "linux" and sys.platform != "win32":
@classmethod
def fromfd(cls, fd: FileDescriptorLike, /) -> kqueue: ...
- KQ_EV_ADD: int
- KQ_EV_CLEAR: int
- KQ_EV_DELETE: int
- KQ_EV_DISABLE: int
- KQ_EV_ENABLE: int
- KQ_EV_EOF: int
- KQ_EV_ERROR: int
- KQ_EV_FLAG1: int
- KQ_EV_ONESHOT: int
- KQ_EV_SYSFLAGS: int
- KQ_FILTER_AIO: int
+ KQ_EV_ADD: Final[int]
+ KQ_EV_CLEAR: Final[int]
+ KQ_EV_DELETE: Final[int]
+ KQ_EV_DISABLE: Final[int]
+ KQ_EV_ENABLE: Final[int]
+ KQ_EV_EOF: Final[int]
+ KQ_EV_ERROR: Final[int]
+ KQ_EV_FLAG1: Final[int]
+ KQ_EV_ONESHOT: Final[int]
+ KQ_EV_SYSFLAGS: Final[int]
+ KQ_FILTER_AIO: Final[int]
if sys.platform != "darwin":
- KQ_FILTER_NETDEV: int
- KQ_FILTER_PROC: int
- KQ_FILTER_READ: int
- KQ_FILTER_SIGNAL: int
- KQ_FILTER_TIMER: int
- KQ_FILTER_VNODE: int
- KQ_FILTER_WRITE: int
- KQ_NOTE_ATTRIB: int
- KQ_NOTE_CHILD: int
- KQ_NOTE_DELETE: int
- KQ_NOTE_EXEC: int
- KQ_NOTE_EXIT: int
- KQ_NOTE_EXTEND: int
- KQ_NOTE_FORK: int
- KQ_NOTE_LINK: int
+ KQ_FILTER_NETDEV: Final[int]
+ KQ_FILTER_PROC: Final[int]
+ KQ_FILTER_READ: Final[int]
+ KQ_FILTER_SIGNAL: Final[int]
+ KQ_FILTER_TIMER: Final[int]
+ KQ_FILTER_VNODE: Final[int]
+ KQ_FILTER_WRITE: Final[int]
+ KQ_NOTE_ATTRIB: Final[int]
+ KQ_NOTE_CHILD: Final[int]
+ KQ_NOTE_DELETE: Final[int]
+ KQ_NOTE_EXEC: Final[int]
+ KQ_NOTE_EXIT: Final[int]
+ KQ_NOTE_EXTEND: Final[int]
+ KQ_NOTE_FORK: Final[int]
+ KQ_NOTE_LINK: Final[int]
if sys.platform != "darwin":
- KQ_NOTE_LINKDOWN: int
- KQ_NOTE_LINKINV: int
- KQ_NOTE_LINKUP: int
- KQ_NOTE_LOWAT: int
- KQ_NOTE_PCTRLMASK: int
- KQ_NOTE_PDATAMASK: int
- KQ_NOTE_RENAME: int
- KQ_NOTE_REVOKE: int
- KQ_NOTE_TRACK: int
- KQ_NOTE_TRACKERR: int
- KQ_NOTE_WRITE: int
+ KQ_NOTE_LINKDOWN: Final[int]
+ KQ_NOTE_LINKINV: Final[int]
+ KQ_NOTE_LINKUP: Final[int]
+ KQ_NOTE_LOWAT: Final[int]
+ KQ_NOTE_PCTRLMASK: Final[int]
+ KQ_NOTE_PDATAMASK: Final[int]
+ KQ_NOTE_RENAME: Final[int]
+ KQ_NOTE_REVOKE: Final[int]
+ KQ_NOTE_TRACK: Final[int]
+ KQ_NOTE_TRACKERR: Final[int]
+ KQ_NOTE_WRITE: Final[int]
if sys.platform == "linux":
@final
@@ -133,23 +133,23 @@ if sys.platform == "linux":
@classmethod
def fromfd(cls, fd: FileDescriptorLike, /) -> epoll: ...
- EPOLLERR: int
- EPOLLEXCLUSIVE: int
- EPOLLET: int
- EPOLLHUP: int
- EPOLLIN: int
- EPOLLMSG: int
- EPOLLONESHOT: int
- EPOLLOUT: int
- EPOLLPRI: int
- EPOLLRDBAND: int
- EPOLLRDHUP: int
- EPOLLRDNORM: int
- EPOLLWRBAND: int
- EPOLLWRNORM: int
- EPOLL_CLOEXEC: int
+ EPOLLERR: Final[int]
+ EPOLLEXCLUSIVE: Final[int]
+ EPOLLET: Final[int]
+ EPOLLHUP: Final[int]
+ EPOLLIN: Final[int]
+ EPOLLMSG: Final[int]
+ EPOLLONESHOT: Final[int]
+ EPOLLOUT: Final[int]
+ EPOLLPRI: Final[int]
+ EPOLLRDBAND: Final[int]
+ EPOLLRDHUP: Final[int]
+ EPOLLRDNORM: Final[int]
+ EPOLLWRBAND: Final[int]
+ EPOLLWRNORM: Final[int]
+ EPOLL_CLOEXEC: Final[int]
if sys.version_info >= (3, 14):
- EPOLLWAKEUP: int
+ EPOLLWAKEUP: Final[int]
if sys.platform != "linux" and sys.platform != "darwin" and sys.platform != "win32":
# Solaris only
diff --git a/python/helpers/typeshed/stdlib/selectors.pyi b/python/helpers/typeshed/stdlib/selectors.pyi
index 0ba843a403d8..bcca4e341b9a 100644
--- a/python/helpers/typeshed/stdlib/selectors.pyi
+++ b/python/helpers/typeshed/stdlib/selectors.pyi
@@ -2,13 +2,13 @@ import sys
from _typeshed import FileDescriptor, FileDescriptorLike, Unused
from abc import ABCMeta, abstractmethod
from collections.abc import Mapping
-from typing import Any, NamedTuple
+from typing import Any, Final, NamedTuple
from typing_extensions import Self, TypeAlias
_EventMask: TypeAlias = int
-EVENT_READ: _EventMask
-EVENT_WRITE: _EventMask
+EVENT_READ: Final = 1
+EVENT_WRITE: Final = 2
class SelectorKey(NamedTuple):
fileobj: FileDescriptorLike
diff --git a/python/helpers/typeshed/stdlib/shutil.pyi b/python/helpers/typeshed/stdlib/shutil.pyi
index c66d8fa128be..cc26cfc556a0 100644
--- a/python/helpers/typeshed/stdlib/shutil.pyi
+++ b/python/helpers/typeshed/stdlib/shutil.pyi
@@ -3,7 +3,7 @@ import sys
from _typeshed import BytesPath, ExcInfo, FileDescriptorOrPath, MaybeNone, StrOrBytesPath, StrPath, SupportsRead, SupportsWrite
from collections.abc import Callable, Iterable, Sequence
from tarfile import _TarfileFilter
-from typing import Any, AnyStr, NamedTuple, NoReturn, Protocol, TypeVar, overload
+from typing import Any, AnyStr, NamedTuple, NoReturn, Protocol, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias, deprecated
__all__ = [
@@ -79,6 +79,7 @@ def copytree(
_OnErrorCallback: TypeAlias = Callable[[Callable[..., Any], str, ExcInfo], object]
_OnExcCallback: TypeAlias = Callable[[Callable[..., Any], str, BaseException], object]
+@type_check_only
class _RmtreeType(Protocol):
avoids_symlink_attacks: bool
if sys.version_info >= (3, 12):
diff --git a/python/helpers/typeshed/stdlib/signal.pyi b/python/helpers/typeshed/stdlib/signal.pyi
index d50565d1c8ac..c2668bd8b32d 100644
--- a/python/helpers/typeshed/stdlib/signal.pyi
+++ b/python/helpers/typeshed/stdlib/signal.pyi
@@ -3,7 +3,7 @@ from _typeshed import structseq
from collections.abc import Callable, Iterable
from enum import IntEnum
from types import FrameType
-from typing import Any, Final, Literal, final
+from typing import Any, Final, final
from typing_extensions import Never, TypeAlias
NSIG: int
@@ -61,8 +61,8 @@ class Handlers(IntEnum):
SIG_DFL = 0
SIG_IGN = 1
-SIG_DFL: Literal[Handlers.SIG_DFL]
-SIG_IGN: Literal[Handlers.SIG_IGN]
+SIG_DFL: Final = Handlers.SIG_DFL
+SIG_IGN: Final = Handlers.SIG_IGN
_SIGNUM: TypeAlias = int | Signals
_HANDLER: TypeAlias = Callable[[int, FrameType | None], Any] | int | Handlers | None
@@ -77,45 +77,45 @@ else:
def getsignal(signalnum: _SIGNUM, /) -> _HANDLER: ...
def signal(signalnum: _SIGNUM, handler: _HANDLER, /) -> _HANDLER: ...
-SIGABRT: Literal[Signals.SIGABRT]
-SIGFPE: Literal[Signals.SIGFPE]
-SIGILL: Literal[Signals.SIGILL]
-SIGINT: Literal[Signals.SIGINT]
-SIGSEGV: Literal[Signals.SIGSEGV]
-SIGTERM: Literal[Signals.SIGTERM]
+SIGABRT: Final = Signals.SIGABRT
+SIGFPE: Final = Signals.SIGFPE
+SIGILL: Final = Signals.SIGILL
+SIGINT: Final = Signals.SIGINT
+SIGSEGV: Final = Signals.SIGSEGV
+SIGTERM: Final = Signals.SIGTERM
if sys.platform == "win32":
- SIGBREAK: Literal[Signals.SIGBREAK]
- CTRL_C_EVENT: Literal[Signals.CTRL_C_EVENT]
- CTRL_BREAK_EVENT: Literal[Signals.CTRL_BREAK_EVENT]
+ SIGBREAK: Final = Signals.SIGBREAK
+ CTRL_C_EVENT: Final = Signals.CTRL_C_EVENT
+ CTRL_BREAK_EVENT: Final = Signals.CTRL_BREAK_EVENT
else:
if sys.platform != "linux":
- SIGINFO: Literal[Signals.SIGINFO]
- SIGEMT: Literal[Signals.SIGEMT]
- SIGALRM: Literal[Signals.SIGALRM]
- SIGBUS: Literal[Signals.SIGBUS]
- SIGCHLD: Literal[Signals.SIGCHLD]
- SIGCONT: Literal[Signals.SIGCONT]
- SIGHUP: Literal[Signals.SIGHUP]
- SIGIO: Literal[Signals.SIGIO]
- SIGIOT: Literal[Signals.SIGABRT] # alias
- SIGKILL: Literal[Signals.SIGKILL]
- SIGPIPE: Literal[Signals.SIGPIPE]
- SIGPROF: Literal[Signals.SIGPROF]
- SIGQUIT: Literal[Signals.SIGQUIT]
- SIGSTOP: Literal[Signals.SIGSTOP]
- SIGSYS: Literal[Signals.SIGSYS]
- SIGTRAP: Literal[Signals.SIGTRAP]
- SIGTSTP: Literal[Signals.SIGTSTP]
- SIGTTIN: Literal[Signals.SIGTTIN]
- SIGTTOU: Literal[Signals.SIGTTOU]
- SIGURG: Literal[Signals.SIGURG]
- SIGUSR1: Literal[Signals.SIGUSR1]
- SIGUSR2: Literal[Signals.SIGUSR2]
- SIGVTALRM: Literal[Signals.SIGVTALRM]
- SIGWINCH: Literal[Signals.SIGWINCH]
- SIGXCPU: Literal[Signals.SIGXCPU]
- SIGXFSZ: Literal[Signals.SIGXFSZ]
+ SIGINFO: Final = Signals.SIGINFO
+ SIGEMT: Final = Signals.SIGEMT
+ SIGALRM: Final = Signals.SIGALRM
+ SIGBUS: Final = Signals.SIGBUS
+ SIGCHLD: Final = Signals.SIGCHLD
+ SIGCONT: Final = Signals.SIGCONT
+ SIGHUP: Final = Signals.SIGHUP
+ SIGIO: Final = Signals.SIGIO
+ SIGIOT: Final = Signals.SIGABRT # alias
+ SIGKILL: Final = Signals.SIGKILL
+ SIGPIPE: Final = Signals.SIGPIPE
+ SIGPROF: Final = Signals.SIGPROF
+ SIGQUIT: Final = Signals.SIGQUIT
+ SIGSTOP: Final = Signals.SIGSTOP
+ SIGSYS: Final = Signals.SIGSYS
+ SIGTRAP: Final = Signals.SIGTRAP
+ SIGTSTP: Final = Signals.SIGTSTP
+ SIGTTIN: Final = Signals.SIGTTIN
+ SIGTTOU: Final = Signals.SIGTTOU
+ SIGURG: Final = Signals.SIGURG
+ SIGUSR1: Final = Signals.SIGUSR1
+ SIGUSR2: Final = Signals.SIGUSR2
+ SIGVTALRM: Final = Signals.SIGVTALRM
+ SIGWINCH: Final = Signals.SIGWINCH
+ SIGXCPU: Final = Signals.SIGXCPU
+ SIGXFSZ: Final = Signals.SIGXFSZ
class ItimerError(OSError): ...
ITIMER_PROF: int
@@ -127,9 +127,9 @@ else:
SIG_UNBLOCK = 1
SIG_SETMASK = 2
- SIG_BLOCK: Literal[Sigmasks.SIG_BLOCK]
- SIG_UNBLOCK: Literal[Sigmasks.SIG_UNBLOCK]
- SIG_SETMASK: Literal[Sigmasks.SIG_SETMASK]
+ SIG_BLOCK: Final = Sigmasks.SIG_BLOCK
+ SIG_UNBLOCK: Final = Sigmasks.SIG_UNBLOCK
+ SIG_SETMASK: Final = Sigmasks.SIG_SETMASK
def alarm(seconds: int, /) -> int: ...
def getitimer(which: int, /) -> tuple[float, float]: ...
def pause() -> None: ...
@@ -147,13 +147,13 @@ else:
else:
def sigwait(sigset: Iterable[int], /) -> _SIGNUM: ...
if sys.platform != "darwin":
- SIGCLD: Literal[Signals.SIGCHLD] # alias
- SIGPOLL: Literal[Signals.SIGIO] # alias
- SIGPWR: Literal[Signals.SIGPWR]
- SIGRTMAX: Literal[Signals.SIGRTMAX]
- SIGRTMIN: Literal[Signals.SIGRTMIN]
+ SIGCLD: Final = Signals.SIGCHLD # alias
+ SIGPOLL: Final = Signals.SIGIO # alias
+ SIGPWR: Final = Signals.SIGPWR
+ SIGRTMAX: Final = Signals.SIGRTMAX
+ SIGRTMIN: Final = Signals.SIGRTMIN
if sys.version_info >= (3, 11):
- SIGSTKFLT: Literal[Signals.SIGSTKFLT]
+ SIGSTKFLT: Final = Signals.SIGSTKFLT
@final
class struct_siginfo(structseq[int], tuple[int, int, int, int, int, int, int]):
@@ -181,7 +181,7 @@ else:
def strsignal(signalnum: _SIGNUM, /) -> str | None: ...
def valid_signals() -> set[Signals]: ...
def raise_signal(signalnum: _SIGNUM, /) -> None: ...
-def set_wakeup_fd(fd: int, /, *, warn_on_full_buffer: bool = ...) -> int: ...
+def set_wakeup_fd(fd: int, /, *, warn_on_full_buffer: bool = True) -> int: ...
if sys.platform == "linux":
- def pidfd_send_signal(pidfd: int, sig: int, siginfo: None = None, flags: int = ..., /) -> None: ...
+ def pidfd_send_signal(pidfd: int, sig: int, siginfo: None = None, flags: int = 0, /) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/smtpd.pyi b/python/helpers/typeshed/stdlib/smtpd.pyi
index 7392bd51627d..dee7e949f42f 100644
--- a/python/helpers/typeshed/stdlib/smtpd.pyi
+++ b/python/helpers/typeshed/stdlib/smtpd.pyi
@@ -4,7 +4,7 @@ import socket
import sys
from collections import defaultdict
from typing import Any
-from typing_extensions import TypeAlias
+from typing_extensions import TypeAlias, deprecated
if sys.version_info >= (3, 11):
__all__ = ["SMTPChannel", "SMTPServer", "DebuggingServer", "PureProxy"]
@@ -87,5 +87,6 @@ class PureProxy(SMTPServer):
def process_message(self, peer: _Address, mailfrom: str, rcpttos: list[str], data: bytes | str) -> str | None: ... # type: ignore[override]
if sys.version_info < (3, 11):
+ @deprecated("Deprecated since Python 3.9; removed in Python 3.11.")
class MailmanProxy(PureProxy):
def process_message(self, peer: _Address, mailfrom: str, rcpttos: list[str], data: bytes | str) -> str | None: ... # type: ignore[override]
diff --git a/python/helpers/typeshed/stdlib/smtplib.pyi b/python/helpers/typeshed/stdlib/smtplib.pyi
index 609b3e6426c4..6a8467689367 100644
--- a/python/helpers/typeshed/stdlib/smtplib.pyi
+++ b/python/helpers/typeshed/stdlib/smtplib.pyi
@@ -7,7 +7,7 @@ from re import Pattern
from socket import socket
from ssl import SSLContext
from types import TracebackType
-from typing import Any, Protocol, overload
+from typing import Any, Final, Protocol, overload, type_check_only
from typing_extensions import Self, TypeAlias
__all__ = [
@@ -30,12 +30,12 @@ __all__ = [
_Reply: TypeAlias = tuple[int, bytes]
_SendErrs: TypeAlias = dict[str, _Reply]
-SMTP_PORT: int
-SMTP_SSL_PORT: int
-CRLF: str
-bCRLF: bytes
+SMTP_PORT: Final = 25
+SMTP_SSL_PORT: Final = 465
+CRLF: Final[str]
+bCRLF: Final[bytes]
-OLDSTYLE_AUTH: Pattern[str]
+OLDSTYLE_AUTH: Final[Pattern[str]]
class SMTPException(OSError): ...
class SMTPNotSupportedError(SMTPException): ...
@@ -65,7 +65,7 @@ class SMTPAuthenticationError(SMTPResponseException): ...
def quoteaddr(addrstring: str) -> str: ...
def quotedata(data: str) -> str: ...
-
+@type_check_only
class _AuthObject(Protocol):
@overload
def __call__(self, challenge: None = None, /) -> str | None: ...
@@ -182,7 +182,7 @@ class SMTP_SSL(SMTP):
context: SSLContext | None = None,
) -> None: ...
-LMTP_PORT: int
+LMTP_PORT: Final = 2003
class LMTP(SMTP):
def __init__(
diff --git a/python/helpers/typeshed/stdlib/socket.pyi b/python/helpers/typeshed/stdlib/socket.pyi
index b4fa4381a72c..b10b3560b91f 100644
--- a/python/helpers/typeshed/stdlib/socket.pyi
+++ b/python/helpers/typeshed/stdlib/socket.pyi
@@ -136,7 +136,7 @@ from _typeshed import ReadableBuffer, Unused, WriteableBuffer
from collections.abc import Iterable
from enum import IntEnum, IntFlag
from io import BufferedReader, BufferedRWPair, BufferedWriter, IOBase, RawIOBase, TextIOWrapper
-from typing import Any, Literal, Protocol, SupportsIndex, overload
+from typing import Any, Final, Literal, Protocol, SupportsIndex, overload, type_check_only
from typing_extensions import Self
__all__ = [
@@ -1051,19 +1051,17 @@ if sys.version_info >= (3, 14):
if sys.platform == "linux":
from _socket import (
- CAN_RAW_ERR_FILTER as CAN_RAW_ERR_FILTER,
IP_FREEBIND as IP_FREEBIND,
IP_RECVORIGDSTADDR as IP_RECVORIGDSTADDR,
- SO_ORIGINAL_DST as SO_ORIGINAL_DST,
VMADDR_CID_LOCAL as VMADDR_CID_LOCAL,
)
- __all__ += ["CAN_RAW_ERR_FILTER", "IP_FREEBIND", "IP_RECVORIGDSTADDR", "VMADDR_CID_LOCAL"]
+ __all__ += ["IP_FREEBIND", "IP_RECVORIGDSTADDR", "VMADDR_CID_LOCAL"]
# Re-exported from errno
-EBADF: int
-EAGAIN: int
-EWOULDBLOCK: int
+EBADF: Final[int]
+EAGAIN: Final[int]
+EWOULDBLOCK: Final[int]
# These errors are implemented in _socket at runtime
# but they consider themselves to live in socket so we'll put them here.
@@ -1126,60 +1124,60 @@ class AddressFamily(IntEnum):
# FreeBSD >= 14.0
AF_DIVERT = 44
-AF_INET = AddressFamily.AF_INET
-AF_INET6 = AddressFamily.AF_INET6
-AF_APPLETALK = AddressFamily.AF_APPLETALK
-AF_DECnet: Literal[12]
-AF_IPX = AddressFamily.AF_IPX
-AF_SNA = AddressFamily.AF_SNA
-AF_UNSPEC = AddressFamily.AF_UNSPEC
+AF_INET: Final = AddressFamily.AF_INET
+AF_INET6: Final = AddressFamily.AF_INET6
+AF_APPLETALK: Final = AddressFamily.AF_APPLETALK
+AF_DECnet: Final = 12
+AF_IPX: Final = AddressFamily.AF_IPX
+AF_SNA: Final = AddressFamily.AF_SNA
+AF_UNSPEC: Final = AddressFamily.AF_UNSPEC
if sys.platform != "darwin":
- AF_IRDA = AddressFamily.AF_IRDA
+ AF_IRDA: Final = AddressFamily.AF_IRDA
if sys.platform != "win32":
- AF_ROUTE = AddressFamily.AF_ROUTE
- AF_UNIX = AddressFamily.AF_UNIX
+ AF_ROUTE: Final = AddressFamily.AF_ROUTE
+ AF_UNIX: Final = AddressFamily.AF_UNIX
if sys.platform == "darwin":
- AF_SYSTEM = AddressFamily.AF_SYSTEM
+ AF_SYSTEM: Final = AddressFamily.AF_SYSTEM
if sys.platform != "win32" and sys.platform != "darwin":
- AF_ASH = AddressFamily.AF_ASH
- AF_ATMPVC = AddressFamily.AF_ATMPVC
- AF_ATMSVC = AddressFamily.AF_ATMSVC
- AF_AX25 = AddressFamily.AF_AX25
- AF_BRIDGE = AddressFamily.AF_BRIDGE
- AF_ECONET = AddressFamily.AF_ECONET
- AF_KEY = AddressFamily.AF_KEY
- AF_LLC = AddressFamily.AF_LLC
- AF_NETBEUI = AddressFamily.AF_NETBEUI
- AF_NETROM = AddressFamily.AF_NETROM
- AF_PPPOX = AddressFamily.AF_PPPOX
- AF_ROSE = AddressFamily.AF_ROSE
- AF_SECURITY = AddressFamily.AF_SECURITY
- AF_WANPIPE = AddressFamily.AF_WANPIPE
- AF_X25 = AddressFamily.AF_X25
+ AF_ASH: Final = AddressFamily.AF_ASH
+ AF_ATMPVC: Final = AddressFamily.AF_ATMPVC
+ AF_ATMSVC: Final = AddressFamily.AF_ATMSVC
+ AF_AX25: Final = AddressFamily.AF_AX25
+ AF_BRIDGE: Final = AddressFamily.AF_BRIDGE
+ AF_ECONET: Final = AddressFamily.AF_ECONET
+ AF_KEY: Final = AddressFamily.AF_KEY
+ AF_LLC: Final = AddressFamily.AF_LLC
+ AF_NETBEUI: Final = AddressFamily.AF_NETBEUI
+ AF_NETROM: Final = AddressFamily.AF_NETROM
+ AF_PPPOX: Final = AddressFamily.AF_PPPOX
+ AF_ROSE: Final = AddressFamily.AF_ROSE
+ AF_SECURITY: Final = AddressFamily.AF_SECURITY
+ AF_WANPIPE: Final = AddressFamily.AF_WANPIPE
+ AF_X25: Final = AddressFamily.AF_X25
if sys.platform == "linux":
- AF_CAN = AddressFamily.AF_CAN
- AF_PACKET = AddressFamily.AF_PACKET
- AF_RDS = AddressFamily.AF_RDS
- AF_TIPC = AddressFamily.AF_TIPC
- AF_ALG = AddressFamily.AF_ALG
- AF_NETLINK = AddressFamily.AF_NETLINK
- AF_VSOCK = AddressFamily.AF_VSOCK
- AF_QIPCRTR = AddressFamily.AF_QIPCRTR
+ AF_CAN: Final = AddressFamily.AF_CAN
+ AF_PACKET: Final = AddressFamily.AF_PACKET
+ AF_RDS: Final = AddressFamily.AF_RDS
+ AF_TIPC: Final = AddressFamily.AF_TIPC
+ AF_ALG: Final = AddressFamily.AF_ALG
+ AF_NETLINK: Final = AddressFamily.AF_NETLINK
+ AF_VSOCK: Final = AddressFamily.AF_VSOCK
+ AF_QIPCRTR: Final = AddressFamily.AF_QIPCRTR
if sys.platform != "linux":
- AF_LINK = AddressFamily.AF_LINK
+ AF_LINK: Final = AddressFamily.AF_LINK
if sys.platform != "darwin" and sys.platform != "linux":
- AF_BLUETOOTH = AddressFamily.AF_BLUETOOTH
+ AF_BLUETOOTH: Final = AddressFamily.AF_BLUETOOTH
if sys.platform == "win32" and sys.version_info >= (3, 12):
- AF_HYPERV = AddressFamily.AF_HYPERV
+ AF_HYPERV: Final = AddressFamily.AF_HYPERV
if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin" and sys.version_info >= (3, 12):
# FreeBSD >= 14.0
- AF_DIVERT = AddressFamily.AF_DIVERT
+ AF_DIVERT: Final = AddressFamily.AF_DIVERT
class SocketKind(IntEnum):
SOCK_STREAM = 1
@@ -1191,14 +1189,14 @@ class SocketKind(IntEnum):
SOCK_CLOEXEC = 524288
SOCK_NONBLOCK = 2048
-SOCK_STREAM = SocketKind.SOCK_STREAM
-SOCK_DGRAM = SocketKind.SOCK_DGRAM
-SOCK_RAW = SocketKind.SOCK_RAW
-SOCK_RDM = SocketKind.SOCK_RDM
-SOCK_SEQPACKET = SocketKind.SOCK_SEQPACKET
+SOCK_STREAM: Final = SocketKind.SOCK_STREAM
+SOCK_DGRAM: Final = SocketKind.SOCK_DGRAM
+SOCK_RAW: Final = SocketKind.SOCK_RAW
+SOCK_RDM: Final = SocketKind.SOCK_RDM
+SOCK_SEQPACKET: Final = SocketKind.SOCK_SEQPACKET
if sys.platform == "linux":
- SOCK_CLOEXEC = SocketKind.SOCK_CLOEXEC
- SOCK_NONBLOCK = SocketKind.SOCK_NONBLOCK
+ SOCK_CLOEXEC: Final = SocketKind.SOCK_CLOEXEC
+ SOCK_NONBLOCK: Final = SocketKind.SOCK_NONBLOCK
class MsgFlag(IntFlag):
MSG_CTRUNC = 8
@@ -1230,36 +1228,36 @@ class MsgFlag(IntFlag):
if sys.platform != "win32" and sys.platform != "linux":
MSG_EOF = 256
-MSG_CTRUNC = MsgFlag.MSG_CTRUNC
-MSG_DONTROUTE = MsgFlag.MSG_DONTROUTE
-MSG_OOB = MsgFlag.MSG_OOB
-MSG_PEEK = MsgFlag.MSG_PEEK
-MSG_TRUNC = MsgFlag.MSG_TRUNC
-MSG_WAITALL = MsgFlag.MSG_WAITALL
+MSG_CTRUNC: Final = MsgFlag.MSG_CTRUNC
+MSG_DONTROUTE: Final = MsgFlag.MSG_DONTROUTE
+MSG_OOB: Final = MsgFlag.MSG_OOB
+MSG_PEEK: Final = MsgFlag.MSG_PEEK
+MSG_TRUNC: Final = MsgFlag.MSG_TRUNC
+MSG_WAITALL: Final = MsgFlag.MSG_WAITALL
if sys.platform == "win32":
- MSG_BCAST = MsgFlag.MSG_BCAST
- MSG_MCAST = MsgFlag.MSG_MCAST
+ MSG_BCAST: Final = MsgFlag.MSG_BCAST
+ MSG_MCAST: Final = MsgFlag.MSG_MCAST
if sys.platform != "darwin":
- MSG_ERRQUEUE = MsgFlag.MSG_ERRQUEUE
+ MSG_ERRQUEUE: Final = MsgFlag.MSG_ERRQUEUE
if sys.platform != "win32":
- MSG_DONTWAIT = MsgFlag.MSG_DONTWAIT
- MSG_EOR = MsgFlag.MSG_EOR
- MSG_NOSIGNAL = MsgFlag.MSG_NOSIGNAL # Sometimes this exists on darwin, sometimes not
+ MSG_DONTWAIT: Final = MsgFlag.MSG_DONTWAIT
+ MSG_EOR: Final = MsgFlag.MSG_EOR
+ MSG_NOSIGNAL: Final = MsgFlag.MSG_NOSIGNAL # Sometimes this exists on darwin, sometimes not
if sys.platform != "win32" and sys.platform != "darwin":
- MSG_CMSG_CLOEXEC = MsgFlag.MSG_CMSG_CLOEXEC
- MSG_CONFIRM = MsgFlag.MSG_CONFIRM
- MSG_FASTOPEN = MsgFlag.MSG_FASTOPEN
- MSG_MORE = MsgFlag.MSG_MORE
+ MSG_CMSG_CLOEXEC: Final = MsgFlag.MSG_CMSG_CLOEXEC
+ MSG_CONFIRM: Final = MsgFlag.MSG_CONFIRM
+ MSG_FASTOPEN: Final = MsgFlag.MSG_FASTOPEN
+ MSG_MORE: Final = MsgFlag.MSG_MORE
if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux":
- MSG_NOTIFICATION = MsgFlag.MSG_NOTIFICATION
+ MSG_NOTIFICATION: Final = MsgFlag.MSG_NOTIFICATION
if sys.platform != "win32" and sys.platform != "linux":
- MSG_EOF = MsgFlag.MSG_EOF
+ MSG_EOF: Final = MsgFlag.MSG_EOF
class AddressInfo(IntFlag):
AI_ADDRCONFIG = 32
@@ -1274,22 +1272,23 @@ class AddressInfo(IntFlag):
AI_MASK = 5127
AI_V4MAPPED_CFG = 512
-AI_ADDRCONFIG = AddressInfo.AI_ADDRCONFIG
-AI_ALL = AddressInfo.AI_ALL
-AI_CANONNAME = AddressInfo.AI_CANONNAME
-AI_NUMERICHOST = AddressInfo.AI_NUMERICHOST
-AI_NUMERICSERV = AddressInfo.AI_NUMERICSERV
-AI_PASSIVE = AddressInfo.AI_PASSIVE
-AI_V4MAPPED = AddressInfo.AI_V4MAPPED
+AI_ADDRCONFIG: Final = AddressInfo.AI_ADDRCONFIG
+AI_ALL: Final = AddressInfo.AI_ALL
+AI_CANONNAME: Final = AddressInfo.AI_CANONNAME
+AI_NUMERICHOST: Final = AddressInfo.AI_NUMERICHOST
+AI_NUMERICSERV: Final = AddressInfo.AI_NUMERICSERV
+AI_PASSIVE: Final = AddressInfo.AI_PASSIVE
+AI_V4MAPPED: Final = AddressInfo.AI_V4MAPPED
if sys.platform != "win32" and sys.platform != "linux":
- AI_DEFAULT = AddressInfo.AI_DEFAULT
- AI_MASK = AddressInfo.AI_MASK
- AI_V4MAPPED_CFG = AddressInfo.AI_V4MAPPED_CFG
+ AI_DEFAULT: Final = AddressInfo.AI_DEFAULT
+ AI_MASK: Final = AddressInfo.AI_MASK
+ AI_V4MAPPED_CFG: Final = AddressInfo.AI_V4MAPPED_CFG
if sys.platform == "win32":
errorTab: dict[int, str] # undocumented
+@type_check_only
class _SendableFile(Protocol):
def read(self, size: int, /) -> bytes: ...
def seek(self, offset: int, /) -> object: ...
@@ -1301,6 +1300,7 @@ class _SendableFile(Protocol):
# def fileno(self) -> int: ...
class socket(_socket.socket):
+ __slots__ = ["__weakref__", "_io_refs", "_closed"]
def __init__(
self, family: AddressFamily | int = -1, type: SocketKind | int = -1, proto: int = -1, fileno: int | None = None
) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/sqlite3/__init__.pyi b/python/helpers/typeshed/stdlib/sqlite3/__init__.pyi
index 5d3c2330be5e..bcfea3a13021 100644
--- a/python/helpers/typeshed/stdlib/sqlite3/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/sqlite3/__init__.pyi
@@ -220,23 +220,29 @@ _SqliteData: TypeAlias = str | ReadableBuffer | int | float | None
_AdaptedInputData: TypeAlias = _SqliteData | Any
# The Mapping must really be a dict, but making it invariant is too annoying.
_Parameters: TypeAlias = SupportsLenAndGetItem[_AdaptedInputData] | Mapping[str, _AdaptedInputData]
+# Controls the legacy transaction handling mode of sqlite3.
+_IsolationLevel: TypeAlias = Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None
+@type_check_only
class _AnyParamWindowAggregateClass(Protocol):
def step(self, *args: Any) -> object: ...
def inverse(self, *args: Any) -> object: ...
def value(self) -> _SqliteData: ...
def finalize(self) -> _SqliteData: ...
+@type_check_only
class _WindowAggregateClass(Protocol):
step: Callable[..., object]
inverse: Callable[..., object]
def value(self) -> _SqliteData: ...
def finalize(self) -> _SqliteData: ...
+@type_check_only
class _AggregateProtocol(Protocol):
def step(self, value: int, /) -> object: ...
def finalize(self) -> int: ...
+@type_check_only
class _SingleParamWindowAggregateClass(Protocol):
def step(self, param: Any, /) -> object: ...
def inverse(self, param: Any, /) -> object: ...
@@ -285,7 +291,7 @@ class Connection:
def Warning(self) -> type[Warning]: ...
@property
def in_transaction(self) -> bool: ...
- isolation_level: str | None # one of '', 'DEFERRED', 'IMMEDIATE' or 'EXCLUSIVE'
+ isolation_level: _IsolationLevel
@property
def total_changes(self) -> int: ...
if sys.version_info >= (3, 12):
@@ -299,26 +305,26 @@ class Connection:
def __init__(
self,
database: StrOrBytesPath,
- timeout: float = ...,
- detect_types: int = ...,
- isolation_level: str | None = ...,
- check_same_thread: bool = ...,
+ timeout: float = 5.0,
+ detect_types: int = 0,
+ isolation_level: _IsolationLevel = "DEFERRED",
+ check_same_thread: bool = True,
factory: type[Connection] | None = ...,
- cached_statements: int = ...,
- uri: bool = ...,
+ cached_statements: int = 128,
+ uri: bool = False,
autocommit: bool = ...,
) -> None: ...
else:
def __init__(
self,
database: StrOrBytesPath,
- timeout: float = ...,
- detect_types: int = ...,
- isolation_level: str | None = ...,
- check_same_thread: bool = ...,
+ timeout: float = 5.0,
+ detect_types: int = 0,
+ isolation_level: _IsolationLevel = "DEFERRED",
+ check_same_thread: bool = True,
factory: type[Connection] | None = ...,
- cached_statements: int = ...,
- uri: bool = ...,
+ cached_statements: int = 128,
+ uri: bool = False,
) -> None: ...
def close(self) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/sqlite3/dbapi2.pyi b/python/helpers/typeshed/stdlib/sqlite3/dbapi2.pyi
index d3ea3ef0e896..9e170a81243d 100644
--- a/python/helpers/typeshed/stdlib/sqlite3/dbapi2.pyi
+++ b/python/helpers/typeshed/stdlib/sqlite3/dbapi2.pyi
@@ -66,6 +66,8 @@ from sqlite3 import (
Row as Row,
Warning as Warning,
)
+from typing import Final, Literal
+from typing_extensions import deprecated
if sys.version_info >= (3, 12):
from _sqlite3 import (
@@ -210,11 +212,15 @@ if sys.version_info >= (3, 11):
if sys.version_info < (3, 14):
# Deprecated and removed from _sqlite3 in 3.12, but removed from here in 3.14.
- version: str
+ version: Final[str]
if sys.version_info < (3, 12):
if sys.version_info >= (3, 10):
# deprecation wrapper that has a different name for the argument...
+ @deprecated(
+ "Deprecated since Python 3.10; removed in Python 3.12. "
+ "Open database in URI mode using `cache=shared` parameter instead."
+ )
def enable_shared_cache(enable: int) -> None: ...
else:
from _sqlite3 import enable_shared_cache as enable_shared_cache
@@ -222,9 +228,9 @@ if sys.version_info < (3, 12):
if sys.version_info < (3, 10):
from _sqlite3 import OptimizedUnicode as OptimizedUnicode
-paramstyle: str
-threadsafety: int
-apilevel: str
+paramstyle: Final = "qmark"
+threadsafety: Literal[0, 1, 3]
+apilevel: Final[str]
Date = date
Time = time
Timestamp = datetime
@@ -235,7 +241,7 @@ def TimestampFromTicks(ticks: float) -> Timestamp: ...
if sys.version_info < (3, 14):
# Deprecated in 3.12, removed in 3.14.
- version_info: tuple[int, int, int]
+ version_info: Final[tuple[int, int, int]]
-sqlite_version_info: tuple[int, int, int]
+sqlite_version_info: Final[tuple[int, int, int]]
Binary = memoryview
diff --git a/python/helpers/typeshed/stdlib/sre_compile.pyi b/python/helpers/typeshed/stdlib/sre_compile.pyi
index 2d04a886c931..d8f0b7937e99 100644
--- a/python/helpers/typeshed/stdlib/sre_compile.pyi
+++ b/python/helpers/typeshed/stdlib/sre_compile.pyi
@@ -2,9 +2,9 @@ from re import Pattern
from sre_constants import *
from sre_constants import _NamedIntConstant
from sre_parse import SubPattern
-from typing import Any
+from typing import Any, Final
-MAXCODE: int
+MAXCODE: Final[int]
def dis(code: list[_NamedIntConstant]) -> None: ...
def isstring(obj: Any) -> bool: ...
diff --git a/python/helpers/typeshed/stdlib/sre_parse.pyi b/python/helpers/typeshed/stdlib/sre_parse.pyi
index c242bd2a065f..eaacbff312a9 100644
--- a/python/helpers/typeshed/stdlib/sre_parse.pyi
+++ b/python/helpers/typeshed/stdlib/sre_parse.pyi
@@ -3,24 +3,24 @@ from collections.abc import Iterable
from re import Match, Pattern as _Pattern
from sre_constants import *
from sre_constants import _NamedIntConstant as _NIC, error as _Error
-from typing import Any, overload
+from typing import Any, Final, overload
from typing_extensions import TypeAlias
-SPECIAL_CHARS: str
-REPEAT_CHARS: str
-DIGITS: frozenset[str]
-OCTDIGITS: frozenset[str]
-HEXDIGITS: frozenset[str]
-ASCIILETTERS: frozenset[str]
-WHITESPACE: frozenset[str]
-ESCAPES: dict[str, tuple[_NIC, int]]
-CATEGORIES: dict[str, tuple[_NIC, _NIC] | tuple[_NIC, list[tuple[_NIC, _NIC]]]]
-FLAGS: dict[str, int]
-TYPE_FLAGS: int
-GLOBAL_FLAGS: int
+SPECIAL_CHARS: Final = ".\\[{()*+?^$|"
+REPEAT_CHARS: Final = "*+?{"
+DIGITS: Final[frozenset[str]]
+OCTDIGITS: Final[frozenset[str]]
+HEXDIGITS: Final[frozenset[str]]
+ASCIILETTERS: Final[frozenset[str]]
+WHITESPACE: Final[frozenset[str]]
+ESCAPES: Final[dict[str, tuple[_NIC, int]]]
+CATEGORIES: Final[dict[str, tuple[_NIC, _NIC] | tuple[_NIC, list[tuple[_NIC, _NIC]]]]]
+FLAGS: Final[dict[str, int]]
+TYPE_FLAGS: Final[int]
+GLOBAL_FLAGS: Final[int]
if sys.version_info >= (3, 11):
- MAXWIDTH: int
+ MAXWIDTH: Final[int]
if sys.version_info < (3, 11):
class Verbose(Exception): ...
@@ -39,7 +39,7 @@ class State:
lookbehindgroups: int | None
@property
def groups(self) -> int: ...
- def opengroup(self, name: str | None = ...) -> int: ...
+ def opengroup(self, name: str | None = None) -> int: ...
def closegroup(self, gid: int, p: SubPattern) -> None: ...
def checkgroup(self, gid: int) -> bool: ...
def checklookbehindgroup(self, gid: int, source: Tokenizer) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/ssl.pyi b/python/helpers/typeshed/stdlib/ssl.pyi
index 9fbf5e8dfa84..faa98cb39920 100644
--- a/python/helpers/typeshed/stdlib/ssl.pyi
+++ b/python/helpers/typeshed/stdlib/ssl.pyi
@@ -27,7 +27,7 @@ from _ssl import (
)
from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer
from collections.abc import Callable, Iterable
-from typing import Any, Literal, NamedTuple, TypedDict, overload, type_check_only
+from typing import Any, Final, Literal, NamedTuple, TypedDict, overload, type_check_only
from typing_extensions import Never, Self, TypeAlias, deprecated
if sys.version_info >= (3, 13):
@@ -50,6 +50,7 @@ _SrvnmeCbType: TypeAlias = Callable[[SSLSocket | SSLObject, str | None, SSLSocke
socket_error = OSError
+@type_check_only
class _Cipher(TypedDict):
aead: bool
alg_bits: int
@@ -80,6 +81,7 @@ class SSLCertVerificationError(SSLError, ValueError):
CertificateError = SSLCertVerificationError
if sys.version_info < (3, 12):
+ @deprecated("Deprecated since Python 3.7; removed in Python 3.12. Use `SSLContext.wrap_socket()` instead.")
def wrap_socket(
sock: socket.socket,
keyfile: StrOrBytesPath | None = None,
@@ -92,46 +94,7 @@ if sys.version_info < (3, 12):
suppress_ragged_eofs: bool = True,
ciphers: str | None = None,
) -> SSLSocket: ...
-
-def create_default_context(
- purpose: Purpose = ...,
- *,
- cafile: StrOrBytesPath | None = None,
- capath: StrOrBytesPath | None = None,
- cadata: str | ReadableBuffer | None = None,
-) -> SSLContext: ...
-
-if sys.version_info >= (3, 10):
- def _create_unverified_context(
- protocol: int | None = None,
- *,
- cert_reqs: int = ...,
- check_hostname: bool = False,
- purpose: Purpose = ...,
- certfile: StrOrBytesPath | None = None,
- keyfile: StrOrBytesPath | None = None,
- cafile: StrOrBytesPath | None = None,
- capath: StrOrBytesPath | None = None,
- cadata: str | ReadableBuffer | None = None,
- ) -> SSLContext: ...
-
-else:
- def _create_unverified_context(
- protocol: int = ...,
- *,
- cert_reqs: int = ...,
- check_hostname: bool = False,
- purpose: Purpose = ...,
- certfile: StrOrBytesPath | None = None,
- keyfile: StrOrBytesPath | None = None,
- cafile: StrOrBytesPath | None = None,
- capath: StrOrBytesPath | None = None,
- cadata: str | ReadableBuffer | None = None,
- ) -> SSLContext: ...
-
-_create_default_https_context: Callable[..., SSLContext]
-
-if sys.version_info < (3, 12):
+ @deprecated("Deprecated since Python 3.7; removed in Python 3.12.")
def match_hostname(cert: _PeerCertRetDictType, hostname: str) -> None: ...
def cert_time_to_seconds(cert_time: str) -> int: ...
@@ -162,9 +125,9 @@ class VerifyMode(enum.IntEnum):
CERT_OPTIONAL = 1
CERT_REQUIRED = 2
-CERT_NONE: VerifyMode
-CERT_OPTIONAL: VerifyMode
-CERT_REQUIRED: VerifyMode
+CERT_NONE: Final = VerifyMode.CERT_NONE
+CERT_OPTIONAL: Final = VerifyMode.CERT_OPTIONAL
+CERT_REQUIRED: Final = VerifyMode.CERT_REQUIRED
class VerifyFlags(enum.IntFlag):
VERIFY_DEFAULT = 0
@@ -176,15 +139,15 @@ class VerifyFlags(enum.IntFlag):
VERIFY_ALLOW_PROXY_CERTS = 64
VERIFY_X509_PARTIAL_CHAIN = 524288
-VERIFY_DEFAULT: VerifyFlags
-VERIFY_CRL_CHECK_LEAF: VerifyFlags
-VERIFY_CRL_CHECK_CHAIN: VerifyFlags
-VERIFY_X509_STRICT: VerifyFlags
-VERIFY_X509_TRUSTED_FIRST: VerifyFlags
+VERIFY_DEFAULT: Final = VerifyFlags.VERIFY_DEFAULT
+VERIFY_CRL_CHECK_LEAF: Final = VerifyFlags.VERIFY_CRL_CHECK_LEAF
+VERIFY_CRL_CHECK_CHAIN: Final = VerifyFlags.VERIFY_CRL_CHECK_CHAIN
+VERIFY_X509_STRICT: Final = VerifyFlags.VERIFY_X509_STRICT
+VERIFY_X509_TRUSTED_FIRST: Final = VerifyFlags.VERIFY_X509_TRUSTED_FIRST
if sys.version_info >= (3, 10):
- VERIFY_ALLOW_PROXY_CERTS: VerifyFlags
- VERIFY_X509_PARTIAL_CHAIN: VerifyFlags
+ VERIFY_ALLOW_PROXY_CERTS: Final = VerifyFlags.VERIFY_ALLOW_PROXY_CERTS
+ VERIFY_X509_PARTIAL_CHAIN: Final = VerifyFlags.VERIFY_X509_PARTIAL_CHAIN
class _SSLMethod(enum.IntEnum):
PROTOCOL_SSLv23 = 2
@@ -197,15 +160,15 @@ class _SSLMethod(enum.IntEnum):
PROTOCOL_TLS_CLIENT = 16
PROTOCOL_TLS_SERVER = 17
-PROTOCOL_SSLv23: _SSLMethod
-PROTOCOL_SSLv2: _SSLMethod
-PROTOCOL_SSLv3: _SSLMethod
-PROTOCOL_TLSv1: _SSLMethod
-PROTOCOL_TLSv1_1: _SSLMethod
-PROTOCOL_TLSv1_2: _SSLMethod
-PROTOCOL_TLS: _SSLMethod
-PROTOCOL_TLS_CLIENT: _SSLMethod
-PROTOCOL_TLS_SERVER: _SSLMethod
+PROTOCOL_SSLv23: Final = _SSLMethod.PROTOCOL_SSLv23
+PROTOCOL_SSLv2: Final = _SSLMethod.PROTOCOL_SSLv2
+PROTOCOL_SSLv3: Final = _SSLMethod.PROTOCOL_SSLv3
+PROTOCOL_TLSv1: Final = _SSLMethod.PROTOCOL_TLSv1
+PROTOCOL_TLSv1_1: Final = _SSLMethod.PROTOCOL_TLSv1_1
+PROTOCOL_TLSv1_2: Final = _SSLMethod.PROTOCOL_TLSv1_2
+PROTOCOL_TLS: Final = _SSLMethod.PROTOCOL_TLS
+PROTOCOL_TLS_CLIENT: Final = _SSLMethod.PROTOCOL_TLS_CLIENT
+PROTOCOL_TLS_SERVER: Final = _SSLMethod.PROTOCOL_TLS_SERVER
class Options(enum.IntFlag):
OP_ALL = 2147483728
@@ -228,29 +191,29 @@ class Options(enum.IntFlag):
if sys.version_info >= (3, 11) or sys.platform == "linux":
OP_IGNORE_UNEXPECTED_EOF = 128
-OP_ALL: Options
-OP_NO_SSLv2: Options
-OP_NO_SSLv3: Options
-OP_NO_TLSv1: Options
-OP_NO_TLSv1_1: Options
-OP_NO_TLSv1_2: Options
-OP_NO_TLSv1_3: Options
-OP_CIPHER_SERVER_PREFERENCE: Options
-OP_SINGLE_DH_USE: Options
-OP_SINGLE_ECDH_USE: Options
-OP_NO_COMPRESSION: Options
-OP_NO_TICKET: Options
-OP_NO_RENEGOTIATION: Options
-OP_ENABLE_MIDDLEBOX_COMPAT: Options
+OP_ALL: Final = Options.OP_ALL
+OP_NO_SSLv2: Final = Options.OP_NO_SSLv2
+OP_NO_SSLv3: Final = Options.OP_NO_SSLv3
+OP_NO_TLSv1: Final = Options.OP_NO_TLSv1
+OP_NO_TLSv1_1: Final = Options.OP_NO_TLSv1_1
+OP_NO_TLSv1_2: Final = Options.OP_NO_TLSv1_2
+OP_NO_TLSv1_3: Final = Options.OP_NO_TLSv1_3
+OP_CIPHER_SERVER_PREFERENCE: Final = Options.OP_CIPHER_SERVER_PREFERENCE
+OP_SINGLE_DH_USE: Final = Options.OP_SINGLE_DH_USE
+OP_SINGLE_ECDH_USE: Final = Options.OP_SINGLE_ECDH_USE
+OP_NO_COMPRESSION: Final = Options.OP_NO_COMPRESSION
+OP_NO_TICKET: Final = Options.OP_NO_TICKET
+OP_NO_RENEGOTIATION: Final = Options.OP_NO_RENEGOTIATION
+OP_ENABLE_MIDDLEBOX_COMPAT: Final = Options.OP_ENABLE_MIDDLEBOX_COMPAT
if sys.version_info >= (3, 12):
- OP_LEGACY_SERVER_CONNECT: Options
- OP_ENABLE_KTLS: Options
+ OP_LEGACY_SERVER_CONNECT: Final = Options.OP_LEGACY_SERVER_CONNECT
+ OP_ENABLE_KTLS: Final = Options.OP_ENABLE_KTLS
if sys.version_info >= (3, 11) or sys.platform == "linux":
- OP_IGNORE_UNEXPECTED_EOF: Options
+ OP_IGNORE_UNEXPECTED_EOF: Final = Options.OP_IGNORE_UNEXPECTED_EOF
-HAS_NEVER_CHECK_COMMON_NAME: bool
+HAS_NEVER_CHECK_COMMON_NAME: Final[bool]
-CHANNEL_BINDING_TYPES: list[str]
+CHANNEL_BINDING_TYPES: Final[list[str]]
class AlertDescription(enum.IntEnum):
ALERT_DESCRIPTION_ACCESS_DENIED = 49
@@ -281,33 +244,33 @@ class AlertDescription(enum.IntEnum):
ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION = 110
ALERT_DESCRIPTION_USER_CANCELLED = 90
-ALERT_DESCRIPTION_HANDSHAKE_FAILURE: AlertDescription
-ALERT_DESCRIPTION_INTERNAL_ERROR: AlertDescription
-ALERT_DESCRIPTION_ACCESS_DENIED: AlertDescription
-ALERT_DESCRIPTION_BAD_CERTIFICATE: AlertDescription
-ALERT_DESCRIPTION_BAD_CERTIFICATE_HASH_VALUE: AlertDescription
-ALERT_DESCRIPTION_BAD_CERTIFICATE_STATUS_RESPONSE: AlertDescription
-ALERT_DESCRIPTION_BAD_RECORD_MAC: AlertDescription
-ALERT_DESCRIPTION_CERTIFICATE_EXPIRED: AlertDescription
-ALERT_DESCRIPTION_CERTIFICATE_REVOKED: AlertDescription
-ALERT_DESCRIPTION_CERTIFICATE_UNKNOWN: AlertDescription
-ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE: AlertDescription
-ALERT_DESCRIPTION_CLOSE_NOTIFY: AlertDescription
-ALERT_DESCRIPTION_DECODE_ERROR: AlertDescription
-ALERT_DESCRIPTION_DECOMPRESSION_FAILURE: AlertDescription
-ALERT_DESCRIPTION_DECRYPT_ERROR: AlertDescription
-ALERT_DESCRIPTION_ILLEGAL_PARAMETER: AlertDescription
-ALERT_DESCRIPTION_INSUFFICIENT_SECURITY: AlertDescription
-ALERT_DESCRIPTION_NO_RENEGOTIATION: AlertDescription
-ALERT_DESCRIPTION_PROTOCOL_VERSION: AlertDescription
-ALERT_DESCRIPTION_RECORD_OVERFLOW: AlertDescription
-ALERT_DESCRIPTION_UNEXPECTED_MESSAGE: AlertDescription
-ALERT_DESCRIPTION_UNKNOWN_CA: AlertDescription
-ALERT_DESCRIPTION_UNKNOWN_PSK_IDENTITY: AlertDescription
-ALERT_DESCRIPTION_UNRECOGNIZED_NAME: AlertDescription
-ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE: AlertDescription
-ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION: AlertDescription
-ALERT_DESCRIPTION_USER_CANCELLED: AlertDescription
+ALERT_DESCRIPTION_HANDSHAKE_FAILURE: Final = AlertDescription.ALERT_DESCRIPTION_HANDSHAKE_FAILURE
+ALERT_DESCRIPTION_INTERNAL_ERROR: Final = AlertDescription.ALERT_DESCRIPTION_INTERNAL_ERROR
+ALERT_DESCRIPTION_ACCESS_DENIED: Final = AlertDescription.ALERT_DESCRIPTION_ACCESS_DENIED
+ALERT_DESCRIPTION_BAD_CERTIFICATE: Final = AlertDescription.ALERT_DESCRIPTION_BAD_CERTIFICATE
+ALERT_DESCRIPTION_BAD_CERTIFICATE_HASH_VALUE: Final = AlertDescription.ALERT_DESCRIPTION_BAD_CERTIFICATE_HASH_VALUE
+ALERT_DESCRIPTION_BAD_CERTIFICATE_STATUS_RESPONSE: Final = AlertDescription.ALERT_DESCRIPTION_BAD_CERTIFICATE_STATUS_RESPONSE
+ALERT_DESCRIPTION_BAD_RECORD_MAC: Final = AlertDescription.ALERT_DESCRIPTION_BAD_RECORD_MAC
+ALERT_DESCRIPTION_CERTIFICATE_EXPIRED: Final = AlertDescription.ALERT_DESCRIPTION_CERTIFICATE_EXPIRED
+ALERT_DESCRIPTION_CERTIFICATE_REVOKED: Final = AlertDescription.ALERT_DESCRIPTION_CERTIFICATE_REVOKED
+ALERT_DESCRIPTION_CERTIFICATE_UNKNOWN: Final = AlertDescription.ALERT_DESCRIPTION_CERTIFICATE_UNKNOWN
+ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE: Final = AlertDescription.ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
+ALERT_DESCRIPTION_CLOSE_NOTIFY: Final = AlertDescription.ALERT_DESCRIPTION_CLOSE_NOTIFY
+ALERT_DESCRIPTION_DECODE_ERROR: Final = AlertDescription.ALERT_DESCRIPTION_DECODE_ERROR
+ALERT_DESCRIPTION_DECOMPRESSION_FAILURE: Final = AlertDescription.ALERT_DESCRIPTION_DECOMPRESSION_FAILURE
+ALERT_DESCRIPTION_DECRYPT_ERROR: Final = AlertDescription.ALERT_DESCRIPTION_DECRYPT_ERROR
+ALERT_DESCRIPTION_ILLEGAL_PARAMETER: Final = AlertDescription.ALERT_DESCRIPTION_ILLEGAL_PARAMETER
+ALERT_DESCRIPTION_INSUFFICIENT_SECURITY: Final = AlertDescription.ALERT_DESCRIPTION_INSUFFICIENT_SECURITY
+ALERT_DESCRIPTION_NO_RENEGOTIATION: Final = AlertDescription.ALERT_DESCRIPTION_NO_RENEGOTIATION
+ALERT_DESCRIPTION_PROTOCOL_VERSION: Final = AlertDescription.ALERT_DESCRIPTION_PROTOCOL_VERSION
+ALERT_DESCRIPTION_RECORD_OVERFLOW: Final = AlertDescription.ALERT_DESCRIPTION_RECORD_OVERFLOW
+ALERT_DESCRIPTION_UNEXPECTED_MESSAGE: Final = AlertDescription.ALERT_DESCRIPTION_UNEXPECTED_MESSAGE
+ALERT_DESCRIPTION_UNKNOWN_CA: Final = AlertDescription.ALERT_DESCRIPTION_UNKNOWN_CA
+ALERT_DESCRIPTION_UNKNOWN_PSK_IDENTITY: Final = AlertDescription.ALERT_DESCRIPTION_UNKNOWN_PSK_IDENTITY
+ALERT_DESCRIPTION_UNRECOGNIZED_NAME: Final = AlertDescription.ALERT_DESCRIPTION_UNRECOGNIZED_NAME
+ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE: Final = AlertDescription.ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE
+ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION: Final = AlertDescription.ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION
+ALERT_DESCRIPTION_USER_CANCELLED: Final = AlertDescription.ALERT_DESCRIPTION_USER_CANCELLED
# This class is not exposed. It calls itself ssl._ASN1Object.
@type_check_only
@@ -370,7 +333,7 @@ class SSLSocket(socket.socket):
def get_channel_binding(self, cb_type: str = "tls-unique") -> bytes | None: ...
def selected_alpn_protocol(self) -> str | None: ...
if sys.version_info >= (3, 10):
- @deprecated("Deprecated in 3.10. Use ALPN instead.")
+ @deprecated("Deprecated since Python 3.10. Use ALPN instead.")
def selected_npn_protocol(self) -> str | None: ...
else:
def selected_npn_protocol(self) -> str | None: ...
@@ -416,13 +379,15 @@ class SSLContext(_SSLContext):
if sys.version_info >= (3, 10):
security_level: int
if sys.version_info >= (3, 10):
- # Using the default (None) for the `protocol` parameter is deprecated,
- # but there isn't a good way of marking that in the stub unless/until PEP 702 is accepted
- def __new__(cls, protocol: int | None = None, *args: Any, **kwargs: Any) -> Self: ...
+ @overload
+ def __new__(cls, protocol: int, *args: Any, **kwargs: Any) -> Self: ...
+ @overload
+ @deprecated("Deprecated since Python 3.10. Use a specific version of the SSL protocol.")
+ def __new__(cls, protocol: None = None, *args: Any, **kwargs: Any) -> Self: ...
else:
def __new__(cls, protocol: int = ..., *args: Any, **kwargs: Any) -> Self: ...
- def load_default_certs(self, purpose: Purpose = ...) -> None: ...
+ def load_default_certs(self, purpose: Purpose = Purpose.SERVER_AUTH) -> None: ...
def load_verify_locations(
self,
cafile: StrOrBytesPath | None = None,
@@ -440,7 +405,7 @@ class SSLContext(_SSLContext):
def set_ciphers(self, cipherlist: str, /) -> None: ...
def set_alpn_protocols(self, alpn_protocols: Iterable[str]) -> None: ...
if sys.version_info >= (3, 10):
- @deprecated("Deprecated in 3.10. Use ALPN instead.")
+ @deprecated("Deprecated since Python 3.10. Use ALPN instead.")
def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ...
else:
def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ...
@@ -466,6 +431,44 @@ class SSLContext(_SSLContext):
session: SSLSession | None = None,
) -> SSLObject: ...
+def create_default_context(
+ purpose: Purpose = Purpose.SERVER_AUTH,
+ *,
+ cafile: StrOrBytesPath | None = None,
+ capath: StrOrBytesPath | None = None,
+ cadata: str | ReadableBuffer | None = None,
+) -> SSLContext: ...
+
+if sys.version_info >= (3, 10):
+ def _create_unverified_context(
+ protocol: int | None = None,
+ *,
+ cert_reqs: int = ...,
+ check_hostname: bool = False,
+ purpose: Purpose = Purpose.SERVER_AUTH,
+ certfile: StrOrBytesPath | None = None,
+ keyfile: StrOrBytesPath | None = None,
+ cafile: StrOrBytesPath | None = None,
+ capath: StrOrBytesPath | None = None,
+ cadata: str | ReadableBuffer | None = None,
+ ) -> SSLContext: ...
+
+else:
+ def _create_unverified_context(
+ protocol: int = ...,
+ *,
+ cert_reqs: int = ...,
+ check_hostname: bool = False,
+ purpose: Purpose = Purpose.SERVER_AUTH,
+ certfile: StrOrBytesPath | None = None,
+ keyfile: StrOrBytesPath | None = None,
+ cafile: StrOrBytesPath | None = None,
+ capath: StrOrBytesPath | None = None,
+ cadata: str | ReadableBuffer | None = None,
+ ) -> SSLContext: ...
+
+_create_default_https_context = create_default_context
+
class SSLObject:
context: SSLContext
@property
@@ -486,7 +489,7 @@ class SSLObject:
def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ...
def selected_alpn_protocol(self) -> str | None: ...
if sys.version_info >= (3, 10):
- @deprecated("Deprecated in 3.10. Use ALPN instead.")
+ @deprecated("Deprecated since Python 3.10. Use ALPN instead.")
def selected_npn_protocol(self) -> str | None: ...
else:
def selected_npn_protocol(self) -> str | None: ...
@@ -515,20 +518,20 @@ class SSLErrorNumber(enum.IntEnum):
SSL_ERROR_WANT_X509_LOOKUP = 4
SSL_ERROR_ZERO_RETURN = 6
-SSL_ERROR_EOF: SSLErrorNumber # undocumented
-SSL_ERROR_INVALID_ERROR_CODE: SSLErrorNumber # undocumented
-SSL_ERROR_SSL: SSLErrorNumber # undocumented
-SSL_ERROR_SYSCALL: SSLErrorNumber # undocumented
-SSL_ERROR_WANT_CONNECT: SSLErrorNumber # undocumented
-SSL_ERROR_WANT_READ: SSLErrorNumber # undocumented
-SSL_ERROR_WANT_WRITE: SSLErrorNumber # undocumented
-SSL_ERROR_WANT_X509_LOOKUP: SSLErrorNumber # undocumented
-SSL_ERROR_ZERO_RETURN: SSLErrorNumber # undocumented
+SSL_ERROR_EOF: Final = SSLErrorNumber.SSL_ERROR_EOF # undocumented
+SSL_ERROR_INVALID_ERROR_CODE: Final = SSLErrorNumber.SSL_ERROR_INVALID_ERROR_CODE # undocumented
+SSL_ERROR_SSL: Final = SSLErrorNumber.SSL_ERROR_SSL # undocumented
+SSL_ERROR_SYSCALL: Final = SSLErrorNumber.SSL_ERROR_SYSCALL # undocumented
+SSL_ERROR_WANT_CONNECT: Final = SSLErrorNumber.SSL_ERROR_WANT_CONNECT # undocumented
+SSL_ERROR_WANT_READ: Final = SSLErrorNumber.SSL_ERROR_WANT_READ # undocumented
+SSL_ERROR_WANT_WRITE: Final = SSLErrorNumber.SSL_ERROR_WANT_WRITE # undocumented
+SSL_ERROR_WANT_X509_LOOKUP: Final = SSLErrorNumber.SSL_ERROR_WANT_X509_LOOKUP # undocumented
+SSL_ERROR_ZERO_RETURN: Final = SSLErrorNumber.SSL_ERROR_ZERO_RETURN # undocumented
def get_protocol_name(protocol_code: int) -> str: ...
-PEM_FOOTER: str
-PEM_HEADER: str
-SOCK_STREAM: int
-SOL_SOCKET: int
-SO_TYPE: int
+PEM_FOOTER: Final[str]
+PEM_HEADER: Final[str]
+SOCK_STREAM: Final = socket.SOCK_STREAM
+SOL_SOCKET: Final = socket.SOL_SOCKET
+SO_TYPE: Final = socket.SO_TYPE
diff --git a/python/helpers/typeshed/stdlib/statistics.pyi b/python/helpers/typeshed/stdlib/statistics.pyi
index 6d7d3fbb4956..ba9e5f1b6b71 100644
--- a/python/helpers/typeshed/stdlib/statistics.pyi
+++ b/python/helpers/typeshed/stdlib/statistics.pyi
@@ -79,6 +79,7 @@ def stdev(data: Iterable[_NumberT], xbar: _NumberT | None = None) -> _NumberT: .
def variance(data: Iterable[_NumberT], xbar: _NumberT | None = None) -> _NumberT: ...
class NormalDist:
+ __slots__ = {"_mu": "Arithmetic mean of a normal distribution", "_sigma": "Standard deviation of a normal distribution"}
def __init__(self, mu: float = 0.0, sigma: float = 1.0) -> None: ...
@property
def mean(self) -> float: ...
diff --git a/python/helpers/typeshed/stdlib/string/__init__.pyi b/python/helpers/typeshed/stdlib/string/__init__.pyi
index 29fe27f39b80..c8b32a98e26d 100644
--- a/python/helpers/typeshed/stdlib/string/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/string/__init__.pyi
@@ -2,7 +2,7 @@ import sys
from _typeshed import StrOrLiteralStr
from collections.abc import Iterable, Mapping, Sequence
from re import Pattern, RegexFlag
-from typing import Any, ClassVar, overload
+from typing import Any, ClassVar, Final, overload
from typing_extensions import LiteralString
__all__ = [
@@ -20,15 +20,15 @@ __all__ = [
"Template",
]
-ascii_letters: LiteralString
-ascii_lowercase: LiteralString
-ascii_uppercase: LiteralString
-digits: LiteralString
-hexdigits: LiteralString
-octdigits: LiteralString
-punctuation: LiteralString
-printable: LiteralString
-whitespace: LiteralString
+whitespace: Final = " \t\n\r\v\f"
+ascii_lowercase: Final = "abcdefghijklmnopqrstuvwxyz"
+ascii_uppercase: Final = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ascii_letters: Final[LiteralString] # string too long
+digits: Final = "0123456789"
+hexdigits: Final = "0123456789abcdefABCDEF"
+octdigits: Final = "01234567"
+punctuation: Final = r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
+printable: Final[LiteralString] # string too long
def capwords(s: StrOrLiteralStr, sep: StrOrLiteralStr | None = None) -> StrOrLiteralStr: ...
diff --git a/python/helpers/typeshed/stdlib/string/templatelib.pyi b/python/helpers/typeshed/stdlib/string/templatelib.pyi
index 324447f5f34c..9906d31c6391 100644
--- a/python/helpers/typeshed/stdlib/string/templatelib.pyi
+++ b/python/helpers/typeshed/stdlib/string/templatelib.pyi
@@ -1,8 +1,8 @@
from collections.abc import Iterator
from types import GenericAlias
-from typing import Any, Literal, final
+from typing import Any, Literal, TypeVar, final, overload
-__all__ = ["Interpolation", "Template"]
+_T = TypeVar("_T")
@final
class Template: # TODO: consider making `Template` generic on `TypeVarTuple`
@@ -11,7 +11,7 @@ class Template: # TODO: consider making `Template` generic on `TypeVarTuple`
def __new__(cls, *args: str | Interpolation) -> Template: ...
def __iter__(self) -> Iterator[str | Interpolation]: ...
- def __add__(self, other: Template | str) -> Template: ...
+ def __add__(self, other: Template, /) -> Template: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
@property
def values(self) -> tuple[Any, ...]: ... # Tuple of interpolation values, which can have any type
@@ -26,6 +26,11 @@ class Interpolation:
__match_args__ = ("value", "expression", "conversion", "format_spec")
def __new__(
- cls, value: Any, expression: str, conversion: Literal["a", "r", "s"] | None = None, format_spec: str = ""
+ cls, value: Any, expression: str = "", conversion: Literal["a", "r", "s"] | None = None, format_spec: str = ""
) -> Interpolation: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
+
+@overload
+def convert(obj: _T, /, conversion: None) -> _T: ...
+@overload
+def convert(obj: object, /, conversion: Literal["r", "s", "a"]) -> str: ...
diff --git a/python/helpers/typeshed/stdlib/stringprep.pyi b/python/helpers/typeshed/stdlib/stringprep.pyi
index fc28c027ca9b..d67955e499c8 100644
--- a/python/helpers/typeshed/stdlib/stringprep.pyi
+++ b/python/helpers/typeshed/stdlib/stringprep.pyi
@@ -1,10 +1,12 @@
-b1_set: set[int]
-b3_exceptions: dict[int, str]
-c22_specials: set[int]
-c6_set: set[int]
-c7_set: set[int]
-c8_set: set[int]
-c9_set: set[int]
+from typing import Final
+
+b1_set: Final[set[int]]
+b3_exceptions: Final[dict[int, str]]
+c22_specials: Final[set[int]]
+c6_set: Final[set[int]]
+c7_set: Final[set[int]]
+c8_set: Final[set[int]]
+c9_set: Final[set[int]]
def in_table_a1(code: str) -> bool: ...
def in_table_b1(code: str) -> bool: ...
diff --git a/python/helpers/typeshed/stdlib/sunau.pyi b/python/helpers/typeshed/stdlib/sunau.pyi
index d81645cb5687..f83a0a4c520e 100644
--- a/python/helpers/typeshed/stdlib/sunau.pyi
+++ b/python/helpers/typeshed/stdlib/sunau.pyi
@@ -1,25 +1,25 @@
from _typeshed import Unused
-from typing import IO, Any, Literal, NamedTuple, NoReturn, overload
+from typing import IO, Any, Final, Literal, NamedTuple, NoReturn, overload
from typing_extensions import Self, TypeAlias
_File: TypeAlias = str | IO[bytes]
class Error(Exception): ...
-AUDIO_FILE_MAGIC: int
-AUDIO_FILE_ENCODING_MULAW_8: int
-AUDIO_FILE_ENCODING_LINEAR_8: int
-AUDIO_FILE_ENCODING_LINEAR_16: int
-AUDIO_FILE_ENCODING_LINEAR_24: int
-AUDIO_FILE_ENCODING_LINEAR_32: int
-AUDIO_FILE_ENCODING_FLOAT: int
-AUDIO_FILE_ENCODING_DOUBLE: int
-AUDIO_FILE_ENCODING_ADPCM_G721: int
-AUDIO_FILE_ENCODING_ADPCM_G722: int
-AUDIO_FILE_ENCODING_ADPCM_G723_3: int
-AUDIO_FILE_ENCODING_ADPCM_G723_5: int
-AUDIO_FILE_ENCODING_ALAW_8: int
-AUDIO_UNKNOWN_SIZE: int
+AUDIO_FILE_MAGIC: Final = 0x2E736E64
+AUDIO_FILE_ENCODING_MULAW_8: Final = 1
+AUDIO_FILE_ENCODING_LINEAR_8: Final = 2
+AUDIO_FILE_ENCODING_LINEAR_16: Final = 3
+AUDIO_FILE_ENCODING_LINEAR_24: Final = 4
+AUDIO_FILE_ENCODING_LINEAR_32: Final = 5
+AUDIO_FILE_ENCODING_FLOAT: Final = 6
+AUDIO_FILE_ENCODING_DOUBLE: Final = 7
+AUDIO_FILE_ENCODING_ADPCM_G721: Final = 23
+AUDIO_FILE_ENCODING_ADPCM_G722: Final = 24
+AUDIO_FILE_ENCODING_ADPCM_G723_3: Final = 25
+AUDIO_FILE_ENCODING_ADPCM_G723_5: Final = 26
+AUDIO_FILE_ENCODING_ALAW_8: Final = 27
+AUDIO_UNKNOWN_SIZE: Final = 0xFFFFFFFF
class _sunau_params(NamedTuple):
nchannels: int
diff --git a/python/helpers/typeshed/stdlib/symbol.pyi b/python/helpers/typeshed/stdlib/symbol.pyi
index 48ae3567a1a5..5344ce504c6c 100644
--- a/python/helpers/typeshed/stdlib/symbol.pyi
+++ b/python/helpers/typeshed/stdlib/symbol.pyi
@@ -1,93 +1,95 @@
-single_input: int
-file_input: int
-eval_input: int
-decorator: int
-decorators: int
-decorated: int
-async_funcdef: int
-funcdef: int
-parameters: int
-typedargslist: int
-tfpdef: int
-varargslist: int
-vfpdef: int
-stmt: int
-simple_stmt: int
-small_stmt: int
-expr_stmt: int
-annassign: int
-testlist_star_expr: int
-augassign: int
-del_stmt: int
-pass_stmt: int
-flow_stmt: int
-break_stmt: int
-continue_stmt: int
-return_stmt: int
-yield_stmt: int
-raise_stmt: int
-import_stmt: int
-import_name: int
-import_from: int
-import_as_name: int
-dotted_as_name: int
-import_as_names: int
-dotted_as_names: int
-dotted_name: int
-global_stmt: int
-nonlocal_stmt: int
-assert_stmt: int
-compound_stmt: int
-async_stmt: int
-if_stmt: int
-while_stmt: int
-for_stmt: int
-try_stmt: int
-with_stmt: int
-with_item: int
-except_clause: int
-suite: int
-test: int
-test_nocond: int
-lambdef: int
-lambdef_nocond: int
-or_test: int
-and_test: int
-not_test: int
-comparison: int
-comp_op: int
-star_expr: int
-expr: int
-xor_expr: int
-and_expr: int
-shift_expr: int
-arith_expr: int
-term: int
-factor: int
-power: int
-atom_expr: int
-atom: int
-testlist_comp: int
-trailer: int
-subscriptlist: int
-subscript: int
-sliceop: int
-exprlist: int
-testlist: int
-dictorsetmaker: int
-classdef: int
-arglist: int
-argument: int
-comp_iter: int
-comp_for: int
-comp_if: int
-encoding_decl: int
-yield_expr: int
-yield_arg: int
-sync_comp_for: int
-func_body_suite: int
-func_type: int
-func_type_input: int
-namedexpr_test: int
-typelist: int
-sym_name: dict[int, str]
+from typing import Final
+
+single_input: Final[int]
+file_input: Final[int]
+eval_input: Final[int]
+decorator: Final[int]
+decorators: Final[int]
+decorated: Final[int]
+async_funcdef: Final[int]
+funcdef: Final[int]
+parameters: Final[int]
+typedargslist: Final[int]
+tfpdef: Final[int]
+varargslist: Final[int]
+vfpdef: Final[int]
+stmt: Final[int]
+simple_stmt: Final[int]
+small_stmt: Final[int]
+expr_stmt: Final[int]
+annassign: Final[int]
+testlist_star_expr: Final[int]
+augassign: Final[int]
+del_stmt: Final[int]
+pass_stmt: Final[int]
+flow_stmt: Final[int]
+break_stmt: Final[int]
+continue_stmt: Final[int]
+return_stmt: Final[int]
+yield_stmt: Final[int]
+raise_stmt: Final[int]
+import_stmt: Final[int]
+import_name: Final[int]
+import_from: Final[int]
+import_as_name: Final[int]
+dotted_as_name: Final[int]
+import_as_names: Final[int]
+dotted_as_names: Final[int]
+dotted_name: Final[int]
+global_stmt: Final[int]
+nonlocal_stmt: Final[int]
+assert_stmt: Final[int]
+compound_stmt: Final[int]
+async_stmt: Final[int]
+if_stmt: Final[int]
+while_stmt: Final[int]
+for_stmt: Final[int]
+try_stmt: Final[int]
+with_stmt: Final[int]
+with_item: Final[int]
+except_clause: Final[int]
+suite: Final[int]
+test: Final[int]
+test_nocond: Final[int]
+lambdef: Final[int]
+lambdef_nocond: Final[int]
+or_test: Final[int]
+and_test: Final[int]
+not_test: Final[int]
+comparison: Final[int]
+comp_op: Final[int]
+star_expr: Final[int]
+expr: Final[int]
+xor_expr: Final[int]
+and_expr: Final[int]
+shift_expr: Final[int]
+arith_expr: Final[int]
+term: Final[int]
+factor: Final[int]
+power: Final[int]
+atom_expr: Final[int]
+atom: Final[int]
+testlist_comp: Final[int]
+trailer: Final[int]
+subscriptlist: Final[int]
+subscript: Final[int]
+sliceop: Final[int]
+exprlist: Final[int]
+testlist: Final[int]
+dictorsetmaker: Final[int]
+classdef: Final[int]
+arglist: Final[int]
+argument: Final[int]
+comp_iter: Final[int]
+comp_for: Final[int]
+comp_if: Final[int]
+encoding_decl: Final[int]
+yield_expr: Final[int]
+yield_arg: Final[int]
+sync_comp_for: Final[int]
+func_body_suite: Final[int]
+func_type: Final[int]
+func_type_input: Final[int]
+namedexpr_test: Final[int]
+typelist: Final[int]
+sym_name: Final[dict[int, str]]
diff --git a/python/helpers/typeshed/stdlib/symtable.pyi b/python/helpers/typeshed/stdlib/symtable.pyi
index d5f2be04b600..a727b878688e 100644
--- a/python/helpers/typeshed/stdlib/symtable.pyi
+++ b/python/helpers/typeshed/stdlib/symtable.pyi
@@ -49,8 +49,11 @@ class Function(SymbolTable):
def get_nonlocals(self) -> tuple[str, ...]: ...
class Class(SymbolTable):
- @deprecated("deprecated in Python 3.14, will be removed in Python 3.16")
- def get_methods(self) -> tuple[str, ...]: ...
+ if sys.version_info >= (3, 14):
+ @deprecated("Deprecated since Python 3.14; will be removed in Python 3.16.")
+ def get_methods(self) -> tuple[str, ...]: ...
+ else:
+ def get_methods(self) -> tuple[str, ...]: ...
class Symbol:
def __init__(
diff --git a/python/helpers/typeshed/stdlib/sys/__init__.pyi b/python/helpers/typeshed/stdlib/sys/__init__.pyi
index ce06551f975a..7807b0eab01f 100644
--- a/python/helpers/typeshed/stdlib/sys/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/sys/__init__.pyi
@@ -6,7 +6,7 @@ from collections.abc import AsyncGenerator, Callable, Sequence
from io import TextIOWrapper
from types import FrameType, ModuleType, TracebackType
from typing import Any, Final, Literal, NoReturn, Protocol, TextIO, TypeVar, final, type_check_only
-from typing_extensions import LiteralString, TypeAlias
+from typing_extensions import LiteralString, TypeAlias, deprecated
_T = TypeVar("_T")
@@ -181,6 +181,14 @@ class _flags(_UninstantiableStructseq, tuple[int, ...]):
if sys.version_info >= (3, 11):
@property
def safe_path(self) -> bool: ...
+ if sys.version_info >= (3, 13):
+ @property
+ def gil(self) -> Literal[0, 1]: ...
+ if sys.version_info >= (3, 14):
+ @property
+ def thread_inherit_context(self) -> Literal[0, 1]: ...
+ @property
+ def context_aware_warnings(self) -> Literal[0, 1]: ...
# Whether or not this exists on lower versions of Python
# may depend on which patch release you're using
# (it was backported to all Python versions on 3.8+ as a security fix)
@@ -335,9 +343,20 @@ class _version_info(_UninstantiableStructseq, tuple[int, int, int, _ReleaseLevel
version_info: _version_info
def call_tracing(func: Callable[..., _T], args: Any, /) -> _T: ...
-def _clear_type_cache() -> None: ...
+
+if sys.version_info >= (3, 13):
+ @deprecated("Deprecated since Python 3.13. Use `_clear_internal_caches()` instead.")
+ def _clear_type_cache() -> None: ...
+
+else:
+ def _clear_type_cache() -> None: ...
+
def _current_frames() -> dict[int, FrameType]: ...
def _getframe(depth: int = 0, /) -> FrameType: ...
+
+if sys.version_info >= (3, 12):
+ def _getframemodulename(depth: int = 0) -> str | None: ...
+
def _debugmallocstats() -> None: ...
def __displayhook__(object: object, /) -> None: ...
def __excepthook__(exctype: type[BaseException], value: BaseException, traceback: TracebackType | None, /) -> None: ...
@@ -367,6 +386,7 @@ def settrace(function: TraceFunction | None, /) -> None: ...
if sys.platform == "win32":
# A tuple of length 5, even though it has more than 5 attributes.
@final
+ @type_check_only
class _WinVersion(_UninstantiableStructseq, tuple[int, int, int, int, str]):
@property
def major(self) -> int: ...
@@ -443,7 +463,14 @@ def get_asyncgen_hooks() -> _asyncgen_hooks: ...
def set_asyncgen_hooks(firstiter: _AsyncgenHook = ..., finalizer: _AsyncgenHook = ...) -> None: ...
if sys.platform == "win32":
- def _enablelegacywindowsfsencoding() -> None: ...
+ if sys.version_info >= (3, 13):
+ @deprecated(
+ "Deprecated since Python 3.13; will be removed in Python 3.16. "
+ "Use the `PYTHONLEGACYWINDOWSFSENCODING` environment variable instead."
+ )
+ def _enablelegacywindowsfsencoding() -> None: ...
+ else:
+ def _enablelegacywindowsfsencoding() -> None: ...
def get_coroutine_origin_tracking_depth() -> int: ...
def set_coroutine_origin_tracking_depth(depth: int) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/sys/_monitoring.pyi b/python/helpers/typeshed/stdlib/sys/_monitoring.pyi
index 0507eeedc26d..5d231c7a93b3 100644
--- a/python/helpers/typeshed/stdlib/sys/_monitoring.pyi
+++ b/python/helpers/typeshed/stdlib/sys/_monitoring.pyi
@@ -5,40 +5,52 @@
# of being a `types.ModuleType` instance that cannot be directly imported,
# and exists in the `sys`-module namespace despite `sys` not being a package.
+import sys
from collections.abc import Callable
from types import CodeType
-from typing import Any
+from typing import Any, Final, type_check_only
+from typing_extensions import deprecated
-DEBUGGER_ID: int
-COVERAGE_ID: int
-PROFILER_ID: int
-OPTIMIZER_ID: int
+DEBUGGER_ID: Final = 0
+COVERAGE_ID: Final = 1
+PROFILER_ID: Final = 2
+OPTIMIZER_ID: Final = 5
def use_tool_id(tool_id: int, name: str, /) -> None: ...
def free_tool_id(tool_id: int, /) -> None: ...
def get_tool(tool_id: int, /) -> str | None: ...
-events: _events
+events: Final[_events]
+@type_check_only
class _events:
- BRANCH: int
- CALL: int
- C_RAISE: int
- C_RETURN: int
- EXCEPTION_HANDLED: int
- INSTRUCTION: int
- JUMP: int
- LINE: int
- NO_EVENTS: int
- PY_RESUME: int
- PY_RETURN: int
- PY_START: int
- PY_THROW: int
- PY_UNWIND: int
- PY_YIELD: int
- RAISE: int
- RERAISE: int
- STOP_ITERATION: int
+ CALL: Final[int]
+ C_RAISE: Final[int]
+ C_RETURN: Final[int]
+ EXCEPTION_HANDLED: Final[int]
+ INSTRUCTION: Final[int]
+ JUMP: Final[int]
+ LINE: Final[int]
+ NO_EVENTS: Final[int]
+ PY_RESUME: Final[int]
+ PY_RETURN: Final[int]
+ PY_START: Final[int]
+ PY_THROW: Final[int]
+ PY_UNWIND: Final[int]
+ PY_YIELD: Final[int]
+ RAISE: Final[int]
+ RERAISE: Final[int]
+ STOP_ITERATION: Final[int]
+ if sys.version_info >= (3, 14):
+ BRANCH_LEFT: Final[int]
+ BRANCH_TAKEN: Final[int]
+
+ @property
+ @deprecated("Deprecated since Python 3.14. Use `BRANCH_LEFT` or `BRANCH_TAKEN` instead.")
+ def BRANCH(self) -> int: ...
+
+ else:
+ BRANCH: Final[int]
def get_events(tool_id: int, /) -> int: ...
def set_events(tool_id: int, event_set: int, /) -> None: ...
@@ -46,7 +58,7 @@ def get_local_events(tool_id: int, code: CodeType, /) -> int: ...
def set_local_events(tool_id: int, code: CodeType, event_set: int, /) -> int: ...
def restart_events() -> None: ...
-DISABLE: object
-MISSING: object
+DISABLE: Final[object]
+MISSING: Final[object]
def register_callback(tool_id: int, event: int, func: Callable[..., Any] | None, /) -> Callable[..., Any] | None: ...
diff --git a/python/helpers/typeshed/stdlib/tarfile.pyi b/python/helpers/typeshed/stdlib/tarfile.pyi
index a18ef0b823f9..7206445313dc 100644
--- a/python/helpers/typeshed/stdlib/tarfile.pyi
+++ b/python/helpers/typeshed/stdlib/tarfile.pyi
@@ -6,9 +6,12 @@ from builtins import list as _list # aliases to avoid name clashes with fields
from collections.abc import Callable, Iterable, Iterator, Mapping
from gzip import _ReadableFileobj as _GzipReadableFileobj, _WritableFileobj as _GzipWritableFileobj
from types import TracebackType
-from typing import IO, ClassVar, Literal, Protocol, overload
+from typing import IO, ClassVar, Final, Literal, Protocol, overload, type_check_only
from typing_extensions import Self, TypeAlias, deprecated
+if sys.version_info >= (3, 14):
+ from compression.zstd import ZstdDict
+
__all__ = [
"TarFile",
"TarInfo",
@@ -44,6 +47,7 @@ if sys.version_info >= (3, 13):
_FilterFunction: TypeAlias = Callable[[TarInfo, str], TarInfo | None]
_TarfileFilter: TypeAlias = Literal["fully_trusted", "tar", "data"] | _FilterFunction
+@type_check_only
class _Fileobj(Protocol):
def read(self, size: int, /) -> bytes: ...
def write(self, b: bytes, /) -> object: ...
@@ -54,58 +58,61 @@ class _Fileobj(Protocol):
# name: str | bytes
# mode: Literal["rb", "r+b", "wb", "xb"]
+@type_check_only
class _Bz2ReadableFileobj(bz2._ReadableFileobj):
def close(self) -> object: ...
+@type_check_only
class _Bz2WritableFileobj(bz2._WritableFileobj):
def close(self) -> object: ...
# tar constants
-NUL: bytes
-BLOCKSIZE: int
-RECORDSIZE: int
-GNU_MAGIC: bytes
-POSIX_MAGIC: bytes
+NUL: Final = b"\0"
+BLOCKSIZE: Final = 512
+RECORDSIZE: Final = 10240
+GNU_MAGIC: Final = b"ustar \0"
+POSIX_MAGIC: Final = b"ustar\x0000"
-LENGTH_NAME: int
-LENGTH_LINK: int
-LENGTH_PREFIX: int
+LENGTH_NAME: Final = 100
+LENGTH_LINK: Final = 100
+LENGTH_PREFIX: Final = 155
-REGTYPE: bytes
-AREGTYPE: bytes
-LNKTYPE: bytes
-SYMTYPE: bytes
-CONTTYPE: bytes
-BLKTYPE: bytes
-DIRTYPE: bytes
-FIFOTYPE: bytes
-CHRTYPE: bytes
+REGTYPE: Final = b"0"
+AREGTYPE: Final = b"\0"
+LNKTYPE: Final = b"1"
+SYMTYPE: Final = b"2"
+CHRTYPE: Final = b"3"
+BLKTYPE: Final = b"4"
+DIRTYPE: Final = b"5"
+FIFOTYPE: Final = b"6"
+CONTTYPE: Final = b"7"
-GNUTYPE_LONGNAME: bytes
-GNUTYPE_LONGLINK: bytes
-GNUTYPE_SPARSE: bytes
+GNUTYPE_LONGNAME: Final = b"L"
+GNUTYPE_LONGLINK: Final = b"K"
+GNUTYPE_SPARSE: Final = b"S"
-XHDTYPE: bytes
-XGLTYPE: bytes
-SOLARIS_XHDTYPE: bytes
+XHDTYPE: Final = b"x"
+XGLTYPE: Final = b"g"
+SOLARIS_XHDTYPE: Final = b"X"
-USTAR_FORMAT: int
-GNU_FORMAT: int
-PAX_FORMAT: int
-DEFAULT_FORMAT: int
+_TarFormat: TypeAlias = Literal[0, 1, 2] # does not exist at runtime
+USTAR_FORMAT: Final = 0
+GNU_FORMAT: Final = 1
+PAX_FORMAT: Final = 2
+DEFAULT_FORMAT: Final = PAX_FORMAT
# tarfile constants
-SUPPORTED_TYPES: tuple[bytes, ...]
-REGULAR_TYPES: tuple[bytes, ...]
-GNU_TYPES: tuple[bytes, ...]
-PAX_FIELDS: tuple[str, ...]
-PAX_NUMBER_FIELDS: dict[str, type]
-PAX_NAME_FIELDS: set[str]
+SUPPORTED_TYPES: Final[tuple[bytes, ...]]
+REGULAR_TYPES: Final[tuple[bytes, ...]]
+GNU_TYPES: Final[tuple[bytes, ...]]
+PAX_FIELDS: Final[tuple[str, ...]]
+PAX_NUMBER_FIELDS: Final[dict[str, type]]
+PAX_NAME_FIELDS: Final[set[str]]
-ENCODING: str
+ENCODING: Final[str]
-class ExFileObject(io.BufferedReader):
+class ExFileObject(io.BufferedReader): # undocumented
def __init__(self, tarfile: TarFile, tarinfo: TarInfo) -> None: ...
class TarFile:
@@ -113,13 +120,13 @@ class TarFile:
name: StrOrBytesPath | None
mode: Literal["r", "a", "w", "x"]
fileobj: _Fileobj | None
- format: int | None
+ format: _TarFormat | None
tarinfo: type[TarInfo]
dereference: bool | None
ignore_zeros: bool | None
encoding: str | None
errors: str
- fileobject: type[ExFileObject]
+ fileobject: type[ExFileObject] # undocumented
pax_headers: Mapping[str, str] | None
debug: int | None
errorlevel: int | None
@@ -186,6 +193,30 @@ class TarFile:
debug: int | None = ...,
errorlevel: int | None = ...,
) -> Self: ...
+ if sys.version_info >= (3, 14):
+ @overload
+ @classmethod
+ def open(
+ cls,
+ name: StrOrBytesPath | None,
+ mode: Literal["r:zst"],
+ fileobj: _Fileobj | None = None,
+ bufsize: int = 10240,
+ *,
+ format: int | None = ...,
+ tarinfo: type[TarInfo] | None = ...,
+ dereference: bool | None = ...,
+ ignore_zeros: bool | None = ...,
+ encoding: str | None = ...,
+ errors: str = ...,
+ pax_headers: Mapping[str, str] | None = ...,
+ debug: int | None = ...,
+ errorlevel: int | None = ...,
+ level: None = None,
+ options: Mapping[int, int] | None = None,
+ zstd_dict: ZstdDict | None = None,
+ ) -> Self: ...
+
@overload
@classmethod
def open(
@@ -304,12 +335,56 @@ class TarFile:
errorlevel: int | None = ...,
preset: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | None = ...,
) -> Self: ...
+ if sys.version_info >= (3, 14):
+ @overload
+ @classmethod
+ def open(
+ cls,
+ name: StrOrBytesPath | None,
+ mode: Literal["x:zst", "w:zst"],
+ fileobj: _Fileobj | None = None,
+ bufsize: int = 10240,
+ *,
+ format: int | None = ...,
+ tarinfo: type[TarInfo] | None = ...,
+ dereference: bool | None = ...,
+ ignore_zeros: bool | None = ...,
+ encoding: str | None = ...,
+ errors: str = ...,
+ pax_headers: Mapping[str, str] | None = ...,
+ debug: int | None = ...,
+ errorlevel: int | None = ...,
+ options: Mapping[int, int] | None = None,
+ zstd_dict: ZstdDict | None = None,
+ ) -> Self: ...
+ @overload
+ @classmethod
+ def open(
+ cls,
+ name: StrOrBytesPath | None = None,
+ *,
+ mode: Literal["x:zst", "w:zst"],
+ fileobj: _Fileobj | None = None,
+ bufsize: int = 10240,
+ format: int | None = ...,
+ tarinfo: type[TarInfo] | None = ...,
+ dereference: bool | None = ...,
+ ignore_zeros: bool | None = ...,
+ encoding: str | None = ...,
+ errors: str = ...,
+ pax_headers: Mapping[str, str] | None = ...,
+ debug: int | None = ...,
+ errorlevel: int | None = ...,
+ options: Mapping[int, int] | None = None,
+ zstd_dict: ZstdDict | None = None,
+ ) -> Self: ...
+
@overload
@classmethod
def open(
cls,
name: StrOrBytesPath | ReadableBuffer | None,
- mode: Literal["r|*", "r|", "r|gz", "r|bz2", "r|xz"],
+ mode: Literal["r|*", "r|", "r|gz", "r|bz2", "r|xz", "r|zst"],
fileobj: _Fileobj | None = None,
bufsize: int = 10240,
*,
@@ -329,7 +404,7 @@ class TarFile:
cls,
name: StrOrBytesPath | ReadableBuffer | None = None,
*,
- mode: Literal["r|*", "r|", "r|gz", "r|bz2", "r|xz"],
+ mode: Literal["r|*", "r|", "r|gz", "r|bz2", "r|xz", "r|zst"],
fileobj: _Fileobj | None = None,
bufsize: int = 10240,
format: int | None = ...,
@@ -347,7 +422,7 @@ class TarFile:
def open(
cls,
name: StrOrBytesPath | WriteableBuffer | None,
- mode: Literal["w|", "w|xz"],
+ mode: Literal["w|", "w|xz", "w|zst"],
fileobj: _Fileobj | None = None,
bufsize: int = 10240,
*,
@@ -367,7 +442,7 @@ class TarFile:
cls,
name: StrOrBytesPath | WriteableBuffer | None = None,
*,
- mode: Literal["w|", "w|xz"],
+ mode: Literal["w|", "w|xz", "w|zst"],
fileobj: _Fileobj | None = None,
bufsize: int = 10240,
format: int | None = ...,
@@ -526,10 +601,52 @@ class TarFile:
debug: int | None = ...,
errorlevel: int | None = ...,
) -> Self: ...
+ if sys.version_info >= (3, 14):
+ @overload
+ @classmethod
+ def zstopen(
+ cls,
+ name: StrOrBytesPath | None,
+ mode: Literal["r"] = "r",
+ fileobj: IO[bytes] | None = None,
+ level: None = None,
+ options: Mapping[int, int] | None = None,
+ zstd_dict: ZstdDict | None = None,
+ *,
+ format: int | None = ...,
+ tarinfo: type[TarInfo] | None = ...,
+ dereference: bool | None = ...,
+ ignore_zeros: bool | None = ...,
+ encoding: str | None = ...,
+ pax_headers: Mapping[str, str] | None = ...,
+ debug: int | None = ...,
+ errorlevel: int | None = ...,
+ ) -> Self: ...
+ @overload
+ @classmethod
+ def zstopen(
+ cls,
+ name: StrOrBytesPath | None,
+ mode: Literal["w", "x"],
+ fileobj: IO[bytes] | None = None,
+ level: int | None = None,
+ options: Mapping[int, int] | None = None,
+ zstd_dict: ZstdDict | None = None,
+ *,
+ format: int | None = ...,
+ tarinfo: type[TarInfo] | None = ...,
+ dereference: bool | None = ...,
+ ignore_zeros: bool | None = ...,
+ encoding: str | None = ...,
+ pax_headers: Mapping[str, str] | None = ...,
+ debug: int | None = ...,
+ errorlevel: int | None = ...,
+ ) -> Self: ...
+
def getmember(self, name: str) -> TarInfo: ...
def getmembers(self) -> _list[TarInfo]: ...
def getnames(self) -> _list[str]: ...
- def list(self, verbose: bool = True, *, members: _list[TarInfo] | None = None) -> None: ...
+ def list(self, verbose: bool = True, *, members: Iterable[TarInfo] | None = None) -> None: ...
def next(self) -> TarInfo | None: ...
# Calling this method without `filter` is deprecated, but it may be set either on the class or in an
# individual call, so we can't mark it as @deprecated here.
@@ -539,7 +656,7 @@ class TarFile:
members: Iterable[TarInfo] | None = None,
*,
numeric_owner: bool = False,
- filter: _TarfileFilter | None = ...,
+ filter: _TarfileFilter | None = None,
) -> None: ...
# Same situation as for `extractall`.
def extract(
@@ -549,7 +666,7 @@ class TarFile:
set_attrs: bool = True,
*,
numeric_owner: bool = False,
- filter: _TarfileFilter | None = ...,
+ filter: _TarfileFilter | None = None,
) -> None: ...
def _extract_member(
self,
@@ -638,7 +755,7 @@ class TarInfo:
offset_data: int
sparse: bytes | None
mode: int
- type: bytes
+ type: bytes # usually one of the TYPE constants, but could be an arbitrary byte
linkname: str
uid: int
gid: int
@@ -648,10 +765,10 @@ class TarInfo:
def __init__(self, name: str = "") -> None: ...
if sys.version_info >= (3, 13):
@property
- @deprecated("Deprecated in Python 3.13; removal scheduled for Python 3.16")
+ @deprecated("Deprecated since Python 3.13; will be removed in Python 3.16.")
def tarfile(self) -> TarFile | None: ...
@tarfile.setter
- @deprecated("Deprecated in Python 3.13; removal scheduled for Python 3.16")
+ @deprecated("Deprecated since Python 3.13; will be removed in Python 3.16.")
def tarfile(self, tarfile: TarFile | None) -> None: ...
else:
tarfile: TarFile | None
@@ -678,7 +795,7 @@ class TarInfo:
deep: bool = True,
) -> Self: ...
def get_info(self) -> Mapping[str, str | int | bytes | Mapping[str, str]]: ...
- def tobuf(self, format: int | None = 2, encoding: str | None = "utf-8", errors: str = "surrogateescape") -> bytes: ...
+ def tobuf(self, format: _TarFormat | None = 2, encoding: str | None = "utf-8", errors: str = "surrogateescape") -> bytes: ...
def create_ustar_header(
self, info: Mapping[str, str | int | bytes | Mapping[str, str]], encoding: str, errors: str
) -> bytes: ...
diff --git a/python/helpers/typeshed/stdlib/telnetlib.pyi b/python/helpers/typeshed/stdlib/telnetlib.pyi
index 6b599256d17b..88aa43d24899 100644
--- a/python/helpers/typeshed/stdlib/telnetlib.pyi
+++ b/python/helpers/typeshed/stdlib/telnetlib.pyi
@@ -2,89 +2,89 @@ import socket
from collections.abc import Callable, MutableSequence, Sequence
from re import Match, Pattern
from types import TracebackType
-from typing import Any
+from typing import Any, Final
from typing_extensions import Self
__all__ = ["Telnet"]
-DEBUGLEVEL: int
-TELNET_PORT: int
+DEBUGLEVEL: Final = 0
+TELNET_PORT: Final = 23
-IAC: bytes
-DONT: bytes
-DO: bytes
-WONT: bytes
-WILL: bytes
-theNULL: bytes
+IAC: Final = b"\xff"
+DONT: Final = b"\xfe"
+DO: Final = b"\xfd"
+WONT: Final = b"\xfc"
+WILL: Final = b"\xfb"
+theNULL: Final = b"\x00"
-SE: bytes
-NOP: bytes
-DM: bytes
-BRK: bytes
-IP: bytes
-AO: bytes
-AYT: bytes
-EC: bytes
-EL: bytes
-GA: bytes
-SB: bytes
+SE: Final = b"\xf0"
+NOP: Final = b"\xf1"
+DM: Final = b"\xf2"
+BRK: Final = b"\xf3"
+IP: Final = b"\xf4"
+AO: Final = b"\xf5"
+AYT: Final = b"\xf6"
+EC: Final = b"\xf7"
+EL: Final = b"\xf8"
+GA: Final = b"\xf9"
+SB: Final = b"\xfa"
-BINARY: bytes
-ECHO: bytes
-RCP: bytes
-SGA: bytes
-NAMS: bytes
-STATUS: bytes
-TM: bytes
-RCTE: bytes
-NAOL: bytes
-NAOP: bytes
-NAOCRD: bytes
-NAOHTS: bytes
-NAOHTD: bytes
-NAOFFD: bytes
-NAOVTS: bytes
-NAOVTD: bytes
-NAOLFD: bytes
-XASCII: bytes
-LOGOUT: bytes
-BM: bytes
-DET: bytes
-SUPDUP: bytes
-SUPDUPOUTPUT: bytes
-SNDLOC: bytes
-TTYPE: bytes
-EOR: bytes
-TUID: bytes
-OUTMRK: bytes
-TTYLOC: bytes
-VT3270REGIME: bytes
-X3PAD: bytes
-NAWS: bytes
-TSPEED: bytes
-LFLOW: bytes
-LINEMODE: bytes
-XDISPLOC: bytes
-OLD_ENVIRON: bytes
-AUTHENTICATION: bytes
-ENCRYPT: bytes
-NEW_ENVIRON: bytes
+BINARY: Final = b"\x00"
+ECHO: Final = b"\x01"
+RCP: Final = b"\x02"
+SGA: Final = b"\x03"
+NAMS: Final = b"\x04"
+STATUS: Final = b"\x05"
+TM: Final = b"\x06"
+RCTE: Final = b"\x07"
+NAOL: Final = b"\x08"
+NAOP: Final = b"\t"
+NAOCRD: Final = b"\n"
+NAOHTS: Final = b"\x0b"
+NAOHTD: Final = b"\x0c"
+NAOFFD: Final = b"\r"
+NAOVTS: Final = b"\x0e"
+NAOVTD: Final = b"\x0f"
+NAOLFD: Final = b"\x10"
+XASCII: Final = b"\x11"
+LOGOUT: Final = b"\x12"
+BM: Final = b"\x13"
+DET: Final = b"\x14"
+SUPDUP: Final = b"\x15"
+SUPDUPOUTPUT: Final = b"\x16"
+SNDLOC: Final = b"\x17"
+TTYPE: Final = b"\x18"
+EOR: Final = b"\x19"
+TUID: Final = b"\x1a"
+OUTMRK: Final = b"\x1b"
+TTYLOC: Final = b"\x1c"
+VT3270REGIME: Final = b"\x1d"
+X3PAD: Final = b"\x1e"
+NAWS: Final = b"\x1f"
+TSPEED: Final = b" "
+LFLOW: Final = b"!"
+LINEMODE: Final = b'"'
+XDISPLOC: Final = b"#"
+OLD_ENVIRON: Final = b"$"
+AUTHENTICATION: Final = b"%"
+ENCRYPT: Final = b"&"
+NEW_ENVIRON: Final = b"'"
-TN3270E: bytes
-XAUTH: bytes
-CHARSET: bytes
-RSP: bytes
-COM_PORT_OPTION: bytes
-SUPPRESS_LOCAL_ECHO: bytes
-TLS: bytes
-KERMIT: bytes
-SEND_URL: bytes
-FORWARD_X: bytes
-PRAGMA_LOGON: bytes
-SSPI_LOGON: bytes
-PRAGMA_HEARTBEAT: bytes
-EXOPL: bytes
-NOOPT: bytes
+TN3270E: Final = b"("
+XAUTH: Final = b")"
+CHARSET: Final = b"*"
+RSP: Final = b"+"
+COM_PORT_OPTION: Final = b","
+SUPPRESS_LOCAL_ECHO: Final = b"-"
+TLS: Final = b"."
+KERMIT: Final = b"/"
+SEND_URL: Final = b"0"
+FORWARD_X: Final = b"1"
+PRAGMA_LOGON: Final = b"\x8a"
+SSPI_LOGON: Final = b"\x8b"
+PRAGMA_HEARTBEAT: Final = b"\x8c"
+EXOPL: Final = b"\xff"
+NOOPT: Final = b"\x00"
class Telnet:
host: str | None # undocumented
diff --git a/python/helpers/typeshed/stdlib/tempfile.pyi b/python/helpers/typeshed/stdlib/tempfile.pyi
index ea6e057e410d..26491074ff71 100644
--- a/python/helpers/typeshed/stdlib/tempfile.pyi
+++ b/python/helpers/typeshed/stdlib/tempfile.pyi
@@ -14,8 +14,8 @@ from _typeshed import (
)
from collections.abc import Iterable, Iterator
from types import GenericAlias, TracebackType
-from typing import IO, Any, AnyStr, Generic, Literal, overload
-from typing_extensions import Self
+from typing import IO, Any, AnyStr, Final, Generic, Literal, overload
+from typing_extensions import Self, deprecated
__all__ = [
"NamedTemporaryFile",
@@ -34,7 +34,7 @@ __all__ = [
]
# global variables
-TMP_MAX: int
+TMP_MAX: Final[int]
tempdir: str | None
template: str
@@ -471,6 +471,7 @@ def mkstemp(
def mkdtemp(suffix: str | None = None, prefix: str | None = None, dir: StrPath | None = None) -> str: ...
@overload
def mkdtemp(suffix: bytes | None = None, prefix: bytes | None = None, dir: BytesPath | None = None) -> bytes: ...
+@deprecated("Deprecated since Python 2.3. Use `mkstemp()` or `NamedTemporaryFile(delete=False)` instead.")
def mktemp(suffix: str = "", prefix: str = "tmp", dir: StrPath | None = None) -> str: ...
def gettempdirb() -> bytes: ...
def gettempprefixb() -> bytes: ...
diff --git a/python/helpers/typeshed/stdlib/termios.pyi b/python/helpers/typeshed/stdlib/termios.pyi
index 5a5a1f53be3c..a35be5dfe740 100644
--- a/python/helpers/typeshed/stdlib/termios.pyi
+++ b/python/helpers/typeshed/stdlib/termios.pyi
@@ -1,6 +1,6 @@
import sys
from _typeshed import FileDescriptorLike
-from typing import Any
+from typing import Any, Final
from typing_extensions import TypeAlias
# Must be a list of length 7, containing 6 ints and a list of NCCS 1-character bytes or ints.
@@ -9,286 +9,287 @@ _Attr: TypeAlias = list[int | list[bytes | int]] | list[int | list[bytes]] | lis
_AttrReturn: TypeAlias = list[Any]
if sys.platform != "win32":
- B0: int
- B110: int
- B115200: int
- B1200: int
- B134: int
- B150: int
- B1800: int
- B19200: int
- B200: int
- B230400: int
- B2400: int
- B300: int
- B38400: int
- B4800: int
- B50: int
- B57600: int
- B600: int
- B75: int
- B9600: int
- BRKINT: int
- BS0: int
- BS1: int
- BSDLY: int
- CDSUSP: int
- CEOF: int
- CEOL: int
- CEOT: int
- CERASE: int
- CFLUSH: int
- CINTR: int
- CKILL: int
- CLNEXT: int
- CLOCAL: int
- CQUIT: int
- CR0: int
- CR1: int
- CR2: int
- CR3: int
- CRDLY: int
- CREAD: int
- CRPRNT: int
- CRTSCTS: int
- CS5: int
- CS6: int
- CS7: int
- CS8: int
- CSIZE: int
- CSTART: int
- CSTOP: int
- CSTOPB: int
- CSUSP: int
- CWERASE: int
- ECHO: int
- ECHOCTL: int
- ECHOE: int
- ECHOK: int
- ECHOKE: int
- ECHONL: int
- ECHOPRT: int
- EXTA: int
- EXTB: int
- FF0: int
- FF1: int
- FFDLY: int
- FIOASYNC: int
- FIOCLEX: int
- FIONBIO: int
- FIONCLEX: int
- FIONREAD: int
- FLUSHO: int
- HUPCL: int
- ICANON: int
- ICRNL: int
- IEXTEN: int
- IGNBRK: int
- IGNCR: int
- IGNPAR: int
- IMAXBEL: int
- INLCR: int
- INPCK: int
- ISIG: int
- ISTRIP: int
- IXANY: int
- IXOFF: int
- IXON: int
- NCCS: int
- NL0: int
- NL1: int
- NLDLY: int
- NOFLSH: int
- OCRNL: int
- OFDEL: int
- OFILL: int
- ONLCR: int
- ONLRET: int
- ONOCR: int
- OPOST: int
- PARENB: int
- PARMRK: int
- PARODD: int
- PENDIN: int
- TAB0: int
- TAB1: int
- TAB2: int
- TAB3: int
- TABDLY: int
- TCIFLUSH: int
- TCIOFF: int
- TCIOFLUSH: int
- TCION: int
- TCOFLUSH: int
- TCOOFF: int
- TCOON: int
- TCSADRAIN: int
- TCSAFLUSH: int
- TCSANOW: int
- TIOCCONS: int
- TIOCEXCL: int
- TIOCGETD: int
- TIOCGPGRP: int
- TIOCGWINSZ: int
- TIOCM_CAR: int
- TIOCM_CD: int
- TIOCM_CTS: int
- TIOCM_DSR: int
- TIOCM_DTR: int
- TIOCM_LE: int
- TIOCM_RI: int
- TIOCM_RNG: int
- TIOCM_RTS: int
- TIOCM_SR: int
- TIOCM_ST: int
- TIOCMBIC: int
- TIOCMBIS: int
- TIOCMGET: int
- TIOCMSET: int
- TIOCNOTTY: int
- TIOCNXCL: int
- TIOCOUTQ: int
- TIOCPKT_DATA: int
- TIOCPKT_DOSTOP: int
- TIOCPKT_FLUSHREAD: int
- TIOCPKT_FLUSHWRITE: int
- TIOCPKT_NOSTOP: int
- TIOCPKT_START: int
- TIOCPKT_STOP: int
- TIOCPKT: int
- TIOCSCTTY: int
- TIOCSETD: int
- TIOCSPGRP: int
- TIOCSTI: int
- TIOCSWINSZ: int
- TOSTOP: int
- VDISCARD: int
- VEOF: int
- VEOL: int
- VEOL2: int
- VERASE: int
- VINTR: int
- VKILL: int
- VLNEXT: int
- VMIN: int
- VQUIT: int
- VREPRINT: int
- VSTART: int
- VSTOP: int
- VSUSP: int
- VT0: int
- VT1: int
- VTDLY: int
- VTIME: int
- VWERASE: int
+ # Values depends on the platform
+ B0: Final[int]
+ B110: Final[int]
+ B115200: Final[int]
+ B1200: Final[int]
+ B134: Final[int]
+ B150: Final[int]
+ B1800: Final[int]
+ B19200: Final[int]
+ B200: Final[int]
+ B230400: Final[int]
+ B2400: Final[int]
+ B300: Final[int]
+ B38400: Final[int]
+ B4800: Final[int]
+ B50: Final[int]
+ B57600: Final[int]
+ B600: Final[int]
+ B75: Final[int]
+ B9600: Final[int]
+ BRKINT: Final[int]
+ BS0: Final[int]
+ BS1: Final[int]
+ BSDLY: Final[int]
+ CDSUSP: Final[int]
+ CEOF: Final[int]
+ CEOL: Final[int]
+ CEOT: Final[int]
+ CERASE: Final[int]
+ CFLUSH: Final[int]
+ CINTR: Final[int]
+ CKILL: Final[int]
+ CLNEXT: Final[int]
+ CLOCAL: Final[int]
+ CQUIT: Final[int]
+ CR0: Final[int]
+ CR1: Final[int]
+ CR2: Final[int]
+ CR3: Final[int]
+ CRDLY: Final[int]
+ CREAD: Final[int]
+ CRPRNT: Final[int]
+ CRTSCTS: Final[int]
+ CS5: Final[int]
+ CS6: Final[int]
+ CS7: Final[int]
+ CS8: Final[int]
+ CSIZE: Final[int]
+ CSTART: Final[int]
+ CSTOP: Final[int]
+ CSTOPB: Final[int]
+ CSUSP: Final[int]
+ CWERASE: Final[int]
+ ECHO: Final[int]
+ ECHOCTL: Final[int]
+ ECHOE: Final[int]
+ ECHOK: Final[int]
+ ECHOKE: Final[int]
+ ECHONL: Final[int]
+ ECHOPRT: Final[int]
+ EXTA: Final[int]
+ EXTB: Final[int]
+ FF0: Final[int]
+ FF1: Final[int]
+ FFDLY: Final[int]
+ FIOASYNC: Final[int]
+ FIOCLEX: Final[int]
+ FIONBIO: Final[int]
+ FIONCLEX: Final[int]
+ FIONREAD: Final[int]
+ FLUSHO: Final[int]
+ HUPCL: Final[int]
+ ICANON: Final[int]
+ ICRNL: Final[int]
+ IEXTEN: Final[int]
+ IGNBRK: Final[int]
+ IGNCR: Final[int]
+ IGNPAR: Final[int]
+ IMAXBEL: Final[int]
+ INLCR: Final[int]
+ INPCK: Final[int]
+ ISIG: Final[int]
+ ISTRIP: Final[int]
+ IXANY: Final[int]
+ IXOFF: Final[int]
+ IXON: Final[int]
+ NCCS: Final[int]
+ NL0: Final[int]
+ NL1: Final[int]
+ NLDLY: Final[int]
+ NOFLSH: Final[int]
+ OCRNL: Final[int]
+ OFDEL: Final[int]
+ OFILL: Final[int]
+ ONLCR: Final[int]
+ ONLRET: Final[int]
+ ONOCR: Final[int]
+ OPOST: Final[int]
+ PARENB: Final[int]
+ PARMRK: Final[int]
+ PARODD: Final[int]
+ PENDIN: Final[int]
+ TAB0: Final[int]
+ TAB1: Final[int]
+ TAB2: Final[int]
+ TAB3: Final[int]
+ TABDLY: Final[int]
+ TCIFLUSH: Final[int]
+ TCIOFF: Final[int]
+ TCIOFLUSH: Final[int]
+ TCION: Final[int]
+ TCOFLUSH: Final[int]
+ TCOOFF: Final[int]
+ TCOON: Final[int]
+ TCSADRAIN: Final[int]
+ TCSAFLUSH: Final[int]
+ TCSANOW: Final[int]
+ TIOCCONS: Final[int]
+ TIOCEXCL: Final[int]
+ TIOCGETD: Final[int]
+ TIOCGPGRP: Final[int]
+ TIOCGWINSZ: Final[int]
+ TIOCM_CAR: Final[int]
+ TIOCM_CD: Final[int]
+ TIOCM_CTS: Final[int]
+ TIOCM_DSR: Final[int]
+ TIOCM_DTR: Final[int]
+ TIOCM_LE: Final[int]
+ TIOCM_RI: Final[int]
+ TIOCM_RNG: Final[int]
+ TIOCM_RTS: Final[int]
+ TIOCM_SR: Final[int]
+ TIOCM_ST: Final[int]
+ TIOCMBIC: Final[int]
+ TIOCMBIS: Final[int]
+ TIOCMGET: Final[int]
+ TIOCMSET: Final[int]
+ TIOCNOTTY: Final[int]
+ TIOCNXCL: Final[int]
+ TIOCOUTQ: Final[int]
+ TIOCPKT_DATA: Final[int]
+ TIOCPKT_DOSTOP: Final[int]
+ TIOCPKT_FLUSHREAD: Final[int]
+ TIOCPKT_FLUSHWRITE: Final[int]
+ TIOCPKT_NOSTOP: Final[int]
+ TIOCPKT_START: Final[int]
+ TIOCPKT_STOP: Final[int]
+ TIOCPKT: Final[int]
+ TIOCSCTTY: Final[int]
+ TIOCSETD: Final[int]
+ TIOCSPGRP: Final[int]
+ TIOCSTI: Final[int]
+ TIOCSWINSZ: Final[int]
+ TOSTOP: Final[int]
+ VDISCARD: Final[int]
+ VEOF: Final[int]
+ VEOL: Final[int]
+ VEOL2: Final[int]
+ VERASE: Final[int]
+ VINTR: Final[int]
+ VKILL: Final[int]
+ VLNEXT: Final[int]
+ VMIN: Final[int]
+ VQUIT: Final[int]
+ VREPRINT: Final[int]
+ VSTART: Final[int]
+ VSTOP: Final[int]
+ VSUSP: Final[int]
+ VT0: Final[int]
+ VT1: Final[int]
+ VTDLY: Final[int]
+ VTIME: Final[int]
+ VWERASE: Final[int]
if sys.version_info >= (3, 13):
- EXTPROC: int
- IUTF8: int
+ EXTPROC: Final[int]
+ IUTF8: Final[int]
if sys.platform == "darwin" and sys.version_info >= (3, 13):
- ALTWERASE: int
- B14400: int
- B28800: int
- B7200: int
- B76800: int
- CCAR_OFLOW: int
- CCTS_OFLOW: int
- CDSR_OFLOW: int
- CDTR_IFLOW: int
- CIGNORE: int
- CRTS_IFLOW: int
- MDMBUF: int
- NL2: int
- NL3: int
- NOKERNINFO: int
- ONOEOT: int
- OXTABS: int
- VDSUSP: int
- VSTATUS: int
+ ALTWERASE: Final[int]
+ B14400: Final[int]
+ B28800: Final[int]
+ B7200: Final[int]
+ B76800: Final[int]
+ CCAR_OFLOW: Final[int]
+ CCTS_OFLOW: Final[int]
+ CDSR_OFLOW: Final[int]
+ CDTR_IFLOW: Final[int]
+ CIGNORE: Final[int]
+ CRTS_IFLOW: Final[int]
+ MDMBUF: Final[int]
+ NL2: Final[int]
+ NL3: Final[int]
+ NOKERNINFO: Final[int]
+ ONOEOT: Final[int]
+ OXTABS: Final[int]
+ VDSUSP: Final[int]
+ VSTATUS: Final[int]
if sys.platform == "darwin" and sys.version_info >= (3, 11):
- TIOCGSIZE: int
- TIOCSSIZE: int
+ TIOCGSIZE: Final[int]
+ TIOCSSIZE: Final[int]
if sys.platform == "linux":
- B1152000: int
- B576000: int
- CBAUD: int
- CBAUDEX: int
- CIBAUD: int
- IOCSIZE_MASK: int
- IOCSIZE_SHIFT: int
- IUCLC: int
- N_MOUSE: int
- N_PPP: int
- N_SLIP: int
- N_STRIP: int
- N_TTY: int
- NCC: int
- OLCUC: int
- TCFLSH: int
- TCGETA: int
- TCGETS: int
- TCSBRK: int
- TCSBRKP: int
- TCSETA: int
- TCSETAF: int
- TCSETAW: int
- TCSETS: int
- TCSETSF: int
- TCSETSW: int
- TCXONC: int
- TIOCGICOUNT: int
- TIOCGLCKTRMIOS: int
- TIOCGSERIAL: int
- TIOCGSOFTCAR: int
- TIOCINQ: int
- TIOCLINUX: int
- TIOCMIWAIT: int
- TIOCTTYGSTRUCT: int
- TIOCSER_TEMT: int
- TIOCSERCONFIG: int
- TIOCSERGETLSR: int
- TIOCSERGETMULTI: int
- TIOCSERGSTRUCT: int
- TIOCSERGWILD: int
- TIOCSERSETMULTI: int
- TIOCSERSWILD: int
- TIOCSLCKTRMIOS: int
- TIOCSSERIAL: int
- TIOCSSOFTCAR: int
- VSWTC: int
- VSWTCH: int
- XCASE: int
- XTABS: int
+ B1152000: Final[int]
+ B576000: Final[int]
+ CBAUD: Final[int]
+ CBAUDEX: Final[int]
+ CIBAUD: Final[int]
+ IOCSIZE_MASK: Final[int]
+ IOCSIZE_SHIFT: Final[int]
+ IUCLC: Final[int]
+ N_MOUSE: Final[int]
+ N_PPP: Final[int]
+ N_SLIP: Final[int]
+ N_STRIP: Final[int]
+ N_TTY: Final[int]
+ NCC: Final[int]
+ OLCUC: Final[int]
+ TCFLSH: Final[int]
+ TCGETA: Final[int]
+ TCGETS: Final[int]
+ TCSBRK: Final[int]
+ TCSBRKP: Final[int]
+ TCSETA: Final[int]
+ TCSETAF: Final[int]
+ TCSETAW: Final[int]
+ TCSETS: Final[int]
+ TCSETSF: Final[int]
+ TCSETSW: Final[int]
+ TCXONC: Final[int]
+ TIOCGICOUNT: Final[int]
+ TIOCGLCKTRMIOS: Final[int]
+ TIOCGSERIAL: Final[int]
+ TIOCGSOFTCAR: Final[int]
+ TIOCINQ: Final[int]
+ TIOCLINUX: Final[int]
+ TIOCMIWAIT: Final[int]
+ TIOCTTYGSTRUCT: Final[int]
+ TIOCSER_TEMT: Final[int]
+ TIOCSERCONFIG: Final[int]
+ TIOCSERGETLSR: Final[int]
+ TIOCSERGETMULTI: Final[int]
+ TIOCSERGSTRUCT: Final[int]
+ TIOCSERGWILD: Final[int]
+ TIOCSERSETMULTI: Final[int]
+ TIOCSERSWILD: Final[int]
+ TIOCSLCKTRMIOS: Final[int]
+ TIOCSSERIAL: Final[int]
+ TIOCSSOFTCAR: Final[int]
+ VSWTC: Final[int]
+ VSWTCH: Final[int]
+ XCASE: Final[int]
+ XTABS: Final[int]
if sys.platform != "darwin":
- B1000000: int
- B1500000: int
- B2000000: int
- B2500000: int
- B3000000: int
- B3500000: int
- B4000000: int
- B460800: int
- B500000: int
- B921600: int
+ B1000000: Final[int]
+ B1500000: Final[int]
+ B2000000: Final[int]
+ B2500000: Final[int]
+ B3000000: Final[int]
+ B3500000: Final[int]
+ B4000000: Final[int]
+ B460800: Final[int]
+ B500000: Final[int]
+ B921600: Final[int]
if sys.platform != "linux":
- TCSASOFT: int
+ TCSASOFT: Final[int]
if sys.platform != "darwin" and sys.platform != "linux":
# not available on FreeBSD either.
- CDEL: int
- CEOL2: int
- CESC: int
- CNUL: int
- COMMON: int
- CSWTCH: int
- IBSHIFT: int
- INIT_C_CC: int
- NSWTCH: int
+ CDEL: Final[int]
+ CEOL2: Final[int]
+ CESC: Final[int]
+ CNUL: Final[int]
+ COMMON: Final[int]
+ CSWTCH: Final[int]
+ IBSHIFT: Final[int]
+ INIT_C_CC: Final[int]
+ NSWTCH: Final[int]
def tcgetattr(fd: FileDescriptorLike, /) -> _AttrReturn: ...
def tcsetattr(fd: FileDescriptorLike, when: int, attributes: _Attr, /) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/threading.pyi b/python/helpers/typeshed/stdlib/threading.pyi
index d31351754d05..28fa5267a997 100644
--- a/python/helpers/typeshed/stdlib/threading.pyi
+++ b/python/helpers/typeshed/stdlib/threading.pyi
@@ -5,7 +5,7 @@ from _typeshed import ProfileFunction, TraceFunction
from collections.abc import Callable, Iterable, Mapping
from contextvars import ContextVar
from types import TracebackType
-from typing import Any, TypeVar, final
+from typing import Any, Final, TypeVar, final
from typing_extensions import deprecated
_T = TypeVar("_T")
@@ -46,10 +46,10 @@ if sys.version_info >= (3, 12):
_profile_hook: ProfileFunction | None
def active_count() -> int: ...
-@deprecated("Use active_count() instead")
+@deprecated("Deprecated since Python 3.10. Use `active_count()` instead.")
def activeCount() -> int: ...
def current_thread() -> Thread: ...
-@deprecated("Use current_thread() instead")
+@deprecated("Deprecated since Python 3.10. Use `current_thread()` instead.")
def currentThread() -> Thread: ...
def get_ident() -> int: ...
def enumerate() -> list[Thread]: ...
@@ -67,7 +67,7 @@ if sys.version_info >= (3, 10):
def stack_size(size: int = 0, /) -> int: ...
-TIMEOUT_MAX: float
+TIMEOUT_MAX: Final[float]
ThreadError = _thread.error
local = _thread._local
@@ -107,13 +107,13 @@ class Thread:
@property
def native_id(self) -> int | None: ... # only available on some platforms
def is_alive(self) -> bool: ...
- @deprecated("Get the daemon attribute instead")
+ @deprecated("Deprecated since Python 3.10. Read the `daemon` attribute instead.")
def isDaemon(self) -> bool: ...
- @deprecated("Set the daemon attribute instead")
+ @deprecated("Deprecated since Python 3.10. Set the `daemon` attribute instead.")
def setDaemon(self, daemonic: bool) -> None: ...
- @deprecated("Use the name attribute instead")
+ @deprecated("Deprecated since Python 3.10. Read the `name` attribute instead.")
def getName(self) -> str: ...
- @deprecated("Use the name attribute instead")
+ @deprecated("Deprecated since Python 3.10. Set the `name` attribute instead.")
def setName(self, name: str) -> None: ...
class _DummyThread(Thread):
@@ -142,13 +142,13 @@ class Condition:
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
- def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
+ def acquire(self, blocking: bool = True, timeout: float = -1) -> 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: ...
- @deprecated("Use notify_all() instead")
+ @deprecated("Deprecated since Python 3.10. Use `notify_all()` instead.")
def notifyAll(self) -> None: ...
class Semaphore:
@@ -163,7 +163,7 @@ class BoundedSemaphore(Semaphore): ...
class Event:
def is_set(self) -> bool: ...
- @deprecated("Use is_set() instead")
+ @deprecated("Deprecated since Python 3.10. Use `is_set()` instead.")
def isSet(self) -> bool: ...
def set(self) -> None: ...
def clear(self) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/time.pyi b/python/helpers/typeshed/stdlib/time.pyi
index 6d2538ea7e3e..5665efbba69d 100644
--- a/python/helpers/typeshed/stdlib/time.pyi
+++ b/python/helpers/typeshed/stdlib/time.pyi
@@ -1,6 +1,6 @@
import sys
from _typeshed import structseq
-from typing import Any, Final, Literal, Protocol, final
+from typing import Any, Final, Literal, Protocol, final, type_check_only
from typing_extensions import TypeAlias
_TimeTuple: TypeAlias = tuple[int, int, int, int, int, int, int, int, int]
@@ -11,28 +11,28 @@ timezone: int
tzname: tuple[str, str]
if sys.platform == "linux":
- CLOCK_BOOTTIME: int
+ CLOCK_BOOTTIME: Final[int]
if sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin":
- CLOCK_PROF: int # FreeBSD, NetBSD, OpenBSD
- CLOCK_UPTIME: int # FreeBSD, OpenBSD
+ CLOCK_PROF: Final[int] # FreeBSD, NetBSD, OpenBSD
+ CLOCK_UPTIME: Final[int] # FreeBSD, OpenBSD
if sys.platform != "win32":
- CLOCK_MONOTONIC: int
- CLOCK_MONOTONIC_RAW: int
- CLOCK_PROCESS_CPUTIME_ID: int
- CLOCK_REALTIME: int
- CLOCK_THREAD_CPUTIME_ID: int
+ CLOCK_MONOTONIC: Final[int]
+ CLOCK_MONOTONIC_RAW: Final[int]
+ CLOCK_PROCESS_CPUTIME_ID: Final[int]
+ CLOCK_REALTIME: Final[int]
+ CLOCK_THREAD_CPUTIME_ID: Final[int]
if sys.platform != "linux" and sys.platform != "darwin":
- CLOCK_HIGHRES: int # Solaris only
+ CLOCK_HIGHRES: Final[int] # Solaris only
if sys.platform == "darwin":
- CLOCK_UPTIME_RAW: int
+ CLOCK_UPTIME_RAW: Final[int]
if sys.version_info >= (3, 13):
- CLOCK_UPTIME_RAW_APPROX: int
- CLOCK_MONOTONIC_RAW_APPROX: int
+ CLOCK_UPTIME_RAW_APPROX: Final[int]
+ CLOCK_MONOTONIC_RAW_APPROX: Final[int]
if sys.platform == "linux":
- CLOCK_TAI: int
+ CLOCK_TAI: Final[int]
# Constructor takes an iterable of any type, of length between 9 and 11 elements.
# However, it always *behaves* like a tuple of 9 elements,
@@ -80,6 +80,7 @@ def time() -> float: ...
if sys.platform != "win32":
def tzset() -> None: ... # Unix only
+@type_check_only
class _ClockInfo(Protocol):
adjustable: bool
implementation: str
diff --git a/python/helpers/typeshed/stdlib/tkinter/__init__.pyi b/python/helpers/typeshed/stdlib/tkinter/__init__.pyi
index db0e34d737a6..060f8ad2dbd6 100644
--- a/python/helpers/typeshed/stdlib/tkinter/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/tkinter/__init__.pyi
@@ -5,7 +5,7 @@ from collections.abc import Callable, Iterable, Mapping, Sequence
from tkinter.constants import *
from tkinter.font import _FontDescription
from types import GenericAlias, TracebackType
-from typing import Any, ClassVar, Generic, Literal, NamedTuple, Protocol, TypedDict, TypeVar, overload, type_check_only
+from typing import Any, ClassVar, Final, Generic, Literal, NamedTuple, Protocol, TypedDict, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias, TypeVarTuple, Unpack, deprecated
if sys.version_info >= (3, 11):
@@ -153,11 +153,11 @@ __all__ = [
TclError = _tkinter.TclError
wantobjects: int
-TkVersion: float
-TclVersion: float
-READABLE = _tkinter.READABLE
-WRITABLE = _tkinter.WRITABLE
-EXCEPTION = _tkinter.EXCEPTION
+TkVersion: Final[float]
+TclVersion: Final[float]
+READABLE: Final = _tkinter.READABLE
+WRITABLE: Final = _tkinter.WRITABLE
+EXCEPTION: Final = _tkinter.EXCEPTION
# Quick guide for figuring out which widget class to choose:
# - Misc: any widget (don't use BaseWidget because Tk doesn't inherit from BaseWidget)
@@ -321,14 +321,21 @@ class Variable:
def trace_add(self, mode: Literal["array", "read", "write", "unset"], callback: Callable[[str, str, str], object]) -> str: ...
def trace_remove(self, mode: Literal["array", "read", "write", "unset"], cbname: str) -> None: ...
def trace_info(self) -> list[tuple[tuple[Literal["array", "read", "write", "unset"], ...], str]]: ...
- @deprecated("use trace_add() instead of trace()")
- def trace(self, mode, callback): ...
- @deprecated("use trace_add() instead of trace_variable()")
- def trace_variable(self, mode, callback): ...
- @deprecated("use trace_remove() instead of trace_vdelete()")
- def trace_vdelete(self, mode, cbname) -> None: ...
- @deprecated("use trace_info() instead of trace_vinfo()")
- def trace_vinfo(self): ...
+ if sys.version_info >= (3, 14):
+ @deprecated("Deprecated since Python 3.14. Use `trace_add()` instead.")
+ def trace(self, mode, callback) -> str: ...
+ @deprecated("Deprecated since Python 3.14. Use `trace_add()` instead.")
+ def trace_variable(self, mode, callback) -> str: ...
+ @deprecated("Deprecated since Python 3.14. Use `trace_remove()` instead.")
+ def trace_vdelete(self, mode, cbname) -> None: ...
+ @deprecated("Deprecated since Python 3.14. Use `trace_info()` instead.")
+ def trace_vinfo(self): ...
+ else:
+ def trace(self, mode, callback) -> str: ...
+ def trace_variable(self, mode, callback) -> str: ...
+ def trace_vdelete(self, mode, cbname) -> None: ...
+ def trace_vinfo(self): ...
+
def __eq__(self, other: object) -> bool: ...
def __del__(self) -> None: ...
__hash__: ClassVar[None] # type: ignore[assignment]
@@ -359,19 +366,21 @@ class BooleanVar(Variable):
def mainloop(n: int = 0) -> None: ...
-getint: Incomplete
-getdouble: Incomplete
+getint = int
+getdouble = float
def getboolean(s): ...
_Ts = TypeVarTuple("_Ts")
+@type_check_only
class _GridIndexInfo(TypedDict, total=False):
minsize: _ScreenUnits
pad: _ScreenUnits
uniform: str | None
weight: int
+@type_check_only
class _BusyInfo(TypedDict):
cursor: _Cursor
@@ -1027,6 +1036,7 @@ class Tk(Misc, Wm):
def loadtk(self) -> None: ...
def record(self, script, /): ...
if sys.version_info < (3, 11):
+ @deprecated("Deprecated since Python 3.9; removed in Python 3.11. Use `splitlist()` instead.")
def split(self, arg, /): ...
def splitlist(self, arg, /): ...
@@ -1039,6 +1049,7 @@ def Tcl(screenName: str | None = None, baseName: str | None = None, className: s
_InMiscTotal = TypedDict("_InMiscTotal", {"in": Misc})
_InMiscNonTotal = TypedDict("_InMiscNonTotal", {"in": Misc}, total=False)
+@type_check_only
class _PackInfo(_InMiscTotal):
# 'before' and 'after' never appear in _PackInfo
anchor: _Anchor
@@ -1080,6 +1091,7 @@ class Pack:
forget = pack_forget
propagate = Misc.pack_propagate
+@type_check_only
class _PlaceInfo(_InMiscNonTotal): # empty dict if widget hasn't been placed
anchor: _Anchor
bordermode: Literal["inside", "outside", "ignore"]
@@ -1116,6 +1128,7 @@ class Place:
place = place_configure
info = place_info
+@type_check_only
class _GridInfo(_InMiscNonTotal): # empty dict if widget hasn't been gridded
column: int
columnspan: int
diff --git a/python/helpers/typeshed/stdlib/tkinter/commondialog.pyi b/python/helpers/typeshed/stdlib/tkinter/commondialog.pyi
index d5fc2f05ceec..6dba6bd60928 100644
--- a/python/helpers/typeshed/stdlib/tkinter/commondialog.pyi
+++ b/python/helpers/typeshed/stdlib/tkinter/commondialog.pyi
@@ -1,12 +1,14 @@
-from _typeshed import Incomplete
from collections.abc import Mapping
-from typing import ClassVar
+from tkinter import Misc
+from typing import Any, ClassVar
__all__ = ["Dialog"]
class Dialog:
command: ClassVar[str | None]
- master: Incomplete | None
- options: Mapping[str, Incomplete]
- def __init__(self, master=None, **options) -> None: ...
- def show(self, **options): ...
+ master: Misc | None
+ # Types of options are very dynamic. They depend on the command and are
+ # sometimes changed to a different type.
+ options: Mapping[str, Any]
+ def __init__(self, master: Misc | None = None, **options: Any) -> None: ...
+ def show(self, **options: Any) -> Any: ...
diff --git a/python/helpers/typeshed/stdlib/tkinter/dnd.pyi b/python/helpers/typeshed/stdlib/tkinter/dnd.pyi
index fe2961701c61..521f451a9b2c 100644
--- a/python/helpers/typeshed/stdlib/tkinter/dnd.pyi
+++ b/python/helpers/typeshed/stdlib/tkinter/dnd.pyi
@@ -1,8 +1,9 @@
from tkinter import Event, Misc, Tk, Widget
-from typing import ClassVar, Protocol
+from typing import ClassVar, Protocol, type_check_only
__all__ = ["dnd_start", "DndHandler"]
+@type_check_only
class _DndSource(Protocol):
def dnd_end(self, target: Widget | None, event: Event[Misc] | None, /) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/tkinter/filedialog.pyi b/python/helpers/typeshed/stdlib/tkinter/filedialog.pyi
index af033dae97c3..b6ef8f45d035 100644
--- a/python/helpers/typeshed/stdlib/tkinter/filedialog.pyi
+++ b/python/helpers/typeshed/stdlib/tkinter/filedialog.pyi
@@ -1,6 +1,6 @@
-from _typeshed import Incomplete, StrOrBytesPath
-from collections.abc import Iterable
-from tkinter import Button, Entry, Frame, Listbox, Misc, Scrollbar, StringVar, Toplevel, commondialog
+from _typeshed import Incomplete, StrOrBytesPath, StrPath
+from collections.abc import Hashable, Iterable
+from tkinter import Button, Entry, Event, Frame, Listbox, Misc, Scrollbar, StringVar, Toplevel, commondialog
from typing import IO, ClassVar, Literal
__all__ = [
@@ -19,12 +19,12 @@ __all__ = [
"askdirectory",
]
-dialogstates: dict[Incomplete, tuple[Incomplete, Incomplete]]
+dialogstates: dict[Hashable, tuple[str, str]]
class FileDialog:
title: str
- master: Incomplete
- directory: Incomplete | None
+ master: Misc
+ directory: str | None
top: Toplevel
botframe: Frame
selection: Entry
@@ -38,23 +38,23 @@ class FileDialog:
filter_button: Button
cancel_button: Button
def __init__(
- self, master, title=None
+ self, master: Misc, title: str | None = None
) -> None: ... # title is usually a str or None, but e.g. int doesn't raise en exception either
- how: Incomplete | None
- def go(self, dir_or_file=".", pattern: str = "*", default: str = "", key=None): ...
- def quit(self, how=None) -> None: ...
- def dirs_double_event(self, event) -> None: ...
- def dirs_select_event(self, event) -> None: ...
- def files_double_event(self, event) -> None: ...
- def files_select_event(self, event) -> None: ...
- def ok_event(self, event) -> None: ...
+ how: str | None
+ def go(self, dir_or_file: StrPath = ".", pattern: StrPath = "*", default: StrPath = "", key: Hashable | None = None): ...
+ def quit(self, how: str | None = None) -> None: ...
+ def dirs_double_event(self, event: Event) -> None: ...
+ def dirs_select_event(self, event: Event) -> None: ...
+ def files_double_event(self, event: Event) -> None: ...
+ def files_select_event(self, event: Event) -> None: ...
+ def ok_event(self, event: Event) -> None: ...
def ok_command(self) -> None: ...
- def filter_command(self, event=None) -> None: ...
- def get_filter(self): ...
- def get_selection(self): ...
- def cancel_command(self, event=None) -> None: ...
- def set_filter(self, dir, pat) -> None: ...
- def set_selection(self, file) -> None: ...
+ def filter_command(self, event: Event | None = None) -> None: ...
+ def get_filter(self) -> tuple[str, str]: ...
+ def get_selection(self) -> str: ...
+ def cancel_command(self, event: Event | None = None) -> None: ...
+ def set_filter(self, dir: StrPath, pat: StrPath) -> None: ...
+ def set_selection(self, file: StrPath) -> None: ...
class LoadFileDialog(FileDialog):
title: str
diff --git a/python/helpers/typeshed/stdlib/tkinter/font.pyi b/python/helpers/typeshed/stdlib/tkinter/font.pyi
index cab97490be34..327ba7a2432e 100644
--- a/python/helpers/typeshed/stdlib/tkinter/font.pyi
+++ b/python/helpers/typeshed/stdlib/tkinter/font.pyi
@@ -2,7 +2,7 @@ import _tkinter
import itertools
import sys
import tkinter
-from typing import Any, ClassVar, Final, Literal, TypedDict, overload
+from typing import Any, ClassVar, Final, Literal, TypedDict, overload, type_check_only
from typing_extensions import TypeAlias, Unpack
__all__ = ["NORMAL", "ROMAN", "BOLD", "ITALIC", "nametofont", "Font", "families", "names"]
@@ -23,6 +23,7 @@ _FontDescription: TypeAlias = (
| _tkinter.Tcl_Obj # A font object constructed in Tcl
)
+@type_check_only
class _FontDict(TypedDict):
family: str
size: int
@@ -31,6 +32,7 @@ class _FontDict(TypedDict):
underline: bool
overstrike: bool
+@type_check_only
class _MetricsDict(TypedDict):
ascent: int
descent: int
diff --git a/python/helpers/typeshed/stdlib/tkinter/messagebox.pyi b/python/helpers/typeshed/stdlib/tkinter/messagebox.pyi
index 902fab62ac05..cd95f0de5f80 100644
--- a/python/helpers/typeshed/stdlib/tkinter/messagebox.pyi
+++ b/python/helpers/typeshed/stdlib/tkinter/messagebox.pyi
@@ -1,5 +1,6 @@
+from tkinter import Misc
from tkinter.commondialog import Dialog
-from typing import ClassVar, Final
+from typing import ClassVar, Final, Literal
__all__ = ["showinfo", "showwarning", "showerror", "askquestion", "askokcancel", "askyesno", "askyesnocancel", "askretrycancel"]
@@ -23,11 +24,75 @@ NO: Final = "no"
class Message(Dialog):
command: ClassVar[str]
-def showinfo(title: str | None = None, message: str | None = None, **options) -> str: ...
-def showwarning(title: str | None = None, message: str | None = None, **options) -> str: ...
-def showerror(title: str | None = None, message: str | None = None, **options) -> str: ...
-def askquestion(title: str | None = None, message: str | None = None, **options) -> str: ...
-def askokcancel(title: str | None = None, message: str | None = None, **options) -> bool: ...
-def askyesno(title: str | None = None, message: str | None = None, **options) -> bool: ...
-def askyesnocancel(title: str | None = None, message: str | None = None, **options) -> bool | None: ...
-def askretrycancel(title: str | None = None, message: str | None = None, **options) -> bool: ...
+def showinfo(
+ title: str | None = None,
+ message: str | None = None,
+ *,
+ detail: str = ...,
+ icon: Literal["error", "info", "question", "warning"] = ...,
+ default: Literal["ok"] = "ok",
+ parent: Misc = ...,
+) -> str: ...
+def showwarning(
+ title: str | None = None,
+ message: str | None = None,
+ *,
+ detail: str = ...,
+ icon: Literal["error", "info", "question", "warning"] = ...,
+ default: Literal["ok"] = "ok",
+ parent: Misc = ...,
+) -> str: ...
+def showerror(
+ title: str | None = None,
+ message: str | None = None,
+ *,
+ detail: str = ...,
+ icon: Literal["error", "info", "question", "warning"] = ...,
+ default: Literal["ok"] = "ok",
+ parent: Misc = ...,
+) -> str: ...
+def askquestion(
+ title: str | None = None,
+ message: str | None = None,
+ *,
+ detail: str = ...,
+ icon: Literal["error", "info", "question", "warning"] = ...,
+ default: Literal["yes", "no"] = ...,
+ parent: Misc = ...,
+) -> str: ...
+def askokcancel(
+ title: str | None = None,
+ message: str | None = None,
+ *,
+ detail: str = ...,
+ icon: Literal["error", "info", "question", "warning"] = ...,
+ default: Literal["ok", "cancel"] = ...,
+ parent: Misc = ...,
+) -> bool: ...
+def askyesno(
+ title: str | None = None,
+ message: str | None = None,
+ *,
+ detail: str = ...,
+ icon: Literal["error", "info", "question", "warning"] = ...,
+ default: Literal["yes", "no"] = ...,
+ parent: Misc = ...,
+) -> bool: ...
+def askyesnocancel(
+ title: str | None = None,
+ message: str | None = None,
+ *,
+ detail: str = ...,
+ icon: Literal["error", "info", "question", "warning"] = ...,
+ default: Literal["cancel", "yes", "no"] = ...,
+ parent: Misc = ...,
+) -> bool | None: ...
+def askretrycancel(
+ title: str | None = None,
+ message: str | None = None,
+ *,
+ detail: str = ...,
+ icon: Literal["error", "info", "question", "warning"] = ...,
+ default: Literal["retry", "cancel"] = ...,
+ parent: Misc = ...,
+) -> bool: ...
diff --git a/python/helpers/typeshed/stdlib/tkinter/ttk.pyi b/python/helpers/typeshed/stdlib/tkinter/ttk.pyi
index 50b9cd8f9bcd..c46239df81eb 100644
--- a/python/helpers/typeshed/stdlib/tkinter/ttk.pyi
+++ b/python/helpers/typeshed/stdlib/tkinter/ttk.pyi
@@ -3,7 +3,7 @@ import tkinter
from _typeshed import Incomplete, MaybeNone
from collections.abc import Callable
from tkinter.font import _FontDescription
-from typing import Any, Literal, TypedDict, overload
+from typing import Any, Literal, TypedDict, overload, type_check_only
from typing_extensions import TypeAlias
__all__ = [
@@ -928,6 +928,7 @@ class Spinbox(Entry):
config = configure # type: ignore[assignment]
def set(self, value: Any) -> None: ...
+@type_check_only
class _TreeviewItemDict(TypedDict):
text: str
image: list[str] | Literal[""] # no idea why it's wrapped in list
@@ -935,6 +936,7 @@ class _TreeviewItemDict(TypedDict):
open: bool # actually 0 or 1
tags: list[str] | Literal[""]
+@type_check_only
class _TreeviewTagDict(TypedDict):
# There is also 'text' and 'anchor', but they don't seem to do anything, using them is likely a bug
foreground: str
@@ -942,6 +944,7 @@ class _TreeviewTagDict(TypedDict):
font: _FontDescription
image: str # not wrapped in list :D
+@type_check_only
class _TreeviewHeaderDict(TypedDict):
text: str
image: list[str] | Literal[""]
@@ -949,6 +952,7 @@ class _TreeviewHeaderDict(TypedDict):
command: str
state: str # Doesn't seem to appear anywhere else than in these dicts
+@type_check_only
class _TreeviewColumnDict(TypedDict):
width: int
minwidth: int
diff --git a/python/helpers/typeshed/stdlib/token.pyi b/python/helpers/typeshed/stdlib/token.pyi
index 7c13b15d95b7..fd1b10da1d12 100644
--- a/python/helpers/typeshed/stdlib/token.pyi
+++ b/python/helpers/typeshed/stdlib/token.pyi
@@ -1,4 +1,5 @@
import sys
+from typing import Final
__all__ = [
"AMPER",
@@ -81,87 +82,87 @@ if sys.version_info >= (3, 12):
if sys.version_info >= (3, 14):
__all__ += ["TSTRING_START", "TSTRING_MIDDLE", "TSTRING_END"]
-ENDMARKER: int
-NAME: int
-NUMBER: int
-STRING: int
-NEWLINE: int
-INDENT: int
-DEDENT: int
-LPAR: int
-RPAR: int
-LSQB: int
-RSQB: int
-COLON: int
-COMMA: int
-SEMI: int
-PLUS: int
-MINUS: int
-STAR: int
-SLASH: int
-VBAR: int
-AMPER: int
-LESS: int
-GREATER: int
-EQUAL: int
-DOT: int
-PERCENT: int
-LBRACE: int
-RBRACE: int
-EQEQUAL: int
-NOTEQUAL: int
-LESSEQUAL: int
-GREATEREQUAL: int
-TILDE: int
-CIRCUMFLEX: int
-LEFTSHIFT: int
-RIGHTSHIFT: int
-DOUBLESTAR: int
-PLUSEQUAL: int
-MINEQUAL: int
-STAREQUAL: int
-SLASHEQUAL: int
-PERCENTEQUAL: int
-AMPEREQUAL: int
-VBAREQUAL: int
-CIRCUMFLEXEQUAL: int
-LEFTSHIFTEQUAL: int
-RIGHTSHIFTEQUAL: int
-DOUBLESTAREQUAL: int
-DOUBLESLASH: int
-DOUBLESLASHEQUAL: int
-AT: int
-RARROW: int
-ELLIPSIS: int
-ATEQUAL: int
+ENDMARKER: Final[int]
+NAME: Final[int]
+NUMBER: Final[int]
+STRING: Final[int]
+NEWLINE: Final[int]
+INDENT: Final[int]
+DEDENT: Final[int]
+LPAR: Final[int]
+RPAR: Final[int]
+LSQB: Final[int]
+RSQB: Final[int]
+COLON: Final[int]
+COMMA: Final[int]
+SEMI: Final[int]
+PLUS: Final[int]
+MINUS: Final[int]
+STAR: Final[int]
+SLASH: Final[int]
+VBAR: Final[int]
+AMPER: Final[int]
+LESS: Final[int]
+GREATER: Final[int]
+EQUAL: Final[int]
+DOT: Final[int]
+PERCENT: Final[int]
+LBRACE: Final[int]
+RBRACE: Final[int]
+EQEQUAL: Final[int]
+NOTEQUAL: Final[int]
+LESSEQUAL: Final[int]
+GREATEREQUAL: Final[int]
+TILDE: Final[int]
+CIRCUMFLEX: Final[int]
+LEFTSHIFT: Final[int]
+RIGHTSHIFT: Final[int]
+DOUBLESTAR: Final[int]
+PLUSEQUAL: Final[int]
+MINEQUAL: Final[int]
+STAREQUAL: Final[int]
+SLASHEQUAL: Final[int]
+PERCENTEQUAL: Final[int]
+AMPEREQUAL: Final[int]
+VBAREQUAL: Final[int]
+CIRCUMFLEXEQUAL: Final[int]
+LEFTSHIFTEQUAL: Final[int]
+RIGHTSHIFTEQUAL: Final[int]
+DOUBLESTAREQUAL: Final[int]
+DOUBLESLASH: Final[int]
+DOUBLESLASHEQUAL: Final[int]
+AT: Final[int]
+RARROW: Final[int]
+ELLIPSIS: Final[int]
+ATEQUAL: Final[int]
if sys.version_info < (3, 13):
- AWAIT: int
- ASYNC: int
-OP: int
-ERRORTOKEN: int
-N_TOKENS: int
-NT_OFFSET: int
-tok_name: dict[int, str]
-COMMENT: int
-NL: int
-ENCODING: int
-TYPE_COMMENT: int
-TYPE_IGNORE: int
-COLONEQUAL: int
-EXACT_TOKEN_TYPES: dict[str, int]
+ AWAIT: Final[int]
+ ASYNC: Final[int]
+OP: Final[int]
+ERRORTOKEN: Final[int]
+N_TOKENS: Final[int]
+NT_OFFSET: Final[int]
+tok_name: Final[dict[int, str]]
+COMMENT: Final[int]
+NL: Final[int]
+ENCODING: Final[int]
+TYPE_COMMENT: Final[int]
+TYPE_IGNORE: Final[int]
+COLONEQUAL: Final[int]
+EXACT_TOKEN_TYPES: Final[dict[str, int]]
if sys.version_info >= (3, 10):
- SOFT_KEYWORD: int
+ SOFT_KEYWORD: Final[int]
if sys.version_info >= (3, 12):
- EXCLAMATION: int
- FSTRING_END: int
- FSTRING_MIDDLE: int
- FSTRING_START: int
+ EXCLAMATION: Final[int]
+ FSTRING_END: Final[int]
+ FSTRING_MIDDLE: Final[int]
+ FSTRING_START: Final[int]
if sys.version_info >= (3, 14):
- TSTRING_START: int
- TSTRING_MIDDLE: int
- TSTRING_END: int
+ TSTRING_START: Final[int]
+ TSTRING_MIDDLE: Final[int]
+ TSTRING_END: Final[int]
def ISTERMINAL(x: int) -> bool: ...
def ISNONTERMINAL(x: int) -> bool: ...
diff --git a/python/helpers/typeshed/stdlib/tokenize.pyi b/python/helpers/typeshed/stdlib/tokenize.pyi
index b658740a1ad7..dabb64b8b96e 100644
--- a/python/helpers/typeshed/stdlib/tokenize.pyi
+++ b/python/helpers/typeshed/stdlib/tokenize.pyi
@@ -3,10 +3,15 @@ from _typeshed import FileDescriptorOrPath
from collections.abc import Callable, Generator, Iterable, Sequence
from re import Pattern
from token import *
-from token import EXACT_TOKEN_TYPES as EXACT_TOKEN_TYPES
-from typing import Any, NamedTuple, TextIO, type_check_only
+from typing import Any, Final, NamedTuple, TextIO, type_check_only
from typing_extensions import TypeAlias
+if sys.version_info < (3, 12):
+ # Avoid double assignment to Final name by imports, which pyright objects to.
+ # EXACT_TOKEN_TYPES is already defined by 'from token import *' above
+ # in Python 3.12+.
+ from token import EXACT_TOKEN_TYPES as EXACT_TOKEN_TYPES
+
__all__ = [
"AMPER",
"AMPEREQUAL",
@@ -96,8 +101,8 @@ if sys.version_info >= (3, 13):
if sys.version_info >= (3, 14):
__all__ += ["TSTRING_START", "TSTRING_MIDDLE", "TSTRING_END"]
-cookie_re: Pattern[str]
-blank_re: Pattern[bytes]
+cookie_re: Final[Pattern[str]]
+blank_re: Final[Pattern[bytes]]
_Position: TypeAlias = tuple[int, int]
@@ -146,46 +151,46 @@ def group(*choices: str) -> str: ... # undocumented
def any(*choices: str) -> str: ... # undocumented
def maybe(*choices: str) -> str: ... # undocumented
-Whitespace: str # undocumented
-Comment: str # undocumented
-Ignore: str # undocumented
-Name: str # undocumented
+Whitespace: Final[str] # undocumented
+Comment: Final[str] # undocumented
+Ignore: Final[str] # undocumented
+Name: Final[str] # undocumented
-Hexnumber: str # undocumented
-Binnumber: str # undocumented
-Octnumber: str # undocumented
-Decnumber: str # undocumented
-Intnumber: str # undocumented
-Exponent: str # undocumented
-Pointfloat: str # undocumented
-Expfloat: str # undocumented
-Floatnumber: str # undocumented
-Imagnumber: str # undocumented
-Number: str # undocumented
+Hexnumber: Final[str] # undocumented
+Binnumber: Final[str] # undocumented
+Octnumber: Final[str] # undocumented
+Decnumber: Final[str] # undocumented
+Intnumber: Final[str] # undocumented
+Exponent: Final[str] # undocumented
+Pointfloat: Final[str] # undocumented
+Expfloat: Final[str] # undocumented
+Floatnumber: Final[str] # undocumented
+Imagnumber: Final[str] # undocumented
+Number: Final[str] # undocumented
def _all_string_prefixes() -> set[str]: ... # undocumented
-StringPrefix: str # undocumented
+StringPrefix: Final[str] # undocumented
-Single: str # undocumented
-Double: str # undocumented
-Single3: str # undocumented
-Double3: str # undocumented
-Triple: str # undocumented
-String: str # undocumented
+Single: Final[str] # undocumented
+Double: Final[str] # undocumented
+Single3: Final[str] # undocumented
+Double3: Final[str] # undocumented
+Triple: Final[str] # undocumented
+String: Final[str] # undocumented
-Special: str # undocumented
-Funny: str # undocumented
+Special: Final[str] # undocumented
+Funny: Final[str] # undocumented
-PlainToken: str # undocumented
-Token: str # undocumented
+PlainToken: Final[str] # undocumented
+Token: Final[str] # undocumented
-ContStr: str # undocumented
-PseudoExtras: str # undocumented
-PseudoToken: str # undocumented
+ContStr: Final[str] # undocumented
+PseudoExtras: Final[str] # undocumented
+PseudoToken: Final[str] # undocumented
-endpats: dict[str, str] # undocumented
-single_quoted: set[str] # undocumented
-triple_quoted: set[str] # undocumented
+endpats: Final[dict[str, str]] # undocumented
+single_quoted: Final[set[str]] # undocumented
+triple_quoted: Final[set[str]] # undocumented
-tabsize: int # undocumented
+tabsize: Final = 8 # undocumented
diff --git a/python/helpers/typeshed/stdlib/tomllib.pyi b/python/helpers/typeshed/stdlib/tomllib.pyi
index c160ffc38bfd..4ff4097f8313 100644
--- a/python/helpers/typeshed/stdlib/tomllib.pyi
+++ b/python/helpers/typeshed/stdlib/tomllib.pyi
@@ -16,7 +16,7 @@ if sys.version_info >= (3, 14):
@overload
def __init__(self, msg: str, doc: str, pos: int) -> None: ...
@overload
- @deprecated("Deprecated in Python 3.14; Please set 'msg', 'doc' and 'pos' arguments only.")
+ @deprecated("Deprecated since Python 3.14. Set the 'msg', 'doc' and 'pos' arguments only.")
def __init__(self, msg: str | type = ..., doc: str | type = ..., pos: int | type = ..., *args: Any) -> None: ...
else:
diff --git a/python/helpers/typeshed/stdlib/traceback.pyi b/python/helpers/typeshed/stdlib/traceback.pyi
index 4553dbd08384..d587295cd1cf 100644
--- a/python/helpers/typeshed/stdlib/traceback.pyi
+++ b/python/helpers/typeshed/stdlib/traceback.pyi
@@ -138,7 +138,7 @@ class TracebackException:
@property
def exc_type_str(self) -> str: ...
@property
- @deprecated("Deprecated in 3.13. Use exc_type_str instead.")
+ @deprecated("Deprecated since Python 3.13. Use `exc_type_str` instead.")
def exc_type(self) -> type[BaseException] | None: ...
else:
exc_type: type[BaseException]
@@ -245,6 +245,23 @@ class TracebackException:
def print(self, *, file: SupportsWrite[str] | None = None, chain: bool = True) -> None: ...
class FrameSummary:
+ if sys.version_info >= (3, 13):
+ __slots__ = (
+ "filename",
+ "lineno",
+ "end_lineno",
+ "colno",
+ "end_colno",
+ "name",
+ "_lines",
+ "_lines_dedented",
+ "locals",
+ "_code",
+ )
+ elif sys.version_info >= (3, 11):
+ __slots__ = ("filename", "lineno", "end_lineno", "colno", "end_colno", "name", "_line", "locals")
+ else:
+ __slots__ = ("filename", "lineno", "name", "_line", "locals")
if sys.version_info >= (3, 11):
def __init__(
self,
diff --git a/python/helpers/typeshed/stdlib/tracemalloc.pyi b/python/helpers/typeshed/stdlib/tracemalloc.pyi
index 05d98ae127d8..31d8f7445639 100644
--- a/python/helpers/typeshed/stdlib/tracemalloc.pyi
+++ b/python/helpers/typeshed/stdlib/tracemalloc.pyi
@@ -32,6 +32,7 @@ class Filter(BaseFilter):
) -> None: ...
class Statistic:
+ __slots__ = ("traceback", "size", "count")
count: int
size: int
traceback: Traceback
@@ -40,6 +41,7 @@ class Statistic:
def __hash__(self) -> int: ...
class StatisticDiff:
+ __slots__ = ("traceback", "size", "size_diff", "count", "count_diff")
count: int
count_diff: int
size: int
@@ -52,6 +54,7 @@ class StatisticDiff:
_FrameTuple: TypeAlias = tuple[str, int]
class Frame:
+ __slots__ = ("_frame",)
@property
def filename(self) -> str: ...
@property
@@ -72,6 +75,7 @@ class Frame:
_TraceTuple: TypeAlias = tuple[int, int, Sequence[_FrameTuple], int | None] | tuple[int, int, Sequence[_FrameTuple]]
class Trace:
+ __slots__ = ("_trace",)
@property
def domain(self) -> int: ...
@property
@@ -83,6 +87,7 @@ class Trace:
def __hash__(self) -> int: ...
class Traceback(Sequence[Frame]):
+ __slots__ = ("_frames", "_total_nframe")
@property
def total_nframe(self) -> int | None: ...
def __init__(self, frames: Sequence[_FrameTuple], total_nframe: int | None = None) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/tty.pyi b/python/helpers/typeshed/stdlib/tty.pyi
index 0611879cf1b2..ca3f0013b20e 100644
--- a/python/helpers/typeshed/stdlib/tty.pyi
+++ b/python/helpers/typeshed/stdlib/tty.pyi
@@ -15,13 +15,13 @@ if sys.platform != "win32":
_FD: TypeAlias = int | IO[str]
# XXX: Undocumented integer constants
- IFLAG: Final[int]
- OFLAG: Final[int]
- CFLAG: Final[int]
- LFLAG: Final[int]
- ISPEED: Final[int]
- OSPEED: Final[int]
- CC: Final[int]
+ IFLAG: Final = 0
+ OFLAG: Final = 1
+ CFLAG: Final = 2
+ LFLAG: Final = 3
+ ISPEED: Final = 4
+ OSPEED: Final = 5
+ CC: Final = 6
def setraw(fd: _FD, when: int = 2) -> _ModeSetterReturn: ...
def setcbreak(fd: _FD, when: int = 2) -> _ModeSetterReturn: ...
diff --git a/python/helpers/typeshed/stdlib/turtle.pyi b/python/helpers/typeshed/stdlib/turtle.pyi
index 9c62c64e718a..e41476b73b8c 100644
--- a/python/helpers/typeshed/stdlib/turtle.pyi
+++ b/python/helpers/typeshed/stdlib/turtle.pyi
@@ -3,8 +3,8 @@ from _typeshed import StrPath
from collections.abc import Callable, Generator, Sequence
from contextlib import contextmanager
from tkinter import Canvas, Frame, Misc, PhotoImage, Scrollbar
-from typing import Any, ClassVar, Literal, TypedDict, overload
-from typing_extensions import Self, TypeAlias
+from typing import Any, ClassVar, Literal, TypedDict, overload, type_check_only
+from typing_extensions import Self, TypeAlias, deprecated
__all__ = [
"ScrolledCanvas",
@@ -146,6 +146,7 @@ if sys.version_info < (3, 13):
_Color: TypeAlias = str | tuple[float, float, float]
_AnyColor: TypeAlias = Any
+@type_check_only
class _PenState(TypedDict):
shown: bool
pendown: bool
@@ -425,6 +426,7 @@ class RawTurtle(TPen, TNavigator): # type: ignore[misc] # Conflicting methods
def get_shapepoly(self) -> _PolygonCoords | None: ...
if sys.version_info < (3, 13):
+ @deprecated("Deprecated since Python 3.1; removed in Python 3.13. Use `tiltangle()` instead.")
def settiltangle(self, angle: float) -> None: ...
@overload
@@ -487,19 +489,8 @@ Pen = Turtle
def write_docstringdict(filename: str = "turtle_docstringdict") -> None: ...
-# Note: it's somewhat unfortunate that we have to copy the function signatures.
-# It would be nice if we could partially reduce the redundancy by doing something
-# like the following:
-#
-# _screen: Screen
-# clear = _screen.clear
-#
-# However, it seems pytype does not support this type of syntax in pyi files.
-
# Functions copied from TurtleScreenBase:
-# Note: mainloop() was always present in the global scope, but was added to
-# TurtleScreenBase in Python 3.0
def mainloop() -> None: ...
def textinput(title: str, prompt: str) -> str | None: ...
def numinput(
@@ -717,6 +708,7 @@ def shapetransform(
def get_shapepoly() -> _PolygonCoords | None: ...
if sys.version_info < (3, 13):
+ @deprecated("Deprecated since Python 3.1; removed in Python 3.13. Use `tiltangle()` instead.")
def settiltangle(angle: float) -> None: ...
@overload
diff --git a/python/helpers/typeshed/stdlib/types.pyi b/python/helpers/typeshed/stdlib/types.pyi
index d9f8e8756833..56efcaa2e6a0 100644
--- a/python/helpers/typeshed/stdlib/types.pyi
+++ b/python/helpers/typeshed/stdlib/types.pyi
@@ -151,7 +151,7 @@ class CodeType:
def co_firstlineno(self) -> int: ...
if sys.version_info >= (3, 10):
@property
- @deprecated("Will be removed in Python 3.15. Use the co_lines() method instead.")
+ @deprecated("Deprecated since Python 3.10; will be removed in Python 3.15. Use `CodeType.co_lines()` instead.")
def co_lnotab(self) -> bytes: ...
else:
@property
@@ -323,7 +323,9 @@ class MappingProxyType(Mapping[_KT, _VT_co]):
@overload
def get(self, key: _KT, /) -> _VT_co | None: ...
@overload
- def get(self, key: _KT, default: _VT_co | _T2, /) -> _VT_co | _T2: ...
+ def get(self, key: _KT, default: _VT_co, /) -> _VT_co: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # Covariant type as parameter
+ @overload
+ def get(self, key: _KT, default: _T2, /) -> _VT_co | _T2: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __reversed__(self) -> Iterator[_KT]: ...
def __or__(self, value: Mapping[_T1, _T2], /) -> dict[_KT | _T1, _VT_co | _T2]: ...
@@ -388,7 +390,7 @@ class GeneratorType(Generator[_YieldT_co, _SendT_contra, _ReturnT_co]):
@property
def gi_running(self) -> bool: ...
@property
- def gi_yieldfrom(self) -> GeneratorType[_YieldT_co, _SendT_contra, Any] | None: ...
+ def gi_yieldfrom(self) -> Iterator[_YieldT_co] | None: ...
if sys.version_info >= (3, 11):
@property
def gi_suspended(self) -> bool: ...
diff --git a/python/helpers/typeshed/stdlib/typing.pyi b/python/helpers/typeshed/stdlib/typing.pyi
index 79ab9eee924f..bd61a88b3e98 100644
--- a/python/helpers/typeshed/stdlib/typing.pyi
+++ b/python/helpers/typeshed/stdlib/typing.pyi
@@ -1,12 +1,11 @@
# Since this module defines "overload" it is not recognized by Ruff as typing.overload
-# ruff: noqa: F811
# TODO: The collections import is required, otherwise mypy crashes.
# https://github.com/python/mypy/issues/16744
import collections # noqa: F401 # pyright: ignore[reportUnusedImport]
import sys
import typing_extensions
from _collections_abc import dict_items, dict_keys, dict_values
-from _typeshed import IdentityFunction, ReadableBuffer, SupportsKeysAndGetItem
+from _typeshed import IdentityFunction, ReadableBuffer, SupportsGetItem, SupportsGetItemViewable, SupportsKeysAndGetItem, Viewable
from abc import ABCMeta, abstractmethod
from re import Match as Match, Pattern as Pattern
from types import (
@@ -147,7 +146,9 @@ if sys.version_info >= (3, 13):
# from _typeshed import AnnotationForm
class Any: ...
-class _Final: ...
+
+class _Final:
+ __slots__ = ("__weakref__",)
def final(f: _T) -> _T: ...
@final
@@ -208,12 +209,12 @@ class TypeVar:
contravariant: bool = False,
) -> None: ...
if sys.version_info >= (3, 10):
- def __or__(self, right: Any) -> _SpecialForm: ... # AnnotationForm
- def __ror__(self, left: Any) -> _SpecialForm: ... # AnnotationForm
+ def __or__(self, right: Any, /) -> _SpecialForm: ... # AnnotationForm
+ def __ror__(self, left: Any, /) -> _SpecialForm: ... # AnnotationForm
if sys.version_info >= (3, 11):
- def __typing_subst__(self, arg: Any) -> Any: ...
+ def __typing_subst__(self, arg: Any, /) -> Any: ...
if sys.version_info >= (3, 13):
- def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ...
+ def __typing_prepare_subst__(self, alias: Any, args: Any, /) -> tuple[Any, ...]: ...
def has_default(self) -> bool: ...
if sys.version_info >= (3, 14):
@property
@@ -230,13 +231,13 @@ _promote = object()
# N.B. Keep this definition in sync with typing_extensions._SpecialForm
@final
class _SpecialForm(_Final):
+ __slots__ = ("_name", "__doc__", "_getitem")
def __getitem__(self, parameters: Any) -> object: ...
if sys.version_info >= (3, 10):
def __or__(self, other: Any) -> _SpecialForm: ...
def __ror__(self, other: Any) -> _SpecialForm: ...
Union: _SpecialForm
-Generic: _SpecialForm
Protocol: _SpecialForm
Callable: _SpecialForm
Type: _SpecialForm
@@ -274,8 +275,8 @@ if sys.version_info >= (3, 11):
def __init__(self, name: str) -> None: ...
def __iter__(self) -> Any: ...
- def __typing_subst__(self, arg: Never) -> Never: ...
- def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ...
+ def __typing_subst__(self, arg: Never, /) -> Never: ...
+ def __typing_prepare_subst__(self, alias: Any, args: Any, /) -> tuple[Any, ...]: ...
if sys.version_info >= (3, 14):
@property
def evaluate_default(self) -> EvaluateFunc | None: ...
@@ -290,7 +291,7 @@ if sys.version_info >= (3, 10):
else:
def __init__(self, origin: ParamSpec) -> None: ...
- def __eq__(self, other: object) -> bool: ...
+ def __eq__(self, other: object, /) -> bool: ...
__hash__: ClassVar[None] # type: ignore[assignment]
@final
@@ -302,7 +303,7 @@ if sys.version_info >= (3, 10):
else:
def __init__(self, origin: ParamSpec) -> None: ...
- def __eq__(self, other: object) -> bool: ...
+ def __eq__(self, other: object, /) -> bool: ...
__hash__: ClassVar[None] # type: ignore[assignment]
@final
@@ -366,11 +367,11 @@ if sys.version_info >= (3, 10):
@property
def kwargs(self) -> ParamSpecKwargs: ...
if sys.version_info >= (3, 11):
- def __typing_subst__(self, arg: Any) -> Any: ...
- def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ...
+ def __typing_subst__(self, arg: Any, /) -> Any: ...
+ def __typing_prepare_subst__(self, alias: Any, args: Any, /) -> tuple[Any, ...]: ...
- def __or__(self, right: Any) -> _SpecialForm: ...
- def __ror__(self, left: Any) -> _SpecialForm: ...
+ def __or__(self, right: Any, /) -> _SpecialForm: ...
+ def __ror__(self, left: Any, /) -> _SpecialForm: ...
if sys.version_info >= (3, 13):
def has_default(self) -> bool: ...
if sys.version_info >= (3, 14):
@@ -420,6 +421,7 @@ def type_check_only(func_or_cls: _FT) -> _FT: ...
# Type aliases and type constructors
+@type_check_only
class _Alias:
# Class for defining generic aliases for library types.
def __getitem__(self, typeargs: Any) -> Any: ...
@@ -440,6 +442,20 @@ Annotated: _SpecialForm
# Predefined type variables.
AnyStr = TypeVar("AnyStr", str, bytes) # noqa: Y001
+@type_check_only
+class _Generic:
+ if sys.version_info < (3, 12):
+ __slots__ = ()
+
+ if sys.version_info >= (3, 10):
+ @classmethod
+ def __class_getitem__(cls, args: TypeVar | ParamSpec | tuple[TypeVar | ParamSpec, ...]) -> _Final: ...
+ else:
+ @classmethod
+ def __class_getitem__(cls, args: TypeVar | tuple[TypeVar, ...]) -> _Final: ...
+
+Generic: type[_Generic]
+
class _ProtocolMeta(ABCMeta):
if sys.version_info >= (3, 12):
def __init__(cls, *args: Any, **kwargs: Any) -> None: ...
@@ -449,36 +465,43 @@ class _ProtocolMeta(ABCMeta):
def runtime_checkable(cls: _TC) -> _TC: ...
@runtime_checkable
class SupportsInt(Protocol, metaclass=ABCMeta):
+ __slots__ = ()
@abstractmethod
def __int__(self) -> int: ...
@runtime_checkable
class SupportsFloat(Protocol, metaclass=ABCMeta):
+ __slots__ = ()
@abstractmethod
def __float__(self) -> float: ...
@runtime_checkable
class SupportsComplex(Protocol, metaclass=ABCMeta):
+ __slots__ = ()
@abstractmethod
def __complex__(self) -> complex: ...
@runtime_checkable
class SupportsBytes(Protocol, metaclass=ABCMeta):
+ __slots__ = ()
@abstractmethod
def __bytes__(self) -> bytes: ...
@runtime_checkable
class SupportsIndex(Protocol, metaclass=ABCMeta):
+ __slots__ = ()
@abstractmethod
def __index__(self) -> int: ...
@runtime_checkable
class SupportsAbs(Protocol[_T_co]):
+ __slots__ = ()
@abstractmethod
def __abs__(self) -> _T_co: ...
@runtime_checkable
class SupportsRound(Protocol[_T_co]):
+ __slots__ = ()
@overload
@abstractmethod
def __round__(self) -> int: ...
@@ -703,14 +726,14 @@ class MutableSet(AbstractSet[_T]):
def __isub__(self, it: AbstractSet[Any]) -> typing_extensions.Self: ...
class MappingView(Sized):
- def __init__(self, mapping: Mapping[Any, Any]) -> None: ... # undocumented
+ def __init__(self, mapping: Sized) -> None: ... # undocumented
def __len__(self) -> int: ...
class ItemsView(MappingView, AbstractSet[tuple[_KT_co, _VT_co]], Generic[_KT_co, _VT_co]):
- def __init__(self, mapping: Mapping[_KT_co, _VT_co]) -> None: ... # undocumented
+ def __init__(self, mapping: SupportsGetItemViewable[_KT_co, _VT_co]) -> None: ... # undocumented
def __and__(self, other: Iterable[Any]) -> set[tuple[_KT_co, _VT_co]]: ...
def __rand__(self, other: Iterable[_T]) -> set[_T]: ...
- def __contains__(self, item: object) -> bool: ...
+ def __contains__(self, item: tuple[object, object]) -> bool: ... # type: ignore[override]
def __iter__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...
def __or__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
def __ror__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
@@ -720,7 +743,7 @@ class ItemsView(MappingView, AbstractSet[tuple[_KT_co, _VT_co]], Generic[_KT_co,
def __rxor__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
class KeysView(MappingView, AbstractSet[_KT_co]):
- def __init__(self, mapping: Mapping[_KT_co, Any]) -> None: ... # undocumented
+ def __init__(self, mapping: Viewable[_KT_co]) -> None: ... # undocumented
def __and__(self, other: Iterable[Any]) -> set[_KT_co]: ...
def __rand__(self, other: Iterable[_T]) -> set[_T]: ...
def __contains__(self, key: object) -> bool: ...
@@ -733,7 +756,7 @@ class KeysView(MappingView, AbstractSet[_KT_co]):
def __rxor__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ...
class ValuesView(MappingView, Collection[_VT_co]):
- def __init__(self, mapping: Mapping[Any, _VT_co]) -> None: ... # undocumented
+ def __init__(self, mapping: SupportsGetItemViewable[Any, _VT_co]) -> None: ... # undocumented
def __contains__(self, value: object) -> bool: ...
def __iter__(self) -> Iterator[_VT_co]: ...
@@ -746,7 +769,9 @@ class Mapping(Collection[_KT], Generic[_KT, _VT_co]):
@overload
def get(self, key: _KT, /) -> _VT_co | None: ...
@overload
- def get(self, key: _KT, /, default: _VT_co | _T) -> _VT_co | _T: ...
+ def get(self, key: _KT, /, default: _VT_co) -> _VT_co: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] # Covariant type as parameter
+ @overload
+ def get(self, key: _KT, /, default: _T) -> _VT_co | _T: ...
def items(self) -> ItemsView[_KT, _VT_co]: ...
def keys(self) -> KeysView[_KT]: ...
def values(self) -> ValuesView[_VT_co]: ...
@@ -799,13 +824,13 @@ class MutableMapping(Mapping[_KT, _VT]):
@overload
def update(self, m: SupportsKeysAndGetItem[_KT, _VT], /) -> None: ...
@overload
- def update(self: Mapping[str, _VT], m: SupportsKeysAndGetItem[str, _VT], /, **kwargs: _VT) -> None: ...
+ def update(self: SupportsGetItem[str, _VT], m: SupportsKeysAndGetItem[str, _VT], /, **kwargs: _VT) -> None: ...
@overload
def update(self, m: Iterable[tuple[_KT, _VT]], /) -> None: ...
@overload
- def update(self: Mapping[str, _VT], m: Iterable[tuple[str, _VT]], /, **kwargs: _VT) -> None: ...
+ def update(self: SupportsGetItem[str, _VT], m: Iterable[tuple[str, _VT]], /, **kwargs: _VT) -> None: ...
@overload
- def update(self: Mapping[str, _VT], **kwargs: _VT) -> None: ...
+ def update(self: SupportsGetItem[str, _VT], **kwargs: _VT) -> None: ...
Text = str
@@ -818,6 +843,7 @@ class IO(Generic[AnyStr]):
# At runtime these are all abstract properties,
# but making them abstract in the stub is hugely disruptive, for not much gain.
# See #8726
+ __slots__ = ()
@property
def mode(self) -> str: ...
# Usually str, but may be bytes if a bytes path was passed to open(). See #10737.
@@ -876,11 +902,13 @@ class IO(Generic[AnyStr]):
) -> None: ...
class BinaryIO(IO[bytes]):
+ __slots__ = ()
@abstractmethod
def __enter__(self) -> BinaryIO: ...
class TextIO(IO[str]):
# See comment regarding the @properties in the `IO` class
+ __slots__ = ()
@property
def buffer(self) -> BinaryIO: ...
@property
@@ -1043,6 +1071,15 @@ if sys.version_info >= (3, 14):
else:
@final
class ForwardRef(_Final):
+ __slots__ = (
+ "__forward_arg__",
+ "__forward_code__",
+ "__forward_evaluated__",
+ "__forward_value__",
+ "__forward_is_argument__",
+ "__forward_is_class__",
+ "__forward_module__",
+ )
__forward_arg__: str
__forward_code__: CodeType
__forward_evaluated__: bool
@@ -1113,9 +1150,9 @@ if sys.version_info >= (3, 12):
# It's writable on types, but not on instances of TypeAliasType.
@property
def __module__(self) -> str | None: ... # type: ignore[override]
- def __getitem__(self, parameters: Any) -> GenericAlias: ... # AnnotationForm
- def __or__(self, right: Any) -> _SpecialForm: ...
- def __ror__(self, left: Any) -> _SpecialForm: ...
+ def __getitem__(self, parameters: Any, /) -> GenericAlias: ... # AnnotationForm
+ def __or__(self, right: Any, /) -> _SpecialForm: ...
+ def __ror__(self, left: Any, /) -> _SpecialForm: ...
if sys.version_info >= (3, 14):
@property
def evaluate_value(self) -> EvaluateFunc: ...
@@ -1124,6 +1161,7 @@ if sys.version_info >= (3, 13):
def is_protocol(tp: type, /) -> bool: ...
def get_protocol_members(tp: type, /) -> frozenset[str]: ...
@final
+ @type_check_only
class _NoDefaultType: ...
NoDefault: _NoDefaultType
diff --git a/python/helpers/typeshed/stdlib/typing_extensions.pyi b/python/helpers/typeshed/stdlib/typing_extensions.pyi
index 3f7c25712081..4cc353dd5c1d 100644
--- a/python/helpers/typeshed/stdlib/typing_extensions.pyi
+++ b/python/helpers/typeshed/stdlib/typing_extensions.pyi
@@ -59,6 +59,7 @@ from typing import ( # noqa: Y022,Y037,Y038,Y039,UP035
TypeVar as _TypeVar,
Union as Union,
_Alias,
+ _SpecialForm,
cast as cast,
no_type_check as no_type_check,
no_type_check_decorator as no_type_check_decorator,
@@ -119,6 +120,7 @@ __all__ = [
"clear_overloads",
"dataclass_transform",
"deprecated",
+ "disjoint_base",
"Doc",
"evaluate_forward_ref",
"get_overloads",
@@ -149,6 +151,7 @@ __all__ = [
"TypeGuard",
"TypeIs",
"TYPE_CHECKING",
+ "type_repr",
"Never",
"NoReturn",
"ReadOnly",
@@ -204,15 +207,6 @@ _TC = _TypeVar("_TC", bound=type[object])
_T_co = _TypeVar("_T_co", covariant=True) # Any type covariant containers.
_T_contra = _TypeVar("_T_contra", contravariant=True)
-class _Final: ... # This should be imported from typing but that breaks pytype
-
-# unfortunately we have to duplicate this class definition from typing.pyi or we break pytype
-class _SpecialForm(_Final):
- def __getitem__(self, parameters: Any) -> object: ...
- if sys.version_info >= (3, 10):
- def __or__(self, other: Any) -> _SpecialForm: ...
- def __ror__(self, other: Any) -> _SpecialForm: ...
-
# Do not import (and re-export) Protocol or runtime_checkable from
# typing module because type checkers need to be able to distinguish
# typing.Protocol and typing_extensions.Protocol so they can properly
@@ -227,6 +221,7 @@ runtime = runtime_checkable
Final: _SpecialForm
def final(f: _F) -> _F: ...
+def disjoint_base(cls: _TC) -> _TC: ...
Literal: _SpecialForm
@@ -455,11 +450,13 @@ if sys.version_info >= (3, 14):
else:
@runtime_checkable
class Reader(Protocol[_T_co]):
+ __slots__ = ()
@abc.abstractmethod
def read(self, size: int = ..., /) -> _T_co: ...
@runtime_checkable
class Writer(Protocol[_T_contra]):
+ __slots__ = ()
@abc.abstractmethod
def write(self, data: _T_contra, /) -> int: ...
@@ -480,6 +477,7 @@ else:
def is_protocol(tp: type, /) -> bool: ...
def get_protocol_members(tp: type, /) -> frozenset[str]: ...
@final
+ @type_check_only
class _NoDefaultType: ...
NoDefault: _NoDefaultType
@@ -600,8 +598,8 @@ else:
def __getitem__(self, parameters: Incomplete | tuple[Incomplete, ...]) -> AnnotationForm: ...
def __init_subclass__(cls, *args: Unused, **kwargs: Unused) -> NoReturn: ...
if sys.version_info >= (3, 10):
- def __or__(self, right: Any) -> _SpecialForm: ...
- def __ror__(self, left: Any) -> _SpecialForm: ...
+ def __or__(self, right: Any, /) -> _SpecialForm: ...
+ def __ror__(self, left: Any, /) -> _SpecialForm: ...
# PEP 727
class Doc:
@@ -611,6 +609,7 @@ class Doc:
def __eq__(self, other: object) -> bool: ...
# PEP 728
+@type_check_only
class _NoExtraItemsType: ...
NoExtraItems: _NoExtraItemsType
@@ -622,7 +621,7 @@ TypeForm: _SpecialForm
if sys.version_info >= (3, 14):
from typing import evaluate_forward_ref as evaluate_forward_ref
- from annotationlib import Format as Format, get_annotations as get_annotations
+ from annotationlib import Format as Format, get_annotations as get_annotations, type_repr as type_repr
else:
class Format(enum.IntEnum):
VALUE = 1
@@ -690,6 +689,7 @@ else:
format: Format | None = None,
_recursive_guard: Container[str] = ...,
) -> AnnotationForm: ...
+ def type_repr(value: object) -> str: ...
# PEP 661
class Sentinel:
diff --git a/python/helpers/typeshed/stdlib/unicodedata.pyi b/python/helpers/typeshed/stdlib/unicodedata.pyi
index 77d69edf06af..9fff042f0b96 100644
--- a/python/helpers/typeshed/stdlib/unicodedata.pyi
+++ b/python/helpers/typeshed/stdlib/unicodedata.pyi
@@ -1,10 +1,10 @@
import sys
from _typeshed import ReadOnlyBuffer
-from typing import Any, Literal, TypeVar, final, overload
+from typing import Any, Final, Literal, TypeVar, final, overload
from typing_extensions import TypeAlias
ucd_3_2_0: UCD
-unidata_version: str
+unidata_version: Final[str]
if sys.version_info < (3, 10):
ucnhash_CAPI: Any
diff --git a/python/helpers/typeshed/stdlib/unittest/case.pyi b/python/helpers/typeshed/stdlib/unittest/case.pyi
index 89bcabf104c2..a602196e73c6 100644
--- a/python/helpers/typeshed/stdlib/unittest/case.pyi
+++ b/python/helpers/typeshed/stdlib/unittest/case.pyi
@@ -2,18 +2,16 @@ import logging
import sys
import unittest.result
from _typeshed import SupportsDunderGE, SupportsDunderGT, SupportsDunderLE, SupportsDunderLT, SupportsRSub, SupportsSub
+from builtins import _ClassInfo
from collections.abc import Callable, Container, Iterable, Mapping, Sequence, Set as AbstractSet
from contextlib import AbstractContextManager
from re import Pattern
from types import GenericAlias, TracebackType
-from typing import Any, AnyStr, Final, Generic, NoReturn, Protocol, SupportsAbs, SupportsRound, TypeVar, overload
-from typing_extensions import Never, ParamSpec, Self, TypeAlias
+from typing import Any, AnyStr, Final, Generic, NoReturn, Protocol, SupportsAbs, SupportsRound, TypeVar, overload, type_check_only
+from typing_extensions import Never, ParamSpec, Self
from unittest._log import _AssertLogsContext, _LoggingWatcher
from warnings import WarningMessage
-if sys.version_info >= (3, 10):
- from types import UnionType
-
_T = TypeVar("_T")
_S = TypeVar("_S", bound=SupportsSub[Any, Any])
_E = TypeVar("_E", bound=BaseException)
@@ -58,16 +56,9 @@ def skipUnless(condition: object, reason: str) -> Callable[[_FT], _FT]: ...
class SkipTest(Exception):
def __init__(self, reason: str) -> None: ...
+@type_check_only
class _SupportsAbsAndDunderGE(SupportsDunderGE[Any], SupportsAbs[Any], Protocol): ...
-# Keep this alias in sync with builtins._ClassInfo
-# We can't import it from builtins or pytype crashes,
-# due to the fact that pytype uses a custom builtins stub rather than typeshed's builtins stub
-if sys.version_info >= (3, 10):
- _ClassInfo: TypeAlias = type | UnionType | tuple[_ClassInfo, ...]
-else:
- _ClassInfo: TypeAlias = type | tuple[_ClassInfo, ...]
-
class TestCase:
failureException: type[BaseException]
longMessage: bool
diff --git a/python/helpers/typeshed/stdlib/unittest/loader.pyi b/python/helpers/typeshed/stdlib/unittest/loader.pyi
index 598e3cd84a5e..81de40c89849 100644
--- a/python/helpers/typeshed/stdlib/unittest/loader.pyi
+++ b/python/helpers/typeshed/stdlib/unittest/loader.pyi
@@ -35,21 +35,38 @@ class TestLoader:
defaultTestLoader: TestLoader
if sys.version_info < (3, 13):
- @deprecated("Deprecated in Python 3.11; removal scheduled for Python 3.13")
- def getTestCaseNames(
- testCaseClass: type[unittest.case.TestCase],
- prefix: str,
- sortUsing: _SortComparisonMethod = ...,
- testNamePatterns: list[str] | None = None,
- ) -> Sequence[str]: ...
- @deprecated("Deprecated in Python 3.11; removal scheduled for Python 3.13")
- def makeSuite(
- testCaseClass: type[unittest.case.TestCase],
- prefix: str = "test",
- sortUsing: _SortComparisonMethod = ...,
- suiteClass: _SuiteClass = ...,
- ) -> unittest.suite.TestSuite: ...
- @deprecated("Deprecated in Python 3.11; removal scheduled for Python 3.13")
- def findTestCases(
- module: ModuleType, prefix: str = "test", sortUsing: _SortComparisonMethod = ..., suiteClass: _SuiteClass = ...
- ) -> unittest.suite.TestSuite: ...
+ if sys.version_info >= (3, 11):
+ @deprecated("Deprecated since Python 3.11; removed in Python 3.13.")
+ def getTestCaseNames(
+ testCaseClass: type[unittest.case.TestCase],
+ prefix: str,
+ sortUsing: _SortComparisonMethod = ...,
+ testNamePatterns: list[str] | None = None,
+ ) -> Sequence[str]: ...
+ @deprecated("Deprecated since Python 3.11; removed in Python 3.13.")
+ def makeSuite(
+ testCaseClass: type[unittest.case.TestCase],
+ prefix: str = "test",
+ sortUsing: _SortComparisonMethod = ...,
+ suiteClass: _SuiteClass = ...,
+ ) -> unittest.suite.TestSuite: ...
+ @deprecated("Deprecated since Python 3.11; removed in Python 3.13.")
+ def findTestCases(
+ module: ModuleType, prefix: str = "test", sortUsing: _SortComparisonMethod = ..., suiteClass: _SuiteClass = ...
+ ) -> unittest.suite.TestSuite: ...
+ else:
+ def getTestCaseNames(
+ testCaseClass: type[unittest.case.TestCase],
+ prefix: str,
+ sortUsing: _SortComparisonMethod = ...,
+ testNamePatterns: list[str] | None = None,
+ ) -> Sequence[str]: ...
+ def makeSuite(
+ testCaseClass: type[unittest.case.TestCase],
+ prefix: str = "test",
+ sortUsing: _SortComparisonMethod = ...,
+ suiteClass: _SuiteClass = ...,
+ ) -> unittest.suite.TestSuite: ...
+ def findTestCases(
+ module: ModuleType, prefix: str = "test", sortUsing: _SortComparisonMethod = ..., suiteClass: _SuiteClass = ...
+ ) -> unittest.suite.TestSuite: ...
diff --git a/python/helpers/typeshed/stdlib/unittest/main.pyi b/python/helpers/typeshed/stdlib/unittest/main.pyi
index 22f2ec10634d..23ead1638ecc 100644
--- a/python/helpers/typeshed/stdlib/unittest/main.pyi
+++ b/python/helpers/typeshed/stdlib/unittest/main.pyi
@@ -5,12 +5,13 @@ import unittest.result
import unittest.suite
from collections.abc import Iterable
from types import ModuleType
-from typing import Any, Final, Protocol
+from typing import Any, Final, Protocol, type_check_only
from typing_extensions import deprecated
MAIN_EXAMPLES: Final[str]
MODULE_EXAMPLES: Final[str]
+@type_check_only
class _TestRunner(Protocol):
def run(self, test: unittest.suite.TestSuite | unittest.case.TestCase, /) -> unittest.result.TestResult: ...
@@ -63,8 +64,11 @@ class TestProgram:
) -> None: ...
if sys.version_info < (3, 13):
- @deprecated("Deprecated in Python 3.11; removal scheduled for Python 3.13")
- def usageExit(self, msg: Any = None) -> None: ...
+ if sys.version_info >= (3, 11):
+ @deprecated("Deprecated since Python 3.11; removed in Python 3.13.")
+ def usageExit(self, msg: Any = None) -> None: ...
+ else:
+ def usageExit(self, msg: Any = None) -> None: ...
def parseArgs(self, argv: list[str]) -> None: ...
def createTests(self, from_discovery: bool = False, Loader: unittest.loader.TestLoader | None = None) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/unittest/mock.pyi b/python/helpers/typeshed/stdlib/unittest/mock.pyi
index 9e353900f2d7..0fa1058985c8 100644
--- a/python/helpers/typeshed/stdlib/unittest/mock.pyi
+++ b/python/helpers/typeshed/stdlib/unittest/mock.pyi
@@ -3,7 +3,7 @@ from _typeshed import MaybeNone
from collections.abc import Awaitable, Callable, Coroutine, Iterable, Mapping, Sequence
from contextlib import _GeneratorContextManager
from types import TracebackType
-from typing import Any, ClassVar, Final, Generic, Literal, TypeVar, overload
+from typing import Any, ClassVar, Final, Generic, Literal, TypeVar, overload, type_check_only
from typing_extensions import ParamSpec, Self, TypeAlias
_T = TypeVar("_T")
@@ -52,7 +52,7 @@ else:
"seal",
)
-FILTER_DIR: Any
+FILTER_DIR: bool # controls the way mock objects respond to `dir` function
class _SentinelObject:
name: Any
@@ -61,7 +61,7 @@ class _SentinelObject:
class _Sentinel:
def __getattr__(self, name: str) -> Any: ...
-sentinel: Any
+sentinel: _Sentinel
DEFAULT: Any
_ArgsKwargs: TypeAlias = tuple[tuple[Any, ...], Mapping[str, Any]]
@@ -262,7 +262,8 @@ class _patch(Generic[_T]):
# This class does not exist at runtime, it's a hack to make this work:
# @patch("foo")
# def bar(..., mock: MagicMock) -> None: ...
-class _patch_default_new(_patch[MagicMock | AsyncMock]):
+@type_check_only
+class _patch_pass_arg(_patch[_T]):
@overload
def __call__(self, func: _TT) -> _TT: ...
# Can't use the following as ParamSpec is only allowed as last parameter:
@@ -288,6 +289,7 @@ class _patch_dict:
# This class does not exist at runtime, it's a hack to add methods to the
# patch() function.
+@type_check_only
class _patcher:
TEST_PREFIX: str
dict: type[_patch_dict]
@@ -295,41 +297,64 @@ class _patcher:
# Ideally we'd be able to add an overload for it so that the return type is _patch[MagicMock],
# but that's impossible with the current type system.
@overload
- def __call__(
+ def __call__( # type: ignore[overload-overlap]
self,
target: str,
new: _T,
- spec: Any | None = ...,
- create: bool = ...,
- spec_set: Any | None = ...,
- autospec: Any | None = ...,
- new_callable: Any | None = ...,
- **kwargs: Any,
+ spec: Literal[False] | None = None,
+ create: bool = False,
+ spec_set: Literal[False] | None = None,
+ autospec: Literal[False] | None = None,
+ new_callable: None = None,
+ *,
+ unsafe: bool = False,
) -> _patch[_T]: ...
@overload
def __call__(
self,
target: str,
*,
- spec: Any | None = ...,
- create: bool = ...,
- spec_set: Any | None = ...,
- autospec: Any | None = ...,
- new_callable: Any | None = ...,
+ # If not False or None, this is passed to new_callable
+ spec: Any | Literal[False] | None = None,
+ create: bool = False,
+ # If not False or None, this is passed to new_callable
+ spec_set: Any | Literal[False] | None = None,
+ autospec: Literal[False] | None = None,
+ new_callable: Callable[..., _T],
+ unsafe: bool = False,
+ # kwargs are passed to new_callable
**kwargs: Any,
- ) -> _patch_default_new: ...
+ ) -> _patch_pass_arg[_T]: ...
+ @overload
+ def __call__(
+ self,
+ target: str,
+ *,
+ spec: Any | bool | None = None,
+ create: bool = False,
+ spec_set: Any | bool | None = None,
+ autospec: Any | bool | None = None,
+ new_callable: None = None,
+ unsafe: bool = False,
+ # kwargs are passed to the MagicMock/AsyncMock constructor
+ **kwargs: Any,
+ ) -> _patch_pass_arg[MagicMock | AsyncMock]: ...
+ # This overload also covers the case, where new==DEFAULT. In this case, the return type is _patch[Any].
+ # Ideally we'd be able to add an overload for it so that the return type is _patch[MagicMock],
+ # but that's impossible with the current type system.
@overload
@staticmethod
def object(
target: Any,
attribute: str,
new: _T,
- spec: Any | None = ...,
- create: bool = ...,
- spec_set: Any | None = ...,
- autospec: Any | None = ...,
- new_callable: Any | None = ...,
- **kwargs: Any,
+ spec: Literal[False] | None = None,
+ create: bool = False,
+ spec_set: Literal[False] | None = None,
+ autospec: Literal[False] | None = None,
+ new_callable: None = None,
+ *,
+ unsafe: bool = False,
) -> _patch[_T]: ...
@overload
@staticmethod
@@ -337,21 +362,71 @@ class _patcher:
target: Any,
attribute: str,
*,
- spec: Any | None = ...,
- create: bool = ...,
- spec_set: Any | None = ...,
- autospec: Any | None = ...,
- new_callable: Any | None = ...,
+ # If not False or None, this is passed to new_callable
+ spec: Any | Literal[False] | None = None,
+ create: bool = False,
+ # If not False or None, this is passed to new_callable
+ spec_set: Any | Literal[False] | None = None,
+ autospec: Literal[False] | None = None,
+ new_callable: Callable[..., _T],
+ unsafe: bool = False,
+ # kwargs are passed to new_callable
**kwargs: Any,
- ) -> _patch[MagicMock | AsyncMock]: ...
+ ) -> _patch_pass_arg[_T]: ...
+ @overload
+ @staticmethod
+ def object(
+ target: Any,
+ attribute: str,
+ *,
+ spec: Any | bool | None = None,
+ create: bool = False,
+ spec_set: Any | bool | None = None,
+ autospec: Any | bool | None = None,
+ new_callable: None = None,
+ unsafe: bool = False,
+ # kwargs are passed to the MagicMock/AsyncMock constructor
+ **kwargs: Any,
+ ) -> _patch_pass_arg[MagicMock | AsyncMock]: ...
+ @overload
@staticmethod
def multiple(
- target: Any,
- spec: Any | None = ...,
- create: bool = ...,
- spec_set: Any | None = ...,
- autospec: Any | None = ...,
- new_callable: Any | None = ...,
+ target: Any | str,
+ # If not False or None, this is passed to new_callable
+ spec: Any | Literal[False] | None = None,
+ create: bool = False,
+ # If not False or None, this is passed to new_callable
+ spec_set: Any | Literal[False] | None = None,
+ autospec: Literal[False] | None = None,
+ *,
+ new_callable: Callable[..., _T],
+ # The kwargs must be DEFAULT
+ **kwargs: Any,
+ ) -> _patch_pass_arg[_T]: ...
+ @overload
+ @staticmethod
+ def multiple(
+ target: Any | str,
+ # If not False or None, this is passed to new_callable
+ spec: Any | Literal[False] | None,
+ create: bool,
+ # If not False or None, this is passed to new_callable
+ spec_set: Any | Literal[False] | None,
+ autospec: Literal[False] | None,
+ new_callable: Callable[..., _T],
+ # The kwargs must be DEFAULT
+ **kwargs: Any,
+ ) -> _patch_pass_arg[_T]: ...
+ @overload
+ @staticmethod
+ def multiple(
+ target: Any | str,
+ spec: Any | bool | None = None,
+ create: bool = False,
+ spec_set: Any | bool | None = None,
+ autospec: Any | bool | None = None,
+ new_callable: None = None,
+ # The kwargs are the mock objects or DEFAULT
**kwargs: Any,
) -> _patch[Any]: ...
@staticmethod
@@ -401,7 +476,7 @@ class _ANY:
def __ne__(self, other: object) -> Literal[False]: ...
__hash__: ClassVar[None] # type: ignore[assignment]
-ANY: Any
+ANY: _ANY
if sys.version_info >= (3, 10):
def create_autospec(
diff --git a/python/helpers/typeshed/stdlib/unittest/runner.pyi b/python/helpers/typeshed/stdlib/unittest/runner.pyi
index 783764464a53..f76771f55e13 100644
--- a/python/helpers/typeshed/stdlib/unittest/runner.pyi
+++ b/python/helpers/typeshed/stdlib/unittest/runner.pyi
@@ -4,15 +4,17 @@ import unittest.result
import unittest.suite
from _typeshed import SupportsFlush, SupportsWrite
from collections.abc import Callable, Iterable
-from typing import Any, Generic, Protocol, TypeVar
+from typing import Any, Generic, Protocol, TypeVar, type_check_only
from typing_extensions import Never, TypeAlias
from warnings import _ActionKind
_ResultClassType: TypeAlias = Callable[[_TextTestStream, bool, int], TextTestResult[Any]]
+@type_check_only
class _SupportsWriteAndFlush(SupportsWrite[str], SupportsFlush, Protocol): ...
# All methods used by unittest.runner.TextTestResult's stream
+@type_check_only
class _TextTestStream(_SupportsWriteAndFlush, Protocol):
def writeln(self, arg: str | None = None, /) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/unittest/util.pyi b/python/helpers/typeshed/stdlib/unittest/util.pyi
index 945b0cecfed0..31c830e8268a 100644
--- a/python/helpers/typeshed/stdlib/unittest/util.pyi
+++ b/python/helpers/typeshed/stdlib/unittest/util.pyi
@@ -5,12 +5,12 @@ from typing_extensions import TypeAlias
_T = TypeVar("_T")
_Mismatch: TypeAlias = tuple[_T, _T, int]
-_MAX_LENGTH: Final[int]
-_PLACEHOLDER_LEN: Final[int]
-_MIN_BEGIN_LEN: Final[int]
-_MIN_END_LEN: Final[int]
-_MIN_COMMON_LEN: Final[int]
-_MIN_DIFF_LEN: Final[int]
+_MAX_LENGTH: Final = 80
+_PLACEHOLDER_LEN: Final = 12
+_MIN_BEGIN_LEN: Final = 5
+_MIN_END_LEN: Final = 5
+_MIN_COMMON_LEN: Final = 5
+_MIN_DIFF_LEN: Final = 41
def _shorten(s: str, prefixlen: int, suffixlen: int) -> str: ...
def _common_shorten_repr(*args: str) -> tuple[str, ...]: ...
diff --git a/python/helpers/typeshed/stdlib/urllib/error.pyi b/python/helpers/typeshed/stdlib/urllib/error.pyi
index 89cec9bf289c..2173d7e6efaa 100644
--- a/python/helpers/typeshed/stdlib/urllib/error.pyi
+++ b/python/helpers/typeshed/stdlib/urllib/error.pyi
@@ -6,6 +6,8 @@ __all__ = ["URLError", "HTTPError", "ContentTooShortError"]
class URLError(OSError):
reason: str | BaseException
+ # The `filename` attribute only exists if it was provided to `__init__` and wasn't `None`.
+ filename: str
def __init__(self, reason: str | BaseException, filename: str | None = None) -> None: ...
class HTTPError(URLError, addinfourl):
@@ -16,6 +18,9 @@ class HTTPError(URLError, addinfourl):
@property
def reason(self) -> str: ... # type: ignore[override]
code: int
+ msg: str
+ hdrs: Message
+ fp: IO[bytes]
def __init__(self, url: str, code: int, msg: str, hdrs: Message, fp: IO[bytes] | None) -> None: ...
class ContentTooShortError(URLError):
diff --git a/python/helpers/typeshed/stdlib/urllib/parse.pyi b/python/helpers/typeshed/stdlib/urllib/parse.pyi
index a5ed616d25af..364892ecdf69 100644
--- a/python/helpers/typeshed/stdlib/urllib/parse.pyi
+++ b/python/helpers/typeshed/stdlib/urllib/parse.pyi
@@ -1,7 +1,7 @@
import sys
from collections.abc import Iterable, Mapping, Sequence
from types import GenericAlias
-from typing import Any, AnyStr, Generic, Literal, NamedTuple, Protocol, overload, type_check_only
+from typing import Any, AnyStr, Final, Generic, Literal, NamedTuple, Protocol, overload, type_check_only
from typing_extensions import TypeAlias
__all__ = [
@@ -28,23 +28,26 @@ __all__ = [
"SplitResultBytes",
]
-uses_relative: list[str]
-uses_netloc: list[str]
-uses_params: list[str]
-non_hierarchical: list[str]
-uses_query: list[str]
-uses_fragment: list[str]
-scheme_chars: str
+uses_relative: Final[list[str]]
+uses_netloc: Final[list[str]]
+uses_params: Final[list[str]]
+non_hierarchical: Final[list[str]]
+uses_query: Final[list[str]]
+uses_fragment: Final[list[str]]
+scheme_chars: Final[str]
if sys.version_info < (3, 11):
- MAX_CACHE_SIZE: int
+ MAX_CACHE_SIZE: Final[int]
class _ResultMixinStr:
+ __slots__ = ()
def encode(self, encoding: str = "ascii", errors: str = "strict") -> _ResultMixinBytes: ...
class _ResultMixinBytes:
+ __slots__ = ()
def decode(self, encoding: str = "ascii", errors: str = "strict") -> _ResultMixinStr: ...
class _NetlocResultMixinBase(Generic[AnyStr]):
+ __slots__ = ()
@property
def username(self) -> AnyStr | None: ...
@property
@@ -55,8 +58,11 @@ class _NetlocResultMixinBase(Generic[AnyStr]):
def port(self) -> int | None: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
-class _NetlocResultMixinStr(_NetlocResultMixinBase[str], _ResultMixinStr): ...
-class _NetlocResultMixinBytes(_NetlocResultMixinBase[bytes], _ResultMixinBytes): ...
+class _NetlocResultMixinStr(_NetlocResultMixinBase[str], _ResultMixinStr):
+ __slots__ = ()
+
+class _NetlocResultMixinBytes(_NetlocResultMixinBase[bytes], _ResultMixinBytes):
+ __slots__ = ()
class _DefragResultBase(NamedTuple, Generic[AnyStr]):
url: AnyStr
diff --git a/python/helpers/typeshed/stdlib/urllib/request.pyi b/python/helpers/typeshed/stdlib/urllib/request.pyi
index d8fc5e0d8f48..876b9d3f165c 100644
--- a/python/helpers/typeshed/stdlib/urllib/request.pyi
+++ b/python/helpers/typeshed/stdlib/urllib/request.pyi
@@ -6,7 +6,7 @@ from email.message import Message
from http.client import HTTPConnection, HTTPMessage, HTTPResponse
from http.cookiejar import CookieJar
from re import Pattern
-from typing import IO, Any, ClassVar, NoReturn, Protocol, TypeVar, overload
+from typing import IO, Any, ClassVar, NoReturn, Protocol, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias, deprecated
from urllib.error import HTTPError as HTTPError
from urllib.response import addclosehook, addinfourl
@@ -237,6 +237,7 @@ class ProxyDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
auth_header: ClassVar[str] # undocumented
def http_error_407(self, req: Request, fp: IO[bytes], code: int, msg: str, headers: HTTPMessage) -> _UrlopenRet | None: ...
+@type_check_only
class _HTTPConnectionProtocol(Protocol):
def __call__(
self,
@@ -324,7 +325,7 @@ def urlretrieve(
def urlcleanup() -> None: ...
if sys.version_info < (3, 14):
- @deprecated("Deprecated since Python 3.3; Removed in 3.14; Use newer urlopen functions and methods.")
+ @deprecated("Deprecated since Python 3.3; removed in Python 3.14. Use newer `urlopen` functions and methods.")
class URLopener:
version: ClassVar[str]
def __init__(self, proxies: dict[str, str] | None = None, **x509: str) -> None: ...
@@ -355,7 +356,7 @@ if sys.version_info < (3, 14):
def open_unknown_proxy(self, proxy: str, fullurl: str, data: ReadableBuffer | None = None) -> None: ... # undocumented
def __del__(self) -> None: ...
- @deprecated("Deprecated since Python 3.3; Removed in 3.14; Use newer urlopen functions and methods.")
+ @deprecated("Deprecated since Python 3.3; removed in Python 3.14. Use newer `urlopen` functions and methods.")
class FancyURLopener(URLopener):
def prompt_user_passwd(self, host: str, realm: str) -> tuple[str, str]: ...
def get_user_passwd(self, host: str, realm: str, clear_cache: int = 0) -> tuple[str, str]: ... # undocumented
diff --git a/python/helpers/typeshed/stdlib/uuid.pyi b/python/helpers/typeshed/stdlib/uuid.pyi
index 99ac6eb223ef..303fb10eaf53 100644
--- a/python/helpers/typeshed/stdlib/uuid.pyi
+++ b/python/helpers/typeshed/stdlib/uuid.pyi
@@ -12,6 +12,7 @@ class SafeUUID(Enum):
unknown = None
class UUID:
+ __slots__ = ("int", "is_safe", "__weakref__")
def __init__(
self,
hex: str | None = None,
@@ -21,7 +22,7 @@ class UUID:
int: builtins.int | None = None,
version: builtins.int | None = None,
*,
- is_safe: SafeUUID = ...,
+ is_safe: SafeUUID = SafeUUID.unknown,
) -> None: ...
@property
def is_safe(self) -> SafeUUID: ...
diff --git a/python/helpers/typeshed/stdlib/venv/__init__.pyi b/python/helpers/typeshed/stdlib/venv/__init__.pyi
index 0f71f0e073f5..14db88523dba 100644
--- a/python/helpers/typeshed/stdlib/venv/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/venv/__init__.pyi
@@ -3,10 +3,11 @@ import sys
from _typeshed import StrOrBytesPath
from collections.abc import Iterable, Sequence
from types import SimpleNamespace
+from typing import Final
logger: logging.Logger
-CORE_VENV_DEPS: tuple[str, ...]
+CORE_VENV_DEPS: Final[tuple[str, ...]]
class EnvBuilder:
system_site_packages: bool
diff --git a/python/helpers/typeshed/stdlib/wave.pyi b/python/helpers/typeshed/stdlib/wave.pyi
index ddc6f6bd02a5..fd7dbfade884 100644
--- a/python/helpers/typeshed/stdlib/wave.pyi
+++ b/python/helpers/typeshed/stdlib/wave.pyi
@@ -1,3 +1,4 @@
+import sys
from _typeshed import ReadableBuffer, Unused
from typing import IO, Any, BinaryIO, Final, Literal, NamedTuple, NoReturn, overload
from typing_extensions import Self, TypeAlias, deprecated
@@ -8,7 +9,7 @@ _File: TypeAlias = str | IO[bytes]
class Error(Exception): ...
-WAVE_FORMAT_PCM: Final = 1
+WAVE_FORMAT_PCM: Final = 0x0001
class _wave_params(NamedTuple):
nchannels: int
@@ -34,10 +35,15 @@ class Wave_read:
def getcomptype(self) -> str: ...
def getcompname(self) -> str: ...
def getparams(self) -> _wave_params: ...
- @deprecated("Deprecated in Python 3.13; removal scheduled for Python 3.15")
- def getmarkers(self) -> None: ...
- @deprecated("Deprecated in Python 3.13; removal scheduled for Python 3.15")
- def getmark(self, id: Any) -> NoReturn: ...
+ if sys.version_info >= (3, 13):
+ @deprecated("Deprecated since Python 3.13; will be removed in Python 3.15.")
+ def getmarkers(self) -> None: ...
+ @deprecated("Deprecated since Python 3.13; will be removed in Python 3.15.")
+ def getmark(self, id: Any) -> NoReturn: ...
+ else:
+ def getmarkers(self) -> None: ...
+ def getmark(self, id: Any) -> NoReturn: ...
+
def setpos(self, pos: int) -> None: ...
def readframes(self, nframes: int) -> bytes: ...
@@ -59,12 +65,18 @@ class Wave_write:
def getcompname(self) -> str: ...
def setparams(self, params: _wave_params | tuple[int, int, int, int, str, str]) -> None: ...
def getparams(self) -> _wave_params: ...
- @deprecated("Deprecated in Python 3.13; removal scheduled for Python 3.15")
- def setmark(self, id: Any, pos: Any, name: Any) -> NoReturn: ...
- @deprecated("Deprecated in Python 3.13; removal scheduled for Python 3.15")
- def getmark(self, id: Any) -> NoReturn: ...
- @deprecated("Deprecated in Python 3.13; removal scheduled for Python 3.15")
- def getmarkers(self) -> None: ...
+ if sys.version_info >= (3, 13):
+ @deprecated("Deprecated since Python 3.13; will be removed in Python 3.15.")
+ def setmark(self, id: Any, pos: Any, name: Any) -> NoReturn: ...
+ @deprecated("Deprecated since Python 3.13; will be removed in Python 3.15.")
+ def getmark(self, id: Any) -> NoReturn: ...
+ @deprecated("Deprecated since Python 3.13; will be removed in Python 3.15.")
+ def getmarkers(self) -> None: ...
+ else:
+ def setmark(self, id: Any, pos: Any, name: Any) -> NoReturn: ...
+ def getmark(self, id: Any) -> NoReturn: ...
+ def getmarkers(self) -> None: ...
+
def tell(self) -> int: ...
def writeframesraw(self, data: ReadableBuffer) -> None: ...
def writeframes(self, data: ReadableBuffer) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/weakref.pyi b/python/helpers/typeshed/stdlib/weakref.pyi
index 593eb4615c8f..90206492cab9 100644
--- a/python/helpers/typeshed/stdlib/weakref.pyi
+++ b/python/helpers/typeshed/stdlib/weakref.pyi
@@ -65,6 +65,7 @@ ref = ReferenceType
# everything below here is implemented in weakref.py
class WeakMethod(ref[_CallableT]):
+ __slots__ = ("_func_ref", "_meth_type", "_alive", "__weakref__")
def __new__(cls, meth: _CallableT, callback: Callable[[Self], Any] | None = None) -> Self: ...
def __call__(self) -> _CallableT | None: ...
def __eq__(self, other: object) -> bool: ...
@@ -99,6 +100,8 @@ class WeakValueDictionary(MutableMapping[_KT, _VT]):
@overload
def get(self, key: _KT, default: None = None) -> _VT | None: ...
@overload
+ def get(self, key: _KT, default: _VT) -> _VT: ...
+ @overload
def get(self, key: _KT, default: _T) -> _VT | _T: ...
# These are incompatible with Mapping
def keys(self) -> Iterator[_KT]: ... # type: ignore[override]
@@ -128,6 +131,7 @@ class WeakValueDictionary(MutableMapping[_KT, _VT]):
def __ior__(self, other: Iterable[tuple[_KT, _VT]]) -> Self: ...
class KeyedRef(ref[_T], Generic[_KT, _T]):
+ __slots__ = ("key",)
key: _KT
def __new__(type, ob: _T, callback: Callable[[Self], Any], key: _KT) -> Self: ...
def __init__(self, ob: _T, callback: Callable[[Self], Any], key: _KT) -> None: ...
@@ -149,6 +153,8 @@ class WeakKeyDictionary(MutableMapping[_KT, _VT]):
@overload
def get(self, key: _KT, default: None = None) -> _VT | None: ...
@overload
+ def get(self, key: _KT, default: _VT) -> _VT: ...
+ @overload
def get(self, key: _KT, default: _T) -> _VT | _T: ...
# These are incompatible with Mapping
def keys(self) -> Iterator[_KT]: ... # type: ignore[override]
@@ -181,6 +187,7 @@ class WeakKeyDictionary(MutableMapping[_KT, _VT]):
def __ior__(self, other: Iterable[tuple[_KT, _VT]]) -> Self: ...
class finalize(Generic[_P, _T]):
+ __slots__ = ()
def __init__(self, obj: _T, func: Callable[_P, Any], /, *args: _P.args, **kwargs: _P.kwargs) -> None: ...
def __call__(self, _: Any = None) -> Any | None: ...
def detach(self) -> tuple[_T, Callable[_P, Any], tuple[Any, ...], dict[str, Any]] | None: ...
diff --git a/python/helpers/typeshed/stdlib/webbrowser.pyi b/python/helpers/typeshed/stdlib/webbrowser.pyi
index 773786c24821..56c30f872727 100644
--- a/python/helpers/typeshed/stdlib/webbrowser.pyi
+++ b/python/helpers/typeshed/stdlib/webbrowser.pyi
@@ -64,10 +64,16 @@ if sys.platform == "win32":
if sys.platform == "darwin":
if sys.version_info < (3, 13):
- @deprecated("Deprecated in 3.11, to be removed in 3.13.")
- class MacOSX(BaseBrowser):
- def __init__(self, name: str) -> None: ...
- def open(self, url: str, new: int = 0, autoraise: bool = True) -> bool: ...
+ if sys.version_info >= (3, 11):
+ @deprecated("Deprecated since Python 3.11; removed in Python 3.13.")
+ class MacOSX(BaseBrowser):
+ def __init__(self, name: str) -> None: ...
+ def open(self, url: str, new: int = 0, autoraise: bool = True) -> bool: ...
+
+ else:
+ class MacOSX(BaseBrowser):
+ def __init__(self, name: str) -> None: ...
+ def open(self, url: str, new: int = 0, autoraise: bool = True) -> bool: ...
class MacOSXOSAScript(BaseBrowser): # In runtime this class does not have `name` and `basename`
if sys.version_info >= (3, 11):
diff --git a/python/helpers/typeshed/stdlib/winreg.pyi b/python/helpers/typeshed/stdlib/winreg.pyi
index d4d04817d7e0..53457112ee96 100644
--- a/python/helpers/typeshed/stdlib/winreg.pyi
+++ b/python/helpers/typeshed/stdlib/winreg.pyi
@@ -59,13 +59,13 @@ if sys.platform == "win32":
def EnableReflectionKey(key: _KeyType, /) -> None: ...
def QueryReflectionKey(key: _KeyType, /) -> bool: ...
- HKEY_CLASSES_ROOT: int
- HKEY_CURRENT_USER: int
- HKEY_LOCAL_MACHINE: int
- HKEY_USERS: int
- HKEY_PERFORMANCE_DATA: int
- HKEY_CURRENT_CONFIG: int
- HKEY_DYN_DATA: int
+ HKEY_CLASSES_ROOT: Final[int]
+ HKEY_CURRENT_USER: Final[int]
+ HKEY_LOCAL_MACHINE: Final[int]
+ HKEY_USERS: Final[int]
+ HKEY_PERFORMANCE_DATA: Final[int]
+ HKEY_CURRENT_CONFIG: Final[int]
+ HKEY_DYN_DATA: Final[int]
KEY_ALL_ACCESS: Final = 983103
KEY_WRITE: Final = 131078
@@ -123,7 +123,7 @@ if sys.platform == "win32":
def __int__(self) -> int: ...
def __enter__(self) -> Self: ...
def __exit__(
- self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
+ self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None, /
) -> bool | None: ...
def Close(self) -> None: ...
def Detach(self) -> int: ...
diff --git a/python/helpers/typeshed/stdlib/wsgiref/headers.pyi b/python/helpers/typeshed/stdlib/wsgiref/headers.pyi
index 2654d79bf4e5..9febad4b3277 100644
--- a/python/helpers/typeshed/stdlib/wsgiref/headers.pyi
+++ b/python/helpers/typeshed/stdlib/wsgiref/headers.pyi
@@ -1,10 +1,10 @@
from re import Pattern
-from typing import overload
+from typing import Final, overload
from typing_extensions import TypeAlias
_HeaderList: TypeAlias = list[tuple[str, str]]
-tspecials: Pattern[str] # undocumented
+tspecials: Final[Pattern[str]] # undocumented
class Headers:
def __init__(self, headers: _HeaderList | None = None) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/wsgiref/simple_server.pyi b/python/helpers/typeshed/stdlib/wsgiref/simple_server.pyi
index 547f562cc1d4..bdf58719c828 100644
--- a/python/helpers/typeshed/stdlib/wsgiref/simple_server.pyi
+++ b/python/helpers/typeshed/stdlib/wsgiref/simple_server.pyi
@@ -1,14 +1,14 @@
from _typeshed.wsgi import ErrorStream, StartResponse, WSGIApplication, WSGIEnvironment
from http.server import BaseHTTPRequestHandler, HTTPServer
-from typing import TypeVar, overload
+from typing import Final, TypeVar, overload
from .handlers import SimpleHandler
__all__ = ["WSGIServer", "WSGIRequestHandler", "demo_app", "make_server"]
-server_version: str # undocumented
-sys_version: str # undocumented
-software_version: str # undocumented
+server_version: Final[str] # undocumented
+sys_version: Final[str] # undocumented
+software_version: Final[str] # undocumented
class ServerHandler(SimpleHandler): # undocumented
server_software: str
diff --git a/python/helpers/typeshed/stdlib/xml/dom/NodeFilter.pyi b/python/helpers/typeshed/stdlib/xml/dom/NodeFilter.pyi
index 007df982e06a..7b301373f528 100644
--- a/python/helpers/typeshed/stdlib/xml/dom/NodeFilter.pyi
+++ b/python/helpers/typeshed/stdlib/xml/dom/NodeFilter.pyi
@@ -1,22 +1,22 @@
-from typing import Literal
+from typing import Final
from xml.dom.minidom import Node
class NodeFilter:
- FILTER_ACCEPT: Literal[1]
- FILTER_REJECT: Literal[2]
- FILTER_SKIP: Literal[3]
+ FILTER_ACCEPT: Final = 1
+ FILTER_REJECT: Final = 2
+ FILTER_SKIP: Final = 3
- SHOW_ALL: int
- SHOW_ELEMENT: int
- SHOW_ATTRIBUTE: int
- SHOW_TEXT: int
- SHOW_CDATA_SECTION: int
- SHOW_ENTITY_REFERENCE: int
- SHOW_ENTITY: int
- SHOW_PROCESSING_INSTRUCTION: int
- SHOW_COMMENT: int
- SHOW_DOCUMENT: int
- SHOW_DOCUMENT_TYPE: int
- SHOW_DOCUMENT_FRAGMENT: int
- SHOW_NOTATION: int
+ SHOW_ALL: Final = 0xFFFFFFFF
+ SHOW_ELEMENT: Final = 0x00000001
+ SHOW_ATTRIBUTE: Final = 0x00000002
+ SHOW_TEXT: Final = 0x00000004
+ SHOW_CDATA_SECTION: Final = 0x00000008
+ SHOW_ENTITY_REFERENCE: Final = 0x00000010
+ SHOW_ENTITY: Final = 0x00000020
+ SHOW_PROCESSING_INSTRUCTION: Final = 0x00000040
+ SHOW_COMMENT: Final = 0x00000080
+ SHOW_DOCUMENT: Final = 0x00000100
+ SHOW_DOCUMENT_TYPE: Final = 0x00000200
+ SHOW_DOCUMENT_FRAGMENT: Final = 0x00000400
+ SHOW_NOTATION: Final = 0x00000800
def acceptNode(self, node: Node) -> int: ...
diff --git a/python/helpers/typeshed/stdlib/xml/dom/__init__.pyi b/python/helpers/typeshed/stdlib/xml/dom/__init__.pyi
index d9615f9aacfe..5dbb6c536f61 100644
--- a/python/helpers/typeshed/stdlib/xml/dom/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/xml/dom/__init__.pyi
@@ -3,18 +3,19 @@ from typing import Any, Final, Literal
from .domreg import getDOMImplementation as getDOMImplementation, registerDOMImplementation as registerDOMImplementation
class Node:
- ELEMENT_NODE: Literal[1]
- ATTRIBUTE_NODE: Literal[2]
- TEXT_NODE: Literal[3]
- CDATA_SECTION_NODE: Literal[4]
- ENTITY_REFERENCE_NODE: Literal[5]
- ENTITY_NODE: Literal[6]
- PROCESSING_INSTRUCTION_NODE: Literal[7]
- COMMENT_NODE: Literal[8]
- DOCUMENT_NODE: Literal[9]
- DOCUMENT_TYPE_NODE: Literal[10]
- DOCUMENT_FRAGMENT_NODE: Literal[11]
- NOTATION_NODE: Literal[12]
+ __slots__ = ()
+ ELEMENT_NODE: Final = 1
+ ATTRIBUTE_NODE: Final = 2
+ TEXT_NODE: Final = 3
+ CDATA_SECTION_NODE: Final = 4
+ ENTITY_REFERENCE_NODE: Final = 5
+ ENTITY_NODE: Final = 6
+ PROCESSING_INSTRUCTION_NODE: Final = 7
+ COMMENT_NODE: Final = 8
+ DOCUMENT_NODE: Final = 9
+ DOCUMENT_TYPE_NODE: Final = 10
+ DOCUMENT_FRAGMENT_NODE: Final = 11
+ NOTATION_NODE: Final = 12
# ExceptionCode
INDEX_SIZE_ERR: Final = 1
@@ -88,10 +89,10 @@ class ValidationErr(DOMException):
code: Literal[16]
class UserDataHandler:
- NODE_CLONED: Literal[1]
- NODE_IMPORTED: Literal[2]
- NODE_DELETED: Literal[3]
- NODE_RENAMED: Literal[4]
+ NODE_CLONED: Final = 1
+ NODE_IMPORTED: Final = 2
+ NODE_DELETED: Final = 3
+ NODE_RENAMED: Final = 4
XML_NAMESPACE: Final = "http://www.w3.org/XML/1998/namespace"
XMLNS_NAMESPACE: Final = "http://www.w3.org/2000/xmlns/"
diff --git a/python/helpers/typeshed/stdlib/xml/dom/expatbuilder.pyi b/python/helpers/typeshed/stdlib/xml/dom/expatbuilder.pyi
index 228ad07e15ad..2b9ac8876970 100644
--- a/python/helpers/typeshed/stdlib/xml/dom/expatbuilder.pyi
+++ b/python/helpers/typeshed/stdlib/xml/dom/expatbuilder.pyi
@@ -1,5 +1,5 @@
from _typeshed import ReadableBuffer, SupportsRead
-from typing import Any, NoReturn
+from typing import Any, Final, NoReturn
from typing_extensions import TypeAlias
from xml.dom.minidom import Document, DocumentFragment, DOMImplementation, Element, Node, TypeInfo
from xml.dom.xmlbuilder import DOMBuilderFilter, Options
@@ -7,16 +7,17 @@ from xml.parsers.expat import XMLParserType
_Model: TypeAlias = tuple[int, int, str | None, tuple[Any, ...]] # same as in pyexpat
-TEXT_NODE = Node.TEXT_NODE
-CDATA_SECTION_NODE = Node.CDATA_SECTION_NODE
-DOCUMENT_NODE = Node.DOCUMENT_NODE
-FILTER_ACCEPT = DOMBuilderFilter.FILTER_ACCEPT
-FILTER_REJECT = DOMBuilderFilter.FILTER_REJECT
-FILTER_SKIP = DOMBuilderFilter.FILTER_SKIP
-FILTER_INTERRUPT = DOMBuilderFilter.FILTER_INTERRUPT
+TEXT_NODE: Final = Node.TEXT_NODE
+CDATA_SECTION_NODE: Final = Node.CDATA_SECTION_NODE
+DOCUMENT_NODE: Final = Node.DOCUMENT_NODE
+FILTER_ACCEPT: Final = DOMBuilderFilter.FILTER_ACCEPT
+FILTER_REJECT: Final = DOMBuilderFilter.FILTER_REJECT
+FILTER_SKIP: Final = DOMBuilderFilter.FILTER_SKIP
+FILTER_INTERRUPT: Final = DOMBuilderFilter.FILTER_INTERRUPT
theDOMImplementation: DOMImplementation
class ElementInfo:
+ __slots__ = ("_attr_info", "_model", "tagName")
tagName: str
def __init__(self, tagName: str, model: _Model | None = None) -> None: ...
def getAttributeType(self, aname: str) -> TypeInfo: ...
@@ -66,19 +67,23 @@ class ExpatBuilder:
def xml_decl_handler(self, version: str, encoding: str | None, standalone: int) -> None: ...
class FilterVisibilityController:
+ __slots__ = ("filter",)
filter: DOMBuilderFilter
def __init__(self, filter: DOMBuilderFilter) -> None: ...
def startContainer(self, node: Node) -> int: ...
def acceptNode(self, node: Node) -> int: ...
class FilterCrutch:
+ __slots__ = ("_builder", "_level", "_old_start", "_old_end")
def __init__(self, builder: ExpatBuilder) -> None: ...
class Rejecter(FilterCrutch):
+ __slots__ = ()
def start_element_handler(self, *args: Any) -> None: ...
def end_element_handler(self, *args: Any) -> None: ...
class Skipper(FilterCrutch):
+ __slots__ = ()
def start_element_handler(self, *args: Any) -> None: ...
def end_element_handler(self, *args: Any) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/xml/dom/minicompat.pyi b/python/helpers/typeshed/stdlib/xml/dom/minicompat.pyi
index 162f60254a58..6fcaee019dc2 100644
--- a/python/helpers/typeshed/stdlib/xml/dom/minicompat.pyi
+++ b/python/helpers/typeshed/stdlib/xml/dom/minicompat.pyi
@@ -8,11 +8,13 @@ _T = TypeVar("_T")
StringTypes: tuple[type[str]]
class NodeList(list[_T]):
+ __slots__ = ()
@property
def length(self) -> int: ...
def item(self, index: int) -> _T | None: ...
class EmptyNodeList(tuple[()]):
+ __slots__ = ()
@property
def length(self) -> Literal[0]: ...
def item(self, index: int) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/xml/dom/minidom.pyi b/python/helpers/typeshed/stdlib/xml/dom/minidom.pyi
index ab2ef87e38a8..e0431417aa3c 100644
--- a/python/helpers/typeshed/stdlib/xml/dom/minidom.pyi
+++ b/python/helpers/typeshed/stdlib/xml/dom/minidom.pyi
@@ -3,7 +3,7 @@ from _collections_abc import dict_keys, dict_values
from _typeshed import Incomplete, ReadableBuffer, SupportsRead, SupportsWrite
from collections.abc import Iterable, Sequence
from types import TracebackType
-from typing import Any, ClassVar, Generic, Literal, NoReturn, Protocol, TypeVar, overload
+from typing import Any, ClassVar, Generic, Literal, NoReturn, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias
from xml.dom.minicompat import EmptyNodeList, NodeList
from xml.dom.xmlbuilder import DocumentLS, DOMImplementationLS
@@ -40,9 +40,11 @@ _ImportableNodeVar = TypeVar(
| Notation,
)
+@type_check_only
class _DOMErrorHandler(Protocol):
def handleError(self, error: Exception) -> bool: ...
+@type_check_only
class _UserDataHandler(Protocol):
def handle(self, operation: int, key: str, data: Any, src: Node, dst: Node) -> None: ...
@@ -186,6 +188,7 @@ _AttrChildrenVar = TypeVar("_AttrChildrenVar", bound=_AttrChildren)
_AttrChildrenPlusFragment = TypeVar("_AttrChildrenPlusFragment", bound=_AttrChildren | DocumentFragment)
class Attr(Node):
+ __slots__ = ("_name", "_value", "namespaceURI", "_prefix", "childNodes", "_localName", "ownerDocument", "ownerElement")
nodeType: ClassVar[Literal[2]]
nodeName: str # same as Attr.name
nodeValue: str # same as Attr.value
@@ -229,6 +232,7 @@ class Attr(Node):
# In the DOM, this interface isn't specific to Attr, but our implementation is
# because that's the only place we use it.
class NamedNodeMap:
+ __slots__ = ("_attrs", "_attrsNS", "_ownerElement")
def __init__(self, attrs: dict[str, Attr], attrsNS: dict[_NSName, Attr], ownerElement: Element) -> None: ...
@property
def length(self) -> int: ...
@@ -260,6 +264,7 @@ class NamedNodeMap:
AttributeList = NamedNodeMap
class TypeInfo:
+ __slots__ = ("namespace", "name")
namespace: str | None
name: str | None
def __init__(self, namespace: Incomplete | None, name: str | None) -> None: ...
@@ -268,6 +273,20 @@ _ElementChildrenVar = TypeVar("_ElementChildrenVar", bound=_ElementChildren)
_ElementChildrenPlusFragment = TypeVar("_ElementChildrenPlusFragment", bound=_ElementChildren | DocumentFragment)
class Element(Node):
+ __slots__ = (
+ "ownerDocument",
+ "parentNode",
+ "tagName",
+ "nodeName",
+ "prefix",
+ "namespaceURI",
+ "_localName",
+ "childNodes",
+ "_attrs",
+ "_attrsNS",
+ "nextSibling",
+ "previousSibling",
+ )
nodeType: ClassVar[Literal[1]]
nodeName: str # same as Element.tagName
nodeValue: None
@@ -329,6 +348,7 @@ class Element(Node):
def removeChild(self, oldChild: _ElementChildrenVar) -> _ElementChildrenVar: ... # type: ignore[override]
class Childless:
+ __slots__ = ()
attributes: None
childNodes: EmptyNodeList
@property
@@ -345,6 +365,7 @@ class Childless:
def replaceChild(self, newChild: _NodesThatAreChildren | DocumentFragment, oldChild: _NodesThatAreChildren) -> NoReturn: ...
class ProcessingInstruction(Childless, Node):
+ __slots__ = ("target", "data")
nodeType: ClassVar[Literal[7]]
nodeName: str # same as ProcessingInstruction.target
nodeValue: str # same as ProcessingInstruction.data
@@ -371,6 +392,7 @@ class ProcessingInstruction(Childless, Node):
def writexml(self, writer: SupportsWrite[str], indent: str = "", addindent: str = "", newl: str = "") -> None: ...
class CharacterData(Childless, Node):
+ __slots__ = ("_data", "ownerDocument", "parentNode", "previousSibling", "nextSibling")
nodeValue: str
attributes: None
@@ -395,6 +417,7 @@ class CharacterData(Childless, Node):
def replaceData(self, offset: int, count: int, arg: str) -> None: ...
class Text(CharacterData):
+ __slots__ = ()
nodeType: ClassVar[Literal[3]]
nodeName: Literal["#text"]
nodeValue: str # same as CharacterData.data, the content of the text node
@@ -446,6 +469,7 @@ class Comment(CharacterData):
def writexml(self, writer: SupportsWrite[str], indent: str = "", addindent: str = "", newl: str = "") -> None: ...
class CDATASection(Text):
+ __slots__ = ()
nodeType: ClassVar[Literal[4]] # type: ignore[assignment]
nodeName: Literal["#cdata-section"] # type: ignore[assignment]
nodeValue: str # same as CharacterData.data, the content of the CDATA Section
@@ -458,6 +482,7 @@ class CDATASection(Text):
def writexml(self, writer: SupportsWrite[str], indent: str = "", addindent: str = "", newl: str = "") -> None: ...
class ReadOnlySequentialNamedNodeMap(Generic[_N]):
+ __slots__ = ("_seq",)
def __init__(self, seq: Sequence[_N] = ()) -> None: ...
def __len__(self) -> int: ...
def getNamedItem(self, name: str) -> _N | None: ...
@@ -472,6 +497,7 @@ class ReadOnlySequentialNamedNodeMap(Generic[_N]):
def length(self) -> int: ...
class Identified:
+ __slots__ = ("publicId", "systemId")
publicId: str | None
systemId: str | None
@@ -563,6 +589,7 @@ class DOMImplementation(DOMImplementationLS):
def getInterface(self, feature: str) -> Self | None: ...
class ElementInfo:
+ __slots__ = ("tagName",)
tagName: str
def __init__(self, name: str) -> None: ...
def getAttributeType(self, aname: str) -> TypeInfo: ...
@@ -575,6 +602,7 @@ class ElementInfo:
_DocumentChildrenPlusFragment = TypeVar("_DocumentChildrenPlusFragment", bound=_DocumentChildren | DocumentFragment)
class Document(Node, DocumentLS):
+ __slots__ = ("_elem_info", "doctype", "_id_search_stack", "childNodes", "_id_cache")
nodeType: ClassVar[Literal[9]]
nodeName: Literal["#document"]
nodeValue: None
diff --git a/python/helpers/typeshed/stdlib/xml/dom/pulldom.pyi b/python/helpers/typeshed/stdlib/xml/dom/pulldom.pyi
index d9458654c185..df7a3ad0eddb 100644
--- a/python/helpers/typeshed/stdlib/xml/dom/pulldom.pyi
+++ b/python/helpers/typeshed/stdlib/xml/dom/pulldom.pyi
@@ -99,7 +99,7 @@ class SAX2DOM(PullDOM):
def ignorableWhitespace(self, chars: str) -> None: ...
def characters(self, chars: str) -> None: ...
-default_bufsize: int
+default_bufsize: Final[int]
def parse(
stream_or_string: str | _SupportsReadClose[bytes] | _SupportsReadClose[str],
diff --git a/python/helpers/typeshed/stdlib/xml/dom/xmlbuilder.pyi b/python/helpers/typeshed/stdlib/xml/dom/xmlbuilder.pyi
index 6fb18bbc4eda..f19f7050b08d 100644
--- a/python/helpers/typeshed/stdlib/xml/dom/xmlbuilder.pyi
+++ b/python/helpers/typeshed/stdlib/xml/dom/xmlbuilder.pyi
@@ -1,5 +1,5 @@
from _typeshed import SupportsRead
-from typing import Any, Literal, NoReturn
+from typing import Any, Final, Literal, NoReturn
from xml.dom.minidom import Document, Node, _DOMErrorHandler
__all__ = ["DOMBuilder", "DOMEntityResolver", "DOMInputSource"]
@@ -29,10 +29,10 @@ class DOMBuilder:
entityResolver: DOMEntityResolver | None
errorHandler: _DOMErrorHandler | None
filter: DOMBuilderFilter | None
- ACTION_REPLACE: Literal[1]
- ACTION_APPEND_AS_CHILDREN: Literal[2]
- ACTION_INSERT_AFTER: Literal[3]
- ACTION_INSERT_BEFORE: Literal[4]
+ ACTION_REPLACE: Final = 1
+ ACTION_APPEND_AS_CHILDREN: Final = 2
+ ACTION_INSERT_AFTER: Final = 3
+ ACTION_INSERT_BEFORE: Final = 4
def __init__(self) -> None: ...
def setFeature(self, name: str, state: int) -> None: ...
def supportsFeature(self, name: str) -> bool: ...
@@ -44,9 +44,11 @@ class DOMBuilder:
def parseWithContext(self, input: DOMInputSource, cnode: Node, action: Literal[1, 2, 3, 4]) -> NoReturn: ...
class DOMEntityResolver:
+ __slots__ = ("_opener",)
def resolveEntity(self, publicId: str | None, systemId: str) -> DOMInputSource: ...
class DOMInputSource:
+ __slots__ = ("byteStream", "characterStream", "stringData", "encoding", "publicId", "systemId", "baseURI")
byteStream: SupportsRead[bytes] | None
characterStream: SupportsRead[str] | None
stringData: str | None
@@ -56,10 +58,10 @@ class DOMInputSource:
baseURI: str | None
class DOMBuilderFilter:
- FILTER_ACCEPT: Literal[1]
- FILTER_REJECT: Literal[2]
- FILTER_SKIP: Literal[3]
- FILTER_INTERRUPT: Literal[4]
+ FILTER_ACCEPT: Final = 1
+ FILTER_REJECT: Final = 2
+ FILTER_SKIP: Final = 3
+ FILTER_INTERRUPT: Final = 4
whatToShow: int
def acceptNode(self, element: Node) -> Literal[1, 2, 3, 4]: ...
def startContainer(self, element: Node) -> Literal[1, 2, 3, 4]: ...
@@ -72,8 +74,8 @@ class DocumentLS:
def saveXML(self, snode: Node | None) -> str: ...
class DOMImplementationLS:
- MODE_SYNCHRONOUS: Literal[1]
- MODE_ASYNCHRONOUS: Literal[2]
+ MODE_SYNCHRONOUS: Final = 1
+ MODE_ASYNCHRONOUS: Final = 2
def createDOMBuilder(self, mode: Literal[1], schemaType: None) -> DOMBuilder: ...
def createDOMWriter(self) -> NoReturn: ...
def createDOMInputSource(self) -> DOMInputSource: ...
diff --git a/python/helpers/typeshed/stdlib/xml/etree/ElementInclude.pyi b/python/helpers/typeshed/stdlib/xml/etree/ElementInclude.pyi
index 8f20ee15a14e..10784e7d4021 100644
--- a/python/helpers/typeshed/stdlib/xml/etree/ElementInclude.pyi
+++ b/python/helpers/typeshed/stdlib/xml/etree/ElementInclude.pyi
@@ -1,16 +1,18 @@
from _typeshed import FileDescriptorOrPath
-from typing import Final, Literal, Protocol, overload
+from typing import Final, Literal, Protocol, overload, type_check_only
from xml.etree.ElementTree import Element
+@type_check_only
class _Loader(Protocol):
@overload
def __call__(self, href: FileDescriptorOrPath, parse: Literal["xml"], encoding: str | None = None) -> Element: ...
@overload
def __call__(self, href: FileDescriptorOrPath, parse: Literal["text"], encoding: str | None = None) -> str: ...
-XINCLUDE: Final[str]
-XINCLUDE_INCLUDE: Final[str]
-XINCLUDE_FALLBACK: Final[str]
+XINCLUDE: Final = "{http://www.w3.org/2001/XInclude}"
+
+XINCLUDE_INCLUDE: Final = "{http://www.w3.org/2001/XInclude}include"
+XINCLUDE_FALLBACK: Final = "{http://www.w3.org/2001/XInclude}fallback"
DEFAULT_MAX_INCLUSION_DEPTH: Final = 6
diff --git a/python/helpers/typeshed/stdlib/xml/etree/ElementPath.pyi b/python/helpers/typeshed/stdlib/xml/etree/ElementPath.pyi
index ebfb4f1ffbb9..80f3c55c1489 100644
--- a/python/helpers/typeshed/stdlib/xml/etree/ElementPath.pyi
+++ b/python/helpers/typeshed/stdlib/xml/etree/ElementPath.pyi
@@ -1,10 +1,10 @@
from collections.abc import Callable, Generator, Iterable
from re import Pattern
-from typing import Any, Literal, TypeVar, overload
+from typing import Any, Final, Literal, TypeVar, overload
from typing_extensions import TypeAlias
from xml.etree.ElementTree import Element
-xpath_tokenizer_re: Pattern[str]
+xpath_tokenizer_re: Final[Pattern[str]]
_Token: TypeAlias = tuple[str, str]
_Next: TypeAlias = Callable[[], _Token]
@@ -20,7 +20,7 @@ def prepare_descendant(next: _Next, token: _Token) -> _Callback | None: ...
def prepare_parent(next: _Next, token: _Token) -> _Callback: ...
def prepare_predicate(next: _Next, token: _Token) -> _Callback | None: ...
-ops: dict[str, Callable[[_Next, _Token], _Callback | None]]
+ops: Final[dict[str, Callable[[_Next, _Token], _Callback | None]]]
class _SelectorContext:
parent_map: dict[Element, Element] | None
diff --git a/python/helpers/typeshed/stdlib/xml/etree/ElementTree.pyi b/python/helpers/typeshed/stdlib/xml/etree/ElementTree.pyi
index 4c55a1a7452e..ff41c5dc6da4 100644
--- a/python/helpers/typeshed/stdlib/xml/etree/ElementTree.pyi
+++ b/python/helpers/typeshed/stdlib/xml/etree/ElementTree.pyi
@@ -78,10 +78,8 @@ def canonicalize(
) -> None: ...
# The tag for Element can be set to the Comment or ProcessingInstruction
-# functions defined in this module. _ElementCallable could be a recursive
-# type, but defining it that way uncovered a bug in pytype.
-_ElementCallable: TypeAlias = Callable[..., Element[Any]]
-_CallableElement: TypeAlias = Element[_ElementCallable]
+# functions defined in this module.
+_ElementCallable: TypeAlias = Callable[..., Element[_ElementCallable]]
_Tag = TypeVar("_Tag", default=str, bound=str | _ElementCallable)
_OtherTag = TypeVar("_OtherTag", default=str, bound=str | _ElementCallable)
@@ -138,8 +136,8 @@ class Element(Generic[_Tag]):
def __bool__(self) -> bool: ...
def SubElement(parent: Element, tag: str, attrib: dict[str, str] = ..., **extra: str) -> Element: ...
-def Comment(text: str | None = None) -> _CallableElement: ...
-def ProcessingInstruction(target: str, text: str | None = None) -> _CallableElement: ...
+def Comment(text: str | None = None) -> Element[_ElementCallable]: ...
+def ProcessingInstruction(target: str, text: str | None = None) -> Element[_ElementCallable]: ...
PI = ProcessingInstruction
@@ -182,7 +180,7 @@ class ElementTree(Generic[_Root]):
) -> None: ...
def write_c14n(self, file: _FileWriteC14N) -> None: ...
-HTML_EMPTY: set[str]
+HTML_EMPTY: Final[set[str]]
def register_namespace(prefix: str, uri: str) -> None: ...
@overload
@@ -335,6 +333,7 @@ class C14NWriterTarget:
# The target type is tricky, because the implementation doesn't
# require any particular attribute to be present. This documents the attributes
# that can be present, but uncommenting any of them would require them.
+@type_check_only
class _Target(Protocol):
# start: Callable[str, dict[str, str], Any] | None
# end: Callable[[str], Any] | None
diff --git a/python/helpers/typeshed/stdlib/xml/sax/__init__.pyi b/python/helpers/typeshed/stdlib/xml/sax/__init__.pyi
index ebe92d28c74d..679466fa34d2 100644
--- a/python/helpers/typeshed/stdlib/xml/sax/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/xml/sax/__init__.pyi
@@ -1,7 +1,7 @@
import sys
from _typeshed import ReadableBuffer, StrPath, SupportsRead, _T_co
from collections.abc import Iterable
-from typing import Protocol
+from typing import Final, Protocol, type_check_only
from typing_extensions import TypeAlias
from xml.sax._exceptions import (
SAXException as SAXException,
@@ -13,12 +13,13 @@ from xml.sax._exceptions import (
from xml.sax.handler import ContentHandler as ContentHandler, ErrorHandler as ErrorHandler
from xml.sax.xmlreader import InputSource as InputSource, XMLReader
+@type_check_only
class _SupportsReadClose(SupportsRead[_T_co], Protocol[_T_co]):
def close(self) -> None: ...
_Source: TypeAlias = StrPath | _SupportsReadClose[bytes] | _SupportsReadClose[str]
-default_parser_list: list[str]
+default_parser_list: Final[list[str]]
def make_parser(parser_list: Iterable[str] = ()) -> XMLReader: ...
def parse(source: _Source, handler: ContentHandler, errorHandler: ErrorHandler = ...) -> None: ...
diff --git a/python/helpers/typeshed/stdlib/xml/sax/expatreader.pyi b/python/helpers/typeshed/stdlib/xml/sax/expatreader.pyi
index 012d6c03e121..3f9573a25f9a 100644
--- a/python/helpers/typeshed/stdlib/xml/sax/expatreader.pyi
+++ b/python/helpers/typeshed/stdlib/xml/sax/expatreader.pyi
@@ -1,7 +1,7 @@
import sys
from _typeshed import ReadableBuffer
from collections.abc import Mapping
-from typing import Any, Literal, overload
+from typing import Any, Final, Literal, overload
from typing_extensions import TypeAlias
from xml.sax import _Source, xmlreader
from xml.sax.handler import _ContentHandlerProtocol
@@ -11,7 +11,7 @@ if sys.version_info >= (3, 10):
_BoolType: TypeAlias = Literal[0, 1] | bool
-version: str
+version: Final[str]
AttributesImpl = xmlreader.AttributesImpl
AttributesNSImpl = xmlreader.AttributesNSImpl
diff --git a/python/helpers/typeshed/stdlib/xml/sax/handler.pyi b/python/helpers/typeshed/stdlib/xml/sax/handler.pyi
index 550911734596..5ecbfa6f1272 100644
--- a/python/helpers/typeshed/stdlib/xml/sax/handler.pyi
+++ b/python/helpers/typeshed/stdlib/xml/sax/handler.pyi
@@ -1,8 +1,8 @@
import sys
-from typing import Literal, NoReturn, Protocol, type_check_only
+from typing import Final, NoReturn, Protocol, type_check_only
from xml.sax import xmlreader
-version: str
+version: Final[str]
@type_check_only
class _ErrorHandlerProtocol(Protocol): # noqa: Y046 # Protocol is not used
@@ -62,20 +62,20 @@ class _EntityResolverProtocol(Protocol): # noqa: Y046 # Protocol is not used
class EntityResolver:
def resolveEntity(self, publicId: str | None, systemId: str) -> str: ...
-feature_namespaces: str
-feature_namespace_prefixes: str
-feature_string_interning: str
-feature_validation: str
-feature_external_ges: str
-feature_external_pes: str
-all_features: list[str]
-property_lexical_handler: Literal["http://xml.org/sax/properties/lexical-handler"]
-property_declaration_handler: Literal["http://xml.org/sax/properties/declaration-handler"]
-property_dom_node: Literal["http://xml.org/sax/properties/dom-node"]
-property_xml_string: Literal["http://xml.org/sax/properties/xml-string"]
-property_encoding: Literal["http://www.python.org/sax/properties/encoding"]
-property_interning_dict: Literal["http://www.python.org/sax/properties/interning-dict"]
-all_properties: list[str]
+feature_namespaces: Final = "http://xml.org/sax/features/namespaces"
+feature_namespace_prefixes: Final = "http://xml.org/sax/features/namespace-prefixes"
+feature_string_interning: Final = "http://xml.org/sax/features/string-interning"
+feature_validation: Final = "http://xml.org/sax/features/validation"
+feature_external_ges: Final[str] # too long string
+feature_external_pes: Final[str] # too long string
+all_features: Final[list[str]]
+property_lexical_handler: Final = "http://xml.org/sax/properties/lexical-handler"
+property_declaration_handler: Final = "http://xml.org/sax/properties/declaration-handler"
+property_dom_node: Final = "http://xml.org/sax/properties/dom-node"
+property_xml_string: Final = "http://xml.org/sax/properties/xml-string"
+property_encoding: Final = "http://www.python.org/sax/properties/encoding"
+property_interning_dict: Final[str] # too long string
+all_properties: Final[list[str]]
if sys.version_info >= (3, 10):
class LexicalHandler:
diff --git a/python/helpers/typeshed/stdlib/xmlrpc/client.pyi b/python/helpers/typeshed/stdlib/xmlrpc/client.pyi
index 6cc4361f4a09..42420ee85848 100644
--- a/python/helpers/typeshed/stdlib/xmlrpc/client.pyi
+++ b/python/helpers/typeshed/stdlib/xmlrpc/client.pyi
@@ -6,9 +6,10 @@ from collections.abc import Callable, Iterable, Mapping
from datetime import datetime
from io import BytesIO
from types import TracebackType
-from typing import Any, ClassVar, Final, Literal, Protocol, overload
+from typing import Any, ClassVar, Final, Literal, Protocol, overload, type_check_only
from typing_extensions import Self, TypeAlias
+@type_check_only
class _SupportsTimeTuple(Protocol):
def timetuple(self) -> time.struct_time: ...
diff --git a/python/helpers/typeshed/stdlib/xmlrpc/server.pyi b/python/helpers/typeshed/stdlib/xmlrpc/server.pyi
index 5f497aa7190e..286aaf980fbf 100644
--- a/python/helpers/typeshed/stdlib/xmlrpc/server.pyi
+++ b/python/helpers/typeshed/stdlib/xmlrpc/server.pyi
@@ -4,28 +4,34 @@ import socketserver
from _typeshed import ReadableBuffer
from collections.abc import Callable, Iterable, Mapping
from re import Pattern
-from typing import Any, ClassVar, Protocol
+from typing import Any, ClassVar, Protocol, type_check_only
from typing_extensions import TypeAlias
from xmlrpc.client import Fault, _Marshallable
# The dispatch accepts anywhere from 0 to N arguments, no easy way to allow this in mypy
+@type_check_only
class _DispatchArity0(Protocol):
def __call__(self) -> _Marshallable: ...
+@type_check_only
class _DispatchArity1(Protocol):
def __call__(self, arg1: _Marshallable, /) -> _Marshallable: ...
+@type_check_only
class _DispatchArity2(Protocol):
def __call__(self, arg1: _Marshallable, arg2: _Marshallable, /) -> _Marshallable: ...
+@type_check_only
class _DispatchArity3(Protocol):
def __call__(self, arg1: _Marshallable, arg2: _Marshallable, arg3: _Marshallable, /) -> _Marshallable: ...
+@type_check_only
class _DispatchArity4(Protocol):
def __call__(
self, arg1: _Marshallable, arg2: _Marshallable, arg3: _Marshallable, arg4: _Marshallable, /
) -> _Marshallable: ...
+@type_check_only
class _DispatchArityN(Protocol):
def __call__(self, *args: _Marshallable) -> _Marshallable: ...
diff --git a/python/helpers/typeshed/stdlib/zipfile/__init__.pyi b/python/helpers/typeshed/stdlib/zipfile/__init__.pyi
index 27c1ef0246c7..e573d04dba05 100644
--- a/python/helpers/typeshed/stdlib/zipfile/__init__.pyi
+++ b/python/helpers/typeshed/stdlib/zipfile/__init__.pyi
@@ -5,7 +5,7 @@ from collections.abc import Callable, Iterable, Iterator
from io import TextIOWrapper
from os import PathLike
from types import TracebackType
-from typing import IO, Final, Literal, Protocol, overload
+from typing import IO, Final, Literal, Protocol, overload, type_check_only
from typing_extensions import Self, TypeAlias
__all__ = [
@@ -41,6 +41,7 @@ error = BadZipfile
class LargeZipFile(Exception): ...
+@type_check_only
class _ZipStream(Protocol):
def read(self, n: int, /) -> bytes: ...
# The following methods are optional:
@@ -49,11 +50,13 @@ class _ZipStream(Protocol):
# def seek(self, n: int, /) -> object: ...
# Stream shape as required by _EndRecData() and _EndRecData64().
+@type_check_only
class _SupportsReadSeekTell(Protocol):
def read(self, n: int = ..., /) -> bytes: ...
def seek(self, cookie: int, whence: int, /) -> object: ...
def tell(self) -> int: ...
+@type_check_only
class _ClosableZipStream(_ZipStream, Protocol):
def close(self) -> object: ...
@@ -93,18 +96,23 @@ class ZipExtFile(io.BufferedIOBase):
def read1(self, n: int | None) -> bytes: ... # type: ignore[override]
def seek(self, offset: int, whence: int = 0) -> int: ...
+@type_check_only
class _Writer(Protocol):
def write(self, s: str, /) -> object: ...
+@type_check_only
class _ZipReadable(Protocol):
def seek(self, offset: int, whence: int = 0, /) -> int: ...
def read(self, n: int = -1, /) -> bytes: ...
+@type_check_only
class _ZipTellable(Protocol):
def tell(self) -> int: ...
+@type_check_only
class _ZipReadableTellable(_ZipReadable, _ZipTellable, Protocol): ...
+@type_check_only
class _ZipWritable(Protocol):
def flush(self) -> None: ...
def close(self) -> None: ...
@@ -153,7 +161,7 @@ class ZipFile:
def __init__(
self,
file: StrPath | _ZipWritable,
- mode: Literal["w", "x"] = ...,
+ mode: Literal["w", "x"],
compression: int = 0,
allowZip64: bool = True,
compresslevel: int | None = None,
@@ -165,7 +173,7 @@ class ZipFile:
def __init__(
self,
file: StrPath | _ZipReadableTellable,
- mode: Literal["a"] = ...,
+ mode: Literal["a"],
compression: int = 0,
allowZip64: bool = True,
compresslevel: int | None = None,
@@ -200,7 +208,7 @@ class ZipFile:
def __init__(
self,
file: StrPath | _ZipWritable,
- mode: Literal["w", "x"] = ...,
+ mode: Literal["w", "x"],
compression: int = 0,
allowZip64: bool = True,
compresslevel: int | None = None,
@@ -211,7 +219,7 @@ class ZipFile:
def __init__(
self,
file: StrPath | _ZipReadableTellable,
- mode: Literal["a"] = ...,
+ mode: Literal["a"],
compression: int = 0,
allowZip64: bool = True,
compresslevel: int | None = None,
@@ -254,9 +262,6 @@ class ZipFile:
) -> None: ...
if sys.version_info >= (3, 11):
def mkdir(self, zinfo_or_directory_name: str | ZipInfo, mode: int = 0o777) -> None: ...
- if sys.version_info >= (3, 14):
- @property
- def data_offset(self) -> int | None: ...
def __del__(self) -> None: ...
@@ -267,6 +272,29 @@ class PyZipFile(ZipFile):
def writepy(self, pathname: str, basename: str = "", filterfunc: Callable[[str], bool] | None = None) -> None: ...
class ZipInfo:
+ __slots__ = (
+ "orig_filename",
+ "filename",
+ "date_time",
+ "compress_type",
+ "compress_level",
+ "comment",
+ "extra",
+ "create_system",
+ "create_version",
+ "extract_version",
+ "reserved",
+ "flag_bits",
+ "volume",
+ "internal_attr",
+ "external_attr",
+ "header_offset",
+ "CRC",
+ "compress_size",
+ "file_size",
+ "_raw_time",
+ "_end_offset",
+ )
filename: str
date_time: _DateTuple
compress_type: int
diff --git a/python/helpers/typeshed/stdlib/zipfile/_path/glob.pyi b/python/helpers/typeshed/stdlib/zipfile/_path/glob.pyi
index f25ae71725c0..f6a661be8cdf 100644
--- a/python/helpers/typeshed/stdlib/zipfile/_path/glob.pyi
+++ b/python/helpers/typeshed/stdlib/zipfile/_path/glob.pyi
@@ -4,7 +4,11 @@ from re import Match
if sys.version_info >= (3, 13):
class Translator:
- def __init__(self, seps: str = ...) -> None: ...
+ if sys.platform == "win32":
+ def __init__(self, seps: str = "\\/") -> None: ...
+ else:
+ def __init__(self, seps: str = "/") -> None: ...
+
def translate(self, pattern: str) -> str: ...
def extend(self, pattern: str) -> str: ...
def match_dirs(self, pattern: str) -> str: ...
diff --git a/python/helpers/typeshed/stdlib/zipimport.pyi b/python/helpers/typeshed/stdlib/zipimport.pyi
index 4aab318e7c71..22af3c272759 100644
--- a/python/helpers/typeshed/stdlib/zipimport.pyi
+++ b/python/helpers/typeshed/stdlib/zipimport.pyi
@@ -27,8 +27,14 @@ class zipimporter(_LoaderBasics):
def __init__(self, path: StrOrBytesPath) -> None: ...
if sys.version_info < (3, 12):
- def find_loader(self, fullname: str, path: str | None = None) -> tuple[zipimporter | None, list[str]]: ... # undocumented
- def find_module(self, fullname: str, path: str | None = None) -> zipimporter | None: ...
+ if sys.version_info >= (3, 10):
+ @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `find_spec()` instead.")
+ def find_loader(self, fullname: str, path: str | None = None) -> tuple[zipimporter | None, list[str]]: ...
+ @deprecated("Deprecated since Python 3.10; removed in Python 3.12. Use `find_spec()` instead.")
+ def find_module(self, fullname: str, path: str | None = None) -> zipimporter | None: ...
+ else:
+ def find_loader(self, fullname: str, path: str | None = None) -> tuple[zipimporter | None, list[str]]: ...
+ def find_module(self, fullname: str, path: str | None = None) -> zipimporter | None: ...
def get_code(self, fullname: str) -> CodeType: ...
def get_data(self, pathname: str) -> bytes: ...
@@ -42,10 +48,12 @@ class zipimporter(_LoaderBasics):
def get_source(self, fullname: str) -> str | None: ...
def is_package(self, fullname: str) -> bool: ...
- @deprecated("Deprecated since 3.10; use exec_module() instead")
- def load_module(self, fullname: str) -> ModuleType: ...
if sys.version_info >= (3, 10):
+ @deprecated("Deprecated since Python 3.10; removed in Python 3.15. Use `exec_module()` instead.")
+ def load_module(self, fullname: str) -> ModuleType: ...
def exec_module(self, module: ModuleType) -> None: ...
def create_module(self, spec: ModuleSpec) -> None: ...
def find_spec(self, fullname: str, target: ModuleType | None = None) -> ModuleSpec | None: ...
def invalidate_caches(self) -> None: ...
+ else:
+ def load_module(self, fullname: str) -> ModuleType: ...
diff --git a/python/helpers/typeshed/stdlib/zlib.pyi b/python/helpers/typeshed/stdlib/zlib.pyi
index 7cafb44b34a7..4e410fdd18ad 100644
--- a/python/helpers/typeshed/stdlib/zlib.pyi
+++ b/python/helpers/typeshed/stdlib/zlib.pyi
@@ -4,11 +4,11 @@ from typing import Any, Final, final, type_check_only
from typing_extensions import Self
DEFLATED: Final = 8
-DEF_MEM_LEVEL: int # can change
+DEF_MEM_LEVEL: Final[int]
DEF_BUF_SIZE: Final = 16384
-MAX_WBITS: int
-ZLIB_VERSION: str # can change
-ZLIB_RUNTIME_VERSION: str # can change
+MAX_WBITS: Final[int]
+ZLIB_VERSION: Final[str]
+ZLIB_RUNTIME_VERSION: Final[str]
Z_NO_COMPRESSION: Final = 0
Z_PARTIAL_FLUSH: Final = 1
Z_BEST_COMPRESSION: Final = 9
@@ -26,6 +26,10 @@ Z_RLE: Final = 3
Z_SYNC_FLUSH: Final = 2
Z_TREES: Final = 6
+if sys.version_info >= (3, 14) and sys.platform == "win32":
+ # Available when zlib was built with zlib-ng, usually only on Windows
+ ZLIBNG_VERSION: Final[str]
+
class error(Exception): ...
# This class is not exposed at runtime. It calls itself zlib.Compress.
diff --git a/python/helpers/typeshed/stdlib/zoneinfo/_common.pyi b/python/helpers/typeshed/stdlib/zoneinfo/_common.pyi
index a2f29f2d14f0..e6d2d83caac1 100644
--- a/python/helpers/typeshed/stdlib/zoneinfo/_common.pyi
+++ b/python/helpers/typeshed/stdlib/zoneinfo/_common.pyi
@@ -1,6 +1,7 @@
import io
-from typing import Any, Protocol
+from typing import Any, Protocol, type_check_only
+@type_check_only
class _IOBytes(Protocol):
def read(self, size: int, /) -> bytes: ...
def seek(self, size: int, whence: int = ..., /) -> Any: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/Authlib/@tests/stubtest_allowlist.txt
index abcbb85a016f..535d2f1b5e6a 100644
--- a/python/helpers/typeshed/stubs/Authlib/@tests/stubtest_allowlist.txt
+++ b/python/helpers/typeshed/stubs/Authlib/@tests/stubtest_allowlist.txt
@@ -1,25 +1,5 @@
# TODO: check these entries
-authlib.jose.ECKey.PRIVATE_KEY_CLS
-authlib.jose.ECKey.PUBLIC_KEY_CLS
-authlib.jose.RSAKey.PRIVATE_KEY_CLS
-authlib.jose.RSAKey.PUBLIC_KEY_CLS
-authlib.jose.drafts._jwe_algorithms.ECDH1PUAlgorithm.description
-authlib.jose.drafts._jwe_algorithms.ECDH1PUAlgorithm.name
authlib.jose.drafts._jwe_enc_cryptodome
-authlib.jose.drafts._jwe_enc_cryptography.C20PEncAlgorithm.description
-authlib.jose.drafts._jwe_enc_cryptography.C20PEncAlgorithm.name
-authlib.jose.rfc7518.ECDHESAlgorithm.description
-authlib.jose.rfc7518.ECDHESAlgorithm.name
-authlib.jose.rfc7518.ECKey.PRIVATE_KEY_CLS
-authlib.jose.rfc7518.ECKey.PUBLIC_KEY_CLS
-authlib.jose.rfc7518.RSAKey.PRIVATE_KEY_CLS
-authlib.jose.rfc7518.RSAKey.PUBLIC_KEY_CLS
-authlib.jose.rfc7518.ec_key.ECKey.PRIVATE_KEY_CLS
-authlib.jose.rfc7518.ec_key.ECKey.PUBLIC_KEY_CLS
-authlib.jose.rfc7518.jwe_algs.ECDHESAlgorithm.description
-authlib.jose.rfc7518.jwe_algs.ECDHESAlgorithm.name
-authlib.jose.rfc7518.rsa_key.RSAKey.PRIVATE_KEY_CLS
-authlib.jose.rfc7518.rsa_key.RSAKey.PUBLIC_KEY_CLS
authlib.oauth2.OAuth2Client.client_auth_class
authlib.oauth2.OAuth2Client.oauth_error_class
authlib.oauth2.OAuth2Client.token_auth_class
@@ -30,10 +10,67 @@ authlib.oauth2.rfc7521.AssertionClient.oauth_error_class
authlib.oauth2.rfc7521.client.AssertionClient.oauth_error_class
authlib.oauth2.rfc7523.JWTBearerTokenValidator.token_cls
authlib.oauth2.rfc7523.validator.JWTBearerTokenValidator.token_cls
-authlib.oauth2.rfc9068.claims.JWTAccessTokenClaims.validate
+
+# Are set to `None` by default, initialized later:
+authlib.jose.drafts._jwe_algorithms.ECDH1PUAlgorithm.description
+authlib.jose.drafts._jwe_algorithms.ECDH1PUAlgorithm.name
+authlib.jose.drafts._jwe_enc_cryptography.C20PEncAlgorithm.description
+authlib.jose.drafts._jwe_enc_cryptography.C20PEncAlgorithm.name
+authlib.jose.rfc7518.AESAlgorithm.description
+authlib.jose.rfc7518.AESAlgorithm.name
+authlib.jose.rfc7518.ECDHESAlgorithm.description
+authlib.jose.rfc7518.ECDHESAlgorithm.name
+authlib.jose.rfc7518.jwe_algs.AESAlgorithm.description
+authlib.jose.rfc7518.jwe_algs.AESAlgorithm.name
+authlib.jose.rfc7518.jwe_algs.AESGCMAlgorithm.description
+authlib.jose.rfc7518.jwe_algs.AESGCMAlgorithm.name
+authlib.jose.rfc7518.jwe_algs.ECDHESAlgorithm.description
+authlib.jose.rfc7518.jwe_algs.ECDHESAlgorithm.name
+authlib.jose.rfc7518.jwe_algs.RSAAlgorithm.description
+authlib.jose.rfc7518.jwe_algs.RSAAlgorithm.name
# Re-exports of hashlib functions whose signatures changed in Python 3.13.4.
# (Remove once 3.13.4 is consistently available)
(authlib.jose.rfc7518.jws_algs.HMACAlgorithm.SHA256)?
(authlib.jose.rfc7518.jws_algs.HMACAlgorithm.SHA384)?
(authlib.jose.rfc7518.jws_algs.HMACAlgorithm.SHA512)?
+
+# Methods whose *args and **kwargs arguments are added dynamically due to the @hooked decorator:
+authlib.oauth2.rfc6749.AuthorizationCodeGrant.create_token_response
+authlib.oauth2.rfc6749.AuthorizationCodeGrant.validate_token_request
+authlib.oauth2.rfc6749.AuthorizationEndpointMixin.validate_consent_request
+authlib.oauth2.rfc6749.ClientCredentialsGrant.create_token_response
+authlib.oauth2.rfc6749.ImplicitGrant.validate_authorization_request
+authlib.oauth2.rfc6749.RefreshTokenGrant.create_token_response
+authlib.oauth2.rfc6749.ResourceOwnerPasswordCredentialsGrant.create_token_response
+authlib.oauth2.rfc6749.grants.AuthorizationCodeGrant.create_token_response
+authlib.oauth2.rfc6749.grants.AuthorizationCodeGrant.validate_token_request
+authlib.oauth2.rfc6749.grants.AuthorizationEndpointMixin.validate_consent_request
+authlib.oauth2.rfc6749.grants.ClientCredentialsGrant.create_token_response
+authlib.oauth2.rfc6749.grants.ImplicitGrant.validate_authorization_request
+authlib.oauth2.rfc6749.grants.RefreshTokenGrant.create_token_response
+authlib.oauth2.rfc6749.grants.ResourceOwnerPasswordCredentialsGrant.create_token_response
+authlib.oauth2.rfc6749.grants.authorization_code.AuthorizationCodeGrant.create_token_response
+authlib.oauth2.rfc6749.grants.authorization_code.AuthorizationCodeGrant.validate_token_request
+authlib.oauth2.rfc6749.grants.base.AuthorizationEndpointMixin.validate_consent_request
+authlib.oauth2.rfc6749.grants.client_credentials.ClientCredentialsGrant.create_token_response
+authlib.oauth2.rfc6749.grants.implicit.ImplicitGrant.validate_authorization_request
+authlib.oauth2.rfc6749.grants.refresh_token.RefreshTokenGrant.create_token_response
+authlib.oauth2.rfc6749.grants.resource_owner_password_credentials.ResourceOwnerPasswordCredentialsGrant.create_token_response
+authlib.oauth2.rfc8628.DeviceCodeGrant.create_token_response
+authlib.oauth2.rfc8628.device_code.DeviceCodeGrant.create_token_response
+authlib.oidc.core.OpenIDImplicitGrant.validate_consent_request
+authlib.oidc.core.grants.OpenIDImplicitGrant.validate_consent_request
+authlib.oidc.core.grants.implicit.OpenIDImplicitGrant.validate_consent_request
+
+# Exclude integrations dirs:
+authlib.integrations.django_client
+authlib.integrations.django_oauth1
+authlib.integrations.django_oauth2
+authlib.integrations.flask_client
+authlib.integrations.flask_oauth1
+authlib.integrations.flask_oauth2
+authlib.integrations.httpx_client
+authlib.integrations.requests_client
+authlib.integrations.sqla_oauth2
+authlib.integrations.starlette_client
diff --git a/python/helpers/typeshed/stubs/Authlib/METADATA.toml b/python/helpers/typeshed/stubs/Authlib/METADATA.toml
index 006051a0d7d0..42ef05ebf022 100644
--- a/python/helpers/typeshed/stubs/Authlib/METADATA.toml
+++ b/python/helpers/typeshed/stubs/Authlib/METADATA.toml
@@ -1,7 +1,4 @@
-version = "1.5.0"
+version = "~= 1.6.0"
upstream_repository = "https://github.com/lepture/authlib"
requires = ["cryptography"]
partial_stub = true
-
-[tool.stubtest]
-ignore_missing_stub = true
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/common/urls.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/common/urls.pyi
index 457993f01006..bc5a64570e64 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/common/urls.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/common/urls.pyi
@@ -16,4 +16,4 @@ def quote(s: str, safe: bytes = b"/") -> str: ...
def unquote(s: str) -> str: ...
def quote_url(s: str) -> str: ...
def extract_params(raw: dict[str, str] | _ExplodedQueryString) -> _ExplodedQueryString: ...
-def is_valid_url(url: str) -> bool: ...
+def is_valid_url(url: str, fragments_allowed: bool = True) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/deprecate.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/deprecate.pyi
index 9f7f18218194..201ceb6a53b2 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/deprecate.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/deprecate.pyi
@@ -1,3 +1,5 @@
class AuthlibDeprecationWarning(DeprecationWarning): ...
-def deprecate(message: str, version: str | None = None, link_uid: str | None = None, link_file: str | None = None) -> None: ...
+def deprecate(
+ message: str, version: str | None = None, link_uid: str | None = None, link_file: str | None = None, stacklevel: int = 3
+) -> None: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/integrations/base_client/async_app.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/integrations/base_client/async_app.pyi
index 422ba2755dc0..c684655f946c 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/integrations/base_client/async_app.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/integrations/base_client/async_app.pyi
@@ -1,5 +1,9 @@
+from logging import Logger
+
from authlib.integrations.base_client.sync_app import OAuth1Base, OAuth2Base
+log: Logger
+
__all__ = ["AsyncOAuth1Mixin", "AsyncOAuth2Mixin"]
class AsyncOAuth1Mixin(OAuth1Base):
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/integrations/base_client/async_openid.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/integrations/base_client/async_openid.pyi
index 24a8c634ad98..d4c21c282a1b 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/integrations/base_client/async_openid.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/integrations/base_client/async_openid.pyi
@@ -3,4 +3,4 @@ __all__ = ["AsyncOpenIDMixin"]
class AsyncOpenIDMixin:
async def fetch_jwk_set(self, force: bool = False): ...
async def userinfo(self, **kwargs): ...
- async def parse_id_token(self, token, nonce, claims_options=None): ...
+ async def parse_id_token(self, token, nonce, claims_options=None, claims_cls=None, leeway: int = 120): ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/integrations/base_client/sync_app.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/integrations/base_client/sync_app.pyi
index 748cd7b0fc38..a2ee03bd7b2d 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/integrations/base_client/sync_app.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/integrations/base_client/sync_app.pyi
@@ -1,4 +1,7 @@
from _typeshed import Incomplete
+from logging import Logger
+
+log: Logger
class BaseApp:
client_cls: Incomplete
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/integrations/base_client/sync_openid.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/integrations/base_client/sync_openid.pyi
index 374b3fb9eb63..961395534252 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/integrations/base_client/sync_openid.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/integrations/base_client/sync_openid.pyi
@@ -1,5 +1,5 @@
class OpenIDMixin:
def fetch_jwk_set(self, force: bool = False): ...
def userinfo(self, **kwargs): ...
- def parse_id_token(self, token, nonce, claims_options=None, leeway: int = 120): ...
+ def parse_id_token(self, token, nonce, claims_options=None, claims_cls=None, leeway: int = 120): ...
def create_load_key(self): ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/jose/drafts/_jwe_algorithms.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/jose/drafts/_jwe_algorithms.pyi
index 3d95fa080026..06983be25d51 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/jose/drafts/_jwe_algorithms.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/jose/drafts/_jwe_algorithms.pyi
@@ -1,9 +1,11 @@
from _typeshed import Incomplete
+from collections.abc import Iterable
+from typing import ClassVar
from authlib.jose.rfc7516 import JWEAlgorithmWithTagAwareKeyAgreement
class ECDH1PUAlgorithm(JWEAlgorithmWithTagAwareKeyAgreement):
- EXTRA_HEADERS: Incomplete
+ EXTRA_HEADERS: ClassVar[Iterable[str]]
ALLOWED_KEY_CLS: Incomplete
name: str
description: str
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7515/models.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7515/models.pyi
index 7640c759dbc9..07f9a2091a48 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7515/models.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7515/models.pyi
@@ -6,8 +6,8 @@ class JWSAlgorithm:
algorithm_type: str
algorithm_location: str
def prepare_key(self, raw_data) -> None: ...
- def sign(self, msg, key) -> None: ...
- def verify(self, msg, sig, key) -> None: ...
+ def sign(self, msg, key): ...
+ def verify(self, msg, sig, key) -> bool: ...
class JWSHeader(dict[str, object]):
protected: Incomplete
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7516/models.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7516/models.pyi
index 794b2aafbd19..1bd060a1df59 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7516/models.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7516/models.pyi
@@ -1,10 +1,12 @@
from _typeshed import Incomplete
from abc import ABCMeta
+from collections.abc import Iterable
+from typing import ClassVar
class JWEAlgorithmBase(metaclass=ABCMeta):
- EXTRA_HEADERS: Incomplete
- name: Incomplete
- description: Incomplete
+ EXTRA_HEADERS: ClassVar[Iterable[str] | None]
+ name: str | None
+ description: str | None
algorithm_type: str
algorithm_location: str
def prepare_key(self, raw_data) -> None: ...
@@ -21,8 +23,8 @@ class JWEAlgorithmWithTagAwareKeyAgreement(JWEAlgorithmBase, metaclass=ABCMeta):
def unwrap(self, enc_alg, ek, headers, key, sender_key, tag=None) -> None: ...
class JWEEncAlgorithm:
- name: Incomplete
- description: Incomplete
+ name: str | None
+ description: str | None
algorithm_type: str
algorithm_location: str
IV_SIZE: Incomplete
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7517/asymmetric_key.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7517/asymmetric_key.pyi
index a2749aadf95e..d5caad3414df 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7517/asymmetric_key.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7517/asymmetric_key.pyi
@@ -1,13 +1,14 @@
from _typeshed import Incomplete
+from typing import ClassVar
from authlib.jose.rfc7517 import Key
class AsymmetricKey(Key):
- PUBLIC_KEY_FIELDS: Incomplete
- PRIVATE_KEY_FIELDS: Incomplete
- PRIVATE_KEY_CLS = Incomplete
- PUBLIC_KEY_CLS = Incomplete
- SSH_PUBLIC_PREFIX: bytes
+ PUBLIC_KEY_FIELDS: ClassVar[list[str]]
+ PRIVATE_KEY_FIELDS: ClassVar[list[str]]
+ PRIVATE_KEY_CLS: ClassVar[type | tuple[type, ...]]
+ PUBLIC_KEY_CLS: ClassVar[type | tuple[type, ...]]
+ SSH_PUBLIC_PREFIX: ClassVar[bytes]
private_key: Incomplete
public_key: Incomplete
def __init__(self, private_key=None, public_key=None, options=None) -> None: ...
@@ -18,10 +19,10 @@ class AsymmetricKey(Key):
def get_private_key(self): ...
def load_raw_key(self) -> None: ...
def load_dict_key(self) -> None: ...
- def dumps_private_key(self) -> None: ...
- def dumps_public_key(self) -> None: ...
- def load_private_key(self) -> None: ...
- def load_public_key(self) -> None: ...
+ def dumps_private_key(self): ...
+ def dumps_public_key(self): ...
+ def load_private_key(self): ...
+ def load_public_key(self): ...
def as_dict(self, is_private: bool = False, **params): ...
def as_key(self, is_private: bool = False): ...
def as_bytes(self, encoding=None, is_private: bool = False, password=None): ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7517/base_key.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7517/base_key.pyi
index 379b24806eda..29450b4b458b 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7517/base_key.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7517/base_key.pyi
@@ -1,11 +1,12 @@
from _typeshed import Incomplete
+from typing import ClassVar
class Key:
kty: str
- ALLOWED_PARAMS: Incomplete
- PRIVATE_KEY_OPS: Incomplete
- PUBLIC_KEY_OPS: Incomplete
- REQUIRED_JSON_FIELDS: Incomplete
+ ALLOWED_PARAMS: ClassVar[list[str]]
+ PRIVATE_KEY_OPS: ClassVar[list[str]]
+ PUBLIC_KEY_OPS: ClassVar[list[str]]
+ REQUIRED_JSON_FIELDS: ClassVar[list[str]]
options: Incomplete
def __init__(self, options=None) -> None: ...
@property
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7518/ec_key.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7518/ec_key.pyi
index c1aa6adb9da6..8a449b235e53 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7518/ec_key.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7518/ec_key.pyi
@@ -1,24 +1,25 @@
from _typeshed import Incomplete
+from typing import ClassVar
from authlib.jose.rfc7517 import AsymmetricKey
-from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePrivateKeyWithSerialization, EllipticCurvePublicKey
+from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePrivateKey, EllipticCurvePublicKey
class ECKey(AsymmetricKey):
kty: str
DSS_CURVES: Incomplete
CURVES_DSS: Incomplete
- REQUIRED_JSON_FIELDS: Incomplete
+ REQUIRED_JSON_FIELDS: ClassVar[list[str]]
PUBLIC_KEY_FIELDS = REQUIRED_JSON_FIELDS
- PRIVATE_KEY_FIELDS: Incomplete
- PUBLIC_KEY_CLS = EllipticCurvePublicKey
- PRIVATE_KEY_CLS = EllipticCurvePrivateKeyWithSerialization
- SSH_PUBLIC_PREFIX: bytes
+ PRIVATE_KEY_FIELDS: ClassVar[list[str]]
+ PUBLIC_KEY_CLS: ClassVar[type]
+ PRIVATE_KEY_CLS: ClassVar[type]
+ SSH_PUBLIC_PREFIX: ClassVar[bytes]
def exchange_shared_key(self, pubkey): ...
@property
def curve_key_size(self): ...
- def load_private_key(self): ...
- def load_public_key(self): ...
- def dumps_private_key(self): ...
- def dumps_public_key(self): ...
+ def load_private_key(self) -> EllipticCurvePrivateKey: ...
+ def load_public_key(self) -> EllipticCurvePublicKey: ...
+ def dumps_private_key(self) -> dict[str, str]: ...
+ def dumps_public_key(self) -> dict[str, str]: ...
@classmethod
def generate_key(cls, crv: str = "P-256", options=None, is_private: bool = False) -> ECKey: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7518/jwe_algs.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7518/jwe_algs.pyi
index b046d71bd697..3a40d1d148eb 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7518/jwe_algs.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7518/jwe_algs.pyi
@@ -1,4 +1,6 @@
from _typeshed import Incomplete
+from collections.abc import Iterable
+from typing import ClassVar, Final
from authlib.jose.rfc7516 import JWEAlgorithm
@@ -12,8 +14,8 @@ class DirectAlgorithm(JWEAlgorithm):
class RSAAlgorithm(JWEAlgorithm):
key_size: int
- name: Incomplete
- description: Incomplete
+ name: str
+ description: str
padding: Incomplete
def __init__(self, name, description, pad_fn) -> None: ...
def prepare_key(self, raw_data): ...
@@ -22,8 +24,8 @@ class RSAAlgorithm(JWEAlgorithm):
def unwrap(self, enc_alg, ek, headers, key): ...
class AESAlgorithm(JWEAlgorithm):
- name: Incomplete
- description: Incomplete
+ name: str
+ description: str
key_size: Incomplete
def __init__(self, key_size) -> None: ...
def prepare_key(self, raw_data): ...
@@ -33,9 +35,9 @@ class AESAlgorithm(JWEAlgorithm):
def unwrap(self, enc_alg, ek, headers, key): ...
class AESGCMAlgorithm(JWEAlgorithm):
- EXTRA_HEADERS: Incomplete
- name: Incomplete
- description: Incomplete
+ EXTRA_HEADERS: ClassVar[Iterable[str]]
+ name: str
+ description: str
key_size: Incomplete
def __init__(self, key_size) -> None: ...
def prepare_key(self, raw_data): ...
@@ -44,7 +46,7 @@ class AESGCMAlgorithm(JWEAlgorithm):
def unwrap(self, enc_alg, ek, headers, key): ...
class ECDHESAlgorithm(JWEAlgorithm):
- EXTRA_HEADERS: Incomplete
+ EXTRA_HEADERS: ClassVar[Iterable[str]]
ALLOWED_KEY_CLS = Incomplete
name: str
description: str
@@ -61,4 +63,4 @@ class ECDHESAlgorithm(JWEAlgorithm):
def u32be_len_input(s, base64: bool = False): ...
-JWE_ALG_ALGORITHMS: Incomplete
+JWE_ALG_ALGORITHMS: Final[list[JWEAlgorithm]]
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7518/jws_algs.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7518/jws_algs.pyi
index 5bcca23de4d0..47ca3a64e69c 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7518/jws_algs.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7518/jws_algs.pyi
@@ -8,7 +8,7 @@ class NoneAlgorithm(JWSAlgorithm):
description: str
def prepare_key(self, raw_data) -> None: ...
def sign(self, msg, key): ...
- def verify(self, msg, sig, key): ...
+ def verify(self, msg, sig, key) -> bool: ...
class HMACAlgorithm(JWSAlgorithm):
SHA256 = hashlib.sha256
@@ -20,7 +20,7 @@ class HMACAlgorithm(JWSAlgorithm):
def __init__(self, sha_type) -> None: ...
def prepare_key(self, raw_data): ...
def sign(self, msg, key): ...
- def verify(self, msg, sig, key): ...
+ def verify(self, msg, sig, key) -> bool: ...
class RSAAlgorithm(JWSAlgorithm):
SHA256: Incomplete
@@ -33,7 +33,7 @@ class RSAAlgorithm(JWSAlgorithm):
def __init__(self, sha_type) -> None: ...
def prepare_key(self, raw_data): ...
def sign(self, msg, key): ...
- def verify(self, msg, sig, key): ...
+ def verify(self, msg, sig, key) -> bool: ...
class ECAlgorithm(JWSAlgorithm):
SHA256: Incomplete
@@ -46,7 +46,7 @@ class ECAlgorithm(JWSAlgorithm):
def __init__(self, name, curve, sha_type) -> None: ...
def prepare_key(self, raw_data): ...
def sign(self, msg, key): ...
- def verify(self, msg, sig, key): ...
+ def verify(self, msg, sig, key) -> bool: ...
class RSAPSSAlgorithm(JWSAlgorithm):
SHA256: Incomplete
@@ -58,6 +58,6 @@ class RSAPSSAlgorithm(JWSAlgorithm):
def __init__(self, sha_type) -> None: ...
def prepare_key(self, raw_data): ...
def sign(self, msg, key): ...
- def verify(self, msg, sig, key): ...
+ def verify(self, msg, sig, key) -> bool: ...
-JWS_ALGORITHMS: Incomplete
+JWS_ALGORITHMS: list[JWSAlgorithm]
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7518/oct_key.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7518/oct_key.pyi
index 1211c58280ae..bb2e6873cf5e 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7518/oct_key.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7518/oct_key.pyi
@@ -1,12 +1,13 @@
from _typeshed import Incomplete
+from typing import ClassVar, Final
from authlib.jose.rfc7517 import Key
-POSSIBLE_UNSAFE_KEYS: Incomplete
+POSSIBLE_UNSAFE_KEYS: Final[tuple[bytes, ...]]
class OctKey(Key):
kty: str
- REQUIRED_JSON_FIELDS: Incomplete
+ REQUIRED_JSON_FIELDS: ClassVar[list[str]]
raw_key: Incomplete
def __init__(self, raw_key=None, options=None) -> None: ...
@property
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7518/rsa_key.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7518/rsa_key.pyi
index 136f1dc00e53..45435c855ff4 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7518/rsa_key.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7518/rsa_key.pyi
@@ -1,23 +1,23 @@
-from _typeshed import Incomplete
+from typing import ClassVar
from authlib.jose.rfc7517 import AsymmetricKey
-from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKeyWithSerialization, RSAPublicKey
+from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPublicKey
class RSAKey(AsymmetricKey):
kty: str
- PUBLIC_KEY_CLS = RSAPublicKey
- PRIVATE_KEY_CLS = RSAPrivateKeyWithSerialization
- PUBLIC_KEY_FIELDS: Incomplete
- PRIVATE_KEY_FIELDS: Incomplete
- REQUIRED_JSON_FIELDS: Incomplete
- SSH_PUBLIC_PREFIX: bytes
- def dumps_private_key(self): ...
- def dumps_public_key(self): ...
- def load_private_key(self): ...
- def load_public_key(self): ...
+ PUBLIC_KEY_CLS: ClassVar[type]
+ PRIVATE_KEY_CLS: ClassVar[type]
+ PUBLIC_KEY_FIELDS: ClassVar[list[str]]
+ PRIVATE_KEY_FIELDS: ClassVar[list[str]]
+ REQUIRED_JSON_FIELDS: ClassVar[list[str]]
+ SSH_PUBLIC_PREFIX: ClassVar[bytes]
+ def dumps_private_key(self) -> dict[str, str]: ...
+ def dumps_public_key(self) -> dict[str, str]: ...
+ def load_private_key(self) -> RSAPrivateKey: ...
+ def load_public_key(self) -> RSAPublicKey: ...
@classmethod
def generate_key(cls, key_size: int = 2048, options=None, is_private: bool = False) -> RSAKey: ...
@classmethod
def import_dict_key(cls, raw, options=None): ...
-def has_all_prime_factors(obj): ...
+def has_all_prime_factors(obj) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7519/jwt.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7519/jwt.pyi
index 0494dd418094..ea21ff1caf96 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7519/jwt.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc7519/jwt.pyi
@@ -1,14 +1,55 @@
from _typeshed import Incomplete
+from collections.abc import Callable
+from re import Pattern
+from typing import Any, Final, Generic, TypedDict, TypeVar, overload, type_check_only
+from typing_extensions import TypeAlias
+
+from ..rfc7517 import KeySet
+from .claims import JWTClaims
+
+_T = TypeVar("_T")
+
+_LoadKey: TypeAlias = Callable[[Incomplete, Incomplete], Incomplete]
class JsonWebToken:
- SENSITIVE_NAMES: Incomplete
- SENSITIVE_VALUES: Incomplete
+ SENSITIVE_NAMES: Final[tuple[str, ...]]
+ SENSITIVE_VALUES: Final[Pattern[str]]
+
def __init__(self, algorithms, private_headers=None) -> None: ...
def check_sensitive_data(self, payload) -> None: ...
def encode(self, header, payload, key, check: bool = True): ...
- def decode(self, s, key, claims_cls=None, claims_options=None, claims_params=None): ...
+ @overload
+ def decode(
+ self,
+ s: str | bytes,
+ key: _LoadKey | KeySet | tuple[Incomplete, ...] | list[Incomplete] | str,
+ claims_cls: None = None,
+ claims_options=None,
+ claims_params=None,
+ ) -> JWTClaims: ...
+ @overload
+ def decode(
+ self,
+ s: str | bytes,
+ key: _LoadKey | KeySet | tuple[Incomplete, ...] | list[Incomplete] | str,
+ claims_cls: type[_T],
+ claims_options=None,
+ claims_params=None,
+ ) -> _T: ...
def decode_payload(bytes_payload): ...
-def prepare_raw_key(raw): ...
+
+_TL = TypeVar("_TL", bound=tuple[Any, ...] | list[Any])
+
+@type_check_only
+class _Keys(TypedDict, Generic[_TL]):
+ keys: _TL
+
+@overload
+def prepare_raw_key(raw: KeySet) -> KeySet: ...
+@overload
+def prepare_raw_key(raw: str) -> dict[str, Any] | str: ... # dict is a JSON object
+@overload
+def prepare_raw_key(raw: _TL) -> _Keys[_TL]: ...
def find_encode_key(key, header): ...
-def create_load_key(key): ...
+def create_load_key(key: KeySet | _Keys[Incomplete] | Incomplete) -> _LoadKey: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc8037/okp_key.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc8037/okp_key.pyi
index aea552297898..085f798df7a2 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc8037/okp_key.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/jose/rfc8037/okp_key.pyi
@@ -1,24 +1,28 @@
-from _typeshed import Incomplete
+from typing import ClassVar, Final
from authlib.jose.rfc7517 import AsymmetricKey
+from cryptography.hazmat.primitives.asymmetric.ed448 import Ed448PrivateKey, Ed448PublicKey
+from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey, Ed25519PublicKey
+from cryptography.hazmat.primitives.asymmetric.x448 import X448PrivateKey, X448PublicKey
+from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey, X25519PublicKey
-PUBLIC_KEYS_MAP: Incomplete
-PRIVATE_KEYS_MAP: Incomplete
+PUBLIC_KEYS_MAP: Final[dict[str, type]]
+PRIVATE_KEYS_MAP: Final[dict[str, type]]
class OKPKey(AsymmetricKey):
kty: str
- REQUIRED_JSON_FIELDS: Incomplete
+ REQUIRED_JSON_FIELDS: ClassVar[list[str]]
PUBLIC_KEY_FIELDS = REQUIRED_JSON_FIELDS
- PRIVATE_KEY_FIELDS: Incomplete
- PUBLIC_KEY_CLS: Incomplete
- PRIVATE_KEY_CLS: Incomplete
- SSH_PUBLIC_PREFIX: bytes
+ PRIVATE_KEY_FIELDS: ClassVar[list[str]]
+ PUBLIC_KEY_CLS: ClassVar[tuple[type, ...]]
+ PRIVATE_KEY_CLS: ClassVar[tuple[type, ...]]
+ SSH_PUBLIC_PREFIX: ClassVar[bytes]
def exchange_shared_key(self, pubkey): ...
@staticmethod
def get_key_curve(key): ...
- def load_private_key(self): ...
- def load_public_key(self): ...
- def dumps_private_key(self): ...
- def dumps_public_key(self, public_key=None): ...
+ def load_private_key(self) -> Ed25519PrivateKey | Ed448PrivateKey | X25519PrivateKey | X448PrivateKey: ...
+ def load_public_key(self) -> Ed25519PublicKey | Ed448PublicKey | X25519PublicKey | X448PublicKey: ...
+ def dumps_private_key(self) -> dict[str, str | None]: ...
+ def dumps_public_key(self, public_key=None) -> dict[str, str | None]: ...
@classmethod
def generate_key(cls, crv: str = "Ed25519", options=None, is_private: bool = False) -> OKPKey: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth1/client.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth1/client.pyi
index 32ac22ba735c..5fe8395920a1 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth1/client.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth1/client.pyi
@@ -37,3 +37,4 @@ class OAuth1Client:
def parse_response_token(self, status_code, text): ...
@staticmethod
def handle_error(error_type, error_description) -> None: ...
+ def __del__(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/auth.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/auth.pyi
index 1e4cc2a8b2ae..b4b818d942ec 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/auth.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/auth.pyi
@@ -22,3 +22,4 @@ class TokenAuth:
def __init__(self, token, token_placement: str = "header", client=None) -> None: ...
def set_token(self, token) -> None: ...
def prepare(self, uri, headers, body): ...
+ def __del__(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/base.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/base.pyi
index fdf2f1f22504..366694c7194e 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/base.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/base.pyi
@@ -2,6 +2,8 @@ from _typeshed import Incomplete
from authlib.common.errors import AuthlibHTTPError
+def invalid_error_characters(text: str) -> list[str]: ...
+
class OAuth2Error(AuthlibHTTPError):
state: Incomplete
redirect_uri: Incomplete
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/client.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/client.pyi
index b9c81298a0f9..17fa26462891 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/client.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/client.pyi
@@ -58,3 +58,4 @@ class OAuth2Client:
def introspect_token(self, url, token=None, token_type_hint=None, body=None, auth=None, headers=None, **kwargs): ...
def register_compliance_hook(self, hook_type, hook) -> None: ...
def parse_response_token(self, resp): ...
+ def __del__(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/__init__.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/__init__.pyi
index 2e5ddb3a6130..360b28566411 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/__init__.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/__init__.pyi
@@ -29,15 +29,22 @@ from .grants import (
TokenEndpointMixin as TokenEndpointMixin,
)
from .models import AuthorizationCodeMixin as AuthorizationCodeMixin, ClientMixin as ClientMixin, TokenMixin as TokenMixin
-from .requests import JsonRequest as JsonRequest, OAuth2Request as OAuth2Request
+from .requests import (
+ JsonPayload as JsonPayload,
+ JsonRequest as JsonRequest,
+ OAuth2Payload as OAuth2Payload,
+ OAuth2Request as OAuth2Request,
+)
from .resource_protector import ResourceProtector as ResourceProtector, TokenValidator as TokenValidator
from .token_endpoint import TokenEndpoint as TokenEndpoint
from .util import list_to_scope as list_to_scope, scope_to_list as scope_to_list
from .wrappers import OAuth2Token as OAuth2Token
__all__ = [
+ "OAuth2Payload",
"OAuth2Token",
"OAuth2Request",
+ "JsonPayload",
"JsonRequest",
"OAuth2Error",
"AccessDeniedError",
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/authorization_server.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/authorization_server.pyi
index 396cb7e89b36..49d3afce88e5 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/authorization_server.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/authorization_server.pyi
@@ -1,13 +1,16 @@
from collections.abc import Callable, Collection, Mapping
-from typing_extensions import TypeAlias
+from typing import overload
+from typing_extensions import TypeAlias, deprecated
from authlib.oauth2 import JsonRequest, OAuth2Error, OAuth2Request
from authlib.oauth2.rfc6749 import BaseGrant, ClientMixin
from authlib.oauth2.rfc6750 import BearerTokenGenerator
+from .hooks import Hookable
+
_ServerResponse: TypeAlias = tuple[int, str, list[tuple[str, str]]]
-class AuthorizationServer:
+class AuthorizationServer(Hookable):
scopes_supported: Collection[str] | None
def __init__(self, scopes_supported: Collection[str] | None = None) -> None: ...
def query_client(self, client_id: str) -> ClientMixin: ...
@@ -24,12 +27,13 @@ class AuthorizationServer:
def register_token_generator(self, grant_type: str, func: BearerTokenGenerator) -> None: ...
def authenticate_client(self, request: OAuth2Request, methods: Collection[str], endpoint: str = "token") -> ClientMixin: ...
def register_client_auth_method(self, method, func) -> None: ...
+ def register_extension(self, extension) -> None: ...
def get_error_uri(self, request, error) -> None: ...
def send_signal(self, name, *args: object, **kwargs: object) -> None: ...
def create_oauth2_request(self, request) -> OAuth2Request: ...
def create_json_request(self, request) -> JsonRequest: ...
def handle_response(self, status: int, body: Mapping[str, object], headers: Mapping[str, str]) -> object: ...
- def validate_requested_scope(self, scope: str, state: str | None = None) -> None: ...
+ def validate_requested_scope(self, scope: str) -> None: ...
def register_grant(
self, grant_cls: type[BaseGrant], extensions: Collection[Callable[[BaseGrant], None]] | None = None
) -> None: ...
@@ -38,6 +42,10 @@ class AuthorizationServer:
def get_consent_grant(self, request=None, end_user=None): ...
def get_token_grant(self, request: OAuth2Request) -> BaseGrant: ...
def create_endpoint_response(self, name, request=None): ...
+ @overload
+ @deprecated("The 'grant' parameter will become mandatory.")
def create_authorization_response(self, request=None, grant_user=None) -> object: ...
+ @overload
+ def create_authorization_response(self, request=None, grant_user=None, grant=None) -> object: ...
def create_token_response(self, request=None) -> _ServerResponse: ...
def handle_error_response(self, request: OAuth2Request, error: OAuth2Error) -> object: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/errors.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/errors.pyi
index 5244780497f4..8436b28f2c11 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/errors.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/errors.pyi
@@ -44,7 +44,17 @@ class UnauthorizedClientError(OAuth2Error):
class UnsupportedResponseTypeError(OAuth2Error):
error: str
response_type: Incomplete
- def __init__(self, response_type) -> None: ...
+ def __init__(
+ self,
+ response_type,
+ description=None,
+ uri=None,
+ status_code=None,
+ state=None,
+ redirect_uri=None,
+ redirect_fragment: bool = False,
+ error=None,
+ ) -> None: ...
def get_error_description(self): ...
class UnsupportedGrantTypeError(OAuth2Error):
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/authorization_code.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/authorization_code.pyi
index 5db449f98a86..356a77d2d625 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/authorization_code.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/authorization_code.pyi
@@ -1,4 +1,5 @@
from collections.abc import Collection
+from logging import Logger
from typing_extensions import TypeAlias
from authlib.oauth2 import OAuth2Request
@@ -6,6 +7,8 @@ from authlib.oauth2.rfc6749 import AuthorizationEndpointMixin, BaseGrant, Client
_ServerResponse: TypeAlias = tuple[int, str, list[tuple[str, str]]]
+log: Logger
+
class AuthorizationCodeGrant(BaseGrant, AuthorizationEndpointMixin, TokenEndpointMixin):
TOKEN_ENDPOINT_AUTH_METHODS: Collection[str]
AUTHORIZATION_CODE_LENGTH: int
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/base.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/base.pyi
index 65f2dcc92645..88b977959580 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/base.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/base.pyi
@@ -1,13 +1,15 @@
from _typeshed import Incomplete
-from collections.abc import Callable, Collection
+from collections.abc import Collection
from typing_extensions import TypeAlias
from authlib.oauth2 import OAuth2Request
from authlib.oauth2.rfc6749 import ClientMixin
+from ..hooks import Hookable
+
_ServerResponse: TypeAlias = tuple[int, str, list[tuple[str, str]]]
-class BaseGrant:
+class BaseGrant(Hookable):
TOKEN_ENDPOINT_AUTH_METHODS: Collection[str]
GRANT_TYPE: str | None
TOKEN_RESPONSE_HEADER: Collection[tuple[str, str]]
@@ -29,8 +31,6 @@ class BaseGrant:
def authenticate_token_endpoint_client(self) -> ClientMixin: ...
def save_token(self, token): ...
def validate_requested_scope(self) -> None: ...
- def register_hook(self, hook_type: str, hook: Callable[..., Incomplete]) -> None: ...
- def execute_hook(self, hook_type: str, *args: object, **kwargs: object) -> None: ...
class TokenEndpointMixin:
TOKEN_ENDPOINT_HTTP_METHODS: Incomplete
@@ -49,7 +49,7 @@ class AuthorizationEndpointMixin:
def validate_authorization_redirect_uri(request: OAuth2Request, client: ClientMixin) -> str: ...
@staticmethod
def validate_no_multiple_request_parameter(request: OAuth2Request): ...
- redirect_uri: Incomplete
- def validate_consent_request(self) -> None: ...
+ redirect_uri: str
+ def validate_consent_request(self) -> str: ...
def validate_authorization_request(self) -> str: ...
def create_authorization_response(self, redirect_uri: str, grant_user) -> _ServerResponse: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/client_credentials.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/client_credentials.pyi
index b7f090ef5d63..39a26a843f82 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/client_credentials.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/client_credentials.pyi
@@ -1,5 +1,9 @@
+from logging import Logger
+
from authlib.oauth2.rfc6749 import BaseGrant, TokenEndpointMixin
+log: Logger
+
class ClientCredentialsGrant(BaseGrant, TokenEndpointMixin):
GRANT_TYPE: str
def validate_token_request(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/implicit.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/implicit.pyi
index b106bf654967..69b1946356d2 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/implicit.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/implicit.pyi
@@ -1,7 +1,10 @@
from _typeshed import Incomplete
+from logging import Logger
from authlib.oauth2.rfc6749 import AuthorizationEndpointMixin, BaseGrant
+log: Logger
+
class ImplicitGrant(BaseGrant, AuthorizationEndpointMixin):
AUTHORIZATION_ENDPOINT: bool
TOKEN_ENDPOINT_AUTH_METHODS: Incomplete
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/refresh_token.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/refresh_token.pyi
index 9d23ebed4089..ed025a1bbdc5 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/refresh_token.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/refresh_token.pyi
@@ -1,9 +1,12 @@
+from logging import Logger
from typing_extensions import TypeAlias
from authlib.oauth2.rfc6749 import BaseGrant, TokenEndpointMixin, TokenMixin
_ServerResponse: TypeAlias = tuple[int, str, list[tuple[str, str]]]
+log: Logger
+
class RefreshTokenGrant(BaseGrant, TokenEndpointMixin):
GRANT_TYPE: str
INCLUDE_NEW_REFRESH_TOKEN: bool
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/resource_owner_password_credentials.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/resource_owner_password_credentials.pyi
index 4637a8064e21..ad18a6eb0d22 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/resource_owner_password_credentials.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/grants/resource_owner_password_credentials.pyi
@@ -1,5 +1,9 @@
+from logging import Logger
+
from authlib.oauth2.rfc6749 import BaseGrant, TokenEndpointMixin
+log: Logger
+
class ResourceOwnerPasswordCredentialsGrant(BaseGrant, TokenEndpointMixin):
GRANT_TYPE: str
def validate_token_request(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/hooks.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/hooks.pyi
new file mode 100644
index 000000000000..78aa94a7a20d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/hooks.pyi
@@ -0,0 +1,8 @@
+from collections.abc import Callable
+
+class Hookable:
+ def __init__(self) -> None: ...
+ def register_hook(self, hook_type: str, hook: Callable[..., None]) -> None: ...
+ def execute_hook(self, hook_type: str, *args, **kwargs) -> None: ...
+
+def hooked(func=None, before: str | None = None, after: str | None = None): ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/models.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/models.pyi
index 87649d102cef..47c8ed0ebcfc 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/models.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/models.pyi
@@ -20,3 +20,5 @@ class TokenMixin:
def get_expires_in(self) -> int: ...
def is_expired(self) -> bool: ...
def is_revoked(self) -> bool: ...
+ def get_user(self): ...
+ def get_client(self) -> ClientMixin: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/requests.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/requests.pyi
index 6b9056ef2eb9..a1e18c2db8ce 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/requests.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6749/requests.pyi
@@ -1,26 +1,10 @@
from _typeshed import Incomplete
from collections.abc import Mapping
+from typing_extensions import deprecated
from authlib.oauth2.rfc6749 import ClientMixin
-class OAuth2Request:
- method: str
- uri: str
- body: Mapping[str, str] | None
- headers: Mapping[str, str] | None
- client: ClientMixin | None
- auth_method: str | None
- user: Incomplete | None
- authorization_code: Incomplete | None
- refresh_token: Incomplete | None
- credential: Incomplete | None
- def __init__(
- self, method: str, uri: str, body: Mapping[str, str] | None = None, headers: Mapping[str, str] | None = None
- ) -> None: ...
- @property
- def args(self) -> dict[str, str | None]: ...
- @property
- def form(self) -> dict[str, str]: ...
+class OAuth2Payload:
@property
def data(self) -> dict[str, str]: ...
@property
@@ -38,11 +22,64 @@ class OAuth2Request:
@property
def state(self) -> str | None: ...
-class JsonRequest:
- method: Incomplete
- uri: Incomplete
- body: Incomplete
- headers: Incomplete
- def __init__(self, method, uri, body=None, headers=None) -> None: ...
+class BasicOAuth2Payload(OAuth2Payload):
+ def __init__(self, payload: dict[str, str]) -> None: ...
+ @property
+ def data(self) -> dict[str, str]: ...
+ @property
+ def datalist(self) -> dict[str, list[Incomplete]]: ...
+
+class OAuth2Request(OAuth2Payload):
+ method: str
+ uri: str
+ headers: Mapping[str, str] | None
+ payload: OAuth2Payload | None
+ client: ClientMixin | None
+ auth_method: str | None
+ user: Incomplete | None
+ authorization_code: Incomplete | None
+ refresh_token: Incomplete | None
+ credential: Incomplete | None
+ def __init__(self, method: str, uri: str, headers: Mapping[str, str] | None = None) -> None: ...
+ @property
+ def args(self) -> dict[str, str | None]: ...
+ @property
+ def form(self) -> dict[str, str]: ...
+ @property
+ @deprecated("'request.data' is deprecated in favor of 'request.payload.data'")
+ def data(self) -> dict[str, str]: ...
+ @property
+ @deprecated("'request.datalist' is deprecated in favor of 'request.payload.datalist'")
+ def datalist(self) -> dict[str, list[Incomplete]]: ...
+ @property
+ @deprecated("'request.client_id' is deprecated in favor of 'request.payload.client_id'")
+ def client_id(self) -> str: ...
+ @property
+ @deprecated("'request.response_type' is deprecated in favor of 'request.payload.response_type'")
+ def response_type(self) -> str: ...
+ @property
+ @deprecated("'request.grant_type' is deprecated in favor of 'request.payload.grant_type'")
+ def grant_type(self) -> str: ...
+ @property
+ @deprecated("'request.redirect_uri' is deprecated in favor of 'request.payload.redirect_uri'")
+ def redirect_uri(self) -> str: ...
+ @property
+ @deprecated("'request.scope' is deprecated in favor of 'request.payload.scope'")
+ def scope(self) -> str: ...
+ @property
+ @deprecated("'request.state' is deprecated in favor of 'request.payload.state'")
+ def state(self) -> str | None: ...
+
+class JsonPayload:
@property
def data(self): ...
+
+class JsonRequest:
+ method: str
+ uri: str
+ payload: JsonPayload | None
+ headers: Mapping[str, str]
+ def __init__(self, method: str, uri: str, headers: Mapping[str, str] | None = None) -> None: ...
+ @property
+ @deprecated("'request.data' is deprecated in favor of 'request.payload.data'")
+ def data(self): ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6750/token.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6750/token.pyi
index 63a388bdb65d..bd521552611f 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6750/token.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc6750/token.pyi
@@ -1,8 +1,9 @@
from collections.abc import Callable
-from typing import Protocol
+from typing import Protocol, type_check_only
from authlib.oauth2.rfc6749 import ClientMixin
+@type_check_only
class _TokenGenerator(Protocol):
def __call__(self, *, client: ClientMixin, grant_type: str, user, scope: str) -> str: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc7521/client.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc7521/client.pyi
index 3aa0c2097a8b..bd0c0821749e 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc7521/client.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc7521/client.pyi
@@ -37,3 +37,4 @@ class AssertionClient:
def token(self, token) -> None: ...
def refresh_token(self): ...
def parse_response_token(self, resp): ...
+ def __del__(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc7523/client.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc7523/client.pyi
index 50b6ae797299..728141d878f3 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc7523/client.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc7523/client.pyi
@@ -1,6 +1,8 @@
+from logging import Logger
from typing import Final
ASSERTION_TYPE: Final[str]
+log: Logger
class JWTBearerClientAssertion:
CLIENT_ASSERTION_TYPE: Final[str]
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc7523/jwt_bearer.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc7523/jwt_bearer.pyi
index fde65f14309d..151e5dbef9fa 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc7523/jwt_bearer.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc7523/jwt_bearer.pyi
@@ -1,12 +1,15 @@
-from _typeshed import Incomplete
+from logging import Logger
+from typing import ClassVar, Final
from authlib.oauth2.rfc6749 import BaseGrant, TokenEndpointMixin
-JWT_BEARER_GRANT_TYPE: str
+log: Logger
+JWT_BEARER_GRANT_TYPE: Final[str]
class JWTBearerGrant(BaseGrant, TokenEndpointMixin):
GRANT_TYPE = JWT_BEARER_GRANT_TYPE
- CLAIMS_OPTIONS: Incomplete
+ CLAIMS_OPTIONS: ClassVar[dict[str, dict[str, bool]]]
+ LEEWAY: ClassVar[int]
@staticmethod
def sign(key, issuer, audience, subject=None, issued_at=None, expires_at=None, claims=None, **kwargs): ...
def process_assertion_claims(self, assertion): ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc7636/challenge.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc7636/challenge.pyi
index 71b92213b6a2..e3d07e846686 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc7636/challenge.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc7636/challenge.pyi
@@ -1,7 +1,10 @@
+import re
from _typeshed import Incomplete
+from collections.abc import Callable
+from typing import Final
-CODE_VERIFIER_PATTERN: Incomplete
-CODE_CHALLENGE_PATTERN: Incomplete
+CODE_VERIFIER_PATTERN: Final[re.Pattern[str]]
+CODE_CHALLENGE_PATTERN: Final[re.Pattern[str]]
def create_s256_code_challenge(code_verifier): ...
def compare_plain_code_challenge(code_verifier, code_challenge): ...
@@ -9,12 +12,12 @@ def compare_s256_code_challenge(code_verifier, code_challenge): ...
class CodeChallenge:
DEFAULT_CODE_CHALLENGE_METHOD: str
- SUPPORTED_CODE_CHALLENGE_METHOD: Incomplete
- CODE_CHALLENGE_METHODS: Incomplete
- required: Incomplete
+ SUPPORTED_CODE_CHALLENGE_METHOD: list[str]
+ CODE_CHALLENGE_METHODS: dict[str, Callable[[Incomplete, Incomplete], Incomplete]]
+ required: bool
def __init__(self, required: bool = True) -> None: ...
def __call__(self, grant) -> None: ...
- def validate_code_challenge(self, grant) -> None: ...
- def validate_code_verifier(self, grant) -> None: ...
+ def validate_code_challenge(self, grant, redirect_uri) -> None: ...
+ def validate_code_verifier(self, grant, result) -> None: ...
def get_authorization_code_challenge(self, authorization_code): ...
def get_authorization_code_challenge_method(self, authorization_code): ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc8628/device_code.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc8628/device_code.pyi
index 931b40dd3f1f..0e7d22172678 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc8628/device_code.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc8628/device_code.pyi
@@ -1,7 +1,9 @@
from _typeshed import Incomplete
+from logging import Logger
from authlib.oauth2.rfc6749 import BaseGrant, TokenEndpointMixin
+log: Logger
DEVICE_CODE_GRANT_TYPE: str
class DeviceCodeGrant(BaseGrant, TokenEndpointMixin):
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9068/claims.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9068/claims.pyi
index b845e2d7129c..e68d1ba20a90 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9068/claims.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9068/claims.pyi
@@ -1,7 +1,7 @@
from authlib.jose import JWTClaims
class JWTAccessTokenClaims(JWTClaims):
- def validate(self, now=None, leeway: int = 0, **kwargs) -> None: ...
+ def validate(self, *, now=None, leeway: int = 0) -> None: ... # type: ignore[override]
def validate_typ(self) -> None: ...
def validate_client_id(self): ...
def validate_auth_time(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9101/__init__.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9101/__init__.pyi
new file mode 100644
index 000000000000..8a6295782b36
--- /dev/null
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9101/__init__.pyi
@@ -0,0 +1,5 @@
+from .authorization_server import JWTAuthenticationRequest as JWTAuthenticationRequest
+from .discovery import AuthorizationServerMetadata as AuthorizationServerMetadata
+from .registration import ClientMetadataClaims as ClientMetadataClaims
+
+__all__ = ["AuthorizationServerMetadata", "JWTAuthenticationRequest", "ClientMetadataClaims"]
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9101/authorization_server.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9101/authorization_server.pyi
new file mode 100644
index 000000000000..c889ee7b2f93
--- /dev/null
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9101/authorization_server.pyi
@@ -0,0 +1,15 @@
+from _typeshed import Incomplete
+
+from ..rfc6749 import AuthorizationServer, ClientMixin
+from ..rfc6749.requests import OAuth2Request
+
+class JWTAuthenticationRequest:
+ support_request: bool
+ support_request_uri: bool
+ def __init__(self, support_request: bool = True, support_request_uri: bool = True) -> None: ...
+ def __call__(self, authorization_server: AuthorizationServer) -> None: ...
+ def parse_authorization_request(self, authorization_server: AuthorizationServer, request: OAuth2Request) -> None: ...
+ def get_request_object(self, request_uri: str): ...
+ def resolve_client_public_keys(self, client: ClientMixin): ...
+ def get_server_metadata(self) -> dict[str, Incomplete]: ...
+ def get_client_require_signed_request_object(self, client: ClientMixin) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9101/discovery.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9101/discovery.pyi
new file mode 100644
index 000000000000..82d106bbae5b
--- /dev/null
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9101/discovery.pyi
@@ -0,0 +1,5 @@
+from _typeshed import Incomplete
+
+class AuthorizationServerMetadata(dict[str, object]):
+ REGISTRY_KEYS: Incomplete
+ def validate_require_signed_request_object(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9101/errors.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9101/errors.pyi
new file mode 100644
index 000000000000..a0bcd96e173b
--- /dev/null
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9101/errors.pyi
@@ -0,0 +1,23 @@
+from ..base import OAuth2Error
+
+__all__ = ["InvalidRequestUriError", "InvalidRequestObjectError", "RequestNotSupportedError", "RequestUriNotSupportedError"]
+
+class InvalidRequestUriError(OAuth2Error):
+ error: str
+ description: str
+ status_code: int
+
+class InvalidRequestObjectError(OAuth2Error):
+ error: str
+ description: str
+ status_code: int
+
+class RequestNotSupportedError(OAuth2Error):
+ error: str
+ description: str
+ status_code: int
+
+class RequestUriNotSupportedError(OAuth2Error):
+ error: str
+ description: str
+ status_code: int
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9101/registration.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9101/registration.pyi
new file mode 100644
index 000000000000..f4c742554cb5
--- /dev/null
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9101/registration.pyi
@@ -0,0 +1,5 @@
+from authlib.jose import BaseClaims
+
+class ClientMetadataClaims(BaseClaims):
+ def validate(self) -> None: ...
+ def validate_require_signed_request_object(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9207/parameter.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9207/parameter.pyi
index 8e06d4bb7b46..70e2ee20b7f2 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9207/parameter.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oauth2/rfc9207/parameter.pyi
@@ -1,4 +1,4 @@
class IssuerParameter:
- def __call__(self, grant) -> None: ...
- def add_issuer_parameter(self, hook_type: str, response) -> None: ...
+ def __call__(self, authorization_server) -> None: ...
+ def add_issuer_parameter(self, authorization_server, response) -> None: ...
def get_issuer(self) -> str | None: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/__init__.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/__init__.pyi
index 00a6e700d31d..0763373dc8ff 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/__init__.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/__init__.pyi
@@ -13,6 +13,7 @@ from .grants import (
OpenIDToken as OpenIDToken,
)
from .models import AuthorizationCodeMixin as AuthorizationCodeMixin
+from .userinfo import UserInfoEndpoint as UserInfoEndpoint
__all__ = [
"AuthorizationCodeMixin",
@@ -21,6 +22,7 @@ __all__ = [
"ImplicitIDToken",
"HybridIDToken",
"UserInfo",
+ "UserInfoEndpoint",
"get_claim_cls_by_response_type",
"OpenIDToken",
"OpenIDCode",
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/claims.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/claims.pyi
index 1fbd121ddd8f..d58ac367067d 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/claims.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/claims.pyi
@@ -28,7 +28,9 @@ class HybridIDToken(ImplicitIDToken):
def validate_c_hash(self) -> None: ...
class UserInfo(dict[str, object]):
- REGISTERED_CLAIMS: Incomplete
+ REGISTERED_CLAIMS: list[str]
+ SCOPES_CLAIMS_MAPPING: dict[str, list[str]]
+ def filter(self, scope: str) -> UserInfo: ...
def __getattr__(self, key): ...
def get_claim_cls_by_response_type(response_type): ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/grants/code.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/grants/code.pyi
index 3ad0e20e3b80..b2339b061c4e 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/grants/code.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/grants/code.pyi
@@ -1,17 +1,21 @@
+from logging import Logger
+
from authlib.oauth2 import OAuth2Request
from authlib.oauth2.rfc6749 import BaseGrant
from authlib.oidc.core import UserInfo
+log: Logger
+
class OpenIDToken:
def get_jwt_config(self, grant: BaseGrant) -> dict[str, str | int]: ...
def generate_user_info(self, user, scope: str) -> UserInfo: ...
def get_audiences(self, request: OAuth2Request) -> list[str]: ...
- def process_token(self, grant: BaseGrant, token: dict[str, str | int]) -> dict[str, str | int]: ...
+ def process_token(self, grant: BaseGrant, response) -> dict[str, str | int]: ...
def __call__(self, grant: BaseGrant) -> None: ...
class OpenIDCode(OpenIDToken):
require_nonce: bool
def __init__(self, require_nonce: bool = False) -> None: ...
def exists_nonce(self, nonce: str, request: OAuth2Request) -> bool: ...
- def validate_openid_authorization_request(self, grant: BaseGrant) -> None: ...
+ def validate_openid_authorization_request(self, grant: BaseGrant, redirect_uri) -> None: ...
def __call__(self, grant: BaseGrant) -> None: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/grants/hybrid.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/grants/hybrid.pyi
index c3a3a7b03def..c57e53dbce90 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/grants/hybrid.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/grants/hybrid.pyi
@@ -1,7 +1,10 @@
from _typeshed import Incomplete
+from logging import Logger
from authlib.oidc.core import OpenIDImplicitGrant
+log: Logger
+
class OpenIDHybridGrant(OpenIDImplicitGrant):
AUTHORIZATION_CODE_LENGTH: int
RESPONSE_TYPES: Incomplete
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/grants/implicit.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/grants/implicit.pyi
index e487fc127ea6..a25ddc555700 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/grants/implicit.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/grants/implicit.pyi
@@ -1,7 +1,10 @@
from _typeshed import Incomplete
+from logging import Logger
from authlib.oauth2.rfc6749 import ImplicitGrant
+log: Logger
+
class OpenIDImplicitGrant(ImplicitGrant):
RESPONSE_TYPES: Incomplete
DEFAULT_RESPONSE_MODE: str
@@ -9,8 +12,8 @@ class OpenIDImplicitGrant(ImplicitGrant):
def get_jwt_config(self) -> None: ...
def generate_user_info(self, user, scope) -> None: ...
def get_audiences(self, request): ...
- def validate_authorization_request(self): ...
- def validate_consent_request(self) -> None: ...
+ def validate_authorization_request(self) -> str: ...
+ def validate_consent_request(self) -> str: ...
def create_authorization_response(self, redirect_uri, grant_user): ...
def create_granted_params(self, grant_user): ...
def process_implicit_token(self, token, code=None): ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/grants/util.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/grants/util.pyi
index 9800380f4659..772103c305ce 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/grants/util.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/grants/util.pyi
@@ -13,6 +13,8 @@ def generate_id_token(
exp: int = 3600,
nonce: str | None = None,
auth_time: int | None = None,
+ acr: str | None = None,
+ amr: list[str] | None = None,
code: str | None = None,
kid: str | None = None,
) -> str: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/models.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/models.pyi
index f081a20b9e44..d204f91d0cb3 100644
--- a/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/models.pyi
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/models.pyi
@@ -3,3 +3,5 @@ from authlib.oauth2.rfc6749 import AuthorizationCodeMixin as _AuthorizationCodeM
class AuthorizationCodeMixin(_AuthorizationCodeMixin):
def get_nonce(self) -> str | None: ...
def get_auth_time(self) -> int | None: ...
+ def get_acr(self) -> str: ...
+ def get_amr(self) -> list[str]: ...
diff --git a/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/userinfo.pyi b/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/userinfo.pyi
new file mode 100644
index 000000000000..0c612351b36a
--- /dev/null
+++ b/python/helpers/typeshed/stubs/Authlib/authlib/oidc/core/userinfo.pyi
@@ -0,0 +1,18 @@
+from authlib.oauth2.rfc6749.authorization_server import AuthorizationServer
+from authlib.oauth2.rfc6749.requests import OAuth2Request
+from authlib.oauth2.rfc6749.resource_protector import ResourceProtector
+
+from .claims import UserInfo
+
+class UserInfoEndpoint:
+ ENDPOINT_NAME: str
+ server: AuthorizationServer | None
+ resource_protector: ResourceProtector | None
+ def __init__(
+ self, server: AuthorizationServer | None = None, resource_protector: ResourceProtector | None = None
+ ) -> None: ...
+ def create_endpoint_request(self, request: OAuth2Request): ...
+ def __call__(self, request: OAuth2Request) -> tuple[int, dict[str, str | None], list[tuple[str, str]]]: ...
+ def generate_user_info(self, user, scope: str) -> UserInfo: ...
+ def get_issuer(self) -> str: ...
+ def resolve_private_key(self): ...
diff --git a/python/helpers/typeshed/stubs/Flask-Cors/flask_cors/core.pyi b/python/helpers/typeshed/stubs/Flask-Cors/flask_cors/core.pyi
index 176e8905eab1..f2ae68861d68 100644
--- a/python/helpers/typeshed/stubs/Flask-Cors/flask_cors/core.pyi
+++ b/python/helpers/typeshed/stubs/Flask-Cors/flask_cors/core.pyi
@@ -2,7 +2,7 @@ from collections.abc import Iterable
from datetime import timedelta
from logging import Logger
from re import Match, Pattern
-from typing import Any, Final, Literal, TypedDict, TypeVar, overload
+from typing import Any, Final, Literal, TypedDict, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
import flask
@@ -11,6 +11,7 @@ _IterableT = TypeVar("_IterableT", bound=Iterable[Any])
_T = TypeVar("_T")
_MultiDict: TypeAlias = Any # werkzeug is not part of typeshed
+@type_check_only
class _Options(TypedDict, total=False):
resources: dict[str, dict[str, Any]] | list[str] | str | None
origins: str | list[str] | None
diff --git a/python/helpers/typeshed/stubs/Flask-Migrate/flask_migrate/__init__.pyi b/python/helpers/typeshed/stubs/Flask-Migrate/flask_migrate/__init__.pyi
index 4d7664402c46..41c0f76741fd 100644
--- a/python/helpers/typeshed/stubs/Flask-Migrate/flask_migrate/__init__.pyi
+++ b/python/helpers/typeshed/stubs/Flask-Migrate/flask_migrate/__init__.pyi
@@ -5,7 +5,7 @@ from _typeshed import StrPath, SupportsFlush, SupportsKeysAndGetItem, SupportsWr
from argparse import Namespace
from collections.abc import Callable, Iterable, Sequence
from logging import Logger
-from typing import Any, Protocol, TypeVar
+from typing import Any, Protocol, TypeVar, type_check_only
from typing_extensions import ParamSpec, TypeAlias
import flask
@@ -20,6 +20,7 @@ _AlembicConfigValue: TypeAlias = Any
alembic_version: tuple[int, int, int]
log: Logger
+@type_check_only
class _SupportsWriteAndFlush(SupportsWrite[_T_contra], SupportsFlush, Protocol): ...
class Config: # should inherit from alembic.config.Config which is not possible yet
diff --git a/python/helpers/typeshed/stubs/Flask-SocketIO/flask_socketio/__init__.pyi b/python/helpers/typeshed/stubs/Flask-SocketIO/flask_socketio/__init__.pyi
index 1b20806fda6c..8fa0c25a66fc 100644
--- a/python/helpers/typeshed/stubs/Flask-SocketIO/flask_socketio/__init__.pyi
+++ b/python/helpers/typeshed/stubs/Flask-SocketIO/flask_socketio/__init__.pyi
@@ -2,7 +2,7 @@ from _typeshed import Incomplete
from collections.abc import Callable
from logging import Logger
from threading import Thread
-from typing import Any, Literal, Protocol, TypedDict, TypeVar, overload
+from typing import Any, Literal, Protocol, TypedDict, TypeVar, overload, type_check_only
from typing_extensions import ParamSpec, TypeAlias, Unpack
from flask import Flask
@@ -16,12 +16,15 @@ _R_co = TypeVar("_R_co", covariant=True)
_ExceptionHandler: TypeAlias = Callable[[BaseException], _R_co]
_Handler: TypeAlias = Callable[_P, _R_co]
+@type_check_only
class _HandlerDecorator(Protocol):
def __call__(self, handler: _Handler[_P, _R_co]) -> _Handler[_P, _R_co]: ...
+@type_check_only
class _ExceptionHandlerDecorator(Protocol):
def __call__(self, exception_handler: _ExceptionHandler[_R_co]) -> _ExceptionHandler[_R_co]: ...
+@type_check_only
class _SocketIOServerOptions(TypedDict, total=False):
client_manager: Incomplete
logger: Logger | bool
@@ -29,6 +32,7 @@ class _SocketIOServerOptions(TypedDict, total=False):
async_handlers: bool
always_connect: bool
+@type_check_only
class _EngineIOServerConfig(TypedDict, total=False):
async_mode: Literal["threading", "eventlet", "gevent", "gevent_uwsgi"]
ping_interval: float | tuple[float, float] # seconds
@@ -43,6 +47,7 @@ class _EngineIOServerConfig(TypedDict, total=False):
monitor_clients: bool
engineio_logger: Logger | bool
+@type_check_only
class _SocketIOKwargs(_SocketIOServerOptions, _EngineIOServerConfig): ...
class SocketIO:
diff --git a/python/helpers/typeshed/stubs/Flask-SocketIO/flask_socketio/namespace.pyi b/python/helpers/typeshed/stubs/Flask-SocketIO/flask_socketio/namespace.pyi
index 50ef75dceba2..94ec7b716dd2 100644
--- a/python/helpers/typeshed/stubs/Flask-SocketIO/flask_socketio/namespace.pyi
+++ b/python/helpers/typeshed/stubs/Flask-SocketIO/flask_socketio/namespace.pyi
@@ -1,10 +1,11 @@
from _typeshed import Incomplete
from collections.abc import Callable
-from typing import Any, Protocol, TypeVar
+from typing import Any, Protocol, TypeVar, type_check_only
_T = TypeVar("_T")
# at runtime, socketio.namespace.BaseNamespace, but socketio isn't py.typed
+@type_check_only
class _BaseNamespace(Protocol):
def is_asyncio_based(self) -> bool: ...
def trigger_event(self, event: str, *args): ...
diff --git a/python/helpers/typeshed/stubs/Flask-SocketIO/flask_socketio/test_client.pyi b/python/helpers/typeshed/stubs/Flask-SocketIO/flask_socketio/test_client.pyi
index 62f27781c868..15cf426959a0 100644
--- a/python/helpers/typeshed/stubs/Flask-SocketIO/flask_socketio/test_client.pyi
+++ b/python/helpers/typeshed/stubs/Flask-SocketIO/flask_socketio/test_client.pyi
@@ -1,9 +1,10 @@
from _typeshed import Incomplete
-from typing import Any, TypedDict
+from typing import Any, TypedDict, type_check_only
from flask import Flask
from flask.testing import FlaskClient
+@type_check_only
class _Packet(TypedDict):
name: str
args: Any
diff --git a/python/helpers/typeshed/stubs/JACK-Client/METADATA.toml b/python/helpers/typeshed/stubs/JACK-Client/METADATA.toml
index f18e0144f591..b37b5b295512 100644
--- a/python/helpers/typeshed/stubs/JACK-Client/METADATA.toml
+++ b/python/helpers/typeshed/stubs/JACK-Client/METADATA.toml
@@ -5,7 +5,7 @@ requires = ["numpy>=1.20", "types-cffi"]
[tool.stubtest]
# darwin and win32 are equivalent
-platforms = ["darwin", "linux"]
+ci_platforms = ["darwin", "linux"]
apt_dependencies = ["libjack-dev"]
brew_dependencies = ["jack"]
# No need to install on the CI. Leaving here as information for Windows contributors.
diff --git a/python/helpers/typeshed/stubs/JACK-Client/jack/__init__.pyi b/python/helpers/typeshed/stubs/JACK-Client/jack/__init__.pyi
index 0644f983e694..7f5627b79f55 100644
--- a/python/helpers/typeshed/stubs/JACK-Client/jack/__init__.pyi
+++ b/python/helpers/typeshed/stubs/JACK-Client/jack/__init__.pyi
@@ -1,6 +1,6 @@
from _typeshed import Unused
from collections.abc import Callable, Generator, Iterable, Iterator, Sequence
-from typing import Any, Final, Literal, NoReturn, overload
+from typing import Any, Final, Literal, NoReturn, overload, type_check_only
from typing_extensions import Self
import numpy
@@ -11,6 +11,7 @@ from numpy.typing import NDArray
# Actual type: _cffi_backend.__CDataOwn
# This is not a real subclassing. Just ensuring type-checkers sees this type as compatible with _CDataBase
# pyright has no error code for subclassing final
+@type_check_only
class _JackPositionT(_CDataBase): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
audio_frames_per_video_frame: float
bar: int
@@ -33,6 +34,7 @@ class _JackPositionT(_CDataBase): # type: ignore[misc] # pyright: ignore[repor
valid: int
video_offset: int
+@type_check_only
class _CBufferType:
@overload
def __getitem__(self, key: int) -> str: ...
@@ -190,7 +192,7 @@ class Port:
def set_alias(self, alias: str) -> None: ...
def unset_alias(self, alias: str) -> None: ...
@property
- def uuid(self) -> str: ...
+ def uuid(self) -> int: ...
@property
def is_audio(self) -> bool: ...
@property
@@ -306,7 +308,7 @@ class CallbackExit(Exception): ...
def get_property(subject: int | str, key: str) -> tuple[bytes, str] | None: ...
def get_properties(subject: int | str) -> dict[str, tuple[bytes, str]]: ...
-def get_all_properties() -> dict[str, dict[str, tuple[bytes, str]]]: ...
+def get_all_properties() -> dict[int, dict[str, tuple[bytes, str]]]: ...
def position2dict(pos: _JackPositionT) -> dict[str, Any]: ... # Anyof[int, float, _CDataBase]
def version() -> tuple[int, int, int, int]: ...
def version_string() -> str: ...
diff --git a/python/helpers/typeshed/stubs/Jetson.GPIO/Jetson/GPIO/gpio_event.pyi b/python/helpers/typeshed/stubs/Jetson.GPIO/Jetson/GPIO/gpio_event.pyi
index 1f456f9c2c46..8e470cba9ed5 100644
--- a/python/helpers/typeshed/stubs/Jetson.GPIO/Jetson/GPIO/gpio_event.pyi
+++ b/python/helpers/typeshed/stubs/Jetson.GPIO/Jetson/GPIO/gpio_event.pyi
@@ -9,7 +9,7 @@ BOTH_EDGE: Final = 3
def add_edge_detect(
chip_fd: int, chip_name: str, channel: int, request: int, bouncetime: int, poll_time: float
) -> Literal[1, 2, 0]: ...
-def remove_edge_detect(chip_name: str, channel: int, timeout: float = ...) -> None: ...
+def remove_edge_detect(chip_name: str, channel: int, timeout: float = 0.3) -> None: ...
def add_edge_callback(chip_name: str, channel: int, callback: Callable[[int], None]) -> None: ...
def edge_event_detected(chip_name: str, channel: int) -> bool: ...
def gpio_event_added(chip_name: str, channel: int) -> Any: ...
diff --git a/python/helpers/typeshed/stubs/Markdown/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/Markdown/@tests/stubtest_allowlist.txt
index e7cd7309850d..1523b9aa78d0 100644
--- a/python/helpers/typeshed/stubs/Markdown/@tests/stubtest_allowlist.txt
+++ b/python/helpers/typeshed/stubs/Markdown/@tests/stubtest_allowlist.txt
@@ -1,3 +1,4 @@
# Deprecated types are infered as functions:
markdown.extensions.abbr.AbbrPreprocessor
markdown.extensions.abbr.AbbrInlineProcessor
+markdown.postprocessors.UnescapePostprocessor
diff --git a/python/helpers/typeshed/stubs/Markdown/METADATA.toml b/python/helpers/typeshed/stubs/Markdown/METADATA.toml
index 68fead4ecf6b..01a67268ef5d 100644
--- a/python/helpers/typeshed/stubs/Markdown/METADATA.toml
+++ b/python/helpers/typeshed/stubs/Markdown/METADATA.toml
@@ -1,6 +1,2 @@
version = "3.8.*"
upstream_repository = "https://github.com/Python-Markdown/markdown"
-partial_stub = true
-
-[tool.stubtest]
-ignore_missing_stub = true
diff --git a/python/helpers/typeshed/stubs/Markdown/markdown/__main__.pyi b/python/helpers/typeshed/stubs/Markdown/markdown/__main__.pyi
new file mode 100644
index 000000000000..ca90cb1fa7f1
--- /dev/null
+++ b/python/helpers/typeshed/stubs/Markdown/markdown/__main__.pyi
@@ -0,0 +1,10 @@
+import optparse
+from logging import Logger
+from typing import Any
+
+logger: Logger
+
+def parse_options(
+ args: list[str] | None = None, values: optparse.Values | None = None
+) -> tuple[dict[str, Any], Any]: ... # first item is opts dict, second item is Values.verbose field
+def run() -> None: ...
diff --git a/python/helpers/typeshed/stubs/Markdown/markdown/core.pyi b/python/helpers/typeshed/stubs/Markdown/markdown/core.pyi
index 48d3bac6dd1c..80eacd4b2a49 100644
--- a/python/helpers/typeshed/stubs/Markdown/markdown/core.pyi
+++ b/python/helpers/typeshed/stubs/Markdown/markdown/core.pyi
@@ -1,5 +1,6 @@
from codecs import _ReadableStream, _WritableStream
from collections.abc import Callable, Mapping, Sequence
+from logging import Logger
from typing import Any, ClassVar, Literal
from typing_extensions import Self
from xml.etree.ElementTree import Element
@@ -8,6 +9,10 @@ from . import blockparser, inlinepatterns, postprocessors, preprocessors, treepr
from .extensions import Extension
from .util import HtmlStash, Registry
+__all__ = ["Markdown", "markdown", "markdownFromFile"]
+
+logger: Logger
+
class Markdown:
preprocessors: Registry[preprocessors.Preprocessor]
inlinePatterns: Registry[inlinepatterns.Pattern]
diff --git a/python/helpers/typeshed/stubs/Markdown/markdown/extensions/abbr.pyi b/python/helpers/typeshed/stubs/Markdown/markdown/extensions/abbr.pyi
index ace06e144ae1..810ab601625f 100644
--- a/python/helpers/typeshed/stubs/Markdown/markdown/extensions/abbr.pyi
+++ b/python/helpers/typeshed/stubs/Markdown/markdown/extensions/abbr.pyi
@@ -19,6 +19,7 @@ class AbbrTreeprocessor(Treeprocessor):
RE: Pattern[str] | None
abbrs: dict[str, str]
def __init__(self, md: Markdown | None = None, abbrs: dict[str, str] | None = None) -> None: ...
+ def create_element(self, title: str, text: str, tail: str) -> Element: ...
def iter_element(self, el: Element, parent: Element | None = None) -> None: ...
# Techinically it is the same type as `AbbrPreprocessor` just not deprecated.
diff --git a/python/helpers/typeshed/stubs/Markdown/markdown/extensions/md_in_html.pyi b/python/helpers/typeshed/stubs/Markdown/markdown/extensions/md_in_html.pyi
index b1ea12305722..29cb8f631c11 100644
--- a/python/helpers/typeshed/stubs/Markdown/markdown/extensions/md_in_html.pyi
+++ b/python/helpers/typeshed/stubs/Markdown/markdown/extensions/md_in_html.pyi
@@ -1,8 +1,34 @@
-from xml.etree.ElementTree import Element
+from collections.abc import Iterable, Mapping
+from typing import Literal
+from xml.etree.ElementTree import Element, TreeBuilder
from markdown.blockprocessors import BlockProcessor
from markdown.extensions import Extension
+from markdown.htmlparser import HTMLExtractor
from markdown.postprocessors import RawHtmlPostprocessor
+from markdown.preprocessors import Preprocessor
+
+class HTMLExtractorExtra(HTMLExtractor):
+ block_level_tags: set[str]
+ span_tags: set[str]
+ raw_tags: set[str]
+ block_tags: set[str]
+ span_and_blocks_tags: set[str]
+ mdstack: list[str]
+ treebuilder: TreeBuilder
+ mdstate: list[Literal["block", "span", "off"] | None]
+ mdstarted: list[bool]
+ def get_element(self) -> Element: ...
+ def get_state(self, tag: str, attrs: Mapping[str, str]) -> Literal["block", "span", "off"] | None: ...
+ def handle_starttag(self, tag: str, attrs: Iterable[tuple[str, str | None]]) -> None: ...
+ def handle_endtag(self, tag: str) -> None: ...
+ def handle_startendtag(self, tag: str, attrs: Iterable[tuple[str, str | None]]) -> None: ...
+ def handle_data(self, data: str) -> None: ...
+ def handle_empty_tag(self, data: str, is_block: bool) -> None: ...
+ def parse_pi(self, i: int) -> int: ...
+ def parse_html_declaration(self, i: int) -> int: ...
+
+class HtmlBlockPreprocessor(Preprocessor): ...
class MarkdownInHtmlProcessor(BlockProcessor):
def parse_element_content(self, element: Element) -> None: ...
diff --git a/python/helpers/typeshed/stubs/Markdown/markdown/extensions/meta.pyi b/python/helpers/typeshed/stubs/Markdown/markdown/extensions/meta.pyi
index b0bead44aece..d6a7f42a807f 100644
--- a/python/helpers/typeshed/stubs/Markdown/markdown/extensions/meta.pyi
+++ b/python/helpers/typeshed/stubs/Markdown/markdown/extensions/meta.pyi
@@ -1,9 +1,11 @@
+from logging import Logger
from re import Pattern
from markdown.core import Markdown
from markdown.extensions import Extension
from markdown.preprocessors import Preprocessor
+log: Logger
META_RE: Pattern[str]
META_MORE_RE: Pattern[str]
BEGIN_RE: Pattern[str]
diff --git a/python/helpers/typeshed/stubs/Markdown/markdown/extensions/smarty.pyi b/python/helpers/typeshed/stubs/Markdown/markdown/extensions/smarty.pyi
index 9a0004630c84..eca70b7b7027 100644
--- a/python/helpers/typeshed/stubs/Markdown/markdown/extensions/smarty.pyi
+++ b/python/helpers/typeshed/stubs/Markdown/markdown/extensions/smarty.pyi
@@ -15,6 +15,8 @@ singleQuoteStartRe: str
doubleQuoteStartRe: str
doubleQuoteSetsRe: str
singleQuoteSetsRe: str
+doubleQuoteSetsRe2: str
+singleQuoteSetsRe2: str
decadeAbbrRe: str
openingDoubleQuotesRegex: str
closingDoubleQuotesRegex: str
diff --git a/python/helpers/typeshed/stubs/Markdown/markdown/extensions/toc.pyi b/python/helpers/typeshed/stubs/Markdown/markdown/extensions/toc.pyi
index 65efb86bfa64..27fd77b833ff 100644
--- a/python/helpers/typeshed/stubs/Markdown/markdown/extensions/toc.pyi
+++ b/python/helpers/typeshed/stubs/Markdown/markdown/extensions/toc.pyi
@@ -1,6 +1,6 @@
from collections.abc import Iterator, MutableSet
from re import Pattern
-from typing import Any, TypedDict
+from typing import Any, TypedDict, type_check_only
from typing_extensions import deprecated
from xml.etree.ElementTree import Element
@@ -10,11 +10,13 @@ from markdown.treeprocessors import Treeprocessor
IDCOUNT_RE: Pattern[str]
+@type_check_only
class _FlatTocToken(TypedDict):
level: int
id: str
name: str
+@type_check_only
class _TocToken(_FlatTocToken):
children: list[_TocToken]
diff --git a/python/helpers/typeshed/stubs/Markdown/markdown/htmlparser.pyi b/python/helpers/typeshed/stubs/Markdown/markdown/htmlparser.pyi
new file mode 100644
index 000000000000..c9319565b921
--- /dev/null
+++ b/python/helpers/typeshed/stubs/Markdown/markdown/htmlparser.pyi
@@ -0,0 +1,28 @@
+import html.parser as htmlparser
+import re
+from _frozen_importlib import ModuleSpec
+from collections.abc import Sequence
+
+from markdown import Markdown
+
+spec: ModuleSpec
+blank_line_re: re.Pattern[str]
+
+class HTMLExtractor(htmlparser.HTMLParser):
+ empty_tags: set[str]
+ lineno_start_cache: list[int]
+ md: Markdown
+ def __init__(self, md: Markdown, *args, **kwargs): ...
+ inraw: bool
+ intail: bool
+ stack: list[str]
+ cleandoc: list[str]
+ @property
+ def line_offset(self) -> int: ...
+ def at_line_start(self) -> bool: ...
+ def get_endtag_text(self, tag: str) -> str: ...
+ def handle_starttag(self, tag: str, attrs: Sequence[tuple[str, str]]) -> None: ... # type: ignore[override]
+ def handle_empty_tag(self, data: str, is_block: bool) -> None: ...
+ def handle_decl(self, data: str) -> None: ...
+ def parse_bogus_comment(self, i: int, report: int = 0) -> int: ...
+ def get_starttag_text(self) -> str: ...
diff --git a/python/helpers/typeshed/stubs/Markdown/markdown/postprocessors.pyi b/python/helpers/typeshed/stubs/Markdown/markdown/postprocessors.pyi
index ad6e2a20d9e1..24cb7d4210e0 100644
--- a/python/helpers/typeshed/stubs/Markdown/markdown/postprocessors.pyi
+++ b/python/helpers/typeshed/stubs/Markdown/markdown/postprocessors.pyi
@@ -1,3 +1,7 @@
+import re
+from typing import ClassVar
+from typing_extensions import deprecated
+
from markdown.core import Markdown
from . import util
@@ -8,7 +12,16 @@ class Postprocessor(util.Processor):
def run(self, text: str) -> str: ...
class RawHtmlPostprocessor(Postprocessor):
+ BLOCK_LEVEL_REGEX: ClassVar[re.Pattern[str]]
def isblocklevel(self, html: str) -> bool: ...
def stash_to_string(self, text: str) -> str: ...
class AndSubstitutePostprocessor(Postprocessor): ...
+
+@deprecated(
+ "This class is deprecated and will be removed in the future; "
+ "use [`UnescapeTreeprocessor`][markdown.treeprocessors.UnescapeTreeprocessor] instead."
+)
+class UnescapePostprocessor(Postprocessor):
+ RE: ClassVar[re.Pattern[str]]
+ def unescape(self, m: re.Match[str]) -> str: ...
diff --git a/python/helpers/typeshed/stubs/Markdown/markdown/serializers.pyi b/python/helpers/typeshed/stubs/Markdown/markdown/serializers.pyi
index b2e0a5ed5bdb..0fbcf66b57a8 100644
--- a/python/helpers/typeshed/stubs/Markdown/markdown/serializers.pyi
+++ b/python/helpers/typeshed/stubs/Markdown/markdown/serializers.pyi
@@ -1,4 +1,9 @@
+import re
from xml.etree.ElementTree import Element
+__all__ = ["to_html_string", "to_xhtml_string"]
+
+RE_AMP: re.Pattern[str]
+
def to_html_string(element: Element) -> str: ...
def to_xhtml_string(element: Element) -> str: ...
diff --git a/python/helpers/typeshed/stubs/Markdown/markdown/test_tools.pyi b/python/helpers/typeshed/stubs/Markdown/markdown/test_tools.pyi
new file mode 100644
index 000000000000..8c9f300d2f92
--- /dev/null
+++ b/python/helpers/typeshed/stubs/Markdown/markdown/test_tools.pyi
@@ -0,0 +1,30 @@
+import unittest
+from _typeshed import Unused
+from typing import Any
+
+__all__ = ["TestCase", "LegacyTestCase", "Kwargs"]
+
+class TestCase(unittest.TestCase):
+ default_kwargs: dict[str, Any] # taken from source code
+ def assertMarkdownRenders(
+ self,
+ source: str,
+ expected: str,
+ expected_attrs: dict[str, Any] | None = None, # values passing to self.assertEqual()
+ **kwargs,
+ ) -> None: ...
+ def dedent(self, text: str) -> str: ...
+
+class recursionlimit:
+ limit: int
+ old_limit: int
+ def __init__(self, limit: int) -> None: ...
+ def __enter__(self) -> None: ...
+ def __exit__(self, type: Unused, value: Unused, tb: Unused) -> None: ...
+
+class Kwargs(dict[str, Any]): ...
+
+class LegacyTestMeta(type):
+ def __new__(cls, name: str, bases: tuple[type, ...], dct: dict[str, Any]): ... # dct is namespace argument for type.__new__()
+
+class LegacyTestCase(unittest.TestCase, metaclass=LegacyTestMeta): ...
diff --git a/python/helpers/typeshed/stubs/Markdown/markdown/util.pyi b/python/helpers/typeshed/stubs/Markdown/markdown/util.pyi
index 672c31a2449c..f30f9e08432c 100644
--- a/python/helpers/typeshed/stubs/Markdown/markdown/util.pyi
+++ b/python/helpers/typeshed/stubs/Markdown/markdown/util.pyi
@@ -1,7 +1,7 @@
import sys
from collections.abc import Iterator
from re import Pattern
-from typing import Final, Generic, TypedDict, TypeVar, overload
+from typing import Final, Generic, TypedDict, TypeVar, overload, type_check_only
from markdown.core import Markdown
@@ -40,6 +40,7 @@ class Processor:
md: Markdown
def __init__(self, md: Markdown | None = None) -> None: ...
+@type_check_only
class _TagData(TypedDict):
tag: str
attrs: dict[str, str]
diff --git a/python/helpers/typeshed/stubs/PyMySQL/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/PyMySQL/@tests/stubtest_allowlist.txt
index 8619761d4d9d..e7a8053fb866 100644
--- a/python/helpers/typeshed/stubs/PyMySQL/@tests/stubtest_allowlist.txt
+++ b/python/helpers/typeshed/stubs/PyMySQL/@tests/stubtest_allowlist.txt
@@ -1,11 +1,3 @@
-pymysql.connections.byte2int
-pymysql.connections.int2byte
-pymysql.connections.pack_int24
-pymysql.cursors.Cursor.__del__
# DictCursorMixin changes method types of inherited classes, but doesn't contain much at runtime
pymysql.cursors.DictCursorMixin.__iter__
pymysql.cursors.DictCursorMixin.fetch[a-z]*
-pymysql.escape_dict
-pymysql.escape_sequence
-pymysql.escape_string
-pymysql.util
diff --git a/python/helpers/typeshed/stubs/PyMySQL/METADATA.toml b/python/helpers/typeshed/stubs/PyMySQL/METADATA.toml
index 8e4adf72f498..5712897f5e72 100644
--- a/python/helpers/typeshed/stubs/PyMySQL/METADATA.toml
+++ b/python/helpers/typeshed/stubs/PyMySQL/METADATA.toml
@@ -1,6 +1,2 @@
version = "1.1.*"
upstream_repository = "https://github.com/PyMySQL/PyMySQL"
-partial_stub = true
-
-[tool.stubtest]
-ignore_missing_stub = true
diff --git a/python/helpers/typeshed/stubs/PyMySQL/pymysql/__init__.pyi b/python/helpers/typeshed/stubs/PyMySQL/pymysql/__init__.pyi
index 7541ce431e4b..5d4a4a3e2465 100644
--- a/python/helpers/typeshed/stubs/PyMySQL/pymysql/__init__.pyi
+++ b/python/helpers/typeshed/stubs/PyMySQL/pymysql/__init__.pyi
@@ -1,8 +1,9 @@
-from typing import Final
+from _typeshed import ReadableBuffer
+from collections.abc import Iterable
+from typing import Final, SupportsBytes, SupportsIndex
-from .connections import Connection as Connection
+from . import connections as connections, constants as constants, converters as converters, cursors as cursors
from .constants import FIELD_TYPE as FIELD_TYPE
-from .converters import escape_dict as escape_dict, escape_sequence as escape_sequence, escape_string as escape_string
from .err import (
DatabaseError as DatabaseError,
DataError as DataError,
@@ -27,14 +28,19 @@ from .times import (
VERSION: Final[tuple[str | int, ...]]
VERSION_STRING: Final[str]
+version_info: tuple[int, int, int, str, int]
+__version__: str
+
+def get_client_info() -> str: ...
+def install_as_MySQLdb() -> None: ...
threadsafety: int
apilevel: str
paramstyle: str
class DBAPISet(frozenset[int]):
- def __ne__(self, other) -> bool: ...
- def __eq__(self, other) -> bool: ...
+ def __ne__(self, other: object) -> bool: ...
+ def __eq__(self, other: object) -> bool: ...
def __hash__(self) -> int: ...
STRING: DBAPISet
@@ -46,16 +52,56 @@ TIMESTAMP: DBAPISet
DATETIME: DBAPISet
ROWID: DBAPISet
-def Binary(x) -> bytes: ...
-def get_client_info() -> str: ...
+def Binary(x: Iterable[SupportsIndex] | SupportsIndex | SupportsBytes | ReadableBuffer) -> bytes: ...
+def thread_safe() -> bool: ...
-__version__: str
-version_info: tuple[int, int, int, str, int]
NULL: str
-# pymysql/__init__.py says "Connect = connect = Connection = connections.Connection"
-Connect = Connection
-connect = Connection
+Connect = connections.Connection
+connect = connections.Connection
+Connection = connections.Connection
-def thread_safe() -> bool: ...
-def install_as_MySQLdb() -> None: ...
+__all__ = [
+ "BINARY",
+ "Binary",
+ "Connect",
+ "Connection",
+ "DATE",
+ "Date",
+ "Time",
+ "Timestamp",
+ "DateFromTicks",
+ "TimeFromTicks",
+ "TimestampFromTicks",
+ "DataError",
+ "DatabaseError",
+ "Error",
+ "FIELD_TYPE",
+ "IntegrityError",
+ "InterfaceError",
+ "InternalError",
+ "MySQLError",
+ "NULL",
+ "NUMBER",
+ "NotSupportedError",
+ "DBAPISet",
+ "OperationalError",
+ "ProgrammingError",
+ "ROWID",
+ "STRING",
+ "TIME",
+ "TIMESTAMP",
+ "Warning",
+ "apilevel",
+ "connect",
+ "connections",
+ "constants",
+ "converters",
+ "cursors",
+ "get_client_info",
+ "paramstyle",
+ "threadsafety",
+ "version_info",
+ "install_as_MySQLdb",
+ "__version__",
+]
diff --git a/python/helpers/typeshed/stubs/PyMySQL/pymysql/connections.pyi b/python/helpers/typeshed/stubs/PyMySQL/pymysql/connections.pyi
index 63acfc6e5c99..eab248848942 100644
--- a/python/helpers/typeshed/stubs/PyMySQL/pymysql/connections.pyi
+++ b/python/helpers/typeshed/stubs/PyMySQL/pymysql/connections.pyi
@@ -1,14 +1,16 @@
-from _typeshed import Incomplete
+from _typeshed import FileDescriptorOrPath, Incomplete
from collections.abc import Mapping
from socket import socket as _socket
from ssl import _PasswordType
-from typing import Any, AnyStr, Generic, TypeVar, overload
-from typing_extensions import Self
+from typing import AnyStr, Generic, TypeVar, overload
+from typing_extensions import Self, deprecated
from .charset import charset_by_id as charset_by_id, charset_by_name as charset_by_name
from .constants import CLIENT as CLIENT, COMMAND as COMMAND, FIELD_TYPE as FIELD_TYPE, SERVER_STATUS as SERVER_STATUS
from .cursors import Cursor
-from .util import byte2int as byte2int, int2byte as int2byte
+
+_C = TypeVar("_C", bound=Cursor)
+_C2 = TypeVar("_C2", bound=Cursor)
SSL_ENABLED: bool
DEFAULT_USER: str | None
@@ -17,68 +19,30 @@ DEFAULT_CHARSET: str
TEXT_TYPES: set[int]
MAX_PACKET_LEN: int
-_C = TypeVar("_C", bound=Cursor)
-_C2 = TypeVar("_C2", bound=Cursor)
-
def dump_packet(data): ...
-def pack_int24(n): ...
def _lenenc_int(i: int) -> bytes: ...
-class MysqlPacket:
- connection: Any
- def __init__(self, data, encoding): ...
- def get_all_data(self): ...
- def read(self, size): ...
- def read_all(self): ...
- def advance(self, length): ...
- def rewind(self, position: int = 0): ...
- def get_bytes(self, position, length: int = 1): ...
- def read_string(self) -> bytes: ...
- def read_uint8(self) -> Any: ...
- def read_uint16(self) -> Any: ...
- def read_uint24(self) -> Any: ...
- def read_uint32(self) -> Any: ...
- def read_uint64(self) -> Any: ...
- def read_length_encoded_integer(self) -> int: ...
- def read_length_coded_string(self) -> bytes: ...
- def read_struct(self, fmt: str) -> tuple[Any, ...]: ...
- def is_ok_packet(self) -> bool: ...
- def is_eof_packet(self) -> bool: ...
- def is_auth_switch_request(self) -> bool: ...
- def is_extra_auth_data(self) -> bool: ...
- def is_resultset_packet(self) -> bool: ...
- def is_load_local_packet(self) -> bool: ...
- def is_error_packet(self) -> bool: ...
- def check_error(self): ...
- def raise_for_error(self) -> None: ...
- def dump(self): ...
-
-class FieldDescriptorPacket(MysqlPacket):
- def __init__(self, data, encoding): ...
- def description(self): ...
- def get_column_length(self): ...
-
class Connection(Generic[_C]):
- ssl: Any
- host: Any
- port: Any
- user: Any
- password: Any
- db: Any
- unix_socket: Any
+ ssl: Incomplete
+ host: Incomplete
+ port: Incomplete
+ user: Incomplete
+ password: Incomplete
+ db: Incomplete
+ unix_socket: Incomplete
charset: str
collation: str | None
- bind_address: Any
- use_unicode: Any
- client_flag: Any
- cursorclass: Any
- connect_timeout: Any
- messages: Any
- encoders: Any
- decoders: Any
- host_info: Any
- sql_mode: Any
- init_command: Any
+ bind_address: Incomplete
+ use_unicode: Incomplete
+ client_flag: Incomplete
+ cursorclass: Incomplete
+ connect_timeout: Incomplete
+ messages: Incomplete
+ encoders: Incomplete
+ decoders: Incomplete
+ host_info: Incomplete
+ sql_mode: Incomplete
+ init_command: Incomplete
max_allowed_packet: int
server_public_key: bytes
@overload
@@ -101,7 +65,7 @@ class Connection(Generic[_C]):
cursorclass: None = None, # different between overloads
init_command=None,
connect_timeout: int | None = 10,
- ssl: Mapping[Any, Any] | None = None,
+ ssl: Mapping[Incomplete, Incomplete] | None = None,
ssl_ca=None,
ssl_cert=None,
ssl_disabled=None,
@@ -118,7 +82,7 @@ class Connection(Generic[_C]):
local_infile: Incomplete | None = False,
max_allowed_packet: int = 16777216,
defer_connect: bool | None = False,
- auth_plugin_map: Mapping[Any, Any] | None = None,
+ auth_plugin_map: Mapping[Incomplete, Incomplete] | None = None,
read_timeout: float | None = None,
write_timeout: float | None = None,
bind_address=None,
@@ -147,7 +111,7 @@ class Connection(Generic[_C]):
cursorclass: type[_C] = ..., # different between overloads
init_command=None,
connect_timeout: int | None = 10,
- ssl: Mapping[Any, Any] | None = None,
+ ssl: Mapping[Incomplete, Incomplete] | None = None,
ssl_ca=None,
ssl_cert=None,
ssl_disabled=None,
@@ -163,7 +127,7 @@ class Connection(Generic[_C]):
local_infile: Incomplete | None = False,
max_allowed_packet: int = 16777216,
defer_connect: bool | None = False,
- auth_plugin_map: Mapping[Any, Any] | None = None,
+ auth_plugin_map: Mapping[Incomplete, Incomplete] | None = None,
read_timeout: float | None = None,
write_timeout: float | None = None,
bind_address=None,
@@ -171,19 +135,20 @@ class Connection(Generic[_C]):
program_name=None,
server_public_key: bytes | None = None,
) -> None: ...
- socket: Any
- rfile: Any
- wfile: Any
+ socket: Incomplete
+ rfile: Incomplete
+ wfile: Incomplete
def close(self) -> None: ...
@property
def open(self) -> bool: ...
+ def __del__(self) -> None: ...
def autocommit(self, value) -> None: ...
def get_autocommit(self) -> bool: ...
def commit(self) -> None: ...
def begin(self) -> None: ...
def rollback(self) -> None: ...
def select_db(self, db) -> None: ...
- def escape(self, obj, mapping: Mapping[Any, Any] | None = None): ...
+ def escape(self, obj, mapping: Mapping[Incomplete, Incomplete] | None = None): ...
def literal(self, obj): ...
def escape_string(self, s: AnyStr) -> AnyStr: ...
@overload
@@ -195,7 +160,9 @@ class Connection(Generic[_C]):
def affected_rows(self): ...
def kill(self, thread_id): ...
def ping(self, reconnect: bool = True) -> None: ...
- def set_charset(self, charset) -> None: ...
+ @deprecated("Method is deprecated. Use set_character_set() instead.")
+ def set_charset(self, charset: str) -> None: ...
+ def set_character_set(self, charset: str, collation: str | None = None) -> None: ...
def connect(self, sock: _socket | None = None) -> None: ...
def write_packet(self, payload) -> None: ...
def _read_packet(self, packet_type=...): ...
@@ -208,35 +175,36 @@ class Connection(Generic[_C]):
def show_warnings(self): ...
def __enter__(self) -> Self: ...
def __exit__(self, *exc_info: object) -> None: ...
- Warning: Any
- Error: Any
- InterfaceError: Any
- DatabaseError: Any
- DataError: Any
- OperationalError: Any
- IntegrityError: Any
- InternalError: Any
- ProgrammingError: Any
- NotSupportedError: Any
+ Warning: Incomplete
+ Error: Incomplete
+ InterfaceError: Incomplete
+ DatabaseError: Incomplete
+ DataError: Incomplete
+ OperationalError: Incomplete
+ IntegrityError: Incomplete
+ InternalError: Incomplete
+ ProgrammingError: Incomplete
+ NotSupportedError: Incomplete
class MySQLResult:
- connection: Any
- affected_rows: Any
- insert_id: Any
- server_status: Any
- warning_count: Any
- message: Any
- field_count: Any
- description: Any
- rows: Any
- has_next: Any
- def __init__(self, connection: Connection[Any]) -> None: ...
- first_packet: Any
+ connection: Incomplete
+ affected_rows: Incomplete
+ insert_id: Incomplete
+ server_status: Incomplete
+ warning_count: Incomplete
+ message: Incomplete
+ field_count: Incomplete
+ description: Incomplete
+ rows: Incomplete
+ has_next: Incomplete
+ def __init__(self, connection: Connection[Incomplete]) -> None: ...
+ def __del__(self) -> None: ...
+ first_packet: Incomplete
def read(self) -> None: ...
def init_unbuffered_query(self) -> None: ...
class LoadLocalFile:
- filename: Any
- connection: Connection[Any]
- def __init__(self, filename: Any, connection: Connection[Any]) -> None: ...
+ filename: FileDescriptorOrPath
+ connection: Connection[Incomplete]
+ def __init__(self, filename: FileDescriptorOrPath, connection: Connection[Incomplete]) -> None: ...
def send_data(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/CLIENT.pyi b/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/CLIENT.pyi
index 21019e028a93..4a1f58c48273 100644
--- a/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/CLIENT.pyi
+++ b/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/CLIENT.pyi
@@ -1,25 +1,27 @@
-LONG_PASSWORD: int
-FOUND_ROWS: int
-LONG_FLAG: int
-CONNECT_WITH_DB: int
-NO_SCHEMA: int
-COMPRESS: int
-ODBC: int
-LOCAL_FILES: int
-IGNORE_SPACE: int
-PROTOCOL_41: int
-INTERACTIVE: int
-SSL: int
-IGNORE_SIGPIPE: int
-TRANSACTIONS: int
-SECURE_CONNECTION: int
-MULTI_STATEMENTS: int
-MULTI_RESULTS: int
-PS_MULTI_RESULTS: int
-PLUGIN_AUTH: int
-CONNECT_ATTRS: int
-PLUGIN_AUTH_LENENC_CLIENT_DATA: int
-CAPABILITIES: int
-HANDLE_EXPIRED_PASSWORDS: int
-SESSION_TRACK: int
-DEPRECATE_EOF: int
+from typing import Final
+
+LONG_PASSWORD: Final[int]
+FOUND_ROWS: Final[int]
+LONG_FLAG: Final[int]
+CONNECT_WITH_DB: Final[int]
+NO_SCHEMA: Final[int]
+COMPRESS: Final[int]
+ODBC: Final[int]
+LOCAL_FILES: Final[int]
+IGNORE_SPACE: Final[int]
+PROTOCOL_41: Final[int]
+INTERACTIVE: Final[int]
+SSL: Final[int]
+IGNORE_SIGPIPE: Final[int]
+TRANSACTIONS: Final[int]
+SECURE_CONNECTION: Final[int]
+MULTI_STATEMENTS: Final[int]
+MULTI_RESULTS: Final[int]
+PS_MULTI_RESULTS: Final[int]
+PLUGIN_AUTH: Final[int]
+CONNECT_ATTRS: Final[int]
+PLUGIN_AUTH_LENENC_CLIENT_DATA: Final[int]
+CAPABILITIES: Final[int]
+HANDLE_EXPIRED_PASSWORDS: Final[int]
+SESSION_TRACK: Final[int]
+DEPRECATE_EOF: Final[int]
diff --git a/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/COMMAND.pyi b/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/COMMAND.pyi
index fe74c540b1f7..bc3f24fb81f3 100644
--- a/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/COMMAND.pyi
+++ b/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/COMMAND.pyi
@@ -1,32 +1,34 @@
-COM_SLEEP: int
-COM_QUIT: int
-COM_INIT_DB: int
-COM_QUERY: int
-COM_FIELD_LIST: int
-COM_CREATE_DB: int
-COM_DROP_DB: int
-COM_REFRESH: int
-COM_SHUTDOWN: int
-COM_STATISTICS: int
-COM_PROCESS_INFO: int
-COM_CONNECT: int
-COM_PROCESS_KILL: int
-COM_DEBUG: int
-COM_PING: int
-COM_TIME: int
-COM_DELAYED_INSERT: int
-COM_CHANGE_USER: int
-COM_BINLOG_DUMP: int
-COM_TABLE_DUMP: int
-COM_CONNECT_OUT: int
-COM_REGISTER_SLAVE: int
-COM_STMT_PREPARE: int
-COM_STMT_EXECUTE: int
-COM_STMT_SEND_LONG_DATA: int
-COM_STMT_CLOSE: int
-COM_STMT_RESET: int
-COM_SET_OPTION: int
-COM_STMT_FETCH: int
-COM_DAEMON: int
-COM_BINLOG_DUMP_GTID: int
-COM_END: int
+from typing import Final
+
+COM_SLEEP: Final[int]
+COM_QUIT: Final[int]
+COM_INIT_DB: Final[int]
+COM_QUERY: Final[int]
+COM_FIELD_LIST: Final[int]
+COM_CREATE_DB: Final[int]
+COM_DROP_DB: Final[int]
+COM_REFRESH: Final[int]
+COM_SHUTDOWN: Final[int]
+COM_STATISTICS: Final[int]
+COM_PROCESS_INFO: Final[int]
+COM_CONNECT: Final[int]
+COM_PROCESS_KILL: Final[int]
+COM_DEBUG: Final[int]
+COM_PING: Final[int]
+COM_TIME: Final[int]
+COM_DELAYED_INSERT: Final[int]
+COM_CHANGE_USER: Final[int]
+COM_BINLOG_DUMP: Final[int]
+COM_TABLE_DUMP: Final[int]
+COM_CONNECT_OUT: Final[int]
+COM_REGISTER_SLAVE: Final[int]
+COM_STMT_PREPARE: Final[int]
+COM_STMT_EXECUTE: Final[int]
+COM_STMT_SEND_LONG_DATA: Final[int]
+COM_STMT_CLOSE: Final[int]
+COM_STMT_RESET: Final[int]
+COM_SET_OPTION: Final[int]
+COM_STMT_FETCH: Final[int]
+COM_DAEMON: Final[int]
+COM_BINLOG_DUMP_GTID: Final[int]
+COM_END: Final[int]
diff --git a/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/CR.pyi b/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/CR.pyi
index 010373963ba2..5b6447f64390 100644
--- a/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/CR.pyi
+++ b/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/CR.pyi
@@ -1,64 +1,77 @@
-CR_ERROR_FIRST: int
-CR_UNKNOWN_ERROR: int
-CR_SOCKET_CREATE_ERROR: int
-CR_CONNECTION_ERROR: int
-CR_CONN_HOST_ERROR: int
-CR_IPSOCK_ERROR: int
-CR_UNKNOWN_HOST: int
-CR_SERVER_GONE_ERROR: int
-CR_VERSION_ERROR: int
-CR_OUT_OF_MEMORY: int
-CR_WRONG_HOST_INFO: int
-CR_LOCALHOST_CONNECTION: int
-CR_TCP_CONNECTION: int
-CR_SERVER_HANDSHAKE_ERR: int
-CR_SERVER_LOST: int
-CR_COMMANDS_OUT_OF_SYNC: int
-CR_NAMEDPIPE_CONNECTION: int
-CR_NAMEDPIPEWAIT_ERROR: int
-CR_NAMEDPIPEOPEN_ERROR: int
-CR_NAMEDPIPESETSTATE_ERROR: int
-CR_CANT_READ_CHARSET: int
-CR_NET_PACKET_TOO_LARGE: int
-CR_EMBEDDED_CONNECTION: int
-CR_PROBE_SLAVE_STATUS: int
-CR_PROBE_SLAVE_HOSTS: int
-CR_PROBE_SLAVE_CONNECT: int
-CR_PROBE_MASTER_CONNECT: int
-CR_SSL_CONNECTION_ERROR: int
-CR_MALFORMED_PACKET: int
-CR_WRONG_LICENSE: int
-CR_NULL_POINTER: int
-CR_NO_PREPARE_STMT: int
-CR_PARAMS_NOT_BOUND: int
-CR_DATA_TRUNCATED: int
-CR_NO_PARAMETERS_EXISTS: int
-CR_INVALID_PARAMETER_NO: int
-CR_INVALID_BUFFER_USE: int
-CR_UNSUPPORTED_PARAM_TYPE: int
-CR_SHARED_MEMORY_CONNECTION: int
-CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR: int
-CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR: int
-CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR: int
-CR_SHARED_MEMORY_CONNECT_MAP_ERROR: int
-CR_SHARED_MEMORY_FILE_MAP_ERROR: int
-CR_SHARED_MEMORY_MAP_ERROR: int
-CR_SHARED_MEMORY_EVENT_ERROR: int
-CR_SHARED_MEMORY_CONNECT_ABANDONED_ERROR: int
-CR_SHARED_MEMORY_CONNECT_SET_ERROR: int
-CR_CONN_UNKNOW_PROTOCOL: int
-CR_INVALID_CONN_HANDLE: int
-CR_SECURE_AUTH: int
-CR_FETCH_CANCELED: int
-CR_NO_DATA: int
-CR_NO_STMT_METADATA: int
-CR_NO_RESULT_SET: int
-CR_NOT_IMPLEMENTED: int
-CR_SERVER_LOST_EXTENDED: int
-CR_STMT_CLOSED: int
-CR_NEW_STMT_METADATA: int
-CR_ALREADY_CONNECTED: int
-CR_AUTH_PLUGIN_CANNOT_LOAD: int
-CR_DUPLICATE_CONNECTION_ATTR: int
-CR_AUTH_PLUGIN_ERR: int
-CR_ERROR_LAST: int
+from typing import Final
+
+CR_ERROR_FIRST: Final = 2000
+CR_UNKNOWN_ERROR: Final = 2000
+CR_SOCKET_CREATE_ERROR: Final = 2001
+CR_CONNECTION_ERROR: Final = 2002
+CR_CONN_HOST_ERROR: Final = 2003
+CR_IPSOCK_ERROR: Final = 2004
+CR_UNKNOWN_HOST: Final = 2005
+CR_SERVER_GONE_ERROR: Final = 2006
+CR_VERSION_ERROR: Final = 2007
+CR_OUT_OF_MEMORY: Final = 2008
+CR_WRONG_HOST_INFO: Final = 2009
+CR_LOCALHOST_CONNECTION: Final = 2010
+CR_TCP_CONNECTION: Final = 2011
+CR_SERVER_HANDSHAKE_ERR: Final = 2012
+CR_SERVER_LOST: Final = 2013
+CR_COMMANDS_OUT_OF_SYNC: Final = 2014
+CR_NAMEDPIPE_CONNECTION: Final = 2015
+CR_NAMEDPIPEWAIT_ERROR: Final = 2016
+CR_NAMEDPIPEOPEN_ERROR: Final = 2017
+CR_NAMEDPIPESETSTATE_ERROR: Final = 2018
+CR_CANT_READ_CHARSET: Final = 2019
+CR_NET_PACKET_TOO_LARGE: Final = 2020
+CR_EMBEDDED_CONNECTION: Final = 2021
+CR_PROBE_SLAVE_STATUS: Final = 2022
+CR_PROBE_SLAVE_HOSTS: Final = 2023
+CR_PROBE_SLAVE_CONNECT: Final = 2024
+CR_PROBE_MASTER_CONNECT: Final = 2025
+CR_SSL_CONNECTION_ERROR: Final = 2026
+CR_MALFORMED_PACKET: Final = 2027
+CR_WRONG_LICENSE: Final = 2028
+CR_NULL_POINTER: Final = 2029
+CR_NO_PREPARE_STMT: Final = 2030
+CR_PARAMS_NOT_BOUND: Final = 2031
+CR_DATA_TRUNCATED: Final = 2032
+CR_NO_PARAMETERS_EXISTS: Final = 2033
+CR_INVALID_PARAMETER_NO: Final = 2034
+CR_INVALID_BUFFER_USE: Final = 2035
+CR_UNSUPPORTED_PARAM_TYPE: Final = 2036
+CR_SHARED_MEMORY_CONNECTION: Final = 2037
+CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR: Final = 2038
+CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR: Final = 2039
+CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR: Final = 2040
+CR_SHARED_MEMORY_CONNECT_MAP_ERROR: Final = 2041
+CR_SHARED_MEMORY_FILE_MAP_ERROR: Final = 2042
+CR_SHARED_MEMORY_MAP_ERROR: Final = 2043
+CR_SHARED_MEMORY_EVENT_ERROR: Final = 2044
+CR_SHARED_MEMORY_CONNECT_ABANDONED_ERROR: Final = 2045
+CR_SHARED_MEMORY_CONNECT_SET_ERROR: Final = 2046
+CR_CONN_UNKNOW_PROTOCOL: Final = 2047
+CR_INVALID_CONN_HANDLE: Final = 2048
+CR_SECURE_AUTH: Final = 2049
+CR_FETCH_CANCELED: Final = 2050
+CR_NO_DATA: Final = 2051
+CR_NO_STMT_METADATA: Final = 2052
+CR_NO_RESULT_SET: Final = 2053
+CR_NOT_IMPLEMENTED: Final = 2054
+CR_SERVER_LOST_EXTENDED: Final = 2055
+CR_STMT_CLOSED: Final = 2056
+CR_NEW_STMT_METADATA: Final = 2057
+CR_ALREADY_CONNECTED: Final = 2058
+CR_AUTH_PLUGIN_CANNOT_LOAD: Final = 2059
+CR_DUPLICATE_CONNECTION_ATTR: Final = 2060
+CR_AUTH_PLUGIN_ERR: Final = 2061
+CR_INSECURE_API_ERR: Final = 2062
+CR_FILE_NAME_TOO_LONG: Final = 2063
+CR_SSL_FIPS_MODE_ERR: Final = 2064
+CR_DEPRECATED_COMPRESSION_NOT_SUPPORTED: Final = 2065
+CR_COMPRESSION_WRONGLY_CONFIGURED: Final = 2066
+CR_KERBEROS_USER_NOT_FOUND: Final = 2067
+CR_LOAD_DATA_LOCAL_INFILE_REJECTED: Final = 2068
+CR_LOAD_DATA_LOCAL_INFILE_REALPATH_FAIL: Final = 2069
+CR_DNS_SRV_LOOKUP_FAILED: Final = 2070
+CR_MANDATORY_TRACKER_NOT_FOUND: Final = 2071
+CR_INVALID_FACTOR_NO: Final = 2072
+CR_ERROR_LAST: Final = 2072
diff --git a/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/ER.pyi b/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/ER.pyi
index 0f4c17f04600..8bd5e9b79e14 100644
--- a/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/ER.pyi
+++ b/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/ER.pyi
@@ -1,472 +1,476 @@
-ERROR_FIRST: int
-HASHCHK: int
-NISAMCHK: int
-NO: int
-YES: int
-CANT_CREATE_FILE: int
-CANT_CREATE_TABLE: int
-CANT_CREATE_DB: int
-DB_CREATE_EXISTS: int
-DB_DROP_EXISTS: int
-DB_DROP_DELETE: int
-DB_DROP_RMDIR: int
-CANT_DELETE_FILE: int
-CANT_FIND_SYSTEM_REC: int
-CANT_GET_STAT: int
-CANT_GET_WD: int
-CANT_LOCK: int
-CANT_OPEN_FILE: int
-FILE_NOT_FOUND: int
-CANT_READ_DIR: int
-CANT_SET_WD: int
-CHECKREAD: int
-DISK_FULL: int
-DUP_KEY: int
-ERROR_ON_CLOSE: int
-ERROR_ON_READ: int
-ERROR_ON_RENAME: int
-ERROR_ON_WRITE: int
-FILE_USED: int
-FILSORT_ABORT: int
-FORM_NOT_FOUND: int
-GET_ERRNO: int
-ILLEGAL_HA: int
-KEY_NOT_FOUND: int
-NOT_FORM_FILE: int
-NOT_KEYFILE: int
-OLD_KEYFILE: int
-OPEN_AS_READONLY: int
-OUTOFMEMORY: int
-OUT_OF_SORTMEMORY: int
-UNEXPECTED_EOF: int
-CON_COUNT_ERROR: int
-OUT_OF_RESOURCES: int
-BAD_HOST_ERROR: int
-HANDSHAKE_ERROR: int
-DBACCESS_DENIED_ERROR: int
-ACCESS_DENIED_ERROR: int
-NO_DB_ERROR: int
-UNKNOWN_COM_ERROR: int
-BAD_NULL_ERROR: int
-BAD_DB_ERROR: int
-TABLE_EXISTS_ERROR: int
-BAD_TABLE_ERROR: int
-NON_UNIQ_ERROR: int
-SERVER_SHUTDOWN: int
-BAD_FIELD_ERROR: int
-WRONG_FIELD_WITH_GROUP: int
-WRONG_GROUP_FIELD: int
-WRONG_SUM_SELECT: int
-WRONG_VALUE_COUNT: int
-TOO_LONG_IDENT: int
-DUP_FIELDNAME: int
-DUP_KEYNAME: int
-DUP_ENTRY: int
-WRONG_FIELD_SPEC: int
-PARSE_ERROR: int
-EMPTY_QUERY: int
-NONUNIQ_TABLE: int
-INVALID_DEFAULT: int
-MULTIPLE_PRI_KEY: int
-TOO_MANY_KEYS: int
-TOO_MANY_KEY_PARTS: int
-TOO_LONG_KEY: int
-KEY_COLUMN_DOES_NOT_EXITS: int
-BLOB_USED_AS_KEY: int
-TOO_BIG_FIELDLENGTH: int
-WRONG_AUTO_KEY: int
-READY: int
-NORMAL_SHUTDOWN: int
-GOT_SIGNAL: int
-SHUTDOWN_COMPLETE: int
-FORCING_CLOSE: int
-IPSOCK_ERROR: int
-NO_SUCH_INDEX: int
-WRONG_FIELD_TERMINATORS: int
-BLOBS_AND_NO_TERMINATED: int
-TEXTFILE_NOT_READABLE: int
-FILE_EXISTS_ERROR: int
-LOAD_INFO: int
-ALTER_INFO: int
-WRONG_SUB_KEY: int
-CANT_REMOVE_ALL_FIELDS: int
-CANT_DROP_FIELD_OR_KEY: int
-INSERT_INFO: int
-UPDATE_TABLE_USED: int
-NO_SUCH_THREAD: int
-KILL_DENIED_ERROR: int
-NO_TABLES_USED: int
-TOO_BIG_SET: int
-NO_UNIQUE_LOGFILE: int
-TABLE_NOT_LOCKED_FOR_WRITE: int
-TABLE_NOT_LOCKED: int
-BLOB_CANT_HAVE_DEFAULT: int
-WRONG_DB_NAME: int
-WRONG_TABLE_NAME: int
-TOO_BIG_SELECT: int
-UNKNOWN_ERROR: int
-UNKNOWN_PROCEDURE: int
-WRONG_PARAMCOUNT_TO_PROCEDURE: int
-WRONG_PARAMETERS_TO_PROCEDURE: int
-UNKNOWN_TABLE: int
-FIELD_SPECIFIED_TWICE: int
-INVALID_GROUP_FUNC_USE: int
-UNSUPPORTED_EXTENSION: int
-TABLE_MUST_HAVE_COLUMNS: int
-RECORD_FILE_FULL: int
-UNKNOWN_CHARACTER_SET: int
-TOO_MANY_TABLES: int
-TOO_MANY_FIELDS: int
-TOO_BIG_ROWSIZE: int
-STACK_OVERRUN: int
-WRONG_OUTER_JOIN: int
-NULL_COLUMN_IN_INDEX: int
-CANT_FIND_UDF: int
-CANT_INITIALIZE_UDF: int
-UDF_NO_PATHS: int
-UDF_EXISTS: int
-CANT_OPEN_LIBRARY: int
-CANT_FIND_DL_ENTRY: int
-FUNCTION_NOT_DEFINED: int
-HOST_IS_BLOCKED: int
-HOST_NOT_PRIVILEGED: int
-PASSWORD_ANONYMOUS_USER: int
-PASSWORD_NOT_ALLOWED: int
-PASSWORD_NO_MATCH: int
-UPDATE_INFO: int
-CANT_CREATE_THREAD: int
-WRONG_VALUE_COUNT_ON_ROW: int
-CANT_REOPEN_TABLE: int
-INVALID_USE_OF_NULL: int
-REGEXP_ERROR: int
-MIX_OF_GROUP_FUNC_AND_FIELDS: int
-NONEXISTING_GRANT: int
-TABLEACCESS_DENIED_ERROR: int
-COLUMNACCESS_DENIED_ERROR: int
-ILLEGAL_GRANT_FOR_TABLE: int
-GRANT_WRONG_HOST_OR_USER: int
-NO_SUCH_TABLE: int
-NONEXISTING_TABLE_GRANT: int
-NOT_ALLOWED_COMMAND: int
-SYNTAX_ERROR: int
-DELAYED_CANT_CHANGE_LOCK: int
-TOO_MANY_DELAYED_THREADS: int
-ABORTING_CONNECTION: int
-NET_PACKET_TOO_LARGE: int
-NET_READ_ERROR_FROM_PIPE: int
-NET_FCNTL_ERROR: int
-NET_PACKETS_OUT_OF_ORDER: int
-NET_UNCOMPRESS_ERROR: int
-NET_READ_ERROR: int
-NET_READ_INTERRUPTED: int
-NET_ERROR_ON_WRITE: int
-NET_WRITE_INTERRUPTED: int
-TOO_LONG_STRING: int
-TABLE_CANT_HANDLE_BLOB: int
-TABLE_CANT_HANDLE_AUTO_INCREMENT: int
-DELAYED_INSERT_TABLE_LOCKED: int
-WRONG_COLUMN_NAME: int
-WRONG_KEY_COLUMN: int
-WRONG_MRG_TABLE: int
-DUP_UNIQUE: int
-BLOB_KEY_WITHOUT_LENGTH: int
-PRIMARY_CANT_HAVE_NULL: int
-TOO_MANY_ROWS: int
-REQUIRES_PRIMARY_KEY: int
-NO_RAID_COMPILED: int
-UPDATE_WITHOUT_KEY_IN_SAFE_MODE: int
-KEY_DOES_NOT_EXITS: int
-CHECK_NO_SUCH_TABLE: int
-CHECK_NOT_IMPLEMENTED: int
-CANT_DO_THIS_DURING_AN_TRANSACTION: int
-ERROR_DURING_COMMIT: int
-ERROR_DURING_ROLLBACK: int
-ERROR_DURING_FLUSH_LOGS: int
-ERROR_DURING_CHECKPOINT: int
-NEW_ABORTING_CONNECTION: int
-DUMP_NOT_IMPLEMENTED: int
-FLUSH_MASTER_BINLOG_CLOSED: int
-INDEX_REBUILD: int
-MASTER: int
-MASTER_NET_READ: int
-MASTER_NET_WRITE: int
-FT_MATCHING_KEY_NOT_FOUND: int
-LOCK_OR_ACTIVE_TRANSACTION: int
-UNKNOWN_SYSTEM_VARIABLE: int
-CRASHED_ON_USAGE: int
-CRASHED_ON_REPAIR: int
-WARNING_NOT_COMPLETE_ROLLBACK: int
-TRANS_CACHE_FULL: int
-SLAVE_MUST_STOP: int
-SLAVE_NOT_RUNNING: int
-BAD_SLAVE: int
-MASTER_INFO: int
-SLAVE_THREAD: int
-TOO_MANY_USER_CONNECTIONS: int
-SET_CONSTANTS_ONLY: int
-LOCK_WAIT_TIMEOUT: int
-LOCK_TABLE_FULL: int
-READ_ONLY_TRANSACTION: int
-DROP_DB_WITH_READ_LOCK: int
-CREATE_DB_WITH_READ_LOCK: int
-WRONG_ARGUMENTS: int
-NO_PERMISSION_TO_CREATE_USER: int
-UNION_TABLES_IN_DIFFERENT_DIR: int
-LOCK_DEADLOCK: int
-TABLE_CANT_HANDLE_FT: int
-CANNOT_ADD_FOREIGN: int
-NO_REFERENCED_ROW: int
-ROW_IS_REFERENCED: int
-CONNECT_TO_MASTER: int
-QUERY_ON_MASTER: int
-ERROR_WHEN_EXECUTING_COMMAND: int
-WRONG_USAGE: int
-WRONG_NUMBER_OF_COLUMNS_IN_SELECT: int
-CANT_UPDATE_WITH_READLOCK: int
-MIXING_NOT_ALLOWED: int
-DUP_ARGUMENT: int
-USER_LIMIT_REACHED: int
-SPECIFIC_ACCESS_DENIED_ERROR: int
-LOCAL_VARIABLE: int
-GLOBAL_VARIABLE: int
-NO_DEFAULT: int
-WRONG_VALUE_FOR_VAR: int
-WRONG_TYPE_FOR_VAR: int
-VAR_CANT_BE_READ: int
-CANT_USE_OPTION_HERE: int
-NOT_SUPPORTED_YET: int
-MASTER_FATAL_ERROR_READING_BINLOG: int
-SLAVE_IGNORED_TABLE: int
-INCORRECT_GLOBAL_LOCAL_VAR: int
-WRONG_FK_DEF: int
-KEY_REF_DO_NOT_MATCH_TABLE_REF: int
-OPERAND_COLUMNS: int
-SUBQUERY_NO_1_ROW: int
-UNKNOWN_STMT_HANDLER: int
-CORRUPT_HELP_DB: int
-CYCLIC_REFERENCE: int
-AUTO_CONVERT: int
-ILLEGAL_REFERENCE: int
-DERIVED_MUST_HAVE_ALIAS: int
-SELECT_REDUCED: int
-TABLENAME_NOT_ALLOWED_HERE: int
-NOT_SUPPORTED_AUTH_MODE: int
-SPATIAL_CANT_HAVE_NULL: int
-COLLATION_CHARSET_MISMATCH: int
-SLAVE_WAS_RUNNING: int
-SLAVE_WAS_NOT_RUNNING: int
-TOO_BIG_FOR_UNCOMPRESS: int
-ZLIB_Z_MEM_ERROR: int
-ZLIB_Z_BUF_ERROR: int
-ZLIB_Z_DATA_ERROR: int
-CUT_VALUE_GROUP_CONCAT: int
-WARN_TOO_FEW_RECORDS: int
-WARN_TOO_MANY_RECORDS: int
-WARN_NULL_TO_NOTNULL: int
-WARN_DATA_OUT_OF_RANGE: int
-WARN_DATA_TRUNCATED: int
-WARN_USING_OTHER_HANDLER: int
-CANT_AGGREGATE_2COLLATIONS: int
-DROP_USER: int
-REVOKE_GRANTS: int
-CANT_AGGREGATE_3COLLATIONS: int
-CANT_AGGREGATE_NCOLLATIONS: int
-VARIABLE_IS_NOT_STRUCT: int
-UNKNOWN_COLLATION: int
-SLAVE_IGNORED_SSL_PARAMS: int
-SERVER_IS_IN_SECURE_AUTH_MODE: int
-WARN_FIELD_RESOLVED: int
-BAD_SLAVE_UNTIL_COND: int
-MISSING_SKIP_SLAVE: int
-UNTIL_COND_IGNORED: int
-WRONG_NAME_FOR_INDEX: int
-WRONG_NAME_FOR_CATALOG: int
-WARN_QC_RESIZE: int
-BAD_FT_COLUMN: int
-UNKNOWN_KEY_CACHE: int
-WARN_HOSTNAME_WONT_WORK: int
-UNKNOWN_STORAGE_ENGINE: int
-WARN_DEPRECATED_SYNTAX: int
-NON_UPDATABLE_TABLE: int
-FEATURE_DISABLED: int
-OPTION_PREVENTS_STATEMENT: int
-DUPLICATED_VALUE_IN_TYPE: int
-TRUNCATED_WRONG_VALUE: int
-TOO_MUCH_AUTO_TIMESTAMP_COLS: int
-INVALID_ON_UPDATE: int
-UNSUPPORTED_PS: int
-GET_ERRMSG: int
-GET_TEMPORARY_ERRMSG: int
-UNKNOWN_TIME_ZONE: int
-WARN_INVALID_TIMESTAMP: int
-INVALID_CHARACTER_STRING: int
-WARN_ALLOWED_PACKET_OVERFLOWED: int
-CONFLICTING_DECLARATIONS: int
-SP_NO_RECURSIVE_CREATE: int
-SP_ALREADY_EXISTS: int
-SP_DOES_NOT_EXIST: int
-SP_DROP_FAILED: int
-SP_STORE_FAILED: int
-SP_LILABEL_MISMATCH: int
-SP_LABEL_REDEFINE: int
-SP_LABEL_MISMATCH: int
-SP_UNINIT_VAR: int
-SP_BADSELECT: int
-SP_BADRETURN: int
-SP_BADSTATEMENT: int
-UPDATE_LOG_DEPRECATED_IGNORED: int
-UPDATE_LOG_DEPRECATED_TRANSLATED: int
-QUERY_INTERRUPTED: int
-SP_WRONG_NO_OF_ARGS: int
-SP_COND_MISMATCH: int
-SP_NORETURN: int
-SP_NORETURNEND: int
-SP_BAD_CURSOR_QUERY: int
-SP_BAD_CURSOR_SELECT: int
-SP_CURSOR_MISMATCH: int
-SP_CURSOR_ALREADY_OPEN: int
-SP_CURSOR_NOT_OPEN: int
-SP_UNDECLARED_VAR: int
-SP_WRONG_NO_OF_FETCH_ARGS: int
-SP_FETCH_NO_DATA: int
-SP_DUP_PARAM: int
-SP_DUP_VAR: int
-SP_DUP_COND: int
-SP_DUP_CURS: int
-SP_CANT_ALTER: int
-SP_SUBSELECT_NYI: int
-STMT_NOT_ALLOWED_IN_SF_OR_TRG: int
-SP_VARCOND_AFTER_CURSHNDLR: int
-SP_CURSOR_AFTER_HANDLER: int
-SP_CASE_NOT_FOUND: int
-FPARSER_TOO_BIG_FILE: int
-FPARSER_BAD_HEADER: int
-FPARSER_EOF_IN_COMMENT: int
-FPARSER_ERROR_IN_PARAMETER: int
-FPARSER_EOF_IN_UNKNOWN_PARAMETER: int
-VIEW_NO_EXPLAIN: int
-FRM_UNKNOWN_TYPE: int
-WRONG_OBJECT: int
-NONUPDATEABLE_COLUMN: int
-VIEW_SELECT_DERIVED: int
-VIEW_SELECT_CLAUSE: int
-VIEW_SELECT_VARIABLE: int
-VIEW_SELECT_TMPTABLE: int
-VIEW_WRONG_LIST: int
-WARN_VIEW_MERGE: int
-WARN_VIEW_WITHOUT_KEY: int
-VIEW_INVALID: int
-SP_NO_DROP_SP: int
-SP_GOTO_IN_HNDLR: int
-TRG_ALREADY_EXISTS: int
-TRG_DOES_NOT_EXIST: int
-TRG_ON_VIEW_OR_TEMP_TABLE: int
-TRG_CANT_CHANGE_ROW: int
-TRG_NO_SUCH_ROW_IN_TRG: int
-NO_DEFAULT_FOR_FIELD: int
-DIVISION_BY_ZERO: int
-TRUNCATED_WRONG_VALUE_FOR_FIELD: int
-ILLEGAL_VALUE_FOR_TYPE: int
-VIEW_NONUPD_CHECK: int
-VIEW_CHECK_FAILED: int
-PROCACCESS_DENIED_ERROR: int
-RELAY_LOG_FAIL: int
-PASSWD_LENGTH: int
-UNKNOWN_TARGET_BINLOG: int
-IO_ERR_LOG_INDEX_READ: int
-BINLOG_PURGE_PROHIBITED: int
-FSEEK_FAIL: int
-BINLOG_PURGE_FATAL_ERR: int
-LOG_IN_USE: int
-LOG_PURGE_UNKNOWN_ERR: int
-RELAY_LOG_INIT: int
-NO_BINARY_LOGGING: int
-RESERVED_SYNTAX: int
-WSAS_FAILED: int
-DIFF_GROUPS_PROC: int
-NO_GROUP_FOR_PROC: int
-ORDER_WITH_PROC: int
-LOGGING_PROHIBIT_CHANGING_OF: int
-NO_FILE_MAPPING: int
-WRONG_MAGIC: int
-PS_MANY_PARAM: int
-KEY_PART_0: int
-VIEW_CHECKSUM: int
-VIEW_MULTIUPDATE: int
-VIEW_NO_INSERT_FIELD_LIST: int
-VIEW_DELETE_MERGE_VIEW: int
-CANNOT_USER: int
-XAER_NOTA: int
-XAER_INVAL: int
-XAER_RMFAIL: int
-XAER_OUTSIDE: int
-XAER_RMERR: int
-XA_RBROLLBACK: int
-NONEXISTING_PROC_GRANT: int
-PROC_AUTO_GRANT_FAIL: int
-PROC_AUTO_REVOKE_FAIL: int
-DATA_TOO_LONG: int
-SP_BAD_SQLSTATE: int
-STARTUP: int
-LOAD_FROM_FIXED_SIZE_ROWS_TO_VAR: int
-CANT_CREATE_USER_WITH_GRANT: int
-WRONG_VALUE_FOR_TYPE: int
-TABLE_DEF_CHANGED: int
-SP_DUP_HANDLER: int
-SP_NOT_VAR_ARG: int
-SP_NO_RETSET: int
-CANT_CREATE_GEOMETRY_OBJECT: int
-FAILED_ROUTINE_BREAK_BINLOG: int
-BINLOG_UNSAFE_ROUTINE: int
-BINLOG_CREATE_ROUTINE_NEED_SUPER: int
-EXEC_STMT_WITH_OPEN_CURSOR: int
-STMT_HAS_NO_OPEN_CURSOR: int
-COMMIT_NOT_ALLOWED_IN_SF_OR_TRG: int
-NO_DEFAULT_FOR_VIEW_FIELD: int
-SP_NO_RECURSION: int
-TOO_BIG_SCALE: int
-TOO_BIG_PRECISION: int
-M_BIGGER_THAN_D: int
-WRONG_LOCK_OF_SYSTEM_TABLE: int
-CONNECT_TO_FOREIGN_DATA_SOURCE: int
-QUERY_ON_FOREIGN_DATA_SOURCE: int
-FOREIGN_DATA_SOURCE_DOESNT_EXIST: int
-FOREIGN_DATA_STRING_INVALID_CANT_CREATE: int
-FOREIGN_DATA_STRING_INVALID: int
-CANT_CREATE_FEDERATED_TABLE: int
-TRG_IN_WRONG_SCHEMA: int
-STACK_OVERRUN_NEED_MORE: int
-TOO_LONG_BODY: int
-WARN_CANT_DROP_DEFAULT_KEYCACHE: int
-TOO_BIG_DISPLAYWIDTH: int
-XAER_DUPID: int
-DATETIME_FUNCTION_OVERFLOW: int
-CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG: int
-VIEW_PREVENT_UPDATE: int
-PS_NO_RECURSION: int
-SP_CANT_SET_AUTOCOMMIT: int
-MALFORMED_DEFINER: int
-VIEW_FRM_NO_USER: int
-VIEW_OTHER_USER: int
-NO_SUCH_USER: int
-FORBID_SCHEMA_CHANGE: int
-ROW_IS_REFERENCED_2: int
-NO_REFERENCED_ROW_2: int
-SP_BAD_VAR_SHADOW: int
-TRG_NO_DEFINER: int
-OLD_FILE_FORMAT: int
-SP_RECURSION_LIMIT: int
-SP_PROC_TABLE_CORRUPT: int
-SP_WRONG_NAME: int
-TABLE_NEEDS_UPGRADE: int
-SP_NO_AGGREGATE: int
-MAX_PREPARED_STMT_COUNT_REACHED: int
-VIEW_RECURSIVE: int
-NON_GROUPING_FIELD_USED: int
-TABLE_CANT_HANDLE_SPKEYS: int
-NO_TRIGGERS_ON_SYSTEM_SCHEMA: int
-USERNAME: int
-HOSTNAME: int
-WRONG_STRING_LENGTH: int
-ERROR_LAST: int
-CONSTRAINT_FAILED: int
+from typing import Final
+
+ERROR_FIRST: Final = 1000
+HASHCHK: Final = 1000
+NISAMCHK: Final = 1001
+NO: Final = 1002
+YES: Final = 1003
+CANT_CREATE_FILE: Final = 1004
+CANT_CREATE_TABLE: Final = 1005
+CANT_CREATE_DB: Final = 1006
+DB_CREATE_EXISTS: Final = 1007
+DB_DROP_EXISTS: Final = 1008
+DB_DROP_DELETE: Final = 1009
+DB_DROP_RMDIR: Final = 1010
+CANT_DELETE_FILE: Final = 1011
+CANT_FIND_SYSTEM_REC: Final = 1012
+CANT_GET_STAT: Final = 1013
+CANT_GET_WD: Final = 1014
+CANT_LOCK: Final = 1015
+CANT_OPEN_FILE: Final = 1016
+FILE_NOT_FOUND: Final = 1017
+CANT_READ_DIR: Final = 1018
+CANT_SET_WD: Final = 1019
+CHECKREAD: Final = 1020
+DISK_FULL: Final = 1021
+DUP_KEY: Final = 1022
+ERROR_ON_CLOSE: Final = 1023
+ERROR_ON_READ: Final = 1024
+ERROR_ON_RENAME: Final = 1025
+ERROR_ON_WRITE: Final = 1026
+FILE_USED: Final = 1027
+FILSORT_ABORT: Final = 1028
+FORM_NOT_FOUND: Final = 1029
+GET_ERRNO: Final = 1030
+ILLEGAL_HA: Final = 1031
+KEY_NOT_FOUND: Final = 1032
+NOT_FORM_FILE: Final = 1033
+NOT_KEYFILE: Final = 1034
+OLD_KEYFILE: Final = 1035
+OPEN_AS_READONLY: Final = 1036
+OUTOFMEMORY: Final = 1037
+OUT_OF_SORTMEMORY: Final = 1038
+UNEXPECTED_EOF: Final = 1039
+CON_COUNT_ERROR: Final = 1040
+OUT_OF_RESOURCES: Final = 1041
+BAD_HOST_ERROR: Final = 1042
+HANDSHAKE_ERROR: Final = 1043
+DBACCESS_DENIED_ERROR: Final = 1044
+ACCESS_DENIED_ERROR: Final = 1045
+NO_DB_ERROR: Final = 1046
+UNKNOWN_COM_ERROR: Final = 1047
+BAD_NULL_ERROR: Final = 1048
+BAD_DB_ERROR: Final = 1049
+TABLE_EXISTS_ERROR: Final = 1050
+BAD_TABLE_ERROR: Final = 1051
+NON_UNIQ_ERROR: Final = 1052
+SERVER_SHUTDOWN: Final = 1053
+BAD_FIELD_ERROR: Final = 1054
+WRONG_FIELD_WITH_GROUP: Final = 1055
+WRONG_GROUP_FIELD: Final = 1056
+WRONG_SUM_SELECT: Final = 1057
+WRONG_VALUE_COUNT: Final = 1058
+TOO_LONG_IDENT: Final = 1059
+DUP_FIELDNAME: Final = 1060
+DUP_KEYNAME: Final = 1061
+DUP_ENTRY: Final = 1062
+WRONG_FIELD_SPEC: Final = 1063
+PARSE_ERROR: Final = 1064
+EMPTY_QUERY: Final = 1065
+NONUNIQ_TABLE: Final = 1066
+INVALID_DEFAULT: Final = 1067
+MULTIPLE_PRI_KEY: Final = 1068
+TOO_MANY_KEYS: Final = 1069
+TOO_MANY_KEY_PARTS: Final = 1070
+TOO_LONG_KEY: Final = 1071
+KEY_COLUMN_DOES_NOT_EXITS: Final = 1072
+BLOB_USED_AS_KEY: Final = 1073
+TOO_BIG_FIELDLENGTH: Final = 1074
+WRONG_AUTO_KEY: Final = 1075
+READY: Final = 1076
+NORMAL_SHUTDOWN: Final = 1077
+GOT_SIGNAL: Final = 1078
+SHUTDOWN_COMPLETE: Final = 1079
+FORCING_CLOSE: Final = 1080
+IPSOCK_ERROR: Final = 1081
+NO_SUCH_INDEX: Final = 1082
+WRONG_FIELD_TERMINATORS: Final = 1083
+BLOBS_AND_NO_TERMINATED: Final = 1084
+TEXTFILE_NOT_READABLE: Final = 1085
+FILE_EXISTS_ERROR: Final = 1086
+LOAD_INFO: Final = 1087
+ALTER_INFO: Final = 1088
+WRONG_SUB_KEY: Final = 1089
+CANT_REMOVE_ALL_FIELDS: Final = 1090
+CANT_DROP_FIELD_OR_KEY: Final = 1091
+INSERT_INFO: Final = 1092
+UPDATE_TABLE_USED: Final = 1093
+NO_SUCH_THREAD: Final = 1094
+KILL_DENIED_ERROR: Final = 1095
+NO_TABLES_USED: Final = 1096
+TOO_BIG_SET: Final = 1097
+NO_UNIQUE_LOGFILE: Final = 1098
+TABLE_NOT_LOCKED_FOR_WRITE: Final = 1099
+TABLE_NOT_LOCKED: Final = 1100
+BLOB_CANT_HAVE_DEFAULT: Final = 1101
+WRONG_DB_NAME: Final = 1102
+WRONG_TABLE_NAME: Final = 1103
+TOO_BIG_SELECT: Final = 1104
+UNKNOWN_ERROR: Final = 1105
+UNKNOWN_PROCEDURE: Final = 1106
+WRONG_PARAMCOUNT_TO_PROCEDURE: Final = 1107
+WRONG_PARAMETERS_TO_PROCEDURE: Final = 1108
+UNKNOWN_TABLE: Final = 1109
+FIELD_SPECIFIED_TWICE: Final = 1110
+INVALID_GROUP_FUNC_USE: Final = 1111
+UNSUPPORTED_EXTENSION: Final = 1112
+TABLE_MUST_HAVE_COLUMNS: Final = 1113
+RECORD_FILE_FULL: Final = 1114
+UNKNOWN_CHARACTER_SET: Final = 1115
+TOO_MANY_TABLES: Final = 1116
+TOO_MANY_FIELDS: Final = 1117
+TOO_BIG_ROWSIZE: Final = 1118
+STACK_OVERRUN: Final = 1119
+WRONG_OUTER_JOIN: Final = 1120
+NULL_COLUMN_IN_INDEX: Final = 1121
+CANT_FIND_UDF: Final = 1122
+CANT_INITIALIZE_UDF: Final = 1123
+UDF_NO_PATHS: Final = 1124
+UDF_EXISTS: Final = 1125
+CANT_OPEN_LIBRARY: Final = 1126
+CANT_FIND_DL_ENTRY: Final = 1127
+FUNCTION_NOT_DEFINED: Final = 1128
+HOST_IS_BLOCKED: Final = 1129
+HOST_NOT_PRIVILEGED: Final = 1130
+PASSWORD_ANONYMOUS_USER: Final = 1131
+PASSWORD_NOT_ALLOWED: Final = 1132
+PASSWORD_NO_MATCH: Final = 1133
+UPDATE_INFO: Final = 1134
+CANT_CREATE_THREAD: Final = 1135
+WRONG_VALUE_COUNT_ON_ROW: Final = 1136
+CANT_REOPEN_TABLE: Final = 1137
+INVALID_USE_OF_NULL: Final = 1138
+REGEXP_ERROR: Final = 1139
+MIX_OF_GROUP_FUNC_AND_FIELDS: Final = 1140
+NONEXISTING_GRANT: Final = 1141
+TABLEACCESS_DENIED_ERROR: Final = 1142
+COLUMNACCESS_DENIED_ERROR: Final = 1143
+ILLEGAL_GRANT_FOR_TABLE: Final = 1144
+GRANT_WRONG_HOST_OR_USER: Final = 1145
+NO_SUCH_TABLE: Final = 1146
+NONEXISTING_TABLE_GRANT: Final = 1147
+NOT_ALLOWED_COMMAND: Final = 1148
+SYNTAX_ERROR: Final = 1149
+DELAYED_CANT_CHANGE_LOCK: Final = 1150
+TOO_MANY_DELAYED_THREADS: Final = 1151
+ABORTING_CONNECTION: Final = 1152
+NET_PACKET_TOO_LARGE: Final = 1153
+NET_READ_ERROR_FROM_PIPE: Final = 1154
+NET_FCNTL_ERROR: Final = 1155
+NET_PACKETS_OUT_OF_ORDER: Final = 1156
+NET_UNCOMPRESS_ERROR: Final = 1157
+NET_READ_ERROR: Final = 1158
+NET_READ_INTERRUPTED: Final = 1159
+NET_ERROR_ON_WRITE: Final = 1160
+NET_WRITE_INTERRUPTED: Final = 1161
+TOO_LONG_STRING: Final = 1162
+TABLE_CANT_HANDLE_BLOB: Final = 1163
+TABLE_CANT_HANDLE_AUTO_INCREMENT: Final = 1164
+DELAYED_INSERT_TABLE_LOCKED: Final = 1165
+WRONG_COLUMN_NAME: Final = 1166
+WRONG_KEY_COLUMN: Final = 1167
+WRONG_MRG_TABLE: Final = 1168
+DUP_UNIQUE: Final = 1169
+BLOB_KEY_WITHOUT_LENGTH: Final = 1170
+PRIMARY_CANT_HAVE_NULL: Final = 1171
+TOO_MANY_ROWS: Final = 1172
+REQUIRES_PRIMARY_KEY: Final = 1173
+NO_RAID_COMPILED: Final = 1174
+UPDATE_WITHOUT_KEY_IN_SAFE_MODE: Final = 1175
+KEY_DOES_NOT_EXITS: Final = 1176
+CHECK_NO_SUCH_TABLE: Final = 1177
+CHECK_NOT_IMPLEMENTED: Final = 1178
+CANT_DO_THIS_DURING_AN_TRANSACTION: Final = 1179
+ERROR_DURING_COMMIT: Final = 1180
+ERROR_DURING_ROLLBACK: Final = 1181
+ERROR_DURING_FLUSH_LOGS: Final = 1182
+ERROR_DURING_CHECKPOINT: Final = 1183
+NEW_ABORTING_CONNECTION: Final = 1184
+DUMP_NOT_IMPLEMENTED: Final = 1185
+FLUSH_MASTER_BINLOG_CLOSED: Final = 1186
+INDEX_REBUILD: Final = 1187
+MASTER: Final = 1188
+MASTER_NET_READ: Final = 1189
+MASTER_NET_WRITE: Final = 1190
+FT_MATCHING_KEY_NOT_FOUND: Final = 1191
+LOCK_OR_ACTIVE_TRANSACTION: Final = 1192
+UNKNOWN_SYSTEM_VARIABLE: Final = 1193
+CRASHED_ON_USAGE: Final = 1194
+CRASHED_ON_REPAIR: Final = 1195
+WARNING_NOT_COMPLETE_ROLLBACK: Final = 1196
+TRANS_CACHE_FULL: Final = 1197
+SLAVE_MUST_STOP: Final = 1198
+SLAVE_NOT_RUNNING: Final = 1199
+BAD_SLAVE: Final = 1200
+MASTER_INFO: Final = 1201
+SLAVE_THREAD: Final = 1202
+TOO_MANY_USER_CONNECTIONS: Final = 1203
+SET_CONSTANTS_ONLY: Final = 1204
+LOCK_WAIT_TIMEOUT: Final = 1205
+LOCK_TABLE_FULL: Final = 1206
+READ_ONLY_TRANSACTION: Final = 1207
+DROP_DB_WITH_READ_LOCK: Final = 1208
+CREATE_DB_WITH_READ_LOCK: Final = 1209
+WRONG_ARGUMENTS: Final = 1210
+NO_PERMISSION_TO_CREATE_USER: Final = 1211
+UNION_TABLES_IN_DIFFERENT_DIR: Final = 1212
+LOCK_DEADLOCK: Final = 1213
+TABLE_CANT_HANDLE_FT: Final = 1214
+CANNOT_ADD_FOREIGN: Final = 1215
+NO_REFERENCED_ROW: Final = 1216
+ROW_IS_REFERENCED: Final = 1217
+CONNECT_TO_MASTER: Final = 1218
+QUERY_ON_MASTER: Final = 1219
+ERROR_WHEN_EXECUTING_COMMAND: Final = 1220
+WRONG_USAGE: Final = 1221
+WRONG_NUMBER_OF_COLUMNS_IN_SELECT: Final = 1222
+CANT_UPDATE_WITH_READLOCK: Final = 1223
+MIXING_NOT_ALLOWED: Final = 1224
+DUP_ARGUMENT: Final = 1225
+USER_LIMIT_REACHED: Final = 1226
+SPECIFIC_ACCESS_DENIED_ERROR: Final = 1227
+LOCAL_VARIABLE: Final = 1228
+GLOBAL_VARIABLE: Final = 1229
+NO_DEFAULT: Final = 1230
+WRONG_VALUE_FOR_VAR: Final = 1231
+WRONG_TYPE_FOR_VAR: Final = 1232
+VAR_CANT_BE_READ: Final = 1233
+CANT_USE_OPTION_HERE: Final = 1234
+NOT_SUPPORTED_YET: Final = 1235
+MASTER_FATAL_ERROR_READING_BINLOG: Final = 1236
+SLAVE_IGNORED_TABLE: Final = 1237
+INCORRECT_GLOBAL_LOCAL_VAR: Final = 1238
+WRONG_FK_DEF: Final = 1239
+KEY_REF_DO_NOT_MATCH_TABLE_REF: Final = 1240
+OPERAND_COLUMNS: Final = 1241
+SUBQUERY_NO_1_ROW: Final = 1242
+UNKNOWN_STMT_HANDLER: Final = 1243
+CORRUPT_HELP_DB: Final = 1244
+CYCLIC_REFERENCE: Final = 1245
+AUTO_CONVERT: Final = 1246
+ILLEGAL_REFERENCE: Final = 1247
+DERIVED_MUST_HAVE_ALIAS: Final = 1248
+SELECT_REDUCED: Final = 1249
+TABLENAME_NOT_ALLOWED_HERE: Final = 1250
+NOT_SUPPORTED_AUTH_MODE: Final = 1251
+SPATIAL_CANT_HAVE_NULL: Final = 1252
+COLLATION_CHARSET_MISMATCH: Final = 1253
+SLAVE_WAS_RUNNING: Final = 1254
+SLAVE_WAS_NOT_RUNNING: Final = 1255
+TOO_BIG_FOR_UNCOMPRESS: Final = 1256
+ZLIB_Z_MEM_ERROR: Final = 1257
+ZLIB_Z_BUF_ERROR: Final = 1258
+ZLIB_Z_DATA_ERROR: Final = 1259
+CUT_VALUE_GROUP_CONCAT: Final = 1260
+WARN_TOO_FEW_RECORDS: Final = 1261
+WARN_TOO_MANY_RECORDS: Final = 1262
+WARN_NULL_TO_NOTNULL: Final = 1263
+WARN_DATA_OUT_OF_RANGE: Final = 1264
+WARN_DATA_TRUNCATED: Final = 1265
+WARN_USING_OTHER_HANDLER: Final = 1266
+CANT_AGGREGATE_2COLLATIONS: Final = 1267
+DROP_USER: Final = 1268
+REVOKE_GRANTS: Final = 1269
+CANT_AGGREGATE_3COLLATIONS: Final = 1270
+CANT_AGGREGATE_NCOLLATIONS: Final = 1271
+VARIABLE_IS_NOT_STRUCT: Final = 1272
+UNKNOWN_COLLATION: Final = 1273
+SLAVE_IGNORED_SSL_PARAMS: Final = 1274
+SERVER_IS_IN_SECURE_AUTH_MODE: Final = 1275
+WARN_FIELD_RESOLVED: Final = 1276
+BAD_SLAVE_UNTIL_COND: Final = 1277
+MISSING_SKIP_SLAVE: Final = 1278
+UNTIL_COND_IGNORED: Final = 1279
+WRONG_NAME_FOR_INDEX: Final = 1280
+WRONG_NAME_FOR_CATALOG: Final = 1281
+WARN_QC_RESIZE: Final = 1282
+BAD_FT_COLUMN: Final = 1283
+UNKNOWN_KEY_CACHE: Final = 1284
+WARN_HOSTNAME_WONT_WORK: Final = 1285
+UNKNOWN_STORAGE_ENGINE: Final = 1286
+WARN_DEPRECATED_SYNTAX: Final = 1287
+NON_UPDATABLE_TABLE: Final = 1288
+FEATURE_DISABLED: Final = 1289
+OPTION_PREVENTS_STATEMENT: Final = 1290
+DUPLICATED_VALUE_IN_TYPE: Final = 1291
+TRUNCATED_WRONG_VALUE: Final = 1292
+TOO_MUCH_AUTO_TIMESTAMP_COLS: Final = 1293
+INVALID_ON_UPDATE: Final = 1294
+UNSUPPORTED_PS: Final = 1295
+GET_ERRMSG: Final = 1296
+GET_TEMPORARY_ERRMSG: Final = 1297
+UNKNOWN_TIME_ZONE: Final = 1298
+WARN_INVALID_TIMESTAMP: Final = 1299
+INVALID_CHARACTER_STRING: Final = 1300
+WARN_ALLOWED_PACKET_OVERFLOWED: Final = 1301
+CONFLICTING_DECLARATIONS: Final = 1302
+SP_NO_RECURSIVE_CREATE: Final = 1303
+SP_ALREADY_EXISTS: Final = 1304
+SP_DOES_NOT_EXIST: Final = 1305
+SP_DROP_FAILED: Final = 1306
+SP_STORE_FAILED: Final = 1307
+SP_LILABEL_MISMATCH: Final = 1308
+SP_LABEL_REDEFINE: Final = 1309
+SP_LABEL_MISMATCH: Final = 1310
+SP_UNINIT_VAR: Final = 1311
+SP_BADSELECT: Final = 1312
+SP_BADRETURN: Final = 1313
+SP_BADSTATEMENT: Final = 1314
+UPDATE_LOG_DEPRECATED_IGNORED: Final = 1315
+UPDATE_LOG_DEPRECATED_TRANSLATED: Final = 1316
+QUERY_INTERRUPTED: Final = 1317
+SP_WRONG_NO_OF_ARGS: Final = 1318
+SP_COND_MISMATCH: Final = 1319
+SP_NORETURN: Final = 1320
+SP_NORETURNEND: Final = 1321
+SP_BAD_CURSOR_QUERY: Final = 1322
+SP_BAD_CURSOR_SELECT: Final = 1323
+SP_CURSOR_MISMATCH: Final = 1324
+SP_CURSOR_ALREADY_OPEN: Final = 1325
+SP_CURSOR_NOT_OPEN: Final = 1326
+SP_UNDECLARED_VAR: Final = 1327
+SP_WRONG_NO_OF_FETCH_ARGS: Final = 1328
+SP_FETCH_NO_DATA: Final = 1329
+SP_DUP_PARAM: Final = 1330
+SP_DUP_VAR: Final = 1331
+SP_DUP_COND: Final = 1332
+SP_DUP_CURS: Final = 1333
+SP_CANT_ALTER: Final = 1334
+SP_SUBSELECT_NYI: Final = 1335
+STMT_NOT_ALLOWED_IN_SF_OR_TRG: Final = 1336
+SP_VARCOND_AFTER_CURSHNDLR: Final = 1337
+SP_CURSOR_AFTER_HANDLER: Final = 1338
+SP_CASE_NOT_FOUND: Final = 1339
+FPARSER_TOO_BIG_FILE: Final = 1340
+FPARSER_BAD_HEADER: Final = 1341
+FPARSER_EOF_IN_COMMENT: Final = 1342
+FPARSER_ERROR_IN_PARAMETER: Final = 1343
+FPARSER_EOF_IN_UNKNOWN_PARAMETER: Final = 1344
+VIEW_NO_EXPLAIN: Final = 1345
+FRM_UNKNOWN_TYPE: Final = 1346
+WRONG_OBJECT: Final = 1347
+NONUPDATEABLE_COLUMN: Final = 1348
+VIEW_SELECT_DERIVED: Final = 1349
+VIEW_SELECT_CLAUSE: Final = 1350
+VIEW_SELECT_VARIABLE: Final = 1351
+VIEW_SELECT_TMPTABLE: Final = 1352
+VIEW_WRONG_LIST: Final = 1353
+WARN_VIEW_MERGE: Final = 1354
+WARN_VIEW_WITHOUT_KEY: Final = 1355
+VIEW_INVALID: Final = 1356
+SP_NO_DROP_SP: Final = 1357
+SP_GOTO_IN_HNDLR: Final = 1358
+TRG_ALREADY_EXISTS: Final = 1359
+TRG_DOES_NOT_EXIST: Final = 1360
+TRG_ON_VIEW_OR_TEMP_TABLE: Final = 1361
+TRG_CANT_CHANGE_ROW: Final = 1362
+TRG_NO_SUCH_ROW_IN_TRG: Final = 1363
+NO_DEFAULT_FOR_FIELD: Final = 1364
+DIVISION_BY_ZERO: Final = 1365
+TRUNCATED_WRONG_VALUE_FOR_FIELD: Final = 1366
+ILLEGAL_VALUE_FOR_TYPE: Final = 1367
+VIEW_NONUPD_CHECK: Final = 1368
+VIEW_CHECK_FAILED: Final = 1369
+PROCACCESS_DENIED_ERROR: Final = 1370
+RELAY_LOG_FAIL: Final = 1371
+PASSWD_LENGTH: Final = 1372
+UNKNOWN_TARGET_BINLOG: Final = 1373
+IO_ERR_LOG_INDEX_READ: Final = 1374
+BINLOG_PURGE_PROHIBITED: Final = 1375
+FSEEK_FAIL: Final = 1376
+BINLOG_PURGE_FATAL_ERR: Final = 1377
+LOG_IN_USE: Final = 1378
+LOG_PURGE_UNKNOWN_ERR: Final = 1379
+RELAY_LOG_INIT: Final = 1380
+NO_BINARY_LOGGING: Final = 1381
+RESERVED_SYNTAX: Final = 1382
+WSAS_FAILED: Final = 1383
+DIFF_GROUPS_PROC: Final = 1384
+NO_GROUP_FOR_PROC: Final = 1385
+ORDER_WITH_PROC: Final = 1386
+LOGGING_PROHIBIT_CHANGING_OF: Final = 1387
+NO_FILE_MAPPING: Final = 1388
+WRONG_MAGIC: Final = 1389
+PS_MANY_PARAM: Final = 1390
+KEY_PART_0: Final = 1391
+VIEW_CHECKSUM: Final = 1392
+VIEW_MULTIUPDATE: Final = 1393
+VIEW_NO_INSERT_FIELD_LIST: Final = 1394
+VIEW_DELETE_MERGE_VIEW: Final = 1395
+CANNOT_USER: Final = 1396
+XAER_NOTA: Final = 1397
+XAER_INVAL: Final = 1398
+XAER_RMFAIL: Final = 1399
+XAER_OUTSIDE: Final = 1400
+XAER_RMERR: Final = 1401
+XA_RBROLLBACK: Final = 1402
+NONEXISTING_PROC_GRANT: Final = 1403
+PROC_AUTO_GRANT_FAIL: Final = 1404
+PROC_AUTO_REVOKE_FAIL: Final = 1405
+DATA_TOO_LONG: Final = 1406
+SP_BAD_SQLSTATE: Final = 1407
+STARTUP: Final = 1408
+LOAD_FROM_FIXED_SIZE_ROWS_TO_VAR: Final = 1409
+CANT_CREATE_USER_WITH_GRANT: Final = 1410
+WRONG_VALUE_FOR_TYPE: Final = 1411
+TABLE_DEF_CHANGED: Final = 1412
+SP_DUP_HANDLER: Final = 1413
+SP_NOT_VAR_ARG: Final = 1414
+SP_NO_RETSET: Final = 1415
+CANT_CREATE_GEOMETRY_OBJECT: Final = 1416
+FAILED_ROUTINE_BREAK_BINLOG: Final = 1417
+BINLOG_UNSAFE_ROUTINE: Final = 1418
+BINLOG_CREATE_ROUTINE_NEED_SUPER: Final = 1419
+EXEC_STMT_WITH_OPEN_CURSOR: Final = 1420
+STMT_HAS_NO_OPEN_CURSOR: Final = 1421
+COMMIT_NOT_ALLOWED_IN_SF_OR_TRG: Final = 1422
+NO_DEFAULT_FOR_VIEW_FIELD: Final = 1423
+SP_NO_RECURSION: Final = 1424
+TOO_BIG_SCALE: Final = 1425
+TOO_BIG_PRECISION: Final = 1426
+M_BIGGER_THAN_D: Final = 1427
+WRONG_LOCK_OF_SYSTEM_TABLE: Final = 1428
+CONNECT_TO_FOREIGN_DATA_SOURCE: Final = 1429
+QUERY_ON_FOREIGN_DATA_SOURCE: Final = 1430
+FOREIGN_DATA_SOURCE_DOESNT_EXIST: Final = 1431
+FOREIGN_DATA_STRING_INVALID_CANT_CREATE: Final = 1432
+FOREIGN_DATA_STRING_INVALID: Final = 1433
+CANT_CREATE_FEDERATED_TABLE: Final = 1434
+TRG_IN_WRONG_SCHEMA: Final = 1435
+STACK_OVERRUN_NEED_MORE: Final = 1436
+TOO_LONG_BODY: Final = 1437
+WARN_CANT_DROP_DEFAULT_KEYCACHE: Final = 1438
+TOO_BIG_DISPLAYWIDTH: Final = 1439
+XAER_DUPID: Final = 1440
+DATETIME_FUNCTION_OVERFLOW: Final = 1441
+CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG: Final = 1442
+VIEW_PREVENT_UPDATE: Final = 1443
+PS_NO_RECURSION: Final = 1444
+SP_CANT_SET_AUTOCOMMIT: Final = 1445
+MALFORMED_DEFINER: Final = 1446
+VIEW_FRM_NO_USER: Final = 1447
+VIEW_OTHER_USER: Final = 1448
+NO_SUCH_USER: Final = 1449
+FORBID_SCHEMA_CHANGE: Final = 1450
+ROW_IS_REFERENCED_2: Final = 1451
+NO_REFERENCED_ROW_2: Final = 1452
+SP_BAD_VAR_SHADOW: Final = 1453
+TRG_NO_DEFINER: Final = 1454
+OLD_FILE_FORMAT: Final = 1455
+SP_RECURSION_LIMIT: Final = 1456
+SP_PROC_TABLE_CORRUPT: Final = 1457
+SP_WRONG_NAME: Final = 1458
+TABLE_NEEDS_UPGRADE: Final = 1459
+SP_NO_AGGREGATE: Final = 1460
+MAX_PREPARED_STMT_COUNT_REACHED: Final = 1461
+VIEW_RECURSIVE: Final = 1462
+NON_GROUPING_FIELD_USED: Final = 1463
+TABLE_CANT_HANDLE_SPKEYS: Final = 1464
+NO_TRIGGERS_ON_SYSTEM_SCHEMA: Final = 1465
+USERNAME: Final = 1466
+HOSTNAME: Final = 1467
+WRONG_STRING_LENGTH: Final = 1468
+ERROR_LAST: Final = 1468
+STATEMENT_TIMEOUT: Final = 1969
+QUERY_TIMEOUT: Final = 3024
+CONSTRAINT_FAILED: Final = 4025
diff --git a/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/FIELD_TYPE.pyi b/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/FIELD_TYPE.pyi
index 4790d922e746..ab5a5b71f529 100644
--- a/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/FIELD_TYPE.pyi
+++ b/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/FIELD_TYPE.pyi
@@ -1,30 +1,32 @@
-DECIMAL: int
-TINY: int
-SHORT: int
-LONG: int
-FLOAT: int
-DOUBLE: int
-NULL: int
-TIMESTAMP: int
-LONGLONG: int
-INT24: int
-DATE: int
-TIME: int
-DATETIME: int
-YEAR: int
-NEWDATE: int
-VARCHAR: int
-BIT: int
-JSON: int
-NEWDECIMAL: int
-ENUM: int
-SET: int
-TINY_BLOB: int
-MEDIUM_BLOB: int
-LONG_BLOB: int
-BLOB: int
-VAR_STRING: int
-STRING: int
-GEOMETRY: int
-CHAR: int
-INTERVAL: int
+from typing import Final
+
+DECIMAL: Final = 0
+TINY: Final = 1
+SHORT: Final = 2
+LONG: Final = 3
+FLOAT: Final = 4
+DOUBLE: Final = 5
+NULL: Final = 6
+TIMESTAMP: Final = 7
+LONGLONG: Final = 8
+INT24: Final = 9
+DATE: Final = 10
+TIME: Final = 11
+DATETIME: Final = 12
+YEAR: Final = 13
+NEWDATE: Final = 14
+VARCHAR: Final = 15
+BIT: Final = 16
+JSON: Final = 245
+NEWDECIMAL: Final = 246
+ENUM: Final = 247
+SET: Final = 248
+TINY_BLOB: Final = 249
+MEDIUM_BLOB: Final = 250
+LONG_BLOB: Final = 251
+BLOB: Final = 252
+VAR_STRING: Final = 253
+STRING: Final = 254
+GEOMETRY: Final = 255
+CHAR: Final = TINY
+INTERVAL: Final = ENUM
diff --git a/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/FLAG.pyi b/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/FLAG.pyi
index 421f231565f3..111e4739fe3d 100644
--- a/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/FLAG.pyi
+++ b/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/FLAG.pyi
@@ -1,15 +1,17 @@
-NOT_NULL: int
-PRI_KEY: int
-UNIQUE_KEY: int
-MULTIPLE_KEY: int
-BLOB: int
-UNSIGNED: int
-ZEROFILL: int
-BINARY: int
-ENUM: int
-AUTO_INCREMENT: int
-TIMESTAMP: int
-SET: int
-PART_KEY: int
-GROUP: int
-UNIQUE: int
+from typing import Final
+
+NOT_NULL: Final = 1
+PRI_KEY: Final = 2
+UNIQUE_KEY: Final = 4
+MULTIPLE_KEY: Final = 8
+BLOB: Final = 16
+UNSIGNED: Final = 32
+ZEROFILL: Final = 64
+BINARY: Final = 128
+ENUM: Final = 256
+AUTO_INCREMENT: Final = 512
+TIMESTAMP: Final = 1024
+SET: Final = 2048
+PART_KEY: Final = 16384
+GROUP: Final = 32767
+UNIQUE: Final = 65536
diff --git a/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/SERVER_STATUS.pyi b/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/SERVER_STATUS.pyi
index 437b89367534..2e006c848e04 100644
--- a/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/SERVER_STATUS.pyi
+++ b/python/helpers/typeshed/stubs/PyMySQL/pymysql/constants/SERVER_STATUS.pyi
@@ -1,10 +1,12 @@
-SERVER_STATUS_IN_TRANS: int
-SERVER_STATUS_AUTOCOMMIT: int
-SERVER_MORE_RESULTS_EXISTS: int
-SERVER_QUERY_NO_GOOD_INDEX_USED: int
-SERVER_QUERY_NO_INDEX_USED: int
-SERVER_STATUS_CURSOR_EXISTS: int
-SERVER_STATUS_LAST_ROW_SENT: int
-SERVER_STATUS_DB_DROPPED: int
-SERVER_STATUS_NO_BACKSLASH_ESCAPES: int
-SERVER_STATUS_METADATA_CHANGED: int
+from typing import Final
+
+SERVER_STATUS_IN_TRANS: Final = 1
+SERVER_STATUS_AUTOCOMMIT: Final = 2
+SERVER_MORE_RESULTS_EXISTS: Final = 8
+SERVER_QUERY_NO_GOOD_INDEX_USED: Final = 16
+SERVER_QUERY_NO_INDEX_USED: Final = 32
+SERVER_STATUS_CURSOR_EXISTS: Final = 64
+SERVER_STATUS_LAST_ROW_SENT: Final = 128
+SERVER_STATUS_DB_DROPPED: Final = 256
+SERVER_STATUS_NO_BACKSLASH_ESCAPES: Final = 512
+SERVER_STATUS_METADATA_CHANGED: Final = 1024
diff --git a/python/helpers/typeshed/stubs/PyMySQL/pymysql/converters.pyi b/python/helpers/typeshed/stubs/PyMySQL/pymysql/converters.pyi
index 3354a1e05371..2a8eaf1c8fe7 100644
--- a/python/helpers/typeshed/stubs/PyMySQL/pymysql/converters.pyi
+++ b/python/helpers/typeshed/stubs/PyMySQL/pymysql/converters.pyi
@@ -1,4 +1,5 @@
import datetime
+import re
import time
from _typeshed import Unused
from collections.abc import Callable, Mapping, Sequence
@@ -28,8 +29,17 @@ def escape_datetime(obj: datetime.datetime, mapping: _EscaperMapping = None) ->
def escape_date(obj: datetime.date, mapping: _EscaperMapping = None) -> str: ...
def escape_struct_time(obj: time.struct_time, mapping: _EscaperMapping = None) -> str: ...
def Decimal2Literal(o: Decimal, d: Unused) -> str: ...
+
+DATETIME_RE: re.Pattern[str]
+
def convert_datetime(obj: str | bytes) -> datetime.datetime | str: ...
+
+TIMEDELTA_RE: re.Pattern[str]
+
def convert_timedelta(obj: str | bytes) -> datetime.timedelta | str: ...
+
+TIME_RE: re.Pattern[str]
+
def convert_time(obj: str | bytes) -> datetime.time | str: ...
def convert_date(obj: str | bytes) -> datetime.date | str: ...
def through(x: _T) -> _T: ...
diff --git a/python/helpers/typeshed/stubs/PyMySQL/pymysql/cursors.pyi b/python/helpers/typeshed/stubs/PyMySQL/pymysql/cursors.pyi
index 4cc5e21ec561..6111f43b77c6 100644
--- a/python/helpers/typeshed/stubs/PyMySQL/pymysql/cursors.pyi
+++ b/python/helpers/typeshed/stubs/PyMySQL/pymysql/cursors.pyi
@@ -1,10 +1,14 @@
+import re
from collections.abc import Iterable, Iterator
-from typing import Any
+from typing import Any, ClassVar
from typing_extensions import Self
from .connections import Connection
+RE_INSERT_VALUES: re.Pattern[str]
+
class Cursor:
+ max_stmt_length: ClassVar[int]
connection: Connection[Any]
description: tuple[str, ...]
rownumber: int
@@ -14,7 +18,6 @@ class Cursor:
errorhandler: Any
lastrowid: int
def __init__(self, connection: Connection[Any]) -> None: ...
- def __del__(self) -> None: ...
def close(self) -> None: ...
def setinputsizes(self, *args) -> None: ...
def setoutputsizes(self, *args) -> None: ...
@@ -31,6 +34,7 @@ class Cursor:
def fetchmany(self, size: int | None = None) -> tuple[tuple[Any, ...], ...]: ...
def fetchall(self) -> tuple[tuple[Any, ...], ...]: ...
def __iter__(self) -> Iterator[tuple[Any, ...]]: ...
+ def __next__(self): ...
class DictCursorMixin:
dict_type: Any # TODO: add support if someone needs this
@@ -40,6 +44,8 @@ class DictCursorMixin:
def __iter__(self) -> Iterator[dict[str, Any]]: ...
class SSCursor(Cursor):
+ def __del__(self) -> None: ...
+ def read_next(self): ...
def fetchall(self) -> list[tuple[Any, ...]]: ... # type: ignore[override]
def fetchall_unbuffered(self) -> Iterator[tuple[Any, ...]]: ...
def scroll(self, value: int, mode: str = "relative") -> None: ...
diff --git a/python/helpers/typeshed/stubs/PyMySQL/pymysql/err.pyi b/python/helpers/typeshed/stubs/PyMySQL/pymysql/err.pyi
index 8aec38f533f2..da77ca9b65ec 100644
--- a/python/helpers/typeshed/stubs/PyMySQL/pymysql/err.pyi
+++ b/python/helpers/typeshed/stubs/PyMySQL/pymysql/err.pyi
@@ -17,4 +17,4 @@ class NotSupportedError(DatabaseError): ...
error_map: dict[int, type[DatabaseError]]
-def raise_mysql_exception(data) -> NoReturn: ...
+def raise_mysql_exception(data: bytes | bytearray) -> NoReturn: ...
diff --git a/python/helpers/typeshed/stubs/PyMySQL/pymysql/optionfile.pyi b/python/helpers/typeshed/stubs/PyMySQL/pymysql/optionfile.pyi
new file mode 100644
index 000000000000..7848c4e04ec8
--- /dev/null
+++ b/python/helpers/typeshed/stubs/PyMySQL/pymysql/optionfile.pyi
@@ -0,0 +1,40 @@
+import configparser
+import sys
+from collections.abc import Mapping, Sequence
+
+class Parser(configparser.RawConfigParser):
+ # __init__ signature was taken from RawConfigParser, but with no allow_no_value argument and all arguments are keyword-only
+ if sys.version_info >= (3, 13):
+ def __init__(
+ self,
+ *,
+ defaults: Mapping[str, str] | None = None,
+ dict_type: type[Mapping[str, str]] = ...,
+ delimiters: Sequence[str] = ("=", ":"),
+ comment_prefixes: Sequence[str] = ("#", ";"),
+ inline_comment_prefixes: Sequence[str] | None = None,
+ strict: bool = True,
+ empty_lines_in_values: bool = True,
+ default_section: str = "DEFAULT",
+ interpolation: configparser.Interpolation | None = ...,
+ converters: configparser._ConvertersMap = ...,
+ allow_unnamed_section: bool = False,
+ ) -> None: ...
+ else:
+ def __init__(
+ self,
+ *,
+ defaults: Mapping[str, str] | None = None,
+ dict_type: type[Mapping[str, str]] = ...,
+ delimiters: Sequence[str] = ("=", ":"),
+ comment_prefixes: Sequence[str] = ("#", ";"),
+ inline_comment_prefixes: Sequence[str] | None = None,
+ strict: bool = True,
+ empty_lines_in_values: bool = True,
+ default_section: str = "DEFAULT",
+ interpolation: configparser.Interpolation | None = ...,
+ converters: configparser._ConvertersMap = ...,
+ ) -> None: ...
+
+ def optionxform(self, key: str) -> str: ...
+ def get(self, section: configparser._SectionName, option: str) -> str: ... # type: ignore[override]
diff --git a/python/helpers/typeshed/stubs/PyMySQL/pymysql/protocol.pyi b/python/helpers/typeshed/stubs/PyMySQL/pymysql/protocol.pyi
index f645af4b1f39..dd742364215a 100644
--- a/python/helpers/typeshed/stubs/PyMySQL/pymysql/protocol.pyi
+++ b/python/helpers/typeshed/stubs/PyMySQL/pymysql/protocol.pyi
@@ -11,6 +11,7 @@ UNSIGNED_INT64_COLUMN: Final[int]
def dump_packet(data) -> None: ...
class MysqlPacket:
+ __slots__ = ("_position", "_data")
def __init__(self, data, encoding) -> None: ...
def get_all_data(self): ...
def read(self, size): ...
@@ -26,7 +27,7 @@ class MysqlPacket:
def read_string(self): ...
def read_length_encoded_integer(self) -> Incomplete | None: ...
def read_length_coded_string(self): ...
- def read_struct(self, fmt): ...
+ def read_struct(self, fmt: str): ...
def is_ok_packet(self) -> bool: ...
def is_eof_packet(self) -> bool: ...
def is_auth_switch_request(self) -> bool: ...
@@ -37,3 +38,23 @@ class MysqlPacket:
def check_error(self) -> None: ...
def raise_for_error(self) -> None: ...
def dump(self) -> None: ...
+
+class FieldDescriptorPacket(MysqlPacket):
+ def __init__(self, data, encoding) -> None: ...
+ def description(self): ...
+ def get_column_length(self): ...
+
+class OKPacketWrapper:
+ def __init__(self, from_packet) -> None: ...
+ # TODO: add attrs from `from_packet`
+ def __getattr__(self, key: str): ...
+
+class EOFPacketWrapper:
+ def __init__(self, from_packet) -> None: ...
+ # TODO: add attrs from `from_packet`
+ def __getattr__(self, key: str): ...
+
+class LoadLocalPacketWrapper:
+ def __init__(self, from_packet) -> None: ...
+ # TODO: add attrs from `from_packet`
+ def __getattr__(self, key: str): ...
diff --git a/python/helpers/typeshed/stubs/PyMySQL/pymysql/times.pyi b/python/helpers/typeshed/stubs/PyMySQL/pymysql/times.pyi
index c798e654518f..2c4f86f7ae31 100644
--- a/python/helpers/typeshed/stubs/PyMySQL/pymysql/times.pyi
+++ b/python/helpers/typeshed/stubs/PyMySQL/pymysql/times.pyi
@@ -1,10 +1,10 @@
-from typing import Any
+from datetime import date, datetime, time, timedelta
-Date: Any
-Time: Any
-TimeDelta: Any
-Timestamp: Any
+Date: type[date]
+Time: type[time]
+TimeDelta: type[timedelta]
+Timestamp: type[datetime]
-def DateFromTicks(ticks): ...
-def TimeFromTicks(ticks): ...
-def TimestampFromTicks(ticks): ...
+def DateFromTicks(ticks: float | None) -> date: ...
+def TimeFromTicks(ticks: float | None) -> time: ...
+def TimestampFromTicks(ticks: float | None) -> datetime: ...
diff --git a/python/helpers/typeshed/stubs/PyMySQL/pymysql/util.pyi b/python/helpers/typeshed/stubs/PyMySQL/pymysql/util.pyi
deleted file mode 100644
index 3d9a65b4b2d3..000000000000
--- a/python/helpers/typeshed/stubs/PyMySQL/pymysql/util.pyi
+++ /dev/null
@@ -1,3 +0,0 @@
-def byte2int(b): ...
-def int2byte(i): ...
-def join_bytes(bs): ...
diff --git a/python/helpers/typeshed/stubs/PyScreeze/METADATA.toml b/python/helpers/typeshed/stubs/PyScreeze/METADATA.toml
index efd1ec87729c..723e24d731c9 100644
--- a/python/helpers/typeshed/stubs/PyScreeze/METADATA.toml
+++ b/python/helpers/typeshed/stubs/PyScreeze/METADATA.toml
@@ -4,7 +4,7 @@ requires = ["Pillow>=10.3.0"]
[tool.stubtest]
# Linux has extra constants, win32 has different definitions
-platforms = ["linux", "win32"]
+ci_platforms = ["linux", "win32"]
# PyScreeze has an odd setup.py file
# that doesn't list Pillow as a dependency for py312+ yet:
# https://github.com/asweigart/pyscreeze/blob/eeca245a135cf171c163b3691300138518efa64e/setup.py#L38-L46
diff --git a/python/helpers/typeshed/stubs/PyYAML/yaml/__init__.pyi b/python/helpers/typeshed/stubs/PyYAML/yaml/__init__.pyi
index 883492c73b4b..715d37e4d30e 100644
--- a/python/helpers/typeshed/stubs/PyYAML/yaml/__init__.pyi
+++ b/python/helpers/typeshed/stubs/PyYAML/yaml/__init__.pyi
@@ -428,6 +428,7 @@ class YAMLObjectMetaclass(type):
def __init__(cls, name, bases, kwds) -> None: ...
class YAMLObject(metaclass=YAMLObjectMetaclass):
+ __slots__ = ()
yaml_loader: Any
yaml_dumper: Any
yaml_tag: Any
diff --git a/python/helpers/typeshed/stubs/PyYAML/yaml/emitter.pyi b/python/helpers/typeshed/stubs/PyYAML/yaml/emitter.pyi
index 68808c751095..6d7f2b0e6bd0 100644
--- a/python/helpers/typeshed/stubs/PyYAML/yaml/emitter.pyi
+++ b/python/helpers/typeshed/stubs/PyYAML/yaml/emitter.pyi
@@ -1,5 +1,5 @@
from collections.abc import Callable
-from typing import Any, NoReturn, Protocol, TypeVar
+from typing import Any, NoReturn, Protocol, TypeVar, type_check_only
from yaml.error import YAMLError
@@ -7,6 +7,7 @@ from .events import Event
_T_contra = TypeVar("_T_contra", str, bytes, contravariant=True)
+@type_check_only
class _WriteStream(Protocol[_T_contra]):
def write(self, data: _T_contra, /) -> object: ...
# Optional fields:
@@ -61,24 +62,26 @@ class Emitter:
def __init__(
self,
stream: _WriteStream[Any],
- canonical: bool | None = ...,
- indent: int | None = ...,
- width: int | None = ...,
- allow_unicode: bool | None = ...,
- line_break: str | None = ...,
+ canonical: bool | None = None,
+ indent: int | None = None,
+ width: int | None = None,
+ allow_unicode: bool | None = None,
+ line_break: str | None = None,
) -> None: ...
def dispose(self) -> None: ...
def emit(self, event: Event) -> None: ...
def need_more_events(self) -> bool: ...
def need_events(self, count: int) -> bool: ...
- def increase_indent(self, flow: bool = ..., indentless: bool = ...) -> None: ...
+ def increase_indent(self, flow: bool = False, indentless: bool = False) -> None: ...
def expect_stream_start(self) -> None: ...
def expect_nothing(self) -> NoReturn: ...
def expect_first_document_start(self) -> None: ...
def expect_document_start(self, first: bool = False) -> None: ...
def expect_document_end(self) -> None: ...
def expect_document_root(self) -> None: ...
- def expect_node(self, root: bool = ..., sequence: bool = ..., mapping: bool = ..., simple_key: bool = ...) -> None: ...
+ def expect_node(
+ self, root: bool = False, sequence: bool = False, mapping: bool = False, simple_key: bool = False
+ ) -> None: ...
def expect_alias(self) -> None: ...
def expect_scalar(self) -> None: ...
def expect_flow_sequence(self) -> None: ...
@@ -91,10 +94,10 @@ class Emitter:
def expect_flow_mapping_value(self) -> None: ...
def expect_block_sequence(self) -> None: ...
def expect_first_block_sequence_item(self) -> None: ...
- def expect_block_sequence_item(self, first: bool = ...) -> None: ...
+ def expect_block_sequence_item(self, first: bool = False) -> None: ...
def expect_block_mapping(self) -> None: ...
def expect_first_block_mapping_key(self) -> None: ...
- def expect_block_mapping_key(self, first: bool = ...) -> None: ...
+ def expect_block_mapping_key(self, first: bool = False) -> None: ...
def expect_block_mapping_simple_value(self) -> None: ...
def expect_block_mapping_value(self) -> None: ...
def check_empty_sequence(self) -> bool: ...
@@ -114,17 +117,19 @@ class Emitter:
def flush_stream(self) -> None: ...
def write_stream_start(self) -> None: ...
def write_stream_end(self) -> None: ...
- def write_indicator(self, indicator: str, need_whitespace: bool, whitespace: bool = ..., indention: bool = ...) -> None: ...
+ def write_indicator(
+ self, indicator: str, need_whitespace: bool, whitespace: bool = False, indention: bool = False
+ ) -> None: ...
def write_indent(self) -> None: ...
- def write_line_break(self, data: str | None = ...) -> None: ...
+ def write_line_break(self, data: str | None = None) -> None: ...
def write_version_directive(self, version_text: str) -> None: ...
def write_tag_directive(self, handle_text: str, prefix_text: str) -> None: ...
- def write_single_quoted(self, text: str, split: bool = ...) -> None: ...
+ def write_single_quoted(self, text: str, split: bool = True) -> None: ...
ESCAPE_REPLACEMENTS: dict[str, str]
- def write_double_quoted(self, text: str, split: bool = ...) -> None: ...
+ def write_double_quoted(self, text: str, split: bool = True) -> None: ...
def determine_block_hints(self, text: str) -> str: ...
def write_folded(self, text: str) -> None: ...
def write_literal(self, text: str) -> None: ...
- def write_plain(self, text: str, split: bool = ...) -> None: ...
+ def write_plain(self, text: str, split: bool = True) -> None: ...
__all__ = ["Emitter", "EmitterError"]
diff --git a/python/helpers/typeshed/stubs/Pygments/pygments/formatters/other.pyi b/python/helpers/typeshed/stubs/Pygments/pygments/formatters/other.pyi
index e02007b00c03..b3f42c323c09 100644
--- a/python/helpers/typeshed/stubs/Pygments/pygments/formatters/other.pyi
+++ b/python/helpers/typeshed/stubs/Pygments/pygments/formatters/other.pyi
@@ -10,7 +10,7 @@ class NullFormatter(Formatter[_T]):
filenames: Any
def format(self, tokensource, outfile) -> None: ...
-class RawTokenFormatter(Formatter[_T]):
+class RawTokenFormatter(Formatter[bytes]):
name: str
aliases: Any
filenames: Any
diff --git a/python/helpers/typeshed/stubs/Pygments/pygments/style.pyi b/python/helpers/typeshed/stubs/Pygments/pygments/style.pyi
index e18f2adaee85..154f822ac480 100644
--- a/python/helpers/typeshed/stubs/Pygments/pygments/style.pyi
+++ b/python/helpers/typeshed/stubs/Pygments/pygments/style.pyi
@@ -1,10 +1,11 @@
from collections.abc import Iterator, Mapping, Set as AbstractSet
-from typing import TypedDict
+from typing import TypedDict, type_check_only
from pygments.token import _TokenType
ansicolors: AbstractSet[str] # not intended to be mutable
+@type_check_only
class _StyleDict(TypedDict):
color: str | None
bold: bool
diff --git a/python/helpers/typeshed/stubs/RPi.GPIO/METADATA.toml b/python/helpers/typeshed/stubs/RPi.GPIO/METADATA.toml
index 557e12238713..c70910d69e4e 100644
--- a/python/helpers/typeshed/stubs/RPi.GPIO/METADATA.toml
+++ b/python/helpers/typeshed/stubs/RPi.GPIO/METADATA.toml
@@ -2,7 +2,9 @@ version = "0.7.*"
upstream_repository = "https://sourceforge.net/p/raspberry-gpio-python/code/"
[tool.stubtest]
-# When stubtest tries to import this module:
-# error: RPi.GPIO failed to import. RuntimeError: This module can only be run on a Raspberry Pi!
+# This package is only supported on Raspberry Pi hardware, which identifies
+# itself as 'linux'. When run on other hardware, it raises a RuntimeError:
+# RPi.GPIO failed to import. RuntimeError: This module can only be run on a Raspberry Pi!
# https://sourceforge.net/p/raspberry-gpio-python/code/ci/08048dd1894a6b09a104557b6eaa6bb68b6baac5/tree/source/py_gpio.c#l1008
-skip = true
+supported_platforms = []
+ci_platforms = []
diff --git a/python/helpers/typeshed/stubs/WTForms/wtforms/fields/core.pyi b/python/helpers/typeshed/stubs/WTForms/wtforms/fields/core.pyi
index c0972d0ca399..49966fe751cb 100644
--- a/python/helpers/typeshed/stubs/WTForms/wtforms/fields/core.pyi
+++ b/python/helpers/typeshed/stubs/WTForms/wtforms/fields/core.pyi
@@ -1,6 +1,6 @@
from builtins import type as _type # type is being shadowed in Field
from collections.abc import Callable, Iterable, Sequence
-from typing import Any, Generic, Protocol, TypeVar, overload
+from typing import Any, Generic, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias
from markupsafe import Markup
@@ -16,9 +16,11 @@ _FieldT_contra = TypeVar("_FieldT_contra", bound=Field, contravariant=True)
# trust, that people won't use it to change the type of data in a field...
_Filter: TypeAlias = Callable[[Any], Any]
+@type_check_only
class _Validator(Protocol[_FormT_contra, _FieldT_contra]):
def __call__(self, form: _FormT_contra, field: _FieldT_contra, /) -> object: ...
+@type_check_only
class _Widget(Protocol[_FieldT_contra]):
def __call__(self, field: _FieldT_contra, **kwargs: Any) -> Markup: ...
diff --git a/python/helpers/typeshed/stubs/WTForms/wtforms/form.pyi b/python/helpers/typeshed/stubs/WTForms/wtforms/form.pyi
index c108954471e0..7c47bfe5644a 100644
--- a/python/helpers/typeshed/stubs/WTForms/wtforms/form.pyi
+++ b/python/helpers/typeshed/stubs/WTForms/wtforms/form.pyi
@@ -1,6 +1,6 @@
from _typeshed import SupportsItems
from collections.abc import Iterable, Iterator, Mapping, Sequence
-from typing import Any, ClassVar, Protocol, TypeVar, overload
+from typing import Any, ClassVar, Protocol, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
from wtforms.fields.core import Field, UnboundField
@@ -12,6 +12,7 @@ _FormErrors: TypeAlias = dict[str, Sequence[str] | _FormErrors]
# _unbound_fields will always be a list on an instance, but on a
# class it might be None, if it never has been instantiated, or
# not instantianted after a new field had been added/removed
+@type_check_only
class _UnboundFields(Protocol):
@overload
def __get__(self, obj: None, owner: type[object] | None = None, /) -> list[tuple[str, UnboundField[Any]]] | None: ...
diff --git a/python/helpers/typeshed/stubs/WTForms/wtforms/i18n.pyi b/python/helpers/typeshed/stubs/WTForms/wtforms/i18n.pyi
index a0f5e237e20e..4ebb609168fc 100644
--- a/python/helpers/typeshed/stubs/WTForms/wtforms/i18n.pyi
+++ b/python/helpers/typeshed/stubs/WTForms/wtforms/i18n.pyi
@@ -1,9 +1,10 @@
from collections.abc import Callable, Iterable
from gettext import GNUTranslations
-from typing import Protocol, TypeVar, overload
+from typing import Protocol, TypeVar, overload, type_check_only
_T = TypeVar("_T")
+@type_check_only
class _SupportsUgettextAndUngettext(Protocol):
def ugettext(self, string: str, /) -> str: ...
def ungettext(self, singular: str, plural: str, n: int, /) -> str: ...
diff --git a/python/helpers/typeshed/stubs/WTForms/wtforms/meta.pyi b/python/helpers/typeshed/stubs/WTForms/wtforms/meta.pyi
index 83181cab93f2..e90a6b4fc066 100644
--- a/python/helpers/typeshed/stubs/WTForms/wtforms/meta.pyi
+++ b/python/helpers/typeshed/stubs/WTForms/wtforms/meta.pyi
@@ -1,6 +1,6 @@
from _typeshed import SupportsItems
from collections.abc import Collection, Iterator, MutableMapping
-from typing import Any, Literal, Protocol, TypeVar, overload
+from typing import Any, Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
from markupsafe import Markup
@@ -9,6 +9,7 @@ from wtforms.form import BaseForm
_FieldT = TypeVar("_FieldT", bound=Field)
+@type_check_only
class _SupportsGettextAndNgettext(Protocol):
def gettext(self, string: str, /) -> str: ...
def ngettext(self, singular: str, plural: str, n: int, /) -> str: ...
@@ -16,6 +17,7 @@ class _SupportsGettextAndNgettext(Protocol):
# these are the methods WTForms depends on, the dict can either provide
# a getlist or getall, if it only provides getall, it will wrapped, to
# provide getlist instead
+@type_check_only
class _MultiDictLikeBase(Protocol):
def __iter__(self) -> Iterator[str]: ...
def __len__(self) -> int: ...
@@ -24,9 +26,11 @@ class _MultiDictLikeBase(Protocol):
# since how file uploads are represented in formdata is implementation-specific
# we have to be generous in what we accept in the return of getlist/getall
# we can make this generic if we ever want to be more specific
+@type_check_only
class _MultiDictLikeWithGetlist(_MultiDictLikeBase, Protocol):
def getlist(self, key: str, /) -> list[Any]: ...
+@type_check_only
class _MultiDictLikeWithGetall(_MultiDictLikeBase, Protocol):
def getall(self, key: str, /) -> list[Any]: ...
diff --git a/python/helpers/typeshed/stubs/WebOb/webob/acceptparse.pyi b/python/helpers/typeshed/stubs/WebOb/webob/acceptparse.pyi
index 5b3043e7b2ce..069564e86749 100644
--- a/python/helpers/typeshed/stubs/WebOb/webob/acceptparse.pyi
+++ b/python/helpers/typeshed/stubs/WebOb/webob/acceptparse.pyi
@@ -1,6 +1,6 @@
from _typeshed import SupportsItems
from collections.abc import Callable, Iterable, Iterator, Sequence
-from typing import Any, Literal, NamedTuple, Protocol, TypeVar, overload
+from typing import Any, Literal, NamedTuple, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias
from webob._types import AsymmetricPropertyWithDelete
@@ -9,6 +9,7 @@ _T = TypeVar("_T")
_ListOrTuple: TypeAlias = list[_T] | tuple[_T, ...]
_ParsedAccept: TypeAlias = tuple[str, float, list[tuple[str, str]], list[str | tuple[str, str]]]
+@type_check_only
class _SupportsStr(Protocol):
def __str__(self) -> str: ... # noqa: Y029
diff --git a/python/helpers/typeshed/stubs/WebOb/webob/cachecontrol.pyi b/python/helpers/typeshed/stubs/WebOb/webob/cachecontrol.pyi
index 5b6df1e856b6..47e75e4e4ab8 100644
--- a/python/helpers/typeshed/stubs/WebOb/webob/cachecontrol.pyi
+++ b/python/helpers/typeshed/stubs/WebOb/webob/cachecontrol.pyi
@@ -14,7 +14,10 @@ class UpdateDict(dict[str, Any]):
updated_args: tuple[Any, ...] | None
class exists_property(Generic[_ScopeT]):
- def __init__(self, prop: str, type: _ScopeT = ...) -> None: ...
+ @overload
+ def __init__(self: exists_property[None], prop: str) -> None: ...
+ @overload
+ def __init__(self, prop: str, type: _ScopeT) -> None: ...
@overload
def __get__(self, obj: None, type: type[CacheControl[Any]] | None = None) -> Self: ...
@overload
@@ -31,7 +34,7 @@ class exists_property(Generic[_ScopeT]):
def __delete__(self, obj: CacheControl[_ScopeT]) -> None: ...
class value_property(Generic[_T, _DefaultT, _NoneLiteral, _ScopeT]):
- def __init__(self, prop: str, default: _DefaultT = ..., none: _NoneLiteral = ..., type: _ScopeT = ...) -> None: ...
+ def __init__(self, prop: str, default: _DefaultT = None, none: _NoneLiteral = None, type: _ScopeT = None) -> None: ... # type: ignore[assignment]
@overload
def __get__(self, obj: None, type: type[CacheControl[Any]] | None = None) -> Self: ...
@overload
diff --git a/python/helpers/typeshed/stubs/WebOb/webob/cookies.pyi b/python/helpers/typeshed/stubs/WebOb/webob/cookies.pyi
index 98914a2a70f7..5846b68d9e14 100644
--- a/python/helpers/typeshed/stubs/WebOb/webob/cookies.pyi
+++ b/python/helpers/typeshed/stubs/WebOb/webob/cookies.pyi
@@ -3,7 +3,7 @@ from _typeshed.wsgi import WSGIEnvironment
from collections.abc import Collection, ItemsView, Iterator, KeysView, MutableMapping, ValuesView
from datetime import date, datetime, timedelta
from time import _TimeTuple, struct_time
-from typing import Any, Literal, Protocol, TypeVar, overload
+from typing import Any, Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
from webob._types import AsymmetricProperty
@@ -26,6 +26,7 @@ _T = TypeVar("_T")
# valid spellings, but it seems more natural to support these two spellings
_SameSitePolicy: TypeAlias = Literal["Strict", "Lax", "None", "strict", "lax", "none"]
+@type_check_only
class _Serializer(Protocol):
def dumps(self, appstruct: Any, /) -> bytes: ...
def loads(self, bstruct: bytes, /) -> Any: ...
@@ -37,6 +38,8 @@ class RequestCookies(MutableMapping[str, str]):
@overload
def get(self, name: str, default: None = None) -> str | None: ...
@overload
+ def get(self, name: str, default: str) -> str: ...
+ @overload
def get(self, name: str, default: _T) -> str | _T: ...
def __delitem__(self, name: str) -> None: ...
def keys(self) -> KeysView[str]: ...
@@ -57,6 +60,7 @@ class Cookie(dict[bytes, Morsel]):
def __str__(self, full: bool = True) -> str: ...
class Morsel(dict[bytes, bytes | bool | None]):
+ __slots__ = ("name", "value")
name: bytes
value: bytes
def __init__(self, name: str | bytes, value: str | bytes) -> None: ...
diff --git a/python/helpers/typeshed/stubs/WebOb/webob/dec.pyi b/python/helpers/typeshed/stubs/WebOb/webob/dec.pyi
index 41478ba2fb48..4b5198a46a72 100644
--- a/python/helpers/typeshed/stubs/WebOb/webob/dec.pyi
+++ b/python/helpers/typeshed/stubs/WebOb/webob/dec.pyi
@@ -1,6 +1,6 @@
from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
from collections.abc import Callable, Iterable, Mapping
-from typing import Any, Generic, overload
+from typing import Any, Generic, overload, type_check_only
from typing_extensions import Concatenate, Never, ParamSpec, Self, TypeAlias, TypeVar
from webob.request import BaseRequest, Request
@@ -145,6 +145,7 @@ class wsgify(Generic[_P, _RequestT_contra]):
cls, middle_func: _MiddlewareMethod[_RequestT, _AppT, _P2], app: _AppT, *_: _P2.args, **kw: _P2.kwargs
) -> type[wsgify[Concatenate[_AppT, _P2], _RequestT]]: ...
+@type_check_only
class _unbound_wsgify(wsgify[_P, _RequestT_contra], Generic[_P, _S, _RequestT_contra]):
@overload # type: ignore[override]
def __call__(self, __self: _S, env: WSGIEnvironment, /, start_response: StartResponse) -> Iterable[bytes]: ...
diff --git a/python/helpers/typeshed/stubs/WebOb/webob/exc.pyi b/python/helpers/typeshed/stubs/WebOb/webob/exc.pyi
index da9ee25cf563..d2cdb2f11ce4 100644
--- a/python/helpers/typeshed/stubs/WebOb/webob/exc.pyi
+++ b/python/helpers/typeshed/stubs/WebOb/webob/exc.pyi
@@ -2,7 +2,7 @@ from _typeshed import SupportsItems, SupportsKeysAndGetItem
from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
from collections.abc import Iterable
from string import Template
-from typing import Any, Literal, Protocol
+from typing import Any, Literal, Protocol, type_check_only
from typing_extensions import Self, TypeAlias
from webob.response import Response
@@ -68,6 +68,7 @@ __all__ = [
_Headers: TypeAlias = SupportsItems[str, str] | SupportsKeysAndGetItem[str, str] | Iterable[tuple[str, str]]
+@type_check_only
class _JSONFormatter(Protocol):
def __call__(self, *, body: str, status: str, title: str, environ: WSGIEnvironment) -> Any: ...
diff --git a/python/helpers/typeshed/stubs/WebOb/webob/multidict.pyi b/python/helpers/typeshed/stubs/WebOb/webob/multidict.pyi
index 1b5f3a0466ea..bc5cd2c76138 100644
--- a/python/helpers/typeshed/stubs/WebOb/webob/multidict.pyi
+++ b/python/helpers/typeshed/stubs/WebOb/webob/multidict.pyi
@@ -1,7 +1,7 @@
-from _typeshed import SupportsKeysAndGetItem
+from _typeshed import SupportsGetItem, SupportsKeysAndGetItem
from _typeshed.wsgi import WSGIEnvironment
from collections.abc import Collection, Iterable, Iterator, MutableMapping
-from typing import Literal, Protocol, TypeVar, overload
+from typing import Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Self
from webob.compat import cgi_FieldStorage, cgi_FieldStorage as _FieldStorageWithFile
@@ -14,6 +14,7 @@ _VT = TypeVar("_VT")
_KT_co = TypeVar("_KT_co", covariant=True)
_VT_co = TypeVar("_VT_co", covariant=True)
+@type_check_only
class _SupportsItemsWithIterableResult(Protocol[_KT_co, _VT_co]):
def items(self) -> Iterable[tuple[_KT_co, _VT_co]]: ...
@@ -48,7 +49,9 @@ class MultiDict(MutableMapping[_KT, _VT]):
def __setitem__(self, key: _KT, value: _VT) -> None: ...
def add(self, key: _KT, value: _VT) -> None: ...
@overload
- def get(self, key: _KT) -> _VT | None: ...
+ def get(self, key: _KT, default: None = None) -> _VT | None: ...
+ @overload
+ def get(self, key: _KT, default: _VT) -> _VT: ...
@overload
def get(self, key: _KT, default: _T) -> _VT | _T: ...
def getall(self, key: _KT) -> list[_VT]: ...
@@ -70,11 +73,11 @@ class MultiDict(MutableMapping[_KT, _VT]):
def pop(self, key: _KT, default: _T) -> _VT | _T: ...
def popitem(self) -> tuple[_KT, _VT]: ...
@overload # type: ignore[override]
- def update(self: MultiDict[str, _VT], **kwargs: _VT) -> None: ...
+ def update(self: SupportsGetItem[str, _VT], **kwargs: _VT) -> None: ...
@overload
def update(self, m: Collection[tuple[_KT, _VT]], /) -> None: ...
@overload
- def update(self: MultiDict[str, _VT], m: Collection[tuple[str, _VT]], /, **kwargs: _VT) -> None: ...
+ def update(self: SupportsGetItem[str, _VT], m: Collection[tuple[str, _VT]], /, **kwargs: _VT) -> None: ...
@overload
def extend(self, other: _SupportsItemsWithIterableResult[_KT, _VT]) -> None: ...
@overload
diff --git a/python/helpers/typeshed/stubs/WebOb/webob/request.pyi b/python/helpers/typeshed/stubs/WebOb/webob/request.pyi
index c562838f7b7b..310c2101ce98 100644
--- a/python/helpers/typeshed/stubs/WebOb/webob/request.pyi
+++ b/python/helpers/typeshed/stubs/WebOb/webob/request.pyi
@@ -4,7 +4,7 @@ from _typeshed import OptExcInfo, SupportsKeysAndGetItem, SupportsNoArgReadline,
from _typeshed.wsgi import WSGIApplication, WSGIEnvironment
from collections.abc import Iterable, Mapping
from re import Pattern
-from typing import IO, Any, ClassVar, Literal, Protocol, TypedDict, TypeVar, overload
+from typing import IO, Any, ClassVar, Literal, Protocol, TypedDict, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias
from webob._types import AsymmetricProperty, AsymmetricPropertyWithDelete, SymmetricProperty, SymmetricPropertyWithDelete
@@ -27,8 +27,10 @@ _HTTPMethod: TypeAlias = Literal["GET", "HEAD", "POST", "PUT", "DELETE", "CONNEC
_ListOrTuple: TypeAlias = list[_T] | tuple[_T, ...]
_RequestCacheControl: TypeAlias = CacheControl[Literal["request"]]
+@type_check_only
class _SupportsReadAndNoArgReadline(SupportsRead[str | bytes], SupportsNoArgReadline[str | bytes], Protocol): ...
+@type_check_only
class _RequestCacheControlDict(TypedDict, total=False):
max_stale: int
min_stale: int
diff --git a/python/helpers/typeshed/stubs/WebOb/webob/response.pyi b/python/helpers/typeshed/stubs/WebOb/webob/response.pyi
index 4a22b3530adc..27d1e90dff04 100644
--- a/python/helpers/typeshed/stubs/WebOb/webob/response.pyi
+++ b/python/helpers/typeshed/stubs/WebOb/webob/response.pyi
@@ -2,7 +2,7 @@ from _typeshed import SupportsItems, SupportsRead
from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
from collections.abc import Iterable, Iterator, Sequence
from datetime import timedelta
-from typing import IO, Any, Literal, Protocol, TypedDict, TypeVar, overload
+from typing import IO, Any, Literal, Protocol, TypedDict, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias
from webob._types import AsymmetricProperty, AsymmetricPropertyWithDelete, SymmetricProperty, SymmetricPropertyWithDelete
@@ -18,6 +18,7 @@ __all__ = ["Response"]
_ResponseT = TypeVar("_ResponseT", bound=Response)
_ResponseCacheControl: TypeAlias = CacheControl[Literal["response"]]
+@type_check_only
class _ResponseCacheExpires(Protocol):
def __call__(
self,
@@ -37,6 +38,7 @@ class _ResponseCacheExpires(Protocol):
stale_if_error: int = ...,
) -> None: ...
+@type_check_only
class _ResponseCacheControlDict(TypedDict, total=False):
public: bool
private: Literal[True] | str
diff --git a/python/helpers/typeshed/stubs/aiofiles/METADATA.toml b/python/helpers/typeshed/stubs/aiofiles/METADATA.toml
index d649874b9a1e..fdab36a21cca 100644
--- a/python/helpers/typeshed/stubs/aiofiles/METADATA.toml
+++ b/python/helpers/typeshed/stubs/aiofiles/METADATA.toml
@@ -3,4 +3,4 @@ upstream_repository = "https://github.com/Tinche/aiofiles"
[tool.stubtest]
# linux and darwin are equivalent
-platforms = ["linux", "win32"]
+ci_platforms = ["linux", "win32"]
diff --git a/python/helpers/typeshed/stubs/aiofiles/aiofiles/base.pyi b/python/helpers/typeshed/stubs/aiofiles/aiofiles/base.pyi
index 1de0bbbfdcb1..4a22ddd6f160 100644
--- a/python/helpers/typeshed/stubs/aiofiles/aiofiles/base.pyi
+++ b/python/helpers/typeshed/stubs/aiofiles/aiofiles/base.pyi
@@ -1,4 +1,6 @@
+from asyncio.events import AbstractEventLoop
from collections.abc import Awaitable, Callable, Generator
+from concurrent.futures import Executor
from contextlib import AbstractAsyncContextManager
from types import TracebackType
from typing import Any, BinaryIO, Generic, TextIO, TypeVar
@@ -8,14 +10,17 @@ _T = TypeVar("_T")
_V_co = TypeVar("_V_co", covariant=True)
class AsyncBase(Generic[_T]):
- def __init__(self, file: TextIO | BinaryIO | None, loop: Any, executor: Any) -> None: ...
+ def __init__(self, file: TextIO | BinaryIO | None, loop: AbstractEventLoop | None, executor: Executor | None) -> None: ...
def __aiter__(self) -> Self: ...
async def __anext__(self) -> _T: ...
class AsyncIndirectBase(AsyncBase[_T]):
- def __init__(self, name: str, loop: Any, executor: Any, indirect: Callable[[], TextIO | BinaryIO]) -> None: ...
+ def __init__(
+ self, name: str, loop: AbstractEventLoop | None, executor: Executor | None, indirect: Callable[[], TextIO | BinaryIO]
+ ) -> None: ...
class AiofilesContextManager(Awaitable[_V_co], AbstractAsyncContextManager[_V_co]):
+ __slots__ = ("_coro", "_obj")
def __init__(self, coro: Awaitable[_V_co]) -> None: ...
def __await__(self) -> Generator[Any, Any, _V_co]: ...
async def __aenter__(self) -> _V_co: ...
diff --git a/python/helpers/typeshed/stubs/aiofiles/aiofiles/os.pyi b/python/helpers/typeshed/stubs/aiofiles/aiofiles/os.pyi
index 5a3de3b591f0..1a544a89d0c8 100644
--- a/python/helpers/typeshed/stubs/aiofiles/aiofiles/os.pyi
+++ b/python/helpers/typeshed/stubs/aiofiles/aiofiles/os.pyi
@@ -2,8 +2,9 @@ import sys
from _typeshed import BytesPath, FileDescriptorOrPath, GenericPath, ReadableBuffer, StrOrBytesPath, StrPath
from asyncio.events import AbstractEventLoop
from collections.abc import Sequence
+from concurrent.futures import Executor
from os import _ScandirIterator, stat_result
-from typing import Any, AnyStr, overload
+from typing import AnyStr, overload
from aiofiles import ospath
from aiofiles.ospath import wrap as wrap
@@ -41,7 +42,7 @@ async def stat(
dir_fd: int | None = None,
follow_symlinks: bool = True,
loop: AbstractEventLoop | None = ...,
- executor: Any = ...,
+ executor: Executor | None = ...,
) -> stat_result: ...
async def rename(
src: StrOrBytesPath,
@@ -50,10 +51,10 @@ async def rename(
src_dir_fd: int | None = None,
dst_dir_fd: int | None = None,
loop: AbstractEventLoop | None = ...,
- executor: Any = ...,
+ executor: Executor | None = ...,
) -> None: ...
async def renames(
- old: StrOrBytesPath, new: StrOrBytesPath, loop: AbstractEventLoop | None = ..., executor: Any = ...
+ old: StrOrBytesPath, new: StrOrBytesPath, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...
) -> None: ...
async def replace(
src: StrOrBytesPath,
@@ -62,60 +63,76 @@ async def replace(
src_dir_fd: int | None = None,
dst_dir_fd: int | None = None,
loop: AbstractEventLoop | None = ...,
- executor: Any = ...,
+ executor: Executor | None = ...,
) -> None: ...
async def remove(
- path: StrOrBytesPath, *, dir_fd: int | None = None, loop: AbstractEventLoop | None = ..., executor: Any = ...
+ path: StrOrBytesPath, *, dir_fd: int | None = None, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...
) -> None: ...
async def unlink(
- path: StrOrBytesPath, *, dir_fd: int | None = ..., loop: AbstractEventLoop | None = ..., executor: Any = ...
+ path: StrOrBytesPath, *, dir_fd: int | None = None, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...
) -> None: ...
async def mkdir(
- path: StrOrBytesPath, mode: int = 511, *, dir_fd: int | None = None, loop: AbstractEventLoop | None = ..., executor: Any = ...
+ path: StrOrBytesPath,
+ mode: int = 511,
+ *,
+ dir_fd: int | None = None,
+ loop: AbstractEventLoop | None = ...,
+ executor: Executor | None = ...,
) -> None: ...
async def makedirs(
- name: StrOrBytesPath, mode: int = 511, exist_ok: bool = False, *, loop: AbstractEventLoop | None = ..., executor: Any = ...
+ name: StrOrBytesPath,
+ mode: int = 511,
+ exist_ok: bool = False,
+ *,
+ loop: AbstractEventLoop | None = ...,
+ executor: Executor | None = ...,
) -> None: ...
async def link(
src: StrOrBytesPath,
dst: StrOrBytesPath,
*,
- src_dir_fd: int | None = ...,
- dst_dir_fd: int | None = ...,
- follow_symlinks: bool = ...,
+ src_dir_fd: int | None = None,
+ dst_dir_fd: int | None = None,
+ follow_symlinks: bool = True,
loop: AbstractEventLoop | None = ...,
- executor: Any = ...,
+ executor: Executor | None = ...,
) -> None: ...
async def symlink(
src: StrOrBytesPath,
dst: StrOrBytesPath,
- target_is_directory: bool = ...,
+ target_is_directory: bool = False,
*,
- dir_fd: int | None = ...,
+ dir_fd: int | None = None,
loop: AbstractEventLoop | None = ...,
- executor: Any = ...,
+ executor: Executor | None = ...,
) -> None: ...
async def readlink(
- path: AnyStr, *, dir_fd: int | None = ..., loop: AbstractEventLoop | None = ..., executor: Any = ...
+ path: AnyStr, *, dir_fd: int | None = None, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...
) -> AnyStr: ...
async def rmdir(
- path: StrOrBytesPath, *, dir_fd: int | None = None, loop: AbstractEventLoop | None = ..., executor: Any = ...
+ path: StrOrBytesPath, *, dir_fd: int | None = None, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...
) -> None: ...
-async def removedirs(name: StrOrBytesPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> None: ...
-@overload
-async def scandir(path: None = None, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> _ScandirIterator[str]: ...
-@overload
-async def scandir(path: int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> _ScandirIterator[str]: ...
+async def removedirs(name: StrOrBytesPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...) -> None: ...
@overload
async def scandir(
- path: GenericPath[AnyStr], *, loop: AbstractEventLoop | None = ..., executor: Any = ...
+ path: None = None, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...
+) -> _ScandirIterator[str]: ...
+@overload
+async def scandir(
+ path: int, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...
+) -> _ScandirIterator[str]: ...
+@overload
+async def scandir(
+ path: GenericPath[AnyStr], *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...
) -> _ScandirIterator[AnyStr]: ...
@overload
-async def listdir(path: StrPath | None, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> list[str]: ...
+async def listdir(
+ path: StrPath | None, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...
+) -> list[str]: ...
@overload
-async def listdir(path: BytesPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> list[bytes]: ...
+async def listdir(path: BytesPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...) -> list[bytes]: ...
@overload
-async def listdir(path: int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> list[str]: ...
+async def listdir(path: int, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...) -> list[str]: ...
async def access(
path: FileDescriptorOrPath, mode: int, *, dir_fd: int | None = None, effective_ids: bool = False, follow_symlinks: bool = True
) -> bool: ...
@@ -126,7 +143,13 @@ if sys.platform != "win32":
@overload
async def sendfile(
- out_fd: int, in_fd: int, offset: int | None, count: int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...
+ out_fd: int,
+ in_fd: int,
+ offset: int | None,
+ count: int,
+ *,
+ loop: AbstractEventLoop | None = ...,
+ executor: Executor | None = ...,
) -> int: ...
@overload
async def sendfile(
@@ -134,11 +157,11 @@ if sys.platform != "win32":
in_fd: int,
offset: int,
count: int,
- headers: Sequence[ReadableBuffer] = ...,
- trailers: Sequence[ReadableBuffer] = ...,
- flags: int = ...,
+ headers: Sequence[ReadableBuffer] = (),
+ trailers: Sequence[ReadableBuffer] = (),
+ flags: int = 0,
*,
loop: AbstractEventLoop | None = ...,
- executor: Any = ...,
+ executor: Executor | None = ...,
) -> int: ... # FreeBSD and Mac OS X only
async def statvfs(path: FileDescriptorOrPath) -> statvfs_result: ... # Unix only
diff --git a/python/helpers/typeshed/stubs/aiofiles/aiofiles/ospath.pyi b/python/helpers/typeshed/stubs/aiofiles/aiofiles/ospath.pyi
index a586375369fb..efec48722eed 100644
--- a/python/helpers/typeshed/stubs/aiofiles/aiofiles/ospath.pyi
+++ b/python/helpers/typeshed/stubs/aiofiles/aiofiles/ospath.pyi
@@ -1,23 +1,36 @@
from _typeshed import FileDescriptorOrPath
from asyncio.events import AbstractEventLoop
from collections.abc import Awaitable, Callable
+from concurrent.futures import Executor
from os import PathLike
-from typing import Any, AnyStr, TypeVar
+from typing import AnyStr, TypeVar
_R = TypeVar("_R")
def wrap(func: Callable[..., _R]) -> Callable[..., Awaitable[_R]]: ...
-async def exists(path: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ...
-async def isfile(path: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ...
-async def isdir(s: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ...
+async def exists(
+ path: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...
+) -> bool: ...
+async def isfile(
+ path: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...
+) -> bool: ...
+async def isdir(s: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...) -> bool: ...
async def islink(path: FileDescriptorOrPath) -> bool: ...
async def ismount(path: FileDescriptorOrPath) -> bool: ...
-async def getsize(filename: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> int: ...
-async def getmtime(filename: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> float: ...
-async def getatime(filename: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> float: ...
-async def getctime(filename: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> float: ...
+async def getsize(
+ filename: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...
+) -> int: ...
+async def getmtime(
+ filename: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...
+) -> float: ...
+async def getatime(
+ filename: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...
+) -> float: ...
+async def getctime(
+ filename: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...
+) -> float: ...
async def samefile(
- f1: FileDescriptorOrPath, f2: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...
+ f1: FileDescriptorOrPath, f2: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...
) -> bool: ...
-async def sameopenfile(fp1: int, fp2: int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ...
+async def sameopenfile(fp1: int, fp2: int, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...) -> bool: ...
async def abspath(path: PathLike[AnyStr] | AnyStr) -> AnyStr: ...
diff --git a/python/helpers/typeshed/stubs/aiofiles/aiofiles/tempfile/__init__.pyi b/python/helpers/typeshed/stubs/aiofiles/aiofiles/tempfile/__init__.pyi
index 87692d844b39..6535885ff2f4 100644
--- a/python/helpers/typeshed/stubs/aiofiles/aiofiles/tempfile/__init__.pyi
+++ b/python/helpers/typeshed/stubs/aiofiles/aiofiles/tempfile/__init__.pyi
@@ -10,12 +10,12 @@ from _typeshed import (
StrPath,
)
from asyncio import AbstractEventLoop
+from concurrent.futures import Executor
from typing import AnyStr, Literal, overload
from ..base import AiofilesContextManager
from ..threadpool.binary import AsyncBufferedIOBase, AsyncBufferedReader, AsyncFileIO
from ..threadpool.text import AsyncTextIOWrapper
-from .temptypes import AsyncTemporaryDirectory
# Text mode: always returns AsyncTextIOWrapper
@overload
@@ -28,7 +28,7 @@ def TemporaryFile(
prefix: AnyStr | None = None,
dir: StrOrBytesPath | None = None,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManager[AsyncTextIOWrapper]: ...
# Unbuffered binary: returns a FileIO
@@ -42,7 +42,7 @@ def TemporaryFile(
prefix: AnyStr | None = None,
dir: StrOrBytesPath | None = None,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManager[AsyncFileIO]: ...
# Buffered binary reading/updating: AsyncBufferedReader
@@ -56,7 +56,7 @@ def TemporaryFile(
prefix: AnyStr | None = None,
dir: StrOrBytesPath | None = None,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManager[AsyncBufferedReader]: ...
# Buffered binary writing: AsyncBufferedIOBase
@@ -70,7 +70,7 @@ def TemporaryFile(
prefix: AnyStr | None = None,
dir: StrOrBytesPath | None = None,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManager[AsyncBufferedIOBase]: ...
# 3.12 added `delete_on_close`
@@ -88,7 +88,7 @@ if sys.version_info >= (3, 12):
delete: bool = True,
delete_on_close: bool = True,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManager[AsyncTextIOWrapper]: ...
# Unbuffered binary: returns a FileIO
@@ -104,7 +104,7 @@ if sys.version_info >= (3, 12):
delete: bool = True,
delete_on_close: bool = True,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManager[AsyncFileIO]: ...
# Buffered binary reading/updating: AsyncBufferedReader
@@ -120,7 +120,7 @@ if sys.version_info >= (3, 12):
delete: bool = True,
delete_on_close: bool = True,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManager[AsyncBufferedReader]: ...
# Buffered binary writing: AsyncBufferedIOBase
@@ -136,7 +136,7 @@ if sys.version_info >= (3, 12):
delete: bool = True,
delete_on_close: bool = True,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManager[AsyncBufferedIOBase]: ...
else:
@@ -152,7 +152,7 @@ else:
dir: StrOrBytesPath | None = None,
delete: bool = True,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManager[AsyncTextIOWrapper]: ...
# Unbuffered binary: returns a FileIO
@@ -167,7 +167,7 @@ else:
dir: StrOrBytesPath | None = None,
delete: bool = True,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManager[AsyncFileIO]: ...
# Buffered binary reading/updating: AsyncBufferedReader
@@ -182,7 +182,7 @@ else:
dir: StrOrBytesPath | None = None,
delete: bool = True,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManager[AsyncBufferedReader]: ...
# Buffered binary writing: AsyncBufferedIOBase
@@ -197,7 +197,7 @@ else:
dir: StrOrBytesPath | None = None,
delete: bool = True,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManager[AsyncBufferedIOBase]: ...
# Text mode: always returns AsyncTextIOWrapper
@@ -213,7 +213,7 @@ def SpooledTemporaryFile(
prefix: AnyStr | None = None,
dir: StrOrBytesPath | None = None,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManager[AsyncTextIOWrapper]: ...
@overload
def SpooledTemporaryFile(
@@ -226,7 +226,7 @@ def SpooledTemporaryFile(
prefix: AnyStr | None = None,
dir: StrOrBytesPath | None = None,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManager[AsyncTextIOWrapper]: ...
# Unbuffered binary: returns a FileIO
@@ -242,7 +242,7 @@ def SpooledTemporaryFile(
prefix: AnyStr | None = None,
dir: StrOrBytesPath | None = None,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManager[AsyncFileIO]: ...
@overload
def SpooledTemporaryFile(
@@ -255,7 +255,7 @@ def SpooledTemporaryFile(
prefix: AnyStr | None = None,
dir: StrOrBytesPath | None = None,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManager[AsyncFileIO]: ...
# Buffered binary reading/updating: AsyncBufferedReader
@@ -270,7 +270,7 @@ def SpooledTemporaryFile(
prefix: AnyStr | None = None,
dir: StrOrBytesPath | None = None,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManager[AsyncBufferedReader]: ...
# Buffered binary writing: AsyncBufferedIOBase
@@ -286,7 +286,7 @@ def SpooledTemporaryFile(
prefix: AnyStr | None = None,
dir: StrOrBytesPath | None = None,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManager[AsyncBufferedIOBase]: ...
@overload
def SpooledTemporaryFile(
@@ -299,7 +299,7 @@ def SpooledTemporaryFile(
prefix: AnyStr | None = None,
dir: StrOrBytesPath | None = None,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManager[AsyncBufferedIOBase]: ...
@overload
def TemporaryDirectory(
@@ -307,7 +307,7 @@ def TemporaryDirectory(
prefix: str | None = None,
dir: StrPath | None = None,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManagerTempDir: ...
@overload
def TemporaryDirectory(
@@ -315,10 +315,10 @@ def TemporaryDirectory(
prefix: bytes | None = None,
dir: BytesPath | None = None,
loop: AbstractEventLoop | None = None,
- executor=None,
+ executor: Executor | None = None,
) -> AiofilesContextManagerTempDir: ...
-class AiofilesContextManagerTempDir(AiofilesContextManager[AsyncTemporaryDirectory]):
- async def __aenter__(self) -> str: ... # type: ignore[override]
+class AiofilesContextManagerTempDir(AiofilesContextManager[str]):
+ async def __aenter__(self) -> str: ...
__all__ = ["NamedTemporaryFile", "TemporaryFile", "SpooledTemporaryFile", "TemporaryDirectory"]
diff --git a/python/helpers/typeshed/stubs/aiofiles/aiofiles/tempfile/temptypes.pyi b/python/helpers/typeshed/stubs/aiofiles/aiofiles/tempfile/temptypes.pyi
index 23abf5cbe796..b6f05e13c7ce 100644
--- a/python/helpers/typeshed/stubs/aiofiles/aiofiles/tempfile/temptypes.pyi
+++ b/python/helpers/typeshed/stubs/aiofiles/aiofiles/tempfile/temptypes.pyi
@@ -1,6 +1,7 @@
-from _typeshed import Incomplete, OpenBinaryMode
+from _typeshed import Incomplete, OpenBinaryMode, ReadableBuffer
from asyncio import AbstractEventLoop
from collections.abc import Generator, Iterable
+from concurrent.futures import Executor
from tempfile import TemporaryDirectory
from typing import TypeVar
@@ -14,16 +15,14 @@ from aiofiles.threadpool.utils import (
_T = TypeVar("_T")
class AsyncSpooledTemporaryFile(AsyncBase[_T]):
- def fileno(self) -> Generator[Incomplete, Incomplete, Incomplete]: ...
- def rollover(self) -> Generator[Incomplete, Incomplete, Incomplete]: ...
+ def fileno(self) -> Generator[Incomplete]: ...
+ def rollover(self) -> Generator[Incomplete]: ...
async def close(self) -> None: ...
async def flush(self) -> None: ...
async def isatty(self) -> bool: ...
- # All must return `AnyStr`:
- async def read(self, n: int = ..., /): ...
- async def readline(self, limit: int | None = ..., /): ...
- async def readlines(self, hint: int = ..., /) -> list[Incomplete]: ...
- # ---
+ async def read(self, n: int = ..., /) -> str | bytes: ...
+ async def readline(self, limit: int | None = ..., /) -> str | bytes: ...
+ async def readlines(self, hint: int = ..., /) -> list[str | bytes]: ...
async def seek(self, offset: int, whence: int = ...) -> int: ...
async def tell(self) -> int: ...
async def truncate(self, size: int | None = ...) -> None: ...
@@ -34,18 +33,17 @@ class AsyncSpooledTemporaryFile(AsyncBase[_T]):
@property
def mode(self) -> OpenBinaryMode: ...
@property
- def name(self) -> str: ...
+ def name(self) -> str | bytes: ...
@property
def newlines(self) -> str: ...
- # Both should work with `AnyStr`, like in `tempfile`:
- async def write(self, s) -> int: ...
- async def writelines(self, iterable: Iterable[Incomplete]) -> None: ...
+ async def write(self, s: str | bytes | ReadableBuffer) -> int: ...
+ async def writelines(self, iterable: Iterable[str | bytes | ReadableBuffer]) -> None: ...
class AsyncTemporaryDirectory:
async def cleanup(self) -> None: ...
@property
- def name(self): ... # should be `AnyStr`
+ def name(self) -> str | bytes: ...
def __init__(
- self, file: TemporaryDirectory[Incomplete], loop: AbstractEventLoop | None, executor: Incomplete | None
+ self, file: TemporaryDirectory[Incomplete], loop: AbstractEventLoop | None, executor: Executor | None
) -> None: ...
async def close(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aiofiles/aiofiles/threadpool/binary.pyi b/python/helpers/typeshed/stubs/aiofiles/aiofiles/threadpool/binary.pyi
index d10f98f2a242..2a02d55752ec 100644
--- a/python/helpers/typeshed/stubs/aiofiles/aiofiles/threadpool/binary.pyi
+++ b/python/helpers/typeshed/stubs/aiofiles/aiofiles/threadpool/binary.pyi
@@ -1,11 +1,13 @@
from _typeshed import FileDescriptorOrPath, ReadableBuffer, WriteableBuffer
from collections.abc import Iterable
from io import FileIO
+from typing import type_check_only
from ..base import AsyncBase, AsyncIndirectBase
# This class does not exist at runtime and instead these methods are
# all dynamically patched in.
+@type_check_only
class _UnknownAsyncBinaryIO(AsyncBase[bytes]):
async def close(self) -> None: ...
async def flush(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aiofiles/aiofiles/threadpool/text.pyi b/python/helpers/typeshed/stubs/aiofiles/aiofiles/threadpool/text.pyi
index 6003a0852c31..6c6bf20a408c 100644
--- a/python/helpers/typeshed/stubs/aiofiles/aiofiles/threadpool/text.pyi
+++ b/python/helpers/typeshed/stubs/aiofiles/aiofiles/threadpool/text.pyi
@@ -1,9 +1,10 @@
from _typeshed import FileDescriptorOrPath
from collections.abc import Iterable
-from typing import BinaryIO
+from typing import BinaryIO, type_check_only
from ..base import AsyncBase, AsyncIndirectBase
+@type_check_only
class _UnknownAsyncTextIO(AsyncBase[str]):
async def close(self) -> None: ...
async def flush(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/METADATA.toml b/python/helpers/typeshed/stubs/antlr4-python3-runtime/METADATA.toml
index 9f1f20021b62..8fc5b261fb0c 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/METADATA.toml
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/METADATA.toml
@@ -2,4 +2,4 @@ version = "4.13.*"
upstream_repository = "https://github.com/antlr/antlr4"
[tool.stubtest]
-platforms = ["linux", "win32"]
+ci_platforms = ["linux", "win32"]
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/BufferedTokenStream.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/BufferedTokenStream.pyi
index bf21e75e68a6..aeca2e341ed8 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/BufferedTokenStream.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/BufferedTokenStream.pyi
@@ -8,6 +8,7 @@ Lexer: Incomplete
class TokenStream: ...
class BufferedTokenStream(TokenStream):
+ __slots__ = ("tokenSource", "tokens", "index", "fetchedEOF")
tokenSource: Incomplete
tokens: Incomplete
index: int
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/CommonTokenFactory.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/CommonTokenFactory.pyi
index 5887446c9d92..447f2a6f6274 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/CommonTokenFactory.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/CommonTokenFactory.pyi
@@ -5,6 +5,7 @@ from antlr4.Token import CommonToken as CommonToken
class TokenFactory: ...
class CommonTokenFactory(TokenFactory):
+ __slots__ = "copyText"
DEFAULT: Incomplete
copyText: Incomplete
def __init__(self, copyText: bool = False) -> None: ...
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/CommonTokenStream.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/CommonTokenStream.pyi
index 34abe2d04e8c..304106cd8ba3 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/CommonTokenStream.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/CommonTokenStream.pyi
@@ -5,6 +5,7 @@ from antlr4.Lexer import Lexer as Lexer
from antlr4.Token import Token as Token
class CommonTokenStream(BufferedTokenStream):
+ __slots__ = "channel"
channel: Incomplete
def __init__(self, lexer: Lexer, channel: int = 0) -> None: ...
def adjustSeekIndex(self, i: int) -> int: ...
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/FileStream.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/FileStream.pyi
index c55094a91456..dc759a462f15 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/FileStream.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/FileStream.pyi
@@ -3,6 +3,7 @@ from _typeshed import Incomplete
from antlr4.InputStream import InputStream as InputStream
class FileStream(InputStream):
+ __slots__ = "fileName"
fileName: Incomplete
def __init__(self, fileName: str, encoding: str = "ascii", errors: str = "strict") -> None: ...
def readDataFrom(self, fileName: str, encoding: str, errors: str = "strict"): ...
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/InputStream.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/InputStream.pyi
index d42ed870429c..3a5991e5ba94 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/InputStream.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/InputStream.pyi
@@ -3,6 +3,7 @@ from _typeshed import Incomplete
from antlr4.Token import Token as Token
class InputStream:
+ __slots__ = ("name", "strdata", "_index", "data", "_size")
name: str
strdata: Incomplete
data: Incomplete
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/IntervalSet.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/IntervalSet.pyi
index 6a6d56fdf83b..2b84ca4e317e 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/IntervalSet.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/IntervalSet.pyi
@@ -1,6 +1,7 @@
from antlr4.Token import Token as Token
class IntervalSet:
+ __slots__ = ("intervals", "readonly")
intervals: list[range] | None
readonly: bool
def __init__(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/LL1Analyzer.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/LL1Analyzer.pyi
index 1963fd468b85..5742e60131ca 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/LL1Analyzer.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/LL1Analyzer.pyi
@@ -19,6 +19,7 @@ from antlr4.RuleContext import RuleContext as RuleContext
from antlr4.Token import Token as Token
class LL1Analyzer:
+ __slots__ = "atn"
HIT_PRED: Incomplete
atn: Incomplete
def __init__(self, atn: ATN) -> None: ...
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/Lexer.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/Lexer.pyi
index 41a63716ffff..1ac2177ffbad 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/Lexer.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/Lexer.pyi
@@ -15,6 +15,22 @@ from antlr4.Token import Token as Token
class TokenSource: ...
class Lexer(Recognizer, TokenSource):
+ __slots__ = (
+ "_input",
+ "_output",
+ "_factory",
+ "_tokenFactorySourcePair",
+ "_token",
+ "_tokenStartCharIndex",
+ "_tokenStartLine",
+ "_tokenStartColumn",
+ "_hitEOF",
+ "_channel",
+ "_type",
+ "_modeStack",
+ "_mode",
+ "_text",
+ )
DEFAULT_MODE: int
MORE: int
SKIP: int
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/ListTokenSource.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/ListTokenSource.pyi
index 935f1b738024..e327864814cc 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/ListTokenSource.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/ListTokenSource.pyi
@@ -5,6 +5,7 @@ from antlr4.Lexer import TokenSource as TokenSource
from antlr4.Token import Token as Token
class ListTokenSource(TokenSource):
+ __slots__ = ("tokens", "sourceName", "pos", "eofToken", "_factory")
tokens: Incomplete
sourceName: Incomplete
pos: int
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/Parser.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/Parser.pyi
index 2a89284c5a68..42cf6443cc97 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/Parser.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/Parser.pyi
@@ -20,6 +20,7 @@ from antlr4.tree.ParseTreePatternMatcher import ParseTreePatternMatcher as Parse
from antlr4.tree.Tree import ErrorNode as ErrorNode, ParseTreeListener as ParseTreeListener, TerminalNode as TerminalNode
class TraceListener(ParseTreeListener):
+ __slots__ = "_parser"
def __init__(self, parser) -> None: ...
def enterEveryRule(self, ctx) -> None: ...
def visitTerminal(self, node) -> None: ...
@@ -27,6 +28,17 @@ class TraceListener(ParseTreeListener):
def exitEveryRule(self, ctx) -> None: ...
class Parser(Recognizer):
+ __slots__ = (
+ "_input",
+ "_output",
+ "_errHandler",
+ "_precedenceStack",
+ "_ctx",
+ "buildParseTrees",
+ "_tracer",
+ "_parseListeners",
+ "_syntaxErrors",
+ )
bypassAltsAtnCache: Incomplete
buildParseTrees: bool
def __init__(self, input: TokenStream, output: TextIO = ...) -> None: ...
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/ParserInterpreter.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/ParserInterpreter.pyi
index 4405ed5dfa6e..b7dabbc4aa33 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/ParserInterpreter.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/ParserInterpreter.pyi
@@ -18,6 +18,16 @@ from antlr4.PredictionContext import PredictionContextCache as PredictionContext
from antlr4.Token import Token as Token
class ParserInterpreter(Parser):
+ __slots__ = (
+ "grammarFileName",
+ "atn",
+ "tokenNames",
+ "ruleNames",
+ "decisionToDFA",
+ "sharedContextCache",
+ "_parentContextStack",
+ "pushRecursionContextStates",
+ )
grammarFileName: Incomplete
atn: Incomplete
tokenNames: Incomplete
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/ParserRuleContext.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/ParserRuleContext.pyi
index b687a84d2713..73c5c5d752b4 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/ParserRuleContext.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/ParserRuleContext.pyi
@@ -13,6 +13,7 @@ from antlr4.tree.Tree import (
)
class ParserRuleContext(RuleContext):
+ __slots__ = ("children", "start", "stop", "exception")
children: Incomplete
start: Incomplete
stop: Incomplete
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/Recognizer.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/Recognizer.pyi
index b671ec91105f..5e9fcc8bc086 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/Recognizer.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/Recognizer.pyi
@@ -5,6 +5,7 @@ from antlr4.RuleContext import RuleContext as RuleContext
from antlr4.Token import Token as Token
class Recognizer:
+ __slots__ = ("_listeners", "_interp", "_stateNumber")
tokenTypeMapCache: Incomplete
ruleIndexMapCache: Incomplete
def __init__(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/RuleContext.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/RuleContext.pyi
index 178d903f0dfe..c7bb19b4e31e 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/RuleContext.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/RuleContext.pyi
@@ -7,6 +7,7 @@ from antlr4.tree.Trees import Trees as Trees
Parser: Incomplete
class RuleContext(RuleNode):
+ __slots__ = ("parentCtx", "invokingState")
EMPTY: Incomplete
parentCtx: Incomplete
invokingState: Incomplete
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/Token.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/Token.pyi
index 8f93ed2564b1..3ca3b3c58eee 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/Token.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/Token.pyi
@@ -1,6 +1,7 @@
from _typeshed import Incomplete
class Token:
+ __slots__ = ("source", "type", "channel", "start", "stop", "tokenIndex", "line", "column", "_text")
INVALID_TYPE: int
EPSILON: int
MIN_USER_TOKEN_TYPE: int
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/TokenStreamRewriter.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/TokenStreamRewriter.pyi
index 92aa2a6ccc69..81e2601e7be6 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/TokenStreamRewriter.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/TokenStreamRewriter.pyi
@@ -4,6 +4,7 @@ from antlr4.CommonTokenStream import CommonTokenStream as CommonTokenStream
from antlr4.Token import Token as Token
class TokenStreamRewriter:
+ __slots__ = ("tokens", "programs", "lastRewriteTokenIndexes")
DEFAULT_PROGRAM_NAME: str
PROGRAM_INIT_SIZE: int
MIN_TOKEN_INDEX: int
@@ -34,6 +35,7 @@ class TokenStreamRewriter:
def getText(self, program_name, start: int, stop: int): ...
class RewriteOperation:
+ __slots__ = ("tokens", "index", "text", "instructionIndex")
tokens: Incomplete
index: Incomplete
text: Incomplete
@@ -48,6 +50,7 @@ class TokenStreamRewriter:
class InsertAfterOp(InsertBeforeOp): ...
class ReplaceOp(RewriteOperation):
+ __slots__ = "last_index"
last_index: Incomplete
def __init__(self, from_idx, to_idx, tokens, text) -> None: ...
def execute(self, buf): ...
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATN.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATN.pyi
index cdef3f41715d..f0951194380c 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATN.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATN.pyi
@@ -7,6 +7,18 @@ from antlr4.RuleContext import RuleContext as RuleContext
from antlr4.Token import Token as Token
class ATN:
+ __slots__ = (
+ "grammarType",
+ "maxTokenType",
+ "states",
+ "decisionToState",
+ "ruleToStartState",
+ "ruleToStopState",
+ "modeNameToStartState",
+ "ruleToTokenType",
+ "lexerActions",
+ "modeToStartState",
+ )
INVALID_ALT_NUMBER: int
grammarType: Incomplete
maxTokenType: Incomplete
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNConfig.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNConfig.pyi
index 99018332d164..12046c969e40 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNConfig.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNConfig.pyi
@@ -6,6 +6,7 @@ from antlr4.atn.SemanticContext import SemanticContext as SemanticContext
from antlr4.PredictionContext import PredictionContext as PredictionContext
class ATNConfig:
+ __slots__ = ("state", "alt", "context", "semanticContext", "reachesIntoOuterContext", "precedenceFilterSuppressed")
state: Incomplete
alt: Incomplete
context: Incomplete
@@ -26,6 +27,7 @@ class ATNConfig:
def equalsForConfigSet(self, other): ...
class LexerATNConfig(ATNConfig):
+ __slots__ = ("lexerActionExecutor", "passedThroughNonGreedyDecision")
lexerActionExecutor: Incomplete
passedThroughNonGreedyDecision: Incomplete
def __init__(
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNConfigSet.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNConfigSet.pyi
index 0c7ac52b273d..aa82c295ce57 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNConfigSet.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNConfigSet.pyi
@@ -13,6 +13,17 @@ from antlr4.Utils import str_list as str_list
ATNSimulator: Incomplete
class ATNConfigSet:
+ __slots__ = (
+ "configLookup",
+ "fullCtx",
+ "readonly",
+ "configs",
+ "uniqueAlt",
+ "conflictingAlts",
+ "hasSemanticContext",
+ "dipsIntoOuterContext",
+ "cachedHashCode",
+ )
configLookup: Incomplete
fullCtx: Incomplete
readonly: bool
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNDeserializationOptions.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNDeserializationOptions.pyi
index e1834444b474..9a2021cd7d67 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNDeserializationOptions.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNDeserializationOptions.pyi
@@ -1,6 +1,7 @@
from _typeshed import Incomplete
class ATNDeserializationOptions:
+ __slots__ = ("readonly", "verifyATN", "generateRuleBypassTransitions")
defaultOptions: Incomplete
readonly: bool
verifyATN: Incomplete
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNDeserializer.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNDeserializer.pyi
index 8c2a67e5a627..ed6b48bf8f84 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNDeserializer.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNDeserializer.pyi
@@ -11,6 +11,7 @@ from antlr4.Token import Token as Token
SERIALIZED_VERSION: int
class ATNDeserializer:
+ __slots__ = ("deserializationOptions", "data", "pos")
deserializationOptions: Incomplete
def __init__(self, options: ATNDeserializationOptions | None = None) -> None: ...
data: Incomplete
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNSimulator.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNSimulator.pyi
index 11fbfe7b0705..2ca0b846e9c9 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNSimulator.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNSimulator.pyi
@@ -10,6 +10,7 @@ from antlr4.PredictionContext import (
)
class ATNSimulator:
+ __slots__ = ("atn", "sharedContextCache", "__dict__")
ERROR: Incomplete
atn: Incomplete
sharedContextCache: Incomplete
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNState.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNState.pyi
index 79b7e4818b3a..5b432fa26026 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNState.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ATNState.pyi
@@ -5,6 +5,7 @@ from antlr4.atn.Transition import Transition as Transition
INITIAL_NUM_TRANSITIONS: int
class ATNState:
+ __slots__ = ("atn", "stateNumber", "stateType", "ruleIndex", "epsilonOnlyTransitions", "transitions", "nextTokenWithinRule")
INVALID_TYPE: int
BASIC: int
RULE_START: int
@@ -39,11 +40,13 @@ class BasicState(ATNState):
def __init__(self) -> None: ...
class DecisionState(ATNState):
+ __slots__ = ("decision", "nonGreedy")
decision: int
nonGreedy: bool
def __init__(self) -> None: ...
class BlockStartState(DecisionState):
+ __slots__ = "endState"
endState: Incomplete
def __init__(self) -> None: ...
@@ -52,6 +55,7 @@ class BasicBlockStartState(BlockStartState):
def __init__(self) -> None: ...
class BlockEndState(ATNState):
+ __slots__ = "startState"
stateType: Incomplete
startState: Incomplete
def __init__(self) -> None: ...
@@ -61,6 +65,7 @@ class RuleStopState(ATNState):
def __init__(self) -> None: ...
class RuleStartState(ATNState):
+ __slots__ = ("stopState", "isPrecedenceRule")
stateType: Incomplete
stopState: Incomplete
isPrecedenceRule: bool
@@ -71,6 +76,7 @@ class PlusLoopbackState(DecisionState):
def __init__(self) -> None: ...
class PlusBlockStartState(BlockStartState):
+ __slots__ = "loopBackState"
stateType: Incomplete
loopBackState: Incomplete
def __init__(self) -> None: ...
@@ -84,12 +90,14 @@ class StarLoopbackState(ATNState):
def __init__(self) -> None: ...
class StarLoopEntryState(DecisionState):
+ __slots__ = ("loopBackState", "isPrecedenceDecision")
stateType: Incomplete
loopBackState: Incomplete
isPrecedenceDecision: Incomplete
def __init__(self) -> None: ...
class LoopEndState(ATNState):
+ __slots__ = "loopBackState"
stateType: Incomplete
loopBackState: Incomplete
def __init__(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/LexerATNSimulator.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/LexerATNSimulator.pyi
index f7bd7e42de2b..0a00ea8445ff 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/LexerATNSimulator.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/LexerATNSimulator.pyi
@@ -22,6 +22,7 @@ from antlr4.PredictionContext import (
from antlr4.Token import Token as Token
class SimState:
+ __slots__ = ("index", "line", "column", "dfaState")
def __init__(self) -> None: ...
index: int
line: int
@@ -30,6 +31,7 @@ class SimState:
def reset(self) -> None: ...
class LexerATNSimulator(ATNSimulator):
+ __slots__ = ("decisionToDFA", "recog", "startIndex", "line", "column", "mode", "DEFAULT_MODE", "MAX_CHAR_VALUE", "prevAccept")
debug: bool
dfa_debug: bool
MIN_DFA_EDGE: int
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/LexerAction.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/LexerAction.pyi
index 4e97dd9e548f..255a96f31eb8 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/LexerAction.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/LexerAction.pyi
@@ -14,6 +14,7 @@ class LexerActionType(IntEnum):
TYPE = 7
class LexerAction:
+ __slots__ = ("actionType", "isPositionDependent")
actionType: Incomplete
isPositionDependent: bool
def __init__(self, action: LexerActionType) -> None: ...
@@ -26,6 +27,7 @@ class LexerSkipAction(LexerAction):
def execute(self, lexer: Lexer): ...
class LexerTypeAction(LexerAction):
+ __slots__ = "type"
type: Incomplete
def __init__(self, type: int) -> None: ...
def execute(self, lexer: Lexer): ...
@@ -33,6 +35,7 @@ class LexerTypeAction(LexerAction):
def __eq__(self, other): ...
class LexerPushModeAction(LexerAction):
+ __slots__ = "mode"
mode: Incomplete
def __init__(self, mode: int) -> None: ...
def execute(self, lexer: Lexer): ...
@@ -50,6 +53,7 @@ class LexerMoreAction(LexerAction):
def execute(self, lexer: Lexer): ...
class LexerModeAction(LexerAction):
+ __slots__ = "mode"
mode: Incomplete
def __init__(self, mode: int) -> None: ...
def execute(self, lexer: Lexer): ...
@@ -57,6 +61,7 @@ class LexerModeAction(LexerAction):
def __eq__(self, other): ...
class LexerCustomAction(LexerAction):
+ __slots__ = ("ruleIndex", "actionIndex")
ruleIndex: Incomplete
actionIndex: Incomplete
isPositionDependent: bool
@@ -66,6 +71,7 @@ class LexerCustomAction(LexerAction):
def __eq__(self, other): ...
class LexerChannelAction(LexerAction):
+ __slots__ = "channel"
channel: Incomplete
def __init__(self, channel: int) -> None: ...
def execute(self, lexer: Lexer): ...
@@ -73,6 +79,7 @@ class LexerChannelAction(LexerAction):
def __eq__(self, other): ...
class LexerIndexedCustomAction(LexerAction):
+ __slots__ = ("offset", "action")
offset: Incomplete
action: Incomplete
isPositionDependent: bool
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/LexerActionExecutor.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/LexerActionExecutor.pyi
index 2cfa6d63c2de..ff09dd23e400 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/LexerActionExecutor.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/LexerActionExecutor.pyi
@@ -4,6 +4,7 @@ from antlr4.atn.LexerAction import LexerAction as LexerAction, LexerIndexedCusto
from antlr4.InputStream import InputStream as InputStream
class LexerActionExecutor:
+ __slots__ = ("lexerActions", "hashCode")
lexerActions: Incomplete
hashCode: Incomplete
def __init__(self, lexerActions: list[LexerAction] = []) -> None: ...
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ParserATNSimulator.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ParserATNSimulator.pyi
index 824700785e60..aa990870ce3c 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ParserATNSimulator.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/ParserATNSimulator.pyi
@@ -34,6 +34,7 @@ from antlr4.Token import Token as Token
from antlr4.Utils import str_list as str_list
class ParserATNSimulator(ATNSimulator):
+ __slots__ = ("parser", "decisionToDFA", "predictionMode", "_input", "_startIndex", "_outerContext", "_dfa", "mergeCache")
debug: bool
trace_atn_sim: bool
dfa_debug: bool
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/SemanticContext.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/SemanticContext.pyi
index 7fb59cd568f0..01f9acf5b0af 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/SemanticContext.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/SemanticContext.pyi
@@ -15,6 +15,7 @@ def filterPrecedencePredicates(collection: set[SemanticContext]): ...
class EmptySemanticContext(SemanticContext): ...
class Predicate(SemanticContext):
+ __slots__ = ("ruleIndex", "predIndex", "isCtxDependent")
ruleIndex: Incomplete
predIndex: Incomplete
isCtxDependent: Incomplete
@@ -33,6 +34,7 @@ class PrecedencePredicate(SemanticContext):
def __eq__(self, other): ...
class AND(SemanticContext):
+ __slots__ = "opnds"
opnds: Incomplete
def __init__(self, a: SemanticContext, b: SemanticContext) -> None: ...
def __eq__(self, other): ...
@@ -41,6 +43,7 @@ class AND(SemanticContext):
def evalPrecedence(self, parser: Recognizer, outerContext: RuleContext): ...
class OR(SemanticContext):
+ __slots__ = "opnds"
opnds: Incomplete
def __init__(self, a: SemanticContext, b: SemanticContext) -> None: ...
def __eq__(self, other): ...
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/Transition.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/Transition.pyi
index 9e2a8a57bcde..608da7480780 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/Transition.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/atn/Transition.pyi
@@ -4,6 +4,7 @@ from antlr4.atn.ATNState import RuleStartState
from antlr4.IntervalSet import IntervalSet
class Transition:
+ __slots__ = ("target", "isEpsilon", "label")
EPSILON: int
RANGE: int
RULE: int
@@ -22,6 +23,7 @@ class Transition:
def __init__(self, target) -> None: ...
class AtomTransition(Transition):
+ __slots__ = ("label_", "serializationType")
label_: Incomplete
label: Incomplete
serializationType: Incomplete
@@ -30,6 +32,7 @@ class AtomTransition(Transition):
def matches(self, symbol: int, minVocabSymbol: int, maxVocabSymbol: int): ...
class RuleTransition(Transition):
+ __slots__ = ("ruleIndex", "precedence", "followState", "serializationType")
ruleIndex: Incomplete
precedence: Incomplete
followState: Incomplete
@@ -39,6 +42,7 @@ class RuleTransition(Transition):
def matches(self, symbol: int, minVocabSymbol: int, maxVocabSymbol: int): ...
class EpsilonTransition(Transition):
+ __slots__ = ("serializationType", "outermostPrecedenceReturn")
serializationType: Incomplete
isEpsilon: bool
outermostPrecedenceReturn: Incomplete
@@ -46,6 +50,7 @@ class EpsilonTransition(Transition):
def matches(self, symbol: int, minVocabSymbol: int, maxVocabSymbol: int): ...
class RangeTransition(Transition):
+ __slots__ = ("serializationType", "start", "stop")
serializationType: Incomplete
start: Incomplete
stop: Incomplete
@@ -58,6 +63,7 @@ class AbstractPredicateTransition(Transition):
def __init__(self, target) -> None: ...
class PredicateTransition(AbstractPredicateTransition):
+ __slots__ = ("serializationType", "ruleIndex", "predIndex", "isCtxDependent")
serializationType: Incomplete
ruleIndex: Incomplete
predIndex: Incomplete
@@ -68,6 +74,7 @@ class PredicateTransition(AbstractPredicateTransition):
def getPredicate(self): ...
class ActionTransition(Transition):
+ __slots__ = ("serializationType", "ruleIndex", "actionIndex", "isCtxDependent")
serializationType: Incomplete
ruleIndex: Incomplete
actionIndex: Incomplete
@@ -77,6 +84,7 @@ class ActionTransition(Transition):
def matches(self, symbol: int, minVocabSymbol: int, maxVocabSymbol: int): ...
class SetTransition(Transition):
+ __slots__ = "serializationType"
serializationType: Incomplete
label: Incomplete
def __init__(self, target, set: IntervalSet) -> None: ...
@@ -88,11 +96,13 @@ class NotSetTransition(SetTransition):
def matches(self, symbol: int, minVocabSymbol: int, maxVocabSymbol: int): ...
class WildcardTransition(Transition):
+ __slots__ = "serializationType"
serializationType: Incomplete
def __init__(self, target) -> None: ...
def matches(self, symbol: int, minVocabSymbol: int, maxVocabSymbol: int): ...
class PrecedencePredicateTransition(AbstractPredicateTransition):
+ __slots__ = ("serializationType", "precedence")
serializationType: Incomplete
precedence: Incomplete
isEpsilon: bool
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/dfa/DFA.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/dfa/DFA.pyi
index 86abf9a72b44..b18b49cb941d 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/dfa/DFA.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/dfa/DFA.pyi
@@ -6,6 +6,7 @@ from antlr4.dfa.DFAState import DFAState as DFAState
from antlr4.error.Errors import IllegalStateException as IllegalStateException
class DFA:
+ __slots__ = ("atnStartState", "decision", "_states", "s0", "precedenceDfa")
atnStartState: Incomplete
decision: Incomplete
s0: Incomplete
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/dfa/DFASerializer.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/dfa/DFASerializer.pyi
index 6d9aac86d3d2..efd431df7eaf 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/dfa/DFASerializer.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/dfa/DFASerializer.pyi
@@ -5,6 +5,7 @@ from antlr4.dfa.DFAState import DFAState as DFAState
from antlr4.Utils import str_list as str_list
class DFASerializer:
+ __slots__ = ("dfa", "literalNames", "symbolicNames")
dfa: Incomplete
literalNames: list[str] | None
symbolicNames: list[str] | None
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/dfa/DFAState.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/dfa/DFAState.pyi
index d70d1a38c7b2..55eff18b7840 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/dfa/DFAState.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/dfa/DFAState.pyi
@@ -4,11 +4,22 @@ from antlr4.atn.ATNConfigSet import ATNConfigSet as ATNConfigSet
from antlr4.atn.SemanticContext import SemanticContext as SemanticContext
class PredPrediction:
+ __slots__ = ("alt", "pred")
alt: Incomplete
pred: Incomplete
def __init__(self, pred: SemanticContext, alt: int) -> None: ...
class DFAState:
+ __slots__ = (
+ "stateNumber",
+ "configs",
+ "edges",
+ "isAcceptState",
+ "prediction",
+ "lexerActionExecutor",
+ "requiresFullContext",
+ "predicates",
+ )
stateNumber: Incomplete
configs: Incomplete
edges: Incomplete
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/Chunk.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/Chunk.pyi
index a8f1b30f938f..be68b31898e7 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/Chunk.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/Chunk.pyi
@@ -3,10 +3,12 @@ from _typeshed import Incomplete
class Chunk: ...
class TagChunk(Chunk):
+ __slots__ = ("tag", "label")
tag: Incomplete
label: Incomplete
def __init__(self, tag: str, label: str | None = None) -> None: ...
class TextChunk(Chunk):
+ __slots__ = "text"
text: Incomplete
def __init__(self, text: str) -> None: ...
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/ParseTreeMatch.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/ParseTreeMatch.pyi
index 23e09c3dd752..71b3dd76899e 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/ParseTreeMatch.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/ParseTreeMatch.pyi
@@ -4,6 +4,7 @@ from antlr4.tree.ParseTreePattern import ParseTreePattern as ParseTreePattern
from antlr4.tree.Tree import ParseTree as ParseTree
class ParseTreeMatch:
+ __slots__ = ("tree", "pattern", "labels", "mismatchedNode")
tree: Incomplete
pattern: Incomplete
labels: Incomplete
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/ParseTreePattern.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/ParseTreePattern.pyi
index d50da5c95c09..ef542c0e1288 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/ParseTreePattern.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/ParseTreePattern.pyi
@@ -5,6 +5,7 @@ from antlr4.tree.Tree import ParseTree as ParseTree
from antlr4.xpath.XPathLexer import XPathLexer as XPathLexer
class ParseTreePattern:
+ __slots__ = ("matcher", "patternRuleIndex", "pattern", "patternTree")
matcher: Incomplete
patternRuleIndex: Incomplete
pattern: Incomplete
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/ParseTreePatternMatcher.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/ParseTreePatternMatcher.pyi
index 392d7be9b31b..0d94f19c0ec0 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/ParseTreePatternMatcher.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/ParseTreePatternMatcher.pyi
@@ -25,6 +25,7 @@ class CannotInvokeStartRule(Exception):
class StartRuleDoesNotConsumeFullPattern(Exception): ...
class ParseTreePatternMatcher:
+ __slots__ = ("lexer", "parser", "start", "stop", "escape")
lexer: Incomplete
parser: Incomplete
start: str
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/RuleTagToken.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/RuleTagToken.pyi
index 12358ca0b9d8..0594ab3c4f37 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/RuleTagToken.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/RuleTagToken.pyi
@@ -3,6 +3,7 @@ from _typeshed import Incomplete
from antlr4.Token import Token as Token
class RuleTagToken(Token):
+ __slots__ = ("label", "ruleName")
source: Incomplete
type: Incomplete
channel: Incomplete
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/TokenTagToken.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/TokenTagToken.pyi
index ff76088ca935..902d685b8418 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/TokenTagToken.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/TokenTagToken.pyi
@@ -3,6 +3,7 @@ from _typeshed import Incomplete
from antlr4.Token import CommonToken as CommonToken
class TokenTagToken(CommonToken):
+ __slots__ = ("tokenName", "label")
tokenName: Incomplete
label: Incomplete
def __init__(self, tokenName: str, type: int, label: str | None = None) -> None: ...
diff --git a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/Tree.pyi b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/Tree.pyi
index 8ec130b45133..c50e70da5897 100644
--- a/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/Tree.pyi
+++ b/python/helpers/typeshed/stubs/antlr4-python3-runtime/antlr4/tree/Tree.pyi
@@ -27,6 +27,7 @@ class ParseTreeListener:
def exitEveryRule(self, ctx): ...
class TerminalNodeImpl(TerminalNode):
+ __slots__ = ("parentCtx", "symbol")
parentCtx: Incomplete
symbol: Incomplete
def __init__(self, symbol: Token) -> None: ...
diff --git a/python/helpers/typeshed/stubs/auth0-python/METADATA.toml b/python/helpers/typeshed/stubs/auth0-python/METADATA.toml
index 8ef32734a656..4e1606df7422 100644
--- a/python/helpers/typeshed/stubs/auth0-python/METADATA.toml
+++ b/python/helpers/typeshed/stubs/auth0-python/METADATA.toml
@@ -1,3 +1,3 @@
-version = "4.9.*"
+version = "4.10.*"
upstream_repository = "https://github.com/auth0/auth0-python"
requires = ["cryptography", "types-requests"]
diff --git a/python/helpers/typeshed/stubs/auth0-python/auth0/authentication/back_channel_login.pyi b/python/helpers/typeshed/stubs/auth0-python/auth0/authentication/back_channel_login.pyi
index e59412243dc7..0f5004a431ad 100644
--- a/python/helpers/typeshed/stubs/auth0-python/auth0/authentication/back_channel_login.pyi
+++ b/python/helpers/typeshed/stubs/auth0-python/auth0/authentication/back_channel_login.pyi
@@ -1,4 +1,13 @@
+from _typeshed import Incomplete
+
from .base import AuthenticationBase
class BackChannelLogin(AuthenticationBase):
- def back_channel_login(self, binding_message: str, login_hint: str, scope: str, **kwargs): ...
+ def back_channel_login(
+ self,
+ binding_message: str,
+ login_hint: str,
+ scope: str,
+ authorization_details: str | list[dict[str, Incomplete]] | None = None,
+ **kwargs,
+ ): ...
diff --git a/python/helpers/typeshed/stubs/auth0-python/auth0/authentication/token_verifier.pyi b/python/helpers/typeshed/stubs/auth0-python/auth0/authentication/token_verifier.pyi
index 9cec21490065..8ce69a71fa9d 100644
--- a/python/helpers/typeshed/stubs/auth0-python/auth0/authentication/token_verifier.pyi
+++ b/python/helpers/typeshed/stubs/auth0-python/auth0/authentication/token_verifier.pyi
@@ -11,11 +11,11 @@ class SymmetricSignatureVerifier(SignatureVerifier):
class JwksFetcher:
CACHE_TTL: ClassVar[int]
- def __init__(self, jwks_url: str, cache_ttl: int = ...) -> None: ...
+ def __init__(self, jwks_url: str, cache_ttl: int = 600) -> None: ...
def get_key(self, key_id: str): ...
class AsymmetricSignatureVerifier(SignatureVerifier):
- def __init__(self, jwks_url: str, algorithm: str = "RS256", cache_ttl: int = ...) -> None: ...
+ def __init__(self, jwks_url: str, algorithm: str = "RS256", cache_ttl: int = 600) -> None: ...
class TokenVerifier:
iss: str
diff --git a/python/helpers/typeshed/stubs/auth0-python/auth0/management/__init__.pyi b/python/helpers/typeshed/stubs/auth0-python/auth0/management/__init__.pyi
index 942a94fa070a..ef02c99b9d43 100644
--- a/python/helpers/typeshed/stubs/auth0-python/auth0/management/__init__.pyi
+++ b/python/helpers/typeshed/stubs/auth0-python/auth0/management/__init__.pyi
@@ -22,6 +22,7 @@ from .resource_servers import ResourceServers
from .roles import Roles
from .rules import Rules
from .rules_configs import RulesConfigs
+from .self_service_profiles import SelfServiceProfiles
from .stats import Stats
from .tenants import Tenants
from .tickets import Tickets
@@ -54,6 +55,7 @@ __all__ = (
"Roles",
"RulesConfigs",
"Rules",
+ "SelfServiceProfiles",
"Stats",
"Tenants",
"Tickets",
diff --git a/python/helpers/typeshed/stubs/auth0-python/auth0/management/auth0.pyi b/python/helpers/typeshed/stubs/auth0-python/auth0/management/auth0.pyi
index f3d7d22ddb26..817d1700cc93 100644
--- a/python/helpers/typeshed/stubs/auth0-python/auth0/management/auth0.pyi
+++ b/python/helpers/typeshed/stubs/auth0-python/auth0/management/auth0.pyi
@@ -24,6 +24,7 @@ from .resource_servers import ResourceServers
from .roles import Roles
from .rules import Rules
from .rules_configs import RulesConfigs
+from .self_service_profiles import SelfServiceProfiles
from .stats import Stats
from .tenants import Tenants
from .tickets import Tickets
@@ -56,6 +57,7 @@ class Auth0:
roles: Roles
rules_configs: RulesConfigs
rules: Rules
+ self_service_profiles: SelfServiceProfiles
stats: Stats
tenants: Tenants
tickets: Tickets
diff --git a/python/helpers/typeshed/stubs/auth0-python/auth0/management/self_service_profiles.pyi b/python/helpers/typeshed/stubs/auth0-python/auth0/management/self_service_profiles.pyi
new file mode 100644
index 000000000000..e75e2a098844
--- /dev/null
+++ b/python/helpers/typeshed/stubs/auth0-python/auth0/management/self_service_profiles.pyi
@@ -0,0 +1,26 @@
+from _typeshed import Incomplete
+
+from ..rest import RestClientOptions
+from ..types import TimeoutType
+
+class SelfServiceProfiles:
+ def __init__(
+ self,
+ domain: str,
+ token: str,
+ telemetry: bool = True,
+ timeout: TimeoutType = 5.0,
+ protocol: str = "https",
+ rest_options: RestClientOptions | None = None,
+ ) -> None: ...
+ def all(self, page: int = 0, per_page: int = 25, include_totals: bool = True) -> list[dict[str, Incomplete]]: ...
+ def create(self, body: dict[str, Incomplete]) -> dict[str, Incomplete]: ...
+ def get(self, profile_id: str) -> dict[str, Incomplete]: ...
+ def delete(self, profile_id: str) -> None: ...
+ def update(self, profile_id: str, body: dict[str, Incomplete]) -> dict[str, Incomplete]: ...
+ def get_custom_text(self, profile_id: str, language: str, page: str) -> dict[str, Incomplete]: ...
+ def update_custom_text(
+ self, profile_id: str, language: str, page: str, body: dict[str, Incomplete]
+ ) -> dict[str, Incomplete]: ...
+ def create_sso_ticket(self, profile_id: str, body: dict[str, Incomplete]) -> dict[str, Incomplete]: ...
+ def revoke_sso_ticket(self, profile_id: str, ticket_id: str) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/aws-xray-sdk/@tests/stubtest_allowlist.txt
index 65bf925433a6..75131498945f 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/@tests/stubtest_allowlist.txt
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/@tests/stubtest_allowlist.txt
@@ -1,3 +1,33 @@
aws_xray_sdk.core.models.subsegment.subsegment_decorator
aws_xray_sdk.core.sampling.connector.ServiceConnector.fetch_sampling_rules
-aws_xray_sdk.core.sampling.sampler.ServiceConnector.fetch_sampling_rules
+
+# We can not import 3rd-party libraries in teststubs runtime,
+# but we can use Protocol to replace this types:
+aws_xray_sdk.ext.aiobotocore
+aws_xray_sdk.ext.aiobotocore.patch
+aws_xray_sdk.ext.aiohttp.client
+aws_xray_sdk.ext.aiohttp.middleware
+aws_xray_sdk.ext.bottle.middleware
+aws_xray_sdk.ext.django.apps
+aws_xray_sdk.ext.django.conf
+aws_xray_sdk.ext.django.db
+aws_xray_sdk.ext.django.middleware
+aws_xray_sdk.ext.django.templates
+aws_xray_sdk.ext.flask.middleware
+aws_xray_sdk.ext.flask_sqlalchemy.query
+aws_xray_sdk.ext.httpx
+aws_xray_sdk.ext.httpx.patch
+aws_xray_sdk.ext.mysql
+aws_xray_sdk.ext.mysql.patch
+aws_xray_sdk.ext.pg8000
+aws_xray_sdk.ext.pg8000.patch
+aws_xray_sdk.ext.pymongo
+aws_xray_sdk.ext.pymongo.patch
+aws_xray_sdk.ext.pymysql
+aws_xray_sdk.ext.pymysql.patch
+aws_xray_sdk.ext.pynamodb
+aws_xray_sdk.ext.pynamodb.patch
+aws_xray_sdk.ext.sqlalchemy.query
+aws_xray_sdk.ext.sqlalchemy.util.decorators
+aws_xray_sdk.ext.sqlalchemy_core
+aws_xray_sdk.ext.sqlalchemy_core.patch
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/METADATA.toml b/python/helpers/typeshed/stubs/aws-xray-sdk/METADATA.toml
index a6fbe2d9ac66..67550f9adbcf 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/METADATA.toml
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/METADATA.toml
@@ -1,6 +1,2 @@
version = "2.14.*"
upstream_repository = "https://github.com/aws/aws-xray-sdk-python"
-partial_stub = true
-
-[tool.stubtest]
-ignore_missing_stub = true
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/__init__.pyi
index bfaa6ea70292..d570c5d860c8 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/__init__.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/__init__.pyi
@@ -2,3 +2,5 @@ from .patcher import patch as patch, patch_all as patch_all
from .recorder import AWSXRayRecorder as AWSXRayRecorder
xray_recorder: AWSXRayRecorder
+
+__all__ = ["patch", "patch_all", "xray_recorder", "AWSXRayRecorder"]
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/emitters/udp_emitter.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/emitters/udp_emitter.pyi
index 9b4a5dfcec43..fa5c2b24ca4e 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/emitters/udp_emitter.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/emitters/udp_emitter.pyi
@@ -1,18 +1,17 @@
from logging import Logger
+from typing import Final
-from aws_xray_sdk.core.daemon_config import DaemonConfig as DaemonConfig
-
-from ..exceptions.exceptions import InvalidDaemonAddressException as InvalidDaemonAddressException
+from aws_xray_sdk.core.models.entity import Entity
log: Logger
-PROTOCOL_HEADER: str
-PROTOCOL_DELIMITER: str
-DEFAULT_DAEMON_ADDRESS: str
+PROTOCOL_HEADER: Final[str]
+PROTOCOL_DELIMITER: Final[str]
+DEFAULT_DAEMON_ADDRESS: Final[str]
class UDPEmitter:
- def __init__(self, daemon_address="127.0.0.1:2000") -> None: ...
- def send_entity(self, entity) -> None: ...
- def set_daemon_address(self, address) -> None: ...
+ def __init__(self, daemon_address: str = "127.0.0.1:2000") -> None: ...
+ def send_entity(self, entity: Entity) -> None: ...
+ def set_daemon_address(self, address: str | None) -> None: ...
@property
def ip(self): ...
@property
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/default_dynamic_naming.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/default_dynamic_naming.pyi
index 8103c32a7b03..ed31616245db 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/default_dynamic_naming.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/default_dynamic_naming.pyi
@@ -1,5 +1,3 @@
-from ..utils.search_pattern import wildcard_match as wildcard_match
-
class DefaultDynamicNaming:
- def __init__(self, pattern, fallback) -> None: ...
- def get_name(self, host_name): ...
+ def __init__(self, pattern: str, fallback: str) -> None: ...
+ def get_name(self, host_name: str | None) -> str: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/dummy_entities.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/dummy_entities.pyi
index cf2fd6e88d4c..f10a1208d4b6 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/dummy_entities.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/dummy_entities.pyi
@@ -1,29 +1,8 @@
-from .noop_traceid import NoOpTraceId as NoOpTraceId
-from .segment import Segment as Segment
-from .subsegment import Subsegment as Subsegment
-from .traceid import TraceId as TraceId
+from .segment import Segment
+from .subsegment import Subsegment
class DummySegment(Segment):
- sampled: bool
def __init__(self, name: str = "dummy") -> None: ...
- def set_aws(self, aws_meta) -> None: ...
- def put_http_meta(self, key, value) -> None: ...
- def put_annotation(self, key, value) -> None: ...
- def put_metadata(self, key, value, namespace: str = "default") -> None: ...
- def set_user(self, user) -> None: ...
- def set_service(self, service_info) -> None: ...
- def apply_status_code(self, status_code) -> None: ...
- def add_exception(self, exception, stack, remote: bool = False) -> None: ...
- def serialize(self) -> None: ...
class DummySubsegment(Subsegment):
- sampled: bool
def __init__(self, segment, name: str = "dummy") -> None: ...
- def set_aws(self, aws_meta) -> None: ...
- def put_http_meta(self, key, value) -> None: ...
- def put_annotation(self, key, value) -> None: ...
- def put_metadata(self, key, value, namespace: str = "default") -> None: ...
- def set_sql(self, sql) -> None: ...
- def apply_status_code(self, status_code) -> None: ...
- def add_exception(self, exception, stack, remote: bool = False) -> None: ...
- def serialize(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/entity.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/entity.pyi
index 20be6fe08682..0e19e4d65fa1 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/entity.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/entity.pyi
@@ -1,31 +1,40 @@
+from _typeshed import Incomplete
from logging import Logger
from traceback import StackSummary
-from typing import Any
+from typing import Any, Final, Literal, overload
+
+from .subsegment import Subsegment
+from .throwable import Throwable
log: Logger
-ORIGIN_TRACE_HEADER_ATTR_KEY: str
+ORIGIN_TRACE_HEADER_ATTR_KEY: Final[str]
class Entity:
- id: Any
- name: Any
- start_time: Any
- parent_id: Any
+ id: str
+ name: str
+ start_time: float
+ parent_id: str | None
sampled: bool
in_progress: bool
- http: Any
- annotations: Any
- metadata: Any
- aws: Any
- cause: Any
- subsegments: Any
- end_time: Any
- def __init__(self, name, entity_id=None) -> None: ...
- def close(self, end_time=None) -> None: ...
- def add_subsegment(self, subsegment) -> None: ...
- def remove_subsegment(self, subsegment) -> None: ...
- def put_http_meta(self, key, value) -> None: ...
- def put_annotation(self, key, value) -> None: ...
- def put_metadata(self, key, value, namespace: str = "default") -> None: ...
+ http: dict[str, dict[str, str | int]]
+ annotations: dict[str, float | str | bool]
+ metadata: dict[str, dict[str, Any]] # value is any object that can be serialized into JSON string
+ aws: dict[str, Incomplete]
+ cause: dict[str, str | list[Throwable]]
+ subsegments: list[Subsegment]
+ end_time: float
+ def __init__(self, name: str, entity_id: str | None = None) -> None: ...
+ def close(self, end_time: float | None = None) -> None: ...
+ def add_subsegment(self, subsegment: Subsegment) -> None: ...
+ def remove_subsegment(self, subsegment: Subsegment) -> None: ...
+ @overload
+ def put_http_meta(self, key: Literal["status", "content_length"], value: int) -> None: ...
+ @overload
+ def put_http_meta(self, key: Literal["url", "method", "user_agent", "client_ip", "x_forwarded_for"], value: str) -> None: ...
+ def put_annotation(self, key: str, value: float | str | bool) -> None: ...
+ def put_metadata(
+ self, key: str, value: Any, namespace: str = "default" # value is any object that can be serialized into JSON string
+ ) -> None: ...
def set_aws(self, aws_meta) -> None: ...
throttle: bool
def add_throttle_flag(self) -> None: ...
@@ -33,9 +42,9 @@ class Entity:
def add_fault_flag(self) -> None: ...
error: bool
def add_error_flag(self) -> None: ...
- def apply_status_code(self, status_code) -> None: ...
+ def apply_status_code(self, status_code: int | None) -> None: ...
def add_exception(self, exception: Exception, stack: StackSummary, remote: bool = False) -> None: ...
def save_origin_trace_header(self, trace_header) -> None: ...
def get_origin_trace_header(self): ...
- def serialize(self): ...
- def to_dict(self): ...
+ def serialize(self) -> str: ...
+ def to_dict(self) -> dict[str, Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/facade_segment.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/facade_segment.pyi
index 96d406a6a9d7..69c156c46cfe 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/facade_segment.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/facade_segment.pyi
@@ -1,24 +1,9 @@
-from typing import Any
+from typing import Final
from .segment import Segment
-MUTATION_UNSUPPORTED_MESSAGE: str
+MUTATION_UNSUPPORTED_MESSAGE: Final[str]
class FacadeSegment(Segment):
- initializing: Any
- def __init__(self, name, entityid, traceid, sampled) -> None: ...
- def close(self, end_time=None) -> None: ...
- def put_http_meta(self, key, value) -> None: ...
- def put_annotation(self, key, value) -> None: ...
- def put_metadata(self, key, value, namespace: str = "default") -> None: ...
- def set_aws(self, aws_meta) -> None: ...
- def set_user(self, user) -> None: ...
- def add_throttle_flag(self) -> None: ...
- def add_fault_flag(self) -> None: ...
- def add_error_flag(self) -> None: ...
- def add_exception(self, exception, stack, remote: bool = False) -> None: ...
- def apply_status_code(self, status_code) -> None: ...
- def serialize(self) -> None: ...
- def ready_to_send(self): ...
- def increment(self) -> None: ...
- def decrement_ref_counter(self) -> None: ...
+ initializing: bool
+ def __init__(self, name: str, entityid: str | None, traceid: str | None, sampled: bool | None) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/http.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/http.pyi
index c42504de43b9..4aa14206214e 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/http.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/http.pyi
@@ -1,13 +1,13 @@
-from typing import Any
+from typing import Final
-URL: str
-METHOD: str
-USER_AGENT: str
-CLIENT_IP: str
-X_FORWARDED_FOR: str
-STATUS: str
-CONTENT_LENGTH: str
-XRAY_HEADER: str
-ALT_XRAY_HEADER: str
-request_keys: Any
-response_keys: Any
+URL: Final[str]
+METHOD: Final[str]
+USER_AGENT: Final[str]
+CLIENT_IP: Final[str]
+X_FORWARDED_FOR: Final[str]
+STATUS: Final[str]
+CONTENT_LENGTH: Final[str]
+XRAY_HEADER: Final[str]
+ALT_XRAY_HEADER: Final[str]
+request_keys: tuple[str, ...]
+response_keys: tuple[str, ...]
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/noop_traceid.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/noop_traceid.pyi
index 0185c6b0b8b9..14771ae030b9 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/noop_traceid.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/noop_traceid.pyi
@@ -1,6 +1,8 @@
+from typing import ClassVar
+
class NoOpTraceId:
- VERSION: str
- DELIMITER: str
+ VERSION: ClassVar[str]
+ DELIMITER: ClassVar[str]
start_time: str
def __init__(self) -> None: ...
- def to_id(self): ...
+ def to_id(self) -> str: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/segment.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/segment.pyi
index 507832b24b5e..903378f6e6b6 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/segment.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/segment.pyi
@@ -1,44 +1,59 @@
+from _typeshed import Incomplete
from types import TracebackType
-from typing import Any
+from typing import Final
from ..recorder import AWSXRayRecorder
from ..utils.atomic_counter import AtomicCounter
+from .dummy_entities import DummySegment
from .entity import Entity
from .subsegment import Subsegment
-ORIGIN_TRACE_HEADER_ATTR_KEY: str
+ORIGIN_TRACE_HEADER_ATTR_KEY: Final[str]
class SegmentContextManager:
- name: str
- segment_kwargs: dict[str, Any]
+ name: str | None
+ segment_kwargs: dict[str, str | bool | None]
recorder: AWSXRayRecorder
- segment: Segment
- def __init__(self, recorder: AWSXRayRecorder, name: str | None = None, **segment_kwargs) -> None: ...
- def __enter__(self): ...
+ segment: Segment | None
+ def __init__(
+ self,
+ recorder: AWSXRayRecorder,
+ name: str | None = None,
+ *,
+ traceid: str | None = None,
+ parent_id: str | None = None,
+ sampling: bool | None = None,
+ ) -> None: ...
+ def __enter__(self) -> DummySegment | Segment: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
class Segment(Entity):
- trace_id: str | None
- id: str | None
+ trace_id: str
+ id: str
in_progress: bool
sampled: bool
user: str | None
ref_counter: AtomicCounter
- parent_id: str | None
+ parent_id: str
service: dict[str, str]
def __init__(
- self, name, entityid: str | None = None, traceid: str | None = None, parent_id: str | None = None, sampled: bool = True
+ self,
+ name: str,
+ entityid: str | None = None,
+ traceid: str | None = None,
+ parent_id: str | None = None,
+ sampled: bool = True,
) -> None: ...
def add_subsegment(self, subsegment: Subsegment) -> None: ...
def increment(self) -> None: ...
def decrement_ref_counter(self) -> None: ...
- def ready_to_send(self): ...
- def get_total_subsegments_size(self): ...
- def decrement_subsegments_size(self): ...
- def remove_subsegment(self, subsegment) -> None: ...
+ def ready_to_send(self) -> bool: ...
+ def get_total_subsegments_size(self) -> int: ...
+ def decrement_subsegments_size(self) -> int: ...
+ def remove_subsegment(self, subsegment: Subsegment) -> None: ...
def set_user(self, user) -> None: ...
- def set_service(self, service_info) -> None: ...
- def set_rule_name(self, rule_name) -> None: ...
- def to_dict(self): ...
+ def set_service(self, service_info: dict[str, str]) -> None: ...
+ def set_rule_name(self, rule_name: str) -> None: ...
+ def to_dict(self) -> dict[str, Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/subsegment.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/subsegment.pyi
index aefece2fd34b..57ceefa1cb12 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/subsegment.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/subsegment.pyi
@@ -1,12 +1,13 @@
-import time
+from _typeshed import Incomplete
from types import TracebackType
-from typing import Any
+from typing import Final
-from ...core import AWSXRayRecorder
+from ..recorder import AWSXRayRecorder
+from .dummy_entities import DummySubsegment
from .entity import Entity
from .segment import Segment
-SUBSEGMENT_RECORDING_ATTRIBUTE: str
+SUBSEGMENT_RECORDING_ATTRIBUTE: Final[str]
def set_as_recording(decorated_func, wrapped) -> None: ...
def is_already_recording(func): ...
@@ -14,12 +15,12 @@ def subsegment_decorator(wrapped, instance, args, kwargs): ...
class SubsegmentContextManager:
name: str | None
- subsegment_kwargs: dict[str, Any] | None
+ subsegment_kwargs: dict[str, str]
recorder: AWSXRayRecorder
- subsegment: Subsegment
- def __init__(self, recorder: AWSXRayRecorder, name=None, **subsegment_kwargs) -> None: ...
- def __call__(self, wrapped, instance, args: list[Any], kwargs: dict[str, Any]): ...
- def __enter__(self) -> Subsegment | None: ...
+ subsegment: Subsegment | None
+ def __init__(self, recorder: AWSXRayRecorder, name: str | None = None, *, namespace: str = "local") -> None: ...
+ def __call__(self, wrapped, instance, args: list[Incomplete], kwargs: dict[str, Incomplete]): ...
+ def __enter__(self) -> DummySubsegment | Subsegment | None: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
@@ -29,10 +30,10 @@ class Subsegment(Entity):
trace_id: str
type: str
namespace: str
- sql: dict[str, Any]
+ sql: dict[str, Incomplete]
def __init__(self, name: str, namespace: str, segment: Segment) -> None: ...
def add_subsegment(self, subsegment: Subsegment) -> None: ...
def remove_subsegment(self, subsegment: Subsegment) -> None: ...
- def close(self, end_time: time.struct_time | None = None) -> None: ...
- def set_sql(self, sql: dict[str, Any]) -> None: ...
- def to_dict(self) -> dict[str, Any]: ...
+ def close(self, end_time: float | None = None) -> None: ...
+ def set_sql(self, sql: dict[str, Incomplete]) -> None: ...
+ def to_dict(self) -> dict[str, Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/throwable.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/throwable.pyi
index a990c488df6c..54b918634306 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/throwable.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/throwable.pyi
@@ -1,12 +1,21 @@
-from typing import Any
+from _typeshed import Incomplete
+from logging import Logger
+from traceback import StackSummary
+from typing import TypedDict, type_check_only
-log: Any
+@type_check_only
+class _StackInfo(TypedDict):
+ path: str
+ line: int
+ label: str
+
+log: Logger
class Throwable:
- id: Any
- message: Any
- type: Any
- remote: Any
- stack: Any
- def __init__(self, exception, stack, remote: bool = False) -> None: ...
- def to_dict(self): ...
+ id: str
+ message: str
+ type: str
+ remote: bool
+ stack: list[_StackInfo] | None
+ def __init__(self, exception: Exception, stack: StackSummary, remote: bool = False) -> None: ...
+ def to_dict(self) -> dict[str, Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/trace_header.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/trace_header.pyi
index 8b5514238950..0105c07dbcd7 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/trace_header.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/trace_header.pyi
@@ -1,25 +1,36 @@
-from typing import Any
-from typing_extensions import Self
+from _typeshed import Incomplete
+from logging import Logger
+from typing import Final, Literal
+from typing_extensions import Self, TypeAlias
-log: Any
-ROOT: str
-PARENT: str
-SAMPLE: str
-SELF: str
-HEADER_DELIMITER: str
+_SampledTrue: TypeAlias = Literal[True, "1", 1]
+_SampledFalse: TypeAlias = Literal[False, "0", 0]
+_SampledUnknown: TypeAlias = Literal["?"]
+_Sampled: TypeAlias = _SampledTrue | _SampledFalse | _SampledUnknown
+
+log: Logger
+ROOT: Final = "Root"
+PARENT: Final = "Parent"
+SAMPLE: Final = "Sampled"
+SELF: Final = "Self"
+HEADER_DELIMITER: Final = ";"
class TraceHeader:
def __init__(
- self, root: str | None = None, parent: str | None = None, sampled: bool | None = None, data: dict[str, Any] | None = None
+ self,
+ root: str | None = None,
+ parent: str | None = None,
+ sampled: _Sampled | None = None,
+ data: dict[str, Incomplete] | None = None,
) -> None: ...
@classmethod
- def from_header_str(cls, header) -> Self: ...
- def to_header_str(self): ...
+ def from_header_str(cls, header: str | None) -> Self: ...
+ def to_header_str(self) -> str: ...
@property
- def root(self): ...
+ def root(self) -> str | None: ...
@property
- def parent(self): ...
+ def parent(self) -> str | None: ...
@property
- def sampled(self): ...
+ def sampled(self) -> Literal[1, 0, "?"] | None: ...
@property
- def data(self): ...
+ def data(self) -> dict[str, Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/traceid.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/traceid.pyi
index 6c00ccd4f2a6..3d076c862f95 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/traceid.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/models/traceid.pyi
@@ -1,8 +1,8 @@
-from typing import Any
+from typing import ClassVar
class TraceId:
- VERSION: str
- DELIMITER: str
- start_time: Any
+ VERSION: ClassVar[str]
+ DELIMITER: ClassVar[str]
+ start_time: int
def __init__(self) -> None: ...
- def to_id(self): ...
+ def to_id(self) -> str: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/patcher.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/patcher.pyi
index 3557c26c3cf0..20cee42f8ef9 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/patcher.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/patcher.pyi
@@ -1,10 +1,11 @@
from collections.abc import Iterable
from logging import Logger
-from typing import Any
log: Logger
-SUPPORTED_MODULES: Any
-NO_DOUBLE_PATCH: Any
+SUPPORTED_MODULES: tuple[str, ...]
+NO_DOUBLE_PATCH: tuple[str, ...]
def patch_all(double_patch: bool = False) -> None: ...
-def patch(modules_to_patch: Iterable[str], raise_errors: bool = True, ignore_module_patterns: str | None = None) -> None: ...
+def patch(
+ modules_to_patch: Iterable[str], raise_errors: bool = True, ignore_module_patterns: Iterable[str] | None = None
+) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/plugins/ec2_plugin.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/plugins/ec2_plugin.pyi
index 3d3e5ea52cc3..aae2f13951b7 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/plugins/ec2_plugin.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/plugins/ec2_plugin.pyi
@@ -1,12 +1,17 @@
-from typing import Any
+from collections.abc import MutableMapping
+from logging import Logger
+from typing import Any, Final, overload
-log: Any
-SERVICE_NAME: str
-ORIGIN: str
-IMDS_URL: str
+log: Logger
+SERVICE_NAME: Final[str]
+ORIGIN: Final[str]
+IMDS_URL: Final[str]
def initialize() -> None: ...
-def get_token(): ...
-def get_metadata(token=None): ...
-def parse_metadata_json(json_str): ...
-def do_request(url, headers=None, method: str = "GET"): ...
+def get_token() -> str | None: ...
+def get_metadata(token: str | None = None) -> dict[str, Any]: ... # result of parse_metadata_json()
+def parse_metadata_json(json_str: str | bytes | bytearray) -> dict[str, Any]: ... # result of json.loads()
+@overload
+def do_request(url: str, headers: MutableMapping[str, str] | None = None, method: str = "GET") -> str: ...
+@overload
+def do_request(url: None, headers: MutableMapping[str, str] | None = None, method: str = "GET") -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/plugins/ecs_plugin.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/plugins/ecs_plugin.pyi
index 56a4a90b0972..b2cd96d3dcba 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/plugins/ecs_plugin.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/plugins/ecs_plugin.pyi
@@ -1,7 +1,8 @@
-from typing import Any
+from logging import Logger
+from typing import Final
-log: Any
-SERVICE_NAME: str
-ORIGIN: str
+log: Logger
+SERVICE_NAME: Final[str]
+ORIGIN: Final[str]
def initialize() -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/plugins/elasticbeanstalk_plugin.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/plugins/elasticbeanstalk_plugin.pyi
index 8fd94a5e18c3..3ae45f58cded 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/plugins/elasticbeanstalk_plugin.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/plugins/elasticbeanstalk_plugin.pyi
@@ -1,8 +1,9 @@
-from typing import Any
+from logging import Logger
+from typing import Final
-log: Any
-CONF_PATH: str
-SERVICE_NAME: str
-ORIGIN: str
+log: Logger
+CONF_PATH: Final[str]
+SERVICE_NAME: Final[str]
+ORIGIN: Final[str]
def initialize() -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/plugins/utils.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/plugins/utils.pyi
index f3ef252e220e..6dbc20343cb6 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/plugins/utils.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/plugins/utils.pyi
@@ -1,6 +1,8 @@
-from typing import Any
+from collections.abc import Iterable
+from types import ModuleType
+from typing import Final
-module_prefix: str
-PLUGIN_MAPPING: Any
+module_prefix: Final[str]
+PLUGIN_MAPPING: Final[dict[str, str]]
-def get_plugin_modules(plugins): ...
+def get_plugin_modules(plugins: Iterable[str]) -> tuple[ModuleType, ...]: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi
index eb91d70c472c..ee8f964f3e30 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi
@@ -1,4 +1,5 @@
import time
+from _typeshed import FileDescriptorOrPath
from collections.abc import Callable, Iterable
from logging import Logger
from typing import Any
@@ -17,8 +18,8 @@ log: Logger
TRACING_NAME_KEY: str
DAEMON_ADDR_KEY: str
CONTEXT_MISSING_KEY: str
-XRAY_META: Any
-SERVICE_INFO: Any
+XRAY_META: dict[str, dict[str, str]]
+SERVICE_INFO: dict[str, str]
class AWSXRayRecorder:
def __init__(self) -> None: ...
@@ -27,7 +28,7 @@ class AWSXRayRecorder:
sampling: bool | None = None,
plugins: Iterable[str] | None = None,
context_missing: str | None = None,
- sampling_rules: dict[str, Any] | str | None = None,
+ sampling_rules: dict[str, Any] | FileDescriptorOrPath | None = None,
daemon_address: str | None = None,
service: str | None = None,
context: Context | None = None,
@@ -47,6 +48,7 @@ class AWSXRayRecorder:
def end_segment(self, end_time: time.struct_time | None = None) -> None: ...
def current_segment(self) -> Segment: ...
def begin_subsegment(self, name: str, namespace: str = "local") -> DummySubsegment | Subsegment | None: ...
+ def begin_subsegment_without_sampling(self, name: str) -> DummySubsegment | Subsegment | None: ...
def current_subsegment(self) -> Subsegment | DummySubsegment | None: ...
def end_subsegment(self, end_time: time.struct_time | None = None) -> None: ...
def put_annotation(self, key: str, value: Any) -> None: ...
@@ -84,9 +86,9 @@ class AWSXRayRecorder:
@service.setter
def service(self, value: str) -> None: ...
@property
- def dynamic_naming(self) -> Any | DefaultDynamicNaming: ...
+ def dynamic_naming(self) -> DefaultDynamicNaming | None: ...
@dynamic_naming.setter
- def dynamic_naming(self, value: Any | DefaultDynamicNaming) -> None: ...
+ def dynamic_naming(self, value: DefaultDynamicNaming | str) -> None: ...
@property
def context(self) -> Context: ...
@context.setter
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/connector.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/connector.pyi
index 3ae19b8da6ad..e496d524da17 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/connector.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/connector.pyi
@@ -1,9 +1,15 @@
+from _typeshed import Incomplete
+
+from aws_xray_sdk.core.context import Context
+
+from .sampling_rule import SamplingRule
+
class ServiceConnector:
def __init__(self) -> None: ...
- def fetch_sampling_rules(self): ...
- def fetch_sampling_target(self, rules): ...
- def setup_xray_client(self, ip, port, client) -> None: ...
+ def fetch_sampling_rules(self) -> list[SamplingRule]: ...
+ def fetch_sampling_target(self, rules) -> tuple[Incomplete, int]: ...
+ def setup_xray_client(self, ip: str, port: str | int, client) -> None: ...
@property
- def context(self): ...
+ def context(self) -> Context: ...
@context.setter
- def context(self, v) -> None: ...
+ def context(self, v: Context) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/local/reservoir.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/local/reservoir.pyi
index e886952023cc..9263428ef9cf 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/local/reservoir.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/local/reservoir.pyi
@@ -1,8 +1,6 @@
-from typing import Any
-
class Reservoir:
- traces_per_sec: Any
+ traces_per_sec: int
used_this_sec: int
- this_sec: Any
+ this_sec: int
def __init__(self, traces_per_sec: int = 0) -> None: ...
- def take(self): ...
+ def take(self) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/local/sampler.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/local/sampler.pyi
index fef2a8ebb405..f4bf2f677537 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/local/sampler.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/local/sampler.pyi
@@ -1,12 +1,18 @@
-from typing import Any
+from typing import TypedDict, type_check_only
+from typing_extensions import NotRequired
-from ...exceptions.exceptions import InvalidSamplingManifestError as InvalidSamplingManifestError
-from .sampling_rule import SamplingRule as SamplingRule
+from .sampling_rule import SamplingRule, _Rule
-local_sampling_rule: Any
-SUPPORTED_RULE_VERSION: Any
+@type_check_only
+class _SamplingRule(TypedDict):
+ version: NotRequired[int]
+ default: _Rule
+ rules: list[_Rule]
+
+local_sampling_rule: _SamplingRule
+SUPPORTED_RULE_VERSION: tuple[int, ...]
class LocalSampler:
- def __init__(self, rules=...) -> None: ...
- def should_trace(self, sampling_req=None): ...
- def load_local_rules(self, rules) -> None: ...
+ def __init__(self, rules: _SamplingRule = ...) -> None: ...
+ def should_trace(self, sampling_req: SamplingRule | None = None) -> bool: ...
+ def load_local_rules(self, rules: _SamplingRule) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/local/sampling_rule.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/local/sampling_rule.pyi
index 9c56eb67e832..418c386559e6 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/local/sampling_rule.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/local/sampling_rule.pyi
@@ -1,28 +1,38 @@
-from aws_xray_sdk.core.utils.search_pattern import wildcard_match as wildcard_match
+from typing import ClassVar, TypedDict, type_check_only
+from typing_extensions import NotRequired
-from ...exceptions.exceptions import InvalidSamplingManifestError as InvalidSamplingManifestError
-from .reservoir import Reservoir as Reservoir
+from .reservoir import Reservoir
+
+@type_check_only
+class _Rule(TypedDict):
+ description: NotRequired[str]
+ host: NotRequired[str]
+ service_name: NotRequired[str]
+ http_method: NotRequired[str]
+ url_path: NotRequired[str]
+ fixed_target: NotRequired[int]
+ rate: NotRequired[float]
class SamplingRule:
- FIXED_TARGET: str
- RATE: str
- HOST: str
- METHOD: str
- PATH: str
- SERVICE_NAME: str
- def __init__(self, rule_dict, version: int = 2, default: bool = False) -> None: ...
- def applies(self, host, method, path): ...
+ FIXED_TARGET: ClassVar[str]
+ RATE: ClassVar[str]
+ HOST: ClassVar[str]
+ METHOD: ClassVar[str]
+ PATH: ClassVar[str]
+ SERVICE_NAME: ClassVar[str]
+ def __init__(self, rule_dict: _Rule, version: int = 2, default: bool = False) -> None: ...
+ def applies(self, host: str | None, method: str | None, path: str | None) -> bool: ...
@property
- def fixed_target(self): ...
+ def fixed_target(self) -> int | None: ...
@property
- def rate(self): ...
+ def rate(self) -> float | None: ...
@property
- def host(self): ...
+ def host(self) -> str | None: ...
@property
- def method(self): ...
+ def method(self) -> str | None: ...
@property
- def path(self): ...
+ def path(self) -> str | None: ...
@property
- def reservoir(self): ...
+ def reservoir(self) -> Reservoir: ...
@property
def version(self): ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/reservoir.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/reservoir.pyi
index e93d05f8b345..10b5b2b7cad9 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/reservoir.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/reservoir.pyi
@@ -2,12 +2,12 @@ from enum import Enum
class Reservoir:
def __init__(self) -> None: ...
- def borrow_or_take(self, now, can_borrow): ...
- def load_quota(self, quota, TTL, interval) -> None: ...
+ def borrow_or_take(self, now: int, can_borrow: bool | None) -> ReservoirDecision | None: ...
+ def load_quota(self, quota: int | None, TTL: int | None, interval: int | None) -> None: ...
@property
- def quota(self): ...
+ def quota(self) -> int | None: ...
@property
- def TTL(self): ...
+ def TTL(self) -> int | None: ...
class ReservoirDecision(Enum):
TAKE = "take"
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/rule_cache.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/rule_cache.pyi
index cccd9105b130..6fb06c428f2e 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/rule_cache.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/rule_cache.pyi
@@ -1,6 +1,6 @@
-from typing import Any
+from typing import Final
-TTL: Any
+TTL: Final = 3600
class RuleCache:
def __init__(self) -> None: ...
@@ -12,6 +12,6 @@ class RuleCache:
@rules.setter
def rules(self, v) -> None: ...
@property
- def last_updated(self): ...
+ def last_updated(self) -> int | None: ...
@last_updated.setter
- def last_updated(self, v) -> None: ...
+ def last_updated(self, v: int | None) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/rule_poller.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/rule_poller.pyi
index dc4b3633802b..5f1f6c3caf5a 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/rule_poller.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/rule_poller.pyi
@@ -1,9 +1,13 @@
-from typing import Any
+from logging import Logger
+from typing import Final
-log: Any
-DEFAULT_INTERVAL: Any
+from .connector import ServiceConnector
+from .rule_cache import RuleCache
+
+log: Logger
+DEFAULT_INTERVAL: Final = 300
class RulePoller:
- def __init__(self, cache, connector) -> None: ...
+ def __init__(self, cache: RuleCache, connector: ServiceConnector) -> None: ...
def start(self) -> None: ...
def wake_up(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/sampler.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/sampler.pyi
index e3ff1cb5e23a..53235a4db593 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/sampler.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/sampler.pyi
@@ -1,13 +1,6 @@
-from typing import Any
+from logging import Logger
-from .connector import ServiceConnector as ServiceConnector
-from .local.sampler import LocalSampler as LocalSampler
-from .reservoir import ReservoirDecision as ReservoirDecision
-from .rule_cache import RuleCache as RuleCache
-from .rule_poller import RulePoller as RulePoller
-from .target_poller import TargetPoller as TargetPoller
-
-log: Any
+log: Logger
class DefaultSampler:
def __init__(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/target_poller.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/target_poller.pyi
index 4be740c6cd0f..7fdc45bf8f0b 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/target_poller.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/sampling/target_poller.pyi
@@ -1,6 +1,6 @@
-from typing import Any
+from logging import Logger
-log: Any
+log: Logger
class TargetPoller:
def __init__(self, cache, rule_poller, connector) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/streaming/default_streaming.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/streaming/default_streaming.pyi
index ab1c4119ae64..012abdf63fc1 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/streaming/default_streaming.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/streaming/default_streaming.pyi
@@ -1,8 +1,14 @@
+from _typeshed import Unused
+from collections.abc import Callable
+
+from aws_xray_sdk.core.models.entity import Entity
+from aws_xray_sdk.core.models.segment import Segment
+
class DefaultStreaming:
def __init__(self, streaming_threshold: int = 30) -> None: ...
- def is_eligible(self, segment): ...
- def stream(self, entity, callback) -> None: ...
+ def is_eligible(self, segment: Segment) -> bool: ...
+ def stream(self, entity: Entity, callback: Callable[..., Unused]) -> None: ...
@property
- def streaming_threshold(self): ...
+ def streaming_threshold(self) -> int: ...
@streaming_threshold.setter
- def streaming_threshold(self, value) -> None: ...
+ def streaming_threshold(self, value: int) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/atomic_counter.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/atomic_counter.pyi
index 3bb8eca1cab2..66a7fb051c4e 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/atomic_counter.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/atomic_counter.pyi
@@ -1,9 +1,7 @@
-from typing import Any
-
class AtomicCounter:
- value: Any
+ value: int
def __init__(self, initial: int = 0) -> None: ...
- def increment(self, num: int = 1): ...
- def decrement(self, num: int = 1): ...
- def get_current(self): ...
- def reset(self): ...
+ def increment(self, num: int = 1) -> int: ...
+ def decrement(self, num: int = 1) -> int: ...
+ def get_current(self) -> int: ...
+ def reset(self) -> int: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/compat.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/compat.pyi
index 799c00ba0468..f6e9aa45654e 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/compat.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/compat.pyi
@@ -1,6 +1,4 @@
-from typing import Any
+annotation_value_types: tuple[type, ...]
-annotation_value_types: Any
-
-def is_classmethod(func): ...
-def is_instance_method(parent_class, func_name, func): ...
+def is_classmethod(func: object) -> bool: ... # argument func is passing to getattr() function
+def is_instance_method(parent_class: type, func_name: str, func: object) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/conversion.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/conversion.pyi
index f8c141418d0d..c5201d5b6e04 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/conversion.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/conversion.pyi
@@ -1,5 +1,13 @@
-from typing import Any
+from logging import Logger
+from typing import Any, TypeVar, overload
-log: Any
+_K = TypeVar("_K")
-def metadata_to_dict(obj): ...
+log: Logger
+
+@overload
+def metadata_to_dict(obj: dict[_K, Any]) -> dict[_K, Any]: ...
+@overload
+def metadata_to_dict(obj: type) -> str: ...
+@overload
+def metadata_to_dict(obj: Any) -> Any: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/search_pattern.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/search_pattern.pyi
index 457f742eeb56..94b94e569186 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/search_pattern.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/search_pattern.pyi
@@ -1 +1,8 @@
-def wildcard_match(pattern, text, case_insensitive: bool = True): ...
+from typing import Literal, overload
+
+@overload
+def wildcard_match(pattern: None, text: str, case_insensitive: bool = True) -> Literal[False]: ...
+@overload
+def wildcard_match(pattern: str, text: None, case_insensitive: bool = True) -> Literal[False]: ...
+@overload
+def wildcard_match(pattern: str, text: str, case_insensitive: bool = True) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/sqs_message_helper.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/sqs_message_helper.pyi
new file mode 100644
index 000000000000..c4c90e27adf6
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/sqs_message_helper.pyi
@@ -0,0 +1,9 @@
+from _typeshed import Incomplete
+from collections.abc import Mapping
+from typing import Final
+
+SQS_XRAY_HEADER: Final = "AWSTraceHeader"
+
+class SqsMessageHelper:
+ @staticmethod
+ def isSampled(sqs_message: Mapping[str, Incomplete]) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/stacktrace.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/stacktrace.pyi
index f7df10b9d7a3..fd7daa078301 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/stacktrace.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/core/utils/stacktrace.pyi
@@ -1 +1,3 @@
-def get_stacktrace(limit=None): ...
+import traceback
+
+def get_stacktrace(limit: int | None = None) -> list[traceback.FrameSummary]: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/__init__.pyi
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/aiobotocore/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/aiobotocore/__init__.pyi
new file mode 100644
index 000000000000..47b402c8e221
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/aiobotocore/__init__.pyi
@@ -0,0 +1,3 @@
+from .patch import patch as patch
+
+__all__ = ["patch"]
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/aiobotocore/patch.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/aiobotocore/patch.pyi
new file mode 100644
index 000000000000..969a93686fd4
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/aiobotocore/patch.pyi
@@ -0,0 +1 @@
+def patch() -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/aiohttp/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/aiohttp/__init__.pyi
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/aiohttp/client.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/aiohttp/client.pyi
new file mode 100644
index 000000000000..dd4500f9d662
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/aiohttp/client.pyi
@@ -0,0 +1,10 @@
+from typing import Final
+
+REMOTE_NAMESPACE: Final = "remote"
+LOCAL_NAMESPACE: Final = "local"
+LOCAL_EXCEPTIONS: tuple[type[Exception], ...]
+
+async def begin_subsegment(session, trace_config_ctx, params): ...
+async def end_subsegment(session, trace_config_ctx, params): ...
+async def end_subsegment_with_exception(session, trace_config_ctx, params): ...
+def aws_xray_trace_config(name=None): ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/aiohttp/middleware.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/aiohttp/middleware.pyi
new file mode 100644
index 000000000000..93fab0a1f06c
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/aiohttp/middleware.pyi
@@ -0,0 +1 @@
+async def middleware(request, handler): ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/boto_utils.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/boto_utils.pyi
new file mode 100644
index 000000000000..29a962e55ed0
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/boto_utils.pyi
@@ -0,0 +1,6 @@
+from _typeshed import Incomplete
+
+whitelist: Incomplete
+
+def inject_header(wrapped, instance, args, kwargs): ...
+def aws_meta_processor(wrapped, instance, args, kwargs, return_value, exception, subsegment, stack) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/botocore/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/botocore/__init__.pyi
new file mode 100644
index 000000000000..47b402c8e221
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/botocore/__init__.pyi
@@ -0,0 +1,3 @@
+from .patch import patch as patch
+
+__all__ = ["patch"]
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/botocore/patch.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/botocore/patch.pyi
new file mode 100644
index 000000000000..969a93686fd4
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/botocore/patch.pyi
@@ -0,0 +1 @@
+def patch() -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/bottle/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/bottle/__init__.pyi
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/bottle/middleware.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/bottle/middleware.pyi
new file mode 100644
index 000000000000..5470f17a3482
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/bottle/middleware.pyi
@@ -0,0 +1,9 @@
+from _typeshed import Incomplete
+from collections.abc import Callable
+from typing import ClassVar
+
+class XRayMiddleware:
+ name: ClassVar[str]
+ api: ClassVar[int]
+ def __init__(self, recorder) -> None: ...
+ def apply(self, callback: Callable[..., Incomplete], route) -> Callable[..., Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/dbapi2.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/dbapi2.pyi
new file mode 100644
index 000000000000..df291e1040cd
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/dbapi2.pyi
@@ -0,0 +1,14 @@
+from typing_extensions import Self
+
+class XRayTracedConn:
+ def __init__(self, conn, meta={}) -> None: ...
+ def cursor(self, *args, **kwargs) -> XRayTracedCursor: ...
+
+class XRayTracedCursor:
+ def __init__(self, cursor, meta={}) -> None: ...
+ def __enter__(self) -> Self: ...
+ def execute(self, query, *args, **kwargs): ...
+ def executemany(self, query, *args, **kwargs): ...
+ def callproc(self, proc, args): ...
+
+def add_sql_meta(meta) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/django/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/django/__init__.pyi
new file mode 100644
index 000000000000..c4741233700b
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/django/__init__.pyi
@@ -0,0 +1,3 @@
+from typing import Final
+
+default_app_config: Final = "aws_xray_sdk.ext.django.apps.XRayConfig"
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/django/apps.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/django/apps.pyi
new file mode 100644
index 000000000000..b00e299307b4
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/django/apps.pyi
@@ -0,0 +1,8 @@
+from logging import Logger
+from typing import ClassVar
+
+log: Logger
+
+class XRayConfig:
+ name: ClassVar[str]
+ def ready(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/django/conf.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/django/conf.pyi
new file mode 100644
index 000000000000..538c47697398
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/django/conf.pyi
@@ -0,0 +1,17 @@
+from _typeshed import Incomplete
+from typing import Final
+
+DEFAULTS: dict[str, str | bool | tuple[Incomplete] | list[Incomplete] | None]
+XRAY_NAMESPACE: Final = "XRAY_RECORDER"
+SUPPORTED_ENV_VARS: tuple[str, ...]
+
+class XRaySettings:
+ defaults: dict[str, str | bool | tuple[Incomplete] | list[Incomplete] | None]
+ def __init__(self, user_settings=None) -> None: ...
+ @property
+ def user_settings(self): ...
+ def __getattr__(self, attr): ...
+
+settings: XRaySettings
+
+def reload_settings(*, settings: str | None = None, value=None) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/django/db.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/django/db.pyi
new file mode 100644
index 000000000000..d71b2856e342
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/django/db.pyi
@@ -0,0 +1,12 @@
+from logging import Logger
+
+from aws_xray_sdk.ext.dbapi2 import XRayTracedCursor
+
+log: Logger
+
+def patch_db() -> None: ...
+
+class DjangoXRayTracedCursor(XRayTracedCursor):
+ def execute(self, query, *args, **kwargs): ...
+ def executemany(self, query, *args, **kwargs): ...
+ def callproc(self, proc, args): ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/django/middleware.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/django/middleware.pyi
new file mode 100644
index 000000000000..d5d5a1faa7cb
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/django/middleware.pyi
@@ -0,0 +1,19 @@
+from _typeshed import Incomplete
+from logging import Logger
+from typing import Final
+
+log: Logger
+
+USER_AGENT_KEY: Final = "HTTP_USER_AGENT"
+X_FORWARDED_KEY: Final = "HTTP_X_FORWARDED_FOR"
+REMOTE_ADDR_KEY: Final = "REMOTE_ADDR"
+HOST_KEY: Final = "HTTP_HOST"
+CONTENT_LENGTH_KEY: Final = "content-length"
+
+class XRayMiddleware:
+ get_response: Incomplete
+ in_lambda_ctx: bool
+
+ def __init__(self, get_response) -> None: ...
+ def __call__(self, request): ...
+ def process_exception(self, request, exception: Exception) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/django/templates.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/django/templates.pyi
new file mode 100644
index 000000000000..142de83de16e
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/django/templates.pyi
@@ -0,0 +1,5 @@
+from logging import Logger
+
+log: Logger
+
+def patch_template() -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/flask/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/flask/__init__.pyi
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/flask/middleware.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/flask/middleware.pyi
new file mode 100644
index 000000000000..ab8e8a2feb4d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/flask/middleware.pyi
@@ -0,0 +1,6 @@
+from _typeshed import Incomplete
+
+class XRayMiddleware:
+ app: Incomplete
+ in_lambda_ctx: bool
+ def __init__(self, app, recorder) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/flask_sqlalchemy/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/flask_sqlalchemy/__init__.pyi
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/flask_sqlalchemy/query.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/flask_sqlalchemy/query.pyi
new file mode 100644
index 000000000000..0f0f512d4fa9
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/flask_sqlalchemy/query.pyi
@@ -0,0 +1,22 @@
+from _typeshed import Incomplete
+
+from aws_xray_sdk.ext.sqlalchemy.query import XRaySession
+
+class XRayBaseQuery: ...
+
+class XRaySignallingSession(XRaySession):
+ app: Incomplete
+ def __init__(self, db, autocommit: bool = False, autoflush: bool = True, **options) -> None: ...
+ def get_bind(self, mapper=None, clause=None): ...
+
+class XRayFlaskSqlAlchemy:
+ def __init__(
+ self,
+ app=None,
+ use_native_unicode: bool = True,
+ session_options=None,
+ metadata=None,
+ query_class: type = ...,
+ model_class: type = ...,
+ ) -> None: ...
+ def create_session(self, options: dict[str, Incomplete]): ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/httplib/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/httplib/__init__.pyi
new file mode 100644
index 000000000000..4f5e3a65b1c0
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/httplib/__init__.pyi
@@ -0,0 +1,3 @@
+from .patch import add_ignored as add_ignored, patch as patch, reset_ignored as reset_ignored, unpatch as unpatch
+
+__all__ = ["patch", "unpatch", "add_ignored", "reset_ignored"]
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/httplib/patch.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/httplib/patch.pyi
new file mode 100644
index 000000000000..aaa85125c03a
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/httplib/patch.pyi
@@ -0,0 +1,12 @@
+from typing import Final
+
+httplib_client_module: Final = "http.client"
+PATCH_FLAG: Final = "__xray_patched"
+
+def add_ignored(subclass=None, hostname=None, urls=None) -> None: ...
+def reset_ignored() -> None: ...
+def http_response_processor(wrapped, instance, args, kwargs, return_value, exception, subsegment, stack) -> None: ...
+def http_send_request_processor(wrapped, instance, args, kwargs, return_value, exception, subsegment, stack) -> None: ...
+def http_read_processor(wrapped, instance, args, kwargs, return_value, exception, subsegment, stack) -> None: ...
+def patch() -> None: ...
+def unpatch() -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/httpx/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/httpx/__init__.pyi
new file mode 100644
index 000000000000..47b402c8e221
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/httpx/__init__.pyi
@@ -0,0 +1,3 @@
+from .patch import patch as patch
+
+__all__ = ["patch"]
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/httpx/patch.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/httpx/patch.pyi
new file mode 100644
index 000000000000..b50265a56940
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/httpx/patch.pyi
@@ -0,0 +1,9 @@
+def patch() -> None: ...
+
+class SyncInstrumentedTransport:
+ def __init__(self, transport): ...
+ def handle_request(self, request): ...
+
+class AsyncInstrumentedTransport:
+ def __init__(self, transport): ...
+ async def handle_async_request(self, request): ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/mysql/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/mysql/__init__.pyi
new file mode 100644
index 000000000000..47b402c8e221
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/mysql/__init__.pyi
@@ -0,0 +1,3 @@
+from .patch import patch as patch
+
+__all__ = ["patch"]
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/mysql/patch.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/mysql/patch.pyi
new file mode 100644
index 000000000000..4b8b7d49c3a0
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/mysql/patch.pyi
@@ -0,0 +1,6 @@
+from typing import Final
+
+MYSQL_ATTR: Final[dict[str, str]]
+
+def patch() -> None: ...
+def sanitize_db_ver(raw: tuple[str]) -> str: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pg8000/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pg8000/__init__.pyi
new file mode 100644
index 000000000000..b65967051d08
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pg8000/__init__.pyi
@@ -0,0 +1,3 @@
+from .patch import patch as patch, unpatch as unpatch
+
+__all__ = ["patch", "unpatch"]
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pg8000/patch.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pg8000/patch.pyi
new file mode 100644
index 000000000000..86f5664ff977
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pg8000/patch.pyi
@@ -0,0 +1,2 @@
+def patch() -> None: ...
+def unpatch() -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/psycopg2/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/psycopg2/__init__.pyi
new file mode 100644
index 000000000000..47b402c8e221
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/psycopg2/__init__.pyi
@@ -0,0 +1,3 @@
+from .patch import patch as patch
+
+__all__ = ["patch"]
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/psycopg2/patch.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/psycopg2/patch.pyi
new file mode 100644
index 000000000000..969a93686fd4
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/psycopg2/patch.pyi
@@ -0,0 +1 @@
+def patch() -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pymongo/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pymongo/__init__.pyi
new file mode 100644
index 000000000000..47b402c8e221
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pymongo/__init__.pyi
@@ -0,0 +1,3 @@
+from .patch import patch as patch
+
+__all__ = ["patch"]
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pymongo/patch.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pymongo/patch.pyi
new file mode 100644
index 000000000000..21c4ac034cb5
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pymongo/patch.pyi
@@ -0,0 +1,8 @@
+class XrayCommandListener:
+ record_full_documents: bool
+ def __init__(self, record_full_documents: bool) -> None: ...
+ def started(self, event) -> None: ...
+ def succeeded(self, event) -> None: ...
+ def failed(self, event) -> None: ...
+
+def patch(record_full_documents: bool = False) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pymysql/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pymysql/__init__.pyi
new file mode 100644
index 000000000000..b65967051d08
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pymysql/__init__.pyi
@@ -0,0 +1,3 @@
+from .patch import patch as patch, unpatch as unpatch
+
+__all__ = ["patch", "unpatch"]
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pymysql/patch.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pymysql/patch.pyi
new file mode 100644
index 000000000000..a8cbba7f52bb
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pymysql/patch.pyi
@@ -0,0 +1,3 @@
+def patch() -> None: ...
+def sanitize_db_ver(raw: tuple[str]) -> str: ...
+def unpatch() -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pynamodb/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pynamodb/__init__.pyi
new file mode 100644
index 000000000000..47b402c8e221
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pynamodb/__init__.pyi
@@ -0,0 +1,3 @@
+from .patch import patch as patch
+
+__all__ = ["patch"]
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pynamodb/patch.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pynamodb/patch.pyi
new file mode 100644
index 000000000000..d86fc62fb297
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/pynamodb/patch.pyi
@@ -0,0 +1,6 @@
+from typing import Final
+
+PYNAMODB4: Final[bool]
+
+def patch() -> None: ...
+def pynamodb_meta_processor(wrapped, instance, args, kwargs, return_value, exception, subsegment, stack) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/requests/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/requests/__init__.pyi
new file mode 100644
index 000000000000..47b402c8e221
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/requests/__init__.pyi
@@ -0,0 +1,3 @@
+from .patch import patch as patch
+
+__all__ = ["patch"]
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/requests/patch.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/requests/patch.pyi
new file mode 100644
index 000000000000..bd200a3bfbc1
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/requests/patch.pyi
@@ -0,0 +1,2 @@
+def patch() -> None: ...
+def requests_processor(wrapped, instance, args, kwargs, return_value, exception, subsegment, stack) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlalchemy/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlalchemy/__init__.pyi
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlalchemy/query.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlalchemy/query.pyi
new file mode 100644
index 000000000000..6a54d0d6e23d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlalchemy/query.pyi
@@ -0,0 +1,16 @@
+from typing import Any
+
+class XRaySession: ...
+class XRayQuery: ...
+
+class XRaySessionMaker:
+ def __init__(
+ self,
+ bind=None,
+ class_: type = ...,
+ autoflush: bool = True,
+ autocommit: bool = False,
+ expire_on_commit: bool = True,
+ info: dict[Any, Any] | None = None, # it was taken from sqlalchemy stubs
+ **kw,
+ ) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlalchemy/util/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlalchemy/util/__init__.pyi
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlalchemy/util/decorators.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlalchemy/util/decorators.pyi
new file mode 100644
index 000000000000..78ffee475aed
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlalchemy/util/decorators.pyi
@@ -0,0 +1,6 @@
+from _typeshed import Incomplete
+from collections.abc import Callable
+
+def decorate_all_functions(function_decorator: Callable[..., Incomplete]) -> Callable[..., Incomplete]: ...
+def xray_on_call(cls, func: Callable[..., Incomplete]) -> Callable[..., Incomplete]: ...
+def parse_bind(bind) -> dict[str, str]: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlalchemy_core/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlalchemy_core/__init__.pyi
new file mode 100644
index 000000000000..b65967051d08
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlalchemy_core/__init__.pyi
@@ -0,0 +1,3 @@
+from .patch import patch as patch, unpatch as unpatch
+
+__all__ = ["patch", "unpatch"]
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlalchemy_core/patch.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlalchemy_core/patch.pyi
new file mode 100644
index 000000000000..86f5664ff977
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlalchemy_core/patch.pyi
@@ -0,0 +1,2 @@
+def patch() -> None: ...
+def unpatch() -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlite3/__init__.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlite3/__init__.pyi
new file mode 100644
index 000000000000..47b402c8e221
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlite3/__init__.pyi
@@ -0,0 +1,3 @@
+from .patch import patch as patch
+
+__all__ = ["patch"]
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlite3/patch.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlite3/patch.pyi
new file mode 100644
index 000000000000..71954e425e43
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/sqlite3/patch.pyi
@@ -0,0 +1,7 @@
+from aws_xray_sdk.ext.dbapi2 import XRayTracedConn
+
+def patch() -> None: ...
+
+class XRayTracedSQLite(XRayTracedConn):
+ def execute(self, *args, **kwargs): ...
+ def executemany(self, *args, **kwargs): ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/util.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/util.pyi
new file mode 100644
index 000000000000..daf9f4501bcf
--- /dev/null
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/ext/util.pyi
@@ -0,0 +1,21 @@
+import re
+from typing import Final, overload
+
+from aws_xray_sdk.core.models.trace_header import TraceHeader
+
+first_cap_re: Final[re.Pattern[str]]
+all_cap_re: Final[re.Pattern[str]]
+UNKNOWN_HOSTNAME: str = "UNKNOWN HOST"
+
+def inject_trace_header(headers, entity) -> None: ...
+def calculate_sampling_decision(trace_header, recorder, sampling_req): ...
+def construct_xray_header(headers) -> TraceHeader: ...
+def calculate_segment_name(host_name, recorder): ...
+def prepare_response_header(origin_header, segment) -> str: ...
+def to_snake_case(name: str) -> str: ...
+def strip_url(url): ...
+@overload
+def get_hostname(url: str | None) -> str: ...
+@overload
+def get_hostname(url: bytes | bytearray | None) -> str | bytes: ...
+def unwrap(obj: object, attr: str) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/sdk_config.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/sdk_config.pyi
index c76b34d0a649..f9a79a65a89e 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/sdk_config.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/sdk_config.pyi
@@ -1,11 +1,12 @@
from logging import Logger
+from typing import ClassVar
log: Logger
class SDKConfig:
- XRAY_ENABLED_KEY: str
- DISABLED_ENTITY_NAME: str
+ XRAY_ENABLED_KEY: ClassVar[str]
+ DISABLED_ENTITY_NAME: ClassVar[str]
@classmethod
- def sdk_enabled(cls): ...
+ def sdk_enabled(cls) -> bool: ...
@classmethod
- def set_sdk_enabled(cls, value) -> None: ...
+ def set_sdk_enabled(cls, value: bool | None) -> None: ...
diff --git a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/version.pyi b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/version.pyi
index 3acee936dc41..8052b08139fb 100644
--- a/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/version.pyi
+++ b/python/helpers/typeshed/stubs/aws-xray-sdk/aws_xray_sdk/version.pyi
@@ -1 +1,3 @@
-VERSION: str
+from typing import Final
+
+VERSION: Final[str]
diff --git a/python/helpers/typeshed/stubs/beautifulsoup4/METADATA.toml b/python/helpers/typeshed/stubs/beautifulsoup4/METADATA.toml
deleted file mode 100644
index b2eb4a77b499..000000000000
--- a/python/helpers/typeshed/stubs/beautifulsoup4/METADATA.toml
+++ /dev/null
@@ -1,9 +0,0 @@
-version = "4.12.*"
-upstream_repository = "https://git.launchpad.net/beautifulsoup/tree"
-requires = ["types-html5lib"]
-partial_stub = true
-obsolete_since = "4.13.0" # Released on 2025-02-02
-
-[tool.stubtest]
-ignore_missing_stub = true
-extras = ["html5lib", "lxml"]
diff --git a/python/helpers/typeshed/stubs/beautifulsoup4/bs4/__init__.pyi b/python/helpers/typeshed/stubs/beautifulsoup4/bs4/__init__.pyi
deleted file mode 100644
index 2bbbfc78da19..000000000000
--- a/python/helpers/typeshed/stubs/beautifulsoup4/bs4/__init__.pyi
+++ /dev/null
@@ -1,82 +0,0 @@
-from _typeshed import SupportsRead
-from collections.abc import Iterator, Sequence
-from typing import Any
-from typing_extensions import Self
-
-from .builder import ParserRejectedMarkup as ParserRejectedMarkup, TreeBuilder, XMLParsedAsHTMLWarning as XMLParsedAsHTMLWarning
-from .element import (
- CData as CData,
- Comment as Comment,
- Declaration as Declaration,
- Doctype as Doctype,
- NavigableString as NavigableString,
- PageElement as PageElement,
- ProcessingInstruction as ProcessingInstruction,
- ResultSet as ResultSet,
- Script as Script,
- SoupStrainer as SoupStrainer,
- Stylesheet as Stylesheet,
- Tag as Tag,
- TemplateString as TemplateString,
-)
-from .formatter import Formatter
-
-class GuessedAtParserWarning(UserWarning): ...
-class MarkupResemblesLocatorWarning(UserWarning): ...
-
-class BeautifulSoup(Tag):
- ROOT_TAG_NAME: str
- DEFAULT_BUILDER_FEATURES: list[str]
- ASCII_SPACES: str
- NO_PARSER_SPECIFIED_WARNING: str
- element_classes: Any
- builder: TreeBuilder
- is_xml: bool
- known_xml: bool | None
- parse_only: SoupStrainer | None
- markup: str
- def __init__(
- self,
- markup: str | bytes | SupportsRead[str] | SupportsRead[bytes] = "",
- features: str | Sequence[str] | None = None,
- builder: TreeBuilder | type[TreeBuilder] | None = None,
- parse_only: SoupStrainer | None = None,
- from_encoding: str | None = None,
- exclude_encodings: Sequence[str] | None = None,
- element_classes: dict[type[PageElement], type[Any]] | None = None,
- **kwargs,
- ) -> None: ...
- def __copy__(self) -> Self: ...
- hidden: bool
- current_data: Any
- currentTag: Any
- tagStack: Any
- open_tag_counter: Any
- preserve_whitespace_tag_stack: Any
- string_container_stack: Any
- def reset(self) -> None: ...
- def new_tag(self, name, namespace=None, nsprefix=None, attrs={}, sourceline=None, sourcepos=None, **kwattrs) -> Tag: ...
- def string_container(self, base_class=None): ...
- def new_string(self, s, subclass=None): ...
- def insert_before(self, *args) -> None: ...
- def insert_after(self, *args) -> None: ...
- def popTag(self): ...
- def pushTag(self, tag) -> None: ...
- def endData(self, containerClass=None) -> None: ...
- def object_was_parsed(self, o, parent=None, most_recent_element=None) -> None: ...
- def handle_starttag(
- self, name, namespace, nsprefix, attrs, sourceline=None, sourcepos=None, namespaces: dict[str, str] | None = None
- ): ...
- def handle_endtag(self, name, nsprefix=None) -> None: ...
- def handle_data(self, data) -> None: ...
- def decode( # type: ignore[override]
- self,
- pretty_print: bool = False,
- eventual_encoding: str = "utf-8",
- formatter: str | Formatter = "minimal",
- iterator: Iterator[PageElement] | None = None,
- ): ... # missing some arguments
-
-class BeautifulStoneSoup(BeautifulSoup): ...
-class StopParsing(Exception): ...
-class FeatureNotFound(ValueError): ...
diff --git a/python/helpers/typeshed/stubs/beautifulsoup4/bs4/builder/__init__.pyi b/python/helpers/typeshed/stubs/beautifulsoup4/bs4/builder/__init__.pyi
deleted file mode 100644
index 0399fb520883..000000000000
--- a/python/helpers/typeshed/stubs/beautifulsoup4/bs4/builder/__init__.pyi
+++ /dev/null
@@ -1,64 +0,0 @@
-from typing import Any
-
-class TreeBuilderRegistry:
- builders_for_feature: Any
- builders: Any
- def __init__(self) -> None: ...
- def register(self, treebuilder_class) -> None: ...
- def lookup(self, *features): ...
-
-class TreeBuilder:
- NAME: str
- ALTERNATE_NAMES: Any
- features: Any
- is_xml: bool
- picklable: bool
- empty_element_tags: Any
- DEFAULT_CDATA_LIST_ATTRIBUTES: Any
- DEFAULT_PRESERVE_WHITESPACE_TAGS: Any
- DEFAULT_STRING_CONTAINERS: Any
- USE_DEFAULT: Any
- TRACKS_LINE_NUMBERS: bool
- soup: Any
- cdata_list_attributes: Any
- preserve_whitespace_tags: Any
- store_line_numbers: Any
- string_containers: Any
- def __init__(
- self, multi_valued_attributes=..., preserve_whitespace_tags=..., store_line_numbers=..., string_containers=...
- ) -> None: ...
- def initialize_soup(self, soup) -> None: ...
- def reset(self) -> None: ...
- def can_be_empty_element(self, tag_name): ...
- def feed(self, markup) -> None: ...
- def prepare_markup(
- self, markup, user_specified_encoding=None, document_declared_encoding=None, exclude_encodings=None
- ) -> None: ...
- def test_fragment_to_document(self, fragment): ...
- def set_up_substitutions(self, tag): ...
-
-class SAXTreeBuilder(TreeBuilder):
- def feed(self, markup) -> None: ...
- def close(self) -> None: ...
- def startElement(self, name, attrs) -> None: ...
- def endElement(self, name) -> None: ...
- def startElementNS(self, nsTuple, nodeName, attrs) -> None: ...
- def endElementNS(self, nsTuple, nodeName) -> None: ...
- def startPrefixMapping(self, prefix, nodeValue) -> None: ...
- def endPrefixMapping(self, prefix) -> None: ...
- def characters(self, content) -> None: ...
- def startDocument(self) -> None: ...
- def endDocument(self) -> None: ...
-
-class HTMLTreeBuilder(TreeBuilder):
- empty_element_tags: Any
- block_elements: Any
- DEFAULT_STRING_CONTAINERS: Any
- DEFAULT_CDATA_LIST_ATTRIBUTES: Any
- DEFAULT_PRESERVE_WHITESPACE_TAGS: Any
- def set_up_substitutions(self, tag): ...
-
-class ParserRejectedMarkup(Exception):
- def __init__(self, message_or_exception) -> None: ...
-
-class XMLParsedAsHTMLWarning(UserWarning): ...
diff --git a/python/helpers/typeshed/stubs/beautifulsoup4/bs4/builder/_html5lib.pyi b/python/helpers/typeshed/stubs/beautifulsoup4/bs4/builder/_html5lib.pyi
deleted file mode 100644
index 412d1afa77b1..000000000000
--- a/python/helpers/typeshed/stubs/beautifulsoup4/bs4/builder/_html5lib.pyi
+++ /dev/null
@@ -1,76 +0,0 @@
-from _typeshed import Incomplete
-from typing import Any
-
-from bs4.builder import HTMLTreeBuilder
-from html5lib.treebuilders import base as treebuilder_base
-
-class HTML5TreeBuilder(HTMLTreeBuilder):
- NAME: str
- features: Any
- TRACKS_LINE_NUMBERS: bool
- user_specified_encoding: Any
- def prepare_markup( # type: ignore[override] # user_specified_encoding doesn't have a default
- self,
- markup,
- user_specified_encoding,
- document_declared_encoding: Incomplete | None = ...,
- exclude_encodings: Incomplete | None = ...,
- ) -> None: ...
- def feed(self, markup) -> None: ...
- underlying_builder: Any
- def create_treebuilder(self, namespaceHTMLElements): ...
- def test_fragment_to_document(self, fragment): ...
-
-class TreeBuilderForHtml5lib(treebuilder_base.TreeBuilder):
- soup: Any
- parser: Any
- store_line_numbers: Any
- def __init__(
- self, namespaceHTMLElements, soup: Incomplete | None = ..., store_line_numbers: bool = ..., **kwargs
- ) -> None: ...
- def documentClass(self): ...
- def insertDoctype(self, token) -> None: ...
- def elementClass(self, name, namespace): ...
- def commentClass(self, data): ...
- def fragmentClass(self): ...
- def appendChild(self, node) -> None: ...
- def getDocument(self): ...
- def getFragment(self): ...
- def testSerializer(self, element): ...
-
-class AttrList:
- element: Any
- attrs: Any
- def __init__(self, element) -> None: ...
- def __iter__(self): ...
- def __setitem__(self, name, value) -> None: ...
- def items(self): ...
- def keys(self): ...
- def __len__(self) -> int: ...
- def __getitem__(self, name): ...
- def __contains__(self, name): ...
-
-class Element(treebuilder_base.Node):
- element: Any
- soup: Any
- namespace: Any
- def __init__(self, element, soup, namespace) -> None: ...
- def appendChild(self, node) -> None: ...
- def getAttributes(self): ...
- def setAttributes(self, attributes) -> None: ...
- attributes: Any
- def insertText(self, data, insertBefore: Incomplete | None = ...) -> None: ...
- def insertBefore(self, node, refNode) -> None: ...
- def removeChild(self, node) -> None: ...
- def reparentChildren(self, new_parent) -> None: ...
- def cloneNode(self): ...
- def hasContent(self): ...
- def getNameTuple(self): ...
- @property
- def nameTuple(self): ...
-
-class TextNode(Element):
- element: Any
- soup: Any
- def __init__(self, element, soup) -> None: ...
- def cloneNode(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/beautifulsoup4/bs4/builder/_htmlparser.pyi b/python/helpers/typeshed/stubs/beautifulsoup4/bs4/builder/_htmlparser.pyi
deleted file mode 100644
index fc912e5eeccd..000000000000
--- a/python/helpers/typeshed/stubs/beautifulsoup4/bs4/builder/_htmlparser.pyi
+++ /dev/null
@@ -1,34 +0,0 @@
-from html.parser import HTMLParser
-from typing import Any
-
-from bs4.builder import HTMLTreeBuilder
-
-class BeautifulSoupHTMLParser(HTMLParser):
- IGNORE: str
- REPLACE: str
- on_duplicate_attribute: Any
- already_closed_empty_element: Any
- def __init__(self, *args, **kwargs) -> None: ...
- def handle_startendtag(self, name, attrs) -> None: ...
- def handle_starttag(self, name, attrs, handle_empty_element: bool = True) -> None: ...
- def handle_endtag(self, name, check_already_closed: bool = True) -> None: ...
- def handle_data(self, data) -> None: ...
- def handle_charref(self, name) -> None: ...
- def handle_entityref(self, name) -> None: ...
- def handle_comment(self, data) -> None: ...
- def handle_decl(self, data) -> None: ...
- def unknown_decl(self, data) -> None: ...
- def handle_pi(self, data) -> None: ...
-
-class HTMLParserTreeBuilder(HTMLTreeBuilder):
- is_xml: bool
- picklable: bool
- NAME: Any
- features: Any
- TRACKS_LINE_NUMBERS: bool
- parser_args: Any
- def __init__(self, parser_args=None, parser_kwargs=None, **kwargs) -> None: ...
- def prepare_markup(
- self, markup, user_specified_encoding=None, document_declared_encoding=None, exclude_encodings=None
- ) -> None: ...
- def feed(self, markup) -> None: ...
diff --git a/python/helpers/typeshed/stubs/beautifulsoup4/bs4/builder/_lxml.pyi b/python/helpers/typeshed/stubs/beautifulsoup4/bs4/builder/_lxml.pyi
deleted file mode 100644
index 8490889295aa..000000000000
--- a/python/helpers/typeshed/stubs/beautifulsoup4/bs4/builder/_lxml.pyi
+++ /dev/null
@@ -1,45 +0,0 @@
-from typing import Any
-
-from bs4.builder import HTMLTreeBuilder, TreeBuilder
-
-class LXMLTreeBuilderForXML(TreeBuilder):
- DEFAULT_PARSER_CLASS: Any
- is_xml: bool
- processing_instruction_class: Any
- NAME: str
- ALTERNATE_NAMES: Any
- features: Any
- CHUNK_SIZE: int
- DEFAULT_NSMAPS: Any
- DEFAULT_NSMAPS_INVERTED: Any
- def initialize_soup(self, soup) -> None: ...
- def default_parser(self, encoding): ...
- def parser_for(self, encoding): ...
- empty_element_tags: Any
- soup: Any
- nsmaps: Any
- def __init__(self, parser=None, empty_element_tags=None, **kwargs) -> None: ...
- def prepare_markup( # type: ignore[override] # the order of the parameters is different
- self, markup, user_specified_encoding=None, exclude_encodings=None, document_declared_encoding=None
- ) -> None: ...
- parser: Any
- def feed(self, markup) -> None: ...
- def close(self) -> None: ...
- def start(self, name, attrs, nsmap={}) -> None: ...
- def end(self, name) -> None: ...
- def pi(self, target, data) -> None: ...
- def data(self, content) -> None: ...
- def doctype(self, name, pubid, system) -> None: ...
- def comment(self, content) -> None: ...
- def test_fragment_to_document(self, fragment): ...
-
-class LXMLTreeBuilder(HTMLTreeBuilder, LXMLTreeBuilderForXML):
- NAME: Any
- ALTERNATE_NAMES: Any
- features: Any
- is_xml: bool
- processing_instruction_class: Any
- def default_parser(self, encoding): ...
- parser: Any
- def feed(self, markup) -> None: ...
- def test_fragment_to_document(self, fragment): ...
diff --git a/python/helpers/typeshed/stubs/beautifulsoup4/bs4/dammit.pyi b/python/helpers/typeshed/stubs/beautifulsoup4/bs4/dammit.pyi
deleted file mode 100644
index 0a63da49f03d..000000000000
--- a/python/helpers/typeshed/stubs/beautifulsoup4/bs4/dammit.pyi
+++ /dev/null
@@ -1,85 +0,0 @@
-from _typeshed import Incomplete
-from collections.abc import Iterable, Iterator
-from logging import Logger
-from typing import Any, Literal
-
-def chardet_dammit(s): ...
-
-xml_encoding: str
-html_meta: str
-encoding_res: Any
-
-class EntitySubstitution:
- CHARACTER_TO_HTML_ENTITY: Any
- HTML_ENTITY_TO_CHARACTER: Any
- CHARACTER_TO_HTML_ENTITY_RE: Any
- CHARACTER_TO_XML_ENTITY: Any
- BARE_AMPERSAND_OR_BRACKET: Any
- AMPERSAND_OR_BRACKET: Any
- @classmethod
- def quoted_attribute_value(cls, value): ...
- @classmethod
- def substitute_xml(cls, value, make_quoted_attribute: bool = False): ...
- @classmethod
- def substitute_xml_containing_entities(cls, value, make_quoted_attribute: bool = False): ...
- @classmethod
- def substitute_html(cls, s): ...
-
-class EncodingDetector:
- known_definite_encodings: list[str]
- user_encodings: list[str]
- exclude_encodings: set[str]
- chardet_encoding: Incomplete | None
- is_html: bool
- declared_encoding: str | None
- markup: Any
- sniffed_encoding: str | None
- def __init__(
- self,
- markup,
- known_definite_encodings: Iterable[str] | None = None,
- is_html: bool = False,
- exclude_encodings: list[str] | None = None,
- user_encodings: list[str] | None = None,
- override_encodings: list[str] | None = None,
- ) -> None: ...
- @property
- def encodings(self) -> Iterator[str]: ...
- @classmethod
- def strip_byte_order_mark(cls, data): ...
- @classmethod
- def find_declared_encoding(cls, markup, is_html: bool = False, search_entire_document: bool = False) -> str | None: ...
-
-class UnicodeDammit:
- CHARSET_ALIASES: dict[str, str]
- ENCODINGS_WITH_SMART_QUOTES: list[str]
- smart_quotes_to: Literal["ascii", "xml", "html"] | None
- tried_encodings: list[tuple[str, str]]
- contains_replacement_characters: bool
- is_html: bool
- log: Logger
- detector: EncodingDetector
- markup: Any
- unicode_markup: str
- original_encoding: Incomplete | None
- def __init__(
- self,
- markup,
- known_definite_encodings: list[str] | None = [],
- smart_quotes_to: Literal["ascii", "xml", "html"] | None = None,
- is_html: bool = False,
- exclude_encodings: list[str] | None = [],
- user_encodings: list[str] | None = None,
- override_encodings: list[str] | None = None,
- ) -> None: ...
- @property
- def declared_html_encoding(self) -> str | None: ...
- def find_codec(self, charset: str) -> str | None: ...
- MS_CHARS: dict[bytes, str | tuple[str, ...]]
- MS_CHARS_TO_ASCII: dict[bytes, str]
- WINDOWS_1252_TO_UTF8: dict[int, bytes]
- MULTIBYTE_MARKERS_AND_SIZES: list[tuple[int, int, int]]
- FIRST_MULTIBYTE_MARKER: int
- LAST_MULTIBYTE_MARKER: int
- @classmethod
- def detwingle(cls, in_bytes: bytes, main_encoding: str = "utf8", embedded_encoding: str = "windows-1252") -> bytes: ...
diff --git a/python/helpers/typeshed/stubs/beautifulsoup4/bs4/diagnose.pyi b/python/helpers/typeshed/stubs/beautifulsoup4/bs4/diagnose.pyi
deleted file mode 100644
index ccb7a01dd63f..000000000000
--- a/python/helpers/typeshed/stubs/beautifulsoup4/bs4/diagnose.pyi
+++ /dev/null
@@ -1,22 +0,0 @@
-from html.parser import HTMLParser
-
-def diagnose(data) -> None: ...
-def lxml_trace(data, html: bool = True, **kwargs) -> None: ...
-
-class AnnouncingParser(HTMLParser):
- def handle_starttag(self, name, attrs) -> None: ...
- def handle_endtag(self, name) -> None: ...
- def handle_data(self, data) -> None: ...
- def handle_charref(self, name) -> None: ...
- def handle_entityref(self, name) -> None: ...
- def handle_comment(self, data) -> None: ...
- def handle_decl(self, data) -> None: ...
- def unknown_decl(self, data) -> None: ...
- def handle_pi(self, data) -> None: ...
-
-def htmlparser_trace(data) -> None: ...
-def rword(length: int = 5): ...
-def rsentence(length: int = 4): ...
-def rdoc(num_elements: int = 1000): ...
-def benchmark_parsers(num_elements: int = 100000) -> None: ...
-def profile(num_elements: int = 100000, parser: str = "lxml") -> None: ...
diff --git a/python/helpers/typeshed/stubs/beautifulsoup4/bs4/element.pyi b/python/helpers/typeshed/stubs/beautifulsoup4/bs4/element.pyi
deleted file mode 100644
index 47eb80b5b853..000000000000
--- a/python/helpers/typeshed/stubs/beautifulsoup4/bs4/element.pyi
+++ /dev/null
@@ -1,391 +0,0 @@
-from _typeshed import ReadableBuffer
-from collections.abc import Callable, Iterable, Iterator
-from re import Pattern
-from typing import Any, Literal, TypeVar, overload
-from typing_extensions import Self, TypeAlias
-
-from . import BeautifulSoup
-from .builder import TreeBuilder
-from .formatter import Formatter, _EntitySubstitution
-
-DEFAULT_OUTPUT_ENCODING: str
-nonwhitespace_re: Pattern[str]
-whitespace_re: Pattern[str]
-PYTHON_SPECIFIC_ENCODINGS: set[str]
-
-class NamespacedAttribute(str):
- def __new__(cls, prefix: str, name: str | None = None, namespace: str | None = None) -> Self: ...
-
-class AttributeValueWithCharsetSubstitution(str): ...
-
-class CharsetMetaAttributeValue(AttributeValueWithCharsetSubstitution):
- def __new__(cls, original_value): ...
- def encode(self, encoding: str) -> str: ... # type: ignore[override] # incompatible with str
-
-class ContentMetaAttributeValue(AttributeValueWithCharsetSubstitution):
- CHARSET_RE: Pattern[str]
- def __new__(cls, original_value): ...
- def encode(self, encoding: str) -> str: ... # type: ignore[override] # incompatible with str
-
-_T = TypeVar("_T")
-_PageElementT = TypeVar("_PageElementT", bound=PageElement)
-_SimpleStrainable: TypeAlias = str | bool | None | bytes | Pattern[str] | Callable[[str], bool] | Callable[[Tag], bool]
-_Strainable: TypeAlias = _SimpleStrainable | Iterable[_SimpleStrainable]
-_SimpleNormalizedStrainable: TypeAlias = str | bool | None | Pattern[str] | Callable[[str], bool] | Callable[[Tag], bool]
-_NormalizedStrainable: TypeAlias = _SimpleNormalizedStrainable | Iterable[_SimpleNormalizedStrainable]
-
-class PageElement:
- parent: Tag | None
- previous_element: PageElement | None
- next_element: PageElement | None
- next_sibling: PageElement | None
- previous_sibling: PageElement | None
- def setup(
- self,
- parent: Tag | None = None,
- previous_element: PageElement | None = None,
- next_element: PageElement | None = None,
- previous_sibling: PageElement | None = None,
- next_sibling: PageElement | None = None,
- ) -> None: ...
- def format_string(self, s: str, formatter: Formatter | str | None) -> str: ...
- def formatter_for_name(self, formatter: Formatter | str | _EntitySubstitution): ...
- nextSibling: PageElement | None
- previousSibling: PageElement | None
- @property
- def stripped_strings(self) -> Iterator[str]: ...
- def get_text(self, separator: str = "", strip: bool = False, types: tuple[type[NavigableString], ...] = ...) -> str: ...
- getText = get_text
- @property
- def text(self) -> str: ...
- def replace_with(self, *args: PageElement | str) -> Self: ...
- replaceWith = replace_with
- def unwrap(self) -> Self: ...
- replace_with_children = unwrap
- replaceWithChildren = unwrap
- def wrap(self, wrap_inside: _PageElementT) -> _PageElementT: ...
- def extract(self, _self_index: int | None = None) -> Self: ...
- def insert(self, position: int, new_child: PageElement | str) -> None: ...
- def append(self, tag: PageElement | str) -> None: ...
- def extend(self, tags: Iterable[PageElement | str]) -> None: ...
- def insert_before(self, *args: PageElement | str) -> None: ...
- def insert_after(self, *args: PageElement | str) -> None: ...
- def find_next(
- self,
- name: _Strainable | SoupStrainer | None = None,
- attrs: dict[str, _Strainable] | _Strainable = {},
- string: _Strainable | None = None,
- **kwargs: _Strainable,
- ) -> Tag | NavigableString | None: ...
- findNext = find_next
- def find_all_next(
- self,
- name: _Strainable | SoupStrainer | None = None,
- attrs: dict[str, _Strainable] | _Strainable = {},
- string: _Strainable | None = None,
- limit: int | None = None,
- **kwargs: _Strainable,
- ) -> ResultSet[PageElement]: ...
- findAllNext = find_all_next
- def find_next_sibling(
- self,
- name: _Strainable | SoupStrainer | None = None,
- attrs: dict[str, _Strainable] | _Strainable = {},
- string: _Strainable | None = None,
- **kwargs: _Strainable,
- ) -> Tag | NavigableString | None: ...
- findNextSibling = find_next_sibling
- def find_next_siblings(
- self,
- name: _Strainable | SoupStrainer | None = None,
- attrs: dict[str, _Strainable] | _Strainable = {},
- string: _Strainable | None = None,
- limit: int | None = None,
- **kwargs: _Strainable,
- ) -> ResultSet[PageElement]: ...
- findNextSiblings = find_next_siblings
- fetchNextSiblings = find_next_siblings
- def find_previous(
- self,
- name: _Strainable | SoupStrainer | None = None,
- attrs: dict[str, _Strainable] | _Strainable = {},
- string: _Strainable | None = None,
- **kwargs: _Strainable,
- ) -> Tag | NavigableString | None: ...
- findPrevious = find_previous
- def find_all_previous(
- self,
- name: _Strainable | SoupStrainer | None = None,
- attrs: dict[str, _Strainable] | _Strainable = {},
- string: _Strainable | None = None,
- limit: int | None = None,
- **kwargs: _Strainable,
- ) -> ResultSet[PageElement]: ...
- findAllPrevious = find_all_previous
- fetchPrevious = find_all_previous
- def find_previous_sibling(
- self,
- name: _Strainable | SoupStrainer | None = None,
- attrs: dict[str, _Strainable] | _Strainable = {},
- string: _Strainable | None = None,
- **kwargs: _Strainable,
- ) -> Tag | NavigableString | None: ...
- findPreviousSibling = find_previous_sibling
- def find_previous_siblings(
- self,
- name: _Strainable | SoupStrainer | None = None,
- attrs: dict[str, _Strainable] | _Strainable = {},
- string: _Strainable | None = None,
- limit: int | None = None,
- **kwargs: _Strainable,
- ) -> ResultSet[PageElement]: ...
- findPreviousSiblings = find_previous_siblings
- fetchPreviousSiblings = find_previous_siblings
- def find_parent(
- self,
- name: _Strainable | SoupStrainer | None = None,
- attrs: dict[str, _Strainable] | _Strainable = {},
- **kwargs: _Strainable,
- ) -> Tag | None: ...
- findParent = find_parent
- def find_parents(
- self,
- name: _Strainable | SoupStrainer | None = None,
- attrs: dict[str, _Strainable] | _Strainable = {},
- limit: int | None = None,
- **kwargs: _Strainable,
- ) -> ResultSet[Tag]: ...
- findParents = find_parents
- fetchParents = find_parents
- @property
- def next(self) -> Tag | NavigableString | None: ...
- @property
- def previous(self) -> Tag | NavigableString | None: ...
- @property
- def next_elements(self) -> Iterable[PageElement]: ...
- @property
- def next_siblings(self) -> Iterable[PageElement]: ...
- @property
- def previous_elements(self) -> Iterable[PageElement]: ...
- @property
- def previous_siblings(self) -> Iterable[PageElement]: ...
- @property
- def parents(self) -> Iterable[Tag]: ...
- @property
- def decomposed(self) -> bool: ...
- def nextGenerator(self) -> Iterable[PageElement]: ...
- def nextSiblingGenerator(self) -> Iterable[PageElement]: ...
- def previousGenerator(self) -> Iterable[PageElement]: ...
- def previousSiblingGenerator(self) -> Iterable[PageElement]: ...
- def parentGenerator(self) -> Iterable[Tag]: ...
-
-class NavigableString(str, PageElement):
- PREFIX: str
- SUFFIX: str
- known_xml: bool | None
- def __new__(cls, value: str | ReadableBuffer) -> Self: ...
- def __copy__(self) -> Self: ...
- def __getnewargs__(self) -> tuple[str]: ...
- def output_ready(self, formatter: Formatter | str | None = "minimal") -> str: ...
- @property
- def name(self) -> None: ...
- @property
- def strings(self) -> Iterable[str]: ...
-
-class PreformattedString(NavigableString):
- PREFIX: str
- SUFFIX: str
- def output_ready(self, formatter: Formatter | str | None = None) -> str: ...
-
-class CData(PreformattedString):
- PREFIX: str
- SUFFIX: str
-
-class ProcessingInstruction(PreformattedString):
- PREFIX: str
- SUFFIX: str
-
-class XMLProcessingInstruction(ProcessingInstruction):
- PREFIX: str
- SUFFIX: str
-
-class Comment(PreformattedString):
- PREFIX: str
- SUFFIX: str
-
-class Declaration(PreformattedString):
- PREFIX: str
- SUFFIX: str
-
-class Doctype(PreformattedString):
- @classmethod
- def for_name_and_ids(cls, name: str | None, pub_id: str, system_id: str) -> Doctype: ...
- PREFIX: str
- SUFFIX: str
-
-class Stylesheet(NavigableString): ...
-class Script(NavigableString): ...
-class TemplateString(NavigableString): ...
-
-class Tag(PageElement):
- parser_class: type[BeautifulSoup] | None
- name: str
- namespace: str | None
- prefix: str | None
- sourceline: int | None
- sourcepos: int | None
- known_xml: bool | None
- attrs: dict[str, str | Any]
- contents: list[PageElement]
- hidden: bool
- can_be_empty_element: bool | None
- cdata_list_attributes: list[str] | None
- preserve_whitespace_tags: list[str] | None
- def __init__(
- self,
- parser: BeautifulSoup | None = None,
- builder: TreeBuilder | None = None,
- name: str | None = None,
- namespace: str | None = None,
- prefix: str | None = None,
- attrs: dict[str, str] | None = None,
- parent: Tag | None = None,
- previous: PageElement | None = None,
- is_xml: bool | None = None,
- sourceline: int | None = None,
- sourcepos: int | None = None,
- can_be_empty_element: bool | None = None,
- cdata_list_attributes: list[str] | None = None,
- preserve_whitespace_tags: list[str] | None = None,
- interesting_string_types: type[NavigableString] | tuple[type[NavigableString], ...] | None = None,
- namespaces: dict[str, str] | None = None,
- ) -> None: ...
- parserClass: type[BeautifulSoup] | None
- def __copy__(self) -> Self: ...
- @property
- def is_empty_element(self) -> bool: ...
- @property
- def isSelfClosing(self) -> bool: ...
- @property
- def string(self) -> str | None: ...
- @string.setter
- def string(self, string: str) -> None: ...
- DEFAULT_INTERESTING_STRING_TYPES: tuple[type[NavigableString], ...]
- @property
- def strings(self) -> Iterable[str]: ...
- def decompose(self) -> None: ...
- def clear(self, decompose: bool = False) -> None: ...
- def smooth(self) -> None: ...
- def index(self, element: PageElement) -> int: ...
- @overload
- def get(self, key: str, default: None = None) -> str | list[str] | None: ...
- @overload
- def get(self, key: str, default: _T) -> str | list[str] | _T: ...
- @overload
- def get_attribute_list(self, key: str, default: None = None) -> list[str | None]: ...
- @overload
- def get_attribute_list(self, key: str, default: list[_T]) -> list[str | _T]: ...
- @overload
- def get_attribute_list(self, key: str, default: _T) -> list[str | _T]: ...
- def has_attr(self, key: str) -> bool: ...
- def __hash__(self) -> int: ...
- def __getitem__(self, key: str) -> str | list[str]: ...
- def __iter__(self) -> Iterator[PageElement]: ...
- def __len__(self) -> int: ...
- def __contains__(self, x: object) -> bool: ...
- def __bool__(self) -> bool: ...
- def __setitem__(self, key: str, value: str | list[str]) -> None: ...
- def __delitem__(self, key: str) -> None: ...
- def __getattr__(self, tag: str) -> Tag | None: ...
- def __eq__(self, other: object) -> bool: ...
- def __ne__(self, other: object) -> bool: ...
- def __unicode__(self) -> str: ...
- def encode(
- self,
- encoding: str = "utf-8",
- indent_level: int | None = None,
- formatter: Literal["html", "html5", "minimal"] | Formatter | None = "minimal",
- errors: str = "xmlcharrefreplace",
- ) -> bytes: ...
- def decode(
- self,
- indent_level: int | None = None,
- eventual_encoding: str = "utf-8",
- formatter: Literal["html", "html5", "minimal"] | Formatter | None = "minimal",
- iterator: Iterator[PageElement] | None = None,
- ) -> str: ...
- @overload
- def prettify(self, encoding: str, formatter: Literal["html", "html5", "minimal"] | Formatter | None = "minimal") -> bytes: ...
- @overload
- def prettify(
- self, encoding: None = None, formatter: Literal["html", "html5", "minimal"] | Formatter | None = "minimal"
- ) -> str: ...
- def decode_contents(
- self,
- indent_level: int | None = None,
- eventual_encoding: str = "utf-8",
- formatter: Literal["html", "html5", "minimal"] | Formatter | None = "minimal",
- ) -> str: ...
- def encode_contents(
- self,
- indent_level: int | None = None,
- encoding: str = "utf-8",
- formatter: Literal["html", "html5", "minimal"] | Formatter | None = "minimal",
- ) -> bytes: ...
- def renderContents(self, encoding: str = "utf-8", prettyPrint: bool = False, indentLevel: int = 0) -> bytes: ...
- def find(
- self,
- name: _Strainable | None = None,
- attrs: dict[str, _Strainable] | _Strainable = {},
- recursive: bool = True,
- string: _Strainable | None = None,
- **kwargs: _Strainable,
- ) -> Tag | NavigableString | None: ...
- findChild = find
- def find_all(
- self,
- name: _Strainable | None = None,
- attrs: dict[str, _Strainable] | _Strainable = {},
- recursive: bool = True,
- string: _Strainable | None = None,
- limit: int | None = None,
- **kwargs: _Strainable,
- ) -> ResultSet[Any]: ...
- __call__ = find_all
- findAll = find_all
- findChildren = find_all
- @property
- def children(self) -> Iterable[PageElement]: ...
- @property
- def descendants(self) -> Iterable[PageElement]: ...
- def select_one(
- self, selector: str, namespaces=None, *, flags: int = ..., custom: dict[str, str] | None = ...
- ) -> Tag | None: ...
- def select(
- self, selector: str, namespaces=None, limit: int | None = None, *, flags: int = ..., custom: dict[str, str] | None = ...
- ) -> ResultSet[Tag]: ...
- def childGenerator(self) -> Iterable[PageElement]: ...
- def recursiveChildGenerator(self) -> Iterable[PageElement]: ...
- def has_key(self, key: str) -> bool: ...
-
-class SoupStrainer:
- name: _NormalizedStrainable
- attrs: dict[str, _NormalizedStrainable]
- string: _NormalizedStrainable
- def __init__(
- self,
- name: _Strainable | None = None,
- attrs: dict[str, _Strainable] | _Strainable = {},
- string: _Strainable | None = None,
- **kwargs: _Strainable,
- ) -> None: ...
- def search_tag(self, markup_name: Tag | str | None = None, markup_attrs={}): ...
- searchTag = search_tag
- def search(self, markup: PageElement | Iterable[PageElement]): ...
-
-class ResultSet(list[_PageElementT]):
- source: SoupStrainer
- @overload
- def __init__(self, source: SoupStrainer) -> None: ...
- @overload
- def __init__(self, source: SoupStrainer, result: Iterable[_PageElementT]) -> None: ...
diff --git a/python/helpers/typeshed/stubs/beautifulsoup4/bs4/formatter.pyi b/python/helpers/typeshed/stubs/beautifulsoup4/bs4/formatter.pyi
deleted file mode 100644
index b6e4facd406a..000000000000
--- a/python/helpers/typeshed/stubs/beautifulsoup4/bs4/formatter.pyi
+++ /dev/null
@@ -1,50 +0,0 @@
-from collections.abc import Callable
-from typing_extensions import TypeAlias
-
-from .dammit import EntitySubstitution as EntitySubstitution
-
-_EntitySubstitution: TypeAlias = Callable[[str], str]
-
-class Formatter(EntitySubstitution):
- HTML: str
- XML: str
- HTML_DEFAULTS: dict[str, set[str]]
- language: str | None
- entity_substitution: _EntitySubstitution
- void_element_close_prefix: str | None
- cdata_containing_tags: list[str]
- empty_attributes_are_booleans: bool
- def __init__(
- self,
- language: str | None = None,
- entity_substitution: _EntitySubstitution | None = None,
- void_element_close_prefix: str | None = "/",
- cdata_containing_tags: list[str] | None = None,
- empty_attributes_are_booleans: bool = False,
- indent: int = 1,
- ) -> None: ...
- def substitute(self, ns: str) -> str: ...
- def attribute_value(self, value: str) -> str: ...
- def attributes(self, tag): ...
-
-class HTMLFormatter(Formatter):
- REGISTRY: dict[str, HTMLFormatter]
- def __init__(
- self,
- entity_substitution: _EntitySubstitution | None = ...,
- void_element_close_prefix: str | None = ...,
- cdata_containing_tags: list[str] | None = ...,
- empty_attributes_are_booleans: bool = False,
- indent: int = 1,
- ) -> None: ...
-
-class XMLFormatter(Formatter):
- REGISTRY: dict[str, XMLFormatter]
- def __init__(
- self,
- entity_substitution: _EntitySubstitution | None = ...,
- void_element_close_prefix: str | None = ...,
- cdata_containing_tags: list[str] | None = ...,
- empty_attributes_are_booleans: bool = False,
- indent: int = 1,
- ) -> None: ...
diff --git a/python/helpers/typeshed/stubs/bleach/bleach/callbacks.pyi b/python/helpers/typeshed/stubs/bleach/bleach/callbacks.pyi
index 5e497cc70328..2e92a8645cfb 100644
--- a/python/helpers/typeshed/stubs/bleach/bleach/callbacks.pyi
+++ b/python/helpers/typeshed/stubs/bleach/bleach/callbacks.pyi
@@ -1,11 +1,12 @@
from collections.abc import MutableMapping
-from typing import Protocol
+from typing import Protocol, type_check_only
from typing_extensions import TypeAlias
from bleach import _HTMLAttrKey
_HTMLAttrs: TypeAlias = MutableMapping[_HTMLAttrKey, str]
+@type_check_only
class _Callback(Protocol): # noqa: Y046
def __call__(self, attrs: _HTMLAttrs, new: bool = ..., /) -> _HTMLAttrs: ...
diff --git a/python/helpers/typeshed/stubs/bleach/bleach/html5lib_shim.pyi b/python/helpers/typeshed/stubs/bleach/bleach/html5lib_shim.pyi
index 792de6da4418..d24c2d825f33 100644
--- a/python/helpers/typeshed/stubs/bleach/bleach/html5lib_shim.pyi
+++ b/python/helpers/typeshed/stubs/bleach/bleach/html5lib_shim.pyi
@@ -1,7 +1,7 @@
import re
from codecs import CodecInfo
from collections.abc import Generator, Iterable, Iterator
-from typing import Any, Final, Protocol
+from typing import Any, Final, Protocol, type_check_only
# We don't re-export any `html5lib` types / values here, because they are not
# really public and may change at any time. This is just a helper module,
@@ -14,6 +14,7 @@ from html5lib.serializer import HTMLSerializer
from html5lib.treewalkers.base import TreeWalker
# Is actually webencodings.Encoding
+@type_check_only
class _Encoding(Protocol):
name: str
codec_info: CodecInfo
diff --git a/python/helpers/typeshed/stubs/boltons/boltons/cacheutils.pyi b/python/helpers/typeshed/stubs/boltons/boltons/cacheutils.pyi
index 751aaec3b1e8..40e786e61bd8 100644
--- a/python/helpers/typeshed/stubs/boltons/boltons/cacheutils.pyi
+++ b/python/helpers/typeshed/stubs/boltons/boltons/cacheutils.pyi
@@ -26,6 +26,8 @@ class LRI(dict[_KT, _VT]):
@overload
def get(self, key: _KT, default: None = None) -> _VT | None: ...
@overload
+ def get(self, key: _KT, default: _VT) -> _VT: ...
+ @overload
def get(self, key: _KT, default: _T) -> _T | _VT: ...
def __delitem__(self, key: _KT) -> None: ...
@overload
diff --git a/python/helpers/typeshed/stubs/boltons/boltons/dictutils.pyi b/python/helpers/typeshed/stubs/boltons/boltons/dictutils.pyi
index d57469749539..5e609ef9af13 100644
--- a/python/helpers/typeshed/stubs/boltons/boltons/dictutils.pyi
+++ b/python/helpers/typeshed/stubs/boltons/boltons/dictutils.pyi
@@ -30,7 +30,7 @@ class OrderedMultiDict(dict[_KT, _VT]):
def popall(self, k: _KT, default: _VT = ...) -> list[_VT]: ...
def poplast(self, k: _KT = ..., default: _VT = ...) -> _VT: ...
@overload # type: ignore[override]
- def setdefault(self, k: _KT, default: None = ...) -> _VT | None: ...
+ def setdefault(self, k: _KT, default: None = None) -> _VT | None: ...
@overload
def setdefault(self, k: _KT, default: _VT) -> _VT: ...
def sorted(self, key: _KT | None = None, reverse: bool = False) -> Self: ...
@@ -51,6 +51,7 @@ class FastIterOrderedMultiDict(OrderedMultiDict[_KT, _VT]): # undocumented
def iterkeys(self, multi: bool = False) -> Generator[_KT, None, None]: ...
class OneToOne(dict[_KT, _VT]):
+ __slots__ = ("inv",)
inv: OneToOne[_VT, _KT]
def clear(self) -> None: ...
def copy(self) -> Self: ...
@@ -87,6 +88,7 @@ def subdict(d: dict[_KT, _VT], keep: Iterable[_KT] | None = None, drop: Iterable
class FrozenHashError(TypeError): ... # undocumented
class FrozenDict(dict[_KT, _VT]):
+ __slots__ = ("_hash",)
def __copy__(self) -> Self: ...
@classmethod
def fromkeys(cls, keys: Iterable[_KT], value: _VT | None = None) -> Self: ... # type: ignore[override]
diff --git a/python/helpers/typeshed/stubs/boltons/boltons/mathutils.pyi b/python/helpers/typeshed/stubs/boltons/boltons/mathutils.pyi
index e74ca0e8d2fe..843e8fcd0412 100644
--- a/python/helpers/typeshed/stubs/boltons/boltons/mathutils.pyi
+++ b/python/helpers/typeshed/stubs/boltons/boltons/mathutils.pyi
@@ -12,6 +12,7 @@ def floor(x: float, options: None = None) -> int: ...
def floor(x: float, options: Iterable[float]) -> float: ...
class Bits:
+ __slots__ = ("val", "len")
val: int
len: int
def __init__(self, val: int | list[bool] | str | bytes = 0, len_: int | None = None) -> None: ...
diff --git a/python/helpers/typeshed/stubs/boltons/boltons/setutils.pyi b/python/helpers/typeshed/stubs/boltons/boltons/setutils.pyi
index 576687a763a7..d86104518841 100644
--- a/python/helpers/typeshed/stubs/boltons/boltons/setutils.pyi
+++ b/python/helpers/typeshed/stubs/boltons/boltons/setutils.pyi
@@ -1,10 +1,11 @@
from collections.abc import Collection, Container, Generator, Iterable, Iterator, MutableSet
from itertools import islice
-from typing import Any, Literal, Protocol, SupportsIndex, TypeVar, overload
+from typing import Any, Literal, Protocol, SupportsIndex, TypeVar, overload, type_check_only
from typing_extensions import Self
_T_co = TypeVar("_T_co", covariant=True)
+@type_check_only
class _RSub(Iterable[_T_co], Protocol):
def __new__(cls: type[_RSub[_T_co]], param: list[_T_co], /) -> _RSub[_T_co]: ...
@@ -58,6 +59,7 @@ class IndexedSet(MutableSet[Any]):
def complement(wrapped: Iterable[Any]) -> _ComplementSet: ...
class _ComplementSet:
+ __slots__ = ("_included", "_excluded")
def __init__(
self, included: set[Any] | frozenset[Any] | None = None, excluded: set[Any] | frozenset[Any] | None = None
) -> None: ...
diff --git a/python/helpers/typeshed/stubs/boltons/boltons/tbutils.pyi b/python/helpers/typeshed/stubs/boltons/boltons/tbutils.pyi
index a1fb06843031..1d4648d6f129 100644
--- a/python/helpers/typeshed/stubs/boltons/boltons/tbutils.pyi
+++ b/python/helpers/typeshed/stubs/boltons/boltons/tbutils.pyi
@@ -4,6 +4,7 @@ from typing import Any, Generic, Literal, TypeVar
from typing_extensions import Self
class Callpoint:
+ __slots__ = ("func_name", "lineno", "module_name", "module_path", "lasti", "line")
func_name: str
lineno: int
module_name: str
diff --git a/python/helpers/typeshed/stubs/boltons/boltons/typeutils.pyi b/python/helpers/typeshed/stubs/boltons/boltons/typeutils.pyi
index 8eee8e4dcf06..c2ae45147c94 100644
--- a/python/helpers/typeshed/stubs/boltons/boltons/typeutils.pyi
+++ b/python/helpers/typeshed/stubs/boltons/boltons/typeutils.pyi
@@ -1,6 +1,7 @@
-from typing import Any, Literal, Protocol
+from typing import Any, Literal, Protocol, type_check_only
from typing_extensions import Self
+@type_check_only
class _Sentinel(Protocol):
def __bool__(self) -> Literal[False]: ...
def __copy__(self) -> Self: ...
diff --git a/python/helpers/typeshed/stubs/braintree/METADATA.toml b/python/helpers/typeshed/stubs/braintree/METADATA.toml
index 68b72841465e..de87e7be2fbb 100644
--- a/python/helpers/typeshed/stubs/braintree/METADATA.toml
+++ b/python/helpers/typeshed/stubs/braintree/METADATA.toml
@@ -1,2 +1,2 @@
-version = "4.36.*"
+version = "4.38.*"
upstream_repository = "https://github.com/braintree/braintree_python"
diff --git a/python/helpers/typeshed/stubs/braintree/braintree/__init__.pyi b/python/helpers/typeshed/stubs/braintree/braintree/__init__.pyi
index 8aa7ae9eda5d..081f8b489f52 100644
--- a/python/helpers/typeshed/stubs/braintree/braintree/__init__.pyi
+++ b/python/helpers/typeshed/stubs/braintree/braintree/__init__.pyi
@@ -84,6 +84,7 @@ from braintree.transaction_details import TransactionDetails as TransactionDetai
from braintree.transaction_gateway import TransactionGateway as TransactionGateway
from braintree.transaction_line_item import TransactionLineItem as TransactionLineItem
from braintree.transaction_search import TransactionSearch as TransactionSearch
+from braintree.transfer import Transfer as Transfer
from braintree.unknown_payment_method import UnknownPaymentMethod as UnknownPaymentMethod
from braintree.us_bank_account import UsBankAccount as UsBankAccount
from braintree.validation_error_collection import ValidationErrorCollection as ValidationErrorCollection
diff --git a/python/helpers/typeshed/stubs/braintree/braintree/attribute_getter.pyi b/python/helpers/typeshed/stubs/braintree/braintree/attribute_getter.pyi
index 66998f5d8001..b38cb2a4816a 100644
--- a/python/helpers/typeshed/stubs/braintree/braintree/attribute_getter.pyi
+++ b/python/helpers/typeshed/stubs/braintree/braintree/attribute_getter.pyi
@@ -4,4 +4,4 @@ class AttributeGetter:
def __init__(self, attributes: dict[str, Any] | None = None) -> None: ...
# This doesn't exist at runtime, but subclasses should define their own fields populated by attributes in __init__
# Until that's done, keep __getattribute__ to fill in the gaps
- def __getattribute__(self, name: str) -> Any: ...
+ def __getattribute__(self, name: str, /) -> Any: ...
diff --git a/python/helpers/typeshed/stubs/braintree/braintree/graphql/types/customer_recommendations_payload.pyi b/python/helpers/typeshed/stubs/braintree/braintree/graphql/types/customer_recommendations_payload.pyi
index d03908781b87..f3d9be7bfc57 100644
--- a/python/helpers/typeshed/stubs/braintree/braintree/graphql/types/customer_recommendations_payload.pyi
+++ b/python/helpers/typeshed/stubs/braintree/braintree/graphql/types/customer_recommendations_payload.pyi
@@ -1,13 +1,21 @@
-from typing import Any
+from typing import Any, overload
from braintree.graphql.unions.customer_recommendations import CustomerRecommendations
class CustomerRecommendationsPayload:
- is_in_paypal_network: bool | None
- recommendations: CustomerRecommendations | None
+ session_id: str
+ is_in_paypal_network: bool
+ recommendations: CustomerRecommendations
+ @overload
def __init__(
self,
- is_in_paypal_network: bool | None = None,
- recommendations: CustomerRecommendations | None = None,
- response: dict[str, Any] | None = None,
+ session_id: None = None,
+ is_in_paypal_network: None = None,
+ recommendations: None = None,
+ *,
+ response: dict[str, Any],
+ ): ...
+ @overload
+ def __init__(
+ self, session_id: str, is_in_paypal_network: bool, recommendations: CustomerRecommendations, response: None = None
): ...
diff --git a/python/helpers/typeshed/stubs/braintree/braintree/transaction.pyi b/python/helpers/typeshed/stubs/braintree/braintree/transaction.pyi
index 9fe08991b64a..6aebd7369799 100644
--- a/python/helpers/typeshed/stubs/braintree/braintree/transaction.pyi
+++ b/python/helpers/typeshed/stubs/braintree/braintree/transaction.pyi
@@ -32,6 +32,7 @@ from braintree.sepa_direct_debit_account import SepaDirectDebitAccount
from braintree.status_event import StatusEvent
from braintree.subscription_details import SubscriptionDetails
from braintree.three_d_secure_info import ThreeDSecureInfo
+from braintree.transfer import Transfer
from braintree.us_bank_account import UsBankAccount
from braintree.venmo_account import VenmoAccount
from braintree.visa_checkout_card import VisaCheckoutCard
@@ -174,6 +175,7 @@ class Transaction(Resource):
facilitator_details: FacilitatorDetails
network_transaction_id: Incomplete
payment_facilitator: PaymentFacilitator
+ transfer: Transfer
def __init__(self, gateway, attributes) -> None: ...
@property
def vault_billing_address(self): ...
diff --git a/python/helpers/typeshed/stubs/braintree/braintree/transfer.pyi b/python/helpers/typeshed/stubs/braintree/braintree/transfer.pyi
new file mode 100644
index 000000000000..2146adaea6b7
--- /dev/null
+++ b/python/helpers/typeshed/stubs/braintree/braintree/transfer.pyi
@@ -0,0 +1,4 @@
+from braintree.attribute_getter import AttributeGetter
+
+class Transfer(AttributeGetter):
+ def __init__(self, attributes) -> None: ...
diff --git a/python/helpers/typeshed/stubs/braintree/braintree/util/graphql_client.pyi b/python/helpers/typeshed/stubs/braintree/braintree/util/graphql_client.pyi
index 35c5d3def76c..60792398addd 100644
--- a/python/helpers/typeshed/stubs/braintree/braintree/util/graphql_client.pyi
+++ b/python/helpers/typeshed/stubs/braintree/braintree/util/graphql_client.pyi
@@ -1,24 +1,28 @@
from _typeshed import Incomplete
from collections.abc import Iterable
-from typing import TypedDict
+from typing import TypedDict, type_check_only
from braintree.configuration import Configuration
from braintree.environment import Environment
from braintree.util.http import Http
+@type_check_only
class _Extension(TypedDict):
errorClass: Incomplete
legacyCode: int | None
+@type_check_only
class _Error(TypedDict):
attribute: str | None
code: int | None
message: str | None
extensions: _Extension | None
+@type_check_only
class _ValidationErrors(TypedDict):
errors: Iterable[_Error]
+@type_check_only
class _Response(TypedDict):
errors: Iterable[_Error] | None
diff --git a/python/helpers/typeshed/stubs/braintree/braintree/webhook_notification.pyi b/python/helpers/typeshed/stubs/braintree/braintree/webhook_notification.pyi
index 085fa5de4b6c..06e38fef592a 100644
--- a/python/helpers/typeshed/stubs/braintree/braintree/webhook_notification.pyi
+++ b/python/helpers/typeshed/stubs/braintree/braintree/webhook_notification.pyi
@@ -61,6 +61,7 @@ class WebhookNotification(Resource):
SubscriptionWentActive: Final = "subscription_went_active"
SubscriptionWentPastDue: Final = "subscription_went_past_due"
TransactionDisbursed: Final = "transaction_disbursed"
+ TransactionRetried: Final = "transaction_retried"
TransactionReviewed: Final = "transaction_reviewed"
TransactionSettled: Final = "transaction_settled"
TransactionSettlementDeclined: Final = "transaction_settlement_declined"
diff --git a/python/helpers/typeshed/stubs/cachetools/METADATA.toml b/python/helpers/typeshed/stubs/cachetools/METADATA.toml
index 593de6011b49..fb57be984ae4 100644
--- a/python/helpers/typeshed/stubs/cachetools/METADATA.toml
+++ b/python/helpers/typeshed/stubs/cachetools/METADATA.toml
@@ -1,2 +1,2 @@
-version = "6.0.*"
+version = "6.1.*"
upstream_repository = "https://github.com/tkem/cachetools"
diff --git a/python/helpers/typeshed/stubs/cffi/METADATA.toml b/python/helpers/typeshed/stubs/cffi/METADATA.toml
index 357ce0ff0599..abf41186a33b 100644
--- a/python/helpers/typeshed/stubs/cffi/METADATA.toml
+++ b/python/helpers/typeshed/stubs/cffi/METADATA.toml
@@ -4,4 +4,4 @@ requires = ["types-setuptools"]
[tool.stubtest]
# linux and darwin are mostly equivalent, except for a single `RTLD_DEEPBIND` variable
-platforms = ["linux", "win32"]
+ci_platforms = ["linux", "win32"]
diff --git a/python/helpers/typeshed/stubs/cffi/_cffi_backend.pyi b/python/helpers/typeshed/stubs/cffi/_cffi_backend.pyi
index 850b66706340..25e444825ada 100644
--- a/python/helpers/typeshed/stubs/cffi/_cffi_backend.pyi
+++ b/python/helpers/typeshed/stubs/cffi/_cffi_backend.pyi
@@ -2,11 +2,12 @@ import sys
import types
from _typeshed import Incomplete, ReadableBuffer, WriteableBuffer
from collections.abc import Callable, Hashable
-from typing import Any, ClassVar, Literal, Protocol, SupportsIndex, TypeVar, final, overload
+from typing import Any, ClassVar, Literal, Protocol, SupportsIndex, TypeVar, final, overload, type_check_only
from typing_extensions import TypeAlias
_T = TypeVar("_T")
+@type_check_only
class _Allocator(Protocol):
def __call__(self, cdecl: str | CType, init: Any = ...) -> _CDataBase: ...
@@ -61,45 +62,48 @@ class Lib:
@final
class _CDataBase:
__name__: ClassVar[str]
- def __add__(self, other): ...
+ def __add__(self, other, /): ...
def __bool__(self) -> bool: ...
def __call__(self, *args, **kwargs): ...
def __complex__(self) -> complex: ...
- def __delitem__(self, other) -> None: ...
+ def __delitem__(self, other, /) -> None: ...
def __dir__(self): ...
def __enter__(self): ...
- def __eq__(self, other): ...
- def __exit__(self, type: type[BaseException] | None, value: BaseException | None, traceback: types.TracebackType | None): ...
+ def __eq__(self, other, /): ...
+ def __exit__(
+ self, type: type[BaseException] | None, value: BaseException | None, traceback: types.TracebackType | None, /
+ ): ...
def __float__(self) -> float: ...
- def __ge__(self, other): ...
- def __getitem__(self, index: SupportsIndex | slice): ...
- def __gt__(self, other): ...
+ def __ge__(self, other, /): ...
+ def __getitem__(self, index: SupportsIndex | slice, /): ...
+ def __gt__(self, other, /): ...
def __hash__(self) -> int: ...
def __int__(self) -> int: ...
def __iter__(self): ...
- def __le__(self, other): ...
+ def __le__(self, other, /): ...
def __len__(self) -> int: ...
- def __lt__(self, other): ...
- def __ne__(self, other): ...
- def __radd__(self, other): ...
- def __rsub__(self, other): ...
- def __setitem__(self, index: SupportsIndex | slice, object) -> None: ...
- def __sub__(self, other): ...
+ def __lt__(self, other, /): ...
+ def __ne__(self, other, /): ...
+ def __radd__(self, other, /): ...
+ def __rsub__(self, other, /): ...
+ def __setitem__(self, index: SupportsIndex | slice, object, /) -> None: ...
+ def __sub__(self, other, /): ...
@final
class buffer:
__hash__: ClassVar[None] # type: ignore[assignment]
def __init__(self, *args, **kwargs) -> None: ...
- def __delitem__(self, other) -> None: ...
- def __eq__(self, other): ...
- def __ge__(self, other): ...
- def __getitem__(self, index): ...
- def __gt__(self, other): ...
- def __le__(self, other): ...
+ def __buffer__(self, flags: int, /) -> memoryview: ...
+ def __delitem__(self, other, /) -> None: ...
+ def __eq__(self, other, /): ...
+ def __ge__(self, other, /): ...
+ def __getitem__(self, index, /): ...
+ def __gt__(self, other, /): ...
+ def __le__(self, other, /): ...
def __len__(self) -> int: ...
- def __lt__(self, other): ...
- def __ne__(self, other): ...
- def __setitem__(self, index, object) -> None: ...
+ def __lt__(self, other, /): ...
+ def __ne__(self, other, /): ...
+ def __setitem__(self, index, object, /) -> None: ...
# These aliases are to work around pyright complaints.
# Pyright doesn't like it when a class object is defined as an alias
diff --git a/python/helpers/typeshed/stubs/cffi/cffi/api.pyi b/python/helpers/typeshed/stubs/cffi/cffi/api.pyi
index 4e17fc564534..07e9ffccab35 100644
--- a/python/helpers/typeshed/stubs/cffi/cffi/api.pyi
+++ b/python/helpers/typeshed/stubs/cffi/cffi/api.pyi
@@ -29,7 +29,7 @@ class FFI:
if sys.platform == "win32":
def dlopen(self, name: str, flags: int = ...) -> _cffi_backend.Lib: ...
else:
- def dlopen(self, name: str | None, flags: int = ...) -> _cffi_backend.Lib: ...
+ def dlopen(self, name: str | None, flags: int = 0) -> _cffi_backend.Lib: ...
def dlclose(self, lib: _cffi_backend.Lib) -> None: ...
def typeof(self, cdecl: str | CData | types.BuiltinFunctionType | types.FunctionType) -> CType: ...
diff --git a/python/helpers/typeshed/stubs/cffi/cffi/backend_ctypes.pyi b/python/helpers/typeshed/stubs/cffi/cffi/backend_ctypes.pyi
index 7faef0c73d59..04c0e8a8ffbe 100644
--- a/python/helpers/typeshed/stubs/cffi/cffi/backend_ctypes.pyi
+++ b/python/helpers/typeshed/stubs/cffi/cffi/backend_ctypes.pyi
@@ -9,6 +9,7 @@ bytechr: Callable[[float], bytes]
class CTypesType(type): ...
class CTypesData:
+ __slots__ = ["__weakref__"]
__metaclass__: Incomplete
__name__: str
def __init__(self, *args) -> None: ...
@@ -23,17 +24,21 @@ class CTypesData:
def __repr__(self, c_name: str | None = None): ...
class CTypesGenericPrimitive(CTypesData):
+ __slots__: list[str] = []
def __hash__(self) -> int: ...
class CTypesGenericArray(CTypesData):
+ __slots__: list[str] = []
def __iter__(self): ...
class CTypesGenericPtr(CTypesData):
+ __slots__ = ["_address", "_as_ctype_ptr"]
kind: str
def __nonzero__(self) -> bool: ...
def __bool__(self) -> bool: ...
-class CTypesBaseStructOrUnion(CTypesData): ...
+class CTypesBaseStructOrUnion(CTypesData):
+ __slots__ = ["_blob"]
class CTypesBackend:
PRIMITIVE_TYPES: Incomplete
diff --git a/python/helpers/typeshed/stubs/cffi/cffi/pkgconfig.pyi b/python/helpers/typeshed/stubs/cffi/cffi/pkgconfig.pyi
index 4c4af8283e6e..510961c2b349 100644
--- a/python/helpers/typeshed/stubs/cffi/cffi/pkgconfig.pyi
+++ b/python/helpers/typeshed/stubs/cffi/cffi/pkgconfig.pyi
@@ -1,5 +1,5 @@
from collections.abc import Sequence
def merge_flags(cfg1: dict[str, list[str]], cfg2: dict[str, list[str]]) -> dict[str, list[str]]: ...
-def call(libname: str, flag: str, encoding: str = ...) -> str: ...
+def call(libname: str, flag: str, encoding: str = "utf-8") -> str: ...
def flags_from_pkgconfig(libs: Sequence[str]) -> dict[str, list[str]]: ...
diff --git a/python/helpers/typeshed/stubs/channels/@tests/django_settings.py b/python/helpers/typeshed/stubs/channels/@tests/django_settings.py
new file mode 100644
index 000000000000..2be16834be19
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/@tests/django_settings.py
@@ -0,0 +1,12 @@
+SECRET_KEY = "1"
+
+INSTALLED_APPS = (
+ "django.contrib.contenttypes",
+ "django.contrib.sites",
+ "django.contrib.sessions",
+ "django.contrib.messages",
+ "django.contrib.admin.apps.SimpleAdminConfig",
+ "django.contrib.staticfiles",
+ "django.contrib.auth",
+ "channels",
+)
diff --git a/python/helpers/typeshed/stubs/channels/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/channels/@tests/stubtest_allowlist.txt
new file mode 100644
index 000000000000..c5c5761b73fe
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/@tests/stubtest_allowlist.txt
@@ -0,0 +1,15 @@
+# channels.auth.UserLazyObject metaclass is mismatch
+channels.auth.UserLazyObject
+
+# these one need to be exclude due to mypy error: * is not present at runtime
+channels.auth.UserLazyObject.DoesNotExist
+channels.auth.UserLazyObject.MultipleObjectsReturned
+channels.auth.UserLazyObject@AnnotatedWith
+
+# database_sync_to_async is implemented as a class instance but stubbed as a function
+# for better type inference when used as decorator/function
+channels.db.database_sync_to_async
+
+# Set to None on class, but initialized to non-None value in __init__
+channels.generic.websocket.WebsocketConsumer.groups
+channels.generic.websocket.AsyncWebsocketConsumer.groups
diff --git a/python/helpers/typeshed/stubs/channels/METADATA.toml b/python/helpers/typeshed/stubs/channels/METADATA.toml
new file mode 100644
index 000000000000..8cd561ad6b15
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/METADATA.toml
@@ -0,0 +1,8 @@
+version = "4.3.*"
+upstream_repository = "https://github.com/django/channels"
+requires = ["django-stubs>=4.2,<5.3", "asgiref"]
+
+[tool.stubtest]
+mypy_plugins = ['mypy_django_plugin.main']
+mypy_plugins_config = {"django-stubs" = {"django_settings_module" = "@tests.django_settings"}}
+stubtest_requirements = ["daphne"]
diff --git a/python/helpers/typeshed/stubs/channels/channels/__init__.pyi b/python/helpers/typeshed/stubs/channels/channels/__init__.pyi
new file mode 100644
index 000000000000..561199954632
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/__init__.pyi
@@ -0,0 +1,4 @@
+from typing import Final
+
+__version__: Final[str]
+DEFAULT_CHANNEL_LAYER: Final[str]
diff --git a/python/helpers/typeshed/stubs/channels/channels/apps.pyi b/python/helpers/typeshed/stubs/channels/channels/apps.pyi
new file mode 100644
index 000000000000..ad15a21b6961
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/apps.pyi
@@ -0,0 +1,7 @@
+from typing import Final
+
+from django.apps import AppConfig
+
+class ChannelsConfig(AppConfig):
+ name: Final = "channels"
+ verbose_name: str = "Channels"
diff --git a/python/helpers/typeshed/stubs/channels/channels/auth.pyi b/python/helpers/typeshed/stubs/channels/channels/auth.pyi
new file mode 100644
index 000000000000..b8594667e059
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/auth.pyi
@@ -0,0 +1,26 @@
+from asgiref.typing import ASGIReceiveCallable, ASGISendCallable
+from channels.middleware import BaseMiddleware
+from django.contrib.auth.backends import BaseBackend
+from django.contrib.auth.base_user import AbstractBaseUser
+from django.contrib.auth.models import AnonymousUser
+from django.utils.functional import LazyObject
+
+from .consumer import _ChannelScope
+from .utils import _ChannelApplication
+
+async def get_user(scope: _ChannelScope) -> AbstractBaseUser | AnonymousUser: ...
+async def login(scope: _ChannelScope, user: AbstractBaseUser, backend: BaseBackend | None = None) -> None: ...
+async def logout(scope: _ChannelScope) -> None: ...
+
+# Inherits AbstractBaseUser to improve autocomplete and show this is a lazy proxy for a user.
+# At runtime, it's just a LazyObject that wraps the actual user instance.
+class UserLazyObject(AbstractBaseUser, LazyObject): ...
+
+class AuthMiddleware(BaseMiddleware):
+ def populate_scope(self, scope: _ChannelScope) -> None: ...
+ async def resolve_scope(self, scope: _ChannelScope) -> None: ...
+ async def __call__(
+ self, scope: _ChannelScope, receive: ASGIReceiveCallable, send: ASGISendCallable
+ ) -> _ChannelApplication: ...
+
+def AuthMiddlewareStack(inner: _ChannelApplication) -> _ChannelApplication: ...
diff --git a/python/helpers/typeshed/stubs/channels/channels/consumer.pyi b/python/helpers/typeshed/stubs/channels/channels/consumer.pyi
new file mode 100644
index 000000000000..66a1ba0df89d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/consumer.pyi
@@ -0,0 +1,75 @@
+from collections.abc import Awaitable
+from typing import Any, ClassVar, Protocol, TypedDict, type_check_only
+
+from asgiref.typing import ASGIReceiveCallable, ASGISendCallable, Scope, WebSocketScope
+from channels.auth import UserLazyObject
+from channels.db import database_sync_to_async
+from channels.layers import BaseChannelLayer
+from django.contrib.sessions.backends.base import SessionBase
+from django.utils.functional import LazyObject
+
+# _LazySession is a LazyObject that wraps a SessionBase instance.
+# We subclass both for type checking purposes to expose SessionBase attributes,
+# and suppress mypy's "misc" error with `# type: ignore[misc]`.
+@type_check_only
+class _LazySession(SessionBase, LazyObject): # type: ignore[misc]
+ _wrapped: SessionBase
+
+@type_check_only
+class _URLRoute(TypedDict):
+ # Values extracted from Django's URLPattern matching,
+ # passed through ASGI scope routing.
+ # `args` and `kwargs` are the result of pattern matching against the URL path.
+ args: tuple[Any, ...]
+ kwargs: dict[str, Any]
+
+# Channel Scope definition
+@type_check_only
+class _ChannelScope(WebSocketScope, total=False):
+ # Channels specific
+ channel: str
+ url_route: _URLRoute
+ path_remaining: str
+
+ # Auth specific
+ cookies: dict[str, str]
+ session: _LazySession
+ user: UserLazyObject | None
+
+# Accepts any ASGI message dict with a required "type" key (str),
+# but allows additional arbitrary keys for flexibility.
+def get_handler_name(message: dict[str, Any]) -> str: ...
+@type_check_only
+class _ASGIApplicationProtocol(Protocol):
+ consumer_class: AsyncConsumer
+
+ # Accepts any initialization kwargs passed to the consumer class.
+ # Typed as `Any` to allow flexibility in subclass-specific arguments.
+ consumer_initkwargs: Any
+
+ def __call__(self, scope: Scope, receive: ASGIReceiveCallable, send: ASGISendCallable) -> Awaitable[None]: ...
+
+class AsyncConsumer:
+ channel_layer_alias: ClassVar[str]
+
+ scope: _ChannelScope
+ channel_layer: BaseChannelLayer
+ channel_name: str
+ channel_receive: ASGIReceiveCallable
+ base_send: ASGISendCallable
+
+ async def __call__(self, scope: _ChannelScope, receive: ASGIReceiveCallable, send: ASGISendCallable) -> None: ...
+ async def dispatch(self, message: dict[str, Any]) -> None: ...
+ async def send(self, message: dict[str, Any]) -> None: ...
+
+ # initkwargs will be used to instantiate the consumer instance.
+ @classmethod
+ def as_asgi(cls, **initkwargs: Any) -> _ASGIApplicationProtocol: ...
+
+class SyncConsumer(AsyncConsumer):
+
+ # Since we're overriding asynchronous methods with synchronous ones,
+ # we need to use `# type: ignore[override]` to suppress mypy errors.
+ @database_sync_to_async
+ def dispatch(self, message: dict[str, Any]) -> None: ... # type: ignore[override]
+ def send(self, message: dict[str, Any]) -> None: ... # type: ignore[override]
diff --git a/python/helpers/typeshed/stubs/channels/channels/db.pyi b/python/helpers/typeshed/stubs/channels/channels/db.pyi
new file mode 100644
index 000000000000..c0147a05b03d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/db.pyi
@@ -0,0 +1,32 @@
+import asyncio
+from _typeshed import OptExcInfo
+from asyncio import BaseEventLoop
+from collections.abc import Callable, Coroutine
+from concurrent.futures import ThreadPoolExecutor
+from typing import Any, TypeVar
+from typing_extensions import ParamSpec
+
+from asgiref.sync import SyncToAsync
+
+_P = ParamSpec("_P")
+_R = TypeVar("_R")
+
+class DatabaseSyncToAsync(SyncToAsync[_P, _R]):
+ def thread_handler(
+ self,
+ loop: BaseEventLoop,
+ exc_info: OptExcInfo,
+ task_context: list[asyncio.Task[Any]] | None,
+ func: Callable[_P, _R],
+ *args: _P.args,
+ **kwargs: _P.kwargs,
+ ) -> _R: ...
+
+# We define `database_sync_to_async` as a function instead of assigning
+# `DatabaseSyncToAsync(...)` directly, to preserve both decorator and
+# higher-order function behavior with correct type hints.
+# A direct assignment would result in incorrect type inference for the wrapped function.
+def database_sync_to_async(
+ func: Callable[_P, _R], thread_sensitive: bool = True, executor: ThreadPoolExecutor | None = None
+) -> Callable[_P, Coroutine[Any, Any, _R]]: ...
+async def aclose_old_connections() -> None: ...
diff --git a/python/helpers/typeshed/stubs/channels/channels/exceptions.pyi b/python/helpers/typeshed/stubs/channels/channels/exceptions.pyi
new file mode 100644
index 000000000000..eaba1dfaee14
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/exceptions.pyi
@@ -0,0 +1,8 @@
+class RequestAborted(Exception): ...
+class RequestTimeout(RequestAborted): ...
+class InvalidChannelLayerError(ValueError): ...
+class AcceptConnection(Exception): ...
+class DenyConnection(Exception): ...
+class ChannelFull(Exception): ...
+class MessageTooLarge(Exception): ...
+class StopConsumer(Exception): ...
diff --git a/python/helpers/typeshed/stubs/channels/channels/generic/__init__.pyi b/python/helpers/typeshed/stubs/channels/channels/generic/__init__.pyi
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/python/helpers/typeshed/stubs/channels/channels/generic/http.pyi b/python/helpers/typeshed/stubs/channels/channels/generic/http.pyi
new file mode 100644
index 000000000000..84e3b1dbff84
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/generic/http.pyi
@@ -0,0 +1,19 @@
+from _typeshed import Unused
+from collections.abc import Iterable
+from typing import Any
+
+from asgiref.typing import HTTPDisconnectEvent, HTTPRequestEvent, HTTPScope
+from channels.consumer import AsyncConsumer
+
+class AsyncHttpConsumer(AsyncConsumer):
+ body: list[bytes]
+ scope: HTTPScope # type: ignore[assignment]
+
+ def __init__(self, *args: Unused, **kwargs: Unused) -> None: ...
+ async def send_headers(self, *, status: int = 200, headers: Iterable[tuple[bytes, bytes]] | None = None) -> None: ...
+ async def send_body(self, body: bytes, *, more_body: bool = False) -> None: ...
+ async def send_response(self, status: int, body: bytes, **kwargs: Any) -> None: ...
+ async def handle(self, body: bytes) -> None: ...
+ async def disconnect(self) -> None: ...
+ async def http_request(self, message: HTTPRequestEvent) -> None: ...
+ async def http_disconnect(self, message: HTTPDisconnectEvent) -> None: ...
diff --git a/python/helpers/typeshed/stubs/channels/channels/generic/websocket.pyi b/python/helpers/typeshed/stubs/channels/channels/generic/websocket.pyi
new file mode 100644
index 000000000000..f19d406e1e5d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/generic/websocket.pyi
@@ -0,0 +1,61 @@
+from _typeshed import Unused
+from typing import Any
+
+from asgiref.typing import WebSocketConnectEvent, WebSocketDisconnectEvent, WebSocketReceiveEvent
+from channels.consumer import AsyncConsumer, SyncConsumer
+
+class WebsocketConsumer(SyncConsumer):
+ groups: list[str]
+
+ def __init__(self, *args: Unused, **kwargs: Unused) -> None: ...
+ def websocket_connect(self, message: WebSocketConnectEvent) -> None: ...
+ def connect(self) -> None: ...
+ def accept(self, subprotocol: str | None = None, headers: list[tuple[str, str]] | None = None) -> None: ...
+ def websocket_receive(self, message: WebSocketReceiveEvent) -> None: ...
+ def receive(self, text_data: str | None = None, bytes_data: bytes | None = None) -> None: ...
+ def send( # type: ignore[override]
+ self, text_data: str | None = None, bytes_data: bytes | None = None, close: bool = False
+ ) -> None: ...
+ def close(self, code: int | bool | None = None, reason: str | None = None) -> None: ...
+ def websocket_disconnect(self, message: WebSocketDisconnectEvent) -> None: ...
+ def disconnect(self, code: int) -> None: ...
+
+class JsonWebsocketConsumer(WebsocketConsumer):
+ def receive(self, text_data: str | None = None, bytes_data: bytes | None = None, **kwargs: Any) -> None: ...
+ # content is typed as Any to match json.loads() return type - JSON can represent
+ # various Python types (dict, list, str, int, float, bool, None)
+ def receive_json(self, content: Any, **kwargs: Any) -> None: ...
+ # content is typed as Any to match json.dumps() input type - accepts any JSON-serializable object
+ def send_json(self, content: Any, close: bool = False) -> None: ...
+ @classmethod
+ def decode_json(cls, text_data: str) -> Any: ... # Returns Any like json.loads()
+ @classmethod
+ def encode_json(cls, content: Any) -> str: ... # Accepts Any like json.dumps()
+
+class AsyncWebsocketConsumer(AsyncConsumer):
+ groups: list[str]
+
+ def __init__(self, *args: Unused, **kwargs: Unused) -> None: ...
+ async def websocket_connect(self, message: WebSocketConnectEvent) -> None: ...
+ async def connect(self) -> None: ...
+ async def accept(self, subprotocol: str | None = None, headers: list[tuple[str, str]] | None = None) -> None: ...
+ async def websocket_receive(self, message: WebSocketReceiveEvent) -> None: ...
+ async def receive(self, text_data: str | None = None, bytes_data: bytes | None = None) -> None: ...
+ async def send( # type: ignore[override]
+ self, text_data: str | None = None, bytes_data: bytes | None = None, close: bool = False
+ ) -> None: ...
+ async def close(self, code: int | bool | None = None, reason: str | None = None) -> None: ...
+ async def websocket_disconnect(self, message: WebSocketDisconnectEvent) -> None: ...
+ async def disconnect(self, code: int) -> None: ...
+
+class AsyncJsonWebsocketConsumer(AsyncWebsocketConsumer):
+ async def receive(self, text_data: str | None = None, bytes_data: bytes | None = None, **kwargs: Any) -> None: ...
+ # content is typed as Any to match json.loads() return type - JSON can represent
+ # various Python types (dict, list, str, int, float, bool, None)
+ async def receive_json(self, content: Any, **kwargs: Any) -> None: ...
+ # content is typed as Any to match json.dumps() input type - accepts any JSON-serializable object
+ async def send_json(self, content: Any, close: bool = False) -> None: ...
+ @classmethod
+ async def decode_json(cls, text_data: str) -> Any: ... # Returns Any like json.loads()
+ @classmethod
+ async def encode_json(cls, content: Any) -> str: ... # Accepts Any like json.dumps()
diff --git a/python/helpers/typeshed/stubs/channels/channels/layers.pyi b/python/helpers/typeshed/stubs/channels/channels/layers.pyi
new file mode 100644
index 000000000000..1fae3a125aae
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/layers.pyi
@@ -0,0 +1,91 @@
+import asyncio
+from re import Pattern
+from typing import Any, ClassVar, overload
+from typing_extensions import TypeAlias, deprecated
+
+class ChannelLayerManager:
+ backends: dict[str, BaseChannelLayer]
+
+ def __init__(self) -> None: ...
+ @property
+ def configs(self) -> dict[str, Any]: ...
+ def make_backend(self, name: str) -> BaseChannelLayer: ...
+ def make_test_backend(self, name: str) -> Any: ...
+ def __getitem__(self, key: str) -> BaseChannelLayer: ...
+ def __contains__(self, key: str) -> bool: ...
+ def set(self, key: str, layer: BaseChannelLayer) -> BaseChannelLayer | None: ...
+
+_ChannelCapacityPattern: TypeAlias = Pattern[str] | str
+_ChannelCapacityDict: TypeAlias = dict[_ChannelCapacityPattern, int]
+_CompiledChannelCapacity: TypeAlias = list[tuple[Pattern[str], int]]
+
+class BaseChannelLayer:
+ MAX_NAME_LENGTH: ClassVar[int] = 100
+ expiry: int
+ capacity: int
+ channel_capacity: _ChannelCapacityDict
+ channel_name_regex: Pattern[str]
+ group_name_regex: Pattern[str]
+ invalid_name_error: str
+
+ def __init__(self, expiry: int = 60, capacity: int = 100, channel_capacity: _ChannelCapacityDict | None = None) -> None: ...
+ def compile_capacities(self, channel_capacity: _ChannelCapacityDict) -> _CompiledChannelCapacity: ...
+ def get_capacity(self, channel: str) -> int: ...
+ @overload
+ def match_type_and_length(self, name: str) -> bool: ...
+ @overload
+ def match_type_and_length(self, name: object) -> bool: ...
+ @overload
+ def require_valid_channel_name(self, name: str, receive: bool = False) -> bool: ...
+ @overload
+ def require_valid_channel_name(self, name: object, receive: bool = False) -> bool: ...
+ @overload
+ def require_valid_group_name(self, name: str) -> bool: ...
+ @overload
+ def require_valid_group_name(self, name: object) -> bool: ...
+ @overload
+ def valid_channel_names(self, names: list[str], receive: bool = False) -> bool: ...
+ @overload
+ def valid_channel_names(self, names: list[Any], receive: bool = False) -> bool: ...
+ def non_local_name(self, name: str) -> str: ...
+ async def send(self, channel: str, message: dict[str, Any]) -> None: ...
+ async def receive(self, channel: str) -> dict[str, Any]: ...
+ async def new_channel(self) -> str: ...
+ async def flush(self) -> None: ...
+ async def group_add(self, group: str, channel: str) -> None: ...
+ async def group_discard(self, group: str, channel: str) -> None: ...
+ async def group_send(self, group: str, message: dict[str, Any]) -> None: ...
+ @deprecated("Use require_valid_channel_name instead.")
+ def valid_channel_name(self, channel_name: str, receive: bool = False) -> bool: ...
+ @deprecated("Use require_valid_group_name instead.")
+ def valid_group_name(self, group_name: str) -> bool: ...
+
+_InMemoryQueueData: TypeAlias = tuple[float, dict[str, Any]]
+
+class InMemoryChannelLayer(BaseChannelLayer):
+ channels: dict[str, asyncio.Queue[_InMemoryQueueData]]
+ groups: dict[str, dict[str, float]]
+ group_expiry: int
+
+ def __init__(
+ self,
+ expiry: int = 60,
+ group_expiry: int = 86400,
+ capacity: int = 100,
+ channel_capacity: _ChannelCapacityDict | None = None,
+ ) -> None: ...
+
+ extensions: list[str]
+
+ async def send(self, channel: str, message: dict[str, Any]) -> None: ...
+ async def receive(self, channel: str) -> dict[str, Any]: ...
+ async def new_channel(self, prefix: str = "specific.") -> str: ...
+ async def flush(self) -> None: ...
+ async def close(self) -> None: ...
+ async def group_add(self, group: str, channel: str) -> None: ...
+ async def group_discard(self, group: str, channel: str) -> None: ...
+ async def group_send(self, group: str, message: dict[str, Any]) -> None: ...
+
+def get_channel_layer(alias: str = "default") -> BaseChannelLayer | None: ...
+
+channel_layers: ChannelLayerManager
diff --git a/python/helpers/typeshed/stubs/channels/channels/management/__init__.pyi b/python/helpers/typeshed/stubs/channels/channels/management/__init__.pyi
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/python/helpers/typeshed/stubs/channels/channels/management/commands/__init__.pyi b/python/helpers/typeshed/stubs/channels/channels/management/commands/__init__.pyi
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/python/helpers/typeshed/stubs/channels/channels/management/commands/runworker.pyi b/python/helpers/typeshed/stubs/channels/channels/management/commands/runworker.pyi
new file mode 100644
index 000000000000..533b94cea88d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/management/commands/runworker.pyi
@@ -0,0 +1,25 @@
+import logging
+from _typeshed import Unused
+from argparse import ArgumentParser
+from typing import TypedDict, type_check_only
+
+from channels.layers import BaseChannelLayer
+from channels.worker import Worker
+from django.core.management.base import BaseCommand
+
+logger: logging.Logger
+
+@type_check_only
+class _RunWorkerCommandOption(TypedDict):
+ verbosity: int | None
+ layer: str
+ channels: list[str]
+
+class Command(BaseCommand):
+ leave_locale_alone: bool = True
+ worker_class: type[Worker] = ...
+ verbosity: int
+ channel_layer: BaseChannelLayer
+
+ def add_arguments(self, parser: ArgumentParser) -> None: ...
+ def handle(self, *args: Unused, **options: _RunWorkerCommandOption) -> None: ...
diff --git a/python/helpers/typeshed/stubs/channels/channels/middleware.pyi b/python/helpers/typeshed/stubs/channels/channels/middleware.pyi
new file mode 100644
index 000000000000..339ae9218244
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/middleware.pyi
@@ -0,0 +1,12 @@
+from asgiref.typing import ASGIReceiveCallable, ASGISendCallable
+
+from .consumer import _ChannelScope
+from .utils import _ChannelApplication
+
+class BaseMiddleware:
+ inner: _ChannelApplication
+
+ def __init__(self, inner: _ChannelApplication) -> None: ...
+ async def __call__(
+ self, scope: _ChannelScope, receive: ASGIReceiveCallable, send: ASGISendCallable
+ ) -> _ChannelApplication: ...
diff --git a/python/helpers/typeshed/stubs/channels/channels/routing.pyi b/python/helpers/typeshed/stubs/channels/channels/routing.pyi
new file mode 100644
index 000000000000..d2a0655d43ce
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/routing.pyi
@@ -0,0 +1,31 @@
+from typing import Any, type_check_only
+
+from asgiref.typing import ASGIReceiveCallable, ASGISendCallable, Scope
+from django.urls.resolvers import URLPattern
+
+from .consumer import _ASGIApplicationProtocol, _ChannelScope
+from .utils import _ChannelApplication
+
+def get_default_application() -> ProtocolTypeRouter: ...
+
+class ProtocolTypeRouter:
+ application_mapping: dict[str, _ChannelApplication]
+
+ def __init__(self, application_mapping: dict[str, Any]) -> None: ...
+ async def __call__(self, scope: Scope, receive: ASGIReceiveCallable, send: ASGISendCallable) -> None: ...
+
+@type_check_only
+class _ExtendedURLPattern(URLPattern):
+ callback: _ASGIApplicationProtocol | URLRouter
+
+class URLRouter:
+ routes: list[_ExtendedURLPattern | URLRouter]
+
+ def __init__(self, routes: list[_ExtendedURLPattern | URLRouter]) -> None: ...
+ async def __call__(self, scope: Scope, receive: ASGIReceiveCallable, send: ASGISendCallable) -> None: ...
+
+class ChannelNameRouter:
+ application_mapping: dict[str, _ChannelApplication]
+
+ def __init__(self, application_mapping: dict[str, _ChannelApplication]) -> None: ...
+ async def __call__(self, scope: _ChannelScope, receive: ASGIReceiveCallable, send: ASGISendCallable) -> None: ...
diff --git a/python/helpers/typeshed/stubs/channels/channels/security/__init__.pyi b/python/helpers/typeshed/stubs/channels/channels/security/__init__.pyi
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/python/helpers/typeshed/stubs/channels/channels/security/websocket.pyi b/python/helpers/typeshed/stubs/channels/channels/security/websocket.pyi
new file mode 100644
index 000000000000..aa76a1b4012e
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/security/websocket.pyi
@@ -0,0 +1,25 @@
+from collections.abc import Iterable
+from re import Pattern
+from typing import Any
+from urllib.parse import ParseResult
+
+from asgiref.typing import ASGIReceiveCallable, ASGISendCallable
+from channels.consumer import _ChannelScope
+from channels.generic.websocket import AsyncWebsocketConsumer
+from channels.utils import _ChannelApplication
+
+class OriginValidator:
+ application: _ChannelApplication
+ allowed_origins: Iterable[str | Pattern[str]]
+
+ def __init__(self, application: _ChannelApplication, allowed_origins: Iterable[str | Pattern[str]]) -> None: ...
+ async def __call__(self, scope: _ChannelScope, receive: ASGIReceiveCallable, send: ASGISendCallable) -> Any: ...
+ def valid_origin(self, parsed_origin: ParseResult | None) -> bool: ...
+ def validate_origin(self, parsed_origin: ParseResult | None) -> bool: ...
+ def match_allowed_origin(self, parsed_origin: ParseResult | None, pattern: str | Pattern[str]) -> bool: ...
+ def get_origin_port(self, origin: ParseResult | None) -> int | None: ...
+
+def AllowedHostsOriginValidator(application: _ChannelApplication) -> OriginValidator: ...
+
+class WebsocketDenier(AsyncWebsocketConsumer):
+ async def connect(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/channels/channels/sessions.pyi b/python/helpers/typeshed/stubs/channels/channels/sessions.pyi
new file mode 100644
index 000000000000..04a4eb729535
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/sessions.pyi
@@ -0,0 +1,56 @@
+import datetime
+from collections.abc import Awaitable
+from typing import Any
+
+from asgiref.typing import ASGIReceiveCallable, ASGISendCallable
+from channels.consumer import _ChannelScope
+from channels.utils import _ChannelApplication
+from django.contrib.sessions.backends.base import SessionBase
+
+class CookieMiddleware:
+ inner: _ChannelApplication
+
+ def __init__(self, inner: _ChannelApplication) -> None: ...
+
+ # Returns the same type as the provided _ChannelApplication.
+ async def __call__(self, scope: _ChannelScope, receive: ASGIReceiveCallable, send: ASGISendCallable) -> Any: ...
+ @classmethod
+ def set_cookie(
+ cls,
+ message: dict[str, Any],
+ key: str,
+ value: str = "",
+ max_age: int | None = None,
+ expires: str | datetime.datetime | None = None,
+ path: str = "/",
+ domain: str | None = None,
+ secure: bool = False,
+ httponly: bool = False,
+ samesite: str = "lax",
+ ) -> None: ...
+ @classmethod
+ def delete_cookie(cls, message: dict[str, Any], key: str, path: str = "/", domain: str | None = None) -> None: ...
+
+class InstanceSessionWrapper:
+ save_message_types: list[str]
+ cookie_response_message_types: list[str]
+ cookie_name: str
+ session_store: SessionBase
+ scope: _ChannelScope
+ activated: bool
+ real_send: ASGISendCallable
+
+ def __init__(self, scope: _ChannelScope, send: ASGISendCallable) -> None: ...
+ async def resolve_session(self) -> None: ...
+ async def send(self, message: dict[str, Any]) -> Awaitable[None]: ...
+ async def save_session(self) -> None: ...
+
+class SessionMiddleware:
+ inner: _ChannelApplication
+
+ def __init__(self, inner: _ChannelApplication) -> None: ...
+ async def __call__(
+ self, scope: _ChannelScope, receive: ASGIReceiveCallable, send: ASGISendCallable
+ ) -> _ChannelApplication: ...
+
+def SessionMiddlewareStack(inner: _ChannelApplication) -> _ChannelApplication: ...
diff --git a/python/helpers/typeshed/stubs/channels/channels/testing/__init__.pyi b/python/helpers/typeshed/stubs/channels/channels/testing/__init__.pyi
new file mode 100644
index 000000000000..1cb75a0bf6dd
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/testing/__init__.pyi
@@ -0,0 +1,6 @@
+from .application import ApplicationCommunicator
+from .http import HttpCommunicator
+from .live import ChannelsLiveServerTestCase
+from .websocket import WebsocketCommunicator
+
+__all__ = ["ApplicationCommunicator", "HttpCommunicator", "ChannelsLiveServerTestCase", "WebsocketCommunicator"]
diff --git a/python/helpers/typeshed/stubs/channels/channels/testing/application.pyi b/python/helpers/typeshed/stubs/channels/channels/testing/application.pyi
new file mode 100644
index 000000000000..db3f567c1d61
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/testing/application.pyi
@@ -0,0 +1,21 @@
+from typing import Any
+
+from asgiref.testing import ApplicationCommunicator as BaseApplicationCommunicator
+
+def no_op() -> None: ...
+
+class ApplicationCommunicator(BaseApplicationCommunicator):
+ # ASGI messages are dictionaries with a "type" key and protocol-specific fields.
+ # Dictionary values can be strings, bytes, lists, or other types depending on the protocol:
+ # - HTTP: {"type": "http.request", "body": b"request data", "headers": [...], ...}
+ # - WebSocket: {"type": "websocket.receive", "bytes": b"binary data"} or {"text": "string"}
+ # - Custom protocols: Application-specific message dictionaries
+ async def send_input(self, message: dict[str, Any]) -> None: ...
+ async def receive_output(self, timeout: float = 1) -> dict[str, Any]: ...
+
+ # The following methods are not present in the original source code,
+ # but are commonly used in practice. Since the base package doesn't
+ # provide type hints for them, they are added here to improve type correctness.
+ async def receive_nothing(self, timeout: float = 0.1, interval: float = 0.01) -> bool: ...
+ async def wait(self, timeout: float = 1) -> None: ...
+ def stop(self, exceptions: bool = True) -> None: ...
diff --git a/python/helpers/typeshed/stubs/channels/channels/testing/http.pyi b/python/helpers/typeshed/stubs/channels/channels/testing/http.pyi
new file mode 100644
index 000000000000..6eb6650036c8
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/testing/http.pyi
@@ -0,0 +1,41 @@
+from collections.abc import Iterable
+from typing import Literal, TypedDict, type_check_only
+
+from channels.testing.application import ApplicationCommunicator
+from channels.utils import _ChannelApplication
+
+# HTTP test-specific response type
+@type_check_only
+class _HTTPTestResponse(TypedDict, total=False):
+ status: int
+ headers: Iterable[tuple[bytes, bytes]]
+ body: bytes
+
+@type_check_only
+class _HTTPTestScope(TypedDict, total=False):
+ type: Literal["http"]
+ http_version: str
+ method: str
+ scheme: str
+ path: str
+ raw_path: bytes
+ query_string: bytes
+ root_path: str
+ headers: Iterable[tuple[bytes, bytes]] | None
+ client: tuple[str, int] | None
+ server: tuple[str, int | None] | None
+
+class HttpCommunicator(ApplicationCommunicator):
+ scope: _HTTPTestScope
+ body: bytes
+ sent_request: bool
+
+ def __init__(
+ self,
+ application: _ChannelApplication,
+ method: str,
+ path: str,
+ body: bytes = b"",
+ headers: Iterable[tuple[bytes, bytes]] | None = None,
+ ) -> None: ...
+ async def get_response(self, timeout: float = 1) -> _HTTPTestResponse: ...
diff --git a/python/helpers/typeshed/stubs/channels/channels/testing/live.pyi b/python/helpers/typeshed/stubs/channels/channels/testing/live.pyi
new file mode 100644
index 000000000000..b2cac0ae6260
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/testing/live.pyi
@@ -0,0 +1,26 @@
+from collections.abc import Callable
+from typing import Any, ClassVar
+from typing_extensions import TypeAlias
+
+from channels.routing import ProtocolTypeRouter
+from channels.utils import _ChannelApplication
+from django.contrib.staticfiles.handlers import ASGIStaticFilesHandler
+from django.test.testcases import TransactionTestCase
+
+DaphneProcess: TypeAlias = Any # TODO: temporary hack for daphne.testing.DaphneProcess; remove once daphne provides types
+
+_StaticWrapper: TypeAlias = Callable[[ProtocolTypeRouter], _ChannelApplication]
+
+def make_application(*, static_wrapper: _StaticWrapper | None) -> Any: ...
+def set_database_connection() -> None: ...
+
+class ChannelsLiveServerTestCase(TransactionTestCase):
+ host: ClassVar[str] = "localhost"
+ ProtocolServerProcess: ClassVar[type[DaphneProcess]] = ...
+ static_wrapper: ClassVar[type[ASGIStaticFilesHandler]] = ...
+ serve_static: ClassVar[bool] = True
+
+ @property
+ def live_server_url(self) -> str: ...
+ @property
+ def live_server_ws_url(self) -> str: ...
diff --git a/python/helpers/typeshed/stubs/channels/channels/testing/websocket.pyi b/python/helpers/typeshed/stubs/channels/channels/testing/websocket.pyi
new file mode 100644
index 000000000000..f303e90e5c39
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/testing/websocket.pyi
@@ -0,0 +1,54 @@
+from collections.abc import Iterable
+from typing import Any, Literal, TypedDict, overload, type_check_only
+from typing_extensions import NotRequired, TypeAlias
+
+from asgiref.typing import ASGIVersions
+from channels.testing.application import ApplicationCommunicator
+from channels.utils import _ChannelApplication
+
+@type_check_only
+class _WebsocketTestScope(TypedDict, total=False):
+ spec_version: int
+ type: Literal["websocket"]
+ asgi: ASGIVersions
+ http_version: str
+ scheme: str
+ path: str
+ raw_path: bytes
+ query_string: bytes
+ root_path: str
+ headers: Iterable[tuple[bytes, bytes]] | None
+ client: tuple[str, int] | None
+ server: tuple[str, int | None] | None
+ subprotocols: Iterable[str] | None
+ state: NotRequired[dict[str, Any]]
+ extensions: dict[str, dict[object, object]] | None
+
+_Connected: TypeAlias = bool
+_CloseCodeOrAcceptSubProtocol: TypeAlias = int | str | None
+_WebsocketConnectResponse: TypeAlias = tuple[_Connected, _CloseCodeOrAcceptSubProtocol]
+
+class WebsocketCommunicator(ApplicationCommunicator):
+ scope: _WebsocketTestScope
+ response_headers: list[tuple[bytes, bytes]] | None
+
+ def __init__(
+ self,
+ application: _ChannelApplication,
+ path: str,
+ headers: Iterable[tuple[bytes, bytes]] | None = None,
+ subprotocols: Iterable[str] | None = None,
+ spec_version: int | None = None,
+ ) -> None: ...
+ async def connect(self, timeout: float = 1) -> _WebsocketConnectResponse: ...
+ async def send_to(self, text_data: str | None = None, bytes_data: bytes | None = None) -> None: ...
+ async def receive_from(self, timeout: float = 1) -> str | bytes: ...
+
+ # These overloads reflect common usage, where users typically send and receive `dict[str, Any]`.
+ # The base case allows `Any` to support broader `json.dumps` / `json.loads` compatibility.
+ @overload
+ async def send_json_to(self, data: dict[str, Any]) -> None: ...
+ @overload
+ async def send_json_to(self, data: Any) -> None: ...
+ async def receive_json_from(self, timeout: float = 1) -> Any: ...
+ async def disconnect(self, code: int = 1000, timeout: float = 1) -> None: ...
diff --git a/python/helpers/typeshed/stubs/channels/channels/utils.pyi b/python/helpers/typeshed/stubs/channels/channels/utils.pyi
new file mode 100644
index 000000000000..0e0818abbbb6
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/utils.pyi
@@ -0,0 +1,20 @@
+from collections.abc import Awaitable, Callable
+from typing import Any, Protocol, type_check_only
+from typing_extensions import TypeAlias
+
+from asgiref.typing import ASGIApplication, ASGIReceiveCallable
+
+def name_that_thing(thing: object) -> str: ...
+async def await_many_dispatch(
+ consumer_callables: list[Callable[[], Awaitable[ASGIReceiveCallable]]], dispatch: Callable[[dict[str, Any]], Awaitable[None]]
+) -> None: ...
+
+# Defines a generic ASGI middleware protocol.
+# All arguments are typed as `Any` to maximize compatibility with third-party ASGI middleware
+# that may not strictly follow type conventions or use more specific signatures.
+@type_check_only
+class _MiddlewareProtocol(Protocol):
+ def __init__(self, *args: Any, **kwargs: Any) -> None: ...
+ async def __call__(self, scope: Any, receive: Any, send: Any) -> Any: ...
+
+_ChannelApplication: TypeAlias = _MiddlewareProtocol | ASGIApplication # noqa: Y047
diff --git a/python/helpers/typeshed/stubs/channels/channels/worker.pyi b/python/helpers/typeshed/stubs/channels/channels/worker.pyi
new file mode 100644
index 000000000000..a20b5feec275
--- /dev/null
+++ b/python/helpers/typeshed/stubs/channels/channels/worker.pyi
@@ -0,0 +1,13 @@
+from asgiref.server import StatelessServer
+from channels.layers import BaseChannelLayer
+from channels.utils import _ChannelApplication
+
+class Worker(StatelessServer):
+ channels: list[str]
+ channel_layer: BaseChannelLayer
+
+ def __init__(
+ self, application: _ChannelApplication, channels: list[str], channel_layer: BaseChannelLayer, max_applications: int = 1000
+ ) -> None: ...
+ async def handle(self) -> None: ...
+ async def listener(self, channel: str) -> None: ...
diff --git a/python/helpers/typeshed/stubs/chevron/METADATA.toml b/python/helpers/typeshed/stubs/chevron/METADATA.toml
old mode 100755
new mode 100644
diff --git a/python/helpers/typeshed/stubs/click-shell/METADATA.toml b/python/helpers/typeshed/stubs/click-shell/METADATA.toml
new file mode 100644
index 000000000000..630e551b1266
--- /dev/null
+++ b/python/helpers/typeshed/stubs/click-shell/METADATA.toml
@@ -0,0 +1,3 @@
+version = "2.1"
+upstream_repository = "https://github.com/clarkperkins/click-shell"
+requires = ["click>=8.0.0"]
diff --git a/python/helpers/typeshed/stubs/click-shell/click_shell/__init__.pyi b/python/helpers/typeshed/stubs/click-shell/click_shell/__init__.pyi
new file mode 100644
index 000000000000..38ef48feb91b
--- /dev/null
+++ b/python/helpers/typeshed/stubs/click-shell/click_shell/__init__.pyi
@@ -0,0 +1,7 @@
+from typing import Final
+
+from .core import Shell as Shell, make_click_shell as make_click_shell
+from .decorators import shell as shell
+
+__all__ = ["make_click_shell", "shell", "Shell", "__version__"]
+__version__: Final[str]
diff --git a/python/helpers/typeshed/stubs/click-shell/click_shell/_cmd.pyi b/python/helpers/typeshed/stubs/click-shell/click_shell/_cmd.pyi
new file mode 100644
index 000000000000..c6848e48928e
--- /dev/null
+++ b/python/helpers/typeshed/stubs/click-shell/click_shell/_cmd.pyi
@@ -0,0 +1,28 @@
+from cmd import Cmd
+from collections.abc import Callable
+from typing import Any, ClassVar, TextIO
+
+import click
+
+class ClickCmd(Cmd):
+ nocommand: ClassVar[str]
+ def __init__(
+ self,
+ ctx: click.Context | None = None,
+ on_finished: Callable[[click.Context], None] | None = None,
+ hist_file: str | None = None,
+ completekey: str = "tab",
+ stdin: TextIO | None = None,
+ stdout: TextIO | None = None,
+ ) -> None: ...
+ def preloop(self) -> None: ...
+ def postloop(self) -> None: ...
+ def cmdloop(self, intro: str | None = None) -> None: ...
+ def get_prompt(self) -> str | None: ...
+ def emptyline(self) -> bool: ...
+ def default(self, line: str) -> None: ...
+ def get_names(self) -> list[str]: ...
+ def do_help(self, arg: str) -> None: ...
+ def do_quit(self, arg: str) -> bool: ...
+ def do_exit(self, arg: str) -> bool: ...
+ def print_topics(self, header: Any, cmds: list[str] | None, cmdlen: int, maxcol: int) -> None: ...
diff --git a/python/helpers/typeshed/stubs/click-shell/click_shell/_compat.pyi b/python/helpers/typeshed/stubs/click-shell/click_shell/_compat.pyi
new file mode 100644
index 000000000000..c383de4ff97c
--- /dev/null
+++ b/python/helpers/typeshed/stubs/click-shell/click_shell/_compat.pyi
@@ -0,0 +1,10 @@
+import types
+from collections.abc import Callable
+from typing import Any, Final
+
+import click
+
+PY2: Final = False
+
+def get_method_type(func: Callable[..., Any], obj: object) -> types.MethodType: ...
+def get_choices(cli: click.Command, prog_name: str, args: list[str], incomplete: str) -> list[str]: ...
diff --git a/python/helpers/typeshed/stubs/click-shell/click_shell/core.pyi b/python/helpers/typeshed/stubs/click-shell/click_shell/core.pyi
new file mode 100644
index 000000000000..673c0c69464d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/click-shell/click_shell/core.pyi
@@ -0,0 +1,35 @@
+from collections.abc import Callable
+from logging import Logger
+from typing import Any
+
+import click
+
+from ._cmd import ClickCmd
+
+logger: Logger
+
+def get_invoke(command: click.Command) -> Callable[[ClickCmd, str], bool]: ...
+def get_help(command: click.Command) -> Callable[[ClickCmd], None]: ...
+def get_complete(command: click.Command) -> Callable[[ClickCmd, str, str, int, int], list[str]]: ...
+
+class ClickShell(ClickCmd):
+ def add_command(self, cmd: click.Command, name: str) -> None: ...
+
+def make_click_shell(
+ ctx: click.Context,
+ prompt: str | Callable[[], str] | Callable[[click.Context, str], str] | None = None,
+ intro: str | None = None,
+ hist_file: str | None = None,
+) -> ClickShell: ...
+
+class Shell(click.Group):
+ def __init__(
+ self,
+ prompt: str | Callable[[], str] | Callable[[click.Context, str], str] | None = None,
+ intro: str | None = None,
+ hist_file: str | None = None,
+ on_finished: Callable[[click.Context], None] | None = None,
+ **attrs: Any,
+ ) -> None: ...
+ def add_command(self, cmd: click.Command, name: str | None = None) -> None: ...
+ def invoke(self, ctx: click.Context) -> Any: ...
diff --git a/python/helpers/typeshed/stubs/click-shell/click_shell/decorators.pyi b/python/helpers/typeshed/stubs/click-shell/click_shell/decorators.pyi
new file mode 100644
index 000000000000..ce72f74fbd6e
--- /dev/null
+++ b/python/helpers/typeshed/stubs/click-shell/click_shell/decorators.pyi
@@ -0,0 +1,8 @@
+from collections.abc import Callable
+from typing import Any
+
+from click.decorators import _AnyCallable
+
+from .core import Shell
+
+def shell(name: str | None = None, **attrs: Any) -> Callable[[_AnyCallable], Shell]: ...
diff --git a/python/helpers/typeshed/stubs/click-spinner/click_spinner/__init__.pyi b/python/helpers/typeshed/stubs/click-spinner/click_spinner/__init__.pyi
index 6093bb0f4c01..9bde16cff242 100644
--- a/python/helpers/typeshed/stubs/click-spinner/click_spinner/__init__.pyi
+++ b/python/helpers/typeshed/stubs/click-spinner/click_spinner/__init__.pyi
@@ -1,11 +1,12 @@
import threading
from collections.abc import Iterator
from types import TracebackType
-from typing import Literal, Protocol
+from typing import Literal, Protocol, type_check_only
from typing_extensions import Self
__version__: str
+@type_check_only
class _Stream(Protocol):
def isatty(self) -> bool: ...
def flush(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/click-web/click_web/resources/cmd_form.pyi b/python/helpers/typeshed/stubs/click-web/click_web/resources/cmd_form.pyi
index fff80bd290ee..d3f3ed573489 100644
--- a/python/helpers/typeshed/stubs/click-web/click_web/resources/cmd_form.pyi
+++ b/python/helpers/typeshed/stubs/click-web/click_web/resources/cmd_form.pyi
@@ -1,6 +1,13 @@
+from typing import Any, TypedDict, type_check_only
+
import click
+@type_check_only
+class _FormData(TypedDict):
+ command: click.Command
+ fields: list[dict[str, Any]] # each item is result of resources.input_fields.get_input_field() function
+
def get_form_for(command_path: str) -> str: ...
def _get_commands_by_path(command_path: str) -> list[tuple[click.Context, click.Command]]: ...
-def _generate_form_data(ctx_and_commands: list[tuple[click.Context, click.Command]]): ...
+def _generate_form_data(ctx_and_commands: list[tuple[click.Context, click.Command]]) -> list[_FormData]: ...
def _process_help(help_text: bool) -> str: ...
diff --git a/python/helpers/typeshed/stubs/click-web/click_web/resources/input_fields.pyi b/python/helpers/typeshed/stubs/click-web/click_web/resources/input_fields.pyi
index bffb313868b2..ec2ede4d14b2 100644
--- a/python/helpers/typeshed/stubs/click-web/click_web/resources/input_fields.pyi
+++ b/python/helpers/typeshed/stubs/click-web/click_web/resources/input_fields.pyi
@@ -25,7 +25,7 @@ class FieldId:
form_type: str,
name: str,
key: str | None = None,
- ): ...
+ ) -> None: ...
@classmethod
def from_string(cls, field_info_as_string: str) -> FieldId: ...
@@ -44,7 +44,7 @@ class BaseInput:
@property
def type_attrs(self) -> dict[str, Any]: ...
def _to_cmd_line_name(self, name: str) -> str: ...
- def _build_name(self, name: str): ...
+ def _build_name(self, name: str) -> str: ...
class ChoiceInput(BaseInput):
if sys.version_info >= (3, 10):
@@ -82,4 +82,4 @@ class DefaultInput(BaseInput):
INPUT_TYPES: Final[list[type[BaseInput]]]
_DEFAULT_INPUT: Final[list[type[DefaultInput]]]
-def get_input_field(ctx: click.Context, param: click.Parameter, command_index, param_index) -> dict[str, Any]: ...
+def get_input_field(ctx: click.Context, param: click.Parameter, command_index: int, param_index: int) -> dict[str, Any]: ...
diff --git a/python/helpers/typeshed/stubs/colorama/METADATA.toml b/python/helpers/typeshed/stubs/colorama/METADATA.toml
index 40a45767ba6c..980206462d55 100644
--- a/python/helpers/typeshed/stubs/colorama/METADATA.toml
+++ b/python/helpers/typeshed/stubs/colorama/METADATA.toml
@@ -2,4 +2,4 @@ version = "0.4.*"
upstream_repository = "https://github.com/tartley/colorama"
[tool.stubtest]
-platforms = ["linux", "win32"]
+ci_platforms = ["linux", "win32"]
diff --git a/python/helpers/typeshed/stubs/croniter/croniter/croniter.pyi b/python/helpers/typeshed/stubs/croniter/croniter/croniter.pyi
index 9d9dfe102bd2..7dd721ddbb2a 100644
--- a/python/helpers/typeshed/stubs/croniter/croniter/croniter.pyi
+++ b/python/helpers/typeshed/stubs/croniter/croniter/croniter.pyi
@@ -3,13 +3,14 @@ from _typeshed import Unused
from collections import OrderedDict
from collections.abc import Generator
from re import Match, Pattern
-from typing import Any, Final, Generic, Literal, Protocol, TypeVar, overload
+from typing import Any, Final, Generic, Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Never, Self, TypeAlias
_R_co = TypeVar("_R_co", float, datetime.datetime, default=float, covariant=True)
_R2_co = TypeVar("_R2_co", float, datetime.datetime, covariant=True)
_Expressions: TypeAlias = list[str] # fixed-length list of 5 or 6 strings
+@type_check_only
class _AllIter(Protocol[_R_co]):
@overload
def __call__(
@@ -188,7 +189,7 @@ class croniter(Generic[_R_co]):
@overload
def get_next(
self, ret_type: type[_R2_co], start_time: float | datetime.datetime | None = None, update_current: bool = True
- ) -> _R_co: ...
+ ) -> _R2_co: ...
@overload
def get_next(
self, ret_type: None = None, start_time: float | datetime.datetime | None = None, update_current: bool = True
diff --git a/python/helpers/typeshed/stubs/dateparser/METADATA.toml b/python/helpers/typeshed/stubs/dateparser/METADATA.toml
index e48024514df7..289446be0823 100644
--- a/python/helpers/typeshed/stubs/dateparser/METADATA.toml
+++ b/python/helpers/typeshed/stubs/dateparser/METADATA.toml
@@ -1,4 +1,4 @@
-version = "1.2.*"
+version = "~=1.2.2"
upstream_repository = "https://github.com/scrapinghub/dateparser"
[tool.stubtest]
diff --git a/python/helpers/typeshed/stubs/dateparser/dateparser/__init__.pyi b/python/helpers/typeshed/stubs/dateparser/dateparser/__init__.pyi
index 4d259de3ae65..d12a9b7281e5 100644
--- a/python/helpers/typeshed/stubs/dateparser/dateparser/__init__.pyi
+++ b/python/helpers/typeshed/stubs/dateparser/dateparser/__init__.pyi
@@ -1,5 +1,5 @@
import datetime
-from typing import Literal, TypedDict
+from typing import Literal, TypedDict, type_check_only
from typing_extensions import TypeAlias
from .date import DateDataParser, _DetectLanguagesFunction
@@ -11,6 +11,7 @@ _default_parser: DateDataParser
_Part: TypeAlias = Literal["day", "month", "year"]
_ParserKind: TypeAlias = Literal["timestamp", "relative-time", "custom-formats", "absolute-time", "no-spaces-time"]
+@type_check_only
class _Settings(TypedDict, total=False):
DATE_ORDER: str
PREFER_LOCALE_DATE_ORDER: bool
diff --git a/python/helpers/typeshed/stubs/dateparser/dateparser/search/search.pyi b/python/helpers/typeshed/stubs/dateparser/dateparser/search/search.pyi
index aeb8b863bc75..369c7355a02f 100644
--- a/python/helpers/typeshed/stubs/dateparser/dateparser/search/search.pyi
+++ b/python/helpers/typeshed/stubs/dateparser/dateparser/search/search.pyi
@@ -1,3 +1,4 @@
+from collections.abc import Collection
from typing import Any
from ..date import _DetectLanguagesFunction
@@ -33,3 +34,4 @@ class DateSearchWithDetection:
def search_dates(
self, text, languages=None, settings=None, detect_languages_function: _DetectLanguagesFunction | None = None
): ...
+ def preprocess_text(self, text: str, languages: Collection[str]) -> str: ...
diff --git a/python/helpers/typeshed/stubs/dateparser/dateparser/timezone_parser.pyi b/python/helpers/typeshed/stubs/dateparser/dateparser/timezone_parser.pyi
index 0b0558d169b3..ff86e7810c39 100644
--- a/python/helpers/typeshed/stubs/dateparser/dateparser/timezone_parser.pyi
+++ b/python/helpers/typeshed/stubs/dateparser/dateparser/timezone_parser.pyi
@@ -1,6 +1,8 @@
+import pathlib
import re
from collections.abc import Generator
from datetime import datetime, timedelta, tzinfo
+from typing import Final
class StaticTzInfo(tzinfo):
def __init__(self, name: str, offset: timedelta) -> None: ...
@@ -17,3 +19,6 @@ def build_tz_offsets(search_regex_parts: list[str]) -> Generator[tuple[str, dict
def get_local_tz_offset() -> timedelta: ...
local_tz_offset: timedelta
+
+CACHE_PATH: Final[pathlib.Path]
+current_hash: int | None
diff --git a/python/helpers/typeshed/stubs/defusedxml/METADATA.toml b/python/helpers/typeshed/stubs/defusedxml/METADATA.toml
index 04dfe1b422e1..c073b5244477 100644
--- a/python/helpers/typeshed/stubs/defusedxml/METADATA.toml
+++ b/python/helpers/typeshed/stubs/defusedxml/METADATA.toml
@@ -1,7 +1,5 @@
version = "0.7.*"
upstream_repository = "https://github.com/tiran/defusedxml"
-partial_stub = true
[tool.stubtest]
-ignore_missing_stub = true
stubtest_requirements = ["lxml"]
diff --git a/python/helpers/typeshed/stubs/defusedxml/defusedxml/ElementTree.pyi b/python/helpers/typeshed/stubs/defusedxml/defusedxml/ElementTree.pyi
index 6328863d59b0..3b10271665af 100644
--- a/python/helpers/typeshed/stubs/defusedxml/defusedxml/ElementTree.pyi
+++ b/python/helpers/typeshed/stubs/defusedxml/defusedxml/ElementTree.pyi
@@ -1,6 +1,18 @@
-from collections.abc import Iterator, Sequence
-from typing import Any
-from xml.etree.ElementTree import Element, ElementTree, ParseError as ParseError, XMLParser as _XMLParser, tostring as tostring
+from _typeshed import ReadableBuffer
+from collections.abc import Sequence
+from typing import Final
+from xml.etree.ElementTree import (
+ Element,
+ ElementTree,
+ ParseError as ParseError,
+ XMLParser as _XMLParser,
+ _FileRead,
+ _IterParseIterator,
+ _Target,
+ tostring as tostring,
+)
+
+__origin__: Final = "xml.etree.ElementTree"
class DefusedXMLParser(_XMLParser):
forbid_dtd: bool
@@ -8,17 +20,30 @@ class DefusedXMLParser(_XMLParser):
forbid_external: bool
def __init__(
self,
- html=...,
- target=None,
+ html: object = ..., # argument is deprecated, if bool(html) is True you will get TypeError
+ target: _Target | None = None,
encoding: str | None = None,
forbid_dtd: bool = False,
forbid_entities: bool = True,
forbid_external: bool = True,
) -> None: ...
- def defused_start_doctype_decl(self, name, sysid, pubid, has_internal_subset) -> None: ...
- def defused_entity_decl(self, name, is_parameter_entity, value, base, sysid, pubid, notation_name) -> None: ...
- def defused_unparsed_entity_decl(self, name, base, sysid, pubid, notation_name) -> None: ...
- def defused_external_entity_ref_handler(self, context, base, sysid, pubid) -> None: ...
+ def defused_start_doctype_decl(self, name: str, sysid: str | None, pubid: str | None, has_internal_subset: bool) -> None: ...
+ def defused_entity_decl(
+ self,
+ name: str,
+ is_parameter_entity: bool,
+ value: str | None,
+ base: str | None,
+ sysid: str,
+ pubid: str | None,
+ notation_name: str | None,
+ ) -> None: ...
+ def defused_unparsed_entity_decl(
+ self, name: str, base: str | None, sysid: str, pubid: str | None, notation_name: str
+ ) -> None: ...
+ def defused_external_entity_ref_handler(
+ self, context: str, base: str | None, sysid: str | None, pubid: str | None
+ ) -> None: ...
XMLTreeBuilder = DefusedXMLParser
XMLParse = DefusedXMLParser
@@ -26,19 +51,25 @@ XMLParser = DefusedXMLParser
# wrapper to xml.etree.ElementTree.parse
def parse(
- source, parser: XMLParser | None = None, forbid_dtd: bool = False, forbid_entities: bool = True, forbid_external: bool = True
+ source: _FileRead,
+ parser: XMLParser | None = None,
+ forbid_dtd: bool = False,
+ forbid_entities: bool = True,
+ forbid_external: bool = True,
) -> ElementTree: ...
# wrapper to xml.etree.ElementTree.iterparse
def iterparse(
- source,
+ source: _FileRead,
events: Sequence[str] | None = None,
parser: XMLParser | None = None,
forbid_dtd: bool = False,
forbid_entities: bool = True,
forbid_external: bool = True,
-) -> Iterator[tuple[str, Any]]: ...
-def fromstring(text, forbid_dtd: bool = False, forbid_entities: bool = True, forbid_external: bool = True) -> Element: ...
+) -> _IterParseIterator: ...
+def fromstring(
+ text: str | ReadableBuffer, forbid_dtd: bool = False, forbid_entities: bool = True, forbid_external: bool = True
+) -> Element: ...
XML = fromstring
diff --git a/python/helpers/typeshed/stubs/defusedxml/defusedxml/cElementTree.pyi b/python/helpers/typeshed/stubs/defusedxml/defusedxml/cElementTree.pyi
index 8fe92b53a28b..5d096d4f14d7 100644
--- a/python/helpers/typeshed/stubs/defusedxml/defusedxml/cElementTree.pyi
+++ b/python/helpers/typeshed/stubs/defusedxml/defusedxml/cElementTree.pyi
@@ -1,3 +1,5 @@
+from typing import Final
+
from .ElementTree import (
XML as XML,
ParseError as ParseError,
@@ -10,4 +12,5 @@ from .ElementTree import (
tostring as tostring,
)
+__origin__: Final = "xml.etree.cElementTree"
__all__ = ["ParseError", "XML", "XMLParse", "XMLParser", "XMLTreeBuilder", "fromstring", "iterparse", "parse", "tostring"]
diff --git a/python/helpers/typeshed/stubs/defusedxml/defusedxml/common.pyi b/python/helpers/typeshed/stubs/defusedxml/defusedxml/common.pyi
index c4afb19018e3..15eb3f181444 100644
--- a/python/helpers/typeshed/stubs/defusedxml/defusedxml/common.pyi
+++ b/python/helpers/typeshed/stubs/defusedxml/defusedxml/common.pyi
@@ -1,29 +1,31 @@
-from _typeshed import Incomplete
+from typing import Final
-PY3: bool
+PY3: Final[bool]
class DefusedXmlException(ValueError): ...
class DTDForbidden(DefusedXmlException):
- name: Incomplete
- sysid: Incomplete
- pubid: Incomplete
- def __init__(self, name, sysid, pubid) -> None: ...
+ name: str
+ sysid: str | None
+ pubid: str | None
+ def __init__(self, name: str, sysid: str | None, pubid: str | None) -> None: ...
class EntitiesForbidden(DefusedXmlException):
- name: Incomplete
- value: Incomplete
- base: Incomplete
- sysid: Incomplete
- pubid: Incomplete
- notation_name: Incomplete
- def __init__(self, name, value, base, sysid, pubid, notation_name) -> None: ...
+ name: str
+ value: str | None
+ base: str | None
+ sysid: str | None
+ pubid: str | None
+ notation_name: str | None
+ def __init__(
+ self, name: str, value: str | None, base: str | None, sysid: str | None, pubid: str | None, notation_name: str | None
+ ) -> None: ...
class ExternalReferenceForbidden(DefusedXmlException):
- context: Incomplete
- base: Incomplete
- sysid: Incomplete
- pubid: Incomplete
- def __init__(self, context, base, sysid, pubid) -> None: ...
+ context: str
+ base: str | None
+ sysid: str | None
+ pubid: str | None
+ def __init__(self, context: str, base: str | None, sysid: str | None, pubid: str | None) -> None: ...
class NotSupportedError(DefusedXmlException): ...
diff --git a/python/helpers/typeshed/stubs/defusedxml/defusedxml/expatbuilder.pyi b/python/helpers/typeshed/stubs/defusedxml/defusedxml/expatbuilder.pyi
index 0c6f4b7b92a7..8905cab7c8d8 100644
--- a/python/helpers/typeshed/stubs/defusedxml/defusedxml/expatbuilder.pyi
+++ b/python/helpers/typeshed/stubs/defusedxml/defusedxml/expatbuilder.pyi
@@ -1,9 +1,11 @@
from _typeshed import SupportsRead
+from typing import Final
from xml.dom.expatbuilder import ExpatBuilder as _ExpatBuilder, Namespaces as _Namespaces
from xml.dom.minidom import Document
from xml.dom.xmlbuilder import Options
+from xml.parsers.expat import XMLParserType
-__origin__: str
+__origin__: Final = "xml.dom.expatbuilder"
class DefusedExpatBuilder(_ExpatBuilder):
forbid_dtd: bool
@@ -12,14 +14,27 @@ class DefusedExpatBuilder(_ExpatBuilder):
def __init__(
self, options: Options | None = None, forbid_dtd: bool = False, forbid_entities: bool = True, forbid_external: bool = True
) -> None: ...
- def defused_start_doctype_decl(self, name, sysid, pubid, has_internal_subset) -> None: ...
- def defused_entity_decl(self, name, is_parameter_entity, value, base, sysid, pubid, notation_name) -> None: ...
- def defused_unparsed_entity_decl(self, name, base, sysid, pubid, notation_name) -> None: ...
- def defused_external_entity_ref_handler(self, context, base, sysid, pubid) -> None: ...
- def install(self, parser) -> None: ...
+ def defused_start_doctype_decl(self, name: str, sysid: str | None, pubid: str | None, has_internal_subset: bool) -> None: ...
+ def defused_entity_decl(
+ self,
+ name: str,
+ is_parameter_entity: bool,
+ value: str | None,
+ base: str | None,
+ sysid: str,
+ pubid: str | None,
+ notation_name: str | None,
+ ) -> None: ...
+ def defused_unparsed_entity_decl(
+ self, name: str, base: str | None, sysid: str, pubid: str | None, notation_name: str
+ ) -> None: ...
+ def defused_external_entity_ref_handler(
+ self, context: str, base: str | None, sysid: str | None, pubid: str | None
+ ) -> None: ...
+ def install(self, parser: XMLParserType) -> None: ...
class DefusedExpatBuilderNS(_Namespaces, DefusedExpatBuilder):
- def install(self, parser) -> None: ...
+ def install(self, parser: XMLParserType) -> None: ...
def reset(self) -> None: ...
def parse(
diff --git a/python/helpers/typeshed/stubs/defusedxml/defusedxml/expatreader.pyi b/python/helpers/typeshed/stubs/defusedxml/defusedxml/expatreader.pyi
index 7453fee132f4..89155fba5e71 100644
--- a/python/helpers/typeshed/stubs/defusedxml/defusedxml/expatreader.pyi
+++ b/python/helpers/typeshed/stubs/defusedxml/defusedxml/expatreader.pyi
@@ -1,10 +1,43 @@
-from _typeshed import Incomplete
+from typing import Final
+from xml.sax.expatreader import ExpatParser as _ExpatParser, _BoolType
-# Cannot type most things here as DefusedExpatParser is based off of
-# xml.sax.expatreader, which is an undocumented module and lacks types at the moment.
+__origin__: Final = "xml.sax.expatreader"
-__origin__: str
+class DefusedExpatParser(_ExpatParser):
+ forbid_dtd: bool
+ forbid_entities: bool
+ forbid_external: bool
+ def __init__(
+ self,
+ namespaceHandling: _BoolType = 0,
+ bufsize: int = 65516,
+ forbid_dtd: bool = False,
+ forbid_entities: bool = True,
+ forbid_external: bool = True,
+ ) -> None: ...
+ def defused_start_doctype_decl(self, name: str, sysid: str | None, pubid: str | None, has_internal_subset: bool) -> None: ...
+ def defused_entity_decl(
+ self,
+ name: str,
+ is_parameter_entity: bool,
+ value: str | None,
+ base: str | None,
+ sysid: str,
+ pubid: str | None,
+ notation_name: str | None,
+ ) -> None: ...
+ def defused_unparsed_entity_decl(
+ self, name: str, base: str | None, sysid: str, pubid: str | None, notation_name: str
+ ) -> None: ...
+ def defused_external_entity_ref_handler(
+ self, context: str, base: str | None, sysid: str | None, pubid: str | None
+ ) -> None: ...
+ def reset(self) -> None: ...
-DefusedExpatParser = Incomplete
-
-def create_parser(*args, **kwargs): ...
+def create_parser(
+ namespaceHandling: _BoolType = 0,
+ bufsize: int = 65516,
+ forbid_dtd: bool = False,
+ forbid_entities: bool = True,
+ forbid_external: bool = True,
+) -> DefusedExpatParser: ...
diff --git a/python/helpers/typeshed/stubs/defusedxml/defusedxml/lxml.pyi b/python/helpers/typeshed/stubs/defusedxml/defusedxml/lxml.pyi
index 10cb30a4a78f..0ff53d95ca3b 100644
--- a/python/helpers/typeshed/stubs/defusedxml/defusedxml/lxml.pyi
+++ b/python/helpers/typeshed/stubs/defusedxml/defusedxml/lxml.pyi
@@ -1,25 +1,42 @@
import threading
from _typeshed import Incomplete
+from typing import Final, Literal, type_check_only
-# Not bothering with types here as lxml support is supposed to be dropped in a future version
-# of defusedxml
+# Not bothering with types here as lxml support is supposed to be dropped in a future version of defusedxml
-LXML3: Incomplete
-__origin__: str
-tostring: Incomplete
+LXML3: bool
+__origin__: Final = "lxml.etree"
+
+def tostring(
+ element_or_tree,
+ *,
+ encoding: str | None = None,
+ method: Literal["xml", "html", "text", "c14n", "c14n2"] = "xml",
+ xml_declaration: bool | None = None,
+ pretty_print: bool = False,
+ with_tail: bool = True,
+ standalone: bool | None = None,
+ doctype=None,
+ exclusive: bool = False,
+ inclusive_ns_prefixes=None,
+ with_comments: bool = True,
+ strip_text: bool = False,
+): ...
# Should be imported from lxml.etree.ElementBase, but lxml lacks types
+@type_check_only
class _ElementBase: ...
class RestrictedElement(_ElementBase):
+ __slots__ = ()
blacklist: Incomplete
def __iter__(self): ...
- def iterchildren(self, tag: Incomplete | None = ..., reversed: bool = ...): ...
- def iter(self, tag: Incomplete | None = ..., *tags): ...
- def iterdescendants(self, tag: Incomplete | None = ..., *tags): ...
- def itersiblings(self, tag: Incomplete | None = ..., preceding: bool = ...): ...
+ def iterchildren(self, tag=None, reversed: bool = False): ...
+ def iter(self, tag=None, *tags): ...
+ def iterdescendants(self, tag=None, *tags): ...
+ def itersiblings(self, tag=None, preceding: bool = False): ...
def getchildren(self): ...
- def getiterator(self, tag: Incomplete | None = ...): ...
+ def getiterator(self, tag=None): ...
class GlobalParserTLS(threading.local):
parser_config: Incomplete
@@ -28,19 +45,10 @@ class GlobalParserTLS(threading.local):
def setDefaultParser(self, parser) -> None: ...
def getDefaultParser(self): ...
-getDefaultParser: Incomplete
-
-def check_docinfo(elementtree, forbid_dtd: bool = ..., forbid_entities: bool = ...) -> None: ...
-def parse(
- source,
- parser: Incomplete | None = ...,
- base_url: Incomplete | None = ...,
- forbid_dtd: bool = ...,
- forbid_entities: bool = ...,
-): ...
-def fromstring(
- text, parser: Incomplete | None = ..., base_url: Incomplete | None = ..., forbid_dtd: bool = ..., forbid_entities: bool = ...
-): ...
+def getDefaultParser(): ...
+def check_docinfo(elementtree, forbid_dtd: bool = False, forbid_entities: bool = True) -> None: ...
+def parse(source, parser=None, base_url=None, forbid_dtd: bool = False, forbid_entities: bool = True): ...
+def fromstring(text, parser=None, base_url=None, forbid_dtd: bool = False, forbid_entities: bool = True): ...
XML = fromstring
diff --git a/python/helpers/typeshed/stubs/defusedxml/defusedxml/minidom.pyi b/python/helpers/typeshed/stubs/defusedxml/defusedxml/minidom.pyi
index 312cbe8c518e..0097ebd5d5b8 100644
--- a/python/helpers/typeshed/stubs/defusedxml/defusedxml/minidom.pyi
+++ b/python/helpers/typeshed/stubs/defusedxml/defusedxml/minidom.pyi
@@ -1,15 +1,22 @@
+from _typeshed import SupportsRead
+from typing import Final
from xml.dom.minidom import Document
+from xml.sax.xmlreader import XMLReader
-__origin__: str
+__origin__: Final = "xml.dom.minidom"
def parse(
- file,
- parser=None,
+ file: str | SupportsRead[bytes | str],
+ parser: XMLReader | None = None,
bufsize: int | None = None,
forbid_dtd: bool = False,
forbid_entities: bool = True,
forbid_external: bool = True,
) -> Document: ...
def parseString(
- string: str, parser=None, forbid_dtd: bool = False, forbid_entities: bool = True, forbid_external: bool = True
+ string: str,
+ parser: XMLReader | None = None,
+ forbid_dtd: bool = False,
+ forbid_entities: bool = True,
+ forbid_external: bool = True,
) -> Document: ...
diff --git a/python/helpers/typeshed/stubs/defusedxml/defusedxml/pulldom.pyi b/python/helpers/typeshed/stubs/defusedxml/defusedxml/pulldom.pyi
index 173065abce6c..706b2b876c06 100644
--- a/python/helpers/typeshed/stubs/defusedxml/defusedxml/pulldom.pyi
+++ b/python/helpers/typeshed/stubs/defusedxml/defusedxml/pulldom.pyi
@@ -1,12 +1,13 @@
+from typing import Final
from xml.dom.pulldom import DOMEventStream
+from xml.sax import _SupportsReadClose
+from xml.sax.xmlreader import XMLReader
-from .expatreader import DefusedExpatParser
-
-__origin__: str
+__origin__: Final = "xml.dom.pulldom"
def parse(
- stream_or_string,
- parser: DefusedExpatParser | None = None,
+ stream_or_string: str | _SupportsReadClose[str] | _SupportsReadClose[bytes],
+ parser: XMLReader | None = None,
bufsize: int | None = None,
forbid_dtd: bool = False,
forbid_entities: bool = True,
@@ -14,7 +15,7 @@ def parse(
) -> DOMEventStream: ...
def parseString(
string: str,
- parser: DefusedExpatParser | None = None,
+ parser: XMLReader | None = None,
forbid_dtd: bool = False,
forbid_entities: bool = True,
forbid_external: bool = True,
diff --git a/python/helpers/typeshed/stubs/defusedxml/defusedxml/sax.pyi b/python/helpers/typeshed/stubs/defusedxml/defusedxml/sax.pyi
index a4c32eda58b5..9ecd454218bf 100644
--- a/python/helpers/typeshed/stubs/defusedxml/defusedxml/sax.pyi
+++ b/python/helpers/typeshed/stubs/defusedxml/defusedxml/sax.pyi
@@ -1,24 +1,26 @@
-from _typeshed import Incomplete
-from xml.sax import ErrorHandler as _ErrorHandler
+from _typeshed import ReadableBuffer, Unused
+from typing import Final
+from xml.sax import ErrorHandler as _ErrorHandler, _Source, xmlreader
+from xml.sax.handler import _ContentHandlerProtocol
from .expatreader import DefusedExpatParser
-__origin__: str
+__origin__: Final = "xml.sax"
def parse(
- source,
- handler,
+ source: xmlreader.InputSource | _Source,
+ handler: _ContentHandlerProtocol,
errorHandler: _ErrorHandler = ...,
forbid_dtd: bool = False,
forbid_entities: bool = True,
forbid_external: bool = True,
) -> None: ...
def parseString(
- string,
- handler,
+ string: ReadableBuffer,
+ handler: _ContentHandlerProtocol,
errorHandler: _ErrorHandler = ...,
forbid_dtd: bool = False,
forbid_entities: bool = True,
forbid_external: bool = True,
) -> None: ...
-def make_parser(parser_list: list[Incomplete] = []) -> DefusedExpatParser: ...
+def make_parser(parser_list: Unused = []) -> DefusedExpatParser: ...
diff --git a/python/helpers/typeshed/stubs/defusedxml/defusedxml/xmlrpc.pyi b/python/helpers/typeshed/stubs/defusedxml/defusedxml/xmlrpc.pyi
index cddcb3f5132c..da38c6870004 100644
--- a/python/helpers/typeshed/stubs/defusedxml/defusedxml/xmlrpc.pyi
+++ b/python/helpers/typeshed/stubs/defusedxml/defusedxml/xmlrpc.pyi
@@ -1,25 +1,48 @@
-from _typeshed import Incomplete
-from xmlrpc.client import ExpatParser
+import gzip
+from _typeshed import ReadableBuffer
+from typing import Final, Protocol, type_check_only
+from xmlrpc.client import ExpatParser, Unmarshaller
-__origin__: str
-MAX_DATA: int = 31457280
+@type_check_only
+class _Readable(Protocol):
+ def read(self, size: int | None = -1) -> bytes: ...
-def defused_gzip_decode(data, limit: int | None = None): ...
+__origin__: Final = "xmlrpc.client"
+MAX_DATA: Final = 31457280
-# Couldn't type this as a class deriving from gzip.GzipFile
-# since overwriting `read` method does not define an optional argument
-# for size when the underlying class does.
-DefusedGzipDecodedResponse = Incomplete
+def defused_gzip_decode(data: ReadableBuffer, limit: int | None = None) -> bytes: ...
+
+class DefusedGzipDecodedResponse(gzip.GzipFile):
+ limit: int
+ readlength: int | None
+ def __init__(self, response: _Readable, limit: int | None = None) -> None: ...
+ def read(self, n: int) -> bytes: ... # type: ignore[override]
+ def close(self) -> None: ...
class DefusedExpatParser(ExpatParser):
forbid_dtd: bool
forbid_entities: bool
forbid_external: bool
- def __init__(self, target, forbid_dtd: bool = False, forbid_entities: bool = True, forbid_external: bool = True) -> None: ...
- def defused_start_doctype_decl(self, name, sysid, pubid, has_internal_subset) -> None: ...
- def defused_entity_decl(self, name, is_parameter_entity, value, base, sysid, pubid, notation_name) -> None: ...
- def defused_unparsed_entity_decl(self, name, base, sysid, pubid, notation_name) -> None: ...
- def defused_external_entity_ref_handler(self, context, base, sysid, pubid) -> None: ...
+ def __init__(
+ self, target: Unmarshaller, forbid_dtd: bool = False, forbid_entities: bool = True, forbid_external: bool = True
+ ) -> None: ...
+ def defused_start_doctype_decl(self, name: str, sysid: str | None, pubid: str | None, has_internal_subset: bool) -> None: ...
+ def defused_entity_decl(
+ self,
+ name: str,
+ is_parameter_entity: bool,
+ value: str | None,
+ base: str | None,
+ sysid: str,
+ pubid: str | None,
+ notation_name: str | None,
+ ) -> None: ...
+ def defused_unparsed_entity_decl(
+ self, name: str, base: str | None, sysid: str, pubid: str | None, notation_name: str
+ ) -> None: ...
+ def defused_external_entity_ref_handler(
+ self, context: str, base: str | None, sysid: str | None, pubid: str | None
+ ) -> None: ...
def monkey_patch() -> None: ...
def unmonkey_patch() -> None: ...
diff --git a/python/helpers/typeshed/stubs/django-filter/@tests/django_settings.py b/python/helpers/typeshed/stubs/django-filter/@tests/django_settings.py
new file mode 100644
index 000000000000..f44d14e04e15
--- /dev/null
+++ b/python/helpers/typeshed/stubs/django-filter/@tests/django_settings.py
@@ -0,0 +1,12 @@
+SECRET_KEY = "1"
+
+INSTALLED_APPS = (
+ "django.contrib.contenttypes",
+ "django.contrib.sites",
+ "django.contrib.sessions",
+ "django.contrib.messages",
+ "django.contrib.admin.apps.SimpleAdminConfig",
+ "django.contrib.staticfiles",
+ "django.contrib.auth",
+ "django_filters",
+)
diff --git a/python/helpers/typeshed/stubs/django-filter/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/django-filter/@tests/stubtest_allowlist.txt
new file mode 100644
index 000000000000..4a0cd56cafbd
--- /dev/null
+++ b/python/helpers/typeshed/stubs/django-filter/@tests/stubtest_allowlist.txt
@@ -0,0 +1,22 @@
+# Iterator class attributes: Runtime behavior differs due to Django 5.0 compatibility logic in choice setters
+django_filters.fields.ChoiceField.iterator
+django_filters.fields.ModelChoiceField.iterator
+django_filters.fields.ModelMultipleChoiceField.iterator
+django_filters.fields.MultipleChoiceField.iterator
+
+# Lookup NamedTuple: Parameter name mismatch between inferred stub and runtime
+django_filters.fields.Lookup.__new__
+django_filters.fields.Lookup.__doc__
+
+# ChoiceIteratorMixin.choices: Cannot define choices property due to incompatibility with base class ChoiceField
+django_filters.fields.ChoiceIteratorMixin.choices
+
+# Our __init__ signatures are more precise -- ignore "stub does not have *args argument"
+django_filters.fields.BaseCSVField.__init__
+django_filters.fields.ChoiceField.__init__
+django_filters.fields.ChoiceIteratorMixin.__init__
+django_filters.fields.LookupChoiceField.__init__
+django_filters.fields.MultipleChoiceField.__init__
+django_filters.fields.RangeField.__init__
+django_filters.filters.QuerySetRequestMixin.__init__
+django_filters.widgets.CSVWidget.__init__
diff --git a/python/helpers/typeshed/stubs/django-filter/METADATA.toml b/python/helpers/typeshed/stubs/django-filter/METADATA.toml
new file mode 100644
index 000000000000..5fdbcdfb6b14
--- /dev/null
+++ b/python/helpers/typeshed/stubs/django-filter/METADATA.toml
@@ -0,0 +1,7 @@
+version = "25.1.*"
+upstream_repository = "https://github.com/carltongibson/django-filter/"
+requires = ["django-stubs"]
+
+[tool.stubtest]
+mypy_plugins = ["mypy_django_plugin.main"]
+mypy_plugins_config = {"django-stubs" = {"django_settings_module" = "@tests.django_settings"}}
diff --git a/python/helpers/typeshed/stubs/django-filter/django_filters/__init__.pyi b/python/helpers/typeshed/stubs/django-filter/django_filters/__init__.pyi
new file mode 100644
index 000000000000..1ed733b2476a
--- /dev/null
+++ b/python/helpers/typeshed/stubs/django-filter/django_filters/__init__.pyi
@@ -0,0 +1,10 @@
+from typing import Final
+
+from .filters import *
+from .filterset import FilterSet as FilterSet, UnknownFieldBehavior as UnknownFieldBehavior
+
+__version__: Final[str]
+
+def parse_version(version: str) -> tuple[str | int]: ...
+
+VERSION: tuple[str | int, ...]
diff --git a/python/helpers/typeshed/stubs/django-filter/django_filters/compat.pyi b/python/helpers/typeshed/stubs/django-filter/django_filters/compat.pyi
new file mode 100644
index 000000000000..87785dfab536
--- /dev/null
+++ b/python/helpers/typeshed/stubs/django-filter/django_filters/compat.pyi
@@ -0,0 +1 @@
+def is_crispy() -> bool: ...
diff --git a/python/helpers/typeshed/stubs/django-filter/django_filters/conf.pyi b/python/helpers/typeshed/stubs/django-filter/django_filters/conf.pyi
new file mode 100644
index 000000000000..b519d1da8b5d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/django-filter/django_filters/conf.pyi
@@ -0,0 +1,17 @@
+from _typeshed import Unused
+from typing import Any
+
+DEFAULTS: dict[str, Any] # Configuration values can be strings, booleans, callables, etc.
+DEPRECATED_SETTINGS: list[str]
+
+def is_callable(value: Any) -> bool: ... # Accepts any value to test if it's callable
+
+class Settings:
+ # Setting values can be of any type, so getter and setter methods return/accept Any
+ def __getattr__(self, name: str) -> Any: ... # Returns setting values of various types
+ def get_setting(self, setting: str) -> Any: ... # Setting values vary by configuration option
+ def change_setting(
+ self, setting: str, value: Any, enter: bool, **kwargs: Unused
+ ) -> None: ... # Accepts any setting value type
+
+settings: Settings
diff --git a/python/helpers/typeshed/stubs/django-filter/django_filters/constants.pyi b/python/helpers/typeshed/stubs/django-filter/django_filters/constants.pyi
new file mode 100644
index 000000000000..1a88634ea477
--- /dev/null
+++ b/python/helpers/typeshed/stubs/django-filter/django_filters/constants.pyi
@@ -0,0 +1,6 @@
+from typing import Any, Final
+
+# String constant used to indicate all model fields should be included
+ALL_FIELDS: Final[str] = "__all__"
+# Collection of values considered empty by Django filters - tuple type allows various empty containers
+EMPTY_VALUES: Final[Any] = ...
diff --git a/python/helpers/typeshed/stubs/django-filter/django_filters/exceptions.pyi b/python/helpers/typeshed/stubs/django-filter/django_filters/exceptions.pyi
new file mode 100644
index 000000000000..725c08b5cada
--- /dev/null
+++ b/python/helpers/typeshed/stubs/django-filter/django_filters/exceptions.pyi
@@ -0,0 +1,8 @@
+from typing import Any
+
+from django.core.exceptions import FieldError
+from django.db import models
+
+class FieldLookupError(FieldError):
+ # Field type params are runtime-determined
+ def __init__(self, model_field: models.Field[Any, Any], lookup_expr: str) -> None: ...
diff --git a/python/helpers/typeshed/stubs/django-filter/django_filters/fields.pyi b/python/helpers/typeshed/stubs/django-filter/django_filters/fields.pyi
new file mode 100644
index 000000000000..7920f9878c9c
--- /dev/null
+++ b/python/helpers/typeshed/stubs/django-filter/django_filters/fields.pyi
@@ -0,0 +1,157 @@
+from _typeshed import Unused
+from collections.abc import Callable, Iterable, Mapping, Sequence
+from typing import Any, NamedTuple
+from typing_extensions import TypeAlias
+
+from django import forms
+from django.db.models import Choices
+from django.forms import Widget
+from django_stubs_ext import StrOrPromise
+
+DJANGO_50: bool
+
+# Ref: django-stubs/forms/fields.pyi
+# Problem: attribute `widget` is always of type `Widget` after field instantiation.
+# However, on class level it can be set to `Type[Widget]` too.
+# If we annotate it as `Union[Widget, Type[Widget]]`, every code that uses field
+# instances will not typecheck.
+# If we annotate it as `Widget`, any widget subclasses that do e.g.
+# `widget = Select` will not typecheck.
+# `Any` gives too much freedom, but does not create false positives.
+_ClassLevelWidget: TypeAlias = Any
+# Validator parameter type depends on type of the form field used.
+_ValidatorCallable: TypeAlias = Callable[[Any], None]
+# Based on django-stubs utils/choices.pyi
+_Choice: TypeAlias = tuple[Any, Any]
+_ChoiceNamedGroup: TypeAlias = tuple[str, Iterable[_Choice]]
+_Choices: TypeAlias = Iterable[_Choice | _ChoiceNamedGroup]
+_ChoicesMapping: TypeAlias = Mapping[Any, Any]
+_ChoicesInput: TypeAlias = _Choices | _ChoicesMapping | type[Choices] | Callable[[], _Choices | _ChoicesMapping]
+
+class RangeField(forms.MultiValueField):
+ widget: _ClassLevelWidget = ...
+ def __init__(
+ self,
+ fields: tuple[forms.Field, forms.Field] | None = None,
+ *,
+ # Inherited from Django MultiValueField
+ require_all_fields: bool = True,
+ required: bool = ...,
+ widget: Widget | type[Widget] | None = ...,
+ label: StrOrPromise | None = ...,
+ initial: Any | None = ..., # Type depends on the form field used.
+ help_text: StrOrPromise = ...,
+ error_messages: Mapping[str, StrOrPromise] | None = ...,
+ show_hidden_initial: bool = ...,
+ validators: Sequence[_ValidatorCallable] = ...,
+ localize: bool = ...,
+ disabled: bool = ...,
+ label_suffix: str | None = ...,
+ ) -> None: ... # Args/kwargs can be any field params, passes to parent
+ def compress(self, data_list: list[Any] | None) -> slice | None: ... # Data list elements can be any field value type
+
+class DateRangeField(RangeField):
+ widget: _ClassLevelWidget = ...
+ def compress(self, data_list: list[Any] | None) -> slice | None: ... # Date values in list can be any date type
+
+class DateTimeRangeField(RangeField):
+ widget: _ClassLevelWidget = ...
+
+class IsoDateTimeRangeField(RangeField):
+ widget: _ClassLevelWidget = ...
+
+class TimeRangeField(RangeField):
+ widget: _ClassLevelWidget = ...
+
+class Lookup(NamedTuple):
+ value: Any # Lookup values can be any filterable type
+ lookup_expr: str
+
+class LookupChoiceField(forms.MultiValueField):
+ def __init__(
+ self,
+ field: forms.Field,
+ lookup_choices: Sequence[tuple[str, str]],
+ *,
+ empty_label: StrOrPromise = ...,
+ widget: Unused = ...,
+ help_text: Unused = ...,
+ # Inherited from Django MultiValueField
+ require_all_fields: bool = True,
+ required: bool = ...,
+ label: StrOrPromise | None = ...,
+ initial: Any | None = ..., # Type depends on the form field used.
+ error_messages: Mapping[str, StrOrPromise] | None = ...,
+ show_hidden_initial: bool = ...,
+ validators: Sequence[_ValidatorCallable] = ...,
+ localize: bool = ...,
+ disabled: bool = ...,
+ label_suffix: str | None = ...,
+ ) -> None: ... # Args/kwargs can be any field params, uses kwargs for empty_label
+ def compress(self, data_list: list[Any] | None) -> Lookup | None: ... # Data list can contain any lookup components
+
+class IsoDateTimeField(forms.DateTimeField):
+ ISO_8601: str
+ input_formats: list[str]
+ def strptime(self, value: str, format: str) -> Any: ... # Returns datetime objects or parsing results
+
+class BaseCSVField(forms.Field):
+ base_widget_class: _ClassLevelWidget = ...
+ def clean(self, value: Any) -> Any: ... # Cleaned values can be any valid field type
+
+class BaseRangeField(BaseCSVField):
+ widget: _ClassLevelWidget = ...
+ def clean(self, value: Any) -> Any: ... # Input and output values can be any range type
+
+class ChoiceIterator:
+ field: ChoiceField
+ choices: Sequence[tuple[Any, str]] # Choice values can be any type (int, str, Model, etc.)
+ def __init__(
+ self, field: ChoiceField, choices: Sequence[tuple[Any, str]]
+ ) -> None: ... # Choice values can be any selectable type
+ def __iter__(self) -> Any: ... # Iterator yields choice tuples with any value types
+ def __len__(self) -> int: ...
+
+class ModelChoiceIterator(forms.models.ModelChoiceIterator):
+ def __iter__(self) -> Any: ... # Iterator yields choice tuples with any value types
+ def __len__(self) -> int: ...
+
+class ChoiceIteratorMixin:
+ null_label: StrOrPromise | None
+ null_value: Any # Null choice values can be any type (None, empty string, etc.)
+ def __init__(self, *, null_label: StrOrPromise | None, null_value: Any) -> None: ...
+
+class ChoiceField(ChoiceIteratorMixin, forms.ChoiceField):
+ iterator = ChoiceIterator
+ empty_label: StrOrPromise
+ def __init__(
+ self,
+ *,
+ empty_label: StrOrPromise = ...,
+ # Inherited from Django ChoiceField
+ choices: _ChoicesInput = (),
+ required: bool = ...,
+ widget: Widget | type[Widget] | None = ...,
+ label: StrOrPromise | None = ...,
+ initial: Any | None = ..., # Type depends on the form field used.
+ help_text: StrOrPromise = ...,
+ error_messages: Mapping[str, StrOrPromise] | None = ...,
+ show_hidden_initial: bool = ...,
+ validators: Sequence[_ValidatorCallable] = ...,
+ localize: bool = ...,
+ disabled: bool = ...,
+ label_suffix: str | None = ...,
+ null_label: StrOrPromise | None,
+ null_value: Any, # Type depends on the form field used.
+ ) -> None: ...
+
+class MultipleChoiceField(ChoiceIteratorMixin, forms.MultipleChoiceField):
+ iterator = ChoiceIterator
+ empty_label: StrOrPromise | None
+
+class ModelChoiceField(ChoiceIteratorMixin, forms.ModelChoiceField[Any]):
+ iterator = ModelChoiceIterator
+ def to_python(self, value: Any) -> Any: ... # Converts any input to Python model objects or values
+
+class ModelMultipleChoiceField(ChoiceIteratorMixin, forms.ModelMultipleChoiceField[Any]):
+ iterator = ModelChoiceIterator
diff --git a/python/helpers/typeshed/stubs/django-filter/django_filters/filters.pyi b/python/helpers/typeshed/stubs/django-filter/django_filters/filters.pyi
new file mode 100644
index 000000000000..db6faefc27d0
--- /dev/null
+++ b/python/helpers/typeshed/stubs/django-filter/django_filters/filters.pyi
@@ -0,0 +1,325 @@
+from collections.abc import Callable, Iterable
+from typing import Any
+
+from django import forms
+from django.db.models import Q, QuerySet
+from django.forms import Field
+from django_stubs_ext import StrOrPromise
+
+from .fields import (
+ BaseCSVField,
+ BaseRangeField,
+ DateRangeField,
+ DateTimeRangeField,
+ IsoDateTimeField,
+ IsoDateTimeRangeField,
+ Lookup,
+ LookupChoiceField,
+ ModelChoiceField,
+ ModelMultipleChoiceField,
+ RangeField,
+ TimeRangeField,
+)
+
+__all__ = [
+ "AllValuesFilter",
+ "AllValuesMultipleFilter",
+ "BaseCSVFilter",
+ "BaseInFilter",
+ "BaseRangeFilter",
+ "BooleanFilter",
+ "CharFilter",
+ "ChoiceFilter",
+ "DateFilter",
+ "DateFromToRangeFilter",
+ "DateRangeFilter",
+ "DateTimeFilter",
+ "DateTimeFromToRangeFilter",
+ "DurationFilter",
+ "Filter",
+ "IsoDateTimeFilter",
+ "IsoDateTimeFromToRangeFilter",
+ "LookupChoiceFilter",
+ "ModelChoiceFilter",
+ "ModelMultipleChoiceFilter",
+ "MultipleChoiceFilter",
+ "NumberFilter",
+ "NumericRangeFilter",
+ "OrderingFilter",
+ "RangeFilter",
+ "TimeFilter",
+ "TimeRangeFilter",
+ "TypedChoiceFilter",
+ "TypedMultipleChoiceFilter",
+ "UUIDFilter",
+]
+
+class Filter:
+ creation_counter: int
+ field_class: type[Any] # Subclasses specify more specific field types
+ field_name: str | None
+ lookup_expr: str
+ distinct: bool
+ exclude: bool
+ extra: dict[str, Any] # Field kwargs can include various types of parameters
+ def __init__(
+ self,
+ field_name: str | None = None,
+ lookup_expr: str | None = None,
+ *,
+ label: StrOrPromise | None = None,
+ method: Callable[..., Any] | str | None = None, # Filter methods can return various types
+ distinct: bool = False,
+ exclude: bool = False,
+ **kwargs: Any, # Field kwargs stored as extra (required, help_text, etc.)
+ ) -> None: ...
+ def get_method(self, qs: QuerySet[Any]) -> Callable[..., QuerySet[Any]]: ... # Returns QuerySet filtering methods
+ method: Callable[..., Any] | str | None # Custom filter methods return various types
+ label: StrOrPromise | None # Filter label for display
+ @property
+ def field(self) -> Field: ...
+ def filter(self, qs: QuerySet[Any], value: Any) -> QuerySet[Any]: ... # Filter value can be any user input type
+
+class CharFilter(Filter):
+ field_class: type[forms.CharField]
+
+class BooleanFilter(Filter):
+ field_class: type[forms.NullBooleanField]
+
+class ChoiceFilter(Filter):
+ field_class: type[Any] # Base class for choice-based filters
+ null_value: Any # Null value can be any type (None, empty string, etc.)
+ def __init__(
+ self,
+ field_name: str | None = None,
+ lookup_expr: str | None = None,
+ *,
+ null_value: Any = ..., # Null value can be any type (None, empty string, etc.)
+ # Inherited from Filter
+ label: StrOrPromise | None = None,
+ method: Callable[..., Any] | str | None = None, # Filter methods can return various types
+ distinct: bool = False,
+ exclude: bool = False,
+ **kwargs: Any, # Field kwargs stored as extra (required, help_text, etc.)
+ ) -> None: ...
+ def filter(self, qs: QuerySet[Any], value: Any) -> QuerySet[Any]: ...
+
+class TypedChoiceFilter(Filter):
+ field_class: type[forms.TypedChoiceField]
+
+class UUIDFilter(Filter):
+ field_class: type[forms.UUIDField]
+
+class MultipleChoiceFilter(Filter):
+ field_class: type[Any] # Base class for multiple choice filters
+ always_filter: bool
+ conjoined: bool
+ null_value: Any # Multiple choice null values vary by implementation
+ def __init__(
+ self,
+ field_name: str | None = None,
+ lookup_expr: str | None = None,
+ *,
+ distinct: bool = True, # Overrides distinct default
+ conjoined: bool = False,
+ null_value: Any = ..., # Multiple choice null values vary by implementation
+ # Inherited from Filter
+ label: StrOrPromise | None = None,
+ method: Callable[..., Any] | str | None = None, # Filter methods can return various types
+ exclude: bool = False,
+ **kwargs: Any, # Field kwargs stored as extra (required, help_text, etc.)
+ ) -> None: ...
+ def is_noop(self, qs: QuerySet[Any], value: Any) -> bool: ... # Value can be any filter input
+ def filter(self, qs: QuerySet[Any], value: Any) -> QuerySet[Any]: ...
+ def get_filter_predicate(self, v: Any) -> Q: ... # Predicate value can be any filter input type
+
+class TypedMultipleChoiceFilter(MultipleChoiceFilter):
+ field_class: type[forms.TypedMultipleChoiceField] # More specific than parent MultipleChoiceField
+
+class DateFilter(Filter):
+ field_class: type[forms.DateField]
+
+class DateTimeFilter(Filter):
+ field_class: type[forms.DateTimeField]
+
+class IsoDateTimeFilter(DateTimeFilter):
+ field_class: type[IsoDateTimeField]
+
+class TimeFilter(Filter):
+ field_class: type[forms.TimeField]
+
+class DurationFilter(Filter):
+ field_class: type[forms.DurationField]
+
+class QuerySetRequestMixin:
+ queryset: QuerySet[Any] | None
+ def __init__(self, *, queryset: QuerySet[Any] | None) -> None: ...
+ def get_request(self) -> Any: ... # Request can be HttpRequest or other request types
+ def get_queryset(self, request: Any) -> QuerySet[Any]: ... # Request parameter accepts various request types
+ @property
+ def field(self) -> Field: ...
+
+class ModelChoiceFilter(QuerySetRequestMixin, ChoiceFilter):
+ field_class: type[ModelChoiceField] # More specific than parent ChoiceField
+ def __init__(
+ self,
+ field_name: str | None = None,
+ lookup_expr: str | None = None,
+ *,
+ # Inherited from QuerySetRequestMixin
+ queryset: QuerySet[Any] | None = None,
+ # Inherited from ChoiceFilter
+ null_value: Any = ..., # Null value can be any type (None, empty string, etc.)
+ # Inherited from Filter
+ label: StrOrPromise | None = None,
+ method: Callable[..., Any] | str | None = None, # Filter methods can return various types
+ distinct: bool = False,
+ exclude: bool = False,
+ **kwargs: Any, # Field kwargs stored as extra (required, help_text, etc.)
+ ) -> None: ...
+
+class ModelMultipleChoiceFilter(QuerySetRequestMixin, MultipleChoiceFilter):
+ field_class: type[ModelMultipleChoiceField] # More specific than parent MultipleChoiceField
+ def __init__(
+ self,
+ field_name: str | None = None,
+ lookup_expr: str | None = None,
+ *,
+ # Inherited from QuerySetRequestMixin
+ queryset: QuerySet[Any] | None = None,
+ # Inherited from MultipleChoiceFilter
+ distinct: bool = True, # Overrides distinct default
+ conjoined: bool = False,
+ null_value: Any = ..., # Multiple choice null values vary by implementation
+ # Inherited from Filter
+ label: StrOrPromise | None = None,
+ method: Callable[..., Any] | str | None = None, # Filter methods can return various types
+ exclude: bool = False,
+ **kwargs: Any, # Field kwargs stored as extra (required, help_text, etc.)
+ ) -> None: ...
+
+class NumberFilter(Filter):
+ field_class: type[forms.DecimalField]
+ def get_max_validator(self) -> Any: ... # Validator can be various Django validator types
+ @property
+ def field(self) -> Field: ...
+
+class NumericRangeFilter(Filter):
+ field_class: type[RangeField]
+ lookup_expr: str
+ def filter(self, qs: QuerySet[Any], value: Any) -> QuerySet[Any]: ...
+
+class RangeFilter(Filter):
+ field_class: type[RangeField]
+ lookup_expr: str
+ def filter(self, qs: QuerySet[Any], value: Any) -> QuerySet[Any]: ...
+
+class DateRangeFilter(ChoiceFilter):
+ choices: list[tuple[str, str]] | None
+ filters: dict[str, Filter] | None
+ def __init__(
+ self,
+ choices: list[tuple[str, str]] | None = None,
+ filters: dict[str, Filter] | None = None,
+ field_name: str | None = None,
+ lookup_expr: str | None = None,
+ *,
+ # Inherited from ChoiceFilter
+ null_value: Any = ..., # Null value can be any type (None, empty string, etc.)
+ # Inherited from Filter
+ label: StrOrPromise | None = None,
+ method: Callable[..., Any] | str | None = None, # Filter methods can return various types
+ distinct: bool = False,
+ exclude: bool = False,
+ **kwargs: Any, # Field kwargs stored as extra (required, help_text, etc.)
+ ) -> None: ... # Uses args/kwargs for choice and filter configuration
+ def filter(self, qs: QuerySet[Any], value: Any) -> QuerySet[Any]: ...
+
+class DateFromToRangeFilter(RangeFilter):
+ field_class: type[DateRangeField]
+
+class DateTimeFromToRangeFilter(RangeFilter):
+ field_class: type[DateTimeRangeField]
+
+class IsoDateTimeFromToRangeFilter(RangeFilter):
+ field_class: type[IsoDateTimeRangeField]
+
+class TimeRangeFilter(RangeFilter):
+ field_class: type[TimeRangeField]
+
+class AllValuesFilter(ChoiceFilter):
+ @property
+ def field(self) -> Field: ...
+
+class AllValuesMultipleFilter(MultipleChoiceFilter):
+ @property
+ def field(self) -> Field: ...
+
+class BaseCSVFilter(Filter):
+ base_field_class: type[BaseCSVField] = ...
+ field_class: type[Any] # Base class for CSV-based filters
+
+class BaseInFilter(BaseCSVFilter): ...
+
+class BaseRangeFilter(BaseCSVFilter):
+ base_field_class: type[BaseRangeField] = ...
+
+class LookupChoiceFilter(Filter):
+ field_class: type[forms.CharField]
+ outer_class: type[LookupChoiceField] = ...
+ empty_label: StrOrPromise | None
+ lookup_choices: list[tuple[str, StrOrPromise]] | None
+ def __init__(
+ self,
+ field_name: str | None = None,
+ lookup_choices: list[tuple[str, StrOrPromise]] | None = None,
+ field_class: type[Field] | None = None,
+ *,
+ empty_label: StrOrPromise = ...,
+ # Inherited from Filter
+ label: StrOrPromise | None = None,
+ method: Callable[..., Any] | str | None = None, # Filter methods can return various types
+ distinct: bool = False,
+ exclude: bool = False,
+ **kwargs: Any, # Field kwargs stored as extra (required, help_text, etc.)
+ ) -> None: ...
+ @classmethod
+ def normalize_lookup(cls, lookup: str | tuple[str, StrOrPromise]) -> tuple[str, StrOrPromise]: ...
+ def get_lookup_choices(self) -> list[tuple[str, StrOrPromise]]: ...
+ @property
+ def field(self) -> Field: ...
+ lookup_expr: str
+ def filter(self, qs: QuerySet[Any], lookup: Lookup) -> QuerySet[Any]: ...
+
+class OrderingFilter(BaseCSVFilter, ChoiceFilter):
+ field_class: type[BaseCSVField] # Inherits CSV field behavior for comma-separated ordering
+ descending_fmt: str
+ param_map: dict[str, str] | None
+ def __init__(
+ self,
+ field_name: str | None = None,
+ lookup_expr: str | None = None,
+ *,
+ fields: dict[str, str] | Iterable[tuple[str, str]] = ...,
+ field_labels: dict[str, StrOrPromise] = ...,
+ # Inherited from ChoiceFilter
+ null_value: Any = ..., # Null value can be any type (None, empty string, etc.)
+ # Inherited from Filter
+ label: StrOrPromise | None = None,
+ method: Callable[..., Any] | str | None = None, # Filter methods can return various types
+ distinct: bool = False,
+ exclude: bool = False,
+ **kwargs: Any, # Field kwargs stored as extra (required, help_text, etc.)
+ ) -> None: ...
+ def get_ordering_value(self, param: str) -> str: ...
+ def filter(self, qs: QuerySet[Any], value: Any) -> QuerySet[Any]: ...
+ @classmethod
+ def normalize_fields(cls, fields: Any) -> list[str]: ...
+ def build_choices(self, fields: Any, labels: dict[str, StrOrPromise] | None) -> list[tuple[str, str]]: ...
+
+class FilterMethod:
+ f: Filter
+ def __init__(self, filter_instance: Filter) -> None: ...
+ def __call__(self, qs: QuerySet[Any], value: Any) -> QuerySet[Any]: ...
+ @property
+ def method(self) -> Callable[..., Any]: ...
diff --git a/python/helpers/typeshed/stubs/django-filter/django_filters/filterset.pyi b/python/helpers/typeshed/stubs/django-filter/django_filters/filterset.pyi
new file mode 100644
index 000000000000..7b59f3004560
--- /dev/null
+++ b/python/helpers/typeshed/stubs/django-filter/django_filters/filterset.pyi
@@ -0,0 +1,86 @@
+from collections import OrderedDict
+from collections.abc import Sequence
+from enum import Enum
+from typing import Any, ClassVar
+
+from django.db import models
+from django.db.models import Model, QuerySet
+from django.forms import Form
+from django.http import HttpRequest, QueryDict
+
+from .filters import Filter
+
+def remote_queryset(field: models.Field[Any, Any]) -> QuerySet[Any]: ... # Field type params vary by model definition
+
+class UnknownFieldBehavior(Enum):
+ RAISE = "raise"
+ WARN = "warn"
+ IGNORE = "ignore"
+
+class FilterSetOptions:
+ model: type[Model] | None
+ fields: Sequence[str] | dict[str, Sequence[str]] | str | None
+ exclude: Sequence[str] | None
+ filter_overrides: dict[type[models.Field[Any, Any]], dict[str, Any]] # Field override mapping
+ form: type[Form]
+ unknown_field_behavior: UnknownFieldBehavior
+ def __init__(self, options: Any | None = None) -> None: ... # Meta options can be various configuration types
+
+class FilterSetMetaclass(type):
+ # Class attrs vary by definition
+ def __new__(cls, name: str, bases: tuple[type, ...], attrs: dict[str, Any]) -> FilterSetMetaclass: ...
+
+ # Class attrs vary by definition
+ @classmethod
+ def get_declared_filters(cls, bases: tuple[type, ...], attrs: dict[str, Any]) -> OrderedDict[str, Filter]: ...
+
+# Django field types vary widely - Any allows mapping all field types to their filters
+FILTER_FOR_DBFIELD_DEFAULTS: dict[type[models.Field[Any, Any]], dict[str, Any]]
+
+class BaseFilterSet:
+ FILTER_DEFAULTS: ClassVar[dict[type[models.Field[Any, Any]], dict[str, Any]]] = ... # Field type mapping
+ is_bound: bool
+ base_filters: OrderedDict[str, Filter]
+ declared_filters: OrderedDict[str, Filter]
+ data: QueryDict | dict[str, Any] | None # Filter input data values vary
+ queryset: QuerySet[Any] | None # Base queryset for any model type
+ request: HttpRequest | None
+ form_prefix: str | None
+ filters: OrderedDict[str, Filter]
+ def __init__(
+ self,
+ data: QueryDict | dict[str, Any] | None = None, # Filter data values vary
+ queryset: QuerySet[Any] | None = None, # Base queryset for any model
+ *,
+ request: HttpRequest | None = None,
+ prefix: str | None = None,
+ ) -> None: ...
+ def is_valid(self) -> bool: ...
+ @property
+ def errors(self) -> dict[str, list[str]]: ...
+ def filter_queryset(self, queryset: QuerySet[Any]) -> QuerySet[Any]: ... # Works with any model type
+ @property
+ def qs(self) -> QuerySet[Any]: ... # Filtered queryset of any model
+ def get_form_class(self) -> type[Form]: ...
+ @property
+ def form(self) -> Form: ...
+ @classmethod
+ def get_fields(cls) -> dict[str, models.Field[Any, Any]]: ... # Model fields have varying type params
+ @classmethod
+ def get_filter_name(cls, field_name: str, lookup_expr: str) -> str: ...
+ @classmethod
+ def get_filters(cls) -> OrderedDict[str, Filter]: ...
+ @classmethod
+ def handle_unrecognized_field(cls, field_name: str, message: str) -> None: ...
+ @classmethod
+ def filter_for_field(
+ cls, field: models.Field[Any, Any], field_name: str, lookup_expr: str | None = None
+ ) -> Filter: ... # Accepts any Django field type
+ @classmethod
+ def filter_for_lookup(cls, field: models.Field[Any, Any], lookup_type: str) -> type[Filter]: ... # Field type varies by model
+
+class FilterSet(BaseFilterSet, metaclass=FilterSetMetaclass): ...
+
+def filterset_factory(
+ model: type[Model], filterset: FilterSetMetaclass = ..., fields: Sequence[str] | dict[str, Sequence[str]] | str | None = None
+) -> type[FilterSet]: ...
diff --git a/python/helpers/typeshed/stubs/django-filter/django_filters/rest_framework/__init__.pyi b/python/helpers/typeshed/stubs/django-filter/django_filters/rest_framework/__init__.pyi
new file mode 100644
index 000000000000..560557bc8d9b
--- /dev/null
+++ b/python/helpers/typeshed/stubs/django-filter/django_filters/rest_framework/__init__.pyi
@@ -0,0 +1,34 @@
+from .backends import DjangoFilterBackend as DjangoFilterBackend
+from .filters import (
+ AllValuesFilter as AllValuesFilter,
+ AllValuesMultipleFilter as AllValuesMultipleFilter,
+ BaseCSVFilter as BaseCSVFilter,
+ BaseInFilter as BaseInFilter,
+ BaseRangeFilter as BaseRangeFilter,
+ BooleanFilter as BooleanFilter,
+ CharFilter as CharFilter,
+ ChoiceFilter as ChoiceFilter,
+ DateFilter as DateFilter,
+ DateFromToRangeFilter as DateFromToRangeFilter,
+ DateRangeFilter as DateRangeFilter,
+ DateTimeFilter as DateTimeFilter,
+ DateTimeFromToRangeFilter as DateTimeFromToRangeFilter,
+ DurationFilter as DurationFilter,
+ Filter as Filter,
+ IsoDateTimeFilter as IsoDateTimeFilter,
+ IsoDateTimeFromToRangeFilter as IsoDateTimeFromToRangeFilter,
+ LookupChoiceFilter as LookupChoiceFilter,
+ ModelChoiceFilter as ModelChoiceFilter,
+ ModelMultipleChoiceFilter as ModelMultipleChoiceFilter,
+ MultipleChoiceFilter as MultipleChoiceFilter,
+ NumberFilter as NumberFilter,
+ NumericRangeFilter as NumericRangeFilter,
+ OrderingFilter as OrderingFilter,
+ RangeFilter as RangeFilter,
+ TimeFilter as TimeFilter,
+ TimeRangeFilter as TimeRangeFilter,
+ TypedChoiceFilter as TypedChoiceFilter,
+ TypedMultipleChoiceFilter as TypedMultipleChoiceFilter,
+ UUIDFilter as UUIDFilter,
+)
+from .filterset import FilterSet as FilterSet
diff --git a/python/helpers/typeshed/stubs/django-filter/django_filters/rest_framework/backends.pyi b/python/helpers/typeshed/stubs/django-filter/django_filters/rest_framework/backends.pyi
new file mode 100644
index 000000000000..b45372d919af
--- /dev/null
+++ b/python/helpers/typeshed/stubs/django-filter/django_filters/rest_framework/backends.pyi
@@ -0,0 +1,30 @@
+from typing import Any
+from typing_extensions import TypeAlias
+
+from django.db.models import QuerySet
+from django.http import HttpRequest
+from django_filters.filterset import FilterSetMetaclass
+
+from . import filterset
+
+# APIView placeholder - djangorestframework is optional, so we use Any for compatibility
+_APIView: TypeAlias = Any
+
+class DjangoFilterBackend:
+ filterset_base: FilterSetMetaclass = ...
+ raise_exception: bool
+ @property
+ def template(self) -> str: ...
+
+ # Works with any model type
+ def get_filterset(self, request: HttpRequest, queryset: QuerySet[Any], view: _APIView) -> filterset.FilterSet | None: ...
+
+ # Any model queryset
+ def get_filterset_class(self, view: _APIView, queryset: QuerySet[Any] | None = None) -> type[filterset.FilterSet] | None: ...
+
+ # Kwargs vary by filterset
+ def get_filterset_kwargs(self, request: HttpRequest, queryset: QuerySet[Any], view: _APIView) -> dict[str, Any]: ...
+
+ # Filters any model type
+ def filter_queryset(self, request: HttpRequest, queryset: QuerySet[Any], view: _APIView) -> QuerySet[Any]: ...
+ def to_html(self, request: HttpRequest, queryset: QuerySet[Any], view: _APIView) -> str: ... # Renders form for any model
diff --git a/python/helpers/typeshed/stubs/django-filter/django_filters/rest_framework/filters.pyi b/python/helpers/typeshed/stubs/django-filter/django_filters/rest_framework/filters.pyi
new file mode 100644
index 000000000000..9dec2084d15f
--- /dev/null
+++ b/python/helpers/typeshed/stubs/django-filter/django_filters/rest_framework/filters.pyi
@@ -0,0 +1,68 @@
+from ..filters import (
+ AllValuesFilter,
+ AllValuesMultipleFilter,
+ BaseCSVFilter,
+ BaseInFilter,
+ BaseRangeFilter,
+ BooleanFilter as _BaseBooleanFilter,
+ CharFilter,
+ ChoiceFilter,
+ DateFilter,
+ DateFromToRangeFilter,
+ DateRangeFilter,
+ DateTimeFilter,
+ DateTimeFromToRangeFilter,
+ DurationFilter,
+ Filter,
+ IsoDateTimeFilter,
+ IsoDateTimeFromToRangeFilter,
+ LookupChoiceFilter,
+ ModelChoiceFilter,
+ ModelMultipleChoiceFilter,
+ MultipleChoiceFilter,
+ NumberFilter,
+ NumericRangeFilter,
+ OrderingFilter,
+ RangeFilter,
+ TimeFilter,
+ TimeRangeFilter,
+ TypedChoiceFilter,
+ TypedMultipleChoiceFilter,
+ UUIDFilter,
+)
+
+__all__ = [
+ "AllValuesFilter",
+ "AllValuesMultipleFilter",
+ "BaseCSVFilter",
+ "BaseInFilter",
+ "BaseRangeFilter",
+ "BooleanFilter",
+ "CharFilter",
+ "ChoiceFilter",
+ "DateFilter",
+ "DateFromToRangeFilter",
+ "DateRangeFilter",
+ "DateTimeFilter",
+ "DateTimeFromToRangeFilter",
+ "DurationFilter",
+ "Filter",
+ "IsoDateTimeFilter",
+ "IsoDateTimeFromToRangeFilter",
+ "LookupChoiceFilter",
+ "ModelChoiceFilter",
+ "ModelMultipleChoiceFilter",
+ "MultipleChoiceFilter",
+ "NumberFilter",
+ "NumericRangeFilter",
+ "OrderingFilter",
+ "RangeFilter",
+ "TimeFilter",
+ "TimeRangeFilter",
+ "TypedChoiceFilter",
+ "TypedMultipleChoiceFilter",
+ "UUIDFilter",
+]
+
+# REST framework specific BooleanFilter that uses BooleanWidget by default
+class BooleanFilter(_BaseBooleanFilter): ...
diff --git a/python/helpers/typeshed/stubs/django-filter/django_filters/rest_framework/filterset.pyi b/python/helpers/typeshed/stubs/django-filter/django_filters/rest_framework/filterset.pyi
new file mode 100644
index 000000000000..cd7eb9ab5813
--- /dev/null
+++ b/python/helpers/typeshed/stubs/django-filter/django_filters/rest_framework/filterset.pyi
@@ -0,0 +1,17 @@
+from collections import OrderedDict
+from typing import Any, ClassVar
+
+from django.db import models
+from django.forms import Form
+from django_filters import filterset
+from django_filters.filters import Filter
+
+# REST framework field mappings support all Django field types
+FILTER_FOR_DBFIELD_DEFAULTS: dict[type[models.Field[Any, Any]], dict[str, Any]]
+
+class FilterSet(filterset.FilterSet):
+ FILTER_DEFAULTS: ClassVar[dict[type[models.Field[Any, Any]], dict[str, Any]]] = ... # DRF field mappings
+ base_filters: OrderedDict[str, Filter]
+ declared_filters: OrderedDict[str, Filter]
+ @property
+ def form(self) -> Form: ...
diff --git a/python/helpers/typeshed/stubs/django-filter/django_filters/utils.pyi b/python/helpers/typeshed/stubs/django-filter/django_filters/utils.pyi
new file mode 100644
index 000000000000..247108ee84ec
--- /dev/null
+++ b/python/helpers/typeshed/stubs/django-filter/django_filters/utils.pyi
@@ -0,0 +1,36 @@
+from collections.abc import Callable
+from datetime import datetime
+from typing import Any
+
+from django.db import models
+from django.db.models import Model
+
+def deprecate(msg: str, level_modifier: int = 0) -> None: ...
+
+class MigrationNotice(DeprecationWarning):
+ url: str
+ def __init__(self, message: str) -> None: ...
+
+class RenameAttributesBase(type):
+ renamed_attributes: tuple[tuple[str, str, DeprecationWarning], ...] = ()
+
+ # Class attrs vary by definition
+ def __new__(metacls, name: str, bases: tuple[type, ...], attrs: dict[str, Any]) -> RenameAttributesBase: ...
+ def get_name(metacls, name: str) -> str: ...
+ def __getattr__(metacls, name: str) -> Any: ... # Attribute values vary by name and class
+ def __setattr__(metacls, name: str, value: Any) -> None: ... # Attribute values can be any type
+
+def try_dbfield(
+ fn: Callable[[models.Field[Any, Any]], Any], field_class: type[models.Field[Any, Any]]
+) -> Any: ... # Generic field operation
+def get_all_model_fields(model: type[Model]) -> dict[str, models.Field[Any, Any]]: ... # Fields vary by model definition
+def get_model_field(model: type[Model], field_name: str) -> models.Field[Any, Any]: ... # Field type unknown at static time
+def get_field_parts(model: type[Model], field_name: str) -> list[models.Field[Any, Any]]: ... # Relationship fields vary
+def resolve_field(
+ model_field: models.Field[Any, Any], lookup_expr: str
+) -> tuple[models.Field[Any, Any], str]: ... # Generic field resolution
+def handle_timezone(value: datetime, is_dst: bool | None = None) -> datetime: ...
+def verbose_field_name(model: type[Model], field_name: str) -> str: ...
+def verbose_lookup_expr(lookup_expr: str) -> str: ...
+def label_for_filter(model: type[Model], field_name: str, lookup_expr: str, exclude: bool = False) -> str: ...
+def translate_validation(error_dict: dict[str, list[str]]) -> dict[str, list[str]]: ...
diff --git a/python/helpers/typeshed/stubs/django-filter/django_filters/views.pyi b/python/helpers/typeshed/stubs/django-filter/django_filters/views.pyi
new file mode 100644
index 000000000000..0af9f1f21256
--- /dev/null
+++ b/python/helpers/typeshed/stubs/django-filter/django_filters/views.pyi
@@ -0,0 +1,38 @@
+from _typeshed import Unused
+from typing import Any
+
+from django.db.models import Model, QuerySet
+from django.http import HttpRequest, HttpResponse
+from django.views.generic import View
+from django.views.generic.list import MultipleObjectMixin, MultipleObjectTemplateResponseMixin
+
+from .constants import ALL_FIELDS
+from .filterset import FilterSet
+
+class FilterMixin:
+ filterset_class: type[FilterSet] | None
+ filterset_fields = ALL_FIELDS
+ strict: bool
+ def get_filterset_class(self) -> type[FilterSet] | None: ...
+ def get_filterset(self, filterset_class: type[FilterSet]) -> FilterSet: ...
+ def get_filterset_kwargs(self, filterset_class: type[FilterSet]) -> dict[str, Any]: ... # Filterset init params vary
+ def get_strict(self) -> bool: ...
+
+class BaseFilterView(FilterMixin, MultipleObjectMixin[Any], View): # Generic model type
+ filterset: FilterSet
+ object_list: QuerySet[Any] # Filtered objects of any model type
+
+ def get(self, request: HttpRequest, *args: Unused, **kwargs: Unused) -> HttpResponse: ...
+
+class FilterView(MultipleObjectTemplateResponseMixin, BaseFilterView):
+ template_name_suffix: str
+
+def object_filter(
+ request: HttpRequest,
+ model: type[Model] | None = None,
+ queryset: QuerySet[Any] | None = None, # Base queryset for any model
+ template_name: str | None = None,
+ extra_context: dict[str, Any] | None = None, # Template context values vary
+ context_processors: list[Any] | None = None, # Context processors vary by implementation
+ filter_class: type[FilterSet] | None = None,
+) -> HttpResponse: ...
diff --git a/python/helpers/typeshed/stubs/django-filter/django_filters/widgets.pyi b/python/helpers/typeshed/stubs/django-filter/django_filters/widgets.pyi
new file mode 100644
index 000000000000..8707dc0fdbfb
--- /dev/null
+++ b/python/helpers/typeshed/stubs/django-filter/django_filters/widgets.pyi
@@ -0,0 +1,81 @@
+from collections.abc import Mapping, Sequence
+from typing import Any
+
+from django import forms
+from django.http import QueryDict
+from django.utils.safestring import SafeString
+
+class LinkWidget(forms.Widget):
+ # Choice values can be any type (int, str, Model, etc.)
+ choices: Sequence[tuple[Any, str]]
+ # Choice values can be any selectable type
+ def __init__(self, attrs: dict[str, Any] | None = None, choices: Sequence[tuple[Any, str]] = ()) -> None: ...
+ data: QueryDict | dict[str, Any]
+ # Return value depends on widget data type
+ def value_from_datadict(self, data: Mapping[str, Any], files: Mapping[str, Any], name: str) -> Any: ...
+ # Widget value and renderer can be any type, choices parameter combines with class choices
+ def render( # type: ignore[override]
+ self,
+ name: str,
+ value: Any,
+ attrs: dict[str, Any] | None = None,
+ choices: Sequence[tuple[Any, str]] = (),
+ renderer: Any | None = None,
+ ) -> SafeString: ...
+ # Choice values and selections can be any type
+ def render_options(self, choices: Sequence[tuple[Any, str]], selected_choices: list[Any], name: str) -> str: ...
+ # Selected choices and option values can be any type
+ def render_option(self, name: str, selected_choices: list[Any], option_value: Any, option_label: str) -> str: ...
+ def option_string(self) -> str: ...
+
+class SuffixedMultiWidget(forms.MultiWidget):
+ suffixes: list[str]
+ def suffixed(self, name: str, suffix: str) -> str: ...
+ # Widget value and context can contain any data types
+ def get_context(self, name: str, value: Any, attrs: dict[str, Any] | None) -> dict[str, Any]: ...
+ # Returns list of any value types from widget data
+ def value_from_datadict(self, data: Mapping[str, Any], files: Mapping[str, Any], name: str) -> list[Any]: ...
+ # Widget data can contain any types
+ def value_omitted_from_data(self, data: Mapping[str, Any], files: Mapping[str, Any], name: str) -> bool: ...
+ def replace_name(self, output: str, index: int) -> str: ...
+ # Decompresses any widget value into list of components
+ def decompress(self, value: Any) -> list[Any] | None: ...
+
+class RangeWidget(SuffixedMultiWidget):
+ template_name: str
+ suffixes: list[str]
+ # Accepts any widget attribute types
+ def __init__(self, attrs: dict[str, Any] | None = None) -> None: ...
+ # Decompresses any range value into list components
+ def decompress(self, value: Any) -> list[Any] | None: ...
+
+class DateRangeWidget(RangeWidget):
+ suffixes: list[str]
+
+class LookupChoiceWidget(SuffixedMultiWidget):
+ suffixes: list[str]
+ # Decompresses any lookup choice value into components
+ def decompress(self, value: Any) -> list[Any] | None: ...
+
+class BooleanWidget(forms.Select):
+ # Accepts any widget attribute types
+ def __init__(self, attrs: dict[str, Any] | None = None) -> None: ...
+ # Widget value and renderer can be any type
+ def render(self, name: str, value: Any, attrs: dict[str, Any] | None = None, renderer: Any | None = None) -> SafeString: ...
+ # Return value type depends on widget data
+ def value_from_datadict(self, data: Mapping[str, Any], files: Mapping[str, Any], name: str) -> Any: ...
+
+class BaseCSVWidget(forms.Widget):
+ # Can be widget class or instance - __init__ converts to instance via instantiation or deepcopy
+ surrogate: type[Any] = ...
+
+ # CSV widget data can contain any types
+ def value_from_datadict(self, data: Mapping[str, Any], files: Mapping[str, Any], name: str) -> list[str]: ...
+ # Widget value and renderer can be any type
+ def render(self, name: str, value: Any, attrs: dict[str, Any] | None = None, renderer: Any | None = None) -> SafeString: ...
+
+class CSVWidget(BaseCSVWidget, forms.TextInput): ...
+
+class QueryArrayWidget(BaseCSVWidget, forms.TextInput):
+ # Query array widget data can contain any types
+ def value_from_datadict(self, data: Mapping[str, Any], files: Mapping[str, Any], name: str) -> list[str]: ...
diff --git a/python/helpers/typeshed/stubs/django-import-export/import_export/resources.pyi b/python/helpers/typeshed/stubs/django-import-export/import_export/resources.pyi
index 1c5a5e7f1b24..1f62c6b74aa2 100644
--- a/python/helpers/typeshed/stubs/django-import-export/import_export/resources.pyi
+++ b/python/helpers/typeshed/stubs/django-import-export/import_export/resources.pyi
@@ -105,7 +105,7 @@ class Resource(Generic[_ModelT], metaclass=DeclarativeMetaclass):
@overload
def handle_import_error(self, result: Result, error: Exception, raise_errors: Literal[True]) -> NoReturn: ...
@overload
- def handle_import_error(self, result: Result, error: Exception, raise_errors: Literal[False] = ...) -> None: ...
+ def handle_import_error(self, result: Result, error: Exception, raise_errors: Literal[False] = False) -> None: ...
def import_row(self, row: dict[str, Any], instance_loader: BaseInstanceLoader, **kwargs: Any) -> RowResult: ...
def import_data(
self,
diff --git a/python/helpers/typeshed/stubs/django-import-export/import_export/templatetags/import_export_tags.pyi b/python/helpers/typeshed/stubs/django-import-export/import_export/templatetags/import_export_tags.pyi
index dcbfa25a67c1..9d6c0e4d7f68 100644
--- a/python/helpers/typeshed/stubs/django-import-export/import_export/templatetags/import_export_tags.pyi
+++ b/python/helpers/typeshed/stubs/django-import-export/import_export/templatetags/import_export_tags.pyi
@@ -4,5 +4,5 @@ from django.template import Library
register: Library
-# @register.simple_tag # commented out for pytype
+@register.simple_tag
def compare_values(value1: str, value2: str) -> LiteralString: ...
diff --git a/python/helpers/typeshed/stubs/docker/docker/models/containers.pyi b/python/helpers/typeshed/stubs/docker/docker/models/containers.pyi
index 4d167e419762..706ffc609fe9 100644
--- a/python/helpers/typeshed/stubs/docker/docker/models/containers.pyi
+++ b/python/helpers/typeshed/stubs/docker/docker/models/containers.pyi
@@ -1,7 +1,7 @@
import datetime
from _typeshed import Incomplete
from collections.abc import Iterable, Mapping
-from typing import Literal, NamedTuple, TypedDict, overload
+from typing import Literal, NamedTuple, TypedDict, overload, type_check_only
from typing_extensions import NotRequired
from docker._types import ContainerWeightDevice, WaitContainerResponse
@@ -13,6 +13,7 @@ from docker.types.services import Mount
from .images import Image
from .resource import Collection, Model
+@type_check_only
class _RestartPolicy(TypedDict):
MaximumRetryCount: NotRequired[int]
Name: NotRequired[Literal["always", "on-failure"]]
diff --git a/python/helpers/typeshed/stubs/docker/docker/models/images.pyi b/python/helpers/typeshed/stubs/docker/docker/models/images.pyi
index 279bd6dcfc6a..7de317a325b3 100644
--- a/python/helpers/typeshed/stubs/docker/docker/models/images.pyi
+++ b/python/helpers/typeshed/stubs/docker/docker/models/images.pyi
@@ -1,3 +1,4 @@
+from _typeshed import SupportsRead
from collections.abc import Iterator
from io import StringIO
from typing import IO, Any, Literal, TypedDict, overload, type_check_only
@@ -73,7 +74,7 @@ class ImageCollection(Collection[Image]):
def get(self, name: str) -> Image: ...
def get_registry_data(self, name, auth_config: dict[str, Any] | None = None) -> RegistryData: ...
def list(self, name: str | None = None, all: bool = False, filters: dict[str, Any] | None = None) -> _ImageList: ...
- def load(self, data: bytes) -> _ImageList: ...
+ def load(self, data: bytes | SupportsRead[bytes]) -> _ImageList: ...
@overload
def pull(
self,
diff --git a/python/helpers/typeshed/stubs/docker/docker/transport/sshconn.pyi b/python/helpers/typeshed/stubs/docker/docker/transport/sshconn.pyi
index 467bc42f45f9..e891d4bc4525 100644
--- a/python/helpers/typeshed/stubs/docker/docker/transport/sshconn.pyi
+++ b/python/helpers/typeshed/stubs/docker/docker/transport/sshconn.pyi
@@ -42,6 +42,6 @@ class SSHHTTPAdapter(BaseHTTPAdapter):
timeout: Incomplete
max_pool_size: Incomplete
pools: Incomplete
- def __init__(self, base_url, timeout: int = 60, pool_connections=..., max_pool_size=..., shell_out: bool = False) -> None: ...
+ def __init__(self, base_url, timeout: int = 60, pool_connections=25, max_pool_size=10, shell_out: bool = False) -> None: ...
def get_connection(self, url, proxies=None): ...
def close(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/docker/docker/utils/proxy.pyi b/python/helpers/typeshed/stubs/docker/docker/utils/proxy.pyi
index f1563618d14b..a8e84d1a6ba1 100644
--- a/python/helpers/typeshed/stubs/docker/docker/utils/proxy.pyi
+++ b/python/helpers/typeshed/stubs/docker/docker/utils/proxy.pyi
@@ -1,13 +1,15 @@
from collections.abc import Sequence
-from typing import TypedDict
+from typing import TypedDict, type_check_only
from typing_extensions import NotRequired
+@type_check_only
class _ProxyConfigDict(TypedDict):
http: NotRequired[str]
https: NotRequired[str]
ftpProxy: NotRequired[str]
noProxy: NotRequired[str]
+@type_check_only
class _Environment(TypedDict):
http_proxy: NotRequired[str]
HTTP_PROXY: NotRequired[str]
diff --git a/python/helpers/typeshed/stubs/dockerfile-parse/dockerfile_parse/__init__.pyi b/python/helpers/typeshed/stubs/dockerfile-parse/dockerfile_parse/__init__.pyi
index eeb43a016a3a..53ccc597c4dc 100644
--- a/python/helpers/typeshed/stubs/dockerfile-parse/dockerfile_parse/__init__.pyi
+++ b/python/helpers/typeshed/stubs/dockerfile-parse/dockerfile_parse/__init__.pyi
@@ -1,3 +1,5 @@
+from typing import Final
+
from .parser import DockerfileParser as DockerfileParser
-__version__: str
+__version__: Final[str]
diff --git a/python/helpers/typeshed/stubs/dockerfile-parse/dockerfile_parse/constants.pyi b/python/helpers/typeshed/stubs/dockerfile-parse/dockerfile_parse/constants.pyi
index 9bf1c78f3e74..9453a8eff553 100644
--- a/python/helpers/typeshed/stubs/dockerfile-parse/dockerfile_parse/constants.pyi
+++ b/python/helpers/typeshed/stubs/dockerfile-parse/dockerfile_parse/constants.pyi
@@ -1,2 +1,4 @@
-DOCKERFILE_FILENAME: str
-COMMENT_INSTRUCTION: str
+from typing import Final
+
+DOCKERFILE_FILENAME: Final = "Dockerfile"
+COMMENT_INSTRUCTION: Final = "COMMENT"
diff --git a/python/helpers/typeshed/stubs/dockerfile-parse/dockerfile_parse/parser.pyi b/python/helpers/typeshed/stubs/dockerfile-parse/dockerfile_parse/parser.pyi
index a5e74082f522..fbaa98096332 100644
--- a/python/helpers/typeshed/stubs/dockerfile-parse/dockerfile_parse/parser.pyi
+++ b/python/helpers/typeshed/stubs/dockerfile-parse/dockerfile_parse/parser.pyi
@@ -1,6 +1,6 @@
import logging
from collections.abc import Mapping, Sequence
-from typing import IO, ClassVar, TypedDict
+from typing import IO, ClassVar, TypedDict, type_check_only
from .util import Context
@@ -19,6 +19,7 @@ class Labels(KeyValues): ...
class Envs(KeyValues): ...
class Args(KeyValues): ...
+@type_check_only
class _InstructionDict(TypedDict):
instruction: str
startline: int
diff --git a/python/helpers/typeshed/stubs/dockerfile-parse/dockerfile_parse/util.pyi b/python/helpers/typeshed/stubs/dockerfile-parse/dockerfile_parse/util.pyi
index a15048eb19c8..5ad32c3780b2 100644
--- a/python/helpers/typeshed/stubs/dockerfile-parse/dockerfile_parse/util.pyi
+++ b/python/helpers/typeshed/stubs/dockerfile-parse/dockerfile_parse/util.pyi
@@ -19,7 +19,7 @@ class WordSplitter:
escaped: bool
def __init__(self, s: str, args: Mapping[str, str] | None = None, envs: Mapping[str, str] | None = None) -> None: ...
def dequote(self) -> str: ...
- def split(self, maxsplit: int | None = None, dequote: bool = True) -> Generator[str | None, None, None]: ...
+ def split(self, maxsplit: int | None = None, dequote: bool = True) -> Generator[str | None]: ...
def extract_key_values(
env_replace: bool, args: Mapping[str, str], envs: Mapping[str, str], instruction_value: str
diff --git a/python/helpers/typeshed/stubs/docutils/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/docutils/@tests/stubtest_allowlist.txt
index dc4c82d50003..5e747c6670f6 100644
--- a/python/helpers/typeshed/stubs/docutils/@tests/stubtest_allowlist.txt
+++ b/python/helpers/typeshed/stubs/docutils/@tests/stubtest_allowlist.txt
@@ -1,20 +1,38 @@
-docutils.frontend.ConfigParser.__getattr__
-docutils.frontend.ConfigParser.read
-docutils.frontend.OptionParser.__getattr__
-docutils.io.FileOutput.__getattr__
-docutils.io.FileOutput.__init__
docutils.nodes.Element.__iter__ # doesn't exist at runtime, but the class is iterable due to __getitem__
docutils.nodes.Element.tagname # class variable is overridden in __init__ method
-docutils.nodes.NodeVisitor.depart_\w+ # Methods are discovered dynamically on commonly-used subclasses
+docutils.nodes.NodeVisitor.depart_\w+ # Methods are discovered dynamically on commonly-used subclasses
docutils.nodes.NodeVisitor.visit_\w+ # Methods are discovered dynamically on commonly-used subclasses
+docutils.nodes.NodeVisitor.__init__ # Argument "document" should be positional-only, but subclasses are not
+
# these methods take a rawsource parameter that has been deprecated and is completely ignored, so we omit it from the stub
docutils.nodes.Text.__new__
-docutils.parsers.recommonmark_wrapper
docutils.parsers.rst.directives.admonitions.BaseAdmonition.node_class # must be overridden by base classes (pseudo-abstract)
docutils.statemachine.State.nested_sm # is initialised in __init__
docutils.statemachine.State.nested_sm_kwargs # is initialised in __init__
docutils.statemachine.ViewList.__iter__ # doesn't exist at runtime, but the class is iterable due to __getitem__
+docutils.transforms.Transform.apply # method apply is not implemented
docutils.transforms.Transform.__getattr__
-docutils.transforms.Transformer.__getattr__
docutils.TransformSpec.unknown_reference_resolvers
-docutils.writers.manpage.Translator.__getattr__
+docutils.writers.latex2e.PreambleCmds... contents
+
+# Files that don't exist at runtime of stubtests, raises ImportError:
+docutils.parsers.commonmark_wrapper
+docutils.parsers.recommonmark_wrapper
+docutils.writers.odf_odt.pygmentsformatter # import `pygments` third-party library
+
+# `TYPE_CHECKING` variable is for internal use:
+docutils.TYPE_CHECKING
+docutils.core.TYPE_CHECKING
+docutils.examples.TYPE_CHECKING
+docutils.frontend.TYPE_CHECKING
+docutils.io.TYPE_CHECKING
+docutils.languages.TYPE_CHECKING
+docutils.nodes.TYPE_CHECKING
+docutils.parsers.TYPE_CHECKING
+docutils.parsers.rst.directives.TYPE_CHECKING
+docutils.parsers.rst.directives.misc.TYPE_CHECKING
+docutils.parsers.rst.languages.TYPE_CHECKING
+docutils.readers.TYPE_CHECKING
+docutils.utils.TYPE_CHECKING
+docutils.writers.TYPE_CHECKING
+docutils.writers._html_base.TYPE_CHECKING
diff --git a/python/helpers/typeshed/stubs/docutils/METADATA.toml b/python/helpers/typeshed/stubs/docutils/METADATA.toml
index 8116a59eb871..b556aa79aef4 100644
--- a/python/helpers/typeshed/stubs/docutils/METADATA.toml
+++ b/python/helpers/typeshed/stubs/docutils/METADATA.toml
@@ -1,6 +1,2 @@
-version = "0.21.*"
+version = "0.22.*"
upstream_repository = "https://sourceforge.net/p/docutils/code"
-partial_stub = true
-
-[tool.stubtest]
-ignore_missing_stub = true
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/__init__.pyi b/python/helpers/typeshed/stubs/docutils/docutils/__init__.pyi
index d275e01a543b..a19ba6ad24e6 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/__init__.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/__init__.pyi
@@ -1,10 +1,10 @@
-from typing import Any, ClassVar, NamedTuple
+from typing import Any, ClassVar, Final, NamedTuple
from typing_extensions import Self
from docutils.transforms import Transform
-__docformat__: str
-__version__: str
+__docformat__: Final = "reStructuredText"
+__version__: Final[str]
class _VersionInfo(NamedTuple):
major: int
@@ -19,8 +19,8 @@ class VersionInfo(_VersionInfo):
cls, major: int = 0, minor: int = 0, micro: int = 0, releaselevel: str = "final", serial: int = 0, release: bool = True
) -> Self: ...
-__version_info__: VersionInfo
-__version_details__: str
+__version_info__: Final[VersionInfo]
+__version_details__: Final[str]
class ApplicationError(Exception): ...
class DataError(ApplicationError): ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/__main__.pyi b/python/helpers/typeshed/stubs/docutils/docutils/__main__.pyi
new file mode 100644
index 000000000000..819b94bd9593
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/__main__.pyi
@@ -0,0 +1,11 @@
+from typing import ClassVar, Final
+
+import docutils
+
+__docformat__: Final = "reStructuredText"
+
+class CliSettingsSpec(docutils.SettingsSpec):
+ config_section: ClassVar[str]
+ config_section_dependencies: ClassVar[tuple[str, ...]]
+
+def main() -> None: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/core.pyi b/python/helpers/typeshed/stubs/docutils/docutils/core.pyi
index 7f356684391d..3532dd0d86d6 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/core.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/core.pyi
@@ -1,35 +1,41 @@
-from _typeshed import Incomplete
+from _typeshed import Incomplete, StrPath
+from typing import Final
+from typing_extensions import deprecated
from docutils import SettingsSpec
-from docutils.writers import _WriterParts
+from docutils.io import FileInput, Input, Output
+from docutils.parsers import Parser
+from docutils.readers import Reader
+from docutils.utils import SystemMessage
+from docutils.writers import Writer, _WriterParts
-__docformat__: str
+__docformat__: Final = "reStructuredText"
class Publisher:
- document: Incomplete
- reader: Incomplete
- parser: Incomplete
- writer: Incomplete
- source: Incomplete
+ document: Incomplete | None
+ reader: Reader[Incomplete]
+ parser: Parser
+ writer: Writer[Incomplete]
+ source: Input[Incomplete]
source_class: Incomplete
- destination: Incomplete
+ destination: Output | None
destination_class: Incomplete
- settings: Incomplete
+ settings: dict[str, Incomplete]
def __init__(
self,
- reader=None,
- parser=None,
- writer=None,
- source=None,
+ reader: Reader[Incomplete] | None = None,
+ parser: Parser | None = None,
+ writer: Writer[Incomplete] | None = None,
+ source: Input[Incomplete] | None = None,
source_class=...,
- destination=None,
+ destination: Output | None = None,
destination_class=...,
- settings=None,
+ settings: dict[str, Incomplete] | None = None,
) -> None: ...
- def set_reader(self, reader_name, parser, parser_name) -> None: ...
- def set_writer(self, writer_name) -> None: ...
- def set_components(self, reader_name, parser_name, writer_name) -> None: ...
- def setup_option_parser(self, usage=None, description=None, settings_spec=None, config_section=None, **defaults): ...
+ def set_reader(self, reader: str, parser: Parser | None = None, parser_name: str | None = None) -> None: ...
+ def set_writer(self, writer_name: str) -> None: ...
+ @deprecated("The `Publisher.set_components()` will be removed in Docutils 2.0.")
+ def set_components(self, reader_name: str, parser_name: str, writer_name: str) -> None: ...
def get_settings(
self,
usage: str | None = None,
@@ -40,122 +46,129 @@ class Publisher:
): ...
def process_programmatic_settings(self, settings_spec, settings_overrides, config_section) -> None: ...
def process_command_line(
- self, argv=None, usage=None, description=None, settings_spec=None, config_section=None, **defaults
+ self,
+ argv: list[str] | None = None,
+ usage=None,
+ description: str | None = None,
+ settings_spec=None,
+ config_section=None,
+ **defaults,
) -> None: ...
- def set_io(self, source_path=None, destination_path=None) -> None: ...
- def set_source(self, source=None, source_path=None) -> None: ...
- def set_destination(self, destination=None, destination_path=None) -> None: ...
+ def set_io(self, source_path: StrPath | None = None, destination_path: StrPath | None = None) -> None: ...
+ def set_source(self, source: str | None = None, source_path: StrPath | None = None) -> None: ...
+ def set_destination(self, destination=None, destination_path: StrPath | None = None) -> None: ...
def apply_transforms(self) -> None: ...
def publish(
self,
- argv=None,
- usage=None,
- description=None,
+ argv: list[str] | None = None,
+ usage: str | None = None,
+ description: str | None = None,
settings_spec=None,
settings_overrides=None,
- config_section=None,
+ config_section: str | None = None,
enable_exit_status: bool = False,
): ...
def debugging_dumps(self) -> None: ...
def prompt(self) -> None: ...
- def report_Exception(self, error) -> None: ...
- def report_SystemMessage(self, error) -> None: ...
- def report_UnicodeError(self, error) -> None: ...
+ def report_Exception(self, error: BaseException) -> None: ...
+ def report_SystemMessage(self, error: SystemMessage) -> None: ...
+ def report_UnicodeError(self, error: UnicodeEncodeError) -> None: ...
-default_usage: str
-default_description: str
+default_usage: Final[str]
+default_description: Final[str]
def publish_cmdline(
- reader=None,
- reader_name: str = "standalone",
- parser=None,
- parser_name: str = "restructuredtext",
- writer=None,
- writer_name: str = "pseudoxml",
+ reader: Reader[Incomplete] | None = None,
+ reader_name: str | None = None,
+ parser: Parser | None = None,
+ parser_name: str | None = None,
+ writer: Writer[Incomplete] | None = None,
+ writer_name: str | None = None,
settings=None,
settings_spec=None,
settings_overrides=None,
- config_section=None,
+ config_section: str | None = None,
enable_exit_status: bool = True,
- argv=None,
- usage=...,
- description=...,
+ argv: list[str] | None = None,
+ usage: str = "%prog [options] [ []]",
+ description: str = ...,
): ...
def publish_file(
source=None,
- source_path=None,
+ source_path: StrPath | None = None,
destination=None,
- destination_path=None,
+ destination_path: StrPath | None = None,
reader=None,
- reader_name: str = "standalone",
+ reader_name: str | None = None,
parser=None,
- parser_name: str = "restructuredtext",
+ parser_name: str | None = None,
writer=None,
- writer_name: str = "pseudoxml",
+ writer_name: str | None = None,
settings=None,
settings_spec=None,
settings_overrides=None,
- config_section=None,
+ config_section: str | None = None,
enable_exit_status: bool = False,
): ...
def publish_string(
source,
- source_path=None,
- destination_path=None,
+ source_path: StrPath | None = None,
+ destination_path: StrPath | None = None,
reader=None,
- reader_name: str = "standalone",
+ reader_name: str | None = None,
parser=None,
- parser_name: str = "restructuredtext",
+ parser_name: str | None = None,
writer=None,
- writer_name: str = "pseudoxml",
+ writer_name: str | None = None,
settings=None,
settings_spec=None,
settings_overrides=None,
- config_section=None,
+ config_section: str | None = None,
enable_exit_status: bool = False,
): ...
def publish_parts(
source,
- source_path=None,
+ source_path: StrPath | None = None,
source_class=...,
- destination_path=None,
+ destination_path: StrPath | None = None,
reader=None,
- reader_name: str = "standalone",
+ reader_name: str | None = None,
parser=None,
- parser_name: str = "restructuredtext",
+ parser_name: str | None = None,
writer=None,
- writer_name: str = "pseudoxml",
+ writer_name: str | None = None,
settings=None,
settings_spec=None,
- settings_overrides=None,
- config_section=None,
+ settings_overrides: dict[str, Incomplete] | None = None,
+ config_section: str | None = None,
enable_exit_status: bool = False,
) -> _WriterParts: ...
def publish_doctree(
source,
- source_path=None,
+ source_path: StrPath | None = None,
source_class=...,
reader=None,
- reader_name: str = "standalone",
+ reader_name: str | None = None,
parser=None,
- parser_name: str = "restructuredtext",
+ parser_name: str | None = None,
settings=None,
settings_spec=None,
settings_overrides=None,
- config_section=None,
+ config_section: str | None = None,
enable_exit_status: bool = False,
): ...
def publish_from_doctree(
document,
- destination_path=None,
+ destination_path: StrPath | None = None,
writer=None,
- writer_name: str = "pseudoxml",
+ writer_name: str | None = None,
settings=None,
settings_spec=None,
settings_overrides=None,
- config_section=None,
+ config_section: str | None = None,
enable_exit_status: bool = False,
): ...
+@deprecated("The `publish_cmdline_to_binary()` is deprecated by `publish_cmdline()` and will be removed in Docutils 0.24.")
def publish_cmdline_to_binary(
reader=None,
reader_name: str = "standalone",
@@ -166,34 +179,34 @@ def publish_cmdline_to_binary(
settings=None,
settings_spec=None,
settings_overrides=None,
- config_section=None,
+ config_section: str | None = None,
enable_exit_status: bool = True,
- argv=None,
- usage=...,
- description=...,
+ argv: list[str] | None = None,
+ usage: str = "%prog [options] [ []]",
+ description: str = ...,
destination=None,
destination_class=...,
): ...
def publish_programmatically(
- source_class,
+ source_class: type[FileInput],
source,
- source_path,
+ source_path: StrPath | None,
destination_class,
destination,
- destination_path,
+ destination_path: StrPath | None,
reader,
- reader_name,
+ reader_name: str,
parser,
- parser_name,
+ parser_name: str,
writer,
- writer_name,
+ writer_name: str,
settings,
settings_spec,
settings_overrides,
- config_section,
- enable_exit_status,
-): ...
-def rst2something(writer, documenttype, doc_path: str = "") -> None: ...
+ config_section: str,
+ enable_exit_status: bool,
+) -> tuple[str | bytes | None, Publisher]: ...
+def rst2something(writer: str, documenttype: str, doc_path: str = "") -> None: ...
def rst2html() -> None: ...
def rst2html4() -> None: ...
def rst2html5() -> None: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/examples.pyi b/python/helpers/typeshed/stubs/docutils/docutils/examples.pyi
index 5b0f74feb261..42dd8c152903 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/examples.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/examples.pyi
@@ -1 +1,44 @@
-def __getattr__(name: str): ... # incomplete module
+from _typeshed import Incomplete, StrPath
+from typing import Literal, overload
+from typing_extensions import TypeAlias
+
+from docutils.core import Publisher
+from docutils.nodes import document
+from docutils.writers import _WriterParts
+
+_HTMLHeaderLevel: TypeAlias = Literal[1, 2, 3, 4, 5, 6]
+
+def html_parts(
+ input_string: str | bytes,
+ source_path: StrPath | None = None,
+ destination_path: StrPath | None = None,
+ input_encoding: str = "unicode",
+ doctitle: bool = True,
+ initial_header_level: _HTMLHeaderLevel = 1,
+) -> _WriterParts: ...
+@overload
+def html_body(
+ input_string: str | bytes,
+ source_path: StrPath | None = None,
+ destination_path: StrPath | None = None,
+ input_encoding: str = "unicode",
+ output_encoding: Literal["unicode"] = "unicode",
+ doctitle: bool = True,
+ initial_header_level: _HTMLHeaderLevel = 1,
+) -> str: ...
+@overload
+def html_body(
+ input_string: str | bytes,
+ source_path: StrPath | None = None,
+ destination_path: StrPath | None = None,
+ input_encoding: str = "unicode",
+ output_encoding: str = "unicode",
+ doctitle: bool = True,
+ initial_header_level: _HTMLHeaderLevel = 1,
+) -> str | bytes: ...
+def internals(
+ source: str,
+ source_path: StrPath | None = None,
+ input_encoding: str = "unicode",
+ settings_overrides: dict[str, Incomplete] | None = None,
+) -> tuple[document | None, Publisher]: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/frontend.pyi b/python/helpers/typeshed/stubs/docutils/docutils/frontend.pyi
index 3b24a75a1442..45e7cd44c740 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/frontend.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/frontend.pyi
@@ -1,55 +1,168 @@
import optparse
-from _typeshed import Incomplete
-from collections.abc import Iterable, Mapping
+from _typeshed import Incomplete, StrPath
+from collections.abc import Iterable, Mapping, Sequence
from configparser import RawConfigParser
-from typing import Any, ClassVar
+from typing import Any, ClassVar, Final, Literal, Protocol, overload, type_check_only
+from typing_extensions import deprecated
from docutils import SettingsSpec
from docutils.utils import DependencyList
-__docformat__: str
+__docformat__: Final = "reStructuredText"
-def store_multiple(option, opt, value, parser, *args, **kwargs) -> None: ...
-def read_config_file(option, opt, value, parser) -> None: ...
-def validate_encoding(setting, value=None, option_parser=None, config_parser=None, config_section=None): ...
-def validate_encoding_error_handler(setting, value=None, option_parser=None, config_parser=None, config_section=None): ...
-def validate_encoding_and_error_handler(setting, value, option_parser, config_parser=None, config_section=None): ...
-def validate_boolean(setting, value=None, option_parser=None, config_parser=None, config_section=None) -> bool: ...
-def validate_nonnegative_int(setting, value=None, option_parser=None, config_parser=None, config_section=None) -> int: ...
-def validate_threshold(setting, value=None, option_parser=None, config_parser=None, config_section=None) -> int: ...
+@type_check_only
+class _OptionValidator(Protocol):
+ def __call__(
+ self,
+ setting: str,
+ value: str | None,
+ option_parser: OptionParser,
+ /,
+ config_parser: ConfigParser | None = None,
+ config_section: str | None = None,
+ ) -> Any: ...
+
+@deprecated("Deprecated and will be removed with the switch to from optparse to argparse.")
+def store_multiple(option: optparse.Option, opt: str, value, parser: OptionParser, *args: str, **kwargs) -> None: ...
+@deprecated("Deprecated and will be removed with the switch to from optparse to argparse.")
+def read_config_file(option: optparse.Option, opt: str, value, parser: OptionParser) -> None: ...
+def validate_encoding(
+ setting: str,
+ value: str | None = None,
+ option_parser: OptionParser | None = None,
+ config_parser: ConfigParser | None = None,
+ config_section: str | None = None,
+) -> str: ...
+def validate_encoding_error_handler(
+ setting: str,
+ value: str | None = None,
+ option_parser: OptionParser | None = None,
+ config_parser: ConfigParser | None = None,
+ config_section: str | None = None,
+) -> str: ...
+def validate_encoding_and_error_handler(
+ setting: str,
+ value: str | None = None,
+ option_parser: OptionParser | None = None,
+ config_parser: ConfigParser | None = None,
+ config_section: str | None = None,
+) -> str: ...
+def validate_boolean(
+ setting: str | bool,
+ value: str | None = None,
+ option_parser: OptionParser | None = None,
+ config_parser: ConfigParser | None = None,
+ config_section: str | None = None,
+) -> bool: ...
+def validate_ternary(
+ setting: str | bool,
+ value: str | None = None,
+ option_parser: OptionParser | None = None,
+ config_parser: ConfigParser | None = None,
+ config_section: str | None = None,
+) -> str | bool | None: ...
+def validate_nonnegative_int(
+ setting: str | int,
+ value: str | None = None,
+ option_parser: OptionParser | None = None,
+ config_parser: ConfigParser | None = None,
+ config_section: str | None = None,
+) -> int: ...
+def validate_threshold(
+ setting: str | int,
+ value: str | None = None,
+ option_parser: OptionParser | None = None,
+ config_parser: ConfigParser | None = None,
+ config_section: str | None = None,
+) -> int: ...
def validate_colon_separated_string_list(
- setting, value=None, option_parser=None, config_parser=None, config_section=None
+ setting: str | list[str],
+ value: str | None = None,
+ option_parser: OptionParser | None = None,
+ config_parser: ConfigParser | None = None,
+ config_section: str | None = None,
) -> list[str]: ...
def validate_comma_separated_list(
- setting, value=None, option_parser=None, config_parser=None, config_section=None
+ setting: str | list[str],
+ value: str | None = None,
+ option_parser: OptionParser | None = None,
+ config_parser: ConfigParser | None = None,
+ config_section: str | None = None,
) -> list[str]: ...
-def validate_url_trailing_slash(setting, value=None, option_parser=None, config_parser=None, config_section=None) -> str: ...
+def validate_math_output(
+ setting: str,
+ value: str | None = None,
+ option_parser: OptionParser | None = None,
+ config_parser: ConfigParser | None = None,
+ config_section: str | None = None,
+) -> tuple[()] | tuple[str, str]: ...
+def validate_url_trailing_slash(
+ setting: str,
+ value: str | None = None,
+ option_parser: OptionParser | None = None,
+ config_parser: ConfigParser | None = None,
+ config_section: str | None = None,
+) -> str: ...
def validate_dependency_file(
- setting, value=None, option_parser=None, config_parser=None, config_section=None
+ setting: str | None,
+ value: str | None = None,
+ option_parser: OptionParser | None = None,
+ config_parser: ConfigParser | None = None,
+ config_section: str | None = None,
) -> DependencyList: ...
-def validate_strip_class(setting, value=None, option_parser=None, config_parser=None, config_section=None): ...
+def validate_strip_class(
+ setting: str,
+ value: str | None = None,
+ option_parser: OptionParser | None = None,
+ config_parser: ConfigParser | None = None,
+ config_section: str | None = None,
+) -> list[str]: ...
def validate_smartquotes_locales(
- setting, value=None, option_parser=None, config_parser=None, config_section=None
-) -> list[tuple[str, str]]: ...
-def make_paths_absolute(pathdict, keys, base_path=None) -> None: ...
-def make_one_path_absolute(base_path, path) -> str: ...
+ setting: str | list[str | tuple[str, str]],
+ value: str | None = None,
+ option_parser: OptionParser | None = None,
+ config_parser: ConfigParser | None = None,
+ config_section: str | None = None,
+) -> list[tuple[str, Sequence[str]]]: ...
+def make_paths_absolute(
+ pathdict: dict[str, list[StrPath] | StrPath], keys: tuple[str], base_path: StrPath | None = None
+) -> None: ...
+@deprecated("The `frontend.make_one_path_absolute` will be removed in Docutils 2.0 or later.")
+def make_one_path_absolute(base_path: StrPath, path: StrPath) -> str: ...
def filter_settings_spec(settings_spec, *exclude, **replace) -> tuple[Any, ...]: ...
-
+@deprecated("The `frontend.Values` class will be removed in Docutils 2.0 or later.")
class Values(optparse.Values):
- def update(self, other_dict, option_parser) -> None: ...
+ record_dependencies: DependencyList
+ def __init__(self, defaults: dict[str, Any] | None = None) -> None: ...
+ def update(self, other_dict: Values | Mapping[str, Incomplete], option_parser: OptionParser) -> None: ...
def copy(self) -> Values: ...
+ def setdefault(self, name: str, default): ...
-class Option(optparse.Option): ...
+@deprecated("The `frontend.Option` class will be removed in Docutils 2.0 or later.")
+class Option(optparse.Option):
+ ATTRS: list[str]
+ validator: _OptionValidator
+ overrides: str | None
+ def __init__(self, *args: str | None, **kwargs) -> None: ...
+@deprecated(
+ "The `frontend.OptionParser` class will be replaced by a subclass of `argparse.ArgumentParser` in Docutils 2.0 or later."
+)
class OptionParser(optparse.OptionParser, SettingsSpec):
standard_config_files: ClassVar[list[str]]
- threshold_choices: ClassVar[list[str]]
+ threshold_choices: ClassVar[tuple[str, ...]]
thresholds: ClassVar[dict[str, int]]
booleans: ClassVar[dict[str, bool]]
default_error_encoding: ClassVar[str]
default_error_encoding_error_handler: ClassVar[str]
config_section: ClassVar[str]
version_template: ClassVar[str]
+ details: str
+ lists: dict[str, Literal[True]]
+ config_files: list[str]
+ relative_path_settings: ClassVar[tuple[str, ...]]
+ version: str
+ components: tuple[SettingsSpec, ...]
def __init__(
self,
components: Iterable[SettingsSpec | type[SettingsSpec]] = (),
@@ -58,11 +171,29 @@ class OptionParser(optparse.OptionParser, SettingsSpec):
*args,
**kwargs,
) -> None: ...
- def __getattr__(self, name: str) -> Incomplete: ...
+ def populate_from_components(self, components: Iterable[SettingsSpec]) -> None: ...
+ @classmethod
+ def get_standard_config_files(cls) -> Sequence[StrPath]: ...
+ def get_standard_config_settings(self) -> Values: ...
+ def get_config_file_settings(self, config_file: str) -> dict[str, Incomplete]: ...
+ def check_values(self, values: Values, args: list[str]) -> Values: ... # type: ignore[override]
+ def check_args(self, args: list[str]) -> tuple[str | None, str | None]: ...
+ def get_default_values(self) -> Values: ...
+ def get_option_by_dest(self, dest: str) -> Option: ...
class ConfigParser(RawConfigParser):
- def __getattr__(self, name: str) -> Incomplete: ...
+ old_settings: ClassVar[dict[str, tuple[str, str]]]
+ old_warning: ClassVar[str]
+ not_utf8_error: ClassVar[str]
+ @overload # type: ignore[override]
+ def read(self, filenames: str | Sequence[str]) -> list[str]: ...
+ @overload
+ @deprecated("The `option_parser` parameter is deprecated and will be removed in Docutils 0.24.")
+ def read(self, filenames: str | Sequence[str], option_parser: OptionParser | None) -> list[str]: ...
+ def handle_old_config(self, filename: str) -> None: ...
+ def validate_settings(self, filename: str, option_parser: OptionParser) -> None: ...
+ def optionxform(self, optionstr: str) -> str: ...
-class ConfigDeprecationWarning(DeprecationWarning): ...
+class ConfigDeprecationWarning(FutureWarning): ...
-def get_default_settings(*components) -> Values: ...
+def get_default_settings(*components: SettingsSpec) -> Values: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/io.pyi b/python/helpers/typeshed/stubs/docutils/docutils/io.pyi
index 532c8bec15e6..34fad7790bb4 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/io.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/io.pyi
@@ -8,16 +8,17 @@ from _typeshed import (
Unused,
)
from re import Pattern
-from typing import IO, Any, ClassVar, Generic, Literal, TypeVar
+from typing import IO, Any, ClassVar, Final, Generic, Literal, TextIO, TypeVar
+from typing_extensions import deprecated
from docutils import TransformSpec, nodes
-__docformat__: str
+__docformat__: Final = "reStructuredText"
class InputError(OSError): ...
class OutputError(OSError): ...
-def check_encoding(stream: Any, encoding: str) -> bool | None: ...
+def check_encoding(stream: TextIO, encoding: str) -> bool | None: ...
def error_string(err: BaseException) -> str: ...
_S = TypeVar("_S")
@@ -31,18 +32,27 @@ class Input(TransformSpec, Generic[_S]):
source_path: str | None
successful_encoding: str | None = None
def __init__(
- self, source: _S | None = None, source_path: str | None = None, encoding: str | None = None, error_handler: str = "strict"
+ self,
+ source: _S | None = None,
+ source_path: str | None = None,
+ encoding: str | None = "utf-8",
+ error_handler: str = "strict",
) -> None: ...
def read(self) -> str: ...
def decode(self, data: str | bytes | bytearray) -> str: ...
coding_slug: ClassVar[Pattern[bytes]]
byte_order_marks: ClassVar[tuple[tuple[bytes, str], ...]]
+ @deprecated("Deprecated and will be removed in Docutils 1.0.")
def determine_encoding_from_data(self, data: str | bytes | bytearray) -> str | None: ...
def isatty(self) -> bool: ...
class Output(TransformSpec):
component_type: ClassVar[str]
default_destination_path: ClassVar[str | None]
+ encoding: Incomplete
+ error_handler: Incomplete
+ destination: Incomplete
+ destination_path: Incomplete
def __init__(
self, destination=None, destination_path=None, encoding: str | None = None, error_handler: str = "strict"
) -> None: ...
@@ -50,6 +60,10 @@ class Output(TransformSpec):
def encode(self, data: str) -> Any: ... # returns bytes or str
class ErrorOutput:
+ destination: Incomplete
+ encoding: Incomplete
+ encoding_errors: Incomplete
+ decoding_errors: Incomplete
def __init__(
self,
destination: str | SupportsWrite[str] | SupportsWrite[bytes] | Literal[False] | None = None,
@@ -62,11 +76,12 @@ class ErrorOutput:
def isatty(self) -> bool: ...
class FileInput(Input[IO[str]]):
+ autoclose: bool
def __init__(
self,
source=None,
source_path=None,
- encoding: str | None = None,
+ encoding: str | None = "utf-8",
error_handler: str = "strict",
autoclose: bool = True,
mode: OpenTextModeReading | OpenBinaryModeReading = "r",
@@ -76,17 +91,37 @@ class FileInput(Input[IO[str]]):
def close(self) -> None: ...
class FileOutput(Output):
+ default_destination_path: ClassVar[str]
mode: ClassVar[OpenTextModeWriting | OpenBinaryModeWriting]
- def __getattr__(self, name: str) -> Incomplete: ...
+ opened: bool
+ autoclose: Incomplete
+ destination: Incomplete
+ destination_path: Incomplete
+ def __init__(
+ self,
+ destination=None,
+ destination_path=None,
+ encoding=None,
+ error_handler: str = "strict",
+ autoclose: bool = True,
+ handle_io_errors=None,
+ mode=None,
+ ) -> None: ...
+ def open(self) -> None: ...
+ def write(self, data): ...
+ def close(self) -> None: ...
+@deprecated("The `BinaryFileOutput` is deprecated by `FileOutput` and will be removed in Docutils 0.24.")
class BinaryFileOutput(FileOutput): ...
class StringInput(Input[str]):
default_source_path: ClassVar[str]
+ def read(self): ...
class StringOutput(Output):
default_destination_path: ClassVar[str]
destination: str | bytes # only defined after call to write()
+ def write(self, data): ...
class NullInput(Input[Any]):
default_source_path: ClassVar[str]
@@ -98,3 +133,4 @@ class NullOutput(Output):
class DocTreeInput(Input[nodes.document]):
default_source_path: ClassVar[str]
+ def read(self): ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/languages/__init__.pyi b/python/helpers/typeshed/stubs/docutils/docutils/languages/__init__.pyi
index d04730262182..415e42286a17 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/languages/__init__.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/languages/__init__.pyi
@@ -1,4 +1,5 @@
from typing import ClassVar, Final, Protocol, type_check_only
+from typing_extensions import Self
from docutils.utils import Reporter
@@ -19,5 +20,6 @@ class LanguageImporter:
def import_from_packages(self, name: str, reporter: Reporter | None = None) -> _LanguageModule: ...
def check_content(self, module: _LanguageModule) -> None: ...
def __call__(self, language_code: str, reporter: Reporter | None = None) -> _LanguageModule: ...
+ def __class_getitem__(cls, name) -> type[Self]: ...
get_language: LanguageImporter
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/languages/eo.pyi b/python/helpers/typeshed/stubs/docutils/docutils/languages/eo.pyi
index 67f306e26583..1bc1c23e214b 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/languages/eo.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/languages/eo.pyi
@@ -1,6 +1,6 @@
-from _typeshed import Incomplete
+from typing import Final, Literal
-__docformat__: str
-labels: Incomplete
-bibliographic_fields: Incomplete
-author_separators: Incomplete
+__docformat__: Final = "reStructuredText"
+labels: dict[str, str]
+bibliographic_fields: dict[str, str]
+author_separators: list[Literal[";", ","]]
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/nodes.pyi b/python/helpers/typeshed/stubs/docutils/docutils/nodes.pyi
index 2b47f4b185bc..d3607e94a531 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/nodes.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/nodes.pyi
@@ -1,20 +1,28 @@
import sys
import xml.dom.minidom
+from _typeshed import Incomplete
from abc import abstractmethod
from collections import Counter
from collections.abc import Callable, Generator, Iterable, Iterator, Mapping, Sequence
-from typing import Any, ClassVar, Literal, Protocol, SupportsIndex, TypeVar, overload
-from typing_extensions import Self, TypeAlias
+from typing import Any, ClassVar, Final, Literal, Protocol, SupportsIndex, TypeVar, overload, type_check_only
+from typing_extensions import Self, TypeAlias, deprecated
from docutils.frontend import Values
from docutils.transforms import Transform, Transformer
from docutils.utils import Reporter
_N = TypeVar("_N", bound=Node)
+_ContentModelCategory: TypeAlias = type[Element] | tuple[type[Element], ...]
+_ContentModelQuantifier: TypeAlias = Literal[".", "?", "+", "*"]
+_ContentModelItem: TypeAlias = tuple[_ContentModelCategory, _ContentModelQuantifier]
+_ContentModelTuple: TypeAlias = tuple[_ContentModelItem, ...]
+@type_check_only
class _DomModule(Protocol):
Document: type[xml.dom.minidom.Document]
+__docformat__: Final = "reStructuredText"
+
# Functional Node Base Classes
class Node:
@@ -26,9 +34,14 @@ class Node:
parent: Element | Any
source: str | None
line: int | None
- document: document | None
+ @property
+ def document(self) -> document | None: ...
+ @document.setter
+ def document(self, value: document) -> None: ...
def __bool__(self) -> Literal[True]: ...
- def asdom(self, dom: _DomModule | None = None) -> xml.dom.minidom.Element: ...
+ def asdom(
+ self, dom: _DomModule | None = None
+ ) -> xml.dom.minidom.Document | xml.dom.minidom.Element | xml.dom.minidom.Text: ...
# While docutils documents the Node class to be abstract it does not
# actually use the ABCMeta metaclass. We still set @abstractmethod here
# (although it's not used in the docutils implementation) because it
@@ -47,7 +60,7 @@ class Node:
@overload
def findall(
self, condition: type[_N], include_self: bool = True, descend: bool = True, siblings: bool = False, ascend: bool = False
- ) -> Generator[_N, None, None]: ...
+ ) -> Generator[_N]: ...
@overload
def findall(
self,
@@ -56,12 +69,14 @@ class Node:
descend: bool = True,
siblings: bool = False,
ascend: bool = False,
- ) -> Generator[Node, None, None]: ...
+ ) -> Generator[Node]: ...
@overload
+ @deprecated("The `nodes.Node.traverse()` is deprecated. Use `Node.findall()` instead.")
def traverse(
self, condition: type[_N], include_self: bool = True, descend: bool = True, siblings: bool = False, ascend: bool = False
) -> list[_N]: ...
@overload
+ @deprecated("The `nodes.Node.traverse()` is deprecated. Use `Node.findall()` instead.")
def traverse(
self,
condition: Callable[[Node], bool] | None = None,
@@ -83,6 +98,8 @@ class Node:
siblings: bool = False,
ascend: bool = False,
) -> Node: ...
+ def validate(self, recursive: bool = True) -> None: ...
+ def validate_position(self) -> None: ...
# Left out
# - def ensure_str (deprecated)
@@ -108,9 +125,12 @@ _T = TypeVar("_T")
class Element(Node):
local_attributes: ClassVar[Sequence[str]]
+ valid_attributes: ClassVar[Sequence[str]]
+ common_attributes: ClassVar[Sequence[str]]
basic_attributes: ClassVar[Sequence[str]]
list_attributes: ClassVar[Sequence[str]]
known_attributes: ClassVar[Sequence[str]]
+ content_model: ClassVar[_ContentModelTuple]
tagname: str
child_text_separator: ClassVar[str]
attributes: dict[str, Any]
@@ -161,6 +181,7 @@ class Element(Node):
def remove(self, item: Node) -> None: ...
def index(self, item: Node, start: int = 0, stop: int = sys.maxsize) -> int: ...
def previous_sibling(self) -> Node | None: ...
+ def section_hierarchy(self) -> list[section]: ...
def is_not_default(self, key: str) -> bool: ...
def update_basic_atts(self, dict_: Mapping[str, Any] | Node) -> None: ...
def append_attr_list(self, attr: str, values: Iterable[Any]) -> None: ...
@@ -199,12 +220,15 @@ class Element(Node):
def pformat(self, indent: str = " ", level: int = 0) -> str: ...
def copy(self) -> Self: ...
def deepcopy(self) -> Self: ...
- def set_class(self, name: str) -> None: ...
def note_referenced_by(self, name: str | None = None, id: str | None = None) -> None: ...
@classmethod
def is_not_list_attribute(cls, attr: str) -> bool: ...
@classmethod
def is_not_known_attribute(cls, attr: str) -> bool: ...
+ def validate_attributes(self) -> None: ...
+ def validate_content(
+ self, model: _ContentModelTuple | None = None, elements: Sequence[Incomplete] | None = None
+ ) -> list[Incomplete]: ...
# '__iter__' is added as workaround, since mypy doesn't support classes that are iterable via '__getitem__'
# see https://github.com/python/typeshed/pull/10099#issuecomment-1528789395
@@ -214,6 +238,7 @@ class TextElement(Element):
def __init__(self, rawsource: str = "", text: str = "", *children: Node, **attributes) -> None: ...
class FixedTextElement(TextElement): ...
+class PureTextElement(TextElement): ...
# Mixins
@@ -221,6 +246,8 @@ class Resolvable:
resolved: int
class BackLinkable:
+ list_attributes: ClassVar[Sequence[str]]
+ valid_attributes: ClassVar[Sequence[str]]
def add_backref(self, refid: str) -> None: ...
# Element Categories
@@ -229,12 +256,19 @@ class Root: ...
class Titular: ...
class PreBibliographic: ...
class Bibliographic: ...
-class Decorative(PreBibliographic): ...
+
+class Decorative(PreBibliographic):
+ content_model: ClassVar[_ContentModelTuple]
+
class Structural: ...
+class SubStructural: ...
class Body: ...
class General(Body): ...
class Sequential(Body): ...
-class Admonition(Body): ...
+
+class Admonition(Body):
+ content_model: ClassVar[_ContentModelTuple]
+
class Special(Body): ...
class Invisible(PreBibliographic): ...
class Part: ...
@@ -284,7 +318,7 @@ class document(Root, Structural, Element):
def __init__(self, settings: Values, reporter: Reporter, *args: Node, **kwargs: Any) -> None: ...
def asdom(self, dom: Any | None = None) -> Any: ...
def set_id(self, node: Element, msgnode: Element | None = None, suggested_prefix: str = "") -> str: ...
- def set_name_id_map(self, node: Element, id: str, msgnode: Element | None = None, explicit: bool | None = None) -> None: ...
+ def set_name_id_map(self, node: Element, id: str, msgnode: Element | None = None, explicit: bool = False) -> None: ...
def set_duplicate_name_id(self, node: Element, id: str, name: str, msgnode: Element, explicit: bool) -> None: ...
def has_name(self, name: str) -> bool: ...
def note_implicit_target(self, target: Element, msgnode: Element | None = None) -> None: ...
@@ -406,7 +440,10 @@ class caption(Part, TextElement): ...
class legend(Part, Element): ...
class table(General, Element): ...
class tgroup(Part, Element): ...
-class colspec(Part, Element): ...
+
+class colspec(Part, Element):
+ def propwidth(self) -> float: ...
+
class thead(Part, Element): ...
class tbody(Part, Element): ...
class row(Part, Element): ...
@@ -414,6 +451,7 @@ class entry(Part, Element): ...
class system_message(Special, BackLinkable, PreBibliographic, Element):
def __init__(self, message: str | None = None, *children: Node, **attributes) -> None: ...
+ def astext(self) -> str: ...
class pending(Special, Invisible, Element):
transform: type[Transform]
@@ -676,6 +714,9 @@ class TreeCopyVisitor(GenericNodeVisitor):
parent: list[Node]
def get_tree_copy(self) -> Node: ...
+class ValidationError(ValueError):
+ def __init__(self, msg: str, problematic_element: Element | None = None) -> None: ...
+
class TreePruningException(Exception): ...
class SkipChildren(TreePruningException): ...
class SkipSiblings(TreePruningException): ...
@@ -689,4 +730,17 @@ def dupname(node: Node, name: str) -> None: ...
def fully_normalize_name(name: str) -> str: ...
def whitespace_normalize_name(name: str) -> str: ...
def serial_escape(value: str) -> str: ...
+def split_name_list(s: str) -> list[str]: ...
def pseudo_quoteattr(value: str) -> str: ...
+def parse_measure(measure: str, unit_pattern: str = "[a-zA-Zµ]*|%?") -> tuple[float, str]: ...
+def create_keyword_validator(*keywords: str) -> Callable[[str], str]: ...
+def validate_identifier(value: str) -> str: ...
+def validate_identifier_list(value: str | list[str]) -> list[str]: ...
+def validate_measure(measure: str) -> str: ...
+def validate_colwidth(measure: str | float) -> float: ...
+def validate_NMTOKEN(value: str) -> str: ...
+def validate_NMTOKENS(value: str | list[str]) -> list[str]: ...
+def validate_refname_list(value: str | list[str]) -> list[str]: ...
+def validate_yesorno(value: str | int | bool) -> bool: ...
+
+ATTRIBUTE_VALIDATORS: dict[str, Callable[[str], Any]]
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/parsers/__init__.pyi b/python/helpers/typeshed/stubs/docutils/docutils/parsers/__init__.pyi
index 1c301b050641..d15966c81088 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/parsers/__init__.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/parsers/__init__.pyi
@@ -14,6 +14,6 @@ class Parser(Component):
def setup_parse(self, inputstring: str, document: _Document) -> None: ...
def finish_parse(self) -> None: ...
-_parser_aliases: dict[str, str]
+PARSER_ALIASES: Final[dict[str, str]]
def get_parser_class(parser_name: str) -> type[Parser]: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/parsers/commonmark_wrapper.pyi b/python/helpers/typeshed/stubs/docutils/docutils/parsers/commonmark_wrapper.pyi
new file mode 100644
index 000000000000..c46e90c800b7
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/parsers/commonmark_wrapper.pyi
@@ -0,0 +1,10 @@
+from typing import Literal
+from typing_extensions import TypeAlias
+
+from docutils import parsers
+
+_ParserName: TypeAlias = Literal["pycmark", "myst", "recommonmark"]
+
+commonmark_parser_names: tuple[_ParserName, ...]
+Parser: type[parsers.Parser] # if Parser is None or parser_name is empty string, user cannot import current module
+parser_name: _ParserName
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/parsers/docutils_xml.pyi b/python/helpers/typeshed/stubs/docutils/docutils/parsers/docutils_xml.pyi
new file mode 100644
index 000000000000..d8351b0c7ea8
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/parsers/docutils_xml.pyi
@@ -0,0 +1,16 @@
+import xml.etree.ElementTree as ET
+from typing import ClassVar, Final
+
+from docutils import nodes, parsers
+
+__docformat__: Final = "reStructuredText"
+
+class Parser(parsers.Parser):
+ config_section_dependencies: ClassVar[tuple[str, ...]]
+ settings_default_overrides: ClassVar[dict[str, bool]]
+
+class Unknown(nodes.Special, nodes.Inline, nodes.Element): ...
+
+def parse_element(inputstring: str, document: nodes.document | None = None) -> nodes.Element: ...
+def element2node(element: ET.Element | None, document: nodes.document | None = None, unindent: bool = True) -> nodes.Element: ...
+def append_text(node: nodes.Element, text: str | None, unindent: bool | None) -> None: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/parsers/null.pyi b/python/helpers/typeshed/stubs/docutils/docutils/parsers/null.pyi
index bd88e09cdfab..ff81ca28c7fd 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/parsers/null.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/parsers/null.pyi
@@ -1,7 +1,9 @@
-from typing import ClassVar
+from typing import ClassVar, Final
from docutils import parsers
+__docformat__: Final = "reStructuredText"
+
class Parser(parsers.Parser):
supported: ClassVar[tuple[str, ...]]
config_section_dependencies: ClassVar[tuple[str, ...]]
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/parsers/recommonmark_wrapper.pyi b/python/helpers/typeshed/stubs/docutils/docutils/parsers/recommonmark_wrapper.pyi
index 93a20f579660..c085b367af92 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/parsers/recommonmark_wrapper.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/parsers/recommonmark_wrapper.pyi
@@ -1,15 +1,18 @@
from types import ModuleType
from typing import ClassVar
+from typing_extensions import deprecated
from docutils import nodes
from docutils.transforms import Transform
+@deprecated("The `recommonmark` package is unmaintained and deprecated; will be removed in Docutils 1.0.")
class pending_xref(nodes.Inline, nodes.Element): ...
sphinx: ModuleType
+@deprecated("The `recommonmark` package is unmaintained and deprecated; will be removed in Docutils 1.0.")
def is_literal(node: nodes.Node) -> bool: ...
-
+@deprecated("The `recommonmark` package is unmaintained and deprecated; will be removed in Docutils 1.0.")
class _CommonMarkParser:
default_config: ClassVar[dict[str, None]]
def __init__(self) -> None: ...
@@ -40,6 +43,7 @@ class _CommonMarkParser:
def add_section(self, section, level): ...
def is_section_level(self, level, section): ...
+@deprecated("The `recommonmark` package is unmaintained and deprecated; will be removed in Docutils 1.0.")
class Parser(_CommonMarkParser):
supported: ClassVar[tuple[str, ...]]
config_section: ClassVar[str]
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/parsers/rst/directives/__init__.pyi b/python/helpers/typeshed/stubs/docutils/docutils/parsers/rst/directives/__init__.pyi
index 70c4c07af847..501bb87ddaf9 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/parsers/rst/directives/__init__.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/parsers/rst/directives/__init__.pyi
@@ -21,6 +21,7 @@ def uri(argument: str) -> str: ...
def nonnegative_int(argument: str) -> int: ...
def percentage(argument: str) -> int: ...
+CSS3_LENGTH_UNITS: Final[tuple[str, ...]]
length_units: Final[list[str]]
def get_measure(argument: str, units: Iterable[str]) -> str: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/parsers/rst/directives/misc.pyi b/python/helpers/typeshed/stubs/docutils/docutils/parsers/rst/directives/misc.pyi
index bde9cf1bb97c..46b89b555d45 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/parsers/rst/directives/misc.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/parsers/rst/directives/misc.pyi
@@ -1,14 +1,23 @@
+from _typeshed import StrPath
from pathlib import Path
from re import Match, Pattern
from typing import ClassVar, Final
+from docutils import nodes
from docutils.parsers.rst import Directive
from docutils.parsers.rst.states import SpecializedBody
__docformat__: Final = "reStructuredText"
+def adapt_path(path: str, source: StrPath = "", root_prefix: StrPath = "") -> str: ...
+
class Include(Directive):
standard_include_path: Path
+ def read_file(self, path: StrPath) -> str: ...
+ def as_literal_block(self, text: str) -> list[nodes.literal_block]: ...
+ def as_code_block(self, text: str) -> list[nodes.literal_block]: ...
+ def custom_parse(self, text: str) -> list[nodes.Node]: ...
+ def insert_into_input_lines(self, text: str) -> None: ...
class Raw(Directive): ...
class Replace(Directive): ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/parsers/rst/directives/tables.pyi b/python/helpers/typeshed/stubs/docutils/docutils/parsers/rst/directives/tables.pyi
index ebde406d577e..56d14a5a6ac6 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/parsers/rst/directives/tables.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/parsers/rst/directives/tables.pyi
@@ -1,8 +1,10 @@
import csv
from _typeshed import Incomplete
-from collections.abc import Callable
+from collections.abc import Callable, Sequence
from typing import ClassVar, Final
+from typing_extensions import deprecated
+from docutils import nodes
from docutils.parsers.rst import Directive
__docformat__: Final = "reStructuredText"
@@ -20,7 +22,7 @@ class Table(Directive):
def extend_short_rows_with_empty_cells(self, columns, parts) -> None: ...
class RSTTable(Table):
- def run(self): ...
+ def run(self) -> Sequence[nodes.table | nodes.system_message]: ...
class CSVTable(Table):
class DocutilsDialect(csv.Dialect):
@@ -34,6 +36,7 @@ class CSVTable(Table):
escapechar: Incomplete
def __init__(self, options) -> None: ...
+ @deprecated("Deprecated and will be removed in Docutils 1.0.")
class HeaderDialect(csv.Dialect):
delimiter: str
quotechar: str
@@ -46,17 +49,14 @@ class CSVTable(Table):
def __init__(self) -> None: ...
@staticmethod
+ @deprecated("Deprecated and not required with Python 3; will be removed in Docutils 0.22.")
def check_requirements() -> None: ...
def process_header_option(self): ...
- def run(self): ...
+ def run(self) -> Sequence[nodes.table | nodes.system_message]: ...
def get_csv_data(self): ...
- @staticmethod
- def decode_from_csv(s): ...
- @staticmethod
- def encode_for_csv(s): ...
def parse_csv_data_into_rows(self, csv_data, dialect, source): ...
class ListTable(Table):
- def run(self): ...
+ def run(self) -> Sequence[nodes.table | nodes.system_message]: ...
def check_list_content(self, node): ...
- def build_table_from_list(self, table_data, col_widths, header_rows, stub_columns): ...
+ def build_table_from_list(self, table_data, col_widths, header_rows, stub_columns) -> nodes.table: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/parsers/rst/roles.pyi b/python/helpers/typeshed/stubs/docutils/docutils/parsers/rst/roles.pyi
index eb1b39446de0..eb238c6f4905 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/parsers/rst/roles.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/parsers/rst/roles.pyi
@@ -1,6 +1,6 @@
from collections.abc import Callable, Mapping, Sequence
from typing import Any, Final
-from typing_extensions import TypeAlias
+from typing_extensions import TypeAlias, deprecated
import docutils.parsers.rst.states
from docutils import nodes
@@ -128,5 +128,8 @@ def unimplemented_role(
options: Mapping[str, Any] | None = None,
content: Sequence[str] | None = None,
) -> tuple[list[Node], list[system_message]]: ...
+@deprecated("Deprecated and will be removed in Docutils 2.0, Use `roles.normalize_options()` instead.")
def set_classes(options: dict[str, str]) -> None: ...
+@deprecated("Deprecated and will be removed in Docutils 2.0, Use `roles.normalize_options()` instead.")
def normalized_role_options(options: Mapping[str, Any] | None) -> dict[str, Any]: ...
+def normalize_options(options: Mapping[str, Any] | None) -> dict[str, Any]: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/parsers/rst/states.pyi b/python/helpers/typeshed/stubs/docutils/docutils/parsers/rst/states.pyi
index 8e657cd3cdad..5f9b79d28aaa 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/parsers/rst/states.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/parsers/rst/states.pyi
@@ -1,11 +1,12 @@
from _typeshed import Incomplete
from collections.abc import Callable, Iterable, Sequence
from re import Match, Pattern
-from types import ModuleType
+from types import ModuleType, SimpleNamespace as Struct
from typing import Any, ClassVar, Final, NoReturn
from typing_extensions import TypeAlias
from docutils import ApplicationError, DataError, nodes
+from docutils.nodes import Node, system_message
from docutils.parsers.rst.languages import _RstLanguageModule
from docutils.statemachine import StateMachine, StateMachineWS, StateWS, StringList
from docutils.utils import Reporter
@@ -18,9 +19,6 @@ class InterpretedRoleNotImplementedError(DataError): ...
class ParserError(ApplicationError): ...
class MarkupMismatch(Exception): ...
-class Struct:
- def __init__(self, **keywordargs) -> None: ...
-
class RSTStateMachine(StateMachineWS[list[str]]):
language: _RstLanguageModule
match_titles: bool
@@ -88,10 +86,10 @@ class RSTState(StateWS[list[str]]):
def title_inconsistent(self, sourcetext: str, lineno: int): ...
def new_subsection(self, title: str, lineno: int, messages) -> None: ...
def paragraph(self, lines: Iterable[str], lineno: int): ...
- def inline_text(self, text: str, lineno: int): ...
+ def inline_text(self, text: str, lineno: int) -> tuple[list[Node], list[system_message]]: ...
def unindent_warning(self, node_name: str): ...
-def build_regexp(definition, compile: bool = True): ...
+def build_regexp(definition, compile_patterns: bool | None = True): ...
_BasicDefinition: TypeAlias = tuple[str, str, str, list[Pattern[str]]]
_DefinitionParts: TypeAlias = tuple[str, str, str, list[Pattern[str] | _BasicDefinition]]
@@ -185,6 +183,8 @@ class Body(RSTState):
pats: Incomplete
patterns: ClassVar[dict[str, str | Pattern[str]]]
initial_transitions: ClassVar[tuple[str, ...]]
+ sequence: str
+ format: str
def indent(self, match, context, next_state): ...
def block_quote(self, indented, line_offset): ...
attribution_pattern: Incomplete
@@ -216,7 +216,7 @@ class Body(RSTState):
def isolate_grid_table(self): ...
def isolate_simple_table(self): ...
def malformed_table(self, block, detail: str = "", offset: int = 0): ...
- def build_table(self, tabledata, tableline, stub_columns: int = 0, widths=None): ...
+ def build_table(self, tabledata, tableline, stub_columns: int = 0, widths=None) -> nodes.table: ...
def build_table_row(self, rowdata, tableline): ...
explicit: Incomplete
def footnote(self, match): ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/readers/__init__.pyi b/python/helpers/typeshed/stubs/docutils/docutils/readers/__init__.pyi
index 24777ae01106..d29e4aa717d3 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/readers/__init__.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/readers/__init__.pyi
@@ -1,4 +1,4 @@
-from typing import Any, ClassVar, Generic, TypeVar
+from typing import Any, ClassVar, Final, Generic, TypeVar
from docutils import Component, nodes
from docutils.frontend import Values
@@ -8,6 +8,8 @@ from docutils.transforms import Transform
_S = TypeVar("_S")
+__docformat__: Final = "reStructuredText"
+
class Reader(Component, Generic[_S]):
component_type: ClassVar[str]
config_section: ClassVar[str]
@@ -15,8 +17,9 @@ class Reader(Component, Generic[_S]):
def __init__(self, parser: Parser | None = None, parser_name: str | None = None) -> None: ...
parser: Parser | None
source: Input[_S] | None
- input: str | Any | None
+ input: str | None
def set_parser(self, parser_name: str) -> None: ...
+ settings: Values
def read(self, source: Input[_S], parser: Parser, settings: Values) -> nodes.document: ...
document: nodes.document
def parse(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/readers/doctree.pyi b/python/helpers/typeshed/stubs/docutils/docutils/readers/doctree.pyi
index 49c796cc7934..27be5d0e1f0e 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/readers/doctree.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/readers/doctree.pyi
@@ -1,7 +1,10 @@
-from typing import TypeVar
+from typing import ClassVar, Final, TypeVar
from docutils import readers
_S = TypeVar("_S", bound=str | bytes)
-class Reader(readers.ReReader[_S]): ...
+__docformat__: Final = "reStructuredText"
+
+class Reader(readers.ReReader[_S]):
+ config_section_dependencies: ClassVar[tuple[str, ...]]
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/readers/pep.pyi b/python/helpers/typeshed/stubs/docutils/docutils/readers/pep.pyi
index 5b0f74feb261..ef0247369aad 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/readers/pep.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/readers/pep.pyi
@@ -1 +1,12 @@
-def __getattr__(name: str): ... # incomplete module
+from typing import ClassVar, Final, TypeVar
+
+from docutils.parsers.rst import states
+from docutils.readers import standalone
+
+__docformat__: Final = "reStructuredText"
+
+_S = TypeVar("_S", bound=str | bytes)
+
+class Reader(standalone.Reader[_S]):
+ settings_default_overrides: ClassVar[dict[str, int]]
+ inliner_class: ClassVar[type[states.Inliner]]
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/readers/standalone.pyi b/python/helpers/typeshed/stubs/docutils/docutils/readers/standalone.pyi
index 5b0f74feb261..6e7319e2c5d1 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/readers/standalone.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/readers/standalone.pyi
@@ -1 +1,11 @@
-def __getattr__(name: str): ... # incomplete module
+from typing import ClassVar, Final, TypeVar
+
+from docutils import nodes, readers
+
+__docformat__: Final = "reStructuredText"
+
+_S = TypeVar("_S", bound=str | bytes)
+
+class Reader(readers.Reader[_S]):
+ document: nodes.document | None # type: ignore[assignment]
+ config_section_dependencies: ClassVar[tuple[str, ...]]
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/statemachine.pyi b/python/helpers/typeshed/stubs/docutils/docutils/statemachine.pyi
index 1653c2710516..353b27734915 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/statemachine.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/statemachine.pyi
@@ -1,7 +1,7 @@
import sys
from collections.abc import Callable, Generator, Iterable, Iterator, Sequence
from re import Match, Pattern
-from typing import Any, ClassVar, Generic, SupportsIndex, TypeVar, overload
+from typing import Any, ClassVar, Final, Generic, SupportsIndex, TypeVar, overload
from typing_extensions import Self, TypeAlias
_T = TypeVar("_T")
@@ -10,6 +10,8 @@ _TransitionResult: TypeAlias = tuple[_Context, str | None, list[str]]
_TransitionMethod: TypeAlias = Callable[[Match[str], _Context, str], _TransitionResult[_Context]]
_Observer: TypeAlias = Callable[[StateMachine[_Context]], None]
+__docformat__: Final = "reStructuredText"
+
class StateMachine(Generic[_Context]):
input_lines: StringList | None
input_offset: int
@@ -163,7 +165,7 @@ class ViewList(Generic[_T]):
def source(self, i: int) -> str: ...
def offset(self, i: int) -> int: ...
def disconnect(self) -> None: ...
- def xitems(self) -> Generator[tuple[str, int, str], None, None]: ...
+ def xitems(self) -> Generator[tuple[str, int, str]]: ...
def pprint(self) -> None: ...
# dummy atribute to indicate to mypy that ViewList is Iterable[str]
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/transforms/__init__.pyi b/python/helpers/typeshed/stubs/docutils/docutils/transforms/__init__.pyi
index 589817290244..3a3732c53e9b 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/transforms/__init__.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/transforms/__init__.pyi
@@ -1,14 +1,36 @@
from _typeshed import Incomplete
+from collections.abc import Iterable, Mapping
+from typing import Any, ClassVar, Final
+from typing_extensions import TypeAlias
-from docutils.nodes import Node, document
+from docutils import ApplicationError, TransformSpec, nodes
+from docutils.languages import LanguageImporter
+
+_TransformTuple: TypeAlias = tuple[str, type[Transform], nodes.Node | None, dict[str, Any]]
+
+__docformat__: Final = "reStructuredText"
+
+class TransformError(ApplicationError): ...
class Transform:
- def __init__(self, document: document, startnode: Node | None = None): ...
- def __getattr__(self, name: str, /) -> Incomplete: ...
+ default_priority: ClassVar[int | None]
+ document: nodes.document
+ startnode: nodes.Node | None
+ language: LanguageImporter
+ def __init__(self, document: nodes.document, startnode: nodes.Node | None = None) -> None: ...
+ def __getattr__(self, name: str, /) -> Incomplete: ... # method apply is not implemented
-class Transformer:
- def __init__(self, document: document): ...
+class Transformer(TransformSpec):
+ transforms: list[_TransformTuple]
+ document: nodes.document
+ applied: list[_TransformTuple]
+ sorted: bool
+ components: Mapping[str, TransformSpec]
+ serialno: int
+ def __init__(self, document: nodes.document): ...
def add_transform(self, transform_class: type[Transform], priority: int | None = None, **kwargs) -> None: ...
- def __getattr__(self, name: str, /) -> Incomplete: ...
-
-def __getattr__(name: str): ... # incomplete module
+ def add_transforms(self, transform_list: Iterable[type[Transform]]) -> None: ...
+ def add_pending(self, pending: nodes.pending, priority: int | None = None) -> None: ...
+ def get_priority_string(self, priority: int) -> str: ...
+ def populate_from_components(self, components: Iterable[TransformSpec]) -> None: ...
+ def apply_transforms(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/transforms/components.pyi b/python/helpers/typeshed/stubs/docutils/docutils/transforms/components.pyi
new file mode 100644
index 000000000000..1c079281007a
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/transforms/components.pyi
@@ -0,0 +1,9 @@
+from typing import ClassVar, Final
+
+from docutils.transforms import Transform
+
+__docformat__: Final = "reStructuredText"
+
+class Filter(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/transforms/frontmatter.pyi b/python/helpers/typeshed/stubs/docutils/docutils/transforms/frontmatter.pyi
new file mode 100644
index 000000000000..bb0a86afb869
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/transforms/frontmatter.pyi
@@ -0,0 +1,34 @@
+import re
+from typing import ClassVar, Final
+
+from docutils import nodes
+from docutils.transforms import Transform
+
+__docformat__: Final = "reStructuredText"
+
+class TitlePromoter(Transform):
+ def promote_title(self, node: nodes.Element) -> bool: ...
+ def promote_subtitle(self, node: nodes.Element) -> bool: ...
+ def candidate_index(self, node: nodes.Element) -> tuple[nodes.Node, int] | tuple[None, None]: ...
+
+class DocTitle(TitlePromoter):
+ default_priority: ClassVar[int]
+ def set_metadata(self) -> None: ...
+ def apply(self) -> None: ...
+
+class SectionSubTitle(TitlePromoter):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
+
+class DocInfo(Transform):
+ default_priority: ClassVar[int]
+ biblio_nodes: ClassVar[dict[str, type[nodes.Element]]]
+ rcs_keyword_substitutions: ClassVar[list[tuple[re.Pattern[str], str]]]
+ def apply(self) -> None: ...
+ def extract_bibliographic(self, field_list): ...
+ def check_empty_biblio_field(self, field, name) -> bool: ...
+ def check_compound_biblio_field(self, field, name) -> bool: ...
+ def extract_authors(self, field, name, docinfo) -> None: ...
+ def authors_from_one_paragraph(self, field) -> list[list[nodes.Text]]: ...
+ def authors_from_bullet_list(self, field): ...
+ def authors_from_paragraphs(self, field): ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/transforms/misc.pyi b/python/helpers/typeshed/stubs/docutils/docutils/transforms/misc.pyi
new file mode 100644
index 000000000000..3baa09ca0761
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/transforms/misc.pyi
@@ -0,0 +1,19 @@
+from typing import ClassVar, Final
+
+from docutils import nodes
+from docutils.transforms import Transform
+
+__docformat__: Final = "reStructuredText"
+
+class CallBack(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
+
+class ClassAttribute(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
+
+class Transitions(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
+ def visit_transition(self, node: nodes.transition) -> None: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/transforms/parts.pyi b/python/helpers/typeshed/stubs/docutils/docutils/transforms/parts.pyi
new file mode 100644
index 000000000000..219f64d7876a
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/transforms/parts.pyi
@@ -0,0 +1,34 @@
+from _typeshed import Incomplete, Unused
+from collections.abc import Iterable, Sequence
+from typing import ClassVar, Final, NoReturn
+
+from docutils import nodes
+from docutils.transforms import Transform
+
+__docformat__: Final = "reStructuredText"
+
+class SectNum(Transform):
+ default_priority: ClassVar[int]
+ maxdepth: int
+ startvalue: int
+ prefix: str
+ suffix: str
+ def apply(self) -> None: ...
+ def update_section_numbers(self, node: nodes.Element, prefix: Iterable[str] = (), depth: int = 0) -> None: ...
+
+class Contents(Transform):
+ default_priority: ClassVar[int]
+ toc_id: Incomplete
+ backlinks: Incomplete
+ def apply(self) -> None: ...
+ def build_contents(
+ self, node: nodes.Element, level: int = 0
+ ) -> nodes.bullet_list | list[None]: ... # return empty list if entries is empty
+ def copy_and_filter(self, node: nodes.Node) -> Sequence[nodes.Node]: ...
+
+class ContentsFilter(nodes.TreeCopyVisitor):
+ def get_entry_text(self) -> Sequence[nodes.Node]: ...
+ def ignore_node_but_process_children(self, node: Unused) -> NoReturn: ...
+ visit_problematic = ignore_node_but_process_children
+ visit_reference = ignore_node_but_process_children
+ visit_target = ignore_node_but_process_children
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/transforms/peps.pyi b/python/helpers/typeshed/stubs/docutils/docutils/transforms/peps.pyi
new file mode 100644
index 000000000000..6b309245d35c
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/transforms/peps.pyi
@@ -0,0 +1,43 @@
+import re
+from typing import ClassVar, Final
+
+from docutils import nodes
+from docutils.transforms import Transform
+
+__docformat__: Final = "reStructuredText"
+
+class Headers(Transform):
+ default_priority: ClassVar[int]
+ pep_url: ClassVar[str]
+ pep_cvs_url: ClassVar[str]
+ rcs_keyword_substitutions: ClassVar[tuple[tuple[re.Pattern[str], str], ...]]
+ def apply(self) -> None: ...
+
+class Contents(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
+
+class TargetNotes(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
+ def cleanup_callback(self, pending: nodes.pending) -> None: ...
+
+class PEPZero(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
+
+class PEPZeroSpecial(nodes.SparseNodeVisitor):
+ pep_url: ClassVar[str]
+ def unknown_visit(self, node: nodes.Node) -> None: ...
+ def visit_reference(self, node: nodes.reference) -> None: ...
+ def visit_field_list(self, node: nodes.field_list) -> None: ...
+ pep_table: bool
+ entry: int
+ def visit_tgroup(self, node: nodes.tgroup) -> None: ...
+ def visit_colspec(self, node: nodes.colspec) -> None: ...
+ def visit_row(self, node: nodes.row) -> None: ...
+ def visit_entry(self, node: nodes.entry) -> None: ...
+
+non_masked_addresses: tuple[str, ...]
+
+def mask_email(ref: nodes.reference, pepno: int | None = None) -> nodes.Node: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/transforms/references.pyi b/python/helpers/typeshed/stubs/docutils/docutils/transforms/references.pyi
new file mode 100644
index 000000000000..a5a0068180f6
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/transforms/references.pyi
@@ -0,0 +1,79 @@
+from _typeshed import Incomplete
+from collections.abc import Iterable
+from typing import ClassVar, Final, overload
+
+from docutils import nodes
+from docutils.transforms import Transform
+
+__docformat__: Final = "reStructuredText"
+
+class PropagateTargets(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
+
+class AnonymousHyperlinks(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
+
+class IndirectHyperlinks(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
+ def resolve_indirect_target(self, target: nodes.Element) -> None: ...
+ def nonexistent_indirect_target(self, target: nodes.Element) -> None: ...
+ def circular_indirect_reference(self, target: nodes.Element) -> None: ...
+ def indirect_target_error(self, target: nodes.Element, explanation) -> None: ...
+ def resolve_indirect_references(self, target: nodes.Element) -> None: ...
+
+class ExternalTargets(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
+
+class InternalTargets(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
+ def resolve_reference_ids(self, target: nodes.Element) -> None: ...
+
+class Footnotes(Transform):
+ default_priority: ClassVar[int]
+ autofootnote_labels: list[str] | None
+ symbols: ClassVar[list[str]]
+ def apply(self) -> None: ...
+ def number_footnotes(self, startnum: int) -> int: ...
+ def number_footnote_references(self, startnum: int) -> None: ...
+ def symbolize_footnotes(self) -> None: ...
+ def resolve_footnotes_and_citations(self) -> None: ...
+ @overload
+ def resolve_references(self, note: nodes.footnote, reflist: Iterable[nodes.footnote_reference]) -> None: ...
+ @overload
+ def resolve_references(self, note: nodes.citation, reflist: Iterable[nodes.citation_reference]) -> None: ...
+ @overload
+ def resolve_references(self, note: nodes.title, reflist: Iterable[nodes.title_reference]) -> None: ...
+
+class CircularSubstitutionDefinitionError(Exception): ...
+
+class Substitutions(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
+
+class TargetNotes(Transform):
+ default_priority: ClassVar[int]
+ classes: Incomplete
+ def __init__(self, document: nodes.document, startnode: nodes.Node) -> None: ...
+ def apply(self) -> None: ...
+ def make_target_footnote(self, refuri: str, refs: list[Incomplete], notes: dict[Incomplete, Incomplete]): ...
+
+class CitationReferences(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
+
+class DanglingReferences(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
+
+class DanglingReferencesVisitor(nodes.SparseNodeVisitor):
+ document: nodes.document
+ def __init__(self, document: nodes.document, unknown_reference_resolvers) -> None: ...
+ def unknown_visit(self, node: nodes.Node) -> None: ...
+ def visit_reference(self, node: nodes.reference) -> None: ...
+ def visit_footnote_reference(self, node: nodes.footnote_reference) -> None: ...
+ def visit_citation_reference(self, node: nodes.citation_reference) -> None: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/transforms/universal.pyi b/python/helpers/typeshed/stubs/docutils/docutils/transforms/universal.pyi
new file mode 100644
index 000000000000..78879e80f994
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/transforms/universal.pyi
@@ -0,0 +1,56 @@
+from _typeshed import Incomplete
+from collections.abc import Generator, Iterable
+from typing import ClassVar, Final, Literal
+
+from docutils import nodes
+from docutils.transforms import Transform
+
+__docformat__: Final = "reStructuredText"
+
+class Decorations(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
+ def generate_header(self) -> None: ...
+ def generate_footer(self) -> list[nodes.paragraph] | None: ...
+
+class ExposeInternals(Transform):
+ default_priority: ClassVar[int]
+ def not_Text(self, node: object) -> bool: ... # node passing to isinstance() method
+ def apply(self) -> None: ...
+
+class Messages(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
+
+class FilterMessages(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
+
+class TestMessages(Transform):
+ __test__: bool
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
+
+class StripComments(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
+
+class StripClassesAndElements(Transform):
+ default_priority: ClassVar[int]
+ strip_elements: set[Incomplete]
+ def apply(self) -> None: ...
+ def check_classes(self, node: object) -> bool: ...
+
+class SmartQuotes(Transform):
+ default_priority: ClassVar[int]
+ nodes_to_skip: ClassVar[tuple[type[nodes.Node], ...]]
+ literal_nodes: ClassVar[tuple[type[nodes.Node | nodes.Body], ...]]
+ smartquotes_action: ClassVar[str]
+ unsupported_languages: set[str]
+ def __init__(self, document: nodes.document, startnode: nodes.Node | None) -> None: ...
+ def get_tokens(self, txtnodes: Iterable[nodes.Node]) -> Generator[tuple[Literal["literal", "plain"], str]]: ...
+ def apply(self) -> None: ...
+
+class Validate(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/transforms/writer_aux.pyi b/python/helpers/typeshed/stubs/docutils/docutils/transforms/writer_aux.pyi
new file mode 100644
index 000000000000..38523f07319e
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/transforms/writer_aux.pyi
@@ -0,0 +1,9 @@
+from typing import ClassVar, Final
+
+from docutils.transforms import Transform
+
+__docformat__: Final = "reStructuredText"
+
+class Admonitions(Transform):
+ default_priority: ClassVar[int]
+ def apply(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/utils/__init__.pyi b/python/helpers/typeshed/stubs/docutils/docutils/utils/__init__.pyi
index 9299145afd02..30b4725712a4 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/utils/__init__.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/utils/__init__.pyi
@@ -1,9 +1,9 @@
import optparse
-from _typeshed import StrPath, SupportsWrite, Unused
-from collections.abc import Callable, Iterable, Mapping
+from _typeshed import StrPath, SupportsWrite
+from collections.abc import Callable, Iterable, Mapping, Sequence
from re import Pattern
from typing import Any, Final, Literal, TypeVar
-from typing_extensions import TypeAlias
+from typing_extensions import TypeAlias, deprecated
from docutils import ApplicationError, DataError, nodes
from docutils.frontend import Values
@@ -27,13 +27,14 @@ class DependencyList:
class SystemMessagePropagation(ApplicationError): ...
class Reporter:
- levels: list[str]
+ get_source_and_line: Callable[[int | None], tuple[StrPath | None, int | None]]
+ levels: Final[Sequence[str]]
- DEBUG_LEVEL: Literal[0]
- INFO_LEVEL: Literal[1]
- WARNING_LEVEL: Literal[2]
- ERROR_LEVEL: Literal[3]
- SEVERE_LEVEL: Literal[4]
+ DEBUG_LEVEL: Final = 0
+ INFO_LEVEL: Final = 1
+ WARNING_LEVEL: Final = 2
+ ERROR_LEVEL: Final = 3
+ SEVERE_LEVEL: Final = 4
stream: ErrorOutput
encoding: str
@@ -55,14 +56,6 @@ class Reporter:
debug_flag: bool
report_level: _SystemMessageLevel
halt_level: int
- def set_conditions(
- self,
- category: Unused,
- report_level: int,
- halt_level: int,
- stream: SupportsWrite[str] | SupportsWrite[bytes] | None = None,
- debug: bool = False,
- ) -> None: ...
def attach_observer(self, observer: _Observer) -> None: ...
def detach_observer(self, observer: _Observer) -> None: ...
def notify_observers(self, message: nodes.system_message) -> None: ...
@@ -113,11 +106,13 @@ def assemble_option_dict(
class NameValueError(DataError): ...
+@deprecated("Deprecated and will be removed in Docutils 1.0.")
def decode_path(path: str) -> str: ...
def extract_name_value(line: str) -> list[tuple[str, str]]: ...
def clean_rcs_keywords(paragraph: nodes.paragraph, keyword_substitutions: Iterable[tuple[Pattern[str], str]]) -> None: ...
def relative_path(source: StrPath | None, target: StrPath) -> str: ...
-def get_stylesheet_reference(settings: Values, relative_to: str | None = None) -> str: ...
+@deprecated("Deprecated and will be removed in Docutils 1.0. Use `get_stylesheet_list()` instead.")
+def get_stylesheet_reference(settings: Values, relative_to: StrPath | None = None) -> str: ...
def get_stylesheet_list(settings: Values) -> list[str]: ...
def find_file_in_dirs(path: StrPath, dirs: Iterable[StrPath]) -> str: ...
def get_trim_footnote_ref_space(settings: Values) -> bool: ...
@@ -134,7 +129,3 @@ def column_width(text: str) -> int: ...
def uniq(L: list[_T]) -> list[_T]: ...
def normalize_language_tag(tag: str) -> list[str]: ...
def xml_declaration(encoding: str | None = None) -> str: ...
-
-release_level_abbreviations: dict[str, str]
-
-def version_identifier(version_info: tuple[int, int, int, str, int, bool] | None = None) -> str: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/utils/_roman_numerals.pyi b/python/helpers/typeshed/stubs/docutils/docutils/utils/_roman_numerals.pyi
new file mode 100644
index 000000000000..0d7b27baff83
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/utils/_roman_numerals.pyi
@@ -0,0 +1,30 @@
+from typing import Final, final
+from typing_extensions import Self
+
+__all__ = ("MAX", "MIN", "InvalidRomanNumeralError", "OutOfRangeError", "RomanNumeral")
+
+MIN: Final = 1
+MAX: Final = 4_999
+
+@final
+class OutOfRangeError(TypeError): ...
+
+@final
+class InvalidRomanNumeralError(ValueError):
+ def __init__(self, value: str, *args: object) -> None: ...
+
+@final
+class RomanNumeral:
+ __slots__ = ("_value",)
+ def __init__(self, value: int, /) -> None: ...
+ def __int__(self) -> int: ...
+ def __eq__(self, other: object) -> bool: ...
+ def __lt__(self, other: object) -> bool: ...
+ def __hash__(self) -> int: ...
+ def __setattr__(self, key: str, value: object) -> None: ...
+ def to_uppercase(self) -> str: ...
+ def to_lowercase(self) -> str: ...
+ @classmethod
+ def from_string(cls, string: str, /) -> Self: ...
+
+_ROMAN_NUMERAL_PREFIXES: Final[list[tuple[int, str, str]]]
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/utils/code_analyzer.pyi b/python/helpers/typeshed/stubs/docutils/docutils/utils/code_analyzer.pyi
index 73313a959ea2..adbf7b956363 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/utils/code_analyzer.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/utils/code_analyzer.pyi
@@ -1,11 +1,12 @@
from collections.abc import Generator, Iterable
-from typing import Literal
+from typing import Final, Literal
from typing_extensions import TypeAlias
from docutils import ApplicationError
_TokenNames: TypeAlias = Literal["long", "short", "none"]
+__docformat__: Final = "reStructuredText"
with_pygments: bool
unstyled_tokens: list[str]
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/utils/error_reporting.pyi b/python/helpers/typeshed/stubs/docutils/docutils/utils/error_reporting.pyi
deleted file mode 100644
index eed08a3c7b88..000000000000
--- a/python/helpers/typeshed/stubs/docutils/docutils/utils/error_reporting.pyi
+++ /dev/null
@@ -1,41 +0,0 @@
-from io import TextIOWrapper
-from typing import TextIO
-from typing_extensions import TypeAlias, deprecated
-
-unicode = str
-
-_DataType: TypeAlias = str | Exception
-
-@deprecated("`docutils.utils.error_reporting` module is deprecated and will be removed in Docutils 0.21 or later.")
-class SafeString:
- data: object
- encoding: str
- encoding_errors: str
- decoding_errors: str
- def __init__(
- self,
- data: object,
- encoding: str | None = None,
- encoding_errors: str = "backslashreplace",
- decoding_errors: str = "replace",
- ) -> None: ...
- def __unicode__(self) -> str: ...
-
-@deprecated("`docutils.utils.error_reporting` module is deprecated and will be removed in Docutils 0.21 or later.")
-class ErrorString(SafeString): ...
-
-@deprecated("`docutils.utils.error_reporting` module is deprecated and will be removed in Docutils 0.21 or later.")
-class ErrorOutput:
- stream: TextIO | TextIOWrapper
- encoding: str
- encoding_errors: str
- decoding_errors: str
- def __init__(
- self,
- stream=None,
- encoding: str | None = None,
- encoding_errors: str = "backslashreplace",
- decoding_errors: str = "replace",
- ) -> None: ...
- def write(self, data: _DataType) -> None: ...
- def close(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/utils/math/__init__.pyi b/python/helpers/typeshed/stubs/docutils/docutils/utils/math/__init__.pyi
index 3504ef1438fe..cfe920e0bbc7 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/utils/math/__init__.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/utils/math/__init__.pyi
@@ -1,7 +1,9 @@
-from typing import Literal
+from typing import Final, Literal
from docutils.nodes import Node
+__docformat__: Final = "reStructuredText"
+
class MathError(ValueError):
details: list[Node]
def __init__(self, msg: object, details: list[Node] = []) -> None: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/utils/math/math2html.pyi b/python/helpers/typeshed/stubs/docutils/docutils/utils/math/math2html.pyi
index 2c4eaffd178f..0972842a9ad0 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/utils/math/math2html.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/utils/math/math2html.pyi
@@ -4,6 +4,7 @@ from typing import ClassVar, Final, TextIO, TypeVar
_T = TypeVar("_T")
+__docformat__: Final = "reStructuredText"
__version__: Final[str]
class Trace:
@@ -51,6 +52,8 @@ class FormulaConfig:
symbolfunctions: ClassVar[dict[str, str]]
textfunctions: ClassVar[dict[str, str]]
unmodified: ClassVar[dict[str, list[str]]]
+ key: str
+ value: str
class CommandLineParser:
options: Incomplete
@@ -86,7 +89,7 @@ class ContainerExtractor:
extracted: Incomplete
def __init__(self, config) -> None: ...
def extract(self, container): ...
- def process(self, container, list) -> None: ...
+ def process(self, container, lst) -> None: ...
def safeclone(self, container): ...
class Parser:
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/utils/math/mathml_elements.pyi b/python/helpers/typeshed/stubs/docutils/docutils/utils/math/mathml_elements.pyi
index 3f1c4d803a3d..a3aef8ac2cda 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/utils/math/mathml_elements.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/utils/math/mathml_elements.pyi
@@ -4,6 +4,7 @@ from collections.abc import Iterable
from typing import ClassVar, Final, SupportsIndex, overload
from typing_extensions import Self
+__docformat__: Final = "reStructuredText"
GLOBAL_ATTRIBUTES: Final[tuple[str, ...]]
class MathElement(ET.Element):
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/utils/math/tex2mathml_extern.pyi b/python/helpers/typeshed/stubs/docutils/docutils/utils/math/tex2mathml_extern.pyi
index d0efc08b1dd9..c15fde2125f9 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/utils/math/tex2mathml_extern.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/utils/math/tex2mathml_extern.pyi
@@ -1,5 +1,6 @@
from typing import Final
+__docformat__: Final = "reStructuredText"
document_template: Final[str]
def blahtexml(math_code: str, as_block: bool = False) -> str: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/utils/roman.pyi b/python/helpers/typeshed/stubs/docutils/docutils/utils/roman.pyi
deleted file mode 100644
index 877a52a4a9ac..000000000000
--- a/python/helpers/typeshed/stubs/docutils/docutils/utils/roman.pyi
+++ /dev/null
@@ -1,23 +0,0 @@
-import argparse
-import re
-from typing import Final, Literal
-
-__author__: Final[str]
-__version__: Final[str]
-__date__: Final[str]
-__copyright__: Final[str]
-
-class RomanError(Exception): ...
-class OutOfRangeError(RomanError): ...
-class NotIntegerError(RomanError): ...
-class InvalidRomanNumeralError(RomanError): ...
-
-romanNumeralMap: tuple[tuple[str, int], ...]
-
-def toRoman(n: int) -> str: ...
-
-romanNumeralPattern: Final[re.Pattern[str]]
-
-def fromRoman(s: str) -> int: ...
-def parse_args() -> argparse.Namespace: ...
-def main() -> Literal[0]: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/__init__.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/__init__.pyi
index 58c40200aaf0..3fa0f555d1ae 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/writers/__init__.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/writers/__init__.pyi
@@ -1,12 +1,17 @@
-from typing import Any, Generic, TypedDict, TypeVar, type_check_only
+from _typeshed import StrPath
+from pathlib import Path
+from typing import Any, Final, Generic, TypedDict, TypeVar, type_check_only
from typing_extensions import Required
from docutils import Component, nodes
+from docutils.frontend import Values
from docutils.io import Output
from docutils.languages import LanguageImporter
_S = TypeVar("_S")
+__docformat__: Final = "reStructuredText"
+
# It would probably be better to specialize writers for subclasses,
# but this gives us all possible Writer items w/o instance checks
@type_check_only
@@ -67,14 +72,21 @@ class _WriterParts(TypedDict, total=False):
class Writer(Component, Generic[_S]):
parts: _WriterParts
language: LanguageImporter | None = None
- def __init__(self) -> None: ...
document: nodes.document | None = None
destination: Output | None = None
output: _S | None = None
- def assemble_parts(self) -> None: ...
- def translate(self) -> None: ...
+ def __init__(self) -> None: ...
def write(self, document: nodes.document, destination: Output) -> str | bytes | None: ...
+ def translate(self) -> None: ...
+ def assemble_parts(self) -> None: ...
class UnfilteredWriter(Writer[_S]): ...
+class DoctreeTranslator(nodes.NodeVisitor):
+ settings: Values
+ def __init__(self, document: nodes.document) -> None: ...
+ def uri2path(self, uri: str, output_path: StrPath | None = None) -> Path: ...
+
+WRITER_ALIASES: Final[dict[str, str]]
+
def get_writer_class(writer_name: str) -> type[Writer[Any]]: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/_html_base.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/_html_base.pyi
new file mode 100644
index 000000000000..9169869aa1a8
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/writers/_html_base.pyi
@@ -0,0 +1,304 @@
+from _typeshed import Incomplete, StrPath
+from collections.abc import Callable
+from re import Pattern
+from typing import ClassVar, Final, NoReturn
+
+from docutils import nodes, writers
+from docutils.frontend import Values
+from docutils.languages import _LanguageModule
+
+__docformat__: Final = "reStructuredText"
+
+class Writer(writers.Writer[str]):
+ settings_defaults: ClassVar[dict[str, str]]
+ relative_path_settings: ClassVar[tuple[str, ...]]
+ config_section: ClassVar[str]
+ config_section_dependencies: ClassVar[tuple[str, ...]]
+ visitor_attributes: ClassVar[tuple[str, ...]]
+ visitor: nodes.NodeVisitor
+ def translate(self) -> None: ...
+ def apply_template(self) -> str: ...
+ def interpolation_dict(self) -> dict[str, str]: ...
+ def assemble_parts(self) -> None: ...
+
+class HTMLTranslator(nodes.NodeVisitor):
+ doctype: ClassVar[str]
+ doctype_mathml: ClassVar[str]
+ head_prefix_template: ClassVar[str]
+ content_type: ClassVar[str]
+ generator: ClassVar[str]
+ documenttag_args: ClassVar[dict[str, str]]
+ mathjax_script: ClassVar[str]
+ mathjax_url: ClassVar[str]
+ stylesheet_link: ClassVar[str]
+ embedded_stylesheet: ClassVar[str]
+ words_and_spaces: ClassVar[Pattern[str]]
+ in_word_wrap_point: ClassVar[Pattern[str]]
+ lang_attribute: ClassVar[str]
+ special_characters: ClassVar[dict[int, str]]
+ videotypes: ClassVar[tuple[str, ...]]
+ attribution_formats: ClassVar[dict[str, tuple[str, str]]]
+ settings: Values
+ language: _LanguageModule
+ initial_header_level: int
+ image_loading: str
+ body: list[str]
+ body_prefix: list[str]
+ body_pre_docinfo: list[Incomplete]
+ body_suffix: list[str]
+ docinfo: list[str]
+ footer: list[str]
+ fragment: list[Incomplete]
+ head: list[Incomplete]
+ head_prefix: list[Incomplete]
+ header: list[Incomplete]
+ html_body: list[Incomplete]
+ html_head: list[Incomplete]
+ html_prolog: list[Incomplete]
+ html_subtitle: list[Incomplete]
+ html_title: list[Incomplete]
+ meta: list[Incomplete]
+ stylesheet: list[Incomplete]
+ title: list[Incomplete]
+ subtitle: list[Incomplete]
+ context: list[Incomplete]
+ section_level: int
+ colspecs: list[Incomplete]
+ compact_p: bool
+ compact_simple: bool
+ compact_field_list: bool
+ in_docinfo: bool
+ in_sidebar: bool
+ in_document_title: int
+ in_mailto: bool
+ author_in_authors: bool
+ math_header: list[str]
+ messages: list[Incomplete]
+ def __init__(self, document: nodes.document) -> None: ...
+ def astext(self) -> str: ...
+ def attval(self, text: str, whitespace: Pattern[str] = ...) -> str: ...
+ def cloak_email(self, addr: str) -> str: ...
+ def cloak_mailto(self, uri: str) -> str: ...
+ def encode(self, text: object) -> str: ...
+ def image_size(self, node: nodes.image) -> str: ...
+ def read_size_with_PIL(self, node) -> tuple[int, int] | None: ...
+ def prepare_svg(self, code: str | bytes, node: nodes.Element, atts: dict[str, Incomplete]) -> str: ...
+ def stylesheet_call(self, path: StrPath, adjust_path: bool | None = None) -> str: ...
+ def starttag(self, node: nodes.Element, tagname: str, suffix: str = "\n", empty: bool = False, **attributes) -> str: ...
+ def emptytag(self, node: nodes.Element, tagname: str, suffix: str = "\n", **attributes) -> str: ...
+ def report_messages(self, node: nodes.Node) -> None: ...
+ def set_class_on_child(self, node, class_, index: int = 0) -> None: ...
+ def visit_Text(self, node: nodes.Text) -> None: ...
+ def depart_Text(self, node: nodes.Text) -> None: ...
+ def visit_abbreviation(self, node: nodes.abbreviation) -> None: ...
+ def depart_abbreviation(self, node: nodes.abbreviation) -> None: ...
+ def visit_acronym(self, node: nodes.acronym) -> None: ...
+ def depart_acronym(self, node: nodes.acronym) -> None: ...
+ def visit_address(self, node: nodes.address) -> None: ...
+ def depart_address(self, node: nodes.address) -> None: ...
+ def visit_admonition(self, node: nodes.admonition) -> None: ...
+ def depart_admonition(self, node: nodes.admonition | None = None) -> None: ...
+ def visit_attribution(self, node: nodes.attribution) -> None: ...
+ def depart_attribution(self, node: nodes.attribution) -> None: ...
+ def visit_author(self, node: nodes.author) -> None: ...
+ def depart_author(self, node: nodes.author) -> None: ...
+ def visit_authors(self, node: nodes.authors) -> None: ...
+ def depart_authors(self, node: nodes.authors) -> None: ...
+ def visit_block_quote(self, node: nodes.block_quote) -> None: ...
+ def depart_block_quote(self, node: nodes.block_quote) -> None: ...
+ def check_simple_list(self, node: nodes.Node) -> bool: ...
+ def is_compactable(self, node: nodes.Element) -> bool: ...
+ def visit_bullet_list(self, node: nodes.bullet_list) -> None: ...
+ def depart_bullet_list(self, node: nodes.bullet_list) -> None: ...
+ def visit_caption(self, node: nodes.caption) -> None: ...
+ def depart_caption(self, node: nodes.caption) -> None: ...
+ def visit_citation(self, node: nodes.citation) -> None: ...
+ def depart_citation(self, node: nodes.citation) -> None: ...
+ def visit_citation_reference(self, node: nodes.citation_reference) -> None: ...
+ def depart_citation_reference(self, node: nodes.citation_reference) -> None: ...
+ def visit_classifier(self, node: nodes.classifier) -> None: ...
+ def depart_classifier(self, node: nodes.classifier) -> None: ...
+ def visit_colspec(self, node: nodes.colspec) -> None: ...
+ def depart_colspec(self, node: nodes.colspec) -> None: ...
+ def visit_comment(self, node: nodes.comment, sub: Callable[[str, str], str] = ...) -> None: ...
+ def visit_compound(self, node: nodes.compound) -> None: ...
+ def depart_compound(self, node: nodes.compound) -> None: ...
+ def visit_container(self, node: nodes.container) -> None: ...
+ def depart_container(self, node: nodes.container) -> None: ...
+ def visit_contact(self, node: nodes.contact) -> None: ...
+ def depart_contact(self, node: nodes.contact) -> None: ...
+ def visit_copyright(self, node: nodes.copyright) -> None: ...
+ def depart_copyright(self, node: nodes.copyright) -> None: ...
+ def visit_date(self, node: nodes.date) -> None: ...
+ def depart_date(self, node: nodes.date) -> None: ...
+ def visit_decoration(self, node: nodes.decoration) -> None: ...
+ def depart_decoration(self, node: nodes.decoration) -> None: ...
+ def visit_definition(self, node: nodes.definition) -> None: ...
+ def depart_definition(self, node: nodes.definition) -> None: ...
+ def visit_definition_list(self, node: nodes.definition_list) -> None: ...
+ def depart_definition_list(self, node: nodes.definition_list) -> None: ...
+ def visit_definition_list_item(self, node: nodes.definition_list_item) -> None: ...
+ def depart_definition_list_item(self, node: nodes.definition_list_item) -> None: ...
+ def visit_description(self, node: nodes.description) -> None: ...
+ def depart_description(self, node: nodes.description) -> None: ...
+ def visit_docinfo(self, node: nodes.docinfo) -> None: ...
+ def depart_docinfo(self, node: nodes.docinfo) -> None: ...
+ def visit_docinfo_item(self, node, name: str, meta: bool = True) -> None: ...
+ def depart_docinfo_item(self) -> None: ...
+ def visit_doctest_block(self, node: nodes.doctest_block) -> None: ...
+ def depart_doctest_block(self, node: nodes.doctest_block) -> None: ...
+ def visit_document(self, node: nodes.document) -> None: ...
+ def depart_document(self, node: nodes.document) -> None: ...
+ def visit_emphasis(self, node: nodes.emphasis) -> None: ...
+ def depart_emphasis(self, node: nodes.emphasis) -> None: ...
+ def visit_entry(self, node: nodes.entry) -> None: ...
+ def depart_entry(self, node: nodes.entry) -> None: ...
+ def visit_enumerated_list(self, node: nodes.enumerated_list) -> None: ...
+ def depart_enumerated_list(self, node: nodes.enumerated_list) -> None: ...
+ def visit_field_list(self, node: nodes.field_list) -> None: ...
+ def depart_field_list(self, node: nodes.field_list) -> None: ...
+ def visit_field(self, node: nodes.field) -> None: ...
+ def depart_field(self, node: nodes.field) -> None: ...
+ def visit_field_name(self, node: nodes.field_name) -> None: ...
+ def depart_field_name(self, node: nodes.field_name) -> None: ...
+ def visit_field_body(self, node: nodes.field_body) -> None: ...
+ def depart_field_body(self, node: nodes.field_body) -> None: ...
+ def visit_figure(self, node: nodes.figure) -> None: ...
+ def depart_figure(self, node: nodes.figure) -> None: ...
+ def visit_footer(self, node: nodes.footer) -> None: ...
+ def depart_footer(self, node: nodes.footer) -> None: ...
+ def visit_footnote(self, node: nodes.footnote) -> None: ...
+ def depart_footnote(self, node: nodes.footnote) -> None: ...
+ def visit_footnote_reference(self, node: nodes.footnote_reference) -> None: ...
+ def depart_footnote_reference(self, node: nodes.footnote_reference) -> None: ...
+ def visit_generated(self, node: nodes.generated) -> None: ...
+ def depart_generated(self, node: nodes.generated) -> None: ...
+ def visit_header(self, node: nodes.header) -> None: ...
+ def depart_header(self, node: nodes.header) -> None: ...
+ def visit_image(self, node: nodes.image) -> None: ...
+ def depart_image(self, node: nodes.image) -> None: ...
+ def visit_inline(self, node: nodes.inline) -> None: ...
+ def depart_inline(self, node: nodes.inline) -> None: ...
+ def visit_label(self, node: nodes.label) -> None: ...
+ def depart_label(self, node: nodes.label) -> None: ...
+ def visit_legend(self, node: nodes.legend) -> None: ...
+ def depart_legend(self, node: nodes.legend) -> None: ...
+ def visit_line(self, node: nodes.line) -> None: ...
+ def depart_line(self, node: nodes.line) -> None: ...
+ def visit_line_block(self, node: nodes.line_block) -> None: ...
+ def depart_line_block(self, node: nodes.line_block) -> None: ...
+ def visit_list_item(self, node: nodes.list_item) -> None: ...
+ def depart_list_item(self, node: nodes.list_item) -> None: ...
+ def visit_literal(self, node: nodes.literal) -> None: ...
+ def depart_literal(self, node: nodes.literal) -> None: ...
+ def visit_literal_block(self, node: nodes.literal_block) -> None: ...
+ def depart_literal_block(self, node: nodes.literal_block) -> None: ...
+ math_tags: dict[str, tuple[str, str, list[str]]]
+ math_output: str | Incomplete
+ def visit_math(self, node: nodes.math) -> None: ...
+ def depart_math(self, node: nodes.math) -> None: ...
+ def visit_math_block(self, node: nodes.math_block) -> None: ...
+ def depart_math_block(self, node: nodes.math_block) -> None: ...
+ def visit_meta(self, node: nodes.meta) -> None: ...
+ def depart_meta(self, node: nodes.meta) -> None: ...
+ def visit_option(self, node: nodes.option) -> None: ...
+ def depart_option(self, node: nodes.option) -> None: ...
+ def visit_option_argument(self, node: nodes.option_argument) -> None: ...
+ def depart_option_argument(self, node: nodes.option_argument) -> None: ...
+ def visit_option_group(self, node: nodes.option_group) -> None: ...
+ def depart_option_group(self, node: nodes.option_group) -> None: ...
+ def visit_option_list(self, node: nodes.option_list) -> None: ...
+ def depart_option_list(self, node: nodes.option_list) -> None: ...
+ def visit_option_list_item(self, node: nodes.option_list_item) -> None: ...
+ def depart_option_list_item(self, node: nodes.option_list_item) -> None: ...
+ def visit_option_string(self, node: nodes.option_string) -> None: ...
+ def depart_option_string(self, node: nodes.option_string) -> None: ...
+ def visit_organization(self, node: nodes.organization) -> None: ...
+ def depart_organization(self, node: nodes.organization) -> None: ...
+ def visit_paragraph(self, node: nodes.paragraph) -> None: ...
+ def depart_paragraph(self, node: nodes.paragraph) -> None: ...
+ def visit_problematic(self, node: nodes.problematic) -> None: ...
+ def depart_problematic(self, node: nodes.problematic) -> None: ...
+ def visit_raw(self, node: nodes.raw) -> None: ...
+ def visit_reference(self, node: nodes.reference) -> None: ...
+ def depart_reference(self, node: nodes.reference) -> None: ...
+ def visit_revision(self, node: nodes.revision) -> None: ...
+ def depart_revision(self, node: nodes.revision) -> None: ...
+ def visit_row(self, node: nodes.row) -> None: ...
+ def depart_row(self, node: nodes.row) -> None: ...
+ def visit_rubric(self, node: nodes.rubric) -> None: ...
+ def depart_rubric(self, node: nodes.rubric) -> None: ...
+ def visit_section(self, node: nodes.section) -> None: ...
+ def depart_section(self, node: nodes.section) -> None: ...
+ def visit_sidebar(self, node: nodes.sidebar) -> None: ...
+ def depart_sidebar(self, node: nodes.sidebar) -> None: ...
+ def visit_status(self, node: nodes.status) -> None: ...
+ def depart_status(self, node: nodes.status) -> None: ...
+ def visit_strong(self, node: nodes.strong) -> None: ...
+ def depart_strong(self, node: nodes.strong) -> None: ...
+ def visit_subscript(self, node: nodes.subscript) -> None: ...
+ def depart_subscript(self, node: nodes.subscript) -> None: ...
+ def visit_substitution_definition(self, node: nodes.substitution_definition) -> None: ...
+ def visit_substitution_reference(self, node: nodes.substitution_reference) -> None: ...
+ def visit_subtitle(self, node: nodes.subtitle) -> None: ...
+ def depart_subtitle(self, node: nodes.subtitle) -> None: ...
+ def visit_superscript(self, node: nodes.superscript) -> None: ...
+ def depart_superscript(self, node: nodes.superscript) -> None: ...
+ def visit_system_message(self, node: nodes.system_message) -> None: ...
+ def depart_system_message(self, node: nodes.system_message) -> None: ...
+ def visit_table(self, node: nodes.table) -> None: ...
+ def depart_table(self, node: nodes.table) -> None: ...
+ def visit_target(self, node: nodes.target) -> None: ...
+ def depart_target(self, node: nodes.target) -> None: ...
+ def visit_tbody(self, node: nodes.tbody) -> None: ...
+ def depart_tbody(self, node: nodes.tbody) -> None: ...
+ def visit_term(self, node: nodes.term) -> None: ...
+ def depart_term(self, node: nodes.term) -> None: ...
+ def visit_tgroup(self, node: nodes.tgroup) -> None: ...
+ def depart_tgroup(self, node: nodes.tgroup) -> None: ...
+ def visit_thead(self, node: nodes.thead) -> None: ...
+ def depart_thead(self, node: nodes.thead) -> None: ...
+ def section_title_tags(self, node: nodes.Element) -> tuple[str, str]: ...
+ def visit_title(self, node: nodes.title) -> None: ...
+ def depart_title(self, node: nodes.title) -> None: ...
+ def visit_title_reference(self, node: nodes.title_reference) -> None: ...
+ def depart_title_reference(self, node: nodes.title_reference) -> None: ...
+ def visit_topic(self, node: nodes.topic) -> None: ...
+ def depart_topic(self, node: nodes.topic) -> None: ...
+ def visit_transition(self, node: nodes.transition) -> None: ...
+ def depart_transition(self, node: nodes.transition) -> None: ...
+ def visit_version(self, node: nodes.version) -> None: ...
+ def depart_version(self, node: nodes.version) -> None: ...
+ def unimplemented_visit(self, node: nodes.Node) -> NoReturn: ...
+
+class SimpleListChecker(nodes.GenericNodeVisitor):
+ def visit_list_item(self, node: nodes.list_item) -> None: ...
+ def pass_node(self, node: nodes.Node) -> None: ...
+ def ignore_node(self, node: nodes.Node) -> None: ...
+ def visit_Text(self, node: nodes.Text) -> None: ...
+ def visit_paragraph(self, node: nodes.paragraph) -> None: ...
+ def visit_bullet_list(self, node: nodes.bullet_list) -> None: ...
+ def visit_enumerated_list(self, node: nodes.enumerated_list) -> None: ...
+ def visit_docinfo(self, node: nodes.docinfo) -> None: ...
+ def visit_author(self, node: nodes.author) -> None: ...
+ def visit_authors(self, node: nodes.authors) -> None: ...
+ def visit_address(self, node: nodes.address) -> None: ...
+ def visit_contact(self, node: nodes.contact) -> None: ...
+ def visit_copyright(self, node: nodes.copyright) -> None: ...
+ def visit_date(self, node: nodes.date) -> None: ...
+ def visit_organization(self, node: nodes.organization) -> None: ...
+ def visit_status(self, node: nodes.status) -> None: ...
+ def visit_version(self, node: nodes.version) -> None: ...
+ def visit_definition_list(self, node: nodes.definition_list) -> None: ...
+ def visit_definition_list_item(self, node: nodes.definition_list_item) -> None: ...
+ def visit_term(self, node: nodes.term) -> None: ...
+ def visit_classifier(self, node: nodes.classifier) -> None: ...
+ def visit_definition(self, node: nodes.definition) -> None: ...
+ def visit_field_list(self, node: nodes.field_list) -> None: ...
+ def visit_field(self, node: nodes.field) -> None: ...
+ def visit_field_body(self, node: nodes.field_body) -> None: ...
+ def visit_field_name(self, node: nodes.field_name) -> None: ...
+ def visit_comment(self, node: nodes.comment) -> None: ...
+ def visit_substitution_definition(self, node: nodes.substitution_definition) -> None: ...
+ def visit_target(self, node: nodes.target) -> None: ...
+ def visit_pending(self, node: nodes.pending) -> None: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/docutils_xml.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/docutils_xml.pyi
index 5b0f74feb261..dfd4096071d4 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/writers/docutils_xml.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/writers/docutils_xml.pyi
@@ -1 +1,45 @@
-def __getattr__(name: str): ... # incomplete module
+from collections.abc import Callable
+from typing import ClassVar, Final
+from xml.sax.handler import ContentHandler
+from xml.sax.xmlreader import Locator, XMLReader
+
+import docutils
+from docutils import nodes, writers
+from docutils.frontend import Values
+
+__docformat__: Final = "reStructuredText"
+
+class RawXmlError(docutils.ApplicationError): ...
+
+class Writer(writers.Writer[str]):
+ settings_defaults: ClassVar[dict[str, str]]
+ config_section: ClassVar[str]
+ config_section_dependencies: ClassVar[tuple[str, ...]]
+ translator_class: type[XMLTranslator]
+ visitor: XMLTranslator
+
+class XMLTranslator(nodes.GenericNodeVisitor):
+ doctype: ClassVar[str]
+ generator: ClassVar[str]
+ xmlparser: ClassVar[XMLReader]
+ warn: Callable[..., nodes.system_message]
+ error: Callable[..., nodes.system_message]
+ settings: Values
+ indent: str
+ newline: str
+ level: int
+ in_simple: int
+ fixed_text: int
+ output: list[str]
+ the_handle: TestXml
+ def __init__(self, document: nodes.document) -> None: ...
+ simple_nodes: ClassVar[tuple[type[nodes.Element], ...]]
+ def default_visit(self, node: nodes.Element) -> None: ... # type: ignore[override]
+ def default_departure(self, node: nodes.Element) -> None: ... # type: ignore[override]
+ def visit_Text(self, node: nodes.Text) -> None: ...
+ def depart_Text(self, node: nodes.Text) -> None: ...
+ def visit_raw(self, node: nodes.raw) -> None: ...
+
+class TestXml(ContentHandler):
+ locator: Locator
+ def setDocumentLocator(self, locator: Locator) -> None: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/html4css1.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/html4css1.pyi
deleted file mode 100644
index 5b0f74feb261..000000000000
--- a/python/helpers/typeshed/stubs/docutils/docutils/writers/html4css1.pyi
+++ /dev/null
@@ -1 +0,0 @@
-def __getattr__(name: str): ... # incomplete module
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/html4css1/__init__.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/html4css1/__init__.pyi
new file mode 100644
index 000000000000..76da0b68d282
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/writers/html4css1/__init__.pyi
@@ -0,0 +1,125 @@
+from _typeshed import Incomplete
+from typing import ClassVar, Final
+
+from docutils import nodes
+from docutils.writers import _html_base
+
+__docformat__: Final = "reStructuredText"
+
+class Writer(_html_base.Writer):
+ default_stylesheets: ClassVar[list[str]]
+ default_stylesheet_dirs: ClassVar[list[str]]
+ default_template: ClassVar[str]
+ config_section: ClassVar[str]
+ translator_class: type[HTMLTranslator]
+
+class HTMLTranslator(_html_base.HTMLTranslator):
+ content_type: ClassVar[str]
+ content_type_mathml: ClassVar[str]
+ object_image_types: ClassVar[dict[str, str]]
+ def set_first_last(self, node) -> None: ...
+ def visit_address(self, node: nodes.address) -> None: ...
+ def depart_address(self, node: nodes.address) -> None: ...
+ def visit_admonition(self, node: nodes.admonition) -> None: ...
+ def depart_admonition(self, node: nodes.admonition | None = None) -> None: ...
+ def visit_author(self, node: nodes.author) -> None: ...
+ author_in_authors: bool
+ def depart_author(self, node: nodes.author) -> None: ...
+ def visit_authors(self, node: nodes.authors) -> None: ...
+ def depart_authors(self, node: nodes.authors) -> None: ...
+ def visit_colspec(self, node: nodes.colspec) -> None: ...
+ def depart_colspec(self, node: nodes.colspec) -> None: ...
+ def is_compactable(self, node: nodes.Element) -> bool: ...
+ def visit_citation(self, node: nodes.citation) -> None: ...
+ def depart_citation(self, node: nodes.citation) -> None: ...
+ def visit_citation_reference(self, node: nodes.citation_reference) -> None: ...
+ def depart_citation_reference(self, node: nodes.citation_reference) -> None: ...
+ def visit_classifier(self, node: nodes.classifier) -> None: ...
+ def depart_classifier(self, node: nodes.classifier) -> None: ...
+ def visit_compound(self, node: nodes.compound) -> None: ...
+ def depart_compound(self, node: nodes.compound) -> None: ...
+ def visit_definition(self, node: nodes.definition) -> None: ...
+ def depart_definition(self, node: nodes.definition) -> None: ...
+ def visit_definition_list(self, node: nodes.definition_list) -> None: ...
+ def depart_definition_list(self, node: nodes.definition_list) -> None: ...
+ def visit_definition_list_item(self, node: nodes.definition_list_item) -> None: ...
+ def depart_definition_list_item(self, node: nodes.definition_list_item) -> None: ...
+ def visit_description(self, node: nodes.description) -> None: ...
+ def depart_description(self, node: nodes.description) -> None: ...
+ in_docinfo: bool
+ def visit_docinfo(self, node: nodes.docinfo) -> None: ...
+ docinfo: Incomplete
+ body: Incomplete
+ def depart_docinfo(self, node: nodes.docinfo) -> None: ...
+ def visit_docinfo_item(self, node, name, meta: bool = True) -> None: ...
+ def depart_docinfo_item(self) -> None: ...
+ def visit_doctest_block(self, node) -> None: ...
+ def depart_doctest_block(self, node) -> None: ...
+ def visit_entry(self, node) -> None: ...
+ def depart_entry(self, node) -> None: ...
+ compact_p: Incomplete
+ compact_simple: Incomplete
+ def visit_enumerated_list(self, node) -> None: ...
+ def depart_enumerated_list(self, node) -> None: ...
+ def visit_field(self, node) -> None: ...
+ def depart_field(self, node) -> None: ...
+ def visit_field_body(self, node) -> None: ...
+ def depart_field_body(self, node) -> None: ...
+ compact_field_list: bool
+ def visit_field_list(self, node: nodes.field_list) -> None: ...
+ def depart_field_list(self, node: nodes.field_list) -> None: ...
+ def visit_field_name(self, node: nodes.field_name) -> None: ...
+ def depart_field_name(self, node: nodes.field_name) -> None: ...
+ def visit_footnote(self, node: nodes.footnote) -> None: ...
+ def footnote_backrefs(self, node: nodes.footnote) -> None: ...
+ def depart_footnote(self, node: nodes.footnote) -> None: ...
+ def visit_footnote_reference(self, node: nodes.footnote_reference) -> None: ...
+ def depart_footnote_reference(self, node: nodes.footnote_reference) -> None: ...
+ def visit_generated(self, node: nodes.generated) -> None: ...
+ def visit_image(self, node: nodes.image) -> None: ...
+ def depart_image(self, node: nodes.image) -> None: ...
+ def visit_label(self, node: nodes.label) -> None: ...
+ def depart_label(self, node: nodes.label) -> None: ...
+ def visit_list_item(self, node: nodes.list_item) -> None: ...
+ def depart_list_item(self, node: nodes.list_item) -> None: ...
+ def visit_literal(self, node: nodes.literal) -> None: ...
+ def depart_literal(self, node: nodes.literal) -> None: ...
+ def visit_literal_block(self, node: nodes.literal_block) -> None: ...
+ def depart_literal_block(self, node: nodes.literal_block) -> None: ...
+ def visit_option_group(self, node: nodes.option_group) -> None: ...
+ def depart_option_group(self, node: nodes.option_group) -> None: ...
+ def visit_option_list(self, node: nodes.option_list) -> None: ...
+ def depart_option_list(self, node: nodes.option_list) -> None: ...
+ def visit_option_list_item(self, node: nodes.option_list_item) -> None: ...
+ def depart_option_list_item(self, node: nodes.option_list_item) -> None: ...
+ def should_be_compact_paragraph(self, node: nodes.Element) -> bool: ...
+ def visit_paragraph(self, node: nodes.paragraph) -> None: ...
+ def depart_paragraph(self, node: nodes.paragraph) -> None: ...
+ in_sidebar: bool
+ def visit_sidebar(self, node: nodes.sidebar) -> None: ...
+ def depart_sidebar(self, node: nodes.sidebar) -> None: ...
+ def visit_subscript(self, node: nodes.subscript) -> None: ...
+ def depart_subscript(self, node: nodes.subscript) -> None: ...
+ in_document_title: int
+ def visit_subtitle(self, node: nodes.subtitle) -> None: ...
+ subtitle: list[Incomplete]
+ def depart_subtitle(self, node: nodes.subtitle) -> None: ...
+ def visit_superscript(self, node: nodes.superscript) -> None: ...
+ def depart_superscript(self, node: nodes.superscript) -> None: ...
+ def visit_system_message(self, node: nodes.system_message) -> None: ...
+ def depart_system_message(self, node: nodes.system_message) -> None: ...
+ def visit_table(self, node: nodes.table) -> None: ...
+ def depart_table(self, node: nodes.table) -> None: ...
+ def visit_tbody(self, node: nodes.tbody) -> None: ...
+ def depart_tbody(self, node: nodes.tbody) -> None: ...
+ def visit_term(self, node: nodes.term) -> None: ...
+ def depart_term(self, node: nodes.term) -> None: ...
+ def visit_thead(self, node: nodes.thead) -> None: ...
+ def depart_thead(self, node: nodes.thead) -> None: ...
+ def section_title_tags(self, node: nodes.Element) -> tuple[str, str]: ...
+
+class SimpleListChecker(_html_base.SimpleListChecker):
+ def visit_list_item(self, node: nodes.list_item) -> None: ...
+ def visit_paragraph(self, node: nodes.paragraph) -> None: ...
+ def visit_definition_list(self, node: nodes.definition_list) -> None: ...
+ def visit_docinfo(self, node: nodes.docinfo) -> None: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/html5_polyglot.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/html5_polyglot.pyi
deleted file mode 100644
index 5b0f74feb261..000000000000
--- a/python/helpers/typeshed/stubs/docutils/docutils/writers/html5_polyglot.pyi
+++ /dev/null
@@ -1 +0,0 @@
-def __getattr__(name: str): ... # incomplete module
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/html5_polyglot/__init__.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/html5_polyglot/__init__.pyi
new file mode 100644
index 000000000000..dd59417aa099
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/writers/html5_polyglot/__init__.pyi
@@ -0,0 +1,16 @@
+from pathlib import Path
+from typing import ClassVar, Final
+
+from docutils.writers import _html_base
+
+__docformat__: Final = "reStructuredText"
+
+class Writer(_html_base.Writer):
+ default_stylesheets: ClassVar[list[str]]
+ default_stylesheet_dirs: ClassVar[list[str]]
+ default_template: ClassVar[Path]
+ translator_class: type[HTMLTranslator]
+
+class HTMLTranslator(_html_base.HTMLTranslator):
+ supported_block_tags: set[str]
+ supported_inline_tags: set[str]
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/latex2e.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/latex2e.pyi
deleted file mode 100644
index 69f1fda5bc6f..000000000000
--- a/python/helpers/typeshed/stubs/docutils/docutils/writers/latex2e.pyi
+++ /dev/null
@@ -1,19 +0,0 @@
-from typing import ClassVar
-
-from docutils.utils import Reporter
-
-class Babel:
- language_codes: ClassVar[dict[str, str]]
- warn_msg: ClassVar[str]
- active_chars: ClassVar[dict[str, str]]
-
- reporter: Reporter | None
- language: str
- otherlanguages: dict[str, str]
-
- def __init__(self, language_code: str, reporter: Reporter | None = None) -> None: ...
- def __call__(self) -> str: ...
- def language_name(self, language_code: str) -> str: ...
- def get_language(self) -> str: ...
-
-def __getattr__(name: str): ... # incomplete module
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/latex2e/__init__.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/latex2e/__init__.pyi
new file mode 100644
index 000000000000..a66025fc35c6
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/writers/latex2e/__init__.pyi
@@ -0,0 +1,421 @@
+import re
+from _typeshed import Incomplete, StrPath
+from collections.abc import Callable, Iterable
+from io import TextIOWrapper
+from pathlib import Path
+from typing import ClassVar, Final, Literal, NoReturn, TypeVar, overload
+from typing_extensions import deprecated
+
+from docutils import nodes
+from docutils.frontend import Values
+from docutils.languages import _LanguageModule
+from docutils.utils import Reporter
+from docutils.writers import Writer as _Writer
+
+_K = TypeVar("_K")
+_V = TypeVar("_V")
+
+__docformat__: Final = "reStructuredText"
+
+LATEX_WRITER_DIR: Final[Path]
+
+class Writer(_Writer[str]):
+ default_template: ClassVar[str]
+ default_template_path: ClassVar[Path]
+ default_preamble: ClassVar[str]
+ table_style_values: ClassVar[list[str]]
+ relative_path_settings: ClassVar[tuple[str, ...]]
+ settings_defaults: ClassVar[dict[str, int]]
+ config_section: ClassVar[str]
+ config_section_dependencies: ClassVar[tuple[str, ...]]
+ head_parts: ClassVar[tuple[str, ...]]
+ visitor_attributes: ClassVar[tuple[str, ...]]
+ translator_class: type[LaTeXTranslator]
+
+class Babel:
+ language_codes: ClassVar[dict[str, str]]
+ warn_msg: ClassVar[str]
+ active_chars: ClassVar[dict[str, str]]
+
+ reporter: Reporter | None
+ language: str
+ otherlanguages: dict[str, str | bool]
+ setup: list[str]
+
+ def __init__(self, language_code: str, reporter: Reporter | None = None) -> None: ...
+ def __call__(self) -> str: ...
+ def language_name(self, language_code: str) -> str: ...
+ def get_language(self) -> str: ...
+
+@deprecated("Deprecated and will be removed in Docutils 0.24.")
+class SortableDict(dict[_K, _V]):
+ def sortedkeys(self) -> list[_K]: ...
+ def sortedvalues(self) -> list[_V]: ...
+
+class PreambleCmds:
+ ch: ClassVar[str]
+ color: ClassVar[str]
+ float: ClassVar[str]
+ linking: ClassVar[str]
+ minitoc: ClassVar[str]
+ table: ClassVar[str]
+ table_columnwidth: ClassVar[str]
+ textcomp: ClassVar[str]
+ abstract_legacy: ClassVar[str]
+ admonition_legacy: ClassVar[str]
+ error_legacy: ClassVar[str]
+ title_legacy: ClassVar[str]
+ toc_list: ClassVar[str]
+ ttem: ClassVar[str]
+ duclass: ClassVar[str]
+ providelength: ClassVar[str]
+ abstract: ClassVar[str]
+ dedication: ClassVar[str]
+ docinfo: ClassVar[str]
+ error: ClassVar[str]
+ highlight_rules: ClassVar[str]
+ admonition: ClassVar[str]
+ fieldlist: ClassVar[str]
+ footnotes: ClassVar[str]
+ inline: ClassVar[str]
+ legend: ClassVar[str]
+ lineblock: ClassVar[str]
+ optionlist: ClassVar[str]
+ rubric: ClassVar[str]
+ sidebar: ClassVar[str]
+ title: ClassVar[str]
+ subtitle: ClassVar[str]
+ documentsubtitle: ClassVar[str]
+ titlereference: ClassVar[str]
+ transition: ClassVar[str]
+ secnumdepth: ClassVar[str]
+ rem: ClassVar[str]
+ vmin: ClassVar[str]
+ vmax: ClassVar[str]
+
+fp: TextIOWrapper
+line: str
+block_name: str
+definitions: str
+
+class CharMaps:
+ alltt: ClassVar[dict[int, str]]
+ special: ClassVar[dict[int, str]]
+ unsupported_unicode: ClassVar[dict[int, str]]
+ utf8_supported_unicode: ClassVar[dict[int, str]]
+ textcomp: ClassVar[dict[int, str]]
+ pifont: ClassVar[dict[int, str]]
+
+class DocumentClass:
+ document_class: str
+ sections: list[str]
+ def __init__(self, document_class: str, with_part: bool = False) -> None: ...
+ def section(self, level: int) -> str: ...
+ def latex_section_depth(self, depth: int) -> int: ...
+
+class Table:
+ legacy_column_widths: bool
+ caption: list[str]
+ stubs: list[Incomplete]
+ colwidths_auto: bool
+ borders: str
+ def __init__(self, translator: LaTeXTranslator, latex_type: str) -> None: ...
+ def open(self) -> None: ...
+ def close(self) -> None: ...
+ def is_open(self) -> bool: ...
+ def set_table_style(self, node, settings) -> None: ...
+ def get_latex_type(self) -> str: ...
+ def set(self, attr, value) -> None: ...
+ def get(self, attr): ...
+ def get_vertical_bar(self) -> Literal["|", ""]: ...
+ def get_opening(self, width: str = r"\linewidth") -> str: ...
+ def get_closing(self) -> str: ...
+ def visit_colspec(self, node: nodes.colspec) -> None: ...
+ def get_colspecs(self, node: nodes.Element) -> str: ...
+ def get_column_width(self) -> str: ...
+ def get_multicolumn_width(self, start: int, len_: int) -> str: ...
+ def need_recurse(self) -> bool | Literal[0]: ...
+ def visit_thead(self) -> list[str]: ...
+ def depart_thead(self) -> list[str]: ...
+ def visit_row(self) -> None: ...
+ def depart_row(self) -> list[str]: ...
+ def set_rowspan(self, cell, value) -> None: ...
+ def get_rowspan(self, cell): ...
+ def get_entry_number(self) -> int: ...
+ def visit_entry(self) -> None: ...
+ def is_stub_column(self): ...
+
+class LaTeXTranslator(nodes.NodeVisitor):
+ is_xetex: ClassVar[bool]
+ compound_enumerators: ClassVar[bool]
+ section_prefix_for_enumerators: ClassVar[bool]
+ section_enumerator_separator: ClassVar[str]
+ has_latex_toc: ClassVar[bool]
+ section_level: ClassVar[int]
+ inside_citation_reference_label: ClassVar[bool]
+ verbatim: ClassVar[bool]
+ insert_non_breaking_blanks: ClassVar[bool]
+ insert_newline: ClassVar[bool]
+ literal: ClassVar[bool]
+ alltt: ClassVar[bool]
+ TITLEDATA_NODES: ClassVar[tuple[type[nodes.Element], ...]]
+
+ warn: Callable[..., nodes.system_message]
+ error: Callable[..., nodes.system_message]
+ settings: Values
+ latex_encoding: str
+ use_latex_toc: Incomplete
+ use_latex_docinfo: Incomplete
+ use_latex_citations: Incomplete
+ reference_label: Incomplete
+ hyperlink_color: Incomplete
+ font_encoding: str
+ literal_block_env: str
+ literal_block_options: str
+ bibtex: Incomplete
+ language_module: _LanguageModule
+ babel: Babel
+ author_separator: str
+ documentoptions: str
+ d_class: DocumentClass
+ graphicx_package: str
+ docutils_footnotes: Incomplete
+ head_prefix: list[str]
+ requirements: SortableDict[str, str] | list[str]
+ latex_preamble: list[Incomplete]
+ fallbacks: SortableDict[str, str] | list[str]
+ pdfsetup: list[str]
+ title: list[Incomplete]
+ subtitle: list[Incomplete]
+ titledata: list[Incomplete]
+ body_pre_docinfo: list[Incomplete]
+ docinfo: list[Incomplete]
+ dedication: list[Incomplete]
+ abstract: list[Incomplete]
+ body: list[Incomplete]
+ context: list[Incomplete]
+ title_labels: list[Incomplete]
+ subtitle_labels: list[Incomplete]
+ author_stack: list[Incomplete]
+ date: list[Incomplete]
+ pdfauthor: list[Incomplete]
+ pdfinfo: list[Incomplete]
+ table_stack: list[Incomplete]
+ active_table: Table
+ out: list[Incomplete]
+ out_stack: list[Incomplete]
+ fallback_stylesheet: bool
+ stylesheet: list[str]
+ hyperref_options: str
+
+ def __init__(self, document: nodes.document, babel_class: type = ...) -> None: ...
+ def stylesheet_call(self, path: StrPath) -> str: ...
+ def to_latex_encoding(self, docutils_encoding: str) -> str: ...
+ def language_label(self, docutil_label: str) -> str: ...
+ def encode(self, text: str) -> str: ...
+ def attval(self, text: str, whitespace: re.Pattern[str] = ...) -> str: ...
+ def is_inline(self, node: nodes.Node) -> bool: ...
+ def ids_to_labels(
+ self, node: nodes.Element, set_anchor: bool = True, protect: bool = False, newline: bool = False
+ ) -> list[Incomplete]: ...
+ def append_hypertargets(self, node: nodes.Element) -> None: ...
+ def set_align_from_classes(self, node) -> None: ...
+ def insert_align_declaration(self, node: nodes.Element, default: str | None = None) -> None: ...
+ def provide_fallback(self, feature: str, key: str | None = None) -> None: ...
+ def duclass_open(self, node) -> None: ...
+ def duclass_close(self, node) -> None: ...
+ def push_output_collector(self, new_out) -> None: ...
+ def pop_output_collector(self) -> None: ...
+ def term_postfix(self, node: nodes.Element) -> str: ...
+ def visit_Text(self, node: nodes.Text) -> None: ...
+ def depart_Text(self, node: nodes.Text) -> None: ...
+ def visit_abbreviation(self, node: nodes.abbreviation) -> None: ...
+ def depart_abbreviation(self, node: nodes.abbreviation) -> None: ...
+ def visit_acronym(self, node: nodes.acronym) -> None: ...
+ def depart_acronym(self, node: nodes.acronym) -> None: ...
+ def visit_address(self, node: nodes.address) -> None: ...
+ def depart_address(self, node: nodes.address) -> None: ...
+ def visit_admonition(self, node: nodes.admonition) -> None: ...
+ def depart_admonition(self, node: nodes.admonition) -> None: ...
+ def visit_author(self, node: nodes.author) -> None: ...
+ def depart_author(self, node: nodes.author) -> None: ...
+ def visit_authors(self, node: nodes.authors) -> None: ...
+ def depart_authors(self, node: nodes.authors) -> None: ...
+ def visit_block_quote(self, node: nodes.block_quote) -> None: ...
+ def depart_block_quote(self, node: nodes.block_quote) -> None: ...
+ def visit_bullet_list(self, node: nodes.bullet_list) -> None: ...
+ def depart_bullet_list(self, node: nodes.bullet_list) -> None: ...
+ def visit_superscript(self, node: nodes.superscript) -> None: ...
+ def depart_superscript(self, node: nodes.superscript) -> None: ...
+ def visit_subscript(self, node: nodes.subscript) -> None: ...
+ def depart_subscript(self, node: nodes.subscript) -> None: ...
+ def visit_caption(self, node: nodes.caption) -> None: ...
+ def depart_caption(self, node: nodes.caption) -> None: ...
+ def visit_title_reference(self, node: nodes.title_reference) -> None: ...
+ def depart_title_reference(self, node: nodes.title_reference) -> None: ...
+ def visit_citation(self, node: nodes.citation) -> None: ...
+ def depart_citation(self, node: nodes.citation) -> None: ...
+ def visit_citation_reference(self, node: nodes.citation_reference) -> None: ...
+ def depart_citation_reference(self, node: nodes.citation_reference) -> None: ...
+ def visit_classifier(self, node: nodes.classifier) -> None: ...
+ def depart_classifier(self, node: nodes.classifier) -> None: ...
+ def visit_colspec(self, node: nodes.colspec) -> None: ...
+ def depart_colspec(self, node: nodes.colspec) -> None: ...
+ def visit_comment(self, node: nodes.comment) -> None: ...
+ def depart_comment(self, node: nodes.comment) -> None: ...
+ def visit_compound(self, node: nodes.compound) -> None: ...
+ def depart_compound(self, node: nodes.compound) -> None: ...
+ def visit_contact(self, node: nodes.contact) -> None: ...
+ def depart_contact(self, node: nodes.contact) -> None: ...
+ def visit_container(self, node: nodes.container) -> None: ...
+ def depart_container(self, node: nodes.container) -> None: ...
+ def visit_copyright(self, node: nodes.copyright) -> None: ...
+ def depart_copyright(self, node: nodes.copyright) -> None: ...
+ def visit_date(self, node: nodes.date) -> None: ...
+ def depart_date(self, node: nodes.date) -> None: ...
+ def visit_decoration(self, node: nodes.decoration) -> None: ...
+ def depart_decoration(self, node: nodes.decoration) -> None: ...
+ def visit_definition(self, node: nodes.definition) -> None: ...
+ def depart_definition(self, node: nodes.definition) -> None: ...
+ def visit_definition_list(self, node: nodes.definition_list) -> None: ...
+ def depart_definition_list(self, node: nodes.definition_list) -> None: ...
+ def visit_definition_list_item(self, node: nodes.definition_list_item) -> None: ...
+ def depart_definition_list_item(self, node: nodes.definition_list_item) -> None: ...
+ def visit_description(self, node: nodes.description) -> None: ...
+ def depart_description(self, node: nodes.description) -> None: ...
+ def visit_docinfo(self, node: nodes.docinfo) -> None: ...
+ def depart_docinfo(self, node: nodes.docinfo) -> None: ...
+ @overload
+ def visit_docinfo_item(self, node) -> None: ...
+ @overload
+ @deprecated("The `name` parameter is deprecated and will be removed in Docutils 0.24.")
+ def visit_docinfo_item(self, node, name: str | None) -> None: ...
+ def depart_docinfo_item(self, node) -> None: ...
+ def visit_doctest_block(self, node: nodes.doctest_block) -> None: ...
+ def depart_doctest_block(self, node: nodes.doctest_block) -> None: ...
+ def visit_document(self, node: nodes.document) -> None: ...
+ def depart_document(self, node: nodes.document) -> None: ...
+ def make_title(self) -> None: ...
+ def append_bibliogaphy(self) -> None: ...
+ def visit_emphasis(self, node: nodes.emphasis) -> None: ...
+ def depart_emphasis(self, node: nodes.emphasis) -> None: ...
+ def insert_additional_table_colum_delimiters(self) -> None: ...
+ def visit_entry(self, node: nodes.entry) -> None: ...
+ def depart_entry(self, node: nodes.entry) -> None: ...
+ def visit_row(self, node: nodes.row) -> None: ...
+ def depart_row(self, node: nodes.row) -> None: ...
+ def visit_enumerated_list(self, node: nodes.enumerated_list) -> None: ...
+ def depart_enumerated_list(self, node: nodes.enumerated_list) -> None: ...
+ def visit_field(self, node: nodes.field) -> None: ...
+ def depart_field(self, node: nodes.field) -> None: ...
+ def visit_field_body(self, node: nodes.field_body) -> None: ...
+ def depart_field_body(self, node: nodes.field_body) -> None: ...
+ def visit_field_list(self, node: nodes.field_list) -> None: ...
+ def depart_field_list(self, node: nodes.field_list) -> None: ...
+ def visit_field_name(self, node: nodes.field_name) -> None: ...
+ def depart_field_name(self, node: nodes.field_name) -> None: ...
+ def visit_figure(self, node: nodes.figure) -> None: ...
+ def depart_figure(self, node: nodes.figure) -> None: ...
+ def visit_footer(self, node: nodes.footer) -> None: ...
+ def depart_footer(self, node: nodes.footer) -> None: ...
+ def visit_footnote(self, node: nodes.footnote) -> None: ...
+ def depart_footnote(self, node: nodes.footnote) -> None: ...
+ def visit_footnote_reference(self, node: nodes.footnote_reference) -> None: ...
+ def depart_footnote_reference(self, node: nodes.footnote_reference) -> None: ...
+ def label_delim(self, node, bracket, superscript) -> None: ...
+ def visit_label(self, node: nodes.label) -> None: ...
+ def depart_label(self, node: nodes.label) -> None: ...
+ def visit_generated(self, node: nodes.generated) -> None: ...
+ def depart_generated(self, node: nodes.generated) -> None: ...
+ def visit_header(self, node: nodes.header) -> None: ...
+ def depart_header(self, node: nodes.header) -> None: ...
+ def to_latex_length(self, length_str: str, node: nodes.Node | None = None) -> str: ...
+ def visit_image(self, node: nodes.image) -> None: ...
+ def depart_image(self, node: nodes.image) -> None: ...
+ def visit_inline(self, node: nodes.inline) -> None: ...
+ def depart_inline(self, node: nodes.inline) -> None: ...
+ def visit_legend(self, node: nodes.legend) -> None: ...
+ def depart_legend(self, node: nodes.legend) -> None: ...
+ def visit_line(self, node: nodes.line) -> None: ...
+ def depart_line(self, node: nodes.line) -> None: ...
+ def visit_line_block(self, node: nodes.line_block) -> None: ...
+ def depart_line_block(self, node: nodes.line_block) -> None: ...
+ def visit_list_item(self, node: nodes.list_item) -> None: ...
+ def depart_list_item(self, node: nodes.list_item) -> None: ...
+ def visit_literal(self, node: nodes.literal) -> None: ...
+ def depart_literal(self, node: nodes.literal) -> None: ...
+ def is_plaintext(self, node) -> bool: ...
+ def visit_literal_block(self, node: nodes.literal_block) -> None: ...
+ def depart_literal_block(self, node: nodes.literal_block) -> None: ...
+ def visit_meta(self, node: nodes.meta) -> None: ...
+ def depart_meta(self, node: nodes.meta) -> None: ...
+ def visit_math(self, node: nodes.math, math_env: str = "$") -> None: ...
+ def depart_math(self, node: nodes.math) -> None: ...
+ def visit_math_block(self, node: nodes.math_block) -> None: ...
+ def depart_math_block(self, node: nodes.math_block) -> None: ...
+ def visit_option(self, node: nodes.option) -> None: ...
+ def depart_option(self, node: nodes.option) -> None: ...
+ def visit_option_argument(self, node: nodes.option_argument) -> None: ...
+ def depart_option_argument(self, node: nodes.option_argument) -> None: ...
+ def visit_option_group(self, node: nodes.option_group) -> None: ...
+ def depart_option_group(self, node: nodes.option_group) -> None: ...
+ def visit_option_list(self, node: nodes.option_list) -> None: ...
+ def depart_option_list(self, node: nodes.option_list) -> None: ...
+ def visit_option_list_item(self, node: nodes.option_list_item) -> None: ...
+ def depart_option_list_item(self, node: nodes.option_list_item) -> None: ...
+ def visit_option_string(self, node: nodes.option_string) -> None: ...
+ def depart_option_string(self, node: nodes.option_string) -> None: ...
+ def visit_organization(self, node: nodes.organization) -> None: ...
+ def depart_organization(self, node: nodes.organization) -> None: ...
+ def visit_paragraph(self, node: nodes.paragraph) -> None: ...
+ def depart_paragraph(self, node: nodes.paragraph) -> None: ...
+ def visit_problematic(self, node: nodes.problematic) -> None: ...
+ def depart_problematic(self, node: nodes.problematic) -> None: ...
+ def visit_raw(self, node: nodes.raw) -> None: ...
+ def depart_raw(self, node: nodes.raw) -> None: ...
+ def has_unbalanced_braces(self, string: Iterable[str]) -> bool: ...
+ def visit_reference(self, node: nodes.reference) -> None: ...
+ def depart_reference(self, node: nodes.reference) -> None: ...
+ def visit_revision(self, node: nodes.revision) -> None: ...
+ def depart_revision(self, node: nodes.revision) -> None: ...
+ def visit_rubric(self, node: nodes.rubric) -> None: ...
+ def depart_rubric(self, node: nodes.rubric) -> None: ...
+ def visit_section(self, node: nodes.section) -> None: ...
+ def depart_section(self, node: nodes.section) -> None: ...
+ def visit_sidebar(self, node: nodes.sidebar) -> None: ...
+ def depart_sidebar(self, node: nodes.sidebar) -> None: ...
+ attribution_formats: dict[str, tuple[str, str]]
+ def visit_attribution(self, node: nodes.attribution) -> None: ...
+ def depart_attribution(self, node: nodes.attribution) -> None: ...
+ def visit_status(self, node: nodes.status) -> None: ...
+ def depart_status(self, node: nodes.status) -> None: ...
+ def visit_strong(self, node: nodes.strong) -> None: ...
+ def depart_strong(self, node: nodes.strong) -> None: ...
+ def visit_substitution_definition(self, node: nodes.substitution_definition) -> None: ...
+ def visit_substitution_reference(self, node: nodes.substitution_reference) -> None: ...
+ def visit_subtitle(self, node: nodes.subtitle) -> None: ...
+ def depart_subtitle(self, node: nodes.subtitle) -> None: ...
+ def visit_system_message(self, node: nodes.system_message) -> None: ...
+ def depart_system_message(self, node: nodes.system_message) -> None: ...
+ def visit_table(self, node: nodes.table) -> None: ...
+ def depart_table(self, node: nodes.table) -> None: ...
+ def visit_target(self, node: nodes.target) -> None: ...
+ def depart_target(self, node: nodes.target) -> None: ...
+ def visit_tbody(self, node: nodes.tbody) -> None: ...
+ def depart_tbody(self, node: nodes.tbody) -> None: ...
+ def visit_term(self, node: nodes.term) -> None: ...
+ def depart_term(self, node: nodes.term) -> None: ...
+ def visit_tgroup(self, node: nodes.tgroup) -> None: ...
+ def depart_tgroup(self, node: nodes.tgroup) -> None: ...
+ def thead_depth(self) -> int: ...
+ def visit_thead(self, node: nodes.thead) -> None: ...
+ def visit_title(self, node: nodes.title) -> None: ...
+ def depart_title(self, node: nodes.title) -> None: ...
+ def visit_contents(self, node) -> None: ...
+ def visit_topic(self, node: nodes.topic) -> None: ...
+ def depart_topic(self, node: nodes.topic) -> None: ...
+ def visit_transition(self, node: nodes.transition) -> None: ...
+ def depart_transition(self, node: nodes.transition) -> None: ...
+ def visit_version(self, node: nodes.version) -> None: ...
+ def depart_version(self, node: nodes.version) -> None: ...
+ def unimplemented_visit(self, node: nodes.Node) -> NoReturn: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/manpage.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/manpage.pyi
index c56336d488a7..6eb88a13c497 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/writers/manpage.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/writers/manpage.pyi
@@ -1,19 +1,252 @@
import re
from _typeshed import Incomplete
from collections.abc import Callable
-from typing import Protocol, type_check_only
-from typing_extensions import Never
+from typing import ClassVar, Final, NoReturn, Protocol, type_check_only
-from docutils import nodes
+from docutils import nodes, writers
+from docutils.frontend import Values
+from docutils.languages import _LanguageModule
@type_check_only
class _RegexPatternSub(Protocol):
# Matches the signature of the bound instance method `re.Pattern[str].sub` exactly
def __call__(self, /, repl: str | Callable[[re.Match[str]], str], string: str, count: int = 0) -> str: ...
-class Translator(nodes.NodeVisitor):
- def visit_admonition(self, node: nodes.admonition, name: str | None = None) -> None: ...
- def visit_comment(self, node: nodes.comment, sub: _RegexPatternSub = ...) -> Never: ...
- def __getattr__(self, name: str, /) -> Incomplete: ...
+__docformat__: Final = "reStructuredText"
+FIELD_LIST_INDENT: Final[int]
+DEFINITION_LIST_INDENT: Final[int]
+OPTION_LIST_INDENT: Final[int]
+BLOCKQOUTE_INDENT: Final[float]
+LITERAL_BLOCK_INDENT: Final[float]
+MACRO_DEF: Final[str]
+NONPRINTING_BREAKPOINT: Final[str]
+NONBREAKING_INSERT_RE: Final[re.Pattern[str]]
+NONBREAKING_INSERT_RE2: Final[re.Pattern[str]]
-def __getattr__(name: str): ... # incomplete module
+def insert_URI_breakpoints(s: str) -> str: ...
+
+class Writer(writers.Writer[str]):
+ translator_class: type[Translator]
+
+class Table:
+ def __init__(self) -> None: ...
+ def new_row(self) -> None: ...
+ def append_separator(self, separator) -> None: ...
+ def append_cell(self, cell_lines: list[str]) -> None: ...
+ def as_list(self) -> list[str]: ...
+
+class Translator(nodes.NodeVisitor):
+ words_and_spaces: ClassVar[re.Pattern[str]]
+ possibly_a_roff_command: ClassVar[re.Pattern[str]]
+ document_start: ClassVar[str]
+ settings: Values
+ language: _LanguageModule
+ head: list[str]
+ body: list[str]
+ foot: list[str]
+ section_level: int
+ context: list[str | int]
+ topic_class: str
+ colspecs: list[nodes.colspec]
+ compact_p: int
+ compact_simple: Incomplete
+ header_written: int
+ authors: list[Incomplete]
+ defs: dict[str, tuple[str, ...]]
+ def comment_begin(self, text: str) -> str: ...
+ def comment(self, text: str) -> str: ...
+ def ensure_eol(self) -> None: ...
+ def ensure_c_eol(self) -> None: ...
+ def astext(self) -> str: ...
+ def deunicode(self, text: str) -> str: ...
+ def encode_special_chars(self, text: str) -> str: ...
+ def visit_Text(self, node: nodes.Text) -> None: ...
+ def depart_Text(self, node: nodes.Text) -> None: ...
+ def list_start(self, node) -> None: ...
+ def list_end(self) -> None: ...
+ def header(self) -> str: ...
+ def append_header(self) -> None: ...
+ def visit_address(self, node: nodes.address) -> None: ...
+ def depart_address(self, node: nodes.address) -> None: ...
+ def visit_admonition(self, node: nodes.admonition, name: str | None = None) -> None: ...
+ def depart_admonition(self, node: nodes.admonition) -> None: ...
+ def visit_attention(self, node: nodes.attention) -> None: ...
+ def depart_attention(self, node: nodes.attention) -> None: ...
+ def visit_docinfo_item(self, node: nodes.docinfo, name: str) -> None: ...
+ def depart_docinfo_item(self, node: nodes.docinfo) -> None: ...
+ def visit_author(self, node: nodes.author) -> None: ...
+ def depart_author(self, node: nodes.author) -> None: ...
+ def visit_authors(self, node: nodes.authors) -> None: ...
+ def depart_authors(self, node: nodes.authors) -> None: ...
+ def visit_block_quote(self, node: nodes.block_quote) -> None: ...
+ def depart_block_quote(self, node: nodes.block_quote) -> None: ...
+ def visit_bullet_list(self, node: nodes.bullet_list) -> None: ...
+ def depart_bullet_list(self, node: nodes.bullet_list) -> None: ...
+ def visit_caption(self, node: nodes.caption) -> None: ...
+ def depart_caption(self, node: nodes.caption) -> None: ...
+ def visit_caution(self, node: nodes.caution) -> None: ...
+ def depart_caution(self, node: nodes.caution) -> None: ...
+ def visit_citation(self, node: nodes.citation) -> None: ...
+ def depart_citation(self, node: nodes.citation) -> None: ...
+ def visit_citation_reference(self, node: nodes.citation_reference) -> None: ...
+ def visit_classifier(self, node: nodes.classifier) -> None: ...
+ def depart_classifier(self, node: nodes.classifier) -> None: ...
+ def visit_colspec(self, node: nodes.colspec) -> None: ...
+ def depart_colspec(self, node: nodes.colspec) -> None: ...
+ def write_colspecs(self) -> None: ...
+ def visit_comment(self, node: nodes.comment, sub: _RegexPatternSub = ...) -> None: ...
+ def visit_contact(self, node: nodes.contact) -> None: ...
+ def depart_contact(self, node: nodes.contact) -> None: ...
+ def visit_container(self, node: nodes.container) -> None: ...
+ def depart_container(self, node: nodes.container) -> None: ...
+ def visit_compound(self, node: nodes.compound) -> None: ...
+ def depart_compound(self, node: nodes.compound) -> None: ...
+ def visit_copyright(self, node: nodes.copyright) -> None: ...
+ def visit_danger(self, node: nodes.danger) -> None: ...
+ def depart_danger(self, node: nodes.danger) -> None: ...
+ def visit_date(self, node: nodes.date) -> None: ...
+ def visit_decoration(self, node: nodes.decoration) -> None: ...
+ def depart_decoration(self, node: nodes.decoration) -> None: ...
+ def visit_definition(self, node: nodes.definition) -> None: ...
+ def depart_definition(self, node: nodes.definition) -> None: ...
+ def visit_definition_list(self, node: nodes.definition_list) -> None: ...
+ def depart_definition_list(self, node: nodes.definition_list) -> None: ...
+ def visit_definition_list_item(self, node: nodes.definition_list_item) -> None: ...
+ def depart_definition_list_item(self, node: nodes.definition_list_item) -> None: ...
+ def visit_description(self, node: nodes.description) -> None: ...
+ def depart_description(self, node: nodes.description) -> None: ...
+ def visit_docinfo(self, node: nodes.docinfo) -> None: ...
+ def depart_docinfo(self, node: nodes.docinfo) -> None: ...
+ def visit_doctest_block(self, node: nodes.doctest_block) -> None: ...
+ def depart_doctest_block(self, node: nodes.doctest_block) -> None: ...
+ def visit_document(self, node: nodes.document) -> None: ...
+ def depart_document(self, node: nodes.document) -> None: ...
+ def visit_emphasis(self, node: nodes.emphasis) -> None: ...
+ def depart_emphasis(self, node: nodes.emphasis) -> None: ...
+ def visit_entry(self, node: nodes.entry) -> None: ...
+ def depart_entry(self, node: nodes.entry) -> None: ...
+ def visit_enumerated_list(self, node: nodes.enumerated_list) -> None: ...
+ def depart_enumerated_list(self, node: nodes.enumerated_list) -> None: ...
+ def visit_error(self, node: nodes.error) -> None: ...
+ def depart_error(self, node: nodes.error) -> None: ...
+ def visit_field(self, node: nodes.field) -> None: ...
+ def depart_field(self, node: nodes.field) -> None: ...
+ def visit_field_body(self, node: nodes.field_body) -> None: ...
+ def depart_field_body(self, node: nodes.field_body) -> None: ...
+ def visit_field_list(self, node: nodes.field_list) -> None: ...
+ def depart_field_list(self, node: nodes.field_list) -> None: ...
+ def visit_field_name(self, node: nodes.field_name) -> None: ...
+ def depart_field_name(self, node: nodes.field_name) -> None: ...
+ def visit_figure(self, node: nodes.figure) -> None: ...
+ def depart_figure(self, node: nodes.figure) -> None: ...
+ def visit_footer(self, node: nodes.footer) -> None: ...
+ def depart_footer(self, node: nodes.footer) -> None: ...
+ def visit_footnote(self, node: nodes.footnote) -> None: ...
+ def depart_footnote(self, node: nodes.footnote) -> None: ...
+ def footnote_backrefs(self, node) -> None: ...
+ def visit_footnote_reference(self, node: nodes.footnote_reference) -> None: ...
+ def depart_footnote_reference(self, node: nodes.footnote_reference) -> None: ...
+ def visit_generated(self, node: nodes.generated) -> None: ...
+ def depart_generated(self, node: nodes.generated) -> None: ...
+ def visit_header(self, node: nodes.header) -> None: ...
+ def depart_header(self, node: nodes.header) -> None: ...
+ def visit_hint(self, node: nodes.hint) -> None: ...
+ def depart_hint(self, node: nodes.hint) -> None: ...
+ def visit_subscript(self, node: nodes.subscript) -> None: ...
+ def depart_subscript(self, node: nodes.subscript) -> None: ...
+ def visit_superscript(self, node: nodes.superscript) -> None: ...
+ def depart_superscript(self, node: nodes.superscript) -> None: ...
+ def visit_attribution(self, node: nodes.attribution) -> None: ...
+ def depart_attribution(self, node: nodes.attribution) -> None: ...
+ def visit_image(self, node: nodes.image) -> None: ...
+ def visit_important(self, node: nodes.important) -> None: ...
+ def depart_important(self, node: nodes.important) -> None: ...
+ def visit_inline(self, node: nodes.inline) -> None: ...
+ def depart_inline(self, node: nodes.inline) -> None: ...
+ def visit_label(self, node: nodes.label) -> None: ...
+ def depart_label(self, node: nodes.label) -> None: ...
+ def visit_legend(self, node: nodes.legend) -> None: ...
+ def depart_legend(self, node: nodes.legend) -> None: ...
+ def visit_line_block(self, node: nodes.line_block) -> None: ...
+ def depart_line_block(self, node: nodes.line_block) -> None: ...
+ def visit_line(self, node: nodes.line) -> None: ...
+ def depart_line(self, node: nodes.line) -> None: ...
+ def visit_list_item(self, node: nodes.list_item) -> None: ...
+ def depart_list_item(self, node: nodes.list_item) -> None: ...
+ def visit_literal(self, node: nodes.literal) -> None: ...
+ def depart_literal(self, node: nodes.literal) -> None: ...
+ def visit_literal_block(self, node: nodes.literal_block) -> None: ...
+ def depart_literal_block(self, node: nodes.literal_block) -> None: ...
+ def visit_math(self, node: nodes.math) -> None: ...
+ def depart_math(self, node: nodes.math) -> None: ...
+ def visit_math_block(self, node: nodes.math_block) -> None: ...
+ def depart_math_block(self, node: nodes.math_block) -> None: ...
+ def visit_note(self, node: nodes.note) -> None: ...
+ def depart_note(self, node: nodes.note) -> None: ...
+ def indent(self, by: float = 0.5) -> None: ...
+ def dedent(self) -> None: ...
+ def visit_option_list(self, node: nodes.option_list) -> None: ...
+ def depart_option_list(self, node: nodes.option_list) -> None: ...
+ def visit_option_list_item(self, node: nodes.option_list_item) -> None: ...
+ def depart_option_list_item(self, node: nodes.option_list_item) -> None: ...
+ def visit_option_group(self, node: nodes.option_group) -> None: ...
+ def depart_option_group(self, node: nodes.option_group) -> None: ...
+ def visit_option(self, node: nodes.option) -> None: ...
+ def depart_option(self, node: nodes.option) -> None: ...
+ def visit_option_string(self, node: nodes.option_string) -> None: ...
+ def depart_option_string(self, node: nodes.option_string) -> None: ...
+ def visit_option_argument(self, node: nodes.option_argument) -> None: ...
+ def depart_option_argument(self, node: nodes.option_argument) -> None: ...
+ def visit_organization(self, node: nodes.organization) -> None: ...
+ def depart_organization(self, node: nodes.organization) -> None: ...
+ def first_child(self, node): ...
+ def visit_paragraph(self, node: nodes.paragraph) -> None: ...
+ def depart_paragraph(self, node: nodes.paragraph) -> None: ...
+ def visit_problematic(self, node: nodes.problematic) -> None: ...
+ def depart_problematic(self, node: nodes.problematic) -> None: ...
+ def visit_raw(self, node: nodes.raw) -> None: ...
+ def visit_revision(self, node: nodes.revision) -> None: ...
+ def depart_revision(self, node: nodes.revision) -> None: ...
+ def visit_row(self, node: nodes.row) -> None: ...
+ def depart_row(self, node: nodes.row) -> None: ...
+ def visit_section(self, node: nodes.section) -> None: ...
+ def depart_section(self, node: nodes.section) -> None: ...
+ def visit_status(self, node: nodes.status) -> None: ...
+ def depart_status(self, node: nodes.status) -> None: ...
+ def visit_strong(self, node: nodes.strong) -> None: ...
+ def depart_strong(self, node: nodes.strong) -> None: ...
+ def visit_substitution_definition(self, node: nodes.substitution_definition) -> None: ...
+ def visit_substitution_reference(self, node: nodes.substitution_reference) -> None: ...
+ def visit_subtitle(self, node: nodes.subtitle) -> None: ...
+ def depart_subtitle(self, node: nodes.subtitle) -> None: ...
+ def visit_system_message(self, node: nodes.system_message) -> None: ...
+ def depart_system_message(self, node: nodes.system_message) -> None: ...
+ def visit_table(self, node: nodes.table) -> None: ...
+ def depart_table(self, node: nodes.table) -> None: ...
+ def visit_target(self, node: nodes.target) -> None: ...
+ def visit_tbody(self, node: nodes.tbody) -> None: ...
+ def depart_tbody(self, node: nodes.tbody) -> None: ...
+ def visit_term(self, node: nodes.term) -> None: ...
+ def depart_term(self, node: nodes.term) -> None: ...
+ def visit_tgroup(self, node: nodes.tgroup) -> None: ...
+ def depart_tgroup(self, node: nodes.tgroup) -> None: ...
+ def visit_thead(self, node: nodes.thead) -> None: ...
+ def depart_thead(self, node: nodes.thead) -> None: ...
+ def visit_tip(self, node: nodes.tip) -> None: ...
+ def depart_tip(self, node: nodes.tip) -> None: ...
+ def visit_title(self, node: nodes.title) -> None: ...
+ def depart_title(self, node: nodes.title) -> None: ...
+ def visit_title_reference(self, node: nodes.title_reference) -> None: ...
+ def depart_title_reference(self, node: nodes.title_reference) -> None: ...
+ def visit_topic(self, node: nodes.topic) -> None: ...
+ def depart_topic(self, node: nodes.topic) -> None: ...
+ def visit_sidebar(self, node: nodes.sidebar) -> None: ...
+ def depart_sidebar(self, node: nodes.sidebar) -> None: ...
+ def visit_rubric(self, node: nodes.rubric) -> None: ...
+ def depart_rubric(self, node: nodes.rubric) -> None: ...
+ def visit_transition(self, node: nodes.transition) -> None: ...
+ def depart_transition(self, node: nodes.transition) -> None: ...
+ def visit_version(self, node: nodes.version) -> None: ...
+ def visit_warning(self, node: nodes.warning) -> None: ...
+ def depart_warning(self, node: nodes.warning) -> None: ...
+ def unimplemented_visit(self, node: nodes.Node) -> NoReturn: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/null.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/null.pyi
index 5b0f74feb261..f20c030b833c 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/writers/null.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/writers/null.pyi
@@ -1 +1,11 @@
-def __getattr__(name: str): ... # incomplete module
+from typing import ClassVar, Final
+
+from docutils import writers
+
+__docformat__: Final = "reStructuredText"
+
+class Writer(writers.UnfilteredWriter[str]):
+ supported: ClassVar[tuple[str, ...]]
+ config_section: ClassVar[str]
+ config_section_dependencies: ClassVar[tuple[str]]
+ def translate(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/odf_odt.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/odf_odt.pyi
deleted file mode 100644
index 5b0f74feb261..000000000000
--- a/python/helpers/typeshed/stubs/docutils/docutils/writers/odf_odt.pyi
+++ /dev/null
@@ -1 +0,0 @@
-def __getattr__(name: str): ... # incomplete module
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/odf_odt/__init__.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/odf_odt/__init__.pyi
new file mode 100644
index 000000000000..d9a6795a9438
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/writers/odf_odt/__init__.pyi
@@ -0,0 +1,426 @@
+import itertools
+import re
+import zipfile
+from _typeshed import FileDescriptorOrPath, Incomplete, ReadableBuffer, SizedBuffer, Unused
+from collections.abc import Generator
+from typing import ClassVar, Final, Literal
+from xml.etree import ElementTree
+
+from docutils import nodes, writers
+from docutils.frontend import Values
+from docutils.languages import _LanguageModule
+from docutils.readers import standalone
+
+__docformat__: Final = "reStructuredText"
+VERSION: Final[str]
+IMAGE_NAME_COUNTER: Final[itertools.count[int]]
+
+class _ElementInterfaceWrapper(ElementTree.Element):
+ def __init__(self, tag: str, attrib: dict[str, str] | None = None) -> None: ...
+ def setparent(self, parent) -> None: ...
+ def getparent(self): ...
+
+SPACES_PATTERN: Final[re.Pattern[str]]
+TABS_PATTERN: Final[re.Pattern[str]]
+FILL_PAT1: Final[re.Pattern[str]]
+FILL_PAT2: Final[re.Pattern[str]]
+TABLESTYLEPREFIX: Final[str]
+TABLENAMEDEFAULT: Final[str]
+TABLEPROPERTYNAMES: Final[tuple[str, ...]]
+GENERATOR_DESC: Final[str]
+NAME_SPACE_1: Final[str]
+CONTENT_NAMESPACE_DICT: Final[dict[str, str]]
+CNSD: Final[dict[str, str]]
+STYLES_NAMESPACE_DICT: Final[dict[str, str]]
+SNSD: Final[dict[str, str]]
+MANIFEST_NAMESPACE_DICT: Final[dict[str, str]]
+MANNSD: Final[dict[str, str]]
+META_NAMESPACE_DICT: Final[dict[str, str]]
+METNSD: Final[dict[str, str]]
+CONTENT_NAMESPACE_ATTRIB: Final[dict[str, str]]
+STYLES_NAMESPACE_ATTRIB: Final[dict[str, str]]
+MANIFEST_NAMESPACE_ATTRIB: Final[dict[str, str]]
+META_NAMESPACE_ATTRIB: Final[dict[str, str]]
+
+def Element(
+ tag: str, attrib: dict[str, str] | None = None, nsmap: Unused = None, nsdict: Unused = ...
+) -> _ElementInterfaceWrapper: ...
+def SubElement(
+ parent: _ElementInterfaceWrapper, tag: str, attrib: dict[str, str] | None = None, nsmap: Unused = None, nsdict: Unused = ...
+) -> _ElementInterfaceWrapper: ...
+def fix_ns(tag: str, attrib: dict[str, str], nsdict: Unused) -> tuple[str, dict[str, str]]: ...
+def add_ns(tag: str, nsdict: Unused = ...) -> str: ...
+def ToString(et: ElementTree.ElementTree) -> str: ...
+def escape_cdata(text: str) -> str: ...
+
+class TableStyle:
+ border: str | None
+ backgroundcolor: str | None
+ def __init__(self, border: str | None = None, backgroundcolor: str | None = None) -> None: ...
+ def get_border_(self): ...
+ def set_border_(self, border) -> None: ...
+ border_: Incomplete
+ def get_backgroundcolor_(self): ...
+ def set_backgroundcolor_(self, backgroundcolor) -> None: ...
+ backgroundcolor_: Incomplete
+
+BUILTIN_DEFAULT_TABLE_STYLE: TableStyle
+
+class ListLevel:
+ level: int
+ sibling_level: bool
+ nested_level: bool
+ def __init__(self, level: int, sibling_level: bool = True, nested_level: bool = True) -> None: ...
+ def get_sibling(self) -> bool: ...
+ def set_sibling(self, sibling_level: bool) -> None: ...
+ def get_nested(self) -> bool: ...
+ def set_nested(self, nested_level: bool) -> None: ...
+ def get_level(self) -> int: ...
+ def set_level(self, level: int) -> None: ...
+
+class Writer(writers.Writer[bytes]):
+ MIME_TYPE: ClassVar[str]
+ EXTENSION: ClassVar[str]
+ default_stylesheet: ClassVar[str]
+ default_stylesheet_path: ClassVar[str]
+ default_template: ClassVar[str]
+ default_template_path: ClassVar[str]
+ translator_class: type[ODFTranslator]
+ settings: Values
+ visitor: ODFTranslator
+ def assemble_my_parts(self) -> None: ...
+ def update_stylesheet(self, stylesheet_root, language_code: str | None, region_code: str | None): ...
+ def write_zip_str(
+ self, zfile: zipfile.ZipFile, name: str, bytes_: str | SizedBuffer, compress_type: int = zipfile.ZIP_DEFLATED
+ ) -> None: ...
+ def store_embedded_files(self, zfile: zipfile.ZipFile) -> None: ...
+ def get_settings(self) -> bytes: ...
+ def get_stylesheet(self) -> bytes: ...
+ def copy_from_stylesheet(self, outzipfile: zipfile.ZipFile) -> None: ...
+ def assemble_parts(self) -> None: ...
+ def create_manifest(self) -> str: ...
+ def create_meta(self) -> str: ...
+
+class ODFTranslator(nodes.GenericNodeVisitor):
+ used_styles: ClassVar[tuple[str, ...]]
+ settings: Values
+ language_code: str
+ language: _LanguageModule
+ format_map: dict[str, str]
+ section_level: int
+ section_count: int
+ content_tree: ElementTree.ElementTree
+ current_element: _ElementInterfaceWrapper
+ automatic_styles: _ElementInterfaceWrapper
+ body_text_element: _ElementInterfaceWrapper
+ paragraph_style_stack: list[str]
+ list_style_stack: list[str]
+ table_count: int
+ column_count: int
+ trace_level: int
+ optiontablestyles_generated: bool
+ field_name: Incomplete
+ field_element: Incomplete
+ title: str | None
+ image_count: int
+ image_style_count: int
+ image_dict: dict[str, tuple[str, str]]
+ embedded_file_list: list[Incomplete]
+ syntaxhighlighting: int
+ syntaxhighlight_lexer: str
+ header_content: list[Incomplete]
+ footer_content: list[Incomplete]
+ in_header: bool
+ in_footer: bool
+ blockstyle: str
+ in_table_of_contents: bool
+ table_of_content_index_body: _ElementInterfaceWrapper | None
+ list_level: int
+ def_list_level: int
+ footnote_ref_dict: dict[Incomplete, _ElementInterfaceWrapper]
+ footnote_list: list[tuple[Incomplete, Incomplete]]
+ footnote_chars_idx: int
+ footnote_level: int
+ pending_ids: Incomplete
+ in_paragraph: bool
+ found_doc_title: bool
+ bumped_list_level_stack: list[ListLevel]
+ meta_dict: dict[Incomplete, Incomplete]
+ line_block_level: int
+ line_indent_level: int
+ citation_id: Incomplete
+ style_index: int
+ str_stylesheet: str | bytes
+ str_stylesheetcontent: str | bytes | None
+ dom_stylesheet: ElementTree.Element | None
+ table_styles: dict[str, TableStyle] | None
+ in_citation: bool
+ inline_style_count_stack: list[int]
+ def get_str_stylesheet(self) -> str | bytes: ...
+ dom_stylesheetcontent: ElementTree.Element
+ def retrieve_styles(self, extension: str) -> None: ...
+ def extract_table_styles(self, styles_str: str | ReadableBuffer) -> dict[str, TableStyle]: ...
+ def get_property(self, stylenode: ElementTree.Element) -> str | None: ...
+ def add_doc_title(self) -> None: ...
+ def find_first_text_p(self, el: _ElementInterfaceWrapper) -> _ElementInterfaceWrapper | None: ...
+ def attach_page_style(self, el: _ElementInterfaceWrapper) -> None: ...
+ def rststyle(self, name: str, parameters: tuple[object, ...] = ()) -> str: ...
+ def generate_content_element(self, root: _ElementInterfaceWrapper) -> _ElementInterfaceWrapper: ...
+ def setup_page(self): ...
+ def get_dom_stylesheet(self) -> ElementTree.Element | None: ...
+ def setup_paper(self, root_el) -> None: ...
+ def add_header_footer(self, root_el) -> None: ...
+ code_none: int
+ code_field: int
+ code_text: int
+ field_pat: re.Pattern[str]
+ def create_custom_headfoot(self, parent: _ElementInterfaceWrapper, text: str, style_name, automatic_styles) -> None: ...
+ def make_field_element(
+ self, parent: _ElementInterfaceWrapper, text: str, style_name, automatic_styles
+ ) -> _ElementInterfaceWrapper | None: ...
+ def split_field_specifiers_iter(self, text: str) -> Generator[tuple[int, str]]: ...
+ def astext(self) -> str: ...
+ def content_astext(self) -> str: ...
+ def set_title(self, title: str) -> None: ...
+ def get_title(self) -> str | None: ...
+ def set_embedded_file_list(self, embedded_file_list) -> None: ...
+ def get_embedded_file_list(self): ...
+ def get_meta_dict(self): ...
+ def process_footnotes(self) -> None: ...
+ def append_child(
+ self, tag: str, attrib: dict[str, str] | None = None, parent: _ElementInterfaceWrapper | None = None
+ ) -> _ElementInterfaceWrapper: ...
+ def append_p(self, style: str, text: str | None = None) -> _ElementInterfaceWrapper: ...
+ def append_pending_ids(self, el: _ElementInterfaceWrapper) -> None: ...
+ def set_current_element(self, el: _ElementInterfaceWrapper) -> None: ...
+ def set_to_parent(self) -> None: ...
+ def generate_labeled_block(self, node: nodes.Node, label: str) -> _ElementInterfaceWrapper: ...
+ def generate_labeled_line(self, node: nodes.Node, label: str) -> _ElementInterfaceWrapper: ...
+ def encode(self, text: str) -> str: ...
+ def dispatch_visit(self, node: nodes.Element) -> None: ... # type: ignore[override]
+ def handle_basic_atts(self, node: nodes.Element) -> None: ...
+ def default_visit(self, node: nodes.Element) -> None: ... # type: ignore[override]
+ def default_departure(self, node: nodes.Element) -> None: ... # type: ignore[override]
+ def visit_Text(self, node: nodes.Text) -> None: ...
+ def depart_Text(self, node: nodes.Text) -> None: ...
+ def visit_address(self, node: nodes.address) -> None: ...
+ def depart_address(self, node: nodes.address) -> None: ...
+ def visit_author(self, node: nodes.author) -> None: ...
+ def depart_author(self, node: nodes.author) -> None: ...
+ def visit_authors(self, node: nodes.authors) -> None: ...
+ def depart_authors(self, node: nodes.authors) -> None: ...
+ def visit_contact(self, node: nodes.contact) -> None: ...
+ def depart_contact(self, node: nodes.contact) -> None: ...
+ def visit_copyright(self, node: nodes.copyright) -> None: ...
+ def depart_copyright(self, node: nodes.copyright) -> None: ...
+ def visit_date(self, node: nodes.date) -> None: ...
+ def depart_date(self, node: nodes.date) -> None: ...
+ def visit_organization(self, node: nodes.organization) -> None: ...
+ def depart_organization(self, node: nodes.organization) -> None: ...
+ def visit_status(self, node: nodes.status) -> None: ...
+ def depart_status(self, node: nodes.status) -> None: ...
+ def visit_revision(self, node: nodes.revision) -> None: ...
+ def depart_revision(self, node: nodes.revision) -> None: ...
+ def visit_version(self, node: nodes.version) -> None: ...
+ def depart_version(self, node: nodes.version) -> None: ...
+ def visit_attribution(self, node: nodes.attribution) -> None: ...
+ def depart_attribution(self, node: nodes.attribution) -> None: ...
+ def visit_block_quote(self, node: nodes.block_quote) -> None: ...
+ def depart_block_quote(self, node: nodes.block_quote) -> None: ...
+ def visit_bullet_list(self, node: nodes.bullet_list) -> None: ...
+ def depart_bullet_list(self, node: nodes.bullet_list) -> None: ...
+ def visit_caption(self, node: nodes.caption) -> None: ...
+ def depart_caption(self, node: nodes.caption) -> None: ...
+ def visit_comment(self, node: nodes.comment) -> None: ...
+ def depart_comment(self, node: nodes.comment) -> None: ...
+ def visit_compound(self, node: nodes.compound) -> None: ...
+ def depart_compound(self, node: nodes.compound) -> None: ...
+ def visit_container(self, node: nodes.container) -> None: ...
+ def depart_container(self, node: nodes.container) -> None: ...
+ def visit_decoration(self, node: nodes.decoration) -> None: ...
+ def depart_decoration(self, node: nodes.decoration) -> None: ...
+ def visit_definition_list(self, node: nodes.definition_list) -> None: ...
+ def depart_definition_list(self, node: nodes.definition_list) -> None: ...
+ def visit_definition_list_item(self, node: nodes.definition_list_item) -> None: ...
+ def depart_definition_list_item(self, node: nodes.definition_list_item) -> None: ...
+ def visit_term(self, node: nodes.term) -> None: ...
+ def depart_term(self, node: nodes.term) -> None: ...
+ def visit_definition(self, node: nodes.definition) -> None: ...
+ def depart_definition(self, node: nodes.definition) -> None: ...
+ def visit_classifier(self, node: nodes.classifier) -> None: ...
+ def depart_classifier(self, node: nodes.classifier) -> None: ...
+ def visit_document(self, node: nodes.document) -> None: ...
+ def depart_document(self, node: nodes.document) -> None: ...
+ def visit_docinfo(self, node: nodes.docinfo) -> None: ...
+ def depart_docinfo(self, node: nodes.docinfo) -> None: ...
+ def visit_emphasis(self, node: nodes.emphasis) -> None: ...
+ def depart_emphasis(self, node: nodes.emphasis) -> None: ...
+ def visit_enumerated_list(self, node: nodes.enumerated_list) -> None: ...
+ def depart_enumerated_list(self, node: nodes.enumerated_list) -> None: ...
+ def visit_list_item(self, node: nodes.list_item) -> None: ...
+ def depart_list_item(self, node: nodes.list_item) -> None: ...
+ def visit_header(self, node: nodes.header) -> None: ...
+ def depart_header(self, node: nodes.header) -> None: ...
+ def visit_footer(self, node: nodes.footer) -> None: ...
+ def depart_footer(self, node: nodes.footer) -> None: ...
+ def visit_field(self, node: nodes.field) -> None: ...
+ def depart_field(self, node: nodes.field) -> None: ...
+ def visit_field_list(self, node: nodes.field_list) -> None: ...
+ def depart_field_list(self, node: nodes.field_list) -> None: ...
+ def visit_field_name(self, node: nodes.field_name) -> None: ...
+ def depart_field_name(self, node: nodes.field_name) -> None: ...
+ def visit_field_body(self, node: nodes.field_body) -> None: ...
+ def depart_field_body(self, node: nodes.field_body) -> None: ...
+ def visit_figure(self, node: nodes.figure) -> None: ...
+ def depart_figure(self, node: nodes.figure) -> None: ...
+ save_footnote_current: _ElementInterfaceWrapper
+ def visit_footnote(self, node: nodes.footnote) -> None: ...
+ def depart_footnote(self, node: nodes.footnote) -> None: ...
+ footnote_chars: list[str]
+ def visit_footnote_reference(self, node: nodes.footnote_reference) -> None: ...
+ def depart_footnote_reference(self, node: nodes.footnote_reference) -> None: ...
+ def visit_citation(self, node: nodes.citation) -> None: ...
+ def depart_citation(self, node: nodes.citation) -> None: ...
+ def visit_citation_reference(self, node: nodes.citation_reference) -> None: ...
+ def depart_citation_reference(self, node: nodes.citation_reference) -> None: ...
+ def visit_label(self, node: nodes.label) -> None: ...
+ def depart_label(self, node: nodes.label) -> None: ...
+ def visit_generated(self, node: nodes.generated) -> None: ...
+ def depart_generated(self, node: nodes.generated) -> None: ...
+ def check_file_exists(self, path: FileDescriptorOrPath) -> Literal[1, 0]: ...
+ def visit_image(self, node: nodes.image) -> None: ...
+ def depart_image(self, node: nodes.image) -> None: ...
+ def get_image_width_height(self, node: nodes.image, attr: str) -> tuple[float | None, Literal["%", "cm"] | None]: ...
+ def convert_to_cm(self, size: str) -> tuple[float, Literal["cm"]]: ...
+ def get_image_scale(self, node: nodes.image) -> float: ...
+ def get_image_scaled_width_height(self, node: nodes.image, source) -> tuple[Incomplete, Incomplete]: ...
+ def get_page_width(self) -> float: ...
+ def generate_figure(self, node: nodes.image, source, destination, current_element): ...
+ def generate_image(
+ self, node: nodes.image, source, destination, current_element, frame_attrs: dict[str, str] | None = None
+ ): ...
+ def is_in_table(self, node: nodes.Node) -> bool: ...
+ def visit_legend(self, node: nodes.legend) -> None: ...
+ def depart_legend(self, node: nodes.legend) -> None: ...
+ def visit_line_block(self, node: nodes.line_block) -> None: ...
+ def depart_line_block(self, node: nodes.line_block) -> None: ...
+ def visit_line(self, node: nodes.line) -> None: ...
+ def depart_line(self, node: nodes.line) -> None: ...
+ def visit_literal(self, node: nodes.literal) -> None: ...
+ def depart_literal(self, node: nodes.literal) -> None: ...
+ def visit_inline(self, node: nodes.inline) -> None: ...
+ def depart_inline(self, node: nodes.inline) -> None: ...
+ def fill_line(self, line: str) -> str: ...
+ def fill_func1(self, matchobj: re.Match[str]) -> str: ...
+ def fill_func2(self, matchobj: re.Match[str]) -> str: ...
+ def visit_literal_block(self, node: nodes.literal_block) -> None: ...
+ def depart_literal_block(self, node: nodes.literal_block) -> None: ...
+ def visit_doctest_block(self, node: nodes.doctest_block) -> None: ...
+ def depart_doctest_block(self, node: nodes.doctest_block) -> None: ...
+ def visit_math(self, node: nodes.math) -> None: ...
+ def depart_math(self, node: nodes.math) -> None: ...
+ def visit_math_block(self, node: nodes.math_block) -> None: ...
+ def depart_math_block(self, node: nodes.math_block) -> None: ...
+ def visit_meta(self, node: nodes.meta) -> None: ...
+ def depart_meta(self, node: nodes.meta) -> None: ...
+ def visit_option_list(self, node: nodes.option_list) -> None: ...
+ def depart_option_list(self, node: nodes.option_list) -> None: ...
+ def visit_option_list_item(self, node: nodes.option_list_item) -> None: ...
+ def depart_option_list_item(self, node: nodes.option_list_item) -> None: ...
+ def visit_option_group(self, node: nodes.option_group) -> None: ...
+ def depart_option_group(self, node: nodes.option_group) -> None: ...
+ def visit_option(self, node: nodes.option) -> None: ...
+ def depart_option(self, node: nodes.option) -> None: ...
+ def visit_option_string(self, node: nodes.option_string) -> None: ...
+ def depart_option_string(self, node: nodes.option_string) -> None: ...
+ def visit_option_argument(self, node: nodes.option_argument) -> None: ...
+ def depart_option_argument(self, node: nodes.option_argument) -> None: ...
+ def visit_description(self, node: nodes.description) -> None: ...
+ def depart_description(self, node: nodes.description) -> None: ...
+ def visit_paragraph(self, node: nodes.paragraph) -> None: ...
+ def depart_paragraph(self, node: nodes.paragraph) -> None: ...
+ def visit_problematic(self, node: nodes.problematic) -> None: ...
+ def depart_problematic(self, node: nodes.problematic) -> None: ...
+ def visit_raw(self, node: nodes.raw) -> None: ...
+ def depart_raw(self, node: nodes.raw) -> None: ...
+ def visit_reference(self, node: nodes.reference) -> None: ...
+ def depart_reference(self, node: nodes.reference) -> None: ...
+ def visit_rubric(self, node: nodes.rubric) -> None: ...
+ def depart_rubric(self, node: nodes.rubric) -> None: ...
+ def visit_section(self, node: nodes.section, move_ids: int = 1) -> None: ...
+ def depart_section(self, node: nodes.section) -> None: ...
+ def visit_strong(self, node: nodes.strong) -> None: ...
+ def depart_strong(self, node: nodes.strong) -> None: ...
+ def visit_substitution_definition(self, node: nodes.substitution_definition) -> None: ...
+ def depart_substitution_definition(self, node: nodes.substitution_definition) -> None: ...
+ def visit_system_message(self, node: nodes.system_message) -> None: ...
+ def depart_system_message(self, node: nodes.system_message) -> None: ...
+ def get_table_style(self, node) -> TableStyle: ...
+ current_table_style: _ElementInterfaceWrapper
+ table_width: float
+ def visit_table(self, node: nodes.table) -> None: ...
+ def depart_table(self, node: nodes.table) -> None: ...
+ def visit_tgroup(self, node: nodes.tgroup) -> None: ...
+ def depart_tgroup(self, node: nodes.tgroup) -> None: ...
+ def visit_colspec(self, node: nodes.colspec) -> None: ...
+ def depart_colspec(self, node: nodes.colspec) -> None: ...
+ in_thead: bool
+ def visit_thead(self, node: nodes.thead) -> None: ...
+ def depart_thead(self, node: nodes.thead) -> None: ...
+ def visit_row(self, node: nodes.row) -> None: ...
+ def depart_row(self, node: nodes.row) -> None: ...
+ def visit_entry(self, node: nodes.entry) -> None: ...
+ def depart_entry(self, node: nodes.entry) -> None: ...
+ def visit_tbody(self, node: nodes.tbody) -> None: ...
+ def depart_tbody(self, node: nodes.tbody) -> None: ...
+ def visit_target(self, node: nodes.target) -> None: ...
+ def depart_target(self, node: nodes.target) -> None: ...
+ def visit_title(self, node: nodes.title, move_ids: int = 1, title_type: str = "title") -> None: ...
+ def depart_title(self, node: nodes.title) -> None: ...
+ def visit_subtitle(self, node: nodes.subtitle, move_ids: int = 1) -> None: ...
+ def depart_subtitle(self, node: nodes.subtitle) -> None: ...
+ def visit_title_reference(self, node: nodes.title_reference) -> None: ...
+ def depart_title_reference(self, node: nodes.title_reference) -> None: ...
+ def generate_table_of_content_entry_template(self, el1) -> None: ...
+ def find_title_label(self, node, class_type, label_key): ...
+ save_current_element: Incomplete
+ def visit_topic(self, node: nodes.topic) -> None: ...
+ def depart_topic(self, node: nodes.topic) -> None: ...
+ def update_toc_page_numbers(self, el) -> None: ...
+ def update_toc_collect(self, el, level, collection) -> None: ...
+ def update_toc_add_numbers(self, collection) -> None: ...
+ def visit_transition(self, node: nodes.transition) -> None: ...
+ def depart_transition(self, node: nodes.transition) -> None: ...
+ def visit_warning(self, node: nodes.warning) -> None: ...
+ def depart_warning(self, node: nodes.warning) -> None: ...
+ def visit_attention(self, node: nodes.attention) -> None: ...
+ def depart_attention(self, node: nodes.attention) -> None: ...
+ def visit_caution(self, node: nodes.caution) -> None: ...
+ def depart_caution(self, node: nodes.caution) -> None: ...
+ def visit_danger(self, node: nodes.danger) -> None: ...
+ def depart_danger(self, node: nodes.danger) -> None: ...
+ def visit_error(self, node: nodes.error) -> None: ...
+ def depart_error(self, node: nodes.error) -> None: ...
+ def visit_hint(self, node: nodes.hint) -> None: ...
+ def depart_hint(self, node: nodes.hint) -> None: ...
+ def visit_important(self, node: nodes.important) -> None: ...
+ def depart_important(self, node: nodes.important) -> None: ...
+ def visit_note(self, node: nodes.note) -> None: ...
+ def depart_note(self, node: nodes.note) -> None: ...
+ def visit_tip(self, node: nodes.tip) -> None: ...
+ def depart_tip(self, node: nodes.tip) -> None: ...
+ def visit_admonition(self, node: nodes.admonition) -> None: ...
+ def depart_admonition(self, node: nodes.admonition) -> None: ...
+ def generate_admonition(self, node: nodes.Node, label: str, title: str | None = None) -> None: ...
+ def visit_subscript(self, node: nodes.subscript) -> None: ...
+ def depart_subscript(self, node: nodes.subscript) -> None: ...
+ def visit_superscript(self, node: nodes.superscript) -> None: ...
+ def depart_superscript(self, node: nodes.superscript) -> None: ...
+ def visit_abbreviation(self, node: nodes.abbreviation) -> None: ...
+ def depart_abbreviation(self, node: nodes.abbreviation) -> None: ...
+ def visit_acronym(self, node: nodes.acronym) -> None: ...
+ def depart_acronym(self, node: nodes.acronym) -> None: ...
+ def visit_sidebar(self, node: nodes.sidebar) -> None: ...
+ def depart_sidebar(self, node: nodes.sidebar) -> None: ...
+
+class Reader(standalone.Reader[str | bytes]): ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/odf_odt/prepstyles.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/odf_odt/prepstyles.pyi
new file mode 100644
index 000000000000..d0fbc5009ca5
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/writers/odf_odt/prepstyles.pyi
@@ -0,0 +1,7 @@
+from _typeshed import StrPath
+from typing import IO
+
+NAMESPACES: dict[str, str]
+
+def prepstyle(filename: StrPath | IO[bytes]) -> None: ...
+def main() -> None: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/odf_odt/pygmentsformatter.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/odf_odt/pygmentsformatter.pyi
new file mode 100644
index 000000000000..10293d3fb075
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/writers/odf_odt/pygmentsformatter.pyi
@@ -0,0 +1,31 @@
+from _typeshed import Incomplete
+from typing import Any
+
+# Formatter[str] from types-pygments
+class _Formatter:
+ name: Any
+ aliases: Any
+ filenames: Any
+ unicodeoutput: bool
+ style: Any
+ full: Any
+ title: Any
+ encoding: Any
+ options: Any
+ def __init__(self, *, encoding: None = None, outencoding: None = None, **options) -> None: ...
+ def get_style_defs(self, arg: str = ""): ...
+ def format(self, tokensource, outfile): ...
+
+class OdtPygmentsFormatter(_Formatter):
+ rststyle_function: Incomplete
+ escape_function: Incomplete
+ def __init__(self, rststyle_function, escape_function) -> None: ...
+ def rststyle(self, name, parameters=()): ...
+ def get_style_defs(self, arg: str = ""): ...
+ def format(self, tokensource, outfile): ...
+
+class OdtPygmentsProgFormatter(OdtPygmentsFormatter):
+ def format(self, tokensource, outfile) -> None: ...
+
+class OdtPygmentsLaTeXFormatter(OdtPygmentsFormatter):
+ def format(self, tokensource, outfile) -> None: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/pep_html.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/pep_html.pyi
deleted file mode 100644
index 5b0f74feb261..000000000000
--- a/python/helpers/typeshed/stubs/docutils/docutils/writers/pep_html.pyi
+++ /dev/null
@@ -1 +0,0 @@
-def __getattr__(name: str): ... # incomplete module
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/pep_html/__init__.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/pep_html/__init__.pyi
new file mode 100644
index 000000000000..bdefd546ad4e
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/writers/pep_html/__init__.pyi
@@ -0,0 +1,20 @@
+from typing import ClassVar, Final
+
+from docutils.writers import html4css1
+
+__docformat__: Final = "reStructuredText"
+
+class Writer(html4css1.Writer):
+ default_stylesheet: ClassVar[str]
+ default_stylesheet_path: ClassVar[str]
+ default_template_path: ClassVar[str]
+ settings_default_overrides: ClassVar[dict[str, str]]
+ relative_path_settings: ClassVar[tuple[str, ...]]
+ config_section_dependencies: ClassVar[tuple[str, ...]]
+ translator_class: type[HTMLTranslator]
+ pepnum: str
+ title: str
+ def interpolation_dict(self) -> dict[str, str | int]: ... # type: ignore[override]
+
+class HTMLTranslator(html4css1.HTMLTranslator):
+ def depart_field_list(self, node) -> None: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/pseudoxml.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/pseudoxml.pyi
index 5b0f74feb261..2372ffc0b509 100644
--- a/python/helpers/typeshed/stubs/docutils/docutils/writers/pseudoxml.pyi
+++ b/python/helpers/typeshed/stubs/docutils/docutils/writers/pseudoxml.pyi
@@ -1 +1,9 @@
-def __getattr__(name: str): ... # incomplete module
+from typing import ClassVar, Final
+
+from docutils import writers
+
+__docformat__: Final = "reStructuredText"
+
+class Writer(writers.Writer[str]):
+ config_section: ClassVar[str]
+ config_section_dependencies: ClassVar[tuple[str, ...]]
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/s5_html.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/s5_html.pyi
deleted file mode 100644
index 5b0f74feb261..000000000000
--- a/python/helpers/typeshed/stubs/docutils/docutils/writers/s5_html.pyi
+++ /dev/null
@@ -1 +0,0 @@
-def __getattr__(name: str): ... # incomplete module
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/s5_html/__init__.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/s5_html/__init__.pyi
new file mode 100644
index 000000000000..fe0f36f15b47
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/writers/s5_html/__init__.pyi
@@ -0,0 +1,42 @@
+import re
+from _typeshed import StrPath
+from typing import ClassVar, Final
+
+from docutils import nodes
+from docutils.writers import html4css1
+
+__docformat__: Final = "reStructuredText"
+themes_dir_path: Final[str]
+
+def find_theme(name: StrPath) -> str: ...
+
+class Writer(html4css1.Writer):
+ settings_default_overrides: ClassVar[dict[str, int]]
+ config_section_dependencies: ClassVar[tuple[str, ...]]
+ translator_class: type[S5HTMLTranslator]
+
+class S5HTMLTranslator(html4css1.HTMLTranslator):
+ s5_stylesheet_template: ClassVar[str]
+ disable_current_slide: ClassVar[str]
+ layout_template: ClassVar[str]
+ default_theme: ClassVar[str]
+ base_theme_file: ClassVar[str]
+ direct_theme_files: ClassVar[tuple[str, ...]]
+ indirect_theme_files: ClassVar[tuple[str, ...]]
+ required_theme_files: ClassVar[tuple[str, ...]]
+ theme_file_path: str | None
+ s5_footer: list[str]
+ s5_header: list[str]
+ section_count: int
+ theme_files_copied: dict[str, bool]
+ def __init__(self, document: nodes.document, /) -> None: ...
+ def setup_theme(self) -> None: ...
+ def copy_theme(self) -> None: ...
+ files_to_skip_pattern: re.Pattern[str]
+ def copy_file(self, name, source_dir, dest_dir): ...
+ def depart_document(self, node: nodes.document) -> None: ...
+ def depart_footer(self, node: nodes.footer) -> None: ...
+ def depart_header(self, node: nodes.header) -> None: ...
+ def visit_section(self, node: nodes.section) -> None: ...
+ def visit_subtitle(self, node: nodes.subtitle) -> None: ...
+ def visit_title(self, node: nodes.title) -> None: ...
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/xetex.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/xetex.pyi
deleted file mode 100644
index 5b0f74feb261..000000000000
--- a/python/helpers/typeshed/stubs/docutils/docutils/writers/xetex.pyi
+++ /dev/null
@@ -1 +0,0 @@
-def __getattr__(name: str): ... # incomplete module
diff --git a/python/helpers/typeshed/stubs/docutils/docutils/writers/xetex/__init__.pyi b/python/helpers/typeshed/stubs/docutils/docutils/writers/xetex/__init__.pyi
new file mode 100644
index 000000000000..a8528b3670b2
--- /dev/null
+++ b/python/helpers/typeshed/stubs/docutils/docutils/writers/xetex/__init__.pyi
@@ -0,0 +1,30 @@
+from typing import ClassVar, Final
+
+from docutils import nodes
+from docutils.utils import Reporter
+from docutils.writers import latex2e
+
+__docformat__: Final = "reStructuredText"
+
+class Writer(latex2e.Writer):
+ default_template: ClassVar[str]
+ default_preamble: ClassVar[str]
+ config_section: ClassVar[str]
+ config_section_dependencies: ClassVar[tuple[str, ...]]
+ translator_class: type[XeLaTeXTranslator]
+
+class Babel(latex2e.Babel):
+ language_code: str
+ reporter: Reporter
+ language: str
+ warn_msg: str # type: ignore[misc]
+ quote_index: int
+ quotes: tuple[str, ...]
+ literal_double_quote: str
+ key: str
+ def __init__(self, language_code: str, reporter: Reporter) -> None: ...
+
+class XeLaTeXTranslator(latex2e.LaTeXTranslator):
+ is_xetex: bool # type: ignore[misc]
+ def __init__(self, document: nodes.document) -> None: ...
+ def to_latex_length(self, length_str: str, node: nodes.Node | None = None) -> str: ...
diff --git a/python/helpers/typeshed/stubs/fanstatic/fanstatic/core.pyi b/python/helpers/typeshed/stubs/fanstatic/fanstatic/core.pyi
index 8279c2c8a530..c57f58ec8b2a 100644
--- a/python/helpers/typeshed/stubs/fanstatic/fanstatic/core.pyi
+++ b/python/helpers/typeshed/stubs/fanstatic/fanstatic/core.pyi
@@ -188,7 +188,7 @@ class NeededResources:
recompute_hashes: bool = True,
base_url: str | None = None,
script_name: str | None = None,
- publisher_signature: str = ...,
+ publisher_signature: str = "fanstatic",
resources: Iterable[Dependable] | None = None,
) -> None: ...
def has_resources(self) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/fanstatic/fanstatic/injector.pyi b/python/helpers/typeshed/stubs/fanstatic/fanstatic/injector.pyi
index aed0ad9b4c8f..5d387b99d65a 100644
--- a/python/helpers/typeshed/stubs/fanstatic/fanstatic/injector.pyi
+++ b/python/helpers/typeshed/stubs/fanstatic/fanstatic/injector.pyi
@@ -1,13 +1,14 @@
from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
from abc import abstractmethod
from collections.abc import Iterable
-from typing import Any, Literal, TypedDict
+from typing import Any, Literal, TypedDict, type_check_only
from typing_extensions import Unpack
from fanstatic.core import Dependable, NeededResources, Resource
from fanstatic.inclusion import Inclusion
from webob import Request, Response
+@type_check_only
class _NeededResourcesConfig(TypedDict, total=False):
versioning: bool
versioning_use_md5: bool
@@ -17,6 +18,7 @@ class _NeededResourcesConfig(TypedDict, total=False):
publisher_signature: str
resources: Iterable[Dependable] | None
+@type_check_only
class _InjectorPluginOptions(TypedDict, total=False):
compile: bool
bundle: bool
@@ -24,6 +26,7 @@ class _InjectorPluginOptions(TypedDict, total=False):
debug: bool
minified: bool
+@type_check_only
class _TopBottomInjectorPluginOptions(_InjectorPluginOptions, total=False):
bottom: bool
force_bottom: bool
diff --git a/python/helpers/typeshed/stubs/fanstatic/fanstatic/publisher.pyi b/python/helpers/typeshed/stubs/fanstatic/fanstatic/publisher.pyi
index ac0257a60613..ba239c5c7e47 100644
--- a/python/helpers/typeshed/stubs/fanstatic/fanstatic/publisher.pyi
+++ b/python/helpers/typeshed/stubs/fanstatic/fanstatic/publisher.pyi
@@ -41,7 +41,7 @@ class Delegator:
publisher: Publisher
publisher_signature: str
trigger: str
- def __init__(self, app: WSGIApplication, publisher: Publisher, publisher_signature: str = ...) -> None: ...
+ def __init__(self, app: WSGIApplication, publisher: Publisher, publisher_signature: str = "fanstatic") -> None: ...
def is_resource(self, request: Request) -> bool: ...
def __call__(self, environ: WSGIEnvironment, start_response: StartResponse) -> Iterable[bytes]: ...
diff --git a/python/helpers/typeshed/stubs/fanstatic/fanstatic/wsgi.pyi b/python/helpers/typeshed/stubs/fanstatic/fanstatic/wsgi.pyi
index 99d63abea818..bd0859b091d3 100644
--- a/python/helpers/typeshed/stubs/fanstatic/fanstatic/wsgi.pyi
+++ b/python/helpers/typeshed/stubs/fanstatic/fanstatic/wsgi.pyi
@@ -8,7 +8,7 @@ from webob import Request, Response
from webob.dec import wsgify
def Fanstatic(
- app: WSGIApplication, publisher_signature: str = ..., injector: InjectorPlugin | None = None, **config: Any
+ app: WSGIApplication, publisher_signature: str = "fanstatic", injector: InjectorPlugin | None = None, **config: Any
) -> Delegator: ...
def make_fanstatic(app: WSGIApplication, global_config: Any, **local_config: Any) -> Delegator: ...
diff --git a/python/helpers/typeshed/stubs/flake8-builtins/METADATA.toml b/python/helpers/typeshed/stubs/flake8-builtins/METADATA.toml
index 39b5d88a6f9f..c50b847abe22 100644
--- a/python/helpers/typeshed/stubs/flake8-builtins/METADATA.toml
+++ b/python/helpers/typeshed/stubs/flake8-builtins/METADATA.toml
@@ -1,3 +1,3 @@
-version = "2.5.*"
+version = "3.0.*"
upstream_repository = "https://github.com/gforcada/flake8-builtins"
requires = ["types-flake8"]
diff --git a/python/helpers/typeshed/stubs/flake8-builtins/flake8_builtins.pyi b/python/helpers/typeshed/stubs/flake8-builtins/flake8_builtins.pyi
index 96043f368ba7..25c003d39648 100644
--- a/python/helpers/typeshed/stubs/flake8-builtins/flake8_builtins.pyi
+++ b/python/helpers/typeshed/stubs/flake8-builtins/flake8_builtins.pyi
@@ -18,6 +18,9 @@ class BuiltinsChecker:
module_name_msg: ClassVar[str]
lambda_argument_msg: ClassVar[str]
+ default_line_number: ClassVar[int]
+ default_column_offset: ClassVar[int]
+
names: ClassVar[list[str]]
ignore_list: ClassVar[set[str]]
ignored_module_names: ClassVar[set[str]]
diff --git a/python/helpers/typeshed/stubs/flake8-simplify/METADATA.toml b/python/helpers/typeshed/stubs/flake8-simplify/METADATA.toml
index 975ef0a56295..5e130f0d97af 100644
--- a/python/helpers/typeshed/stubs/flake8-simplify/METADATA.toml
+++ b/python/helpers/typeshed/stubs/flake8-simplify/METADATA.toml
@@ -1,6 +1,2 @@
-version = "0.21.*"
+version = "0.22.*"
upstream_repository = "https://github.com/MartinThoma/flake8-simplify"
-partial_stub = true
-
-[tool.stubtest]
-ignore_missing_stub = true
diff --git a/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/__init__.pyi b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/__init__.pyi
index c1831fa38365..db32a3db4104 100644
--- a/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/__init__.pyi
+++ b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/__init__.pyi
@@ -1,9 +1,30 @@
import ast
+import logging
from collections.abc import Generator
from typing import Any, ClassVar
+logger: logging.Logger
+
+class Visitor(ast.NodeVisitor):
+ def __init__(self) -> None: ...
+ def visit_Assign(self, node: ast.Assign) -> None: ...
+ def visit_Call(self, node: ast.Call) -> None: ...
+ def visit_With(self, node: ast.With) -> None: ...
+ def visit_Expr(self, node: ast.Expr) -> None: ...
+ def visit_BoolOp(self, node: ast.BoolOp) -> None: ...
+ def visit_If(self, node: ast.If) -> None: ...
+ def visit_For(self, node: ast.For) -> None: ...
+ def visit_Subscript(self, node: ast.Subscript) -> None: ...
+ def visit_Try(self, node: ast.Try) -> None: ...
+ def visit_UnaryOp(self, node_v: ast.UnaryOp) -> None: ...
+ def visit_IfExp(self, node: ast.IfExp) -> None: ...
+ def visit_Compare(self, node: ast.Compare) -> None: ...
+ def visit_ClassDef(self, node: ast.ClassDef) -> None: ...
+
class Plugin:
name: ClassVar[str]
version: ClassVar[str]
def __init__(self, tree: ast.AST) -> None: ...
def run(self) -> Generator[tuple[int, int, str, type[Any]], None, None]: ...
+
+def add_meta(root: ast.AST, level: int = 0) -> None: ...
diff --git a/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/constants.pyi b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/constants.pyi
new file mode 100644
index 000000000000..66c47b6ad841
--- /dev/null
+++ b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/constants.pyi
@@ -0,0 +1,3 @@
+BOOL_CONST_TYPES: tuple[type, ...]
+AST_CONST_TYPES: tuple[type, ...]
+STR_TYPES: tuple[type, ...]
diff --git a/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/__init__.pyi b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/__init__.pyi
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_assign.pyi b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_assign.pyi
new file mode 100644
index 000000000000..019ac9f499a7
--- /dev/null
+++ b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_assign.pyi
@@ -0,0 +1,6 @@
+import ast
+
+from flake8_simplify.utils import Assign
+
+def get_sim904(node: ast.Assign) -> list[tuple[int, int, str]]: ...
+def get_sim909(node: Assign) -> list[tuple[int, int, str]]: ...
diff --git a/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_bool_op.pyi b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_bool_op.pyi
new file mode 100644
index 000000000000..d130dceae322
--- /dev/null
+++ b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_bool_op.pyi
@@ -0,0 +1,8 @@
+import ast
+
+def get_sim101(node: ast.BoolOp) -> list[tuple[int, int, str]]: ...
+def get_sim109(node: ast.BoolOp) -> list[tuple[int, int, str]]: ...
+def get_sim220(node: ast.BoolOp) -> list[tuple[int, int, str]]: ...
+def get_sim221(node: ast.BoolOp) -> list[tuple[int, int, str]]: ...
+def get_sim222(node: ast.BoolOp) -> list[tuple[int, int, str]]: ...
+def get_sim223(node: ast.BoolOp) -> list[tuple[int, int, str]]: ...
diff --git a/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_call.pyi b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_call.pyi
new file mode 100644
index 000000000000..d8b62cfa427d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_call.pyi
@@ -0,0 +1,13 @@
+import ast
+import logging
+
+from flake8_simplify.utils import Call
+
+logger: logging.Logger
+
+def get_sim115(node: Call) -> list[tuple[int, int, str]]: ...
+def get_sim901(node: ast.Call) -> list[tuple[int, int, str]]: ...
+def get_sim905(node: ast.Call) -> list[tuple[int, int, str]]: ...
+def get_sim906(node: ast.Call) -> list[tuple[int, int, str]]: ...
+def get_sim910(node: Call) -> list[tuple[int, int, str]]: ...
+def get_sim911(node: ast.AST) -> list[tuple[int, int, str]]: ...
diff --git a/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_classdef.pyi b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_classdef.pyi
new file mode 100644
index 000000000000..09dc22b3595f
--- /dev/null
+++ b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_classdef.pyi
@@ -0,0 +1,3 @@
+import ast
+
+def get_sim120(node: ast.ClassDef) -> list[tuple[int, int, str]]: ...
diff --git a/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_compare.pyi b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_compare.pyi
new file mode 100644
index 000000000000..0a7b816a5e3c
--- /dev/null
+++ b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_compare.pyi
@@ -0,0 +1,4 @@
+import ast
+
+def get_sim118(node: ast.Compare) -> list[tuple[int, int, str]]: ...
+def get_sim300(node: ast.Compare) -> list[tuple[int, int, str]]: ...
diff --git a/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_expr.pyi b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_expr.pyi
new file mode 100644
index 000000000000..af53ac0309d8
--- /dev/null
+++ b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_expr.pyi
@@ -0,0 +1,3 @@
+import ast
+
+def get_sim112(node: ast.Expr) -> list[tuple[int, int, str]]: ...
diff --git a/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_for.pyi b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_for.pyi
new file mode 100644
index 000000000000..235c7fd2b287
--- /dev/null
+++ b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_for.pyi
@@ -0,0 +1,7 @@
+import ast
+
+from flake8_simplify.utils import For
+
+def get_sim104(node: ast.For) -> list[tuple[int, int, str]]: ...
+def get_sim110_sim111(node: ast.For) -> list[tuple[int, int, str]]: ...
+def get_sim113(node: For) -> list[tuple[int, int, str]]: ...
diff --git a/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_if.pyi b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_if.pyi
new file mode 100644
index 000000000000..65121cfcef51
--- /dev/null
+++ b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_if.pyi
@@ -0,0 +1,11 @@
+import ast
+
+from flake8_simplify.utils import If
+
+def get_sim102(node: ast.If) -> list[tuple[int, int, str]]: ...
+def get_sim103(node: ast.If) -> list[tuple[int, int, str]]: ...
+def get_sim108(node: If) -> list[tuple[int, int, str]]: ...
+def get_sim114(node: ast.If) -> list[tuple[int, int, str]]: ...
+def get_sim116(node: ast.If) -> list[tuple[int, int, str]]: ...
+def get_sim908(node: ast.If) -> list[tuple[int, int, str]]: ...
+def get_sim401(node: ast.If) -> list[tuple[int, int, str]]: ...
diff --git a/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_ifexp.pyi b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_ifexp.pyi
new file mode 100644
index 000000000000..8a37a0c6a5ab
--- /dev/null
+++ b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_ifexp.pyi
@@ -0,0 +1,5 @@
+import ast
+
+def get_sim210(node: ast.IfExp) -> list[tuple[int, int, str]]: ...
+def get_sim211(node: ast.IfExp) -> list[tuple[int, int, str]]: ...
+def get_sim212(node: ast.IfExp) -> list[tuple[int, int, str]]: ...
diff --git a/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_subscript.pyi b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_subscript.pyi
new file mode 100644
index 000000000000..eb2fa207b32b
--- /dev/null
+++ b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_subscript.pyi
@@ -0,0 +1,3 @@
+import ast
+
+def get_sim907(node: ast.Subscript) -> list[tuple[int, int, str]]: ...
diff --git a/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_try.pyi b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_try.pyi
new file mode 100644
index 000000000000..9156100ebbe1
--- /dev/null
+++ b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_try.pyi
@@ -0,0 +1,4 @@
+import ast
+
+def get_sim105(node: ast.Try) -> list[tuple[int, int, str]]: ...
+def get_sim107(node: ast.Try) -> list[tuple[int, int, str]]: ...
diff --git a/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_unary_op.pyi b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_unary_op.pyi
new file mode 100644
index 000000000000..93603e0576f1
--- /dev/null
+++ b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_unary_op.pyi
@@ -0,0 +1,8 @@
+import ast
+
+from flake8_simplify.utils import UnaryOp
+
+def get_sim201(node: UnaryOp) -> list[tuple[int, int, str]]: ...
+def get_sim202(node: UnaryOp) -> list[tuple[int, int, str]]: ...
+def get_sim203(node: UnaryOp) -> list[tuple[int, int, str]]: ...
+def get_sim208(node: ast.UnaryOp) -> list[tuple[int, int, str]]: ...
diff --git a/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_with.pyi b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_with.pyi
new file mode 100644
index 000000000000..310080e7ec0d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/rules/ast_with.pyi
@@ -0,0 +1,3 @@
+import ast
+
+def get_sim117(node: ast.With) -> list[tuple[int, int, str]]: ...
diff --git a/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/utils.pyi b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/utils.pyi
new file mode 100644
index 000000000000..3f4ea1c6524e
--- /dev/null
+++ b/python/helpers/typeshed/stubs/flake8-simplify/flake8_simplify/utils.pyi
@@ -0,0 +1,37 @@
+import ast
+from _typeshed import Incomplete
+
+class UnaryOp(ast.UnaryOp):
+ parent: ast.Expr
+ def __init__(self, orig: ast.UnaryOp) -> None: ...
+
+class Call(ast.Call):
+ parent: ast.Expr
+ def __init__(self, orig: ast.Call) -> None: ...
+
+class If(ast.If):
+ parent: ast.Expr
+ def __init__(self, orig: ast.If) -> None: ...
+
+class For(ast.For):
+ parent: ast.AST
+ previous_sibling: Incomplete
+ def __init__(self, orig: ast.For) -> None: ...
+
+class Assign(ast.Assign):
+ parent: ast.AST
+ previous_sibling: Incomplete
+ def __init__(self, orig: ast.Assign) -> None: ...
+
+def to_source(node: ast.expr | ast.Expr | ast.withitem | ast.slice | ast.Assign | None) -> str: ...
+def strip_parenthesis(string: str) -> str: ...
+def strip_triple_quotes(string: str) -> str: ...
+def use_double_quotes(string: str) -> str: ...
+def is_body_same(body1: list[ast.stmt], body2: list[ast.stmt]) -> bool: ...
+def is_stmt_equal(a: ast.stmt, b: ast.stmt) -> bool: ...
+def get_if_body_pairs(node: ast.If) -> list[tuple[ast.expr, list[ast.stmt]]]: ...
+def is_constant_increase(expr: ast.AugAssign) -> bool: ...
+def is_exception_check(node: ast.If) -> bool: ...
+def is_same_expression(a: ast.expr, b: ast.expr) -> bool: ...
+def expression_uses_variable(expr: ast.expr, var: str) -> bool: ...
+def body_contains_continue(stmts: list[ast.stmt]) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/flake8-typing-imports/METADATA.toml b/python/helpers/typeshed/stubs/flake8-typing-imports/METADATA.toml
index 141ae45b44c0..4c3b5ede410c 100644
--- a/python/helpers/typeshed/stubs/flake8-typing-imports/METADATA.toml
+++ b/python/helpers/typeshed/stubs/flake8-typing-imports/METADATA.toml
@@ -1,6 +1,2 @@
version = "1.16.*"
upstream_repository = "https://github.com/asottile/flake8-typing-imports"
-partial_stub = true
-
-[tool.stubtest]
-ignore_missing_stub = true
diff --git a/python/helpers/typeshed/stubs/flake8-typing-imports/flake8_typing_imports.pyi b/python/helpers/typeshed/stubs/flake8-typing-imports/flake8_typing_imports.pyi
index e9da0dae47c4..f2dd55ee9f12 100644
--- a/python/helpers/typeshed/stubs/flake8-typing-imports/flake8_typing_imports.pyi
+++ b/python/helpers/typeshed/stubs/flake8-typing-imports/flake8_typing_imports.pyi
@@ -1,16 +1,40 @@
import argparse
import ast
from collections.abc import Generator
-from typing import Any, ClassVar
+from typing import Any, Final, NamedTuple
+from typing_extensions import Self
+
+class Version(NamedTuple):
+ major: int = 0
+ minor: int = 0
+ patch: int = 0
+ @classmethod
+ def parse(cls, s: str) -> Self: ...
+
+SYMBOLS: Final[list[tuple[Version, frozenset[str]]]]
+VERSIONS: Final[frozenset[Version]]
+
+class Visitor(ast.NodeVisitor):
+ imports: dict[str, list[tuple[int, int]]]
+ attributes: dict[str, list[tuple[int, int]]]
+ defined_overload: bool
+ unions_pattern_or_match: list[tuple[int, int]]
+ from_imported_names: set[str]
+ namedtuple_methods: list[tuple[int, int]]
+ namedtuple_defaults: list[tuple[int, int]]
+ def __init__(self) -> None: ...
+ def visit_ImportFrom(self, node: ast.ImportFrom) -> None: ...
+ def visit_Attribute(self, node: ast.Attribute) -> None: ...
+ def visit_FunctionDef(self, node: ast.FunctionDef) -> None: ...
+ def visit_Subscript(self, node: ast.Subscript) -> None: ...
+ def visit_ClassDef(self, node: ast.ClassDef) -> None: ...
+ def visit_AnnAssign(self, node: ast.AnnAssign) -> None: ...
+ def generic_visit(self, node: ast.AST) -> None: ...
class Plugin:
- name: ClassVar[str]
- version: ClassVar[str]
@staticmethod
def add_options(option_manager: Any) -> None: ...
@classmethod
def parse_options(cls, options: argparse.Namespace) -> None: ...
def __init__(self, tree: ast.AST) -> None: ...
- def run(self) -> Generator[tuple[int, int, str, type[Any]], None, None]: ...
-
-def __getattr__(name: str): ... # incomplete module (other attributes are normally not accessed)
+ def run(self) -> Generator[tuple[int, int, str, type[Any]]]: ...
diff --git a/python/helpers/typeshed/stubs/flake8/METADATA.toml b/python/helpers/typeshed/stubs/flake8/METADATA.toml
index e327bf388ff5..f84346a54668 100644
--- a/python/helpers/typeshed/stubs/flake8/METADATA.toml
+++ b/python/helpers/typeshed/stubs/flake8/METADATA.toml
@@ -1,3 +1,3 @@
-version = "7.2.*"
+version = "7.3.*"
upstream_repository = "https://github.com/pycqa/flake8"
requires = ["types-pyflakes"]
diff --git a/python/helpers/typeshed/stubs/flake8/flake8/_compat.pyi b/python/helpers/typeshed/stubs/flake8/flake8/_compat.pyi
index 2cf456feceb0..7fbc26e88fc1 100644
--- a/python/helpers/typeshed/stubs/flake8/flake8/_compat.pyi
+++ b/python/helpers/typeshed/stubs/flake8/flake8/_compat.pyi
@@ -3,3 +3,7 @@ from typing import Final
FSTRING_START: Final[int]
FSTRING_MIDDLE: Final[int]
FSTRING_END: Final[int]
+
+TSTRING_START: Final[int]
+TSTRING_MIDDLE: Final[int]
+TSTRING_END: Final[int]
diff --git a/python/helpers/typeshed/stubs/flake8/flake8/processor.pyi b/python/helpers/typeshed/stubs/flake8/flake8/processor.pyi
index 87d26df68ab2..f193a21840be 100644
--- a/python/helpers/typeshed/stubs/flake8/flake8/processor.pyi
+++ b/python/helpers/typeshed/stubs/flake8/flake8/processor.pyi
@@ -43,6 +43,7 @@ class FileProcessor:
def __init__(self, filename: str, options: Namespace, lines: list[str] | None = None) -> None: ...
@property
def file_tokens(self) -> list[TokenInfo]: ...
+ def tstring_start(self, lineno: int) -> None: ...
def fstring_start(self, lineno: int) -> None: ...
def multiline_string(self, token: TokenInfo) -> Generator[str, None, None]: ...
def reset_blank_before(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/fpdf2/METADATA.toml b/python/helpers/typeshed/stubs/fpdf2/METADATA.toml
index 8ffd02df0c12..99ca1632cb80 100644
--- a/python/helpers/typeshed/stubs/fpdf2/METADATA.toml
+++ b/python/helpers/typeshed/stubs/fpdf2/METADATA.toml
@@ -1,4 +1,4 @@
-version = "2.8.3"
+version = "2.8.4"
upstream_repository = "https://github.com/PyFPDF/fpdf2"
requires = ["Pillow>=10.3.0"]
diff --git a/python/helpers/typeshed/stubs/fpdf2/fpdf/annotations.pyi b/python/helpers/typeshed/stubs/fpdf2/fpdf/annotations.pyi
index 351f46fa9edd..b55b30978dff 100644
--- a/python/helpers/typeshed/stubs/fpdf2/fpdf/annotations.pyi
+++ b/python/helpers/typeshed/stubs/fpdf2/fpdf/annotations.pyi
@@ -55,6 +55,26 @@ class AnnotationMixin:
class PDFAnnotation(AnnotationMixin, PDFObject): ...
class AnnotationDict(AnnotationMixin):
+ __slots__ = (
+ "type",
+ "subtype",
+ "rect",
+ "border",
+ "f_t",
+ "v",
+ "f",
+ "contents",
+ "a",
+ "dest",
+ "c",
+ "t",
+ "quad_points",
+ "p",
+ "name",
+ "ink_list",
+ "f_s",
+ "d_a",
+ )
def serialize(self) -> str: ...
class PDFEmbeddedFile(PDFContentStream):
diff --git a/python/helpers/typeshed/stubs/fpdf2/fpdf/bidi.pyi b/python/helpers/typeshed/stubs/fpdf2/fpdf/bidi.pyi
index 3efbf7e65458..c748e733f349 100644
--- a/python/helpers/typeshed/stubs/fpdf2/fpdf/bidi.pyi
+++ b/python/helpers/typeshed/stubs/fpdf2/fpdf/bidi.pyi
@@ -15,6 +15,7 @@ class _BracketInfo(TypedDict):
BIDI_BRACKETS: Final[dict[str, _BracketInfo]]
class BidiCharacter:
+ __slots__ = ["character_index", "character", "bidi_class", "original_bidi_class", "embedding_level", "direction"]
character_index: int
character: str
bidi_class: str
@@ -28,11 +29,13 @@ class BidiCharacter:
@dataclass
class DirectionalStatus:
+ __slots__ = ["embedding_level", "directional_override_status", "directional_isolate_status"]
embedding_level: int # between 0 and MAX_DEPTH
directional_override_status: Literal["N", "L", "R"]
directional_isolate_status: bool
class IsolatingRun:
+ __slots__ = ["characters", "previous_direction", "next_direction"]
characters: list[BidiCharacter]
previous_direction: str
next_direction: str
@@ -46,6 +49,7 @@ def auto_detect_base_direction(string: str, stop_at_pdi: bool = False, debug: bo
def calculate_isolate_runs(paragraph: Sequence[BidiCharacter]) -> list[IsolatingRun]: ...
class BidiParagraph:
+ __slots__ = ("text", "base_direction", "debug", "base_embedding_level", "characters")
text: str
base_direction: TextDirection
debug: bool
diff --git a/python/helpers/typeshed/stubs/fpdf2/fpdf/encryption.pyi b/python/helpers/typeshed/stubs/fpdf2/fpdf/encryption.pyi
index 55c72a1d1d52..3c3edabd53f4 100644
--- a/python/helpers/typeshed/stubs/fpdf2/fpdf/encryption.pyi
+++ b/python/helpers/typeshed/stubs/fpdf2/fpdf/encryption.pyi
@@ -1,7 +1,7 @@
from _typeshed import Incomplete, SupportsLenAndGetItem
from collections.abc import Generator, Iterable
from logging import Logger
-from typing import ClassVar, Protocol, TypeVar, overload
+from typing import ClassVar, Protocol, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
from .enums import AccessPermission, EncryptionMethod
@@ -15,6 +15,7 @@ LOGGER: Logger
import_error: ImportError | None
+@type_check_only
class _SupportsGetItem(Protocol[_T_co]):
def __getitem__(self, k: int, /) -> _T_co: ...
diff --git a/python/helpers/typeshed/stubs/fpdf2/fpdf/enums.pyi b/python/helpers/typeshed/stubs/fpdf2/fpdf/enums.pyi
index f9f7fb8ce4ee..5c11f04e31ce 100644
--- a/python/helpers/typeshed/stubs/fpdf2/fpdf/enums.pyi
+++ b/python/helpers/typeshed/stubs/fpdf2/fpdf/enums.pyi
@@ -1,9 +1,15 @@
+from abc import ABC, abstractmethod
+from collections.abc import Sequence
+from dataclasses import dataclass
from enum import Enum, Flag, IntEnum, IntFlag
-from typing import Literal
+from typing import Final, Literal
from typing_extensions import Self, TypeAlias
+from .drawing import DeviceCMYK, DeviceGray, DeviceRGB
from .syntax import Name
+_Color: TypeAlias = str | int | Sequence[int] | DeviceCMYK | DeviceGray | DeviceRGB
+
class SignatureFlag(IntEnum):
SIGNATURES_EXIST = 1
APPEND_ONLY = 2
@@ -68,15 +74,6 @@ class MethodReturnValue(CoerciveIntFlag):
LINES = 2
HEIGHT = 4
-class TableBordersLayout(CoerciveEnum):
- ALL = "ALL"
- NONE = "NONE"
- INTERNAL = "INTERNAL"
- MINIMAL = "MINIMAL"
- HORIZONTAL_LINES = "HORIZONTAL_LINES"
- NO_HORIZONTAL_LINES = "NO_HORIZONTAL_LINES"
- SINGLE_TOP_LINE = "SINGLE_TOP_LINE"
-
class CellBordersLayout(CoerciveIntFlag):
NONE = 0
LEFT = 1
@@ -86,6 +83,90 @@ class CellBordersLayout(CoerciveIntFlag):
ALL = 15
INHERIT = 16
+@dataclass
+class TableBorderStyle:
+ thickness: float | None = None
+ color: int | tuple[int, int, int] | None = None
+ dash: float | None = None
+ gap: float = 0.0
+ phase: float = 0.0
+
+ @staticmethod
+ def from_bool(should_draw: TableBorderStyle | bool | None) -> TableBorderStyle: ...
+ @property
+ def dash_dict(self) -> dict[str, float | None]: ...
+ def changes_stroke(self, pdf) -> bool: ...
+ def should_render(self) -> bool: ...
+ def get_change_stroke_commands(self, scale: float) -> list[str]: ...
+ @staticmethod
+ def get_line_command(x1: float, y1: float, x2: float, y2: float) -> list[str]: ...
+ def get_draw_commands(self, pdf, x1: float, y1: float, x2: float, y2: float) -> list[str]: ...
+
+@dataclass
+class TableCellStyle:
+ left: bool | TableBorderStyle = False
+ bottom: bool | TableBorderStyle = False
+ right: bool | TableBorderStyle = False
+ top: bool | TableBorderStyle = False
+
+ @staticmethod
+ def get_change_fill_color_command(color: _Color | None) -> list[str]: ...
+ def get_draw_commands(
+ self, pdf, x1: float, y1: float, x2: float, y2: float, fill_color: _Color | None = None
+ ) -> list[str]: ...
+ def override_cell_border(self, cell_border: CellBordersLayout) -> Self: ...
+ def draw_cell_border(self, pdf, x1: float, y1: float, x2: float, y2: float, fill_color: _Color | None = None) -> None: ...
+
+class TableBordersLayout(ABC):
+ ALL: Final[TableBordersLayoutAll]
+ NONE: Final[TableBordersLayoutNone]
+ INTERNAL: Final[TableBordersLayoutInternal]
+ MINIMAL: Final[TableBordersLayoutMinimal]
+ HORIZONTAL_LINES: Final[TableBordersLayoutHorizontalLines]
+ NO_HORIZONTAL_LINES: Final[TableBordersLayoutNoHorizontalLines]
+ SINGLE_TOP_LINE: Final[TableBordersLayoutSingleTopLine]
+ @abstractmethod
+ def cell_style_getter(
+ self, row_idx: int, col_idx: int, col_pos: int, num_heading_rows: int, num_rows: int, num_col_idx: int, num_col_pos: int
+ ) -> TableCellStyle: ...
+ @classmethod
+ def coerce(cls, value: Self | str) -> Self: ...
+
+class TableBordersLayoutAll(TableBordersLayout):
+ def cell_style_getter(
+ self, row_idx: int, col_idx: int, col_pos: int, num_heading_rows: int, num_rows: int, num_col_idx: int, num_col_pos: int
+ ) -> TableCellStyle: ...
+
+class TableBordersLayoutNone(TableBordersLayout):
+ def cell_style_getter(
+ self, row_idx: int, col_idx: int, col_pos: int, num_heading_rows: int, num_rows: int, num_col_idx: int, num_col_pos: int
+ ) -> TableCellStyle: ...
+
+class TableBordersLayoutInternal(TableBordersLayout):
+ def cell_style_getter(
+ self, row_idx: int, col_idx: int, col_pos: int, num_heading_rows: int, num_rows: int, num_col_idx: int, num_col_pos: int
+ ) -> TableCellStyle: ...
+
+class TableBordersLayoutMinimal(TableBordersLayout):
+ def cell_style_getter(
+ self, row_idx: int, col_idx: int, col_pos: int, num_heading_rows: int, num_rows: int, num_col_idx: int, num_col_pos: int
+ ) -> TableCellStyle: ...
+
+class TableBordersLayoutHorizontalLines(TableBordersLayout):
+ def cell_style_getter(
+ self, row_idx: int, col_idx: int, col_pos: int, num_heading_rows: int, num_rows: int, num_col_idx: int, num_col_pos: int
+ ) -> TableCellStyle: ...
+
+class TableBordersLayoutNoHorizontalLines(TableBordersLayout):
+ def cell_style_getter(
+ self, row_idx: int, col_idx: int, col_pos: int, num_heading_rows: int, num_rows: int, num_col_idx: int, num_col_pos: int
+ ) -> TableCellStyle: ...
+
+class TableBordersLayoutSingleTopLine(TableBordersLayout):
+ def cell_style_getter(
+ self, row_idx: int, col_idx: int, col_pos: int, num_heading_rows: int, num_rows: int, num_col_idx: int, num_col_pos: int
+ ) -> TableCellStyle: ...
+
class TableCellFillMode(CoerciveEnum):
NONE = "NONE"
ALL = "ALL"
diff --git a/python/helpers/typeshed/stubs/fpdf2/fpdf/fonts.pyi b/python/helpers/typeshed/stubs/fpdf2/fpdf/fonts.pyi
index ee0502b493dc..72d97ebd1e73 100644
--- a/python/helpers/typeshed/stubs/fpdf2/fpdf/fonts.pyi
+++ b/python/helpers/typeshed/stubs/fpdf2/fpdf/fonts.pyi
@@ -20,6 +20,7 @@ class HarfBuzzFont(Incomplete): # derives from uharfbuzz.Font
@dataclass
class FontFace:
+ __slots__ = ("family", "emphasis", "size_pt", "color", "fill_color")
family: str | None
emphasis: TextEmphasis | None
size_pt: int | None
@@ -79,6 +80,7 @@ class TitleStyle(TextStyle): ...
__pdoc__: Final[dict[str, bool]]
class CoreFont:
+ __slots__ = ("i", "type", "name", "sp", "ss", "up", "ut", "cw", "fontkey", "emphasis")
i: int
type: str
name: str
@@ -94,6 +96,27 @@ class CoreFont:
def encode_text(self, text: str) -> str: ...
class TTFFont:
+ __slots__ = (
+ "i",
+ "type",
+ "name",
+ "desc",
+ "glyph_ids",
+ "hbfont",
+ "sp",
+ "ss",
+ "up",
+ "ut",
+ "cw",
+ "ttffile",
+ "fontkey",
+ "emphasis",
+ "scale",
+ "subset",
+ "cmap",
+ "ttfont",
+ "missing_glyphs",
+ )
i: int
type: str
ttffile: Incomplete
@@ -114,6 +137,7 @@ class TTFFont:
subset: SubsetMap
hbfont: HarfBuzzFont | None # Not always defined.
def __init__(self, fpdf, font_file_path, fontkey: str, style: int) -> None: ...
+ def __deepcopy__(self, memo) -> Self: ...
def close(self) -> None: ...
def get_text_width(self, text: str, font_size_pt: int, text_shaping_params): ...
def shaped_text_width(self, text: str, font_size_pt: int, text_shaping_params): ...
@@ -136,6 +160,7 @@ class PDFFontDescriptor(PDFObject):
@dataclass(order=True)
class Glyph:
+ __slots__ = ("glyph_id", "unicode", "glyph_name", "glyph_width")
glyph_id: int
unicode: tuple[Incomplete, ...]
glyph_name: str
diff --git a/python/helpers/typeshed/stubs/fpdf2/fpdf/fpdf.pyi b/python/helpers/typeshed/stubs/fpdf2/fpdf/fpdf.pyi
index 67832cb7fbf2..820ba83c6b55 100644
--- a/python/helpers/typeshed/stubs/fpdf2/fpdf/fpdf.pyi
+++ b/python/helpers/typeshed/stubs/fpdf2/fpdf/fpdf.pyi
@@ -109,7 +109,7 @@ _FontStyles: TypeAlias = Literal[
]
FPDF_VERSION: Final[str]
-PAGE_FORMATS: dict[_Format, tuple[float, float]]
+PAGE_FORMATS: Final[dict[_Format, tuple[float, float]]]
class ToCPlaceholder(NamedTuple):
render_function: Callable[[FPDF, list[OutlineSection]], object]
diff --git a/python/helpers/typeshed/stubs/fpdf2/fpdf/html.pyi b/python/helpers/typeshed/stubs/fpdf2/fpdf/html.pyi
index 9cf64f1e6163..8225d7177721 100644
--- a/python/helpers/typeshed/stubs/fpdf2/fpdf/html.pyi
+++ b/python/helpers/typeshed/stubs/fpdf2/fpdf/html.pyi
@@ -7,7 +7,7 @@ from typing_extensions import TypeAlias
from fpdf import FPDF
-from .enums import TextEmphasis
+from .enums import Align, TextEmphasis
from .fonts import FontFace
from .table import Row, Table
@@ -17,8 +17,10 @@ __copyright__: Final[str]
_OLType: TypeAlias = Literal["1", "a", "A", "I", "i"]
LOGGER: Logger
-BULLET_WIN1252: Final[str]
-DEGREE_WIN1252: Final[str]
+MESSAGE_WAITING_WIN1252: Final = "\x95"
+BULLET_UNICODE: Final = "•"
+DEGREE_SIGN_WIN1252: Final = "\xb0"
+RING_OPERATOR_UNICODE: Final = "∘"
HEADING_TAGS: Final[tuple[str, ...]]
DEFAULT_TAG_STYLES: Final[dict[str, FontFace]]
INLINE_TAGS: Final[tuple[str, ...]]
@@ -49,10 +51,10 @@ class HTML2FPDF(HTMLParser):
follows_trailing_space: bool
follows_heading: bool
href: str
- align: str
+ align: float | Align | None
indent: int
line_height_stack: list[Incomplete]
- ol_type: list[_OLType]
+ ol_type: dict[int, _OLType]
bullet: list[Incomplete]
heading_level: Incomplete | None
render_title_tag: bool
@@ -71,7 +73,7 @@ class HTML2FPDF(HTMLParser):
li_tag_indent: int | None = None,
dd_tag_indent: int | None = None,
table_line_separators: bool = False,
- ul_bullet_char: str = "\x95",
+ ul_bullet_char: str = "disc",
li_prefix_color: tuple[int, int, int] = (190, 0, 0),
heading_sizes: SupportsKeysAndGetItem[str, int] | Iterable[tuple[str, int]] | None = None,
pre_code_font: str | None = None,
@@ -88,7 +90,7 @@ class HTML2FPDF(HTMLParser):
def render_toc(self, pdf, outline) -> None: ...
def error(self, message: str) -> None: ...
-def ul_prefix(ul_type: str) -> str: ...
+def ul_prefix(ul_type: str, is_ttf_font: bool | None) -> str: ...
def ol_prefix(ol_type: _OLType, index: int) -> str: ...
class HTMLMixin:
diff --git a/python/helpers/typeshed/stubs/fpdf2/fpdf/outline.pyi b/python/helpers/typeshed/stubs/fpdf2/fpdf/outline.pyi
index 52ceb7eff68d..4a26d8ee0982 100644
--- a/python/helpers/typeshed/stubs/fpdf2/fpdf/outline.pyi
+++ b/python/helpers/typeshed/stubs/fpdf2/fpdf/outline.pyi
@@ -9,6 +9,7 @@ from .syntax import Destination, PDFObject, PDFString
@dataclass
class OutlineSection:
+ __slots__ = ("name", "level", "page_number", "dest", "struct_elem")
name: str
level: int
page_number: int
@@ -16,6 +17,7 @@ class OutlineSection:
struct_elem: StructElem | None = None
class OutlineItemDictionary(PDFObject):
+ __slots__ = ("_id", "title", "parent", "prev", "next", "first", "last", "count", "dest", "struct_elem")
title: PDFString
parent: Incomplete | None
prev: Incomplete | None
@@ -28,6 +30,7 @@ class OutlineItemDictionary(PDFObject):
def __init__(self, title: str, dest: Destination | None = None, struct_elem: StructElem | None = None) -> None: ...
class OutlineDictionary(PDFObject):
+ __slots__ = ("_id", "type", "first", "last", "count")
type: str
first: Incomplete | None
last: Incomplete | None
diff --git a/python/helpers/typeshed/stubs/fpdf2/fpdf/output.pyi b/python/helpers/typeshed/stubs/fpdf2/fpdf/output.pyi
index fb963c770e04..86c1b56c855e 100644
--- a/python/helpers/typeshed/stubs/fpdf2/fpdf/output.pyi
+++ b/python/helpers/typeshed/stubs/fpdf2/fpdf/output.pyi
@@ -102,6 +102,21 @@ class PDFXmpMetadata(PDFContentStream):
def __init__(self, contents: bytes) -> None: ...
class PDFXObject(PDFContentStream):
+ __slots__ = (
+ "_id",
+ "_contents",
+ "filter",
+ "length",
+ "type",
+ "subtype",
+ "width",
+ "height",
+ "color_space",
+ "bits_per_component",
+ "decode",
+ "decode_parms",
+ "s_mask",
+ )
type: Name
subtype: Name
width: Incomplete
@@ -126,11 +141,13 @@ class PDFXObject(PDFContentStream):
) -> None: ...
class PDFICCProfile(PDFContentStream):
+ __slots__ = ("_id", "_contents", "filter", "length", "n", "alternate")
n: Incomplete
alternate: Name
def __init__(self, contents: bytes, n, alternate: str) -> None: ...
class PDFPageLabel:
+ __slots__ = ("_style", "_prefix", "st")
st: int
def __init__(self, label_style: PageLabelStyle, label_prefix: str, label_start: int) -> None: ...
@property
@@ -143,6 +160,24 @@ class PDFPageLabel:
def get_start(self) -> int: ...
class PDFPage(PDFObject):
+ __slots__ = (
+ "_id",
+ "type",
+ "contents",
+ "dur",
+ "trans",
+ "annots",
+ "group",
+ "media_box",
+ "struct_parents",
+ "resources",
+ "parent",
+ "_index",
+ "_width_pt",
+ "_height_pt",
+ "_page_label",
+ "_text_substitution_fragments",
+ )
type: Name
contents: Incomplete
dur: Incomplete | None
@@ -184,6 +219,7 @@ class PDFXrefAndTrailer(ContentWithoutID):
def serialize(self, _security_handler: StandardSecurityHandler | None = None) -> str: ...
class OutputIntentDictionary:
+ __slots__ = ("type", "s", "output_condition_identifier", "output_condition", "registry_name", "dest_output_profile", "info")
type: Name
s: Name
output_condition_identifier: PDFString | None
diff --git a/python/helpers/typeshed/stubs/fpdf2/fpdf/structure_tree.pyi b/python/helpers/typeshed/stubs/fpdf2/fpdf/structure_tree.pyi
index 3123d74fcdb5..6d3f35cd536f 100644
--- a/python/helpers/typeshed/stubs/fpdf2/fpdf/structure_tree.pyi
+++ b/python/helpers/typeshed/stubs/fpdf2/fpdf/structure_tree.pyi
@@ -6,17 +6,20 @@ from .encryption import StandardSecurityHandler
from .syntax import PDFArray, PDFObject, PDFString
class NumberTree(PDFObject):
+ __slots__ = ("_id", "nums")
nums: defaultdict[Incomplete, list[Incomplete]]
def __init__(self) -> None: ...
def serialize(self, obj_dict: Unused = None, _security_handler: StandardSecurityHandler | None = None) -> str: ...
class StructTreeRoot(PDFObject):
+ __slots__ = ("_id", "type", "parent_tree", "k")
type: str
parent_tree: NumberTree
k: PDFArray[Incomplete]
def __init__(self) -> None: ...
class StructElem(PDFObject):
+ __slots__ = ("_id", "type", "s", "p", "k", "t", "alt", "pg", "_page_number")
type: str
s: str
p: PDFObject
diff --git a/python/helpers/typeshed/stubs/fpdf2/fpdf/svg.pyi b/python/helpers/typeshed/stubs/fpdf2/fpdf/svg.pyi
index 3f98d58aafdf..2a2eb78fb606 100644
--- a/python/helpers/typeshed/stubs/fpdf2/fpdf/svg.pyi
+++ b/python/helpers/typeshed/stubs/fpdf2/fpdf/svg.pyi
@@ -2,7 +2,7 @@ from _typeshed import Incomplete, Unused
from collections.abc import Callable
from logging import Logger
from re import Pattern
-from typing import Literal, NamedTuple, overload
+from typing import Final, Literal, NamedTuple, Protocol, TypeVar, overload, type_check_only
from ._fonttools_shims import BasePen, _TTGlyphSet
from .drawing import ClippingPath, PaintedPath
@@ -10,13 +10,18 @@ from .fpdf import FPDF
from .image_datastructures import ImageCache
LOGGER: Logger
-
__pdoc__: dict[str, bool]
-def force_nodocument(item): ...
+@type_check_only
+class _HasQualname(Protocol):
+ __qualname__: str
-NUMBER_SPLIT: Pattern[str]
-TRANSFORM_GETTER: Pattern[str]
+_T = TypeVar("_T", bound=_HasQualname)
+
+def force_nodocument(item: _T) -> _T: ...
+
+NUMBER_SPLIT: Final[Pattern[str]]
+TRANSFORM_GETTER: Final[Pattern[str]]
class Percent(float): ...
diff --git a/python/helpers/typeshed/stubs/fpdf2/fpdf/syntax.pyi b/python/helpers/typeshed/stubs/fpdf2/fpdf/syntax.pyi
index a6005e9e4c52..215db48473d1 100644
--- a/python/helpers/typeshed/stubs/fpdf2/fpdf/syntax.pyi
+++ b/python/helpers/typeshed/stubs/fpdf2/fpdf/syntax.pyi
@@ -21,6 +21,7 @@ def create_dictionary_string(
def create_list_string(list_): ...
def iobj_ref(n): ...
def create_stream(stream: str | bytes | bytearray, encryption_handler: StandardSecurityHandler | None = None, obj_id=None): ...
+def wrap_in_local_context(draw_commands: list[str]) -> list[str]: ...
class Raw(str): ...
diff --git a/python/helpers/typeshed/stubs/fpdf2/fpdf/table.pyi b/python/helpers/typeshed/stubs/fpdf2/fpdf/table.pyi
index 55ec102ed504..46276c07ddcf 100644
--- a/python/helpers/typeshed/stubs/fpdf2/fpdf/table.pyi
+++ b/python/helpers/typeshed/stubs/fpdf2/fpdf/table.pyi
@@ -58,7 +58,6 @@ class Table:
self, cells: Iterable[str] = (), style: FontFace | None = None, v_align: VAlign | str | None = None, min_height=None
) -> Row: ...
def render(self) -> None: ...
- def get_cell_border(self, i: int, j: int, cell: Cell) -> str | Literal[0, 1]: ...
class Row:
cells: list[Cell]
@@ -106,6 +105,7 @@ class Row:
@dataclass
class Cell:
+ __slots__ = ("text", "align", "v_align", "style", "img", "img_fill_width", "colspan", "rowspan", "padding", "link", "border")
text: str
align: str | Align | None
v_align: str | VAlign | None
diff --git a/python/helpers/typeshed/stubs/fpdf2/fpdf/template.pyi b/python/helpers/typeshed/stubs/fpdf2/fpdf/template.pyi
index 4c94913b3356..41d5f9d55308 100644
--- a/python/helpers/typeshed/stubs/fpdf2/fpdf/template.pyi
+++ b/python/helpers/typeshed/stubs/fpdf2/fpdf/template.pyi
@@ -22,7 +22,7 @@ class FlexTemplate:
set: Any
def __contains__(self, name): ...
def __getitem__(self, name): ...
- def split_multicell(self, text, element_name): ...
+ def split_multicell(self, text: str, element_name: str) -> list[str]: ...
def render(self, offsetx: float = 0.0, offsety: float = 0.0, rotate: float = 0.0, scale: float = 1.0): ...
class Template(FlexTemplate):
diff --git a/python/helpers/typeshed/stubs/gdb/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/gdb/@tests/stubtest_allowlist.txt
index 22017ab0580c..0defd3d50977 100644
--- a/python/helpers/typeshed/stubs/gdb/@tests/stubtest_allowlist.txt
+++ b/python/helpers/typeshed/stubs/gdb/@tests/stubtest_allowlist.txt
@@ -74,5 +74,10 @@ gdb.Progspace.xmethods
# stubtest thinks this can't be sub-classed at runtime, but it is
gdb.disassembler.DisassemblerPart
-# incomplete modules
-gdb\.dap\.[a-z_]+\.[A-Za-z_]+
+gdb.TuiEnabledEvent
+gdb.events.tui_enabled
+
+gdb.Progspace.missing_debug_handlers
+gdb.missing_debug_handlers
+gdb.missing_files
+gdb.missing_objfile
diff --git a/python/helpers/typeshed/stubs/gdb/METADATA.toml b/python/helpers/typeshed/stubs/gdb/METADATA.toml
index 475788246998..6dca8b4d7a0c 100644
--- a/python/helpers/typeshed/stubs/gdb/METADATA.toml
+++ b/python/helpers/typeshed/stubs/gdb/METADATA.toml
@@ -1,4 +1,4 @@
-version = "15.0.*"
+version = "16.3.*"
# This is the official web portal for the GDB Git repo,
# see https://sourceware.org/gdb/current/ for other ways of obtaining the source code.
upstream_repository = "https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=tree"
@@ -11,5 +11,5 @@ extra_description = """\
"""
[tool.stubtest]
-platforms = ["linux"]
+ci_platforms = ["linux"]
apt_dependencies = ["gdb"]
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/__init__.pyi b/python/helpers/typeshed/stubs/gdb/gdb/__init__.pyi
index 12e35708e867..4f4a67b28427 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/__init__.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/__init__.pyi
@@ -4,14 +4,15 @@
import _typeshed
import threading
-from _typeshed import Incomplete
from collections.abc import Callable, Iterator, Mapping, Sequence
from contextlib import AbstractContextManager
-from typing import Any, Final, Generic, Literal, Protocol, TypeVar, final, overload, type_check_only
+from typing import Any, Final, Generic, Literal, Protocol, TypedDict, TypeVar, final, overload, type_check_only
from typing_extensions import TypeAlias, deprecated
import gdb.FrameDecorator
import gdb.types
+from gdb.missing_debug import MissingDebugHandler
+from gdb.missing_files import MissingFileHandler
# The following submodules are automatically imported
from . import events as events, printing as printing, prompt as prompt, types as types
@@ -46,7 +47,8 @@ def add_history(value: Value, /) -> int: ...
def history_count() -> int: ...
def convenience_variable(name: str, /) -> Value | None: ...
def set_convenience_variable(name: str, value: _ValueOrNative | None, /) -> None: ...
-def parse_and_eval(expression: str, global_context: bool = False, /) -> Value: ...
+def parse_and_eval(expression: str, global_context: bool = False) -> Value: ...
+def format_address(address: int, progspace: Progspace = ..., architecture: Architecture = ...): ...
def find_pc_line(pc: int | Value) -> Symtab_and_line: ...
def post_event(event: Callable[[], object], /) -> None: ...
def write(string: str, stream: int = ...) -> None: ...
@@ -83,31 +85,31 @@ class Value:
def __index__(self) -> int: ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
- def __add__(self, other: _ValueOrNative) -> Value: ...
- def __radd__(self, other: _ValueOrNative) -> Value: ...
- def __sub__(self, other: _ValueOrNative) -> Value: ...
- def __rsub__(self, other: _ValueOrNative) -> Value: ...
- def __mul__(self, other: _ValueOrNative) -> Value: ...
- def __rmul__(self, other: _ValueOrNative) -> Value: ...
- def __truediv__(self, other: _ValueOrNative) -> Value: ...
- def __rtruediv__(self, other: _ValueOrNative) -> Value: ...
- def __mod__(self, other: _ValueOrNative) -> Value: ...
- def __rmod__(self, other: _ValueOrNative) -> Value: ...
- def __pow__(self, other: _ValueOrNative, mod: None = None) -> Value: ...
- def __and__(self, other: _ValueOrNative) -> Value: ...
- def __or__(self, other: _ValueOrNative) -> Value: ...
- def __xor__(self, other: _ValueOrNative) -> Value: ...
- def __lshift__(self, other: _ValueOrNative) -> Value: ...
- def __rshift__(self, other: _ValueOrNative) -> Value: ...
- def __eq__(self, other: _ValueOrNative) -> bool: ... # type: ignore[override]
- def __ne__(self, other: _ValueOrNative) -> bool: ... # type: ignore[override]
- def __lt__(self, other: _ValueOrNative) -> bool: ...
- def __le__(self, other: _ValueOrNative) -> bool: ...
- def __gt__(self, other: _ValueOrNative) -> bool: ...
- def __ge__(self, other: _ValueOrNative) -> bool: ...
- def __getitem__(self, key: int | str | Field) -> Value: ...
+ def __add__(self, other: _ValueOrNative, /) -> Value: ...
+ def __radd__(self, other: _ValueOrNative, /) -> Value: ...
+ def __sub__(self, other: _ValueOrNative, /) -> Value: ...
+ def __rsub__(self, other: _ValueOrNative, /) -> Value: ...
+ def __mul__(self, other: _ValueOrNative, /) -> Value: ...
+ def __rmul__(self, other: _ValueOrNative, /) -> Value: ...
+ def __truediv__(self, other: _ValueOrNative, /) -> Value: ...
+ def __rtruediv__(self, other: _ValueOrNative, /) -> Value: ...
+ def __mod__(self, other: _ValueOrNative, /) -> Value: ...
+ def __rmod__(self, other: _ValueOrNative, /) -> Value: ...
+ def __pow__(self, other: _ValueOrNative, mod: None = None, /) -> Value: ...
+ def __and__(self, other: _ValueOrNative, /) -> Value: ...
+ def __or__(self, other: _ValueOrNative, /) -> Value: ...
+ def __xor__(self, other: _ValueOrNative, /) -> Value: ...
+ def __lshift__(self, other: _ValueOrNative, /) -> Value: ...
+ def __rshift__(self, other: _ValueOrNative, /) -> Value: ...
+ def __eq__(self, other: _ValueOrNative, /) -> bool: ... # type: ignore[override]
+ def __ne__(self, other: _ValueOrNative, /) -> bool: ... # type: ignore[override]
+ def __lt__(self, other: _ValueOrNative, /) -> bool: ...
+ def __le__(self, other: _ValueOrNative, /) -> bool: ...
+ def __gt__(self, other: _ValueOrNative, /) -> bool: ...
+ def __ge__(self, other: _ValueOrNative, /) -> bool: ...
+ def __getitem__(self, key: int | str | Field, /) -> Value: ...
def __call__(self, *args: _ValueOrNative) -> Value: ...
- def __init__(self, val: _ValueOrNative) -> None: ...
+ def __init__(self, val: _ValueOrNative, type: Type | None = None) -> None: ...
def cast(self, type: Type) -> Value: ...
def dereference(self) -> Value: ...
def referenced_value(self) -> Value: ...
@@ -125,9 +127,12 @@ class Value:
symbols: bool = ...,
unions: bool = ...,
address: bool = ...,
+ styling: bool = ...,
+ nibbles: bool = ...,
deref_refs: bool = ...,
actual_objects: bool = ...,
static_members: bool = ...,
+ max_characters: int = ...,
max_elements: int = ...,
max_depth: int = ...,
repeat_threshold: int = ...,
@@ -175,7 +180,7 @@ class Type(Mapping[str, Field]):
def get(self, key: str, default: Any = ...) -> Field | Any: ...
def has_key(self, key: str) -> bool: ...
def __len__(self) -> int: ...
- def __getitem__(self, key: str) -> Field: ...
+ def __getitem__(self, key: str, /) -> Field: ...
def __iter__(self) -> TypeIterator[str]: ...
_T = TypeVar("_T")
@@ -238,6 +243,7 @@ SEARCH_FUNCTION_DOMAIN: Final[int]
# Pretty Printing
+@type_check_only
class _PrettyPrinter(Protocol):
# TODO: The "children" and "display_hint" methods are optional for
# pretty-printers. Unfortunately, there is no such thing as an optional
@@ -258,12 +264,15 @@ type_printers: list[gdb.types._TypePrinter]
# Filtering Frames
+@type_check_only
class _FrameFilter(Protocol):
name: str
enabled: bool
priority: int
- def filter(self, iterator: Iterator[gdb.FrameDecorator.FrameDecorator]) -> Iterator[gdb.FrameDecorator.FrameDecorator]: ...
+ def filter(
+ self, iterator: Iterator[gdb.FrameDecorator.FrameDecorator | gdb.FrameDecorator.DAPFrameDecorator]
+ ) -> Iterator[gdb.FrameDecorator.FrameDecorator | gdb.FrameDecorator.DAPFrameDecorator]: ...
frame_filters: dict[str, _FrameFilter]
@@ -271,7 +280,7 @@ frame_filters: dict[str, _FrameFilter]
@final
class PendingFrame:
- def read_register(self, reg: str | RegisterDescriptor | int, /) -> Value: ...
+ def read_register(self, register: str | RegisterDescriptor | int) -> Value: ...
def create_unwind_info(self, frame_id: object, /) -> UnwindInfo: ...
def architecture(self) -> Architecture: ...
def language(self): ...
@@ -285,7 +294,7 @@ class PendingFrame:
@final
class UnwindInfo:
- def add_saved_register(self, reg: str | RegisterDescriptor | int, value: Value, /) -> None: ...
+ def add_saved_register(self, register: str | RegisterDescriptor | int, value: Value) -> None: ...
@type_check_only
class _Unwinder(Protocol):
@@ -312,14 +321,16 @@ class Inferior:
pid: int
was_attached: bool
progspace: Progspace
- main_name: Incomplete
- arguments: Incomplete
-
+ main_name: str | None
+ @property
+ def arguments(self) -> str | None: ...
+ @arguments.setter
+ def arguments(self, args: str | Sequence[str]) -> None: ...
def is_valid(self) -> bool: ...
def threads(self) -> tuple[InferiorThread, ...]: ...
def architecture(self) -> Architecture: ...
def read_memory(self, address: _ValueOrInt, length: int) -> memoryview: ...
- def write_memory(self, address: _ValueOrInt, buffer: _BufferType, length: int = ...) -> memoryview: ...
+ def write_memory(self, address: _ValueOrInt, buffer: _BufferType, length: int = ...) -> None: ...
def search_memory(self, address: _ValueOrInt, length: int, pattern: _BufferType) -> int | None: ...
def thread_from_handle(self, handle: Value) -> InferiorThread: ...
@deprecated("Use gdb.thread_from_handle() instead.")
@@ -366,6 +377,7 @@ class Record:
function_call_history: list[RecordFunctionSegment]
def goto(self, instruction: Instruction, /) -> None: ...
+ def clear(self) -> None: ...
class Instruction:
pc: int
@@ -475,7 +487,7 @@ class Progspace:
type_printers: list[gdb.types._TypePrinter]
frame_filters: dict[str, _FrameFilter]
frame_unwinders: list[_Unwinder]
- missing_debug_handlers: Incomplete
+ missing_file_handlers: Sequence[tuple[Literal["debug"], MissingDebugHandler] | tuple[Literal["file"], MissingFileHandler]]
def block_for_pc(self, pc: int, /) -> Block | None: ...
def find_pc_line(self, pc: int, /) -> Symtab_and_line: ...
@@ -538,17 +550,17 @@ class Frame:
def architecture(self) -> Architecture: ...
def type(self) -> int: ...
def unwind_stop_reason(self) -> int: ...
- def pc(self) -> Value: ...
+ def pc(self) -> int: ...
def block(self) -> Block: ...
def function(self) -> Symbol: ...
def older(self) -> Frame | None: ...
def newer(self) -> Frame | None: ...
def find_sal(self) -> Symtab_and_line: ...
- def read_register(self, register: str | RegisterDescriptor | int, /) -> Value: ...
- def read_var(self, variable: str | Symbol, /, block: Block | None = ...) -> Value: ...
+ def read_register(self, register: str | RegisterDescriptor | int) -> Value: ...
+ def read_var(self, variable: str | Symbol, block: Block | None = ...) -> Value: ...
def select(self) -> None: ...
def level(self) -> int: ...
- def static_link(self) -> Incomplete | None: ...
+ def static_link(self) -> Frame | None: ...
def language(self): ...
# Blocks
@@ -594,6 +606,7 @@ class Symbol:
is_constant: bool
is_function: bool
is_variable: bool
+ is_artificial: bool
def is_valid(self) -> bool: ...
def value(self, frame: Frame = ..., /) -> Value: ...
@@ -670,13 +683,12 @@ class LineTable:
# Breakpoints
class Breakpoint:
-
# The where="spec" form of __init__(). See py-breakpoints.c:bppy_init():keywords for the positional order.
@overload
def __init__(
self,
# where
- spec: str,
+ spec: str = ...,
# options
type: int = ...,
wp_class: int = ...,
@@ -811,7 +823,7 @@ class Breakpoint:
temporary: bool
hit_count: int
location: str | None
- locations: Incomplete
+ locations: Sequence[BreakpointLocation]
inferior: int | None
expression: str | None
condition: str | None
@@ -819,13 +831,13 @@ class Breakpoint:
@final
class BreakpointLocation:
- address: Incomplete
+ address: int
enabled: bool
fullname: str
- function: Incomplete
- owner: Incomplete
- source: Incomplete
- thread_groups: Incomplete
+ function: str | None
+ owner: Breakpoint
+ source: tuple[str, int]
+ thread_groups: Sequence[int]
BP_NONE: int
BP_BREAKPOINT: int
@@ -860,10 +872,16 @@ class LazyString:
# Architectures
+@type_check_only
+class _Instruction(TypedDict):
+ addr: int
+ asm: str
+ length: int
+
@final
class Architecture:
def name(self) -> str: ...
- def disassemble(self, start_pc: int, end_pc: int = ..., count: int = ...) -> list[dict[str, object]]: ...
+ def disassemble(self, start_pc: int, end_pc: int = ..., count: int = ...) -> list[_Instruction]: ...
def integer_type(self, size: int, signed: bool = ...) -> Type: ...
def registers(self, reggroup: str = ...) -> RegisterDescriptorIterator: ...
def register_groups(self) -> RegisterGroupsIterator: ...
@@ -912,8 +930,9 @@ class TuiWindow:
def is_valid(self) -> bool: ...
def erase(self) -> None: ...
- def write(self, string: str, full_window: bool = ..., /) -> None: ...
+ def write(self, string: str, full_window: bool = ...) -> None: ...
+@type_check_only
class _Window(Protocol):
def close(self) -> None: ...
def render(self) -> None: ...
@@ -934,18 +953,19 @@ class ExitedEvent(Event):
inferior: Inferior
class ThreadExitedEvent(Event): ...
-class StopEvent(ThreadEvent): ...
+
+class StopEvent(ThreadEvent):
+ details: dict[str, object]
class BreakpointEvent(StopEvent):
breakpoints: Sequence[Breakpoint]
breakpoint: Breakpoint
-missing_debug_handlers: list[Incomplete]
-
class NewObjFileEvent(Event):
new_objfile: Objfile
-class FreeObjFileEvent(Event): ...
+class FreeObjFileEvent(Event):
+ objfile: Objfile
class ClearObjFilesEvent(Event):
progspace: Progspace
@@ -956,6 +976,7 @@ class FreeProgspaceEvent(Event): ...
class SignalEvent(StopEvent):
stop_signal: str
+@type_check_only
class _InferiorCallEvent(Event): ...
class InferiorCallPreEvent(_InferiorCallEvent):
@@ -990,6 +1011,9 @@ class ConnectionEvent(Event):
class ExecutableChangedEvent(Event): ...
+class TuiEnabledEvent(Event):
+ enabled: bool
+
_ET = TypeVar("_ET", bound=Event | Breakpoint | None)
@final
@@ -1000,3 +1024,6 @@ class EventRegistry(Generic[_ET]):
class ValuePrinter: ...
def blocked_signals(): ...
+def notify_mi(name: str, data: dict[str, object] | None = None): ...
+def interrupt(): ...
+def execute_mi(command: str, *args: str) -> dict[str, object]: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/__init__.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/__init__.pyi
index 2eb66f91e63a..9c9c1931ee7e 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/__init__.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/__init__.pyi
@@ -1,11 +1,19 @@
-from typing import Any
-
-class Server:
- def __init__(self, in_stream, out_stream, child_stream) -> None: ...
- def main_loop(self) -> None: ...
- def send_event(self, event: str, body: Any | None = None) -> None: ... # body is an arbitrary object
- def send_event_later(self, event: str, body: Any | None = None) -> None: ... # body is an arbitrary object
- def shutdown(self) -> None: ...
+from . import (
+ breakpoint as breakpoint,
+ bt as bt,
+ evaluate as evaluate,
+ launch as launch,
+ locations as locations,
+ memory as memory,
+ modules as modules,
+ next as next,
+ pause as pause,
+ scopes as scopes,
+ sources as sources,
+ startup as startup,
+ threads as threads,
+)
+from .server import Server as Server
def pre_command_loop() -> None: ...
def run() -> None: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/breakpoint.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/breakpoint.pyi
index 5b0f74feb261..6e96978e2f43 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/breakpoint.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/breakpoint.pyi
@@ -1 +1,49 @@
-def __getattr__(name: str): ... # incomplete module
+from _typeshed import Incomplete, Unused
+from collections.abc import Sequence
+from contextlib import AbstractContextManager
+from typing import TypedDict, type_check_only
+from typing_extensions import NotRequired
+
+import gdb
+
+from .sources import Source
+
+@type_check_only
+class _SourceBreakpoint(TypedDict):
+ source: str
+ line: int
+ condition: NotRequired[str | None]
+ hitCondition: NotRequired[str | None]
+ logMessage: NotRequired[str | None]
+
+@type_check_only
+class _ExceptionFilterOptions(TypedDict):
+ filderId: str
+ condition: NotRequired[str | None]
+
+@type_check_only
+class _BreakpointDescriptor(TypedDict):
+ id: int
+ verified: bool
+ reason: NotRequired[str] # only present when verified is False. Possibly only literal "pending" or "failed"
+ message: NotRequired[str] # only present when reason == "failed"
+ source: NotRequired[Source]
+ line: NotRequired[int]
+ instructionReference: NotRequired[str]
+
+@type_check_only
+class _SetBreakpointResult(TypedDict):
+ breakpoints: list[_BreakpointDescriptor]
+
+# frozenset entries are tuples from _SourceBreakpoint.items() or _ExceptionFilterOptions.items()
+breakpoint_map: dict[str, dict[frozenset[Incomplete], gdb.Breakpoint]]
+
+def suppress_new_breakpoint_event() -> AbstractContextManager[None]: ...
+def set_breakpoint(*, source: Source, breakpoints: Sequence[_SourceBreakpoint] = (), **args: Unused) -> _SetBreakpointResult: ...
+def set_fn_breakpoint(*, breakpoints: Sequence[_SourceBreakpoint], **args: Unused) -> _SetBreakpointResult: ...
+def set_insn_breakpoints(
+ *, breakpoints: Sequence[_SourceBreakpoint], offset: int | None = None, **args: Unused
+) -> _SetBreakpointResult: ...
+def set_exception_breakpoints(
+ *, filters: Sequence[str], filterOptions: Sequence[_ExceptionFilterOptions] = (), **args: Unused
+) -> _SetBreakpointResult: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/bt.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/bt.pyi
index 5b0f74feb261..0127cfbbaa0a 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/bt.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/bt.pyi
@@ -1 +1,49 @@
-def __getattr__(name: str): ... # incomplete module
+from _typeshed import Unused
+from typing import TypedDict, type_check_only
+from typing_extensions import NotRequired
+
+from .sources import Source
+from .varref import _ValueFormat
+
+@type_check_only
+class _StackFrameFormat(_ValueFormat, total=False):
+ parameters: bool
+ parameterTypes: bool
+ parameterNames: bool
+ parameterValues: bool
+ line: bool
+ module: bool
+ includeAll: bool
+
+@type_check_only
+class _StackFrame(TypedDict):
+ id: int
+ name: str
+ line: int
+ column: int
+ instructionPointerReference: str
+ moduleId: NotRequired[str | None]
+ source: NotRequired[Source]
+
+@type_check_only
+class _StackTraceResult(TypedDict):
+ stackFrames: list[_StackFrame]
+
+def check_stack_frame(
+ *,
+ # From source:
+ # Note that StackFrameFormat extends ValueFormat, which is why
+ # "hex" appears here.
+ hex: bool = False,
+ parameters: bool = False,
+ parameterTypes: bool = False,
+ parameterNames: bool = False,
+ parameterValues: bool = False,
+ line: bool = False,
+ module: bool = False,
+ includeAll: bool = False,
+ **rest: Unused,
+) -> _StackFrameFormat: ...
+def stacktrace(
+ *, levels: int = 0, startFrame: int = 0, threadId: int, format: _StackFrameFormat | None = None, **extra: Unused
+) -> _StackTraceResult: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/disassemble.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/disassemble.pyi
index 5b0f74feb261..387dbaf4b9bc 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/disassemble.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/disassemble.pyi
@@ -1 +1,22 @@
-def __getattr__(name: str): ... # incomplete module
+from _typeshed import Unused
+from typing import TypedDict, type_check_only
+from typing_extensions import NotRequired
+
+from .sources import Source
+
+@type_check_only
+class _Instruction(TypedDict):
+ address: str
+ instruction: str
+ instructionBytes: str
+ symbol: NotRequired[str] # only set if there's a corresponding label
+ line: NotRequired[int] # only set if source is available
+ location: NotRequired[Source] # only set if source is available
+
+@type_check_only
+class _DisassembleResult(TypedDict):
+ instructions: list[_Instruction]
+
+def disassemble(
+ *, memoryReference: str, offset: int = 0, instructionOffset: int = 0, instructionCount: int, **extra: Unused
+) -> _DisassembleResult: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/evaluate.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/evaluate.pyi
index 5b0f74feb261..04cd64085758 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/evaluate.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/evaluate.pyi
@@ -1 +1,31 @@
-def __getattr__(name: str): ... # incomplete module
+from _typeshed import Unused
+from typing import Literal, TypedDict, type_check_only
+
+import gdb
+
+from .varref import VariableReference, _ValueFormat, _VariableReferenceDescriptor
+
+class EvaluateResult(VariableReference):
+ def __init__(self, value: gdb.Value) -> None: ...
+
+@type_check_only
+class _VariablesResult(TypedDict):
+ variables: list[_VariableReferenceDescriptor]
+
+def eval_request(
+ *,
+ expression: str,
+ frameId: int | None = None,
+ context: Literal["watch", "variables", "hover", "repl"] = "variables",
+ format: _ValueFormat | None = None,
+ **args: Unused,
+) -> _VariableReferenceDescriptor: ...
+def variables(
+ *, variablesReference: int, start: int = 0, count: int = 0, format: _ValueFormat | None = None, **args: Unused
+) -> _VariablesResult: ...
+def set_expression(
+ *, expression: str, value: str, frameId: int | None = None, format: _ValueFormat | None = None, **args: Unused
+) -> _VariableReferenceDescriptor: ...
+def set_variable(
+ *, variablesReference: int, name: str, value: str, format: _ValueFormat | None = None, **args: Unused
+) -> _VariableReferenceDescriptor: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/events.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/events.pyi
index 5b0f74feb261..7cd269266eff 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/events.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/events.pyi
@@ -1 +1,12 @@
-def __getattr__(name: str): ... # incomplete module
+import gdb
+
+inferior_running: bool
+
+def send_process_event_once() -> None: ...
+def expect_process(reason: str) -> None: ...
+def thread_event(event: gdb.ThreadEvent, reason: str) -> None: ...
+def expect_stop(reason: str) -> None: ...
+def exec_and_expect_stop(cmd: str, expected_pause: bool = False) -> None: ...
+
+# Map from gdb stop reasons to DAP stop reasons.
+stop_reason_map: dict[str, str]
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/frames.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/frames.pyi
index 5b0f74feb261..3c7d516e36c6 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/frames.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/frames.pyi
@@ -1 +1,7 @@
-def __getattr__(name: str): ... # incomplete module
+from collections.abc import Generator
+
+import gdb
+
+def frame_for_id(id: int) -> gdb.Frame: ...
+def select_frame(id: int) -> None: ...
+def dap_frame_generator(frame_low: int, levels: int, include_all: bool) -> Generator[tuple[int, gdb.Frame]]: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/io.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/io.pyi
index 5b0f74feb261..2cf4f182f395 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/io.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/io.pyi
@@ -1 +1,16 @@
-def __getattr__(name: str): ... # incomplete module
+from _typeshed import SupportsFlush, SupportsRead, SupportsReadline, SupportsWrite
+from typing import Any, type_check_only
+
+import gdb
+
+from .server import _JSONValue
+from .startup import DAPQueue
+
+@type_check_only
+class _SupportsReadAndReadlineBytes(SupportsRead[bytes], SupportsReadline[bytes]): ...
+
+@type_check_only
+class _SupportsWriteAndFlushBytes(SupportsWrite[bytes], SupportsFlush): ...
+
+def read_json(stream: _SupportsReadAndReadlineBytes) -> Any: ... # returns result of json.loads
+def start_json_writer(stream: _SupportsWriteAndFlushBytes, queue: DAPQueue[_JSONValue]) -> gdb.Thread: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/launch.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/launch.pyi
index 5b0f74feb261..5d573114df88 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/launch.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/launch.pyi
@@ -1 +1,14 @@
-def __getattr__(name: str): ... # incomplete module
+from _typeshed import Unused
+from collections.abc import Mapping, Sequence
+
+def launch(
+ *,
+ program: str | None = None,
+ cwd: str | None = None,
+ args: Sequence[str] = (),
+ env: Mapping[str, str] | None = None,
+ stopAtBeginningOfMainSubprogram: bool = False,
+ **extra: Unused,
+): ...
+def attach(*, program: str | None = None, pid: int | None = None, target: str | None = None, **args: Unused) -> None: ...
+def config_done(**args: Unused) -> None: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/locations.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/locations.pyi
index 5b0f74feb261..da63e65c83ea 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/locations.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/locations.pyi
@@ -1 +1,16 @@
-def __getattr__(name: str): ... # incomplete module
+from _typeshed import Unused
+from typing import TypedDict, type_check_only
+
+from .sources import Source
+
+@type_check_only
+class _Line(TypedDict):
+ line: int
+
+@type_check_only
+class _BreakpointLocationsResult(TypedDict):
+ breakpoints: list[_Line]
+
+def breakpoint_locations(
+ *, source: Source, line: int, endLine: int | None = None, **extra: Unused
+) -> _BreakpointLocationsResult: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/memory.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/memory.pyi
index 5b0f74feb261..b6a33a3d1262 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/memory.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/memory.pyi
@@ -1 +1,10 @@
-def __getattr__(name: str): ... # incomplete module
+from _typeshed import Unused
+from typing import TypedDict, type_check_only
+
+@type_check_only
+class _ReadMemoryResult(TypedDict):
+ address: str
+ data: str
+
+def read_memory(*, memoryReference: str, offset: int = 0, count: int, **extra: Unused) -> _ReadMemoryResult: ...
+def write_memory(*, memoryReference: str, offset: int = 0, data: str, **extra: Unused): ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/modules.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/modules.pyi
index 5b0f74feb261..eae61cfb47da 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/modules.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/modules.pyi
@@ -1 +1,21 @@
-def __getattr__(name: str): ... # incomplete module
+from _typeshed import Unused
+from typing import TypedDict, type_check_only
+from typing_extensions import NotRequired
+
+import gdb
+
+@type_check_only
+class _Module(TypedDict):
+ id: str | None
+ name: str | None
+ path: NotRequired[str | None]
+
+@type_check_only
+class _ModulesResult(TypedDict):
+ modules: list[_Module]
+ totalModules: int
+
+def module_id(objfile: gdb.Objfile) -> str | None: ...
+def is_module(objfile: gdb.Objfile) -> bool: ...
+def make_module(objf: gdb.Objfile) -> _Module: ...
+def modules(*, startModule: int = 0, moduleCount: int = 0, **args: Unused) -> _ModulesResult: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/next.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/next.pyi
index 5b0f74feb261..c23e4260b950 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/next.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/next.pyi
@@ -1 +1,14 @@
-def __getattr__(name: str): ... # incomplete module
+from _typeshed import Unused
+from typing import Literal, TypedDict, type_check_only
+from typing_extensions import TypeAlias
+
+@type_check_only
+class _ContinueRequestResult(TypedDict):
+ allThreadsContinued: bool
+
+_Granularity: TypeAlias = Literal["statement", "instruction"]
+
+def next(*, threadId: int, singleThread: bool = False, granularity: _Granularity = "statement", **args: Unused) -> None: ...
+def step_in(*, threadId: int, singleThread: bool = False, granularity: _Granularity = "statement", **args: Unused) -> None: ...
+def step_out(*, threadId: int, singleThread: bool = False, **args: Unused): ...
+def continue_request(*, threadId: int, singleThread: bool = False, **args: Unused) -> _ContinueRequestResult: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/pause.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/pause.pyi
index 5b0f74feb261..6343b7b03156 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/pause.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/pause.pyi
@@ -1 +1,3 @@
-def __getattr__(name: str): ... # incomplete module
+from _typeshed import Unused
+
+def pause(**args: Unused) -> None: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/scopes.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/scopes.pyi
index 5b0f74feb261..c5421b6f747f 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/scopes.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/scopes.pyi
@@ -1 +1,47 @@
-def __getattr__(name: str): ... # incomplete module
+from _typeshed import Unused
+from collections.abc import Iterable
+from typing import TypedDict, type_check_only
+from typing_extensions import NotRequired
+
+import gdb
+
+from ..FrameDecorator import FrameDecorator, SymValueWrapper
+from .varref import BaseReference, _ReferenceDescriptor
+
+frame_to_scope: dict[int, _ScopeReference]
+
+@type_check_only
+class _ScopeReferenceDescriptor(_ReferenceDescriptor):
+ presentationHint: str
+ expensive: bool
+ namedVariables: int
+ line: NotRequired[int]
+
+@type_check_only
+class _ScopesResult(TypedDict):
+ scopes: list[_ScopeReferenceDescriptor]
+
+def clear_scopes(event: Unused) -> None: ...
+def set_finish_value(val: gdb.Value) -> None: ...
+def symbol_value(sym: SymValueWrapper, frame: FrameDecorator) -> tuple[str, gdb.Value]: ...
+
+class _ScopeReference(BaseReference):
+ hint: str
+ frame: FrameDecorator
+ inf_frame: gdb.Frame
+ function: str | None
+ line: int | None
+ var_list: tuple[SymValueWrapper, ...]
+ def __init__(self, name: str, hint: str, frame: FrameDecorator, var_list: Iterable[SymValueWrapper]) -> None: ...
+ def to_object(self) -> _ScopeReferenceDescriptor: ...
+ def has_children(self) -> bool: ...
+ def child_count(self) -> int: ...
+ # note: parameter named changed from 'index' to 'idx'
+ def fetch_one_child(self, idx: int) -> tuple[str, gdb.Value]: ...
+
+class _FinishScopeReference(_ScopeReference): ...
+
+class _RegisterReference(_ScopeReference):
+ def __init__(self, name: str, frame: FrameDecorator) -> None: ...
+
+def scopes(*, frameId: int, **extra: Unused) -> _ScopesResult: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/server.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/server.pyi
index 5b0f74feb261..22b8231f7d54 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/server.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/server.pyi
@@ -1 +1,77 @@
-def __getattr__(name: str): ... # incomplete module
+import threading
+from _typeshed import Incomplete, SupportsReadline, Unused
+from collections.abc import Callable
+from contextlib import AbstractContextManager
+from typing import Any, Generic, TypeVar, type_check_only
+from typing_extensions import TypeAlias
+
+from .io import _SupportsReadAndReadlineBytes, _SupportsWriteAndFlushBytes
+from .startup import DAPQueue
+
+_T = TypeVar("_T")
+_F = TypeVar("_F", bound=Callable[..., Any])
+
+_RequestID: TypeAlias = int
+_EventBody: TypeAlias = Any # arbitrary object, implicitly constrained by the event being sent
+_JSONValue: TypeAlias = Any # any object that can be handled by json.dumps/json.loads
+
+class NotStoppedException(Exception): ...
+
+class CancellationHandler:
+ lock: threading.Lock
+ reqs: list[_RequestID]
+ in_flight_dap_thread: _RequestID | None
+ in_flight_gdb_thread: _RequestID | None
+ def starting(self, req: _RequestID) -> None: ...
+ def done(self, req: _RequestID) -> None: ... # req argument is not used
+ def cancel(self, req: _RequestID) -> None: ...
+ def interruptable_region(self, req: _RequestID | None) -> AbstractContextManager[None]: ...
+
+class Server:
+ in_stream: _SupportsReadAndReadlineBytes
+ out_stream: _SupportsWriteAndFlushBytes
+ child_stream: SupportsReadline[str]
+ delay_events: list[tuple[str, _EventBody]]
+ write_queue: DAPQueue[_JSONValue | None]
+ read_queue: DAPQueue[_JSONValue | None]
+ done: bool
+ canceller: CancellationHandler
+ config: dict[str, Incomplete]
+ def __init__(
+ self,
+ in_stream: _SupportsReadAndReadlineBytes,
+ out_stream: _SupportsWriteAndFlushBytes,
+ child_stream: SupportsReadline[str],
+ ) -> None: ...
+ def main_loop(self) -> None: ...
+ def send_event(self, event: str, body: _EventBody | None = None) -> None: ...
+ def send_event_later(self, event: str, body: _EventBody | None = None) -> None: ...
+ def shutdown(self) -> None: ...
+
+def send_event(event: str, body: _EventBody | None = None) -> None: ...
+@type_check_only
+class _Wrapper:
+ def __call__(self, func: _F) -> _F: ...
+
+def request(name: str, *, response: bool = True, on_dap_thread: bool = False, expect_stopped: bool = True) -> _Wrapper: ...
+def capability(name: str, value: bool = True) -> _Wrapper: ...
+def client_bool_capability(name: str) -> bool: ...
+def initialize(**args) -> dict[str, bool]: ... # args is arbitrary values for Server.config
+def terminate(**args: Unused) -> None: ...
+def disconnect(*, terminateDebuggee: bool = False, **args: Unused): ...
+def cancel(**args: Unused) -> None: ...
+
+class Invoker:
+ cmd: str
+ def __init__(self, cmd: str) -> None: ...
+ def __call__(self) -> None: ...
+
+class Cancellable(Generic[_T]):
+ fn: Callable[[], _T]
+ result_q: DAPQueue[_T] | None
+ req: _RequestID
+ def __init__(self, fn: Callable[[], _T], result_q: DAPQueue[_T] | None = None) -> None: ...
+ def __call__(self) -> None: ...
+
+def send_gdb(cmd: str | Callable[[], object]) -> None: ...
+def send_gdb_with_response(fn: str | Callable[[], _T]) -> _T: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/sources.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/sources.pyi
index 5b0f74feb261..f12bcb3c9ab9 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/sources.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/sources.pyi
@@ -1 +1,24 @@
-def __getattr__(name: str): ... # incomplete module
+from _typeshed import Unused
+from typing import TypedDict, type_check_only
+from typing_extensions import TypeAlias
+
+_SourceReferenceID: TypeAlias = int
+
+@type_check_only
+class Source(TypedDict, total=False):
+ name: str
+ path: str
+ sourceReference: _SourceReferenceID
+
+@type_check_only
+class _LoadSourcesResult(TypedDict):
+ sources: list[Source]
+
+@type_check_only
+class _SourceResult(TypedDict):
+ content: str
+
+def make_source(fullname: str, filename: str | None) -> Source: ...
+def decode_source(source: Source) -> _SourceReferenceID: ...
+def loaded_sources(**extra: Unused) -> _LoadSourcesResult: ...
+def source(*, source: Source | None = None, sourceReference: _SourceReferenceID, **extra: Unused) -> _SourceResult: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/startup.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/startup.pyi
index 5b0f74feb261..702f2d8bf77b 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/startup.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/startup.pyi
@@ -1 +1,44 @@
-def __getattr__(name: str): ... # incomplete module
+import enum
+import io
+import queue
+import threading
+from collections.abc import Callable, Iterable
+from typing import Any, ClassVar, TypeVar
+from typing_extensions import TypeAlias
+
+import gdb
+
+_T = TypeVar("_T")
+_F = TypeVar("_F", bound=Callable[..., Any])
+
+DAPQueue: TypeAlias = queue.SimpleQueue[_T]
+
+class DAPException(Exception): ...
+
+def parse_and_eval(expression: str, global_context: bool = False) -> gdb.Value: ...
+
+# target and args are passed to gdb.Thread
+def start_thread(name: str, target: Callable[..., object], args: Iterable[Any] = ()) -> gdb.Thread: ...
+def start_dap(target: Callable[..., object]) -> None: ...
+def in_gdb_thread(func: _F) -> _F: ...
+def in_dap_thread(func: _F) -> _F: ...
+
+class LogLevel(enum.IntEnum):
+ DEFAULT = 1
+ FULL = 2
+
+class LogLevelParam(gdb.Parameter):
+ def __init__(self) -> None: ...
+
+class LoggingParam(gdb.Parameter):
+ lock: ClassVar[threading.Lock]
+ log_file: io.TextIOWrapper | None
+ def __init__(self) -> None: ...
+ def get_set_string(self) -> str: ...
+
+dap_log: LoggingParam
+
+def log(something: object, level: LogLevel = LogLevel.DEFAULT) -> None: ...
+def thread_log(something: object, level: LogLevel = LogLevel.DEFAULT) -> None: ...
+def log_stack(level: LogLevel = LogLevel.DEFAULT) -> None: ...
+def exec_and_log(cmd: str) -> None: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/state.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/state.pyi
index 5b0f74feb261..1d80080e1531 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/state.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/state.pyi
@@ -1 +1 @@
-def __getattr__(name: str): ... # incomplete module
+def set_thread(thread_id: int) -> None: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/threads.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/threads.pyi
index 5b0f74feb261..3de0ccff3b13 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/threads.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/threads.pyi
@@ -1 +1,14 @@
-def __getattr__(name: str): ... # incomplete module
+from _typeshed import Unused
+from typing import TypedDict, type_check_only
+from typing_extensions import NotRequired
+
+@type_check_only
+class _Thread(TypedDict):
+ id: int
+ name: NotRequired[str]
+
+@type_check_only
+class _ThreadsResult(TypedDict):
+ threads: list[_Thread]
+
+def threads(**args: Unused) -> _ThreadsResult: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/typecheck.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/typecheck.pyi
index 5b0f74feb261..37993cca7a34 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/typecheck.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/typecheck.pyi
@@ -1 +1,6 @@
-def __getattr__(name: str): ... # incomplete module
+from collections.abc import Callable
+from typing import Any, TypeVar
+
+_F = TypeVar("_F", bound=Callable[..., Any])
+
+def type_check(func: _F) -> _F: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/dap/varref.pyi b/python/helpers/typeshed/stubs/gdb/gdb/dap/varref.pyi
index 5b0f74feb261..83d700607585 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/dap/varref.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/dap/varref.pyi
@@ -1 +1,70 @@
-def __getattr__(name: str): ... # incomplete module
+import abc
+from _typeshed import Unused
+from collections import defaultdict
+from collections.abc import Generator
+from contextlib import AbstractContextManager
+from typing import TypedDict, type_check_only
+from typing_extensions import NotRequired
+
+import gdb
+
+@type_check_only
+class _ValueFormat(TypedDict, total=False):
+ hex: bool
+
+@type_check_only
+class _ReferenceDescriptor(TypedDict):
+ # Result of BaseReference.to_object()
+ variableReference: int
+ name: NotRequired[str]
+
+@type_check_only
+class _VariableReferenceDescriptor(_ReferenceDescriptor):
+ # Result of VariableReference.to_object()
+ indexedVariables: NotRequired[int]
+ namedVariables: NotRequired[int]
+ memoryReference: NotRequired[str]
+ type: NotRequired[str]
+ # Below key name set by VariableReference.result_name
+ # Could be modelled with extra_items=str if PEP 728 is accepted.
+ value: NotRequired[str]
+
+all_variables: list[BaseReference]
+
+def clear_vars(event: Unused) -> None: ...
+def apply_format(value_format: _ValueFormat | None) -> AbstractContextManager[None]: ...
+
+class BaseReference(abc.ABC):
+ ref: int
+ name: str
+ children: list[VariableReference | None] | None
+ by_name: dict[str, VariableReference]
+ name_counts: defaultdict[str, int]
+ def __init__(self, name: str) -> None: ...
+ def to_object(self) -> _ReferenceDescriptor: ...
+ @abc.abstractmethod
+ def has_children(self) -> bool: ...
+ def reset_children(self): ...
+ @abc.abstractmethod
+ def fetch_one_child(self, index: int) -> tuple[str, gdb.Value]: ...
+ @abc.abstractmethod
+ def child_count(self) -> int: ...
+ def fetch_children(self, start: int, count: int) -> Generator[VariableReference]: ...
+ def find_child_by_name(self, name: str) -> VariableReference: ...
+
+class VariableReference(BaseReference):
+ result_name: str
+ value: gdb.Value
+ child_cache: list[tuple[int | str, gdb.Value]] | None
+ count: int | None
+ printer: gdb._PrettyPrinter
+ def __init__(self, name: str, value: gdb.Value, result_name: str = "value") -> None: ...
+ def assign(self, value: gdb.Value) -> None: ...
+ def has_children(self) -> bool: ...
+ def cache_children(self) -> list[tuple[int | str, gdb.Value]]: ...
+ def child_count(self) -> int: ...
+ def to_object(self) -> _VariableReferenceDescriptor: ...
+ # note: parameter named changed from 'index' to 'idx'
+ def fetch_one_child(self, idx: int) -> tuple[str, gdb.Value]: ...
+
+def find_variable(ref: int) -> BaseReference: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/disassembler.pyi b/python/helpers/typeshed/stubs/gdb/gdb/disassembler.pyi
index a1560c154600..9310e382307a 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/disassembler.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/disassembler.pyi
@@ -1,40 +1,41 @@
-from _typeshed import Incomplete
+from collections.abc import Sequence
from typing import Final, final
import gdb
+from gdb import Architecture, Progspace
class Disassembler:
def __init__(self, name: str) -> None: ...
def __call__(self, info): ...
class DisassembleInfo:
- address: Incomplete
- architecture: Incomplete
- progspace: Incomplete
- def __init__(self, /, *args, **kwargs) -> None: ...
- def address_part(self, address) -> DisassemblerAddressPart: ...
+ address: int
+ architecture: Architecture
+ progspace: Progspace
+ def __init__(self, info: DisassembleInfo) -> None: ...
+ def address_part(self, address: int) -> DisassemblerAddressPart: ...
def is_valid(self) -> bool: ...
- def read_memory(self, len, offset: int = 0): ...
- def text_part(self, string, style) -> DisassemblerTextPart: ...
+ def read_memory(self, len: int, offset: int = 0): ...
+ def text_part(self, style: int, string: str) -> DisassemblerTextPart: ...
class DisassemblerPart:
def __init__(self, /, *args, **kwargs) -> None: ...
@final
class DisassemblerAddressPart(DisassemblerPart):
- address: Incomplete
+ address: int
string: str
@final
class DisassemblerTextPart(DisassemblerPart):
string: str
- style: Incomplete
+ style: int
@final
class DisassemblerResult:
- def __init__(self, /, *args, **kwargs) -> None: ...
- length: Incomplete
- parts: Incomplete
+ def __init__(self, length: int, string: str | None = None, parts: Sequence[DisassemblerPart] | None = None) -> None: ...
+ length: int
+ parts: Sequence[DisassemblerPart]
string: str
STYLE_TEXT: Final = 0
@@ -48,7 +49,7 @@ STYLE_ADDRESS_OFFSET: Final = 7
STYLE_SYMBOL: Final = 8
STYLE_COMMENT_START: Final = 9
-def builtin_disassemble(INFO: DisassembleInfo, MEMORY_SOURCE=None) -> None: ...
+def builtin_disassemble(info: DisassembleInfo) -> None: ...
class maint_info_py_disassemblers_cmd(gdb.Command):
def __init__(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/events.pyi b/python/helpers/typeshed/stubs/gdb/gdb/events.pyi
index fab42e4fb73b..6160804bf485 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/events.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/events.pyi
@@ -22,3 +22,4 @@ new_thread: gdb.EventRegistry[gdb.NewThreadEvent]
gdb_exiting: gdb.EventRegistry[gdb.GdbExitingEvent]
connection_removed: gdb.EventRegistry[gdb.ConnectionEvent]
executable_changed: gdb.EventRegistry[gdb.ExecutableChangedEvent]
+tui_enabled: gdb.EventRegistry[gdb.TuiEnabledEvent]
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/missing_debug.pyi b/python/helpers/typeshed/stubs/gdb/gdb/missing_debug.pyi
index 81f716da27fa..1b9d5988f954 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/missing_debug.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/missing_debug.pyi
@@ -1,12 +1,8 @@
-from _typeshed import Incomplete
-
import gdb
+from gdb import Progspace
+from gdb.missing_files import MissingFileHandler
-class MissingDebugHandler:
- @property
- def name(self) -> str: ...
- enabled: bool
- def __init__(self, name: str) -> None: ...
+class MissingDebugHandler(MissingFileHandler):
def __call__(self, objfile: gdb.Objfile) -> bool | str | None: ...
-def register_handler(locus: Incomplete | None, handler: MissingDebugHandler, replace: bool = False) -> None: ...
+def register_handler(locus: Progspace | None, handler: MissingDebugHandler, replace: bool = False) -> None: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/missing_files.pyi b/python/helpers/typeshed/stubs/gdb/gdb/missing_files.pyi
new file mode 100644
index 000000000000..fbc6f113167d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/gdb/gdb/missing_files.pyi
@@ -0,0 +1,13 @@
+from typing import Literal
+
+from gdb import Progspace
+
+class MissingFileHandler:
+ @property
+ def name(self) -> str: ...
+ enabled: bool
+ def __init__(self, name: str) -> None: ...
+
+def register_handler(
+ handler_type: Literal["debug", "objfile"], locus: Progspace | None, handler: MissingFileHandler, replace: bool = False
+) -> None: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/missing_objfile.pyi b/python/helpers/typeshed/stubs/gdb/gdb/missing_objfile.pyi
new file mode 100644
index 000000000000..8e50b1c1baa5
--- /dev/null
+++ b/python/helpers/typeshed/stubs/gdb/gdb/missing_objfile.pyi
@@ -0,0 +1,7 @@
+from gdb import Progspace
+from gdb.missing_files import MissingFileHandler
+
+class MissingObjfileHandler(MissingFileHandler):
+ def __call__(self, buildid: str, filename: str) -> bool | str | None: ...
+
+def register_handler(locus: Progspace | None, handler: MissingObjfileHandler, replace: bool = False) -> None: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/types.pyi b/python/helpers/typeshed/stubs/gdb/gdb/types.pyi
index d87eeb3bec99..e74472a5d10a 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/types.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/types.pyi
@@ -1,5 +1,5 @@
from collections.abc import Iterator
-from typing import Protocol
+from typing import Protocol, type_check_only
import gdb
@@ -10,13 +10,14 @@ def deep_items(type_: gdb.Type) -> Iterator[tuple[str, gdb.Field]]: ...
def get_type_recognizers() -> list[_TypeRecognizer]: ...
def apply_type_recognizers(recognizers: list[_TypeRecognizer], type_obj: gdb.Type) -> str | None: ...
def register_type_printer(locus: gdb.Objfile | gdb.Progspace | None, printer: _TypePrinter) -> None: ...
-
+@type_check_only
class _TypePrinter(Protocol):
enabled: bool
name: str
def instantiate(self) -> _TypeRecognizer | None: ...
+@type_check_only
class _TypeRecognizer(Protocol):
def recognize(self, type: gdb.Type, /) -> str | None: ...
diff --git a/python/helpers/typeshed/stubs/gdb/gdb/xmethod.pyi b/python/helpers/typeshed/stubs/gdb/gdb/xmethod.pyi
index f61708ae62cf..9c0a2f34d0d7 100644
--- a/python/helpers/typeshed/stubs/gdb/gdb/xmethod.pyi
+++ b/python/helpers/typeshed/stubs/gdb/gdb/xmethod.pyi
@@ -1,13 +1,13 @@
from collections.abc import Sequence
from re import Pattern
-from typing import Protocol
+from typing import Protocol, type_check_only
import gdb
def register_xmethod_matcher(
locus: gdb.Objfile | gdb.Progspace | None, matcher: XMethodMatcher, replace: bool = False
) -> None: ...
-
+@type_check_only
class _XMethod(Protocol):
name: str
enabled: bool
@@ -31,6 +31,7 @@ class XMethodMatcher:
def __init__(self, name: str) -> None: ...
def match(self, class_type: gdb.Type, method_name: str) -> XMethodWorker | Sequence[XMethodWorker]: ...
+@type_check_only
class _SimpleWorkerMethod(Protocol):
def __call__(self, *args: gdb.Value) -> object: ...
diff --git a/python/helpers/typeshed/stubs/geopandas/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/geopandas/@tests/stubtest_allowlist.txt
index c70c8a84ee96..8b1d55baf177 100644
--- a/python/helpers/typeshed/stubs/geopandas/@tests/stubtest_allowlist.txt
+++ b/python/helpers/typeshed/stubs/geopandas/@tests/stubtest_allowlist.txt
@@ -14,10 +14,6 @@ geopandas\.(geodataframe\.)?GeoDataFrame\.plot
geopandas\.io\._geoarrow
geopandas\._exports
-# Not present in stub OK (do not work at runtime, to be removed from geopandas)
-geopandas\.(geoseries\.)?GeoSeries\.append # https://github.com/geopandas/geopandas/pull/3460
-geopandas\.(geoseries\.)?GeoSeries\.select # https://github.com/geopandas/geopandas/pull/3394
-
# Inconsistent (TODO)
geopandas\.(geoseries\.)?GeoSeries\.apply
geopandas\.(geoseries\.)?GeoSeries\.fillna
diff --git a/python/helpers/typeshed/stubs/geopandas/METADATA.toml b/python/helpers/typeshed/stubs/geopandas/METADATA.toml
index a47a9a46e2e2..97cd71db2c18 100644
--- a/python/helpers/typeshed/stubs/geopandas/METADATA.toml
+++ b/python/helpers/typeshed/stubs/geopandas/METADATA.toml
@@ -1,6 +1,6 @@
-version = "1.0.1"
+version = "1.1.1"
# Requires a version of numpy with a `py.typed` file
-requires = ["numpy>=1.20", "pandas-stubs<2.2.3.250527", "types-shapely", "pyproj"]
+requires = ["numpy>=1.20", "pandas-stubs", "types-shapely", "pyproj"]
upstream_repository = "https://github.com/geopandas/geopandas"
[tool.stubtest]
diff --git a/python/helpers/typeshed/stubs/geopandas/geopandas/accessors.pyi b/python/helpers/typeshed/stubs/geopandas/geopandas/accessors.pyi
new file mode 100644
index 000000000000..d69a67fe594b
--- /dev/null
+++ b/python/helpers/typeshed/stubs/geopandas/geopandas/accessors.pyi
@@ -0,0 +1,7 @@
+from typing import Any
+
+import pandas as pd
+
+class GeoSeriesAccessor:
+ def __init__(self, series: pd.Series[Any]) -> None: ... # Cannot use pd.Series[BaseGeometry]
+ def __getattr__(self, name: str) -> Any: ... # Delegate all attributes to the GeoSeries
diff --git a/python/helpers/typeshed/stubs/geopandas/geopandas/array.pyi b/python/helpers/typeshed/stubs/geopandas/geopandas/array.pyi
index c6ba2b330406..7572dd5b5c48 100644
--- a/python/helpers/typeshed/stubs/geopandas/geopandas/array.pyi
+++ b/python/helpers/typeshed/stubs/geopandas/geopandas/array.pyi
@@ -1,7 +1,7 @@
import builtins
from _typeshed import Incomplete, Unused
-from collections.abc import Callable, Sequence
-from typing import Any, ClassVar, Literal, NoReturn, SupportsIndex, TypeVar, overload
+from collections.abc import Callable, Collection, Sequence
+from typing import Any, ClassVar, Final, Literal, NoReturn, SupportsIndex, TypeVar, overload
from typing_extensions import Self, TypeAlias, deprecated
import numpy as np
@@ -21,11 +21,14 @@ _Array2D: TypeAlias = np.ndarray[tuple[int, int], np.dtype[_ScalarType]]
_ArrayOrGeom: TypeAlias = GeometryArray | ArrayLike | Geometry
TransformerFromCRS = Transformer.from_crs
+POLYGON_GEOM_TYPES: Final[set[str]]
+LINE_GEOM_TYPES: Final[set[str]]
+POINT_GEOM_TYPES: Final[set[str]]
class GeometryDtype(ExtensionDtype):
type: ClassVar[type[BaseGeometry]]
name: ClassVar[str]
- na_value: float
+ na_value: None
@classmethod
def construct_from_string(cls, string: str) -> Self: ...
@classmethod
@@ -35,14 +38,14 @@ def isna(value: object) -> bool: ...
def from_shapely(data, crs: _ConvertibleToCRS | None = None) -> GeometryArray: ...
def to_shapely(geoms: GeometryArray) -> _Array1D[np.object_]: ...
def from_wkb(
- data, crs: _ConvertibleToCRS | None = None, on_invalid: Literal["raise", "warn", "ignore"] = "raise"
+ data, crs: _ConvertibleToCRS | None = None, on_invalid: Literal["raise", "warn", "ignore", "fix"] = "raise"
) -> GeometryArray: ...
@overload
def to_wkb(geoms: GeometryArray, hex: Literal[False] = False, **kwargs) -> _Array1D[np.bytes_]: ...
@overload
def to_wkb(geoms: GeometryArray, hex: Literal[True], **kwargs) -> _Array1D[np.str_]: ...
def from_wkt(
- data, crs: _ConvertibleToCRS | None = None, on_invalid: Literal["raise", "warn", "ignore"] = "raise"
+ data, crs: _ConvertibleToCRS | None = None, on_invalid: Literal["raise", "warn", "ignore", "fix"] = "raise"
) -> GeometryArray: ...
def to_wkt(geoms: GeometryArray, **kwargs) -> _Array1D[np.str_]: ...
def points_from_xy(
@@ -80,6 +83,8 @@ class GeometryArray(ExtensionArray):
@property
def is_valid(self) -> _Array1D[np.bool_]: ...
def is_valid_reason(self) -> _Array1D[np.object_]: ...
+ def is_valid_coverage(self, gap_width: float = 0.0) -> bool: ...
+ def invalid_coverage_edges(self, gap_width: float = 0.0) -> _Array1D[np.object_]: ...
@property
def is_empty(self) -> _Array1D[np.bool_]: ...
@property
@@ -93,6 +98,8 @@ class GeometryArray(ExtensionArray):
@property
def has_z(self) -> _Array1D[np.bool_]: ...
@property
+ def has_m(self) -> _Array1D[np.bool_]: ...
+ @property
def geom_type(self) -> _Array1D[np.str_]: ...
@property
def area(self) -> _Array1D[np.float64]: ...
@@ -108,6 +115,7 @@ class GeometryArray(ExtensionArray):
@property
def centroid(self) -> GeometryArray: ...
def concave_hull(self, ratio: float, allow_holes: bool) -> _Array1D[np.object_]: ...
+ def constrained_delaunay_triangles(self) -> GeometryArray: ...
@property
def convex_hull(self) -> GeometryArray: ...
@property
@@ -128,10 +136,13 @@ class GeometryArray(ExtensionArray):
def remove_repeated_points(self, tolerance: float | ArrayLike = 0.0) -> GeometryArray: ...
def representative_point(self) -> GeometryArray: ...
def minimum_bounding_circle(self) -> GeometryArray: ...
+ def maximum_inscribed_circle(self, tolerance: float | ArrayLike) -> GeometryArray: ...
def minimum_bounding_radius(self) -> _Array1D[np.float64]: ...
def minimum_clearance(self) -> _Array1D[np.float64]: ...
+ def minimum_clearance_line(self) -> GeometryArray: ...
def normalize(self) -> GeometryArray: ...
- def make_valid(self) -> GeometryArray: ...
+ def orient_polygons(self, exterior_cw: bool = False) -> GeometryArray: ...
+ def make_valid(self, method: Literal["linework", "structure"] = "linework", keep_collapsed: bool = True) -> GeometryArray: ...
def reverse(self) -> GeometryArray: ...
def segmentize(self, max_segment_length: float | ArrayLike) -> GeometryArray: ...
def force_2d(self) -> GeometryArray: ...
@@ -156,8 +167,7 @@ class GeometryArray(ExtensionArray):
def within(self, other: _ArrayOrGeom) -> _Array1D[np.bool_]: ...
def dwithin(self, other: _ArrayOrGeom, distance: float) -> _Array1D[np.bool_]: ...
def geom_equals_exact(self, other: _ArrayOrGeom, tolerance: float | ArrayLike) -> _Array1D[np.bool_]: ...
- @deprecated("Use method `geom_equals_exact` instead.")
- def geom_almost_equals(self, other: _ArrayOrGeom, decimal: float) -> _Array1D[np.bool_]: ...
+ def geom_equals_identical(self, other: _ArrayOrGeom) -> _Array1D[np.bool_]: ...
def clip_by_rect(self, xmin: float, ymin: float, xmax: float, ymax: float) -> GeometryArray: ...
def difference(self, other: _ArrayOrGeom) -> GeometryArray: ...
def intersection(self, other: _ArrayOrGeom) -> GeometryArray: ...
@@ -172,14 +182,17 @@ class GeometryArray(ExtensionArray):
def buffer(self, distance: float | ArrayLike, resolution: int = 16, **kwargs) -> GeometryArray: ...
def interpolate(self, distance: float | ArrayLike, normalized: bool = False) -> GeometryArray: ...
def simplify(self, tolerance: float | ArrayLike, preserve_topology: bool = True) -> GeometryArray: ...
+ def simplify_coverage(self, tolerance: float | ArrayLike, simplify_boundary: bool = True) -> GeometryArray: ...
def project(self, other: _ArrayOrGeom, normalized: bool = False) -> _Array1D[np.float64]: ...
def relate(self, other: _ArrayOrGeom) -> _Array1D[np.str_]: ...
def relate_pattern(self, other: _ArrayOrGeom, pattern: str) -> _Array1D[np.bool_]: ...
@deprecated("Use method `union_all` instead.")
def unary_union(self) -> BaseGeometry: ...
- def union_all(self, method: Literal["coverage", "unary"] = "unary") -> BaseGeometry: ...
+ def union_all(
+ self, method: Literal["coverage", "unary", "disjoint_subset"] = "unary", grid_size: float | None = None
+ ) -> BaseGeometry: ...
def intersection_all(self) -> BaseGeometry: ...
- def affine_transform(self, matrix) -> GeometryArray: ...
+ def affine_transform(self, matrix: Collection[float]) -> GeometryArray: ...
def translate(self, xoff: float = 0.0, yoff: float = 0.0, zoff: float = 0.0) -> GeometryArray: ...
def rotate(self, angle: float, origin: _AffinityOrigin = "center", use_radians: bool = False) -> GeometryArray: ...
def scale(
@@ -197,21 +210,20 @@ class GeometryArray(ExtensionArray):
@property
def z(self) -> _Array1D[np.float64]: ...
@property
+ def m(self) -> _Array1D[np.float64]: ...
+ @property
def bounds(self) -> _Array2D[np.float64]: ...
@property
def total_bounds(self) -> _Array1D[np.float64]: ...
@property
def size(self) -> int: ...
@property
- def shape(self) -> tuple[int]: ... # Always 1-D, this is not a mistake
+ def shape(self) -> tuple[int]: ... # Always 1-D, this is not mistaken for tuple[int, ...]
@property
def ndim(self) -> Literal[1]: ...
def copy(self, *args: Unused, **kwargs: Unused) -> GeometryArray: ...
def take(
- self,
- indices: Sequence[SupportsIndex] | NDArray[np.integer[Any]], # np.integer[Any] because precision is not important
- allow_fill: bool = False,
- fill_value: Geometry | None = None,
+ self, indices: Sequence[SupportsIndex] | NDArray[np.integer], allow_fill: bool = False, fill_value: Geometry | None = None
) -> GeometryArray: ...
def fillna(
self,
@@ -239,6 +251,8 @@ class GeometryArray(ExtensionArray):
def __ne__(self, other: object) -> _Array1D[np.bool_]: ... # type: ignore[override]
def __contains__(self, item: object) -> np.bool_: ...
+# TODO: Improve `func` type with a callable protocol (with overloads for 2D and 3D geometries)
def transform(
- data: NDArray[np.object_], func: Callable[[NDArray[np.float64], NDArray[np.float64]], NDArray[np.float64]]
+ data: NDArray[np.object_] | GeometryArray | pd.Series[Any], # Cannot use pd.Series[BaseGeometry]
+ func: Callable[..., NDArray[np.float64]],
) -> NDArray[np.object_]: ...
diff --git a/python/helpers/typeshed/stubs/geopandas/geopandas/base.pyi b/python/helpers/typeshed/stubs/geopandas/geopandas/base.pyi
index 1c5c3dddbfe4..979c4fcbebef 100644
--- a/python/helpers/typeshed/stubs/geopandas/geopandas/base.pyi
+++ b/python/helpers/typeshed/stubs/geopandas/geopandas/base.pyi
@@ -1,5 +1,5 @@
from _typeshed import Incomplete, SupportsGetItem
-from collections.abc import Callable, Hashable, Iterable, Mapping, Sequence
+from collections.abc import Callable, Collection, Hashable, Iterable, Mapping, Sequence
from typing import Any, Literal, Protocol, SupportsIndex, overload, type_check_only
from typing_extensions import Self, TypeAlias, deprecated
@@ -64,6 +64,8 @@ class GeoPandasBase:
@property
def is_valid(self) -> pd.Series[bool]: ...
def is_valid_reason(self) -> pd.Series[str]: ...
+ def is_valid_coverage(self, *, gap_width: float = 0.0) -> bool: ...
+ def invalid_coverage_edges(self, *, gap_width: float = 0.0) -> GeoSeries: ...
@property
def is_empty(self) -> pd.Series[bool]: ...
def count_coordinates(self) -> pd.Series[int]: ...
@@ -79,6 +81,8 @@ class GeoPandasBase:
def is_closed(self) -> pd.Series[bool]: ...
@property
def has_z(self) -> pd.Series[bool]: ...
+ @property
+ def has_m(self) -> pd.Series[bool]: ...
def get_precision(self) -> pd.Series[float]: ...
def get_geometry(self, index: SupportsIndex | ArrayLike) -> GeoSeries: ...
@property
@@ -86,6 +90,7 @@ class GeoPandasBase:
@property
def centroid(self) -> GeoSeries: ...
def concave_hull(self, ratio: float = 0.0, allow_holes: bool = False) -> GeoSeries: ...
+ def constrained_delaunay_triangles(self) -> GeoSeries: ...
@property
def convex_hull(self) -> GeoSeries: ...
def delaunay_triangles(self, tolerance: float | ArrayLike = 0.0, only_edges: bool | ArrayLike = False) -> GeoSeries: ...
@@ -113,10 +118,13 @@ class GeoPandasBase:
) -> GeoSeries: ...
def representative_point(self) -> GeoSeries: ...
def minimum_bounding_circle(self) -> GeoSeries: ...
+ def maximum_inscribed_circle(self, *, tolerance: float | ArrayLike | None = None) -> GeoSeries: ...
def minimum_bounding_radius(self) -> pd.Series[float]: ...
def minimum_clearance(self) -> pd.Series[float]: ...
+ def minimum_clearance_line(self) -> GeoSeries: ...
def normalize(self) -> GeoSeries: ...
- def make_valid(self) -> GeoSeries: ...
+ def orient_polygons(self, *, exterior_cw: bool = False) -> GeoSeries: ...
+ def make_valid(self, *, method: Literal["linework", "structure"] = "linework", keep_collapsed: bool = True) -> GeoSeries: ...
def reverse(self) -> GeoSeries: ...
def segmentize(self, max_segment_length: float | ArrayLike) -> GeoSeries: ...
def transform(
@@ -126,18 +134,20 @@ class GeoPandasBase:
def force_3d(self, z: float | ArrayLike = 0) -> GeoSeries: ...
def line_merge(self, directed: bool = False) -> GeoSeries: ...
@property
+ @deprecated("Use method `union_all` instead.")
def unary_union(self) -> BaseGeometry: ...
- def union_all(self, method: Literal["coverage", "unary"] = "unary") -> BaseGeometry: ...
+ def union_all(
+ self, method: Literal["coverage", "unary", "disjoint_subset"] = "unary", *, grid_size: float | None = None
+ ) -> BaseGeometry: ...
def intersection_all(self) -> BaseGeometry: ...
def contains(self, other: GeoSeries | Geometry, align: bool | None = None) -> pd.Series[bool]: ...
def contains_properly(self, other: GeoSeries | Geometry, align: bool | None = None) -> pd.Series[bool]: ...
def dwithin(self, other: GeoSeries | Geometry, distance: float | ArrayLike, align: bool | None = None) -> pd.Series[bool]: ...
def geom_equals(self, other: GeoSeries | Geometry, align: bool | None = None) -> pd.Series[bool]: ...
- @deprecated("Use method `geom_equals_exact` instead.")
- def geom_almost_equals(self, other: GeoSeries | Geometry, decimal: int = 6, align: bool | None = None) -> pd.Series[bool]: ...
def geom_equals_exact(
self, other: GeoSeries | Geometry, tolerance: float | ArrayLike, align: bool | None = None
) -> pd.Series[bool]: ...
+ def geom_equals_identical(self, other: GeoSeries | Geometry, align: bool | None = None) -> pd.Series[bool]: ...
def crosses(self, other: GeoSeries | Geometry, align: bool | None = None) -> pd.Series[bool]: ...
def disjoint(self, other: GeoSeries | Geometry, align: bool | None = None) -> pd.Series[bool]: ...
def intersects(self, other: GeoSeries | Geometry, align: bool | None = None) -> pd.Series[bool]: ...
@@ -180,11 +190,12 @@ class GeoPandasBase:
**kwargs,
) -> GeoSeries: ...
def simplify(self, tolerance: float | ArrayLike, preserve_topology: bool = True) -> GeoSeries: ...
+ def simplify_coverage(self, tolerance: float | ArrayLike, *, simplify_boundary: bool = True) -> GeoSeries: ...
def relate(self, other: GeoSeries | Geometry, align: bool | None = None) -> pd.Series[str]: ...
def relate_pattern(self, other: GeoSeries | Geometry, pattern: str, align: bool | None = None) -> pd.Series[bool]: ...
def project(self, other: GeoSeries | Geometry, normalized: bool = False, align: bool | None = None) -> pd.Series[float]: ...
def interpolate(self, distance: float | ArrayLike, normalized: bool = False) -> GeoSeries: ...
- def affine_transform(self, matrix) -> GeoSeries: ...
+ def affine_transform(self, matrix: Collection[float]) -> GeoSeries: ...
def translate(self, xoff: float = 0.0, yoff: float = 0.0, zoff: float = 0.0) -> GeoSeries: ...
def rotate(self, angle: float, origin: _AffinityOrigin = "center", use_radians: bool = False) -> GeoSeries: ...
def scale(
@@ -195,7 +206,9 @@ class GeoPandasBase:
) -> GeoSeries: ...
@property
def cx(self) -> SupportsGetItem[tuple[SupportsIndex | slice, SupportsIndex | slice], Self]: ...
- def get_coordinates(self, include_z: bool = False, ignore_index: bool = False, index_parts: bool = False) -> pd.DataFrame: ...
+ def get_coordinates(
+ self, include_z: bool = False, ignore_index: bool = False, index_parts: bool = False, *, include_m: bool = False
+ ) -> pd.DataFrame: ...
def hilbert_distance(
self, total_bounds: tuple[float, float, float, float] | Iterable[float] | None = None, level: int = 16
) -> pd.Series[int]: ...
diff --git a/python/helpers/typeshed/stubs/geopandas/geopandas/geodataframe.pyi b/python/helpers/typeshed/stubs/geopandas/geopandas/geodataframe.pyi
index 7f30a113b0ab..b9d6c6d5dbc0 100644
--- a/python/helpers/typeshed/stubs/geopandas/geopandas/geodataframe.pyi
+++ b/python/helpers/typeshed/stubs/geopandas/geopandas/geodataframe.pyi
@@ -1,14 +1,14 @@
import io
import os
from _typeshed import Incomplete, SupportsGetItem, SupportsLenAndGetItem, SupportsRead, SupportsWrite
-from collections.abc import Callable, Container, Hashable, Iterable, Iterator, Mapping
+from collections.abc import Callable, Container, Hashable, Iterable, Iterator, Mapping, Sequence
from json import JSONEncoder
from typing import Any, Literal, overload
from typing_extensions import Self
import pandas as pd
from numpy.typing import ArrayLike
-from pandas._typing import AggFuncTypeFrame, AstypeArg, Axes, Axis, Dtype, GroupByObject, IndexLabel, Scalar
+from pandas._typing import AggFuncTypeFrame, Axes, Axis, Dtype, GroupByObject, IndexLabel, Scalar
from pyproj import CRS
from ._decorator import doc
@@ -160,7 +160,9 @@ class GeoDataFrame(GeoPandasBase, pd.DataFrame): # type: ignore[misc]
chunksize: None = None,
) -> GeoDataFrame: ...
@classmethod
- def from_arrow(cls, table, geometry: str | None = None) -> GeoDataFrame: ... # table: pyarrow.Table
+ def from_arrow(
+ cls, table, geometry: str | None = None, to_pandas_kwargs: Mapping[str, Incomplete] | None = None
+ ) -> GeoDataFrame: ... # TODO: `table: pyarrow.Table | table-like`
def to_json( # type: ignore[override]
self,
na: str = "null",
@@ -306,16 +308,11 @@ class GeoDataFrame(GeoPandasBase, pd.DataFrame): # type: ignore[misc]
sort: bool = True,
observed: bool = False,
dropna: bool = True,
- method: Literal["coverage", "unary"] = "unary",
+ method: Literal["coverage", "unary", "disjoint_subset"] = "unary",
+ grid_size: float | None = None,
**kwargs,
) -> GeoDataFrame: ...
def explode(self, column: IndexLabel | None = None, ignore_index: bool = False, index_parts: bool = False) -> Self: ...
- def astype(
- self,
- dtype: AstypeArg | Mapping[Any, Dtype] | pd.Series[Any], # any because of mapping invariance and series typevar bounds
- copy: bool | None = None,
- errors: Literal["ignore", "raise"] = "raise",
- ) -> GeoDataFrame: ...
def to_postgis(
self,
name: str,
@@ -334,12 +331,15 @@ class GeoDataFrame(GeoPandasBase, pd.DataFrame): # type: ignore[misc]
def sjoin(
self,
df: GeoDataFrame,
- # *args, **kwargs passed to geopandas.sjoin
how: Literal["left", "right", "inner"] = "inner",
predicate: str = "intersects",
lsuffix: str = "left",
rsuffix: str = "right",
+ *,
+ # **kwargs passed to geopandas.sjoin
distance: float | ArrayLike | None = None,
+ on_attribute: str | Sequence[str] | None = None,
+ **kwargs,
) -> GeoDataFrame: ...
def sjoin_nearest(
self,
diff --git a/python/helpers/typeshed/stubs/geopandas/geopandas/geoseries.pyi b/python/helpers/typeshed/stubs/geopandas/geopandas/geoseries.pyi
index bb45f01cd6be..09a38d336f87 100644
--- a/python/helpers/typeshed/stubs/geopandas/geopandas/geoseries.pyi
+++ b/python/helpers/typeshed/stubs/geopandas/geopandas/geoseries.pyi
@@ -1,14 +1,14 @@
import io
import json
import os
-from _typeshed import Incomplete, SupportsRead, Unused
+from _typeshed import Incomplete, SupportsRead
from collections.abc import Callable, Hashable
from typing import Any, Literal, final, overload
from typing_extensions import Self
import pandas as pd
from numpy.typing import ArrayLike
-from pandas._typing import Axes, AxisIndex, Dtype
+from pandas._typing import Axes, Dtype
from pyproj import CRS
from shapely.geometry.base import BaseGeometry
@@ -55,6 +55,8 @@ class GeoSeries(GeoPandasBase, pd.Series[BaseGeometry]): # type: ignore[type-va
def y(self) -> pd.Series[float]: ...
@property
def z(self) -> pd.Series[float]: ...
+ @property
+ def m(self) -> pd.Series[float]: ...
# Keep inline with GeoDataFrame.from_file and geopandas.io.file._read_file
@classmethod
def from_file(
@@ -76,7 +78,7 @@ class GeoSeries(GeoPandasBase, pd.Series[BaseGeometry]): # type: ignore[type-va
data: ArrayLike, # array-like of bytes handled by shapely.from_wkb(data)
index: Axes | None = None,
crs: _ConvertibleToCRS | None = None,
- on_invalid: Literal["raise", "warn", "ignore"] = "raise",
+ on_invalid: Literal["raise", "warn", "ignore", "fix"] = "raise",
*,
dtype: Dtype | None = None,
name: Hashable = None,
@@ -89,7 +91,7 @@ class GeoSeries(GeoPandasBase, pd.Series[BaseGeometry]): # type: ignore[type-va
data: ArrayLike, # array-like of str handled by shapely.from_wkt(data)
index: Axes | None = None,
crs: _ConvertibleToCRS | None = None,
- on_invalid: Literal["raise", "warn", "ignore"] = "raise",
+ on_invalid: Literal["raise", "warn", "ignore", "fix"] = "raise",
*,
dtype: Dtype | None = None,
name: Hashable = None,
@@ -145,11 +147,7 @@ class GeoSeries(GeoPandasBase, pd.Series[BaseGeometry]): # type: ignore[type-va
overwrite: bool | None = ...,
**kwargs, # engine and driver dependent
) -> None: ...
- # *** TODO: compare `__getitem__` with pandas-stubs ***
- # def __getitem__(self, key): ...
- # *** `sort_index` is annotated with `-> Self` in pandas-stubs; no need to override it ***
- # def sort_index(self, *args, **kwargs): ...
- def take(self, indices: ArrayLike, axis: AxisIndex = 0, **kwargs: Unused) -> GeoSeries: ...
+ # *** `__getitem__`, `sort_index` and `take` are annotated with `-> Self` in pandas-stubs; no need to override them ***
# *** `apply` annotation in pandas-stubs is compatible except for deprecated `convert_dtype` argument ***
# def apply(self, func, convert_dtype: bool | None = None, args=(), **kwargs): ...
def isna(self) -> pd.Series[bool]: ...
diff --git a/python/helpers/typeshed/stubs/geopandas/geopandas/io/_geoarrow.pyi b/python/helpers/typeshed/stubs/geopandas/geopandas/io/_geoarrow.pyi
index a0f185fe48dc..d4a53581cb8b 100644
--- a/python/helpers/typeshed/stubs/geopandas/geopandas/io/_geoarrow.pyi
+++ b/python/helpers/typeshed/stubs/geopandas/geopandas/io/_geoarrow.pyi
@@ -1,6 +1,15 @@
from _typeshed import Incomplete
-from typing import Literal
-from typing_extensions import TypeAlias
+from collections.abc import Mapping
+from typing import (
+ # pyarrow types returned as Any to avoid depending on pyarrow (40 MB) in stubs
+ Any as _PAArray,
+ Any as _PAField,
+ Any as _PATable,
+ Literal,
+ Protocol,
+ type_check_only,
+)
+from typing_extensions import CapsuleType, TypeAlias
import numpy as np
from numpy.typing import NDArray
@@ -8,22 +17,30 @@ from numpy.typing import NDArray
from ..array import GeometryArray
from ..geodataframe import GeoDataFrame
-_PATable: TypeAlias = Incomplete
-_PAField: TypeAlias = Incomplete
-_PAArray: TypeAlias = Incomplete
-
# Literal for language server completions and str because runtime normalizes to lowercase
_GeomEncoding: TypeAlias = Literal["WKB", "geoarrow"] | str # noqa: Y051
+@type_check_only
+class _PyarrowTableLike(Protocol):
+ def __arrow_c_stream__(self, requested_schema=None) -> CapsuleType: ...
+
+@type_check_only
+class _PyarrowFieldLike(Protocol):
+ def __arrow_c_schema__(self) -> CapsuleType: ...
+
+@type_check_only
+class _PyarrowArrayLike(Protocol):
+ def __arrow_c_array__(self) -> tuple[CapsuleType, CapsuleType]: ...
+
GEOARROW_ENCODINGS: list[str]
class ArrowTable:
- def __init__(self, pa_table: _PATable) -> None: ...
- def __arrow_c_stream__(self, requested_schema=None): ...
+ def __init__(self, pa_table: _PyarrowTableLike) -> None: ...
+ def __arrow_c_stream__(self, requested_schema=None) -> CapsuleType: ...
class GeoArrowArray:
- def __init__(self, pa_field: _PAField, pa_array: _PAArray) -> None: ...
- def __arrow_c_array__(self, requested_schema=None) -> tuple[Incomplete, Incomplete]: ...
+ def __init__(self, pa_field: _PyarrowFieldLike, pa_array: _PyarrowArrayLike) -> None: ...
+ def __arrow_c_array__(self, requested_schema=None) -> tuple[CapsuleType, CapsuleType]: ...
def geopandas_to_arrow(
df: GeoDataFrame,
@@ -43,6 +60,8 @@ def construct_geometry_array(
crs: str | None = None,
interleaved: bool = True,
) -> tuple[_PAField, _PAArray]: ...
-def arrow_to_geopandas(table, geometry: str | None = None) -> GeoDataFrame: ...
+def arrow_to_geopandas(
+ table, geometry: str | None = None, to_pandas_kwargs: Mapping[str, Incomplete] | None = None
+) -> GeoDataFrame: ...
def arrow_to_geometry_array(arr) -> GeometryArray: ...
def construct_shapely_array(arr: _PAArray, extension_name: str) -> NDArray[np.object_]: ...
diff --git a/python/helpers/typeshed/stubs/geopandas/geopandas/io/arrow.pyi b/python/helpers/typeshed/stubs/geopandas/geopandas/io/arrow.pyi
index a82a238aef9f..88e2419b8d1e 100644
--- a/python/helpers/typeshed/stubs/geopandas/geopandas/io/arrow.pyi
+++ b/python/helpers/typeshed/stubs/geopandas/geopandas/io/arrow.pyi
@@ -1,22 +1,28 @@
import os
-from _typeshed import SupportsGetItem, SupportsKeysAndGetItem
-from collections.abc import Iterable
+from _typeshed import Incomplete, SupportsGetItem, SupportsKeysAndGetItem
+from collections.abc import Iterable, Mapping
from typing import Any, Final
from ..geodataframe import GeoDataFrame
METADATA_VERSION: Final[str]
+SUPPORTED_VERSIONS_LITERAL = Incomplete
SUPPORTED_VERSIONS: Final[list[str]]
GEOARROW_ENCODINGS: Final[list[str]]
SUPPORTED_ENCODINGS: Final[list[str]]
+PARQUET_GEOMETRY_ENCODINGS = Incomplete
def _read_parquet(
path: str | os.PathLike[str],
columns: Iterable[str] | None = None,
storage_options: SupportsKeysAndGetItem[str, Any] | None = None, # type depend on the connection
bbox: SupportsGetItem[int, float] | None = None,
+ to_pandas_kwargs: Mapping[str, Incomplete] | None = None,
**kwargs, # kwargs passed to pyarrow.parquet.read_table
) -> GeoDataFrame: ...
def _read_feather(
- path: str | os.PathLike[str], columns: Iterable[str] | None = None, **kwargs # kwargs passed to pyarrow.feather.read_table
+ path: str | os.PathLike[str],
+ columns: Iterable[str] | None = None,
+ to_pandas_kwargs: Mapping[str, Incomplete] | None = None,
+ **kwargs, # kwargs passed to pyarrow.feather.read_table
) -> GeoDataFrame: ...
diff --git a/python/helpers/typeshed/stubs/geopandas/geopandas/io/file.pyi b/python/helpers/typeshed/stubs/geopandas/geopandas/io/file.pyi
index 1ba0af5bf8f3..75efae95093a 100644
--- a/python/helpers/typeshed/stubs/geopandas/geopandas/io/file.pyi
+++ b/python/helpers/typeshed/stubs/geopandas/geopandas/io/file.pyi
@@ -1,7 +1,7 @@
import os
from _typeshed import Incomplete, SupportsRead
from collections import OrderedDict
-from typing import Literal, TypedDict, overload
+from typing import Literal, TypedDict, overload, type_check_only
import pandas as pd
from pandas._typing import Axes
@@ -38,7 +38,7 @@ def _read_file(
encoding: str | None = None,
**kwargs, # depend on engine
) -> pd.DataFrame: ...
-
+@type_check_only
class _Schema(TypedDict):
geometry: str | list[str]
properties: OrderedDict[str, str]
diff --git a/python/helpers/typeshed/stubs/geopandas/geopandas/io/sql.pyi b/python/helpers/typeshed/stubs/geopandas/geopandas/io/sql.pyi
index 743439f873b8..d498da5064c9 100644
--- a/python/helpers/typeshed/stubs/geopandas/geopandas/io/sql.pyi
+++ b/python/helpers/typeshed/stubs/geopandas/geopandas/io/sql.pyi
@@ -2,7 +2,7 @@ import sqlite3
from _typeshed import Incomplete, SupportsLenAndGetItem
from collections.abc import Container, Iterator, Mapping
from contextlib import AbstractContextManager
-from typing import Any, Protocol, overload
+from typing import Any, Protocol, overload, type_check_only
from typing_extensions import TypeAlias
from pandas._typing import Scalar
@@ -16,6 +16,7 @@ from ..geodataframe import GeoDataFrame
# isinstance checks. However to avoid a dependency on SQLAlchemy, we use "good-enough"
# protocols that match as much as possible the SQLAlchemy implementation. This makes it
# very hard for someone to pass in the wrong object.
+@type_check_only
class _SqlalchemyTransactionLike(Protocol):
# is_active: bool
# connection: _SqlalchemyConnectionLike
@@ -27,9 +28,11 @@ class _SqlalchemyTransactionLike(Protocol):
def commit(self) -> None: ...
# `Any` is used in places where it would require to copy a lot of types from sqlalchemy
+@type_check_only
class _SqlAlchemyEventTarget(Protocol):
dispatch: Any
+@type_check_only
class _SqlalchemyConnectionLike(_SqlAlchemyEventTarget, Protocol):
engine: Any
@property
@@ -52,6 +55,7 @@ class _SqlalchemyConnectionLike(_SqlAlchemyEventTarget, Protocol):
def in_nested_transaction(self) -> bool: ...
def close(self) -> None: ...
+@type_check_only
class _SqlalchemyEngineLike(_SqlAlchemyEventTarget, Protocol):
dialect: Any
pool: Any
diff --git a/python/helpers/typeshed/stubs/geopandas/geopandas/plotting.pyi b/python/helpers/typeshed/stubs/geopandas/geopandas/plotting.pyi
index eadbb6445d1b..01528e6284e4 100644
--- a/python/helpers/typeshed/stubs/geopandas/geopandas/plotting.pyi
+++ b/python/helpers/typeshed/stubs/geopandas/geopandas/plotting.pyi
@@ -198,7 +198,7 @@ class GeoplotAccessor(PlotAccessor):
@overload
def __call__(
self,
- column: Hashable | None = None,
+ column: Hashable | pd.Series | pd.Index | NDArray | None = None,
cmap: str | Colormap | None = None,
color: _ColorOrColors | None = None,
ax: Axes | None = None,
@@ -229,7 +229,7 @@ class GeoplotAccessor(PlotAccessor):
) -> Axes: ...
def geo(
self,
- column: Hashable | None = None,
+ column: Hashable | pd.Series | pd.Index | NDArray | None = None,
cmap: str | Colormap | None = None,
color: _ColorOrColors | None = None,
ax: Axes | None = None,
diff --git a/python/helpers/typeshed/stubs/geopandas/geopandas/sindex.pyi b/python/helpers/typeshed/stubs/geopandas/geopandas/sindex.pyi
index bd2611478d72..211c04069a9c 100644
--- a/python/helpers/typeshed/stubs/geopandas/geopandas/sindex.pyi
+++ b/python/helpers/typeshed/stubs/geopandas/geopandas/sindex.pyi
@@ -21,7 +21,7 @@ class SpatialIndex:
predicate: str | None = None,
sort: bool = False,
distance: float | ArrayLike | None = None,
- output_format: Literal["tuple"] = "tuple",
+ output_format: Literal["indices"] = "indices",
) -> NDArray[np.int64]: ...
@overload
def query(
diff --git a/python/helpers/typeshed/stubs/gevent/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/gevent/@tests/stubtest_allowlist.txt
index 3cd813e4b742..19832db85422 100644
--- a/python/helpers/typeshed/stubs/gevent/@tests/stubtest_allowlist.txt
+++ b/python/helpers/typeshed/stubs/gevent/@tests/stubtest_allowlist.txt
@@ -120,10 +120,6 @@ gevent._config._PositiveValueMixin.validate
# internal API implementation detail we don't care about
gevent._ffi.watcher.AbstractWatcherType.__new__
-# these are inconsistent due to the ParamSpec hack for positional only callables
-gevent.baseserver.BaseServer.do_close
-gevent.baseserver.BaseServer.do_handle
-
# we don't care about write/writeall allowing a named parameter
gevent._fileobjectcommon.FlushingBufferedWriter.write
gevent._fileobjectcommon.WriteIsWriteallMixin.write
@@ -174,6 +170,7 @@ gevent.socket.getnameinfo
gevent.socket.socket.closed
gevent.socket.wait_readwrite
gevent.socket.wait_write
+gevent.socket.socket.__slots__
# we have punted on ssl, the gevent version of these functions have an additional
# argument for timeouts/blocking and there are some with different default values
diff --git a/python/helpers/typeshed/stubs/gevent/METADATA.toml b/python/helpers/typeshed/stubs/gevent/METADATA.toml
index 456b719c6819..dce29acee5db 100644
--- a/python/helpers/typeshed/stubs/gevent/METADATA.toml
+++ b/python/helpers/typeshed/stubs/gevent/METADATA.toml
@@ -5,7 +5,7 @@ requires = ["types-greenlet", "types-psutil"]
[tool.stubtest]
# Run stubtest on all platforms, since there is some platform specific stuff
# especially in the stdlib module replacement
-platforms = ["linux", "darwin", "win32"]
+ci_platforms = ["linux", "darwin", "win32"]
# for testing the ffi loop implementations on all platforms
stubtest_requirements = ["cffi", "dnspython"]
apt_dependencies = ["libev4", "libev-dev", "libuv1", "libuv1-dev"]
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/_abstract_linkable.pyi b/python/helpers/typeshed/stubs/gevent/gevent/_abstract_linkable.pyi
index cdf549b90cf3..5c312a96c763 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/_abstract_linkable.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/_abstract_linkable.pyi
@@ -4,6 +4,7 @@ from typing_extensions import Self
from gevent.hub import Hub
class AbstractLinkable:
+ __slots__ = ("hub", "_links", "_notifier", "_notify_all", "__weakref__")
@property
def hub(self) -> Hub | None: ...
def __init__(self, hub: Hub | None = None) -> None: ...
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/_config.pyi b/python/helpers/typeshed/stubs/gevent/gevent/_config.pyi
index a7824ba9714e..af42269bffbe 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/_config.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/_config.pyi
@@ -1,5 +1,5 @@
from collections.abc import Callable, Sequence
-from typing import Any, Generic, NoReturn, Protocol, TypeVar, overload
+from typing import Any, Generic, NoReturn, Protocol, TypeVar, overload, type_check_only
from gevent._types import _Loop, _Resolver
from gevent.fileobject import _FileObjectType
@@ -9,6 +9,7 @@ __all__ = ["config"]
_T = TypeVar("_T")
+@type_check_only
class _SettingDescriptor(Protocol[_T]):
@overload
def __get__(self, obj: None, owner: type[Config]) -> property: ...
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/_ffi/loop.pyi b/python/helpers/typeshed/stubs/gevent/gevent/_ffi/loop.pyi
index 7bd152d277e0..3e3004679223 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/_ffi/loop.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/_ffi/loop.pyi
@@ -2,7 +2,7 @@ import sys
from _typeshed import FileDescriptor
from collections.abc import Callable, Sequence
from types import TracebackType
-from typing import Protocol
+from typing import Protocol, type_check_only
from typing_extensions import TypeAlias, TypeVarTuple, Unpack
from gevent._types import _AsyncWatcher, _Callback, _ChildWatcher, _IoWatcher, _StatWatcher, _TimerWatcher, _Watcher
@@ -12,13 +12,14 @@ _ErrorHandlerFunc: TypeAlias = Callable[
[object | None, type[BaseException] | None, BaseException | None, TracebackType | None], object
]
+@type_check_only
class _SupportsHandleError(Protocol):
handle_error: _ErrorHandlerFunc
_ErrorHandler: TypeAlias = _ErrorHandlerFunc | _SupportsHandleError
def assign_standard_callbacks(
- ffi: object, lib: object, callbacks_class: Callable[[object], object], extras: Sequence[tuple[object, object]] = ...
+ ffi: object, lib: object, callbacks_class: Callable[[object], object], extras: Sequence[tuple[object, object]] = ()
) -> object: ...
class AbstractLoop:
@@ -27,7 +28,7 @@ class AbstractLoop:
starting_timer_may_update_loop_time: bool
# internal API, this __init__ will only be called from subclasses
def __init__(
- self, ffi: object, lib: object, watchers: object, flags: int | None = ..., default: bool | None = ...
+ self, ffi: object, lib: object, watchers: object, flags: int | None = None, default: bool | None = None
) -> None: ...
def destroy(self) -> bool | None: ...
@property
@@ -77,10 +78,10 @@ class AbstractLoop:
def install_sigchld(self) -> None: ...
def async_(self, ref: bool = True, priority: int | None = None) -> _AsyncWatcher: ...
- def stat(self, path: str, interval: float = 0.0, ref: bool = True, priority: bool | None = ...) -> _StatWatcher: ...
+ def stat(self, path: str, interval: float = 0.0, ref: bool = True, priority: bool | None = None) -> _StatWatcher: ...
def run_callback(self, func: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]) -> _Callback: ...
def run_callback_threadsafe(self, func: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]) -> _Callback: ...
- def callback(self, priority: float | None = ...) -> _Callback: ...
+ def callback(self, priority: float | None = None) -> _Callback: ...
def fileno(self) -> FileDescriptor | None: ...
__all__ = ["AbstractLoop", "assign_standard_callbacks"]
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/_ffi/watcher.pyi b/python/helpers/typeshed/stubs/gevent/gevent/_ffi/watcher.pyi
index 05128ac2cf34..fcf69cd12d9c 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/_ffi/watcher.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/_ffi/watcher.pyi
@@ -14,7 +14,7 @@ class AbstractWatcherType(type):
class watcher(metaclass=AbstractWatcherType):
loop: _Loop
- def __init__(self, _loop: _Loop, ref: bool = True, priority: int | None = None, args: tuple[object, ...] = ...) -> None: ...
+ def __init__(self, _loop: _Loop, ref: bool = True, priority: int | None = None, args: tuple[object, ...] = ()) -> None: ...
def close(self) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/_fileobjectcommon.pyi b/python/helpers/typeshed/stubs/gevent/gevent/_fileobjectcommon.pyi
index 727dd29a95ce..d631fd0740f7 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/_fileobjectcommon.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/_fileobjectcommon.pyi
@@ -28,7 +28,8 @@ class FlushingBufferedWriter(io.BufferedWriter): ...
class WriteallMixin:
def writeall(self, b: ReadableBuffer, /) -> int: ...
-class FileIO(io.FileIO): ...
+class FileIO(io.FileIO):
+ __slots__ = ()
class WriteIsWriteallMixin(WriteallMixin):
def write(self, b: ReadableBuffer, /) -> int: ...
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/_hub_primitives.pyi b/python/helpers/typeshed/stubs/gevent/gevent/_hub_primitives.pyi
index f0cfe8a6836b..e308682edc42 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/_hub_primitives.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/_hub_primitives.pyi
@@ -1,7 +1,7 @@
from _typeshed import FileDescriptor
from collections.abc import Callable, Collection, Iterable
from types import TracebackType
-from typing import Any, Generic, Protocol, TypeVar, overload
+from typing import Any, Generic, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeVarTuple, Unpack
from gevent._greenlet_primitives import SwitchOutGreenletWithLoop
@@ -15,6 +15,7 @@ _T = TypeVar("_T")
_Ts = TypeVarTuple("_Ts")
_WaitableT = TypeVar("_WaitableT", bound=_Waitable)
+@type_check_only
class _Waitable(Protocol):
def rawlink(self, callback: Callable[[Any], object], /) -> object: ...
def unlink(self, callback: Callable[[Any], object], /) -> object: ...
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/_ident.pyi b/python/helpers/typeshed/stubs/gevent/gevent/_ident.pyi
index 7c1bf6b8d319..e59d21de18cf 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/_ident.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/_ident.pyi
@@ -3,6 +3,7 @@ from weakref import ref
@final
class ValuedWeakRef(ref):
+ __slots__ = ("value",)
value: Any
@final
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/_monitor.pyi b/python/helpers/typeshed/stubs/gevent/gevent/_monitor.pyi
index 782f99c5c5ca..3647e0f33f0d 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/_monitor.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/_monitor.pyi
@@ -19,6 +19,7 @@ def implementer(interface: Any, /) -> Callable[[_T], _T]: ...
class MonitorWarning(RuntimeWarning): ...
class _MonitorEntry:
+ __slots__ = ("function", "period", "last_run_time")
function: Callable[[Hub], object]
period: float
last_run_time: float
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/_threading.pyi b/python/helpers/typeshed/stubs/gevent/gevent/_threading.pyi
index 0eeaaf454716..1c671bdec7f9 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/_threading.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/_threading.pyi
@@ -9,6 +9,7 @@ _Cookie = NewType("_Cookie", LockType)
class EmptyTimeout(Exception): ...
class Queue(Generic[_T]):
+ __slots__ = ("_queue", "_mutex", "_not_empty", "unfinished_tasks")
unfinished_tasks: int
def __init__(self) -> None: ...
def task_done(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/_util.pyi b/python/helpers/typeshed/stubs/gevent/gevent/_util.pyi
index 77c8cbd3a1f0..4d465603c410 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/_util.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/_util.pyi
@@ -8,14 +8,19 @@ _T = TypeVar("_T")
WRAPPER_ASSIGNMENTS: tuple[str, ...]
WRAPPER_UPDATES: tuple[str, ...]
-def update_wrapper(wrapper: _T, wrapped: object, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> _T: ...
+def update_wrapper(
+ wrapper: _T,
+ wrapped: object,
+ assigned: Sequence[str] = ("__module__", "__name__", "__qualname__", "__doc__", "__annotations__"),
+ updated: Sequence[str] = ("__dict__",),
+) -> _T: ...
def copy_globals(
source: ModuleType,
globs: MutableMapping[str, Any],
only_names: Iterable[str] | None = None,
ignore_missing_names: bool = False,
- names_to_ignore: Sequence[str] = ...,
- dunder_names_to_keep: Sequence[str] = ...,
+ names_to_ignore: Sequence[str] = (),
+ dunder_names_to_keep: Sequence[str] = ("__implements__", "__all__", "__imports__"),
cleanup_globs: bool = True,
) -> list[str]: ...
def import_c_accel(globs: MutableMapping[str, Any], cname: str) -> None: ...
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/_waiter.pyi b/python/helpers/typeshed/stubs/gevent/gevent/_waiter.pyi
index 23158d120c33..a240f02585bf 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/_waiter.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/_waiter.pyi
@@ -21,6 +21,7 @@ _ThrowArgs: TypeAlias = (
)
class Waiter(Generic[_T]):
+ __slots__ = ["hub", "greenlet", "value", "_exception"]
@property
def hub(self) -> Hub: ... # readonly in Cython
@property
@@ -42,4 +43,5 @@ class Waiter(Generic[_T]):
def __call__(self, source: _ValueSource[_T]) -> None: ...
@final
-class MultipleWaiter(Waiter[_T]): ...
+class MultipleWaiter(Waiter[_T]):
+ __slots__ = ["_values"]
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/baseserver.pyi b/python/helpers/typeshed/stubs/gevent/gevent/baseserver.pyi
index aa5308ec0b92..95cfe0551b5b 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/baseserver.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/baseserver.pyi
@@ -1,21 +1,23 @@
from collections.abc import Callable, Container
from types import TracebackType
-from typing import Any, Generic, Literal, Protocol
-from typing_extensions import ParamSpec, Self, TypeAlias
+from typing import Generic, Literal, Protocol, type_check_only
+from typing_extensions import ParamSpec, Self, TypeAlias, TypeVarTuple, Unpack
from gevent._types import _Loop
from gevent.pool import Pool
from gevent.socket import socket as _GeventSocket
from greenlet import greenlet
+_Ts = TypeVarTuple("_Ts")
_P = ParamSpec("_P")
+@type_check_only
class _SpawnFunc(Protocol):
def __call__(self, func: Callable[_P, object], /, *args: _P.args, **kwargs: _P.kwargs) -> greenlet: ...
_Spawner: TypeAlias = Pool | _SpawnFunc | int | Literal["default"] | None
-class BaseServer(Generic[_P]):
+class BaseServer(Generic[Unpack[_Ts]]):
min_delay: float
max_delay: float
max_accept: int
@@ -27,27 +29,23 @@ class BaseServer(Generic[_P]):
family: int
address: str | tuple[str, int]
socket: _GeventSocket
- handle: Callable[..., object]
+ handle: Callable[[Unpack[_Ts]], object]
def __init__(
self,
listener: _GeventSocket | tuple[str, int] | str,
- handle: Callable[_P, object] | None = None,
+ handle: Callable[[Unpack[_Ts]], object] | None = None,
spawn: _Spawner = "default",
) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(self, typ: type[BaseException] | None, value: BaseException | None, tb: TracebackType | None, /) -> None: ...
def set_listener(self, listener: _GeventSocket | tuple[str, int] | str) -> None: ...
def set_spawn(self, spawn: _Spawner) -> None: ...
- def set_handle(self, handle: Callable[_P, object]) -> None: ...
+ def set_handle(self, handle: Callable[[Unpack[_Ts]], object]) -> None: ...
def start_accepting(self) -> None: ...
def stop_accepting(self) -> None: ...
- # neither of these accept keyword arguments, but if we omit them, then ParamSpec
- # won't match the arguments correctly
- def do_handle(self, *args: _P.args, **_: _P.kwargs) -> None: ...
- def do_close(self, *args: _P.args, **_: _P.kwargs) -> None: ...
- # we would like to return _P.args here, however pyright will complain
- # mypy doesn't seem to mind
- def do_read(self) -> tuple[Any, ...] | None: ...
+ def do_handle(self, *args: Unpack[_Ts]) -> None: ...
+ def do_close(self, *args: Unpack[_Ts]) -> None: ...
+ def do_read(self) -> tuple[Unpack[_Ts]] | None: ...
def full(self) -> bool: ...
@property
def server_host(self) -> str | None: ...
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/event.pyi b/python/helpers/typeshed/stubs/gevent/gevent/event.pyi
index b6b827da36b9..d5570b019301 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/event.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/event.pyi
@@ -1,5 +1,5 @@
from types import TracebackType
-from typing import Generic, Literal, Protocol, TypeVar, overload
+from typing import Generic, Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
from gevent._abstract_linkable import AbstractLinkable
@@ -11,6 +11,7 @@ _T_co = TypeVar("_T_co", covariant=True)
_ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, TracebackType | None]
_OptExcInfo: TypeAlias = _ExcInfo | tuple[None, None, None]
+@type_check_only
class _ValueSource(Protocol[_T_co]):
def successful(self) -> bool: ...
@property
@@ -19,6 +20,7 @@ class _ValueSource(Protocol[_T_co]):
def exception(self) -> BaseException | None: ...
class Event(AbstractLinkable):
+ __slots__ = ("_flag",)
def __init__(self) -> None: ...
def is_set(self) -> bool: ...
def isSet(self) -> bool: ...
@@ -31,6 +33,7 @@ class Event(AbstractLinkable):
def wait(self, timeout: float) -> bool: ...
class AsyncResult(AbstractLinkable, Generic[_T]):
+ __slots__ = ("_value", "_exc_info", "_imap_task_index")
def __init__(self) -> None: ...
@property
def value(self) -> _T | None: ...
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/events.pyi b/python/helpers/typeshed/stubs/gevent/gevent/events.pyi
index de1913d501eb..ffc491711f26 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/events.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/events.pyi
@@ -1,7 +1,7 @@
import sys
from collections.abc import Callable, Mapping, Sequence
from types import ModuleType
-from typing import Any, Protocol, TypeVar
+from typing import Any, Protocol, TypeVar, type_check_only
from typing_extensions import TypeAlias
from gevent.hub import Hub
@@ -30,6 +30,7 @@ else:
subscribers: list[Callable[[Any], object]]
+@type_check_only
class _PeriodicMonitorThread(Protocol):
def add_monitoring_function(self, function: Callable[[Hub], object], period: float | None) -> object: ...
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/hub.pyi b/python/helpers/typeshed/stubs/gevent/gevent/hub.pyi
index 4e4d409b59b4..02631bff6f27 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/hub.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/hub.pyi
@@ -1,6 +1,6 @@
from collections.abc import Callable
from types import TracebackType
-from typing import Any, Generic, Protocol, TextIO, TypeVar, overload
+from typing import Any, Generic, Protocol, TextIO, TypeVar, overload, type_check_only
from typing_extensions import ParamSpec
import gevent._hub_local
@@ -23,6 +23,7 @@ getcurrent = greenlet.getcurrent
get_hub = gevent._hub_local.get_hub
Waiter = gevent._waiter.Waiter
+@type_check_only
class _DefaultReturnProperty(Protocol[_T]):
@overload
def __get__(self, obj: None, owner: type[object] | None = None) -> property: ...
@@ -104,6 +105,7 @@ class Hub(WaitOperationsGreenlet):
threadpool: _DefaultReturnProperty[ThreadPool]
class linkproxy:
+ __slots__ = ["callback", "obj"]
callback: Callable[[object], object]
obj: object
def __init__(self, callback: Callable[[_T], object], obj: _T) -> None: ...
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/libev/corecext.pyi b/python/helpers/typeshed/stubs/gevent/gevent/libev/corecext.pyi
index 5b328fcbe19b..8edbbc56a110 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/libev/corecext.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/libev/corecext.pyi
@@ -43,7 +43,7 @@ if sys.platform != "win32":
def reinit(self) -> None: ...
def ref(self) -> None: ...
def unref(self) -> None: ...
- def break_(self, how: int = ...) -> None: ...
+ def break_(self, how: int = 1) -> None: ...
def verify(self) -> None: ...
def now(self) -> float: ...
def update_now(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/local.pyi b/python/helpers/typeshed/stubs/gevent/gevent/local.pyi
index cdcf88b483c8..30b149cbf3c5 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/local.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/local.pyi
@@ -2,10 +2,19 @@ from typing import Any
from typing_extensions import Self
class local:
+ __slots__ = (
+ "_local__impl",
+ "_local_type_set_descriptors",
+ "_local_type_get_descriptors",
+ "_local_type_vars",
+ "_local_type_del_descriptors",
+ "_local_type",
+ "_local_type_set_or_del_descriptors",
+ )
def __init__(self, *args: object, **kwargs: object) -> None: ...
def __copy__(self) -> Self: ...
- def __getattribute__(self, name: str) -> Any: ...
- def __delattr__(self, name: str) -> None: ...
- def __setattr__(self, name: str, value: Any) -> None: ...
+ def __getattribute__(self, name: str, /) -> Any: ...
+ def __delattr__(self, name: str, /) -> None: ...
+ def __setattr__(self, name: str, value: Any, /) -> None: ...
__all__ = ["local"]
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/lock.pyi b/python/helpers/typeshed/stubs/gevent/gevent/lock.pyi
index 2daa782741fa..80cb2342f661 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/lock.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/lock.pyi
@@ -8,6 +8,7 @@ from gevent.hub import Hub
__all__ = ["Semaphore", "BoundedSemaphore", "DummySemaphore", "RLock"]
class Semaphore(AbstractLinkable):
+ __slots__ = ("counter", "_multithreaded")
counter: int
def __init__(self, value: int = 1, hub: Hub | None = None) -> None: ...
def acquire(self, blocking: bool = True, timeout: float | None = None) -> bool: ...
@@ -18,7 +19,8 @@ class Semaphore(AbstractLinkable):
def __enter__(self) -> None: ...
def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
-class BoundedSemaphore(Semaphore): ...
+class BoundedSemaphore(Semaphore):
+ __slots__ = ("_initial_value",)
class DummySemaphore:
def __init__(self, value: int | None = None) -> None: ...
@@ -33,6 +35,7 @@ class DummySemaphore:
def __exit__(self, typ: type[BaseException] | None, val: BaseException | None, tb: TracebackType | None) -> None: ...
class RLock:
+ __slots__ = ("_block", "_owner", "_count", "__weakref__")
def __init__(self, hub: Hub | None = None) -> None: ...
def acquire(self, blocking: bool = True, timeout: float | None = None) -> bool: ...
def __enter__(self) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/pool.pyi b/python/helpers/typeshed/stubs/gevent/gevent/pool.pyi
index ffda747048a0..7ced638ddf70 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/pool.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/pool.pyi
@@ -18,6 +18,7 @@ _S = TypeVar("_S")
_P = ParamSpec("_P")
class GroupMappingMixin:
+ __slots__ = ()
def spawn(self, func: Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs) -> Greenlet[_P, _T]: ...
# we would like to use ParamSpec for these, but since args and kwds are passed in as is
# pyright will complain if we use _P.args/_P.kwargs, it appears to work on mypy though
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/pywsgi.pyi b/python/helpers/typeshed/stubs/gevent/gevent/pywsgi.pyi
index 91400018eabd..3d9400c6431f 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/pywsgi.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/pywsgi.pyi
@@ -5,7 +5,7 @@ from http.client import HTTPMessage
from io import BufferedIOBase, BufferedReader
from logging import Logger
from types import TracebackType
-from typing import Any, ClassVar, Literal, Protocol, TypeVar, overload
+from typing import Any, ClassVar, Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Self
from gevent.baseserver import _Spawner
@@ -17,11 +17,22 @@ __all__ = ["WSGIServer", "WSGIHandler", "LoggingLogAdapter", "Environ", "SecureE
_T = TypeVar("_T")
+@type_check_only
class _LogOutputStream(SupportsWrite[str], Protocol):
def writelines(self, lines: Iterable[str], /) -> None: ...
def flush(self) -> None: ...
class Input:
+ __slots__ = (
+ "rfile",
+ "content_length",
+ "socket",
+ "position",
+ "chunked_input",
+ "chunk_length",
+ "_chunked_input_error",
+ "send_100_continue_enabled",
+ )
rfile: BufferedReader
content_length: int | None
socket: _GeventSocket | None
@@ -102,6 +113,7 @@ class WSGIHandler:
def get_environ(self) -> WSGIEnvironment: ...
class LoggingLogAdapter:
+ __slots__ = ("_logger", "_level")
def __init__(self, logger: Logger, level: int = 20) -> None: ...
def write(self, msg: str) -> None: ...
def flush(self) -> None: ...
@@ -110,9 +122,11 @@ class LoggingLogAdapter:
def __setattr__(self, name: str, value: object) -> None: ...
def __delattr__(self, name: str) -> None: ...
-class Environ(WSGIEnvironment): ...
+class Environ(WSGIEnvironment):
+ __slots__ = ()
class SecureEnviron(Environ):
+ __slots__ = ("secure_repr", "whitelist_keys", "print_masked_keys")
default_secure_repr: ClassVar[bool]
default_whitelist_keys: ClassVar[Container[str]]
default_print_masked_keys: ClassVar[bool]
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/queue.pyi b/python/helpers/typeshed/stubs/gevent/gevent/queue.pyi
index b95cb5212be6..e0a504edba15 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/queue.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/queue.pyi
@@ -21,6 +21,7 @@ else:
_T = TypeVar("_T")
class SimpleQueue(Generic[_T]):
+ __slots__ = ("_maxsize", "getters", "putters", "hub", "_event_unlock", "queue", "__weakref__", "is_shutdown")
@property
def hub(self) -> Hub: ... # readonly in Cython
@property
@@ -53,6 +54,7 @@ class SimpleQueue(Generic[_T]):
next = __next__
class Queue(SimpleQueue[_T]):
+ __slots__ = ("_cond", "unfinished_tasks")
@property
def unfinished_tasks(self) -> int: ... # readonly in Cython
@overload
@@ -69,6 +71,7 @@ JoinableQueue = Queue
@final
class UnboundQueue(Queue[_T]):
+ __slots__ = ()
@overload
def __init__(self, maxsize: None = None) -> None: ...
@overload
@@ -76,10 +79,14 @@ class UnboundQueue(Queue[_T]):
@overload
def __init__(self, maxsize: None = None, *, items: Iterable[_T]) -> None: ...
-class PriorityQueue(Queue[_T]): ...
-class LifoQueue(Queue[_T]): ...
+class PriorityQueue(Queue[_T]):
+ __slots__ = ()
+
+class LifoQueue(Queue[_T]):
+ __slots__ = ()
class Channel(Generic[_T]):
+ __slots__ = ("getters", "putters", "hub", "_event_unlock", "__weakref__")
@property
def getters(self) -> deque[Waiter[Any]]: ... # readonly in Cython
@property
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/resolver/ares.pyi b/python/helpers/typeshed/stubs/gevent/gevent/resolver/ares.pyi
index 29c5ea0cb843..ca16b3cf1dc1 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/resolver/ares.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/resolver/ares.pyi
@@ -1,11 +1,12 @@
from collections.abc import Sequence
-from typing import TypedDict
+from typing import TypedDict, type_check_only
from gevent._types import _Watcher
from gevent.hub import Hub
from gevent.resolver import AbstractResolver
from gevent.resolver.cares import channel
+@type_check_only
class _ChannelArgs(TypedDict):
flags: str | int | None
timeout: str | float | None
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/resolver/cares.pyi b/python/helpers/typeshed/stubs/gevent/gevent/resolver/cares.pyi
index 21f3e504c7e8..c6b8dc645105 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/resolver/cares.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/resolver/cares.pyi
@@ -43,7 +43,7 @@ class channel:
flags: int = 0,
) -> None: ...
def gethostbyaddr(self, callback: Callable[[Result[ares_host_result]], object], addr: str) -> Any: ...
- def gethostbyname(self, callback: Callable[[Result[ares_host_result]], object], name: str, family: int = ...) -> None: ...
+ def gethostbyname(self, callback: Callable[[Result[ares_host_result]], object], name: str, family: int = 2) -> None: ...
def getnameinfo(self, callback: Callable[[Result[_NameinfoResult]], object], sockaddr: _SockAddr, flags: int) -> None: ...
def set_servers(self, servers: Sequence[str] | str | None = None) -> None: ...
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/server.pyi b/python/helpers/typeshed/stubs/gevent/gevent/server.pyi
index 712754d4ee2a..a76b21c2bb6d 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/server.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/server.pyi
@@ -1,7 +1,7 @@
from _socket import _Address as _StrictAddress
from _typeshed import ReadableBuffer, StrOrBytesPath
from collections.abc import Callable
-from typing import Any, ClassVar, TypedDict, overload
+from typing import Any, ClassVar, TypedDict, overload, type_check_only
from typing_extensions import TypeAlias
from gevent.baseserver import BaseServer, _Spawner
@@ -12,6 +12,7 @@ from gevent.ssl import SSLContext, wrap_socket as ssl_wrap_socket
# from the stdlib _socket.pyi. But that would exclude some potentially valid handlers.
_Address: TypeAlias = Any
+@type_check_only
class _SSLArguments(TypedDict, total=False):
keyfile: StrOrBytesPath
certfile: StrOrBytesPath
@@ -23,7 +24,7 @@ class _SSLArguments(TypedDict, total=False):
do_handshake_on_connect: bool
ciphers: str
-class StreamServer(BaseServer[[_GeventSocket, _Address]]):
+class StreamServer(BaseServer[_GeventSocket, _Address]):
backlog: int
reuse_addr: ClassVar[int | None]
wrap_socket = ssl_wrap_socket
@@ -67,7 +68,7 @@ class StreamServer(BaseServer[[_GeventSocket, _Address]]):
def do_close(self, sock: _GeventSocket, address: _Address) -> None: ...
def wrap_socket_and_handle(self, client_socket: _GeventSocket, address: _StrictAddress) -> Any: ...
-class DatagramServer(BaseServer[[_GeventSocket, _Address]]):
+class DatagramServer(BaseServer[_GeventSocket, _Address]):
reuse_addr: ClassVar[int | None]
def __init__(
self,
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/threadpool.pyi b/python/helpers/typeshed/stubs/gevent/gevent/threadpool.pyi
index e65c64cb2d1f..3ce23ac79fb6 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/threadpool.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/threadpool.pyi
@@ -16,6 +16,17 @@ _TaskItem: TypeAlias = tuple[Callable[..., Any], tuple[Any, ...], dict[str, Any]
_Receiver: TypeAlias = Callable[[_ValueSource[_T]], object]
class ThreadPool(GroupMappingMixin):
+ __slots__ = (
+ "hub",
+ "_maxsize",
+ "manager",
+ "pid",
+ "fork_watcher",
+ "_available_worker_threads_greenlet_sem",
+ "_worker_greenlets",
+ "task_queue",
+ "_idle_task_timeout",
+ )
hub: Hub
pid: int
manager: Greenlet[..., Any] | None
@@ -37,6 +48,7 @@ class ThreadPool(GroupMappingMixin):
def spawn(self, func: Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs) -> AsyncResult[_T]: ... # type: ignore[override]
class ThreadResult(Generic[_T]):
+ __slots__ = ("exc_info", "async_watcher", "_call_when_ready", "value", "context", "hub", "receiver")
receiver: _Receiver[_T]
hub: Hub
context: object | None
diff --git a/python/helpers/typeshed/stubs/gevent/gevent/timeout.pyi b/python/helpers/typeshed/stubs/gevent/gevent/timeout.pyi
index 3fff1e511c8a..bb276524c49d 100644
--- a/python/helpers/typeshed/stubs/gevent/gevent/timeout.pyi
+++ b/python/helpers/typeshed/stubs/gevent/gevent/timeout.pyi
@@ -1,6 +1,6 @@
from collections.abc import Callable
from types import TracebackType
-from typing import Any, Literal, Protocol, TypeVar, overload
+from typing import Any, Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import ParamSpec, Self
from gevent._types import _TimerWatcher
@@ -11,6 +11,7 @@ _T2 = TypeVar("_T2")
_TimeoutT = TypeVar("_TimeoutT", bound=Timeout)
_P = ParamSpec("_P")
+@type_check_only
class _HasSeconds(Protocol):
@property
def seconds(self) -> float | int: ...
diff --git a/python/helpers/typeshed/stubs/greenlet/greenlet/_greenlet.pyi b/python/helpers/typeshed/stubs/greenlet/greenlet/_greenlet.pyi
index ed2dac474595..aafc728fa4e3 100644
--- a/python/helpers/typeshed/stubs/greenlet/greenlet/_greenlet.pyi
+++ b/python/helpers/typeshed/stubs/greenlet/greenlet/_greenlet.pyi
@@ -2,7 +2,7 @@ import sys
from collections.abc import Callable
from contextvars import Context
from types import FrameType, TracebackType
-from typing import Any, Literal, Protocol, overload
+from typing import Any, Literal, Protocol, overload, type_check_only
from typing_extensions import TypeAlias
_TraceEvent: TypeAlias = Literal["switch", "throw"]
@@ -19,6 +19,7 @@ GREENLET_USE_TRACING: bool
# to pass this around, can still pass it around without having to ignore type errors...
_C_API: object
+@type_check_only
class _ParentDescriptor(Protocol):
def __get__(self, obj: greenlet, owner: type[greenlet] | None = None) -> greenlet | None: ...
def __set__(self, obj: greenlet, value: greenlet) -> None: ...
diff --git a/python/helpers/typeshed/stubs/grpcio/grpc/aio/__init__.pyi b/python/helpers/typeshed/stubs/grpcio/grpc/aio/__init__.pyi
index a27b8eeca99a..04d98877f7d9 100644
--- a/python/helpers/typeshed/stubs/grpcio/grpc/aio/__init__.pyi
+++ b/python/helpers/typeshed/stubs/grpcio/grpc/aio/__init__.pyi
@@ -435,7 +435,9 @@ class Metadata(Mapping[_MetadataKey, _MetadataValue]):
def delete_all(self, key: _MetadataKey) -> None: ...
def __iter__(self) -> Iterator[_MetadataKey]: ...
@overload
- def get(self, key: _MetadataKey) -> _MetadataValue | None: ...
+ def get(self, key: _MetadataKey, default: None = None) -> _MetadataValue | None: ...
+ @overload
+ def get(self, key: _MetadataKey, default: _MetadataValue) -> _MetadataValue: ...
@overload
def get(self, key: _MetadataKey, default: _T) -> _MetadataValue | _T: ...
def get_all(self, key: _MetadataKey) -> list[_MetadataValue]: ...
diff --git a/python/helpers/typeshed/stubs/hdbcli/METADATA.toml b/python/helpers/typeshed/stubs/hdbcli/METADATA.toml
index 5898c3f9f5b1..168d2786a79a 100644
--- a/python/helpers/typeshed/stubs/hdbcli/METADATA.toml
+++ b/python/helpers/typeshed/stubs/hdbcli/METADATA.toml
@@ -1,2 +1,2 @@
-version = "2.24.*"
+version = "2.25.*"
# upstream_repository = closed-source
diff --git a/python/helpers/typeshed/stubs/hdbcli/hdbcli/__init__.pyi b/python/helpers/typeshed/stubs/hdbcli/hdbcli/__init__.pyi
index 539250c104a5..bbf8a8962414 100644
--- a/python/helpers/typeshed/stubs/hdbcli/hdbcli/__init__.pyi
+++ b/python/helpers/typeshed/stubs/hdbcli/hdbcli/__init__.pyi
@@ -1,5 +1,7 @@
+from typing import Final
+
from . import dbapi as dbapi
-__version__: str
+__version__: Final[str]
__all__ = ["dbapi"]
diff --git a/python/helpers/typeshed/stubs/hdbcli/hdbcli/dbapi.pyi b/python/helpers/typeshed/stubs/hdbcli/hdbcli/dbapi.pyi
index 2b1282a1f029..0db854ac86a9 100644
--- a/python/helpers/typeshed/stubs/hdbcli/hdbcli/dbapi.pyi
+++ b/python/helpers/typeshed/stubs/hdbcli/hdbcli/dbapi.pyi
@@ -50,6 +50,7 @@ class LOB:
def write(self, object: str | bytes) -> int: ...
_Parameters: TypeAlias = Sequence[tuple[Any, ...]] | None
+_Holdability: TypeAlias = Literal[0, 1, 2, 3]
class Cursor:
description: tuple[tuple[Any, ...], ...]
@@ -74,7 +75,7 @@ class Cursor:
def fetchmany(self, size: int | None = ...) -> list[ResultRow]: ...
def getrowsaffectedcounts(self) -> tuple[Any, ...]: ...
def getpacketsize(self) -> int: ...
- def get_resultset_holdability(self) -> int: ...
+ def get_resultset_holdability(self) -> _Holdability: ...
def getwarning(self) -> Warning | None: ...
def haswarning(self) -> bool: ...
def clearwarning(self) -> None: ...
@@ -95,7 +96,7 @@ class Cursor:
def setfetchsize(self, value: int) -> None: ...
def setquerytimeout(self, value: int) -> None: ...
def setpacketsize(self, value: int) -> None: ...
- def set_resultset_holdability(self, holdability: int) -> None: ...
+ def set_resultset_holdability(self, holdability: _Holdability) -> None: ...
def setoutputsize(self, *args: Any, **kwargs: Any) -> None: ...
def setcommandinfo(self, command_info: str, line_number: int) -> None: ...
diff --git a/python/helpers/typeshed/stubs/hdbcli/hdbcli/resultrow.pyi b/python/helpers/typeshed/stubs/hdbcli/hdbcli/resultrow.pyi
index 8c3da3881017..26b6c37fc773 100644
--- a/python/helpers/typeshed/stubs/hdbcli/hdbcli/resultrow.pyi
+++ b/python/helpers/typeshed/stubs/hdbcli/hdbcli/resultrow.pyi
@@ -8,8 +8,8 @@ class ResultRow:
def __len__(self) -> int: ...
@overload
- def __getitem__(self, index: int) -> Any: ...
+ def __getitem__(self, index: int, /) -> Any: ...
@overload
- def __getitem__(self, index: slice) -> Sequence[Any]: ...
+ def __getitem__(self, index: slice, /) -> Sequence[Any]: ...
def __iter__(self) -> Iterator[Any]: ...
# __next__, __delitem__, __setitem__ are technically defined but lead always to an error
diff --git a/python/helpers/typeshed/stubs/html5lib/METADATA.toml b/python/helpers/typeshed/stubs/html5lib/METADATA.toml
index b1fa786dac26..23a4684130a6 100644
--- a/python/helpers/typeshed/stubs/html5lib/METADATA.toml
+++ b/python/helpers/typeshed/stubs/html5lib/METADATA.toml
@@ -1,7 +1,5 @@
version = "1.1.*"
upstream_repository = "https://github.com/html5lib/html5lib-python"
-partial_stub = true
[tool.stubtest]
-ignore_missing_stub = true
extras = ["all"]
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/__init__.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/__init__.pyi
index 709bc661394a..3a24c70e9f41 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/__init__.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/__init__.pyi
@@ -1,6 +1,10 @@
+from typing import Final
+
from .html5parser import HTMLParser as HTMLParser, parse as parse, parseFragment as parseFragment
from .serializer import serialize as serialize
from .treebuilders import getTreeBuilder as getTreeBuilder
from .treewalkers import getTreeWalker as getTreeWalker
-__version__: str
+__all__ = ["HTMLParser", "parse", "parseFragment", "getTreeBuilder", "getTreeWalker", "serialize"]
+
+__version__: Final[str]
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/_ihatexml.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/_ihatexml.pyi
index cd710c885815..44115cfbab7a 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/_ihatexml.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/_ihatexml.pyi
@@ -1,39 +1,41 @@
-from typing import Any
+import re
+from _typeshed import Incomplete
+from collections.abc import Iterable
baseChar: str
ideographic: str
combiningCharacter: str
digit: str
extender: str
-letter: Any
-name: Any
-nameFirst: Any
-reChar: Any
-reCharRange: Any
+letter: str
+name: str
+nameFirst: str
+reChar: re.Pattern[str]
+reCharRange: re.Pattern[str]
-def charStringToList(chars): ...
-def normaliseCharList(charList): ...
+def charStringToList(chars: str) -> list[str]: ...
+def normaliseCharList(charList: Iterable[str]) -> list[str]: ...
-max_unicode: Any
+max_unicode: int
-def missingRanges(charList): ...
+def missingRanges(charList: Iterable[str]) -> list[str]: ...
def listToRegexpStr(charList): ...
-def hexToInt(hex_str): ...
-def escapeRegexp(string): ...
+def hexToInt(hex_str: str | bytes | bytearray) -> int: ...
+def escapeRegexp(string: str) -> str: ...
-nonXmlNameBMPRegexp: Any
-nonXmlNameFirstBMPRegexp: Any
-nonPubidCharRegexp: Any
+nonXmlNameBMPRegexp: re.Pattern[str]
+nonXmlNameFirstBMPRegexp: re.Pattern[str]
+nonPubidCharRegexp: re.Pattern[str]
class InfosetFilter:
- replacementRegexp: Any
- dropXmlnsLocalName: Any
- dropXmlnsAttrNs: Any
- preventDoubleDashComments: Any
- preventDashAtCommentEnd: Any
- replaceFormFeedCharacters: Any
- preventSingleQuotePubid: Any
- replaceCache: Any
+ replacementRegexp: re.Pattern[str]
+ dropXmlnsLocalName: Incomplete
+ dropXmlnsAttrNs: Incomplete
+ preventDoubleDashComments: Incomplete
+ preventDashAtCommentEnd: Incomplete
+ replaceFormFeedCharacters: Incomplete
+ preventSingleQuotePubid: Incomplete
+ replaceCache: Incomplete
def __init__(
self,
dropXmlnsLocalName: bool = False,
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/_inputstream.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/_inputstream.pyi
index 10759fad6cd5..9f10e4dbf98e 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/_inputstream.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/_inputstream.pyi
@@ -1,9 +1,10 @@
-from _typeshed import SupportsRead
+from _typeshed import Incomplete, SupportsRead
from codecs import CodecInfo
-from typing import Any, Protocol, overload
+from typing import Protocol, overload, type_check_only
from typing_extensions import TypeAlias
# Is actually webencodings.Encoding
+@type_check_only
class _Encoding(Protocol):
name: str
codec_info: CodecInfo
@@ -13,20 +14,20 @@ _UnicodeInputStream: TypeAlias = str | SupportsRead[str]
_BinaryInputStream: TypeAlias = bytes | SupportsRead[bytes]
_InputStream: TypeAlias = _UnicodeInputStream | _BinaryInputStream # noqa: Y047 # used in other files
-spaceCharactersBytes: Any
-asciiLettersBytes: Any
-asciiUppercaseBytes: Any
-spacesAngleBrackets: Any
+spaceCharactersBytes: Incomplete
+asciiLettersBytes: Incomplete
+asciiUppercaseBytes: Incomplete
+spacesAngleBrackets: Incomplete
invalid_unicode_no_surrogate: str
-invalid_unicode_re: Any
-non_bmp_invalid_codepoints: Any
-ascii_punctuation_re: Any
-charsUntilRegEx: Any
+invalid_unicode_re: Incomplete
+non_bmp_invalid_codepoints: Incomplete
+ascii_punctuation_re: Incomplete
+charsUntilRegEx: Incomplete
class BufferedStream:
- stream: Any
- buffer: Any
- position: Any
+ stream: Incomplete
+ buffer: Incomplete
+ position: Incomplete
def __init__(self, stream) -> None: ...
def tell(self): ...
def seek(self, pos) -> None: ...
@@ -47,10 +48,10 @@ def HTMLInputStream(
) -> HTMLBinaryInputStream: ...
class HTMLUnicodeInputStream:
- reportCharacterErrors: Any
- newLines: Any
+ reportCharacterErrors: Incomplete
+ newLines: Incomplete
charEncoding: tuple[_Encoding, str]
- dataStream: Any
+ dataStream: Incomplete
def __init__(self, source: _UnicodeInputStream) -> None: ...
chunk: str
chunkSize: int
@@ -69,14 +70,14 @@ class HTMLUnicodeInputStream:
def unget(self, char) -> None: ...
class HTMLBinaryInputStream(HTMLUnicodeInputStream):
- rawStream: Any
+ rawStream: Incomplete
numBytesMeta: int
numBytesChardet: int
- override_encoding: Any
- transport_encoding: Any
- same_origin_parent_encoding: Any
- likely_encoding: Any
- default_encoding: Any
+ override_encoding: Incomplete
+ transport_encoding: Incomplete
+ same_origin_parent_encoding: Incomplete
+ likely_encoding: Incomplete
+ default_encoding: Incomplete
charEncoding: tuple[_Encoding, str]
def __init__(
self,
@@ -88,7 +89,7 @@ class HTMLBinaryInputStream(HTMLUnicodeInputStream):
default_encoding: str = "windows-1252",
useChardet: bool = True,
) -> None: ...
- dataStream: Any
+ dataStream: Incomplete
def reset(self) -> None: ...
def openStream(self, source): ...
def determineEncoding(self, chardet: bool = True): ...
@@ -105,7 +106,7 @@ class EncodingBytes(bytes):
def previous(self): ...
def setPosition(self, position) -> None: ...
def getPosition(self): ...
- position: Any
+ position: Incomplete
def getCurrentByte(self): ...
@property
def currentByte(self): ...
@@ -115,8 +116,8 @@ class EncodingBytes(bytes):
def jumpTo(self, bytes): ...
class EncodingParser:
- data: Any
- encoding: Any
+ data: Incomplete
+ encoding: Incomplete
def __init__(self, data) -> None: ...
def getEncoding(self): ...
def handleComment(self): ...
@@ -128,7 +129,7 @@ class EncodingParser:
def getAttribute(self): ...
class ContentAttrParser:
- data: Any
+ data: Incomplete
def __init__(self, data) -> None: ...
def parse(self): ...
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/_tokenizer.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/_tokenizer.pyi
index e999fbcde4cf..22316b1112b5 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/_tokenizer.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/_tokenizer.pyi
@@ -1,20 +1,20 @@
-from typing import Any
+from _typeshed import Incomplete
from ._inputstream import _InputStream
-entitiesTrie: Any
+entitiesTrie: Incomplete
attributeMap = dict
class HTMLTokenizer:
- stream: Any
- parser: Any
+ stream: Incomplete
+ parser: Incomplete
escapeFlag: bool
- lastFourChars: Any
- state: Any
+ lastFourChars: Incomplete
+ state: Incomplete
escape: bool
- currentToken: Any
+ currentToken: Incomplete
def __init__(self, stream: _InputStream, parser=None, **kwargs) -> None: ...
- tokenQueue: Any
+ tokenQueue: Incomplete
def __iter__(self): ...
def consumeNumberEntity(self, isHex): ...
def consumeEntity(self, allowedChar=None, fromAttribute: bool = False) -> None: ...
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/_trie/__init__.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/_trie/__init__.pyi
index 7095d84cbea4..3b0ea9a093bf 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/_trie/__init__.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/_trie/__init__.pyi
@@ -1 +1,3 @@
from .py import Trie as Trie
+
+__all__ = ["Trie"]
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/_trie/_base.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/_trie/_base.pyi
index 7016028a2417..45725be511b6 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/_trie/_base.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/_trie/_base.pyi
@@ -1,8 +1,8 @@
+from _typeshed import Incomplete
from abc import ABCMeta
from collections.abc import Mapping
-from typing import Any
-class Trie(Mapping[Any, Any], metaclass=ABCMeta):
+class Trie(Mapping[Incomplete, Incomplete], metaclass=ABCMeta):
def keys(self, prefix=None): ...
def has_keys_with_prefix(self, prefix): ...
def longest_prefix(self, prefix): ...
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/_utils.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/_utils.pyi
index 7cc3edba3c64..f41afba04144 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/_utils.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/_utils.pyi
@@ -1,17 +1,27 @@
+import xml.etree.ElementTree as default_etree
+from _typeshed import Incomplete
from collections.abc import Mapping
-from typing import Any
+
+__all__ = [
+ "default_etree",
+ "MethodDispatcher",
+ "isSurrogatePair",
+ "surrogatePairToCodepoint",
+ "moduleFactoryFactory",
+ "supports_lone_surrogates",
+]
supports_lone_surrogates: bool
-class MethodDispatcher(dict[Any, Any]):
- default: Any
+class MethodDispatcher(dict[Incomplete, Incomplete]):
+ default: Incomplete
def __init__(self, items=()) -> None: ...
def __getitem__(self, key): ...
def __get__(self, instance, owner=None): ...
-class BoundMethodDispatcher(Mapping[Any, Any]):
- instance: Any
- dispatcher: Any
+class BoundMethodDispatcher(Mapping[Incomplete, Incomplete]):
+ instance: Incomplete
+ dispatcher: Incomplete
def __init__(self, instance, dispatcher) -> None: ...
def __getitem__(self, key): ...
def get(self, key, default): ... # type: ignore[override]
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/constants.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/constants.pyi
index b8a3ac8f1cdd..a0e12fbff98e 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/constants.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/constants.pyi
@@ -1,37 +1,37 @@
-from typing import Any
+from _typeshed import Incomplete
-EOF: Any
-E: Any
-namespaces: Any
-scopingElements: Any
-formattingElements: Any
-specialElements: Any
-htmlIntegrationPointElements: Any
-mathmlTextIntegrationPointElements: Any
-adjustSVGAttributes: Any
-adjustMathMLAttributes: Any
-adjustForeignAttributes: Any
-unadjustForeignAttributes: Any
-spaceCharacters: Any
-tableInsertModeElements: Any
-asciiLowercase: Any
-asciiUppercase: Any
-asciiLetters: Any
-digits: Any
-hexDigits: Any
-asciiUpper2Lower: Any
-headingElements: Any
-voidElements: Any
-cdataElements: Any
-rcdataElements: Any
-booleanAttributes: Any
-entitiesWindows1252: Any
-xmlEntities: Any
-entities: Any
-replacementCharacters: Any
-tokenTypes: Any
-tagTokenTypes: Any
-prefixes: Any
+EOF: Incomplete
+E: dict[str, str]
+namespaces: dict[str, str]
+scopingElements: frozenset[tuple[str, str]]
+formattingElements: frozenset[tuple[str, str]]
+specialElements: frozenset[tuple[str, str]]
+htmlIntegrationPointElements: frozenset[tuple[str, str]]
+mathmlTextIntegrationPointElements: frozenset[tuple[str, str]]
+adjustSVGAttributes: dict[str, str]
+adjustMathMLAttributes: dict[str, str]
+adjustForeignAttributes: dict[str, tuple[str, str, str] | tuple[None, str, str]]
+unadjustForeignAttributes: dict[tuple[str, str], str]
+spaceCharacters: frozenset[str]
+tableInsertModeElements: frozenset[str]
+asciiLowercase: frozenset[str]
+asciiUppercase: frozenset[str]
+asciiLetters: frozenset[str]
+digits: frozenset[str]
+hexDigits: frozenset[str]
+asciiUpper2Lower: dict[int, int]
+headingElements: tuple[str, ...]
+voidElements: frozenset[str]
+cdataElements: frozenset[str]
+rcdataElements: frozenset[str]
+booleanAttributes: dict[str, frozenset[str]]
+entitiesWindows1252: tuple[int, ...]
+xmlEntities: frozenset[str]
+entities: dict[str, str]
+replacementCharacters: dict[int, str]
+tokenTypes: dict[str, int]
+tagTokenTypes: frozenset[int]
+prefixes: dict[str, str]
class DataLossWarning(UserWarning): ...
class _ReparseException(Exception): ...
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/filters/base.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/filters/base.pyi
index 166f2040425e..82773fd9124f 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/filters/base.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/filters/base.pyi
@@ -1,7 +1,7 @@
-from typing import Any
+from _typeshed import Incomplete
class Filter:
- source: Any
+ source: Incomplete
def __init__(self, source) -> None: ...
def __iter__(self): ...
def __getattr__(self, name: str): ...
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/filters/inject_meta_charset.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/filters/inject_meta_charset.pyi
index 9cde8fde35bc..030cd63753df 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/filters/inject_meta_charset.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/filters/inject_meta_charset.pyi
@@ -1,8 +1,6 @@
-from typing import Any
-
from . import base
class Filter(base.Filter):
- encoding: Any
- def __init__(self, source, encoding) -> None: ...
+ encoding: str | None
+ def __init__(self, source, encoding: str | None) -> None: ...
def __iter__(self): ...
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/filters/lint.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/filters/lint.pyi
index 9aba9592a96f..39629c8696d6 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/filters/lint.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/filters/lint.pyi
@@ -1,8 +1,8 @@
-from typing import Any
-
from . import base
+spaceCharacters: str
+
class Filter(base.Filter):
- require_matching_tags: Any
+ require_matching_tags: bool
def __init__(self, source, require_matching_tags: bool = True) -> None: ...
def __iter__(self): ...
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/filters/optionaltags.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/filters/optionaltags.pyi
index 5d53a467e4a5..81045a0e068f 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/filters/optionaltags.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/filters/optionaltags.pyi
@@ -1,7 +1,10 @@
+from _typeshed import Incomplete
+from collections.abc import Generator
+
from . import base
class Filter(base.Filter):
- def slider(self) -> None: ...
+ def slider(self) -> Generator[tuple[Incomplete, Incomplete, Incomplete]]: ...
def __iter__(self): ...
- def is_optional_start(self, tagname, previous, next): ...
- def is_optional_end(self, tagname, next): ...
+ def is_optional_start(self, tagname: str, previous, next) -> bool: ...
+ def is_optional_end(self, tagname: str, next) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/filters/sanitizer.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/filters/sanitizer.pyi
index 176e81a01796..7761f2719a5a 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/filters/sanitizer.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/filters/sanitizer.pyi
@@ -1,34 +1,51 @@
-from typing import Any
+import re
+from collections.abc import Iterable
+from typing_extensions import deprecated
from . import base
+__all__ = ["Filter"]
+
+allowed_elements: frozenset[tuple[str, str]]
+allowed_attributes: frozenset[tuple[None, str] | tuple[str, str]]
+attr_val_is_uri: frozenset[tuple[None, str] | tuple[str, str]]
+svg_attr_val_allows_ref: frozenset[tuple[None, str]]
+svg_allow_local_href: frozenset[tuple[None, str]]
+allowed_css_properties: frozenset[str]
+allowed_css_keywords: frozenset[str]
+allowed_svg_properties: frozenset[str]
+allowed_protocols: frozenset[str]
+allowed_content_types: frozenset[str]
+data_content_type: re.Pattern[str]
+
+@deprecated("html5lib's sanitizer is deprecated; see https://github.com/html5lib/html5lib-python/issues/443")
class Filter(base.Filter):
- allowed_elements: Any
- allowed_attributes: Any
- allowed_css_properties: Any
- allowed_css_keywords: Any
- allowed_svg_properties: Any
- allowed_protocols: Any
- allowed_content_types: Any
- attr_val_is_uri: Any
- svg_attr_val_allows_ref: Any
- svg_allow_local_href: Any
+ allowed_elements: Iterable[tuple[str | None, str]]
+ allowed_attributes: Iterable[tuple[str | None, str]]
+ allowed_css_properties: Iterable[str]
+ allowed_css_keywords: Iterable[str]
+ allowed_svg_properties: Iterable[str]
+ allowed_protocols: Iterable[str]
+ allowed_content_types: Iterable[str]
+ attr_val_is_uri: Iterable[tuple[str | None, str]]
+ svg_attr_val_allows_ref: Iterable[tuple[str | None, str]]
+ svg_allow_local_href: Iterable[tuple[str | None, str]]
def __init__(
self,
source,
- allowed_elements=...,
- allowed_attributes=...,
- allowed_css_properties=...,
- allowed_css_keywords=...,
- allowed_svg_properties=...,
- allowed_protocols=...,
- allowed_content_types=...,
- attr_val_is_uri=...,
- svg_attr_val_allows_ref=...,
- svg_allow_local_href=...,
+ allowed_elements: Iterable[tuple[str | None, str]] = ...,
+ allowed_attributes: Iterable[tuple[str | None, str]] = ...,
+ allowed_css_properties: Iterable[str] = ...,
+ allowed_css_keywords: Iterable[str] = ...,
+ allowed_svg_properties: Iterable[str] = ...,
+ allowed_protocols: Iterable[str] = ...,
+ allowed_content_types: Iterable[str] = ...,
+ attr_val_is_uri: Iterable[tuple[str | None, str]] = ...,
+ svg_attr_val_allows_ref: Iterable[tuple[str | None, str]] = ...,
+ svg_allow_local_href: Iterable[tuple[str | None, str]] = ...,
) -> None: ...
def __iter__(self): ...
def sanitize_token(self, token): ...
def allowed_token(self, token): ...
def disallowed_token(self, token): ...
- def sanitize_css(self, style): ...
+ def sanitize_css(self, style: str) -> str: ...
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/filters/whitespace.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/filters/whitespace.pyi
index 117aaf6411a0..39f818100c7a 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/filters/whitespace.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/filters/whitespace.pyi
@@ -1,11 +1,12 @@
-from typing import Any
+import re
from . import base
-SPACES_REGEX: Any
+spaceCharacters: str
+SPACES_REGEX: re.Pattern[str]
class Filter(base.Filter):
- spacePreserveElements: Any
+ spacePreserveElements: frozenset[str]
def __iter__(self): ...
-def collapse_spaces(text): ...
+def collapse_spaces(text: str) -> str: ...
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/html5parser.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/html5parser.pyi
index 2e38eaea5688..ca2bd4f31e2b 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/html5parser.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/html5parser.pyi
@@ -1,9 +1,10 @@
from _typeshed import Incomplete
-from typing import Any, Literal, overload
+from typing import Literal, overload
from xml.etree.ElementTree import Element
from ._inputstream import _InputStream
from ._tokenizer import HTMLTokenizer
+from .treebuilders.base import TreeBuilder
@overload
def parse(
@@ -18,18 +19,24 @@ def method_decorator_metaclass(function): ...
class HTMLParser:
strict: bool
- tree: Any
+ tree: Incomplete
errors: list[Incomplete]
- phases: Any
- def __init__(self, tree=None, strict: bool = False, namespaceHTMLElements: bool = True, debug: bool = False) -> None: ...
+ phases: Incomplete
+ def __init__(
+ self,
+ tree: str | type[TreeBuilder] | None = None,
+ strict: bool = False,
+ namespaceHTMLElements: bool = True,
+ debug: bool = False,
+ ) -> None: ...
firstStartTag: bool
- log: Any
+ log: Incomplete
compatMode: str
container: str
- innerHTML: Any
- phase: Any
- lastPhase: Any
- beforeRCDataPhase: Any
+ innerHTML: Incomplete
+ phase: Incomplete
+ lastPhase: Incomplete
+ beforeRCDataPhase: Incomplete
framesetOK: bool
tokenizer: HTMLTokenizer
def reset(self) -> None: ...
@@ -46,7 +53,7 @@ class HTMLParser:
def adjustForeignAttributes(self, token) -> None: ...
def reparseTokenNormal(self, token) -> None: ...
def resetInsertionMode(self) -> None: ...
- originalPhase: Any
+ originalPhase: Incomplete
def parseRCDataRawtext(self, token, contentType) -> None: ...
def getPhases(debug): ...
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/serializer.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/serializer.pyi
index c17b2205ae43..e7232e2e1d11 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/serializer.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/serializer.pyi
@@ -1,6 +1,9 @@
from _typeshed import Incomplete
from collections.abc import Generator
-from typing import Any, overload
+from typing import overload
+
+k: str
+v: str | int
def htmlentityreplace_errors(exc: Exception) -> tuple[str | bytes, int]: ...
@overload
@@ -25,14 +28,14 @@ class HTMLSerializer:
inject_meta_charset: bool
strip_whitespace: bool
sanitize: bool
- options: Any
- errors: Any
+ options: Incomplete
+ errors: Incomplete
strict: bool
def __init__(self, **kwargs) -> None: ...
def encode(self, string): ...
def encodeStrict(self, string): ...
- encoding: Any
- def serialize(self, treewalker, encoding=None) -> Generator[Incomplete, None, None]: ...
+ encoding: Incomplete
+ def serialize(self, treewalker, encoding=None) -> Generator[Incomplete]: ...
def render(self, treewalker, encoding=None): ...
def serializeError(self, data: str = "XXX ERROR MESSAGE NEEDED") -> None: ...
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/treeadapters/__init__.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/treeadapters/__init__.pyi
index bf1267485d4b..49b1ebb296a2 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/treeadapters/__init__.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/treeadapters/__init__.pyi
@@ -1 +1,3 @@
from . import genshi as genshi, sax as sax
+
+__all__ = ["sax", "genshi"]
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/treeadapters/sax.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/treeadapters/sax.pyi
index 87ebcb1cb930..3ac32ef19361 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/treeadapters/sax.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/treeadapters/sax.pyi
@@ -1,5 +1,6 @@
-from typing import Any
-
-prefix_mapping: Any
+prefix: str | None
+localName: str
+namespace: str
+prefix_mapping: dict[str, str]
def to_sax(walker, handler) -> None: ...
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/treebuilders/__init__.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/treebuilders/__init__.pyi
index 703478287fe5..7fc1af410d92 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/treebuilders/__init__.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/treebuilders/__init__.pyi
@@ -1,5 +1,5 @@
-from typing import Any
+from typing import Literal
-treeBuilderCache: Any
+treeBuilderCache: dict[str, type]
-def getTreeBuilder(treeType, implementation=None, **kwargs): ...
+def getTreeBuilder(treeType: Literal["dom", "etree", "lxml"], implementation=None, **kwargs): ...
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/treebuilders/base.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/treebuilders/base.pyi
index 577b92327b9c..59137fe3239f 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/treebuilders/base.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/treebuilders/base.pyi
@@ -1,15 +1,15 @@
-from typing import Any
+from _typeshed import Incomplete
-Marker: Any
-listElementsMap: Any
+Marker: Incomplete
+listElementsMap: dict[str | None, tuple[frozenset[tuple[str, str]], bool]]
class Node:
- name: Any
- parent: Any
- value: Any
- attributes: Any
- childNodes: Any
- def __init__(self, name) -> None: ...
+ name: str
+ parent: Incomplete
+ value: Incomplete
+ attributes: Incomplete
+ childNodes: Incomplete
+ def __init__(self, name: str) -> None: ...
def appendChild(self, node) -> None: ...
def insertText(self, data, insertBefore=None) -> None: ...
def insertBefore(self, node, refNode) -> None: ...
@@ -18,24 +18,24 @@ class Node:
def cloneNode(self) -> None: ...
def hasContent(self) -> None: ...
-class ActiveFormattingElements(list[Any]):
+class ActiveFormattingElements(list[Incomplete]):
def append(self, node) -> None: ...
- def nodesEqual(self, node1, node2): ...
+ def nodesEqual(self, node1, node2) -> bool: ...
class TreeBuilder:
- documentClass: Any
- elementClass: Any
- commentClass: Any
- doctypeClass: Any
- fragmentClass: Any
- defaultNamespace: str
- def __init__(self, namespaceHTMLElements) -> None: ...
- openElements: Any
- activeFormattingElements: Any
- headPointer: Any
- formPointer: Any
+ documentClass: Incomplete
+ elementClass: Incomplete
+ commentClass: Incomplete
+ doctypeClass: Incomplete
+ fragmentClass: Incomplete
+ defaultNamespace: str | None
+ def __init__(self, namespaceHTMLElements: bool | None) -> None: ...
+ openElements: Incomplete
+ activeFormattingElements: Incomplete
+ headPointer: Incomplete
+ formPointer: Incomplete
insertFromTable: bool
- document: Any
+ document: Incomplete
def reset(self) -> None: ...
def elementInScope(self, target, variant=None): ...
def reconstructActiveFormattingElements(self) -> None: ...
@@ -52,4 +52,4 @@ class TreeBuilder:
def generateImpliedEndTags(self, exclude=None) -> None: ...
def getDocument(self): ...
def getFragment(self): ...
- def testSerializer(self, node) -> None: ...
+ def testSerializer(self, node): ...
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/treebuilders/dom.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/treebuilders/dom.pyi
index 12de3344d248..d8049c383cf1 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/treebuilders/dom.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/treebuilders/dom.pyi
@@ -1,5 +1,7 @@
-from typing import Any
+from _typeshed import Incomplete
+from collections.abc import Callable
+from types import ModuleType
-def getDomBuilder(DomImplementation): ...
+def getDomBuilder(DomImplementation) -> dict[str, Incomplete]: ...
-getDomModule: Any
+getDomModule: Callable[..., ModuleType]
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/treebuilders/etree.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/treebuilders/etree.pyi
index 948651dabd8c..b9dfabb88835 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/treebuilders/etree.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/treebuilders/etree.pyi
@@ -1,7 +1,10 @@
-from typing import Any
+import re
+from _typeshed import Incomplete
+from collections.abc import Callable
+from types import ModuleType
-tag_regexp: Any
+tag_regexp: re.Pattern[str]
-def getETreeBuilder(ElementTreeImplementation, fullTree: bool = False): ...
+def getETreeBuilder(ElementTreeImplementation, fullTree: bool = False) -> dict[str, Incomplete]: ...
-getETreeModule: Any
+getETreeModule: Callable[..., ModuleType]
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/treebuilders/etree_lxml.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/treebuilders/etree_lxml.pyi
index 3bf5bea6481f..665eb117d358 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/treebuilders/etree_lxml.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/treebuilders/etree_lxml.pyi
@@ -1,15 +1,16 @@
-from typing import Any
+import re
+from _typeshed import Incomplete
from . import base
fullTree: bool
-tag_regexp: Any
-comment_type: Any
+tag_regexp: re.Pattern[str]
+comment_type: Incomplete
class DocumentType:
- name: Any
- publicId: Any
- systemId: Any
+ name: Incomplete
+ publicId: Incomplete
+ systemId: Incomplete
def __init__(self, name, publicId, systemId) -> None: ...
class Document:
@@ -18,21 +19,21 @@ class Document:
@property
def childNodes(self): ...
-def testSerializer(element): ...
-def tostring(element): ...
+def testSerializer(element) -> str: ...
+def tostring(element) -> str: ...
class TreeBuilder(base.TreeBuilder):
- documentClass: Any
- doctypeClass: Any
- elementClass: Any
- commentClass: Any
- fragmentClass: Any
- implementation: Any
- namespaceHTMLElements: Any
+ documentClass: Incomplete
+ doctypeClass: Incomplete
+ elementClass: Incomplete
+ commentClass: Incomplete
+ fragmentClass: Incomplete
+ implementation: Incomplete
+ namespaceHTMLElements: Incomplete
def __init__(self, namespaceHTMLElements, fullTree: bool = False): ...
- insertComment: Any
- initial_comments: Any
- doctype: Any
+ insertComment: Incomplete
+ initial_comments: Incomplete
+ doctype: Incomplete
def reset(self) -> None: ...
def testSerializer(self, element): ...
def getDocument(self): ...
@@ -40,5 +41,5 @@ class TreeBuilder(base.TreeBuilder):
def insertDoctype(self, token) -> None: ...
def insertCommentInitial(self, data, parent=None) -> None: ...
def insertCommentMain(self, data, parent=None) -> None: ...
- document: Any
+ document: Incomplete
def insertRoot(self, token) -> None: ...
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/treewalkers/__init__.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/treewalkers/__init__.pyi
index 62d6f2a9f5fc..247912e69830 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/treewalkers/__init__.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/treewalkers/__init__.pyi
@@ -1,2 +1,7 @@
-def getTreeWalker(treeType, implementation=None, **kwargs): ...
-def pprint(walker): ...
+from types import ModuleType
+
+__all__ = ["getTreeWalker", "pprint"]
+
+def getTreeWalker(treeType: str, implementation: ModuleType | None = None, **kwargs): ...
+def concatenateCharacterTokens(tokens): ...
+def pprint(walker) -> str: ...
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/treewalkers/base.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/treewalkers/base.pyi
index 3e6649735266..2ef37965b6d2 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/treewalkers/base.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/treewalkers/base.pyi
@@ -1,15 +1,18 @@
-from typing import Any
+from _typeshed import Incomplete
-DOCUMENT: Any
-DOCTYPE: Any
-TEXT: Any
-ELEMENT: Any
-COMMENT: Any
-ENTITY: Any
+__all__ = ["DOCUMENT", "DOCTYPE", "TEXT", "ELEMENT", "COMMENT", "ENTITY", "UNKNOWN", "TreeWalker", "NonRecursiveTreeWalker"]
+
+DOCUMENT: int
+DOCTYPE: int
+TEXT: int
+ELEMENT: int
+COMMENT: int
+ENTITY: int
UNKNOWN: str
+spaceCharacters: str
class TreeWalker:
- tree: Any
+ tree: Incomplete
def __init__(self, tree) -> None: ...
def __iter__(self): ...
def error(self, msg): ...
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/treewalkers/etree.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/treewalkers/etree.pyi
index 33f6d800214f..94878061a818 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/treewalkers/etree.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/treewalkers/etree.pyi
@@ -1,7 +1,9 @@
-from typing import Any
+import re
+from collections.abc import Callable
+from types import ModuleType
-tag_regexp: Any
+tag_regexp: re.Pattern[str]
def getETreeBuilder(ElementTreeImplementation): ...
-getETreeModule: Any
+getETreeModule: Callable[..., ModuleType]
diff --git a/python/helpers/typeshed/stubs/html5lib/html5lib/treewalkers/etree_lxml.pyi b/python/helpers/typeshed/stubs/html5lib/html5lib/treewalkers/etree_lxml.pyi
index 6ef2c48379f5..4071bb068650 100644
--- a/python/helpers/typeshed/stubs/html5lib/html5lib/treewalkers/etree_lxml.pyi
+++ b/python/helpers/typeshed/stubs/html5lib/html5lib/treewalkers/etree_lxml.pyi
@@ -1,40 +1,44 @@
-from typing import Any
+from _typeshed import Incomplete
+from typing import SupportsIndex, overload
from .base import NonRecursiveTreeWalker
-def ensure_str(s): ...
+@overload
+def ensure_str(s: None) -> None: ...
+@overload
+def ensure_str(s: str | bytes | bytearray) -> str: ...
class Root:
- elementtree: Any
- children: Any
- text: Any
- tail: Any
+ elementtree: Incomplete
+ children: list[Incomplete]
+ text: str | None
+ tail: str | None
def __init__(self, et) -> None: ...
- def __getitem__(self, key): ...
+ def __getitem__(self, key: SupportsIndex): ...
def getnext(self) -> None: ...
def __len__(self) -> int: ...
class Doctype:
- root_node: Any
- name: Any
- public_id: Any
- system_id: Any
- text: Any
- tail: Any
+ root_node: Incomplete
+ name: Incomplete
+ public_id: Incomplete
+ system_id: Incomplete
+ text: Incomplete
+ tail: Incomplete
def __init__(self, root_node, name, public_id, system_id) -> None: ...
def getnext(self): ...
class FragmentRoot(Root):
- children: Any
- text: Any
+ children: Incomplete
+ text: Incomplete
def __init__(self, children) -> None: ...
def getnext(self) -> None: ...
class FragmentWrapper:
- root_node: Any
- obj: Any
- text: Any
- tail: Any
+ root_node: Incomplete
+ obj: Incomplete
+ text: Incomplete
+ tail: Incomplete
def __init__(self, fragment_root, obj) -> None: ...
def __getattr__(self, name: str): ...
def getnext(self): ...
@@ -45,8 +49,8 @@ class FragmentWrapper:
def __len__(self) -> int: ...
class TreeWalker(NonRecursiveTreeWalker):
- fragmentChildren: Any
- filter: Any
+ fragmentChildren: Incomplete
+ filter: Incomplete
def __init__(self, tree) -> None: ...
def getNodeDetails(self, node): ...
def getFirstChild(self, node): ...
diff --git a/python/helpers/typeshed/stubs/httplib2/httplib2/__init__.pyi b/python/helpers/typeshed/stubs/httplib2/httplib2/__init__.pyi
index 1ae0fe340053..c61d1456bba3 100644
--- a/python/helpers/typeshed/stubs/httplib2/httplib2/__init__.pyi
+++ b/python/helpers/typeshed/stubs/httplib2/httplib2/__init__.pyi
@@ -1,35 +1,62 @@
+import email.message
import http.client
+import re
+from _ssl import _PasswordType
+from _typeshed import Incomplete, MaybeNone, StrOrBytesPath
from collections.abc import Generator
-from typing import Any, ClassVar
+from ssl import _SSLMethod
+from typing import ClassVar, Final, Literal, TypeVar
from typing_extensions import Self
from .error import *
-__author__: str
-__copyright__: str
-__contributors__: list[str]
-__license__: str
-__version__: str
+_T = TypeVar("_T", default=str)
-debuglevel: int
-RETRIES: int
+__author__: Final[str]
+__copyright__: Final[str]
+__contributors__: Final[list[str]]
+__license__: Final[str]
+__version__: Final[str]
+
+def has_timeout(timeout: float | None) -> bool: ...
+
+debuglevel: Final[int]
+RETRIES: Final[int]
+DEFAULT_MAX_REDIRECTS: Final[int]
+HOP_BY_HOP: Final[list[str]]
+SAFE_METHODS: Final[tuple[str, ...]]
+REDIRECT_CODES: Final[frozenset[int]]
+CA_CERTS: Final[str]
+DEFAULT_TLS_VERSION: Final[_SSLMethod]
+URI: Final[re.Pattern[str]]
+
+def parse_uri(uri: str) -> tuple[str | MaybeNone, str | MaybeNone, str | MaybeNone, str | MaybeNone, str | MaybeNone]: ...
+def urlnorm(uri: str) -> tuple[str | MaybeNone, str | MaybeNone, str | MaybeNone, str | MaybeNone]: ...
+
+re_url_scheme: Final[re.Pattern[str]]
+re_unsafe: Final[re.Pattern[str]]
+
+def safename(filename: str | bytes) -> str: ...
+
+NORMALIZE_SPACE: Final[re.Pattern[str]]
+USE_WWW_AUTH_STRICT_PARSING: Final[int]
class Authentication:
- path: Any
- host: Any
- credentials: Any
- http: Any
- def __init__(self, credentials, host, request_uri, headers, response, content, http) -> None: ...
- def depth(self, request_uri): ...
- def inscope(self, host, request_uri): ...
+ path: Incomplete
+ host: Incomplete
+ credentials: Incomplete
+ http: Incomplete
+ def __init__(self, credentials, host, request_uri: str, headers, response, content, http) -> None: ...
+ def depth(self, request_uri: str) -> int: ...
+ def inscope(self, host: str, request_uri: str) -> bool: ...
def request(self, method, request_uri, headers, content) -> None: ...
- def response(self, response, content): ...
- def __eq__(self, auth): ...
- def __ne__(self, auth): ...
- def __lt__(self, auth): ...
- def __gt__(self, auth): ...
- def __le__(self, auth): ...
- def __ge__(self, auth): ...
+ def response(self, response, content) -> bool: ...
+ def __eq__(self, auth: object) -> bool: ...
+ def __ne__(self, auth: object) -> bool: ...
+ def __lt__(self, auth: object) -> bool: ...
+ def __gt__(self, auth: object) -> bool: ...
+ def __le__(self, auth: object) -> bool: ...
+ def __ge__(self, auth: object) -> bool: ...
def __bool__(self) -> bool: ...
class BasicAuthentication(Authentication):
@@ -37,21 +64,21 @@ class BasicAuthentication(Authentication):
def request(self, method, request_uri, headers, content) -> None: ...
class DigestAuthentication(Authentication):
- challenge: Any
- A1: Any
+ challenge: Incomplete
+ A1: Incomplete
def __init__(self, credentials, host, request_uri, headers, response, content, http) -> None: ...
def request(self, method, request_uri, headers, content, cnonce=None): ...
- def response(self, response, content): ...
+ def response(self, response, content) -> bool: ...
class HmacDigestAuthentication(Authentication):
- challenge: Any
- hashmod: Any
- pwhashmod: Any
- key: Any
+ challenge: Incomplete
+ hashmod: Incomplete
+ pwhashmod: Incomplete
+ key: Incomplete
__author__: ClassVar[str]
def __init__(self, credentials, host, request_uri, headers, response, content, http) -> None: ...
def request(self, method, request_uri, headers, content) -> None: ...
- def response(self, response, content): ...
+ def response(self, response, content) -> bool: ...
class WsseAuthentication(Authentication):
def __init__(self, credentials, host, request_uri, headers, response, content, http) -> None: ...
@@ -63,15 +90,15 @@ class GoogleLoginAuthentication(Authentication):
def request(self, method, request_uri, headers, content) -> None: ...
class FileCache:
- cache: Any
- safe: Any
+ cache: Incomplete
+ safe: Incomplete
def __init__(self, cache, safe=...) -> None: ...
def get(self, key): ...
def set(self, key, value) -> None: ...
def delete(self, key) -> None: ...
class Credentials:
- credentials: Any
+ credentials: Incomplete
def __init__(self) -> None: ...
def add(self, name, password, domain: str = "") -> None: ...
def clear(self) -> None: ...
@@ -84,7 +111,7 @@ class KeyCerts(Credentials):
class AllHosts: ...
class ProxyInfo:
- bypass_hosts: Any
+ bypass_hosts: Incomplete
def __init__(
self, proxy_type, proxy_host, proxy_port, proxy_rdns: bool = True, proxy_user=None, proxy_pass=None, proxy_headers=None
) -> None: ...
@@ -93,60 +120,65 @@ class ProxyInfo:
def applies_to(self, hostname): ...
def bypass_host(self, hostname): ...
+def proxy_info_from_environment(method: Literal["http", "https"] = "http") -> ProxyInfo | None: ...
+def proxy_info_from_url(url: str, method: Literal["http", "https"] = "http", noproxy: str | None = None) -> ProxyInfo: ...
+
class HTTPConnectionWithTimeout(http.client.HTTPConnection):
- proxy_info: Any
+ proxy_info: Incomplete
def __init__(self, host, port=None, timeout=None, proxy_info=None) -> None: ...
- sock: Any
+ sock: Incomplete
def connect(self) -> None: ...
class HTTPSConnectionWithTimeout(http.client.HTTPSConnection):
- disable_ssl_certificate_validation: Any
- ca_certs: Any
- proxy_info: Any
- key_file: Any
- cert_file: Any
- key_password: Any
+ disable_ssl_certificate_validation: bool
+ ca_certs: StrOrBytesPath | None
+ proxy_info: Incomplete
+ key_file: StrOrBytesPath | None
+ cert_file: StrOrBytesPath | None
+ key_password: _PasswordType | None
def __init__(
self,
- host,
- port=None,
- key_file=None,
- cert_file=None,
- timeout=None,
+ host: str,
+ port: int | None = None,
+ key_file: StrOrBytesPath | None = None,
+ cert_file: StrOrBytesPath | None = None,
+ timeout: float | None = None,
proxy_info=None,
- ca_certs=None,
+ ca_certs: StrOrBytesPath | None = None,
disable_ssl_certificate_validation: bool = False,
tls_maximum_version=None,
tls_minimum_version=None,
- key_password=None,
+ key_password: _PasswordType | None = None,
) -> None: ...
- sock: Any
+ sock: Incomplete
def connect(self) -> None: ...
+SCHEME_TO_CONNECTION: Final[dict[Literal["http", "https"], type[http.client.HTTPConnection]]]
+
class Http:
- proxy_info: Any
- ca_certs: Any
- disable_ssl_certificate_validation: Any
- tls_maximum_version: Any
- tls_minimum_version: Any
- connections: Any
- cache: Any
- credentials: Any
- certificates: Any
- authorizations: Any
+ proxy_info: Incomplete
+ ca_certs: Incomplete
+ disable_ssl_certificate_validation: bool
+ tls_maximum_version: Incomplete
+ tls_minimum_version: Incomplete
+ connections: Incomplete
+ cache: FileCache
+ credentials: Credentials
+ certificates: KeyCerts
+ authorizations: list[Authentication]
follow_redirects: bool
- redirect_codes: Any
- optimistic_concurrency_methods: Any
- safe_methods: Any
+ redirect_codes: frozenset[int]
+ optimistic_concurrency_methods: list[str]
+ safe_methods: list[str]
follow_all_redirects: bool
ignore_etag: bool
force_exception_to_status_code: bool
- timeout: Any
+ timeout: float | None
forward_authorization_headers: bool
def __init__(
self,
- cache=None,
- timeout=None,
+ cache: str | FileCache | None = None,
+ timeout: float | None = None,
proxy_info=...,
ca_certs=None,
disable_ssl_certificate_validation: bool = False,
@@ -159,13 +191,13 @@ class Http:
def clear_credentials(self) -> None: ...
def request(self, uri, method: str = "GET", body=None, headers=None, redirections=5, connection_type=None): ...
-class Response(dict[str, Any]):
+class Response(dict[str, str | _T]):
fromcache: bool
version: int
status: int
reason: str
- previous: Any
- def __init__(self, info) -> None: ...
+ previous: Response[_T] | None
+ def __init__(self, info: http.client.HTTPResponse | email.message.Message | dict[str, _T]) -> None: ...
@property
def dict(self) -> Self: ...
diff --git a/python/helpers/typeshed/stubs/httplib2/httplib2/auth.pyi b/python/helpers/typeshed/stubs/httplib2/httplib2/auth.pyi
index da11738e7ecc..9c7c94b8a832 100644
--- a/python/helpers/typeshed/stubs/httplib2/httplib2/auth.pyi
+++ b/python/helpers/typeshed/stubs/httplib2/httplib2/auth.pyi
@@ -1,16 +1,19 @@
-from typing import Any
+import re
+from _typeshed import Incomplete
+from collections.abc import Callable
+from typing import Final
-UNQUOTE_PAIRS: Any
-unquote: Any
-tchar: Any
-token: Any
-token68: Any
-quoted_string: Any
-auth_param_name: Any
-auth_param: Any
-params: Any
-scheme: Any
-challenge: Any
-authentication_info: Any
-www_authenticate: Any
-downcaseTokens: Any
+UNQUOTE_PAIRS: Final[re.Pattern[str]]
+unquote: Callable[..., str]
+tchar: Final[str]
+token: Incomplete # types from pyparsing library
+token68: Incomplete
+quoted_string: Incomplete
+auth_param_name: Incomplete
+auth_param: Incomplete
+params: Incomplete
+scheme: Incomplete
+challenge: Incomplete
+authentication_info: Incomplete
+www_authenticate: Incomplete
+downcaseTokens: Incomplete
diff --git a/python/helpers/typeshed/stubs/httplib2/httplib2/certs.pyi b/python/helpers/typeshed/stubs/httplib2/httplib2/certs.pyi
index c0a5ce2b9bce..197e1ced1d60 100644
--- a/python/helpers/typeshed/stubs/httplib2/httplib2/certs.pyi
+++ b/python/helpers/typeshed/stubs/httplib2/httplib2/certs.pyi
@@ -1,9 +1,10 @@
-from typing import Any
+from collections.abc import Callable
+from typing import Final
certifi_available: bool
-certifi_where: Any
+certifi_where: Callable[[], str] | None
custom_ca_locater_available: bool
-custom_ca_locater_where: Any
-BUILTIN_CA_CERTS: Any
+custom_ca_locater_where: Callable[..., str] | None
+BUILTIN_CA_CERTS: Final[str]
-def where(): ...
+def where() -> str: ...
diff --git a/python/helpers/typeshed/stubs/httplib2/httplib2/error.pyi b/python/helpers/typeshed/stubs/httplib2/httplib2/error.pyi
index 1287702e2196..fa94b45ba8c0 100644
--- a/python/helpers/typeshed/stubs/httplib2/httplib2/error.pyi
+++ b/python/helpers/typeshed/stubs/httplib2/httplib2/error.pyi
@@ -1,11 +1,15 @@
-from typing import Any
+from _typeshed import Incomplete
+
+from httplib2 import Response
class HttpLib2Error(Exception): ...
class HttpLib2ErrorWithResponse(HttpLib2Error):
- response: Any
- content: Any
- def __init__(self, desc, response, content) -> None: ...
+ response: Response | dict[str, Incomplete] | None
+ content: str | bytes | None
+ def __init__(
+ self, desc: str | None, response: Response | dict[str, Incomplete] | None, content: str | bytes | None
+ ) -> None: ...
class RedirectMissingLocation(HttpLib2ErrorWithResponse): ...
class RedirectLimit(HttpLib2ErrorWithResponse): ...
diff --git a/python/helpers/typeshed/stubs/httplib2/httplib2/iri2uri.pyi b/python/helpers/typeshed/stubs/httplib2/httplib2/iri2uri.pyi
index 7365d894ee2e..d935ed36f15e 100644
--- a/python/helpers/typeshed/stubs/httplib2/httplib2/iri2uri.pyi
+++ b/python/helpers/typeshed/stubs/httplib2/httplib2/iri2uri.pyi
@@ -1,12 +1,14 @@
-from typing import Any
+from typing import Final, TypeVar
-__author__: str
-__copyright__: str
-__contributors__: list[str]
-__version__: str
-__license__: str
+_T = TypeVar("_T")
-escape_range: Any
+__author__: Final[str]
+__copyright__: Final[str]
+__contributors__: Final[list[str]]
+__version__: Final[str]
+__license__: Final[str]
-def encode(c): ...
-def iri2uri(uri): ...
+escape_range: list[tuple[int, int]]
+
+def encode(c: str) -> str: ...
+def iri2uri(uri: _T) -> _T: ...
diff --git a/python/helpers/typeshed/stubs/httplib2/httplib2/socks.pyi b/python/helpers/typeshed/stubs/httplib2/httplib2/socks.pyi
index f5ef620f8d78..0f25f6034f22 100644
--- a/python/helpers/typeshed/stubs/httplib2/httplib2/socks.pyi
+++ b/python/helpers/typeshed/stubs/httplib2/httplib2/socks.pyi
@@ -1,9 +1,15 @@
import socket
+from _typeshed import Incomplete, ReadableBuffer
+from types import ModuleType
+from typing import Final, Literal
+from typing_extensions import TypeAlias
-PROXY_TYPE_SOCKS4: int
-PROXY_TYPE_SOCKS5: int
-PROXY_TYPE_HTTP: int
-PROXY_TYPE_HTTP_NO_TUNNEL: int
+_ProxyType: TypeAlias = Literal[1, 2, 3, 4]
+
+PROXY_TYPE_SOCKS4: Final[_ProxyType]
+PROXY_TYPE_SOCKS5: Final[_ProxyType]
+PROXY_TYPE_HTTP: Final[_ProxyType]
+PROXY_TYPE_HTTP_NO_TUNNEL: Final[_ProxyType]
class ProxyError(Exception): ...
class GeneralProxyError(ProxyError): ...
@@ -12,16 +18,36 @@ class Socks5Error(ProxyError): ...
class Socks4Error(ProxyError): ...
class HTTPError(ProxyError): ...
-def setdefaultproxy(proxytype=None, addr=None, port=None, rdns: bool = True, username=None, password=None) -> None: ...
-def wrapmodule(module) -> None: ...
+def setdefaultproxy(
+ proxytype: _ProxyType | None = None,
+ addr: str | None = None,
+ port: int | None = None,
+ rdns: bool = True,
+ username: str | None = None,
+ password: str | None = None,
+) -> None: ...
+def wrapmodule(module: ModuleType) -> None: ...
class socksocket(socket.socket):
- def __init__(self, family=..., type=..., proto: int = 0, _sock=None) -> None: ...
- def sendall(self, content, *args): ...
- def setproxy(
- self, proxytype=None, addr=None, port=None, rdns: bool = True, username=None, password=None, headers=None
+ def __init__(
+ self,
+ family: socket.AddressFamily | int = ...,
+ type: socket.SocketKind | int = ...,
+ proto: int = 0,
+ _sock: int | None = None,
) -> None: ...
- def getproxysockname(self): ...
- def getproxypeername(self): ...
- def getpeername(self): ...
- def connect(self, destpair) -> None: ...
+ def sendall(self, content: ReadableBuffer, flags: int = ...) -> None: ... # type: ignore[override]
+ def setproxy(
+ self,
+ proxytype: _ProxyType | None = None,
+ addr: str | None = None,
+ port: int | None = None,
+ rdns: bool = True,
+ username: str | None = None,
+ password: str | None = None,
+ headers: dict[str, str] | None = None,
+ ) -> None: ...
+ def getproxysockname(self) -> tuple[str | bytes, Incomplete] | None: ...
+ def getproxypeername(self) -> socket._RetAddress: ...
+ def getpeername(self) -> tuple[str | bytes, Incomplete] | None: ...
+ def connect(self, destpair: list[str | bytes | int] | tuple[str | bytes, int]) -> None: ... # type: ignore[override]
diff --git a/python/helpers/typeshed/stubs/hvac/hvac/adapters.pyi b/python/helpers/typeshed/stubs/hvac/hvac/adapters.pyi
index 5cc6e1ebf7b7..3bd1b3e0d981 100644
--- a/python/helpers/typeshed/stubs/hvac/hvac/adapters.pyi
+++ b/python/helpers/typeshed/stubs/hvac/hvac/adapters.pyi
@@ -1,6 +1,6 @@
from abc import ABCMeta, abstractmethod
from collections.abc import Mapping
-from typing import Any, Generic, TypeVar
+from typing import Any, Generic, TypeVar, type_check_only
from typing_extensions import Self
from requests import Response, Session
@@ -50,6 +50,7 @@ class Adapter(Generic[_R], metaclass=ABCMeta):
self, method, url: str, headers: Mapping[str, str] | None = None, raise_exception: bool = True, **kwargs: Any
) -> _R: ...
+@type_check_only
class _GenericRawAdapter(Adapter[_R]):
def get_login_token(self, response: _R) -> str: ...
def request(
diff --git a/python/helpers/typeshed/stubs/hvac/hvac/utils.pyi b/python/helpers/typeshed/stubs/hvac/hvac/utils.pyi
index 5eaf5803bc3e..0afd5dc74e86 100644
--- a/python/helpers/typeshed/stubs/hvac/hvac/utils.pyi
+++ b/python/helpers/typeshed/stubs/hvac/hvac/utils.pyi
@@ -1,7 +1,8 @@
from collections.abc import Callable, Iterable, Mapping
-from typing import Any, NoReturn, TypedDict, TypeVar
+from typing import Any, NoReturn, TypedDict, TypeVar, type_check_only
from typing_extensions import NotRequired
+@type_check_only
class _DeprecateProperty(TypedDict):
to_be_removed_in_version: str
client_property: str
diff --git a/python/helpers/typeshed/stubs/icalendar/icalendar/parser.pyi b/python/helpers/typeshed/stubs/icalendar/icalendar/parser.pyi
index 7064af19d664..e1aaea27f9e1 100644
--- a/python/helpers/typeshed/stubs/icalendar/icalendar/parser.pyi
+++ b/python/helpers/typeshed/stubs/icalendar/icalendar/parser.pyi
@@ -81,7 +81,7 @@ def unescape_list_or_string(val: str) -> str: ...
class Contentline(str):
strict: bool
- def __new__(cls, value: str | bytes, strict: bool = False, encoding: str = ...) -> Self: ...
+ def __new__(cls, value: str | bytes, strict: bool = False, encoding: str = "utf-8") -> Self: ...
@classmethod
def from_parts(cls, name: ICAL_TYPE, params: Parameters, values, sorted: bool = True) -> Self: ...
def parts(self) -> tuple[str, Parameters, str]: ...
diff --git a/python/helpers/typeshed/stubs/icalendar/icalendar/parser_tools.pyi b/python/helpers/typeshed/stubs/icalendar/icalendar/parser_tools.pyi
index df1c2ada38d3..6456cc836306 100644
--- a/python/helpers/typeshed/stubs/icalendar/icalendar/parser_tools.pyi
+++ b/python/helpers/typeshed/stubs/icalendar/icalendar/parser_tools.pyi
@@ -12,10 +12,10 @@ ICAL_TYPE: TypeAlias = str | bytes
def from_unicode(value: ICAL_TYPE, encoding: str = "utf-8") -> bytes: ...
def to_unicode(value: ICAL_TYPE, encoding: str = "utf-8-sig") -> str: ...
@overload
-def data_encode(data: ICAL_TYPE, encoding: str = ...) -> bytes: ...
+def data_encode(data: ICAL_TYPE, encoding: str = "utf-8") -> bytes: ...
@overload
-def data_encode(data: dict[Any, Any], encoding: str = ...) -> dict[Any, Any]: ...
+def data_encode(data: dict[Any, Any], encoding: str = "utf-8") -> dict[Any, Any]: ...
@overload
-def data_encode(data: list[Any] | tuple[Any, ...], encoding: str = ...) -> list[Any]: ...
+def data_encode(data: list[Any] | tuple[Any, ...], encoding: str = "utf-8") -> list[Any]: ...
@overload
-def data_encode(data: _T, encoding: str = ...) -> _T: ...
+def data_encode(data: _T, encoding: str = "utf-8") -> _T: ...
diff --git a/python/helpers/typeshed/stubs/icalendar/icalendar/prop.pyi b/python/helpers/typeshed/stubs/icalendar/icalendar/prop.pyi
index 7ac00bcd7c51..a3e0c389f32d 100644
--- a/python/helpers/typeshed/stubs/icalendar/icalendar/prop.pyi
+++ b/python/helpers/typeshed/stubs/icalendar/icalendar/prop.pyi
@@ -3,7 +3,7 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, SupportsKeysAndGetIt
from collections.abc import Iterable, Iterator
from enum import Enum
from re import Pattern
-from typing import Any, ClassVar, Final, Literal, Protocol, SupportsIndex, overload
+from typing import Any, ClassVar, Final, Literal, Protocol, SupportsIndex, overload, type_check_only
from typing_extensions import Self, TypeAlias
from .caselessdict import CaselessDict
@@ -47,6 +47,7 @@ _PropType: TypeAlias = type[Any] # any of the v* classes in this file
_PeriodTuple: TypeAlias = tuple[datetime.datetime, datetime.datetime | datetime.timedelta]
_AnyTimeType: TypeAlias = datetime.datetime | datetime.date | datetime.timedelta | datetime.time | _PeriodTuple
+@type_check_only
class _vType(Protocol):
def to_ical(self) -> bytes | str: ...
diff --git a/python/helpers/typeshed/stubs/inifile/inifile.pyi b/python/helpers/typeshed/stubs/inifile/inifile.pyi
index 8dd54936e82f..c64a3168d983 100644
--- a/python/helpers/typeshed/stubs/inifile/inifile.pyi
+++ b/python/helpers/typeshed/stubs/inifile/inifile.pyi
@@ -69,7 +69,9 @@ class IniData(MutableMapping[str, str]):
def to_dict(self) -> dict[str, str]: ...
def __len__(self) -> int: ...
@overload
- def get(self, name: str) -> str | None: ...
+ def get(self, name: str, default: None = None) -> str | None: ...
+ @overload
+ def get(self, name: str, default: str) -> str: ...
@overload
def get(self, name: str, default: _T) -> str | _T: ...
@overload
diff --git a/python/helpers/typeshed/stubs/jmespath/jmespath/ast.pyi b/python/helpers/typeshed/stubs/jmespath/jmespath/ast.pyi
index 76651892e03d..d8c75d0abdde 100644
--- a/python/helpers/typeshed/stubs/jmespath/jmespath/ast.pyi
+++ b/python/helpers/typeshed/stubs/jmespath/jmespath/ast.pyi
@@ -1,4 +1,4 @@
-from typing import Literal, TypedDict
+from typing import Literal, TypedDict, type_check_only
from typing_extensions import NotRequired, TypeAlias
_NodeType: TypeAlias = Literal[
@@ -26,6 +26,7 @@ _NodeType: TypeAlias = Literal[
"value_projection",
]
+@type_check_only
class _ASTNode(TypedDict):
type: _NodeType
children: list[_ASTNode]
@@ -52,4 +53,4 @@ def pipe(left: _ASTNode, right: _ASTNode) -> _ASTNode: ...
def projection(left: _ASTNode, right: _ASTNode) -> _ASTNode: ...
def subexpression(children: list[_ASTNode]) -> _ASTNode: ...
def slice(start: _ASTNode, end: _ASTNode, step: _ASTNode) -> _ASTNode: ...
-def value_projection(left, right) -> _ASTNode: ...
+def value_projection(left: _ASTNode, right: _ASTNode) -> _ASTNode: ...
diff --git a/python/helpers/typeshed/stubs/jmespath/jmespath/exceptions.pyi b/python/helpers/typeshed/stubs/jmespath/jmespath/exceptions.pyi
index 13500a8e0b58..45a6c4ec514e 100644
--- a/python/helpers/typeshed/stubs/jmespath/jmespath/exceptions.pyi
+++ b/python/helpers/typeshed/stubs/jmespath/jmespath/exceptions.pyi
@@ -30,7 +30,7 @@ class ArityError(ParseError):
expected_arity: int
actual_arity: int
function_name: str
- def __init__(self, expected, actual, name) -> None: ...
+ def __init__(self, expected: int, actual: int, name: str) -> None: ...
class VariadictArityError(ArityError): ...
diff --git a/python/helpers/typeshed/stubs/jmespath/jmespath/functions.pyi b/python/helpers/typeshed/stubs/jmespath/jmespath/functions.pyi
index f9c212e4823e..4d657f4c49ea 100644
--- a/python/helpers/typeshed/stubs/jmespath/jmespath/functions.pyi
+++ b/python/helpers/typeshed/stubs/jmespath/jmespath/functions.pyi
@@ -1,10 +1,11 @@
from collections.abc import Callable, Iterable
-from typing import Any, TypedDict, TypeVar
+from typing import Any, TypedDict, TypeVar, type_check_only
from typing_extensions import NotRequired
TYPES_MAP: dict[str, str]
REVERSE_TYPES_MAP: dict[str, tuple[str, ...]]
+@type_check_only
class _Signature(TypedDict):
types: list[str]
variadic: NotRequired[bool]
diff --git a/python/helpers/typeshed/stubs/jmespath/jmespath/lexer.pyi b/python/helpers/typeshed/stubs/jmespath/jmespath/lexer.pyi
index ac89d2e1e667..0e26ebc18888 100644
--- a/python/helpers/typeshed/stubs/jmespath/jmespath/lexer.pyi
+++ b/python/helpers/typeshed/stubs/jmespath/jmespath/lexer.pyi
@@ -1,8 +1,9 @@
from collections.abc import Iterator
-from typing import ClassVar, TypedDict
+from typing import ClassVar, TypedDict, type_check_only
from jmespath.exceptions import EmptyExpressionError as EmptyExpressionError, LexerError as LexerError
+@type_check_only
class _LexerTokenizeResult(TypedDict):
type: str
value: str
diff --git a/python/helpers/typeshed/stubs/jmespath/jmespath/visitor.pyi b/python/helpers/typeshed/stubs/jmespath/jmespath/visitor.pyi
index 64125ddd176f..5789b39b018e 100644
--- a/python/helpers/typeshed/stubs/jmespath/jmespath/visitor.pyi
+++ b/python/helpers/typeshed/stubs/jmespath/jmespath/visitor.pyi
@@ -1,6 +1,6 @@
from _typeshed import Unused
from collections.abc import Callable, MutableMapping
-from typing import Any, ClassVar, NoReturn, TypedDict, TypeVar
+from typing import Any, ClassVar, NoReturn, TypedDict, TypeVar, type_check_only
from jmespath.functions import Functions
@@ -17,13 +17,17 @@ class _Expression:
expression: str
interpreter: Visitor
def __init__(self, expression: str, interpreter: Visitor) -> None: ...
- def visit(self, node: _TreeNode, *args, **kwargs) -> Any: ...
+ # `args` and `kwargs` are passed to the appropriate `visit_*` method.
+ def visit(self, node: _TreeNode, *args: Any, **kwargs: Any) -> Any: ...
class Visitor:
def __init__(self) -> None: ...
- def visit(self, node: _TreeNode, *args, **kwargs) -> Any: ...
+ # `args` and `kwargs` are passed to the appropriate `visit_*` method.
+ # Its return value is returned from visit.
+ def visit(self, node: _TreeNode, *args: Any, **kwargs: Any) -> Any: ...
def default_visit(self, node: _TreeNode, *args: Unused, **kwargs: Unused) -> NoReturn: ...
+@type_check_only
class _TreeNode(TypedDict):
type: str
value: Any
@@ -59,4 +63,4 @@ class TreeInterpreter(Visitor):
class GraphvizVisitor(Visitor):
def __init__(self) -> None: ...
- def visit(self, node: _TreeNode, *args, **kwargs) -> str: ...
+ def visit(self, node: _TreeNode, *args: Unused, **kwargs: Unused) -> str: ...
diff --git a/python/helpers/typeshed/stubs/jsonnet/METADATA.toml b/python/helpers/typeshed/stubs/jsonnet/METADATA.toml
new file mode 100644
index 000000000000..ee234e839059
--- /dev/null
+++ b/python/helpers/typeshed/stubs/jsonnet/METADATA.toml
@@ -0,0 +1,2 @@
+version = "0.21.*"
+upstream_repository = "https://github.com/google/jsonnet"
diff --git a/python/helpers/typeshed/stubs/jsonnet/_jsonnet.pyi b/python/helpers/typeshed/stubs/jsonnet/_jsonnet.pyi
new file mode 100644
index 000000000000..cad86c28b9d1
--- /dev/null
+++ b/python/helpers/typeshed/stubs/jsonnet/_jsonnet.pyi
@@ -0,0 +1,35 @@
+from collections.abc import Callable
+from typing import Final
+
+# Gleaned from https://github.com/google/jsonnet/blob/master/python/_jsonnet.c
+version: Final[str]
+
+def evaluate_file(
+ filename: str,
+ jpathdir: str | list[str] | None = ...,
+ max_stack: int = 500,
+ gc_min_objects: int = 1000,
+ gc_growth_trigger: float = 2,
+ ext_vars: dict[str, str] | None = ...,
+ ext_codes: dict[str, str] | None = ...,
+ tla_vars: dict[str, str] | None = ...,
+ tla_codes: dict[str, str] | None = ...,
+ max_trace: int = 20,
+ import_callback: Callable[[str, str], tuple[str, object | None]] = ...,
+ native_callbacks: dict[str, tuple[tuple[str, ...], Callable[..., object]]] | None = ...,
+) -> str: ...
+def evaluate_snippet(
+ filename: str,
+ src: str,
+ jpathdir: str | list[str] | None = ...,
+ max_stack: int = 500,
+ gc_min_objects: int = 1000,
+ gc_growth_trigger: float = 2,
+ ext_vars: dict[str, str] | None = ...,
+ ext_codes: dict[str, str] | None = ...,
+ tla_vars: dict[str, str] | None = ...,
+ tla_codes: dict[str, str] | None = ...,
+ max_trace: int = 20,
+ import_callback: Callable[[str, str], tuple[str, object | None]] = ...,
+ native_callbacks: dict[str, tuple[tuple[str, ...], Callable[..., object]]] | None = ...,
+) -> str: ...
diff --git a/python/helpers/typeshed/stubs/jsonschema/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/jsonschema/@tests/stubtest_allowlist.txt
new file mode 100644
index 000000000000..b140a9c3bf1e
--- /dev/null
+++ b/python/helpers/typeshed/stubs/jsonschema/@tests/stubtest_allowlist.txt
@@ -0,0 +1,93 @@
+# Testing modules are not included in type stubs:
+jsonschema.tests.*
+jsonschema.benchmarks.*
+
+# When importing this module, SystemExit: 2 is thrown:
+jsonschema.__main__
+
+# Autogenerated methods using @attr.* decorators:
+jsonschema.Draft201909Validator.__attrs_attrs__
+jsonschema.Draft201909Validator.__attrs_own_setattr__
+jsonschema.Draft201909Validator.__attrs_post_init__
+jsonschema.Draft201909Validator.__match_args__
+jsonschema.Draft202012Validator.__attrs_attrs__
+jsonschema.Draft202012Validator.__attrs_own_setattr__
+jsonschema.Draft202012Validator.__attrs_post_init__
+jsonschema.Draft202012Validator.__match_args__
+jsonschema.Draft3Validator.__attrs_attrs__
+jsonschema.Draft3Validator.__attrs_own_setattr__
+jsonschema.Draft3Validator.__attrs_post_init__
+jsonschema.Draft3Validator.__match_args__
+jsonschema.Draft4Validator.__attrs_attrs__
+jsonschema.Draft4Validator.__attrs_own_setattr__
+jsonschema.Draft4Validator.__attrs_post_init__
+jsonschema.Draft4Validator.__match_args__
+jsonschema.Draft6Validator.__attrs_attrs__
+jsonschema.Draft6Validator.__attrs_own_setattr__
+jsonschema.Draft6Validator.__attrs_post_init__
+jsonschema.Draft6Validator.__match_args__
+jsonschema.Draft7Validator.__attrs_attrs__
+jsonschema.Draft7Validator.__attrs_own_setattr__
+jsonschema.Draft7Validator.__attrs_post_init__
+jsonschema.Draft7Validator.__match_args__
+jsonschema.RefResolutionError.__attrs_attrs__
+jsonschema.RefResolutionError.__match_args__
+jsonschema.TypeChecker.__attrs_attrs__
+jsonschema.TypeChecker.__match_args__
+jsonschema._types.TypeChecker.__attrs_attrs__
+jsonschema._types.TypeChecker.__match_args__
+jsonschema.cli._Outputter.__attrs_attrs__
+jsonschema.cli._Outputter.__attrs_own_setattr__
+jsonschema.cli._Outputter.__match_args__
+jsonschema.cli._PlainFormatter.__attrs_attrs__
+jsonschema.cli._PlainFormatter.__attrs_own_setattr__
+jsonschema.cli._PlainFormatter.__match_args__
+jsonschema.cli._PrettyFormatter.__attrs_attrs__
+jsonschema.cli._PrettyFormatter.__attrs_own_setattr__
+jsonschema.cli._PrettyFormatter.__match_args__
+jsonschema.exceptions.RefResolutionError.__attrs_attrs__
+jsonschema.exceptions.RefResolutionError.__match_args__
+jsonschema.validators.Draft201909Validator.__attrs_attrs__
+jsonschema.validators.Draft201909Validator.__attrs_own_setattr__
+jsonschema.validators.Draft201909Validator.__attrs_post_init__
+jsonschema.validators.Draft201909Validator.__match_args__
+jsonschema.validators.Draft202012Validator.__attrs_attrs__
+jsonschema.validators.Draft202012Validator.__attrs_own_setattr__
+jsonschema.validators.Draft202012Validator.__attrs_post_init__
+jsonschema.validators.Draft202012Validator.__match_args__
+jsonschema.validators.Draft3Validator.__attrs_attrs__
+jsonschema.validators.Draft3Validator.__attrs_own_setattr__
+jsonschema.validators.Draft3Validator.__attrs_post_init__
+jsonschema.validators.Draft3Validator.__match_args__
+jsonschema.validators.Draft4Validator.__attrs_attrs__
+jsonschema.validators.Draft4Validator.__attrs_own_setattr__
+jsonschema.validators.Draft4Validator.__attrs_post_init__
+jsonschema.validators.Draft4Validator.__match_args__
+jsonschema.validators.Draft6Validator.__attrs_attrs__
+jsonschema.validators.Draft6Validator.__attrs_own_setattr__
+jsonschema.validators.Draft6Validator.__attrs_post_init__
+jsonschema.validators.Draft6Validator.__match_args__
+jsonschema.validators.Draft7Validator.__attrs_attrs__
+jsonschema.validators.Draft7Validator.__attrs_own_setattr__
+jsonschema.validators.Draft7Validator.__attrs_post_init__
+jsonschema.validators.Draft7Validator.__match_args__
+# >= Python 3.13
+jsonschema.Draft201909Validator.__replace__
+jsonschema.Draft202012Validator.__replace__
+jsonschema.Draft3Validator.__replace__
+jsonschema.Draft4Validator.__replace__
+jsonschema.Draft6Validator.__replace__
+jsonschema.Draft7Validator.__replace__
+jsonschema.RefResolutionError.__replace__
+jsonschema.TypeChecker.__replace__
+jsonschema._types.TypeChecker.__replace__
+jsonschema.cli._Outputter.__replace__
+jsonschema.cli._PlainFormatter.__replace__
+jsonschema.cli._PrettyFormatter.__replace__
+jsonschema.exceptions.RefResolutionError.__replace__
+jsonschema.validators.Draft201909Validator.__replace__
+jsonschema.validators.Draft202012Validator.__replace__
+jsonschema.validators.Draft3Validator.__replace__
+jsonschema.validators.Draft4Validator.__replace__
+jsonschema.validators.Draft6Validator.__replace__
+jsonschema.validators.Draft7Validator.__replace__
diff --git a/python/helpers/typeshed/stubs/jsonschema/METADATA.toml b/python/helpers/typeshed/stubs/jsonschema/METADATA.toml
index 1b90ab4f480d..8a678272753a 100644
--- a/python/helpers/typeshed/stubs/jsonschema/METADATA.toml
+++ b/python/helpers/typeshed/stubs/jsonschema/METADATA.toml
@@ -1,8 +1,6 @@
-version = "4.24.*"
+version = "~=4.25.1"
upstream_repository = "https://github.com/python-jsonschema/jsonschema"
requires = ["referencing"]
-partial_stub = true
[tool.stubtest]
-ignore_missing_stub = true
extras = ["format"]
diff --git a/python/helpers/typeshed/stubs/jsonschema/jsonschema/__init__.pyi b/python/helpers/typeshed/stubs/jsonschema/jsonschema/__init__.pyi
index dcb925bc6032..61cf92fd5d18 100644
--- a/python/helpers/typeshed/stubs/jsonschema/jsonschema/__init__.pyi
+++ b/python/helpers/typeshed/stubs/jsonschema/jsonschema/__init__.pyi
@@ -26,3 +26,17 @@ from jsonschema.validators import (
RefResolver as RefResolver,
validate as validate,
)
+
+__all__ = [
+ "Draft3Validator",
+ "Draft4Validator",
+ "Draft6Validator",
+ "Draft7Validator",
+ "Draft201909Validator",
+ "Draft202012Validator",
+ "FormatChecker",
+ "SchemaError",
+ "TypeChecker",
+ "ValidationError",
+ "validate",
+]
diff --git a/python/helpers/typeshed/stubs/jsonschema/jsonschema/_types.pyi b/python/helpers/typeshed/stubs/jsonschema/jsonschema/_types.pyi
index 4c248ab95da4..a4fa843f195c 100644
--- a/python/helpers/typeshed/stubs/jsonschema/jsonschema/_types.pyi
+++ b/python/helpers/typeshed/stubs/jsonschema/jsonschema/_types.pyi
@@ -1,15 +1,18 @@
+from _typeshed import Unused
from collections.abc import Callable, Iterable, Mapping
+from typing import Literal
-def is_array(checker, instance) -> bool: ...
-def is_bool(checker, instance) -> bool: ...
-def is_integer(checker, instance) -> bool: ...
-def is_null(checker, instance) -> bool: ...
-def is_number(checker, instance) -> bool: ...
-def is_object(checker, instance) -> bool: ...
-def is_string(checker, instance) -> bool: ...
-def is_any(checker, instance) -> bool: ...
+def is_array(checker: Unused, instance: object) -> bool: ...
+def is_bool(checker: Unused, instance: object) -> bool: ...
+def is_integer(checker: Unused, instance: object) -> bool: ...
+def is_null(checker: Unused, instance: object) -> bool: ...
+def is_number(checker: Unused, instance: object) -> bool: ...
+def is_object(checker: Unused, instance: object) -> bool: ...
+def is_string(checker: Unused, instance: object) -> bool: ...
+def is_any(checker: Unused, instance: Unused) -> Literal[True]: ...
class TypeChecker:
+ __slots__ = ("_type_checkers", "__weakref__")
def __init__(self, type_checkers: Mapping[str, Callable[[object], bool]] = ...) -> None: ...
def is_type(self, instance, type: str) -> bool: ...
def redefine(self, type: str, fn: Callable[..., bool]) -> TypeChecker: ...
diff --git a/python/helpers/typeshed/stubs/jsonschema/jsonschema/_utils.pyi b/python/helpers/typeshed/stubs/jsonschema/jsonschema/_utils.pyi
index 90c26404e6e6..0ddd9c689191 100644
--- a/python/helpers/typeshed/stubs/jsonschema/jsonschema/_utils.pyi
+++ b/python/helpers/typeshed/stubs/jsonschema/jsonschema/_utils.pyi
@@ -1,5 +1,8 @@
-from _typeshed import Incomplete, SupportsKeysAndGetItem, SupportsNext
-from collections.abc import Generator, Iterable, Iterator, Mapping, MutableMapping, Sized
+from _typeshed import Incomplete, SupportsKeysAndGetItem, SupportsNext, SupportsRichComparison
+from collections.abc import Generator, Iterable, Iterator, Mapping, MutableMapping
+from typing import Literal, TypeVar, overload
+
+_T = TypeVar("_T")
class URIDict(MutableMapping[str, str]):
def normalize(self, uri: str) -> str: ...
@@ -13,15 +16,16 @@ class URIDict(MutableMapping[str, str]):
class Unset: ...
-def format_as_index(container: str, indices) -> str: ...
-def find_additional_properties(
- instance: Iterable[Incomplete], schema: Mapping[Incomplete, Incomplete]
-) -> Generator[Incomplete, None, None]: ...
-def extras_msg(extras: Iterable[Incomplete] | Sized) -> str: ...
-def ensure_list(thing) -> list[Incomplete]: ...
+def format_as_index(container: str, indices: Iterable[Incomplete] | None) -> str: ...
+def find_additional_properties(instance: Iterable[str], schema: Mapping[str, Iterable[str]]) -> Generator[str]: ...
+def extras_msg(extras: Iterable[object]) -> tuple[str, Literal["was", "were"]]: ... # elements are passed to the repr() function
+@overload
+def ensure_list(thing: str) -> list[str]: ...
+@overload
+def ensure_list(thing: _T) -> _T: ...
def equal(one, two) -> bool: ...
def unbool(element, true=..., false=...): ...
-def uniq(container) -> bool: ...
+def uniq(container: Iterable[SupportsRichComparison]) -> bool: ...
def find_evaluated_item_indexes_by_schema(validator, instance, schema) -> list[Incomplete]: ...
def find_evaluated_property_keys_by_schema(validator, instance, schema) -> list[Incomplete]: ...
def is_valid(errs_it: SupportsNext[object]) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/jsonschema/jsonschema/cli.pyi b/python/helpers/typeshed/stubs/jsonschema/jsonschema/cli.pyi
index 01ef4137d8ed..3d640e236fb6 100644
--- a/python/helpers/typeshed/stubs/jsonschema/jsonschema/cli.pyi
+++ b/python/helpers/typeshed/stubs/jsonschema/jsonschema/cli.pyi
@@ -1,32 +1,65 @@
-from _typeshed import Incomplete
+import argparse
+from _typeshed import ExcInfo, FileDescriptorOrPath, Incomplete, OptExcInfo, SupportsWrite
+from collections.abc import Mapping, Sequence
+from typing import Any
+from typing_extensions import Self, deprecated
+@deprecated("The jsonschema CLI is deprecated and will be removed in a future version. Please use check-jsonschema instead.")
class _CannotLoadFile(Exception): ...
+@deprecated("The jsonschema CLI is deprecated and will be removed in a future version. Please use check-jsonschema instead.")
class _Outputter:
- def __init__(self, formatter, stdout, stderr): ...
+ __slots__ = ("_formatter", "_stdout", "_stderr", "__weakref__")
+ _formatter: _PlainFormatter | _PrettyFormatter
+ _stdout: SupportsWrite[str]
+ _stderr: SupportsWrite[str]
+
+ def __init__(
+ self, formatter: _PlainFormatter | _PrettyFormatter, stdout: SupportsWrite[str], stderr: SupportsWrite[str]
+ ) -> None: ...
@classmethod
- def from_arguments(cls, arguments, stdout, stderr): ...
- def load(self, path): ...
- def filenotfound_error(self, **kwargs) -> None: ...
- def parsing_error(self, **kwargs) -> None: ...
- def validation_error(self, **kwargs) -> None: ...
- def validation_success(self, **kwargs) -> None: ...
+ def from_arguments(
+ cls, arguments: Mapping[str, Incomplete], stdout: SupportsWrite[str], stderr: SupportsWrite[str]
+ ) -> Self: ...
+ def load(self, path: FileDescriptorOrPath) -> Any: ... # result of json.load()
+ def filenotfound_error(self, *, path: FileDescriptorOrPath, exc_info: OptExcInfo) -> None: ...
+ def parsing_error(self, *, path: FileDescriptorOrPath, exc_info: ExcInfo) -> None: ...
+ def validation_error(self, *, instance_path: FileDescriptorOrPath, error: BaseException) -> None: ...
+ def validation_success(self, *, instance_path: FileDescriptorOrPath) -> None: ...
+@deprecated("The jsonschema CLI is deprecated and will be removed in a future version. Please use check-jsonschema instead.")
class _PrettyFormatter:
- def filenotfound_error(self, path, exc_info): ...
- def parsing_error(self, path, exc_info): ...
- def validation_error(self, instance_path, error): ...
- def validation_success(self, instance_path): ...
+ __slots__ = ("__weakref__",)
+ _ERROR_MSG: str
+ _SUCCESS_MSG: str
+ def __init__(self) -> None: ...
+ def filenotfound_error(self, path: FileDescriptorOrPath, exc_info: OptExcInfo) -> str: ...
+ def parsing_error(self, path: FileDescriptorOrPath, exc_info: ExcInfo) -> str: ...
+ def validation_error(self, instance_path: FileDescriptorOrPath, error: BaseException) -> str: ...
+ def validation_success(self, instance_path: FileDescriptorOrPath) -> str: ...
+
+@deprecated("The jsonschema CLI is deprecated and will be removed in a future version. Please use check-jsonschema instead.")
class _PlainFormatter:
- def __init__(self, error_format): ...
- def filenotfound_error(self, path, exc_info): ...
- def parsing_error(self, path, exc_info): ...
- def validation_error(self, instance_path, error): ...
- def validation_success(self, instance_path): ...
+ __slots__ = ("_error_format", "__weakref__")
+ _error_format: str
-parser: Incomplete
+ def __init__(self, error_format: str) -> None: ...
+ def filenotfound_error(self, path: FileDescriptorOrPath, exc_info: OptExcInfo) -> str: ...
+ def parsing_error(self, path: FileDescriptorOrPath, exc_info: ExcInfo) -> str: ...
+ def validation_error(self, instance_path: FileDescriptorOrPath, error: BaseException) -> str: ...
+ def validation_success(self, instance_path: FileDescriptorOrPath) -> str: ...
-def parse_args(args): ...
-def main(args=...) -> None: ...
-def run(arguments, stdout=..., stderr=..., stdin=...): ...
+parser: argparse.ArgumentParser
+
+@deprecated("The jsonschema CLI is deprecated and will be removed in a future version. Please use check-jsonschema instead.")
+def parse_args(args: Sequence[str] | None) -> dict[str, Any]: ... # result of vars(argparse.Namespace())
+@deprecated("The jsonschema CLI is deprecated and will be removed in a future version. Please use check-jsonschema instead.")
+def main(args: Sequence[str] = ...) -> None: ...
+@deprecated("The jsonschema CLI is deprecated and will be removed in a future version. Please use check-jsonschema instead.")
+def run(
+ arguments: Mapping[str, Incomplete],
+ stdout: SupportsWrite[str] = ...,
+ stderr: SupportsWrite[str] = ...,
+ stdin: SupportsWrite[str] = ...,
+) -> int: ...
diff --git a/python/helpers/typeshed/stubs/jsonschema/jsonschema/protocols.pyi b/python/helpers/typeshed/stubs/jsonschema/jsonschema/protocols.pyi
index 1bde7a46cff9..8f523c1ca4a6 100644
--- a/python/helpers/typeshed/stubs/jsonschema/jsonschema/protocols.pyi
+++ b/python/helpers/typeshed/stubs/jsonschema/jsonschema/protocols.pyi
@@ -1,12 +1,12 @@
from _typeshed import Incomplete
from collections.abc import Iterator, Mapping, Sequence
-from typing import ClassVar, Protocol
+from typing import Any, ClassVar, Protocol
from typing_extensions import TypeAlias
+import referencing.jsonschema
from jsonschema._format import FormatChecker
from jsonschema._types import TypeChecker
from jsonschema.exceptions import ValidationError
-from jsonschema.validators import RefResolver
_JsonParameter: TypeAlias = str | int | float | bool | None | Mapping[str, _JsonParameter] | Sequence[_JsonParameter]
@@ -15,12 +15,14 @@ class Validator(Protocol):
VALIDATORS: ClassVar[dict[Incomplete, Incomplete]]
TYPE_CHECKER: ClassVar[TypeChecker]
FORMAT_CHECKER: ClassVar[FormatChecker]
- schema: dict[Incomplete, Incomplete] | bool
+ schema: referencing.jsonschema.Schema
def __init__(
self,
- schema: dict[Incomplete, Incomplete] | bool,
- resolver: RefResolver | None = None,
+ schema: Mapping[Incomplete, Incomplete] | bool,
+ resolver: Any = None, # deprecated
format_checker: FormatChecker | None = None,
+ *,
+ registry: referencing.jsonschema.SchemaRegistry = ...,
) -> None: ...
@classmethod
def check_schema(cls, schema: dict[Incomplete, Incomplete]) -> None: ...
diff --git a/python/helpers/typeshed/stubs/jsonschema/jsonschema/validators.pyi b/python/helpers/typeshed/stubs/jsonschema/jsonschema/validators.pyi
index cd71f1a43b79..4e93434f1d65 100644
--- a/python/helpers/typeshed/stubs/jsonschema/jsonschema/validators.pyi
+++ b/python/helpers/typeshed/stubs/jsonschema/jsonschema/validators.pyi
@@ -1,7 +1,7 @@
from _typeshed import Incomplete, SupportsKeysAndGetItem
from collections.abc import Callable, Generator, Iterable, Iterator, Mapping
from contextlib import contextmanager
-from typing import Any, ClassVar, overload
+from typing import Any, ClassVar, overload, type_check_only
from typing_extensions import TypeAlias, deprecated
from referencing.jsonschema import Schema, SchemaRegistry
@@ -20,7 +20,8 @@ _ValidatorCallback: TypeAlias = Callable[[Any, Any, _JsonValue, _JsonObject], It
# This class does not exist at runtime. Compatible classes are created at
# runtime by create().
-class _Validator:
+@type_check_only
+class _Validator(Validator):
VALIDATORS: ClassVar[dict[Incomplete, Incomplete]]
META_SCHEMA: ClassVar[dict[Incomplete, Incomplete]]
TYPE_CHECKER: ClassVar[Incomplete]
@@ -31,12 +32,11 @@ class _Validator:
format_checker: FormatChecker | None
def __init__(
self,
- schema: Schema,
- resolver=None,
+ schema: Mapping[Incomplete, Incomplete] | bool,
+ resolver: Any = None, # deprecated
format_checker: FormatChecker | None = None,
*,
registry: SchemaRegistry = ...,
- _resolver=None,
) -> None: ...
@classmethod
def check_schema(cls, schema: Schema, format_checker: FormatChecker | Unset = ...) -> None: ...
@@ -54,7 +54,7 @@ class _Validator:
def iter_errors(self, instance, _schema: Schema | None) -> Generator[Incomplete]: ...
def descend(
self, instance, schema: Schema, path: Incomplete | None = ..., schema_path: Incomplete | None = ..., resolver=None
- ) -> Generator[Incomplete, None, None]: ...
+ ) -> Generator[Incomplete]: ...
def validate(self, *args, **kwargs) -> None: ...
def is_type(self, instance, type) -> bool: ...
@overload
@@ -63,7 +63,7 @@ class _Validator:
@deprecated("Passing a schema to Validator.is_valid is deprecated and will be removed in a future release.")
def is_valid(self, instance, _schema: Schema | None) -> bool: ...
-def validates(version: str) -> Callable[..., Incomplete]: ...
+def validates(version: str) -> Callable[[_Validator], _Validator]: ...
def create(
meta_schema: Schema,
validators: Mapping[str, _ValidatorCallback] | tuple[()] = (),
@@ -76,12 +76,23 @@ def create(
def extend(validator, validators=(), version=None, type_checker=None, format_checker=None): ...
# At runtime these are fields that are assigned the return values of create() calls.
-class Draft3Validator(_Validator): ...
-class Draft4Validator(_Validator): ...
-class Draft6Validator(_Validator): ...
-class Draft7Validator(_Validator): ...
-class Draft201909Validator(_Validator): ...
-class Draft202012Validator(_Validator): ...
+class Draft3Validator(_Validator):
+ __slots__ = ("_validators", "schema", "_ref_resolver", "format_checker", "_registry", "_resolver", "__weakref__")
+
+class Draft4Validator(_Validator):
+ __slots__ = ("_validators", "schema", "_ref_resolver", "format_checker", "_registry", "_resolver", "__weakref__")
+
+class Draft6Validator(_Validator):
+ __slots__ = ("_validators", "schema", "_ref_resolver", "format_checker", "_registry", "_resolver", "__weakref__")
+
+class Draft7Validator(_Validator):
+ __slots__ = ("_validators", "schema", "_ref_resolver", "format_checker", "_registry", "_resolver", "__weakref__")
+
+class Draft201909Validator(_Validator):
+ __slots__ = ("_validators", "schema", "_ref_resolver", "format_checker", "_registry", "_resolver", "__weakref__")
+
+class Draft202012Validator(_Validator):
+ __slots__ = ("_validators", "schema", "_ref_resolver", "format_checker", "_registry", "_resolver", "__weakref__")
_Handler: TypeAlias = Callable[[str], Incomplete]
diff --git a/python/helpers/typeshed/stubs/keyboard/METADATA.toml b/python/helpers/typeshed/stubs/keyboard/METADATA.toml
index c9280f44feac..6a2335fd9e45 100644
--- a/python/helpers/typeshed/stubs/keyboard/METADATA.toml
+++ b/python/helpers/typeshed/stubs/keyboard/METADATA.toml
@@ -6,4 +6,4 @@ upstream_repository = "https://github.com/boppreh/keyboard"
# It's only by possible mouse buttons and event literal types.
# As well as returning a tuple of int/long from keyboard.mouse.get_position
# The "mouse" module is obsoleted by the "mouse" package.
-# platforms =
+# ci_platforms = ["linux"]
diff --git a/python/helpers/typeshed/stubs/ldap3/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/ldap3/@tests/stubtest_allowlist.txt
new file mode 100644
index 000000000000..c1fe27b112fb
--- /dev/null
+++ b/python/helpers/typeshed/stubs/ldap3/@tests/stubtest_allowlist.txt
@@ -0,0 +1 @@
+ldap3.utils.ordDict # file is available only in Python 2.6
diff --git a/python/helpers/typeshed/stubs/ldap3/METADATA.toml b/python/helpers/typeshed/stubs/ldap3/METADATA.toml
index 76740bed39e9..47c015f41255 100644
--- a/python/helpers/typeshed/stubs/ldap3/METADATA.toml
+++ b/python/helpers/typeshed/stubs/ldap3/METADATA.toml
@@ -1,10 +1,8 @@
version = "2.9.*"
upstream_repository = "https://github.com/cannatag/ldap3"
requires = ["types-pyasn1"]
-partial_stub = true
[tool.stubtest]
-ignore_missing_stub = true
apt_dependencies = ["libkrb5-dev"]
# No need to install on the CI. Leaving here as information for MacOs/Windows contributors.
# brew_dependencies = ["krb5"]
diff --git a/python/helpers/typeshed/stubs/ldap3/ldap3/utils/asn1.pyi b/python/helpers/typeshed/stubs/ldap3/ldap3/utils/asn1.pyi
index e29518128a5a..4d4abfcea9ca 100644
--- a/python/helpers/typeshed/stubs/ldap3/ldap3/utils/asn1.pyi
+++ b/python/helpers/typeshed/stubs/ldap3/ldap3/utils/asn1.pyi
@@ -4,6 +4,7 @@ from typing import Any, Final, TypeVar, overload
from typing_extensions import TypeAlias
from pyasn1.codec.ber.encoder import AbstractItemEncoder
+from pyasn1.type.tag import TagSet
# Use _typeshed._SupportsGetItemBuffer after PEP 688
_SupportsGetItemBuffer: TypeAlias = SliceableBuffer | IndexableBuffer
@@ -19,6 +20,9 @@ class LDAPBooleanEncoder(AbstractItemEncoder):
# Requires pyasn1 > 0.3.7
def encodeValue(self, value: bool | int, asn1Spec: Unused, encodeFun: Unused, **options: Unused): ...
+customTagMap: dict[TagSet, AbstractItemEncoder]
+customTypeMap: dict[int, AbstractItemEncoder]
+
def compute_ber_size(data): ...
def decode_message_fast(message): ...
@overload
diff --git a/python/helpers/typeshed/stubs/ldap3/ldap3/version.pyi b/python/helpers/typeshed/stubs/ldap3/ldap3/version.pyi
index 50be840c1d09..5939bd051b4b 100644
--- a/python/helpers/typeshed/stubs/ldap3/ldap3/version.pyi
+++ b/python/helpers/typeshed/stubs/ldap3/ldap3/version.pyi
@@ -1,3 +1,9 @@
-__url__: str
-__description__: str
-__status__: str
+from typing import Final
+
+__version__: Final[str]
+__author__: Final[str]
+__email__: Final[str]
+__url__: Final[str]
+__description__: Final[str]
+__status__: Final[str]
+__license__: Final[str]
diff --git a/python/helpers/typeshed/stubs/lupa/METADATA.toml b/python/helpers/typeshed/stubs/lupa/METADATA.toml
index 4c6af6eeb903..ce6fd0811de1 100644
--- a/python/helpers/typeshed/stubs/lupa/METADATA.toml
+++ b/python/helpers/typeshed/stubs/lupa/METADATA.toml
@@ -1,2 +1,2 @@
-version = "2.4.*"
+version = "2.5.*"
upstream_repository = "https://github.com/scoder/lupa"
diff --git a/python/helpers/typeshed/stubs/lupa/lupa/lua51.pyi b/python/helpers/typeshed/stubs/lupa/lupa/lua51.pyi
index cdd4e4b096dd..3d4de040e93d 100644
--- a/python/helpers/typeshed/stubs/lupa/lupa/lua51.pyi
+++ b/python/helpers/typeshed/stubs/lupa/lupa/lua51.pyi
@@ -1,6 +1,7 @@
from _typeshed import MaybeNone
-from collections.abc import Callable, Iterator
+from collections.abc import Callable, Iterable
from typing import Any, Final, Generic, TypeVar, type_check_only
+from typing_extensions import TypeAlias
__all__ = [
"LUA_VERSION",
@@ -34,22 +35,29 @@ unpacks_lua_table_method: Callable[[Callable[..., Any]], Callable[..., Any]]
# inner classes
-@type_check_only
-class _LuaIter:
- def __iter__(self) -> Iterator[object]: ...
-
@type_check_only
class _LuaTable:
- def keys(self) -> _LuaIter: ...
- def values(self) -> _LuaIter: ...
- def items(self) -> _LuaIter: ...
+ def keys(self) -> Iterable[_LuaKey]: ...
+ def values(self) -> Iterable[_LuaObject]: ...
+ def items(self) -> Iterable[tuple[_LuaKey, _LuaObject]]: ...
+ def __getitem__(self, key: _LuaKey) -> _LuaObject: ...
+ def __setitem__(self, key: _LuaKey, value: _LuaObject) -> None: ...
+ def __delitem__(self, key: _LuaKey) -> None: ...
+
+# A Lua object can be a table or a primitive type. Because we have no way of
+# knowing the actual type across languages, we simply use an Any for a Lua
+# object.
+
+# A previous version of this code had
+# _LuaObject: TypeAlias = _LuaTable | int | str | float | bool | None
+# but that causes false type failures when running, e.g., `lua.globals()['foo']['bar']`
+# (because `lua.globals()['foo']` is not known to be a nested table
+_LuaKey: TypeAlias = str | int
+_LuaObject: TypeAlias = Any
@type_check_only
class _LuaNoGC: ...
-@type_check_only
-class _LuaObject: ...
-
# classes
_bint = TypeVar("_bint", bool, int)
@@ -70,8 +78,7 @@ class LuaRuntime:
lua_implementation: Final[str]
lua_version: Final[tuple[int, int]]
- # @classmethod
- # def __cinit__(cls, unpack_return_tuples: bool) -> None: ...
+ def __init__(self, /, unpack_returned_tuples: bool) -> None: ...
# def add_pending_unref(self, ref: int) -> None: ...
# def clean_up_pending_unrefs(self) -> int: ...
def get_max_memory(self, total: bool = False) -> int | MaybeNone: ...
@@ -84,7 +91,7 @@ class LuaRuntime:
def require(self, modulename: str) -> object: ...
def globals(self) -> _LuaTable: ...
def table(self, *items: Any, **kwargs: Any) -> _LuaTable: ...
- def table_from(self, *args: Any, recursive: bool = ...) -> _LuaTable: ...
+ def table_from(self, *args: Any, recursive: bool = False) -> _LuaTable: ...
def nogc(self) -> _LuaNoGC: ...
def gccollect(self) -> None: ...
def set_max_memory(self, max_memory: int, total: bool = False) -> None: ...
diff --git a/python/helpers/typeshed/stubs/lupa/lupa/lua52.pyi b/python/helpers/typeshed/stubs/lupa/lupa/lua52.pyi
index cdd4e4b096dd..3d4de040e93d 100644
--- a/python/helpers/typeshed/stubs/lupa/lupa/lua52.pyi
+++ b/python/helpers/typeshed/stubs/lupa/lupa/lua52.pyi
@@ -1,6 +1,7 @@
from _typeshed import MaybeNone
-from collections.abc import Callable, Iterator
+from collections.abc import Callable, Iterable
from typing import Any, Final, Generic, TypeVar, type_check_only
+from typing_extensions import TypeAlias
__all__ = [
"LUA_VERSION",
@@ -34,22 +35,29 @@ unpacks_lua_table_method: Callable[[Callable[..., Any]], Callable[..., Any]]
# inner classes
-@type_check_only
-class _LuaIter:
- def __iter__(self) -> Iterator[object]: ...
-
@type_check_only
class _LuaTable:
- def keys(self) -> _LuaIter: ...
- def values(self) -> _LuaIter: ...
- def items(self) -> _LuaIter: ...
+ def keys(self) -> Iterable[_LuaKey]: ...
+ def values(self) -> Iterable[_LuaObject]: ...
+ def items(self) -> Iterable[tuple[_LuaKey, _LuaObject]]: ...
+ def __getitem__(self, key: _LuaKey) -> _LuaObject: ...
+ def __setitem__(self, key: _LuaKey, value: _LuaObject) -> None: ...
+ def __delitem__(self, key: _LuaKey) -> None: ...
+
+# A Lua object can be a table or a primitive type. Because we have no way of
+# knowing the actual type across languages, we simply use an Any for a Lua
+# object.
+
+# A previous version of this code had
+# _LuaObject: TypeAlias = _LuaTable | int | str | float | bool | None
+# but that causes false type failures when running, e.g., `lua.globals()['foo']['bar']`
+# (because `lua.globals()['foo']` is not known to be a nested table
+_LuaKey: TypeAlias = str | int
+_LuaObject: TypeAlias = Any
@type_check_only
class _LuaNoGC: ...
-@type_check_only
-class _LuaObject: ...
-
# classes
_bint = TypeVar("_bint", bool, int)
@@ -70,8 +78,7 @@ class LuaRuntime:
lua_implementation: Final[str]
lua_version: Final[tuple[int, int]]
- # @classmethod
- # def __cinit__(cls, unpack_return_tuples: bool) -> None: ...
+ def __init__(self, /, unpack_returned_tuples: bool) -> None: ...
# def add_pending_unref(self, ref: int) -> None: ...
# def clean_up_pending_unrefs(self) -> int: ...
def get_max_memory(self, total: bool = False) -> int | MaybeNone: ...
@@ -84,7 +91,7 @@ class LuaRuntime:
def require(self, modulename: str) -> object: ...
def globals(self) -> _LuaTable: ...
def table(self, *items: Any, **kwargs: Any) -> _LuaTable: ...
- def table_from(self, *args: Any, recursive: bool = ...) -> _LuaTable: ...
+ def table_from(self, *args: Any, recursive: bool = False) -> _LuaTable: ...
def nogc(self) -> _LuaNoGC: ...
def gccollect(self) -> None: ...
def set_max_memory(self, max_memory: int, total: bool = False) -> None: ...
diff --git a/python/helpers/typeshed/stubs/lupa/lupa/lua53.pyi b/python/helpers/typeshed/stubs/lupa/lupa/lua53.pyi
index cdd4e4b096dd..3d4de040e93d 100644
--- a/python/helpers/typeshed/stubs/lupa/lupa/lua53.pyi
+++ b/python/helpers/typeshed/stubs/lupa/lupa/lua53.pyi
@@ -1,6 +1,7 @@
from _typeshed import MaybeNone
-from collections.abc import Callable, Iterator
+from collections.abc import Callable, Iterable
from typing import Any, Final, Generic, TypeVar, type_check_only
+from typing_extensions import TypeAlias
__all__ = [
"LUA_VERSION",
@@ -34,22 +35,29 @@ unpacks_lua_table_method: Callable[[Callable[..., Any]], Callable[..., Any]]
# inner classes
-@type_check_only
-class _LuaIter:
- def __iter__(self) -> Iterator[object]: ...
-
@type_check_only
class _LuaTable:
- def keys(self) -> _LuaIter: ...
- def values(self) -> _LuaIter: ...
- def items(self) -> _LuaIter: ...
+ def keys(self) -> Iterable[_LuaKey]: ...
+ def values(self) -> Iterable[_LuaObject]: ...
+ def items(self) -> Iterable[tuple[_LuaKey, _LuaObject]]: ...
+ def __getitem__(self, key: _LuaKey) -> _LuaObject: ...
+ def __setitem__(self, key: _LuaKey, value: _LuaObject) -> None: ...
+ def __delitem__(self, key: _LuaKey) -> None: ...
+
+# A Lua object can be a table or a primitive type. Because we have no way of
+# knowing the actual type across languages, we simply use an Any for a Lua
+# object.
+
+# A previous version of this code had
+# _LuaObject: TypeAlias = _LuaTable | int | str | float | bool | None
+# but that causes false type failures when running, e.g., `lua.globals()['foo']['bar']`
+# (because `lua.globals()['foo']` is not known to be a nested table
+_LuaKey: TypeAlias = str | int
+_LuaObject: TypeAlias = Any
@type_check_only
class _LuaNoGC: ...
-@type_check_only
-class _LuaObject: ...
-
# classes
_bint = TypeVar("_bint", bool, int)
@@ -70,8 +78,7 @@ class LuaRuntime:
lua_implementation: Final[str]
lua_version: Final[tuple[int, int]]
- # @classmethod
- # def __cinit__(cls, unpack_return_tuples: bool) -> None: ...
+ def __init__(self, /, unpack_returned_tuples: bool) -> None: ...
# def add_pending_unref(self, ref: int) -> None: ...
# def clean_up_pending_unrefs(self) -> int: ...
def get_max_memory(self, total: bool = False) -> int | MaybeNone: ...
@@ -84,7 +91,7 @@ class LuaRuntime:
def require(self, modulename: str) -> object: ...
def globals(self) -> _LuaTable: ...
def table(self, *items: Any, **kwargs: Any) -> _LuaTable: ...
- def table_from(self, *args: Any, recursive: bool = ...) -> _LuaTable: ...
+ def table_from(self, *args: Any, recursive: bool = False) -> _LuaTable: ...
def nogc(self) -> _LuaNoGC: ...
def gccollect(self) -> None: ...
def set_max_memory(self, max_memory: int, total: bool = False) -> None: ...
diff --git a/python/helpers/typeshed/stubs/lupa/lupa/lua54.pyi b/python/helpers/typeshed/stubs/lupa/lupa/lua54.pyi
index cdd4e4b096dd..3d4de040e93d 100644
--- a/python/helpers/typeshed/stubs/lupa/lupa/lua54.pyi
+++ b/python/helpers/typeshed/stubs/lupa/lupa/lua54.pyi
@@ -1,6 +1,7 @@
from _typeshed import MaybeNone
-from collections.abc import Callable, Iterator
+from collections.abc import Callable, Iterable
from typing import Any, Final, Generic, TypeVar, type_check_only
+from typing_extensions import TypeAlias
__all__ = [
"LUA_VERSION",
@@ -34,22 +35,29 @@ unpacks_lua_table_method: Callable[[Callable[..., Any]], Callable[..., Any]]
# inner classes
-@type_check_only
-class _LuaIter:
- def __iter__(self) -> Iterator[object]: ...
-
@type_check_only
class _LuaTable:
- def keys(self) -> _LuaIter: ...
- def values(self) -> _LuaIter: ...
- def items(self) -> _LuaIter: ...
+ def keys(self) -> Iterable[_LuaKey]: ...
+ def values(self) -> Iterable[_LuaObject]: ...
+ def items(self) -> Iterable[tuple[_LuaKey, _LuaObject]]: ...
+ def __getitem__(self, key: _LuaKey) -> _LuaObject: ...
+ def __setitem__(self, key: _LuaKey, value: _LuaObject) -> None: ...
+ def __delitem__(self, key: _LuaKey) -> None: ...
+
+# A Lua object can be a table or a primitive type. Because we have no way of
+# knowing the actual type across languages, we simply use an Any for a Lua
+# object.
+
+# A previous version of this code had
+# _LuaObject: TypeAlias = _LuaTable | int | str | float | bool | None
+# but that causes false type failures when running, e.g., `lua.globals()['foo']['bar']`
+# (because `lua.globals()['foo']` is not known to be a nested table
+_LuaKey: TypeAlias = str | int
+_LuaObject: TypeAlias = Any
@type_check_only
class _LuaNoGC: ...
-@type_check_only
-class _LuaObject: ...
-
# classes
_bint = TypeVar("_bint", bool, int)
@@ -70,8 +78,7 @@ class LuaRuntime:
lua_implementation: Final[str]
lua_version: Final[tuple[int, int]]
- # @classmethod
- # def __cinit__(cls, unpack_return_tuples: bool) -> None: ...
+ def __init__(self, /, unpack_returned_tuples: bool) -> None: ...
# def add_pending_unref(self, ref: int) -> None: ...
# def clean_up_pending_unrefs(self) -> int: ...
def get_max_memory(self, total: bool = False) -> int | MaybeNone: ...
@@ -84,7 +91,7 @@ class LuaRuntime:
def require(self, modulename: str) -> object: ...
def globals(self) -> _LuaTable: ...
def table(self, *items: Any, **kwargs: Any) -> _LuaTable: ...
- def table_from(self, *args: Any, recursive: bool = ...) -> _LuaTable: ...
+ def table_from(self, *args: Any, recursive: bool = False) -> _LuaTable: ...
def nogc(self) -> _LuaNoGC: ...
def gccollect(self) -> None: ...
def set_max_memory(self, max_memory: int, total: bool = False) -> None: ...
diff --git a/python/helpers/typeshed/stubs/m3u8/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/m3u8/@tests/stubtest_allowlist.txt
index 28f49d10cb3f..7842199c24e4 100644
--- a/python/helpers/typeshed/stubs/m3u8/@tests/stubtest_allowlist.txt
+++ b/python/helpers/typeshed/stubs/m3u8/@tests/stubtest_allowlist.txt
@@ -1,17 +1,5 @@
# type check only
m3u8.httpclient.HTTPSHandler.__new__
# internal functions and attributes
-m3u8.M3U8.simple_attributes
-m3u8.model.M3U8.simple_attributes
-m3u8.model.denormalize_attribute
-m3u8.model.find_key
-m3u8.model.number_to_string
-m3u8.model.quoted
-m3u8.parser.cast_date_time
-m3u8.parser.format_date_time
m3u8.parser.get_segment_custom_value
-m3u8.parser.normalize_attribute
-m3u8.parser.remove_quotes
-m3u8.parser.remove_quotes_parser
m3u8.parser.save_segment_custom_value
-m3u8.parser.string_to_lines
diff --git a/python/helpers/typeshed/stubs/m3u8/m3u8/__init__.pyi b/python/helpers/typeshed/stubs/m3u8/m3u8/__init__.pyi
index 888edc10743c..8ce37aeb0b52 100644
--- a/python/helpers/typeshed/stubs/m3u8/m3u8/__init__.pyi
+++ b/python/helpers/typeshed/stubs/m3u8/m3u8/__init__.pyi
@@ -65,7 +65,7 @@ _CustomTagsParser: TypeAlias = Callable[[str, int, dict[str, Any], dict[str, Any
def loads(content: str, uri: str | None = None, custom_tags_parser: _CustomTagsParser | None = None) -> M3U8: ...
def load(
uri: str,
- timeout=None,
+ timeout: float | None = None,
headers: Mapping[str, Any] = {},
custom_tags_parser: _CustomTagsParser | None = None,
http_client: _HTTPClientProtocol = ...,
diff --git a/python/helpers/typeshed/stubs/m3u8/m3u8/model.pyi b/python/helpers/typeshed/stubs/m3u8/m3u8/model.pyi
index d9b50c11f051..53e31529e23e 100644
--- a/python/helpers/typeshed/stubs/m3u8/m3u8/model.pyi
+++ b/python/helpers/typeshed/stubs/m3u8/m3u8/model.pyi
@@ -1,7 +1,8 @@
import datetime as dt
-from _typeshed import Incomplete, StrOrBytesPath
-from collections.abc import Callable, Mapping
-from typing import ClassVar, Literal, Protocol, TypeVar, type_check_only
+from _typeshed import Incomplete, StrOrBytesPath, Unused
+from collections.abc import Callable, Iterable, Mapping
+from decimal import Decimal
+from typing import Any, ClassVar, Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
from m3u8.mixins import BasePathMixin, GroupedBasePathMixin
@@ -27,7 +28,7 @@ _PlaylistAnyT = TypeVar("_PlaylistAnyT", bound=_PlaylistProtocol)
class MalformedPlaylistError(Exception): ...
class M3U8:
- simple_attributes: list[tuple[str, str]]
+ simple_attributes: tuple[tuple[str, str], ...]
data: dict[str, Incomplete]
keys: list[Key]
segment_map: list[InitializationSection]
@@ -54,7 +55,7 @@ class M3U8:
is_i_frames_only: bool | None
target_duration: float | None
media_sequence: int | None
- program_date_time: str | None
+ program_date_time: dt.datetime | None
is_independent_segments: bool | None
version: str | None
allow_cache: str | None
@@ -118,29 +119,29 @@ class Segment(BasePathMixin):
uri: str | None = None,
base_uri: str | None = None,
program_date_time: dt.datetime | None = None,
- current_program_date_time=None,
+ current_program_date_time: dt.datetime | None = None,
duration: float | None = None,
title: str | None = None,
- bitrate=None,
- byterange=None,
+ bitrate: int | None = None,
+ byterange: str | None = None,
cue_out: bool = False,
cue_out_start: bool = False,
cue_out_explicitly_duration: bool = False,
cue_in: bool = False,
discontinuity: bool = False,
- key=None,
- scte35=None,
+ key: Unused = None,
+ scte35: str | None = None,
oatcls_scte35: str | None = None,
- scte35_duration=None,
+ scte35_duration: float | None = None,
scte35_elapsedtime=None,
asset_metadata: Mapping[str, str] | None = None,
keyobject: Key | None = None,
- parts: list[Mapping[str, Incomplete]] | None = None,
+ parts: Iterable[Mapping[str, Incomplete]] | None = None,
init_section: Mapping[str, Incomplete] | None = None,
- dateranges=None,
+ dateranges: Iterable[Mapping[str, Incomplete]] | None = None,
gap_tag: list[Mapping[str, Incomplete]] | None = None,
media_sequence: int | None = None,
- custom_parser_values=None,
+ custom_parser_values: dict[str, Incomplete] | None = None,
) -> None: ...
def add_part(self, part: PartialSegment) -> None: ...
def dumps(self, last_segment: PartialSegment | None, timespec: str = "milliseconds", infspec: str = "auto") -> str: ...
@@ -177,11 +178,11 @@ class PartialSegment(BasePathMixin):
uri: str | None,
duration: float | None,
program_date_time: dt.datetime | None = None,
- current_program_date_time=None,
- byterange=None,
+ current_program_date_time: dt.datetime | None = None,
+ byterange: str | None = None,
independent=None,
gap=None,
- dateranges: list[Mapping[str, Incomplete]] | None = None,
+ dateranges: Iterable[Mapping[str, Incomplete]] | None = None,
gap_tag=None,
) -> None: ...
def dumps(self, last_segment) -> str: ...
@@ -251,7 +252,25 @@ class StreamInfo:
pathway_id: str | None
stable_variant_id: str | None
req_video_layout: str | None
- def __init__(self, **kwargs) -> None: ...
+ def __init__(
+ self,
+ *,
+ bandwidth: int | None = None,
+ closed_captions=None,
+ average_bandwidth: int | None = None,
+ program_id: int | None = None,
+ resolution: tuple[int, int] | None = None,
+ codecs: str | None = None,
+ audio: str | None = None,
+ video: str | None = None,
+ subtitles: str | None = None,
+ frame_rate: float | None = None,
+ video_range: str | None = None,
+ hdcp_level: str | None = None,
+ pathway_id: str | None = None,
+ stable_variant_id: str | None = None,
+ req_video_layout: str | None = None,
+ ) -> None: ...
class Media(BasePathMixin):
base_uri: str | None
@@ -328,7 +347,7 @@ class ServerControl:
part_hold_back: float | None = None,
can_skip_dateranges: str | None = None,
) -> None: ...
- def __getitem__(self, item: str): ...
+ def __getitem__(self, item: str) -> str | float | None: ...
def dumps(self) -> str: ...
class Skip:
@@ -356,7 +375,7 @@ class PreloadHint(BasePathMixin):
byterange_start: int | None = None,
byterange_length: int | None = None,
) -> None: ...
- def __getitem__(self, item: str) -> str: ...
+ def __getitem__(self, item: str) -> str | int | None: ...
def dumps(self) -> str: ...
class SessionData:
@@ -381,7 +400,21 @@ class DateRange:
scte35_in: str | None
end_on_next: Incomplete
x_client_attrs: list[tuple[str, str]]
- def __init__(self, **kwargs) -> None: ...
+ def __init__(
+ self,
+ *,
+ id: str,
+ start_date: str | None = None,
+ class_: str | None = None, # actually passing as `class` argument
+ end_date: str | None = None,
+ duration: float | None = None,
+ planned_duration: float | None = None,
+ scte35_cmd: str | None = None,
+ scte35_out: str | None = None,
+ scte35_in: str | None = None,
+ end_on_next=None,
+ **kwargs: str, # for arguments with `x_` prefix
+ ) -> None: ...
def dumps(self) -> str: ...
class ContentSteering(BasePathMixin):
@@ -404,3 +437,11 @@ class Tiles(BasePathMixin): # this is unused in runtime, so this is (temporary)
duration: Incomplete
def __init__(self, resolution, layout, duration) -> None: ...
def dumps(self) -> str: ...
+
+@overload
+def find_key(keydata: None, keylist: Iterable[Key | None]) -> None: ...
+@overload
+def find_key(keydata: Mapping[str, Any], keylist: Iterable[Key | None]) -> Key: ... # keydata can contain any values
+def denormalize_attribute(attribute: str) -> str: ...
+def quoted(string: str | None) -> str: ...
+def number_to_string(number: str | float | Decimal) -> str: ...
diff --git a/python/helpers/typeshed/stubs/m3u8/m3u8/parser.pyi b/python/helpers/typeshed/stubs/m3u8/m3u8/parser.pyi
index f33e0126e8d5..4eaf0543ffc8 100644
--- a/python/helpers/typeshed/stubs/m3u8/m3u8/parser.pyi
+++ b/python/helpers/typeshed/stubs/m3u8/m3u8/parser.pyi
@@ -1,14 +1,29 @@
from collections.abc import Callable
+from datetime import date, datetime, time
+from itertools import repeat
from re import Pattern
-from typing import Any
+from typing import Any, overload
from typing_extensions import TypeAlias
-ATTRIBUTELISTPATTERN: Pattern[str]
_CustomTagsParser: TypeAlias = Callable[[str, int, dict[str, Any], dict[str, Any]], object]
+ATTRIBUTELISTPATTERN: Pattern[str]
+
+def cast_date_time(value: str) -> datetime: ...
+@overload
+def format_date_time(value: time, *, timespec: str = ...) -> str: ...
+@overload
+def format_date_time(value: datetime, *, sep: str = ..., timespec: str = ...) -> str: ...
+@overload
+def format_date_time(value: date) -> str: ...
+
class ParseError(Exception):
lineno: int
line: str
def __init__(self, lineno: int, line: str) -> None: ...
def parse(content: str, strict: bool = False, custom_tags_parser: _CustomTagsParser | None = None) -> dict[str, Any]: ...
+def string_to_lines(string: str) -> list[str]: ...
+def remove_quotes_parser(*attrs: repeat[Callable[[str], str]]) -> dict[repeat[Callable[[str], str]], Callable[[str], str]]: ...
+def remove_quotes(string: str) -> str: ...
+def normalize_attribute(attribute: str) -> str: ...
diff --git a/python/helpers/typeshed/stubs/mock/mock/mock.pyi b/python/helpers/typeshed/stubs/mock/mock/mock.pyi
index a4ad35e575cb..bd241cf01988 100644
--- a/python/helpers/typeshed/stubs/mock/mock/mock.pyi
+++ b/python/helpers/typeshed/stubs/mock/mock/mock.pyi
@@ -2,7 +2,7 @@ from _typeshed import Incomplete
from collections.abc import Callable, Coroutine, Iterable, Mapping, Sequence
from contextlib import AbstractContextManager
from types import TracebackType
-from typing import Any, ClassVar, Generic, Literal, TypeVar, overload
+from typing import Any, ClassVar, Generic, Literal, TypeVar, overload, type_check_only
from typing_extensions import ParamSpec, Self
_F = TypeVar("_F", bound=Callable[..., Any])
@@ -211,6 +211,7 @@ class _patch_dict:
start: Any
stop: Any
+@type_check_only
class _patcher:
TEST_PREFIX: str
dict: type[_patch_dict]
diff --git a/python/helpers/typeshed/stubs/netaddr/netaddr/eui/__init__.pyi b/python/helpers/typeshed/stubs/netaddr/netaddr/eui/__init__.pyi
index 38a5e3fd5d29..c73a5b6e34d8 100644
--- a/python/helpers/typeshed/stubs/netaddr/netaddr/eui/__init__.pyi
+++ b/python/helpers/typeshed/stubs/netaddr/netaddr/eui/__init__.pyi
@@ -8,11 +8,13 @@ from netaddr.strategy.eui48 import mac_eui48
from netaddr.strategy.eui64 import eui64_base
class BaseIdentifier:
+ __slots__ = ("_value", "__weakref__")
def __init__(self) -> None: ...
def __int__(self) -> int: ...
def __index__(self) -> int: ...
class OUI(BaseIdentifier):
+ __slots__ = ("records",)
records: list[dict[str, object]]
def __init__(self, oui: str | int) -> None: ...
def __eq__(self, other: object) -> bool: ...
@@ -22,6 +24,7 @@ class OUI(BaseIdentifier):
def registration(self, index: int = 0) -> DictDotLookup: ...
class IAB(BaseIdentifier):
+ __slots__ = ("record",)
IAB_EUI_VALUES: ClassVar[tuple[int, int]]
@classmethod
def split_iab_mac(cls, eui_int: int, strict: bool = False) -> tuple[int, int]: ...
@@ -32,6 +35,7 @@ class IAB(BaseIdentifier):
def registration(self) -> DictDotLookup: ...
class EUI(BaseIdentifier):
+ __slots__ = ("_module", "_dialect")
def __init__(
self, addr: EUI | int | str, version: int | None = None, dialect: type[mac_eui48 | eui64_base] | None = None
) -> None: ...
diff --git a/python/helpers/typeshed/stubs/netaddr/netaddr/ip/__init__.pyi b/python/helpers/typeshed/stubs/netaddr/netaddr/ip/__init__.pyi
index de1e752cbc2a..b857e10436ad 100644
--- a/python/helpers/typeshed/stubs/netaddr/netaddr/ip/__init__.pyi
+++ b/python/helpers/typeshed/stubs/netaddr/netaddr/ip/__init__.pyi
@@ -8,6 +8,7 @@ from netaddr.core import DictDotLookup
from netaddr.strategy.ipv6 import ipv6_verbose
class BaseIP:
+ __slots__ = ("_value", "_module", "__weakref__")
def __init__(self) -> None: ...
@property
def value(self) -> int | None: ...
@@ -40,6 +41,7 @@ _IPAddressAddr: TypeAlias = BaseIP | int | str
_IPNetworkAddr: TypeAlias = IPNetwork | IPAddress | tuple[int, int] | str
class IPAddress(BaseIP):
+ __slots__ = ()
def __init__(self, addr: _IPAddressAddr, version: Literal[4, 6] | None = None, flags: int = 0) -> None: ...
def netmask_bits(self) -> int: ...
def is_hostmask(self) -> bool: ...
@@ -79,6 +81,7 @@ class IPAddress(BaseIP):
def is_ipv6_unique_local(self) -> bool: ...
class IPListMixin:
+ __slots__ = ()
def __iter__(self) -> Iterator[IPAddress]: ...
@property
def size(self) -> int: ...
@@ -95,6 +98,7 @@ class IPListMixin:
def parse_ip_network(module, addr: tuple[int, int] | str, flags: int = 0, *, expand_partial: bool = False) -> tuple[int, int]: ...
class IPNetwork(BaseIP, IPListMixin):
+ __slots__ = ("_prefixlen",)
def __init__(
self, addr: _IPNetworkAddr, version: Literal[4, 6] | None = None, flags: int = 0, *, expand_partial: bool = False
) -> None: ...
@@ -135,6 +139,7 @@ class IPNetwork(BaseIP, IPListMixin):
def iter_hosts(self) -> Iterator[IPAddress]: ...
class IPRange(BaseIP, IPListMixin):
+ __slots__ = ("_start", "_end")
def __init__(self, start: _IPAddressAddr, end: _IPAddressAddr, flags: int = 0) -> None: ...
def __contains__(self, other: BaseIP | _IPAddressAddr) -> bool: ...
@property
diff --git a/python/helpers/typeshed/stubs/netaddr/netaddr/ip/glob.pyi b/python/helpers/typeshed/stubs/netaddr/netaddr/ip/glob.pyi
index 34660723c002..e0836fcf3bdd 100644
--- a/python/helpers/typeshed/stubs/netaddr/netaddr/ip/glob.pyi
+++ b/python/helpers/typeshed/stubs/netaddr/netaddr/ip/glob.pyi
@@ -10,6 +10,7 @@ def glob_to_cidrs(ipglob: str) -> list[IPNetwork]: ...
def cidr_to_glob(cidr: _IPNetworkAddr) -> str: ...
class IPGlob(IPRange):
+ __slots__ = ("_glob",)
def __init__(self, ipglob: str) -> None: ...
@property
def glob(self) -> str: ...
diff --git a/python/helpers/typeshed/stubs/netaddr/netaddr/ip/sets.pyi b/python/helpers/typeshed/stubs/netaddr/netaddr/ip/sets.pyi
index 49f9cf64dd57..b512ee720b30 100644
--- a/python/helpers/typeshed/stubs/netaddr/netaddr/ip/sets.pyi
+++ b/python/helpers/typeshed/stubs/netaddr/netaddr/ip/sets.pyi
@@ -7,6 +7,7 @@ from netaddr.ip import IPAddress, IPNetwork, IPRange, _IPNetworkAddr
_IPIterable: TypeAlias = IPNetwork | IPRange | IPSet | Iterable[_IPNetworkAddr | IPRange | int]
class IPSet:
+ __slots__ = ("_cidrs", "__weakref__")
def __init__(self, iterable: _IPIterable | None = None, flags: int = 0) -> None: ...
def compact(self) -> None: ...
def __hash__(self) -> NoReturn: ...
diff --git a/python/helpers/typeshed/stubs/networkx/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/networkx/@tests/stubtest_allowlist.txt
index 750b9fd968f3..16085bf5b6c6 100644
--- a/python/helpers/typeshed/stubs/networkx/@tests/stubtest_allowlist.txt
+++ b/python/helpers/typeshed/stubs/networkx/@tests/stubtest_allowlist.txt
@@ -4,7 +4,6 @@
networkx\.(algorithms\.)?(boundary\.)?edge_boundary
networkx\.(algorithms\.)?(bridges\.)?local_bridges
networkx\.(algorithms\.)?(clique\.)?node_clique_number
-networkx\.(algorithms\.)?(shortest_paths\.)?(generic\.)?shortest_path
networkx\.(convert_matrix\.)?from_numpy_array
networkx\.(convert_matrix\.)?from_pandas_adjacency
networkx\.(convert_matrix\.)?from_pandas_edgelist
@@ -32,6 +31,9 @@ networkx\.(utils\.)?(backends\.)?_dispatchable\.__call__
networkx.conftest
networkx(\..+?)?\.tests(\..+?)?
+# Stub-only module
+networkx\._typing
+
# "..._DT is not present at runtime" but we don't set it in stubs, I don't understand this one
networkx(\.algorithms)?(\.tree)?(\.mst)?\.SpanningTreeIterator\.Partition\._DT
networkx(\.algorithms)?(\.tree)?(\.branchings)?\.ArborescenceIterator\.Partition\._DT
diff --git a/python/helpers/typeshed/stubs/networkx/@tests/test_cases/check_tricky_function_params.py b/python/helpers/typeshed/stubs/networkx/@tests/test_cases/check_tricky_function_params.py
new file mode 100644
index 000000000000..6a1105347ee3
--- /dev/null
+++ b/python/helpers/typeshed/stubs/networkx/@tests/test_cases/check_tricky_function_params.py
@@ -0,0 +1,11 @@
+import networkx as nx
+
+# Test covariant dict type for `pos` in nx_latex functions
+G: "nx.Graph[int]" = nx.Graph([(1, 2), (2, 3), (3, 4)])
+nx.to_latex_raw(G, pos=nx.spring_layout(G, seed=42)) # OK: dict[node, ndarray]
+pos1: dict[int, tuple[int, int]] = {1: (1, 2), 2: (3, 4), 3: (5, 6), 4: (7, 8)}
+nx.to_latex_raw(G, pos=pos1) # OK: dict[node, 2-tuple]
+pos2: dict[int, str] = {1: "(1, 2)", 2: "(3, 4)", 3: "(5, 6)", 4: "(7, 8)"}
+nx.to_latex_raw(G, pos=pos2) # OK: dict[node, str]
+pos3: dict[int, int] = {1: 1, 2: 3, 3: 5, 4: 7}
+nx.to_latex_raw(G, pos=pos3) # type: ignore # dict keys must be str or collection
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/_typing.pyi b/python/helpers/typeshed/stubs/networkx/networkx/_typing.pyi
new file mode 100644
index 000000000000..ff530c5ba668
--- /dev/null
+++ b/python/helpers/typeshed/stubs/networkx/networkx/_typing.pyi
@@ -0,0 +1,29 @@
+# Stub-only module, can't be imported at runtime.
+
+import sys
+from collections.abc import Collection
+from typing import Any, Protocol, type_check_only
+from typing_extensions import TypeAlias, TypeVar
+
+import numpy as np
+
+_ScalarT = TypeVar("_ScalarT", bound=bool | int | float | complex | str | bytes | np.generic)
+_GenericT = TypeVar("_GenericT", bound=np.generic)
+_GenericT_co = TypeVar("_GenericT_co", bound=np.generic, covariant=True)
+_ShapeT_co = TypeVar("_ShapeT_co", bound=tuple[int, ...], default=Any, covariant=True)
+
+# numpy aliases
+if sys.version_info >= (3, 10):
+ @type_check_only
+ class SupportsArray(Protocol[_GenericT_co, _ShapeT_co]):
+ def __array__(self) -> np.ndarray[_ShapeT_co, np.dtype[_GenericT_co]]: ...
+
+ ArrayLike1D: TypeAlias = Collection[_ScalarT] | SupportsArray[_GenericT, tuple[int]]
+else:
+ # networkx does not support Python 3.9 but pyright still runs on 3.9 in CI
+ # See https://github.com/python/typeshed/issues/10722
+ ArrayLike1D: TypeAlias = Collection[_ScalarT] | np.ndarray[tuple[int], np.dtype[_GenericT]]
+
+Array1D: TypeAlias = np.ndarray[tuple[int], np.dtype[_GenericT]]
+Array2D: TypeAlias = np.ndarray[tuple[int, int], np.dtype[_GenericT]]
+Seed: TypeAlias = int | np.random.Generator | np.random.RandomState
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/clique.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/clique.pyi
index 4587354a1c07..b906c7a95bcd 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/clique.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/clique.pyi
@@ -1,12 +1,14 @@
+from _typeshed import Incomplete
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
__all__ = ["clique_removal", "max_clique", "large_clique_size", "maximum_independent_set"]
@_dispatchable
-def maximum_independent_set(G: Graph[_Node]): ...
+def maximum_independent_set(G: Graph[_Node]) -> set[Incomplete]: ...
@_dispatchable
-def max_clique(G: Graph[_Node]): ...
+def max_clique(G: Graph[_Node]) -> set[Incomplete]: ...
@_dispatchable
def clique_removal(G: Graph[_Node]): ...
@_dispatchable
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi
index 4c1a7d55c117..cff53629ceb7 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi
@@ -5,4 +5,4 @@ from numpy.random import RandomState
__all__ = ["average_clustering"]
@_dispatchable
-def average_clustering(G: Graph[_Node], trials: int = 1000, seed: int | RandomState | None = None): ...
+def average_clustering(G: Graph[_Node], trials: int = 1000, seed: int | RandomState | None = None) -> float: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi
index 7adcdcb978f2..2e1986d6806e 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi
@@ -11,4 +11,6 @@ def local_node_connectivity(G: Graph[_Node], source: _Node, target: _Node, cutof
@_dispatchable
def node_connectivity(G: Graph[_Node], s: _Node | None = None, t: _Node | None = None): ...
@_dispatchable
-def all_pairs_node_connectivity(G: Graph[_Node], nbunch: Iterable[Incomplete] | None = None, cutoff: int | None = None): ...
+def all_pairs_node_connectivity(
+ G: Graph[_Node], nbunch: Iterable[Incomplete] | None = None, cutoff: int | None = None
+) -> dict[Incomplete, dict[Incomplete, Incomplete]]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi
index a24428f63b8e..e37d3713ce42 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi
@@ -1,9 +1,11 @@
+from _typeshed import Incomplete
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
__all__ = ["min_weighted_dominating_set", "min_edge_dominating_set"]
@_dispatchable
-def min_weighted_dominating_set(G: Graph[_Node], weight: str | None = None): ...
+def min_weighted_dominating_set(G: Graph[_Node], weight: str | None = None) -> set[Incomplete]: ...
@_dispatchable
-def min_edge_dominating_set(G: Graph[_Node]): ...
+def min_edge_dominating_set(G: Graph[_Node]) -> set[Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi
index b1965791435a..e0fe94385cd5 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi
@@ -1,7 +1,10 @@
+from _typeshed import Incomplete
+from collections import defaultdict
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
__all__ = ["k_components"]
@_dispatchable
-def k_components(G: Graph[_Node], min_density: float = 0.95): ...
+def k_components(G: Graph[_Node], min_density: float = 0.95) -> defaultdict[Incomplete, list[Incomplete]]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/matching.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/matching.pyi
index 799818b498f2..7b5f723d44d0 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/matching.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/matching.pyi
@@ -1,7 +1,9 @@
+from _typeshed import Incomplete
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
__all__ = ["min_maximal_matching"]
@_dispatchable
-def min_maximal_matching(G: Graph[_Node]): ...
+def min_maximal_matching(G: Graph[_Node]) -> set[Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi
index acf37c745376..eaff9c69cc07 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi
@@ -1,6 +1,6 @@
from _typeshed import Incomplete, SupportsLenAndGetItem
-from collections.abc import Callable, Mapping
-from typing import Any, TypeVar
+from collections.abc import Callable, Iterable, Mapping
+from typing import Any, Literal, TypeVar
from networkx.classes.digraph import DiGraph
from networkx.classes.graph import Graph, _Node
@@ -21,7 +21,7 @@ _SupportsLenAndGetItemT = TypeVar("_SupportsLenAndGetItemT", bound=SupportsLenAn
def swap_two_nodes(soln: _SupportsLenAndGetItemT, seed) -> _SupportsLenAndGetItemT: ...
def move_one_node(soln: _SupportsLenAndGetItemT, seed) -> _SupportsLenAndGetItemT: ...
@_dispatchable
-def christofides(G: Graph[_Node], weight: str | None = "weight", tree: Graph[_Node] | None = None): ...
+def christofides(G: Graph[_Node], weight: str | None = "weight", tree: Graph[_Node] | None = None) -> list[Incomplete]: ...
@_dispatchable
def traveling_salesman_problem(
G: Graph[_Node],
@@ -57,7 +57,7 @@ def simulated_annealing_tsp(
@_dispatchable
def threshold_accepting_tsp(
G: Graph[_Node],
- init_cycle,
+ init_cycle: Literal["greedy"] | Iterable[Incomplete],
weight: str | None = "weight",
source=None,
threshold: int | None = 1,
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi
index ffd5206df85d..abec263a7bd0 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi
@@ -1,7 +1,9 @@
+from _typeshed import Incomplete
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
__all__ = ["min_weighted_vertex_cover"]
@_dispatchable
-def min_weighted_vertex_cover(G: Graph[_Node], weight: str | None = None): ...
+def min_weighted_vertex_cover(G: Graph[_Node], weight: str | None = None) -> set[Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi
index a4782a825d00..349d6cff8a3c 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi
@@ -1,5 +1,6 @@
from _typeshed import Incomplete
from collections.abc import Iterable
+from typing import Literal
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
@@ -8,5 +9,9 @@ __all__ = ["average_degree_connectivity"]
@_dispatchable
def average_degree_connectivity(
- G: Graph[_Node], source="in+out", target="in+out", nodes: Iterable[Incomplete] | None = None, weight: str | None = None
-): ...
+ G: Graph[_Node],
+ source: Literal["in+out", "out", "in"] = "in+out",
+ target: Literal["in+out", "out", "in"] = "in+out",
+ nodes: Iterable[Incomplete] | None = None,
+ weight: str | None = None,
+) -> dict[Incomplete, int | float]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi
index 2789386434d7..78f36749726d 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi
@@ -14,12 +14,12 @@ __all__ = [
@_dispatchable
def degree_assortativity_coefficient(
G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable[Incomplete] | None = None
-): ...
+) -> float: ...
@_dispatchable
def degree_pearson_correlation_coefficient(
G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable[Incomplete] | None = None
-): ...
+) -> float: ...
@_dispatchable
-def attribute_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None): ...
+def attribute_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None) -> float: ...
@_dispatchable
-def numeric_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None): ...
+def numeric_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None) -> float: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi
index 4c5ced294890..84168115f9db 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi
@@ -9,7 +9,7 @@ __all__ = ["attribute_mixing_matrix", "attribute_mixing_dict", "degree_mixing_ma
@_dispatchable
def attribute_mixing_dict(
G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None, normalized: bool = False
-): ...
+) -> dict[Incomplete, Incomplete]: ...
@_dispatchable
def attribute_mixing_matrix(
G: Graph[_Node],
@@ -21,7 +21,7 @@ def attribute_mixing_matrix(
@_dispatchable
def degree_mixing_dict(
G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes=None, normalized: bool = False
-): ...
+) -> dict[Incomplete, Incomplete]: ...
@_dispatchable
def degree_mixing_matrix(
G: Graph[_Node],
@@ -33,4 +33,4 @@ def degree_mixing_matrix(
mapping: SupportsGetItem[Incomplete, Incomplete] | None = None,
): ...
@_dispatchable
-def mixing_dict(xy, normalized: bool = False): ...
+def mixing_dict(xy, normalized: bool = False) -> dict[Incomplete, Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi
index d86ce3da8211..231c1966d0eb 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi
@@ -13,4 +13,4 @@ def average_neighbor_degree(
target: str | None = "out",
nodes: Iterable[Incomplete] | None = None,
weight: str | None = None,
-): ...
+) -> dict[Incomplete, Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/asteroidal.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/asteroidal.pyi
index 8745fe1accbf..9e4dbd34028f 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/asteroidal.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/asteroidal.pyi
@@ -6,7 +6,7 @@ from networkx.utils.backends import _dispatchable
__all__ = ["is_at_free", "find_asteroidal_triple"]
@_dispatchable
-def find_asteroidal_triple(G: Graph[_Node]): ...
+def find_asteroidal_triple(G: Graph[_Node]) -> list[Incomplete] | None: ...
@_dispatchable
def is_at_free(G: Graph[_Node]) -> bool: ...
@_dispatchable
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/basic.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/basic.pyi
index fcf13edb9dac..afba78f9fdfc 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/basic.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/basic.pyi
@@ -7,14 +7,14 @@ from networkx.utils.backends import _dispatchable
__all__ = ["is_bipartite", "is_bipartite_node_set", "color", "sets", "density", "degrees"]
@_dispatchable
-def color(G: Graph[_Node]): ...
+def color(G: Graph[_Node]) -> dict[Incomplete, Incomplete]: ...
@_dispatchable
def is_bipartite(G: Graph[_Node]) -> bool: ...
@_dispatchable
def is_bipartite_node_set(G: Graph[_Node], nodes: Iterable[Incomplete]) -> bool: ...
@_dispatchable
-def sets(G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None): ...
+def sets(G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None) -> tuple[set[Incomplete], set[Incomplete]]: ...
@_dispatchable
-def density(B: Graph[_Node], nodes): ...
+def density(B: Graph[_Node], nodes) -> float: ...
@_dispatchable
-def degrees(B: Graph[_Node], nodes, weight: str | None = None): ...
+def degrees(B: Graph[_Node], nodes, weight: str | None = None) -> tuple[Incomplete, Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi
index 976948059f2b..529287ee87d7 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi
@@ -1,11 +1,13 @@
+from _typeshed import Incomplete
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
__all__ = ["degree_centrality", "betweenness_centrality", "closeness_centrality"]
@_dispatchable
-def degree_centrality(G: Graph[_Node], nodes): ...
+def degree_centrality(G: Graph[_Node], nodes) -> dict[Incomplete, Incomplete]: ...
@_dispatchable
-def betweenness_centrality(G: Graph[_Node], nodes): ...
+def betweenness_centrality(G: Graph[_Node], nodes) -> dict[Incomplete, Incomplete]: ...
@_dispatchable
-def closeness_centrality(G: Graph[_Node], nodes, normalized: bool | None = True): ...
+def closeness_centrality(G: Graph[_Node], nodes, normalized: bool | None = True) -> dict[Incomplete, Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi
index 0931bb9f735d..1a341ef85e92 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi
@@ -13,11 +13,13 @@ def cc_min(nu, nv) -> float: ...
modes: dict[str, Callable[[Incomplete, Incomplete], float]]
@_dispatchable
-def latapy_clustering(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, mode: str = "dot"): ...
+def latapy_clustering(
+ G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, mode: str = "dot"
+) -> dict[Incomplete, Incomplete]: ...
clustering = latapy_clustering
@_dispatchable
-def average_clustering(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, mode: str = "dot"): ...
+def average_clustering(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, mode: str = "dot") -> float: ...
@_dispatchable
-def robins_alexander_clustering(G: Graph[_Node]): ...
+def robins_alexander_clustering(G: Graph[_Node]) -> float: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/covering.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/covering.pyi
index c915c19c00f0..ab33bcecf487 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/covering.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/covering.pyi
@@ -7,4 +7,4 @@ from networkx.utils.backends import _dispatchable
__all__ = ["min_edge_cover"]
@_dispatchable
-def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable[..., Incomplete] | None = None): ...
+def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable[..., Incomplete] | None = None) -> set[Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi
index 18fb7d40473f..51fb464b16bc 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi
@@ -1,4 +1,3 @@
-from _typeshed import Incomplete
from collections.abc import Generator
from networkx.classes.graph import Graph, _Node
@@ -9,7 +8,7 @@ __all__ = ["generate_edgelist", "write_edgelist", "parse_edgelist", "read_edgeli
@_dispatchable
def write_edgelist(G, path, comments: str = "#", delimiter: str = " ", data: bool = True, encoding: str = "utf-8") -> None: ...
@_dispatchable
-def generate_edgelist(G, delimiter: str = " ", data: bool = True) -> Generator[Incomplete, None, None]: ...
+def generate_edgelist(G, delimiter: str = " ", data: bool = True) -> Generator[str]: ...
@_dispatchable
def parse_edgelist(
lines,
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/matching.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/matching.pyi
index 91ef136107e4..cdf9dddbbbf1 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/matching.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/matching.pyi
@@ -7,9 +7,9 @@ from networkx.utils.backends import _dispatchable
__all__ = ["maximum_matching", "hopcroft_karp_matching", "eppstein_matching", "to_vertex_cover", "minimum_weight_full_matching"]
@_dispatchable
-def hopcroft_karp_matching(G: Graph[_Node], top_nodes: Iterable[_Node] | None = None): ...
+def hopcroft_karp_matching(G: Graph[_Node], top_nodes: Iterable[_Node] | None = None) -> dict[Incomplete, Incomplete]: ...
@_dispatchable
-def eppstein_matching(G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None): ...
+def eppstein_matching(G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None) -> dict[Incomplete, Incomplete]: ...
@_dispatchable
def to_vertex_cover(
G: Graph[_Node], matching: SupportsGetItem[Incomplete, Incomplete], top_nodes: Iterable[Incomplete] | None = None
@@ -20,4 +20,4 @@ maximum_matching = hopcroft_karp_matching
@_dispatchable
def minimum_weight_full_matching(
G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None, weight: str | None = "weight"
-): ...
+) -> dict[Incomplete, Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi
index 2e484482aa8d..b33fed570b98 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi
@@ -14,6 +14,6 @@ def biadjacency_matrix(
dtype=None,
weight: str | None = "weight",
format="csr",
-): ...
+): ... # Return is a complex union of scipy classes depending on the format param
@_dispatchable
def from_biadjacency_matrix(A, create_using: Graph[_Node] | None = None, edge_attribute: str = "weight"): ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi
index cb7233ef90ab..539e8012ad11 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi
@@ -7,4 +7,4 @@ from networkx.utils.backends import _dispatchable
__all__ = ["node_redundancy"]
@_dispatchable
-def node_redundancy(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None): ...
+def node_redundancy(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None) -> dict[Incomplete, float]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi
index 1778bd31cf5a..462e8fef2d73 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi
@@ -1,7 +1,9 @@
+from _typeshed import Incomplete
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
__all__ = ["spectral_bipartivity"]
@_dispatchable
-def spectral_bipartivity(G: Graph[_Node], nodes=None, weight: str = "weight"): ...
+def spectral_bipartivity(G: Graph[_Node], nodes=None, weight: str = "weight") -> float | dict[Incomplete, Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi
index 7d39f64677cf..c22f749306eb 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi
@@ -1,3 +1,5 @@
+from _typeshed import Incomplete
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
from numpy.random import RandomState
@@ -18,12 +20,12 @@ def approximate_current_flow_betweenness_centrality(
epsilon: float = 0.5,
kmax: int = 10000,
seed: int | RandomState | None = None,
-): ...
+) -> dict[Incomplete, float]: ...
@_dispatchable
def current_flow_betweenness_centrality(
G: Graph[_Node], normalized: bool | None = True, weight: str | None = None, dtype: type = ..., solver: str = "full"
-): ...
+) -> dict[Incomplete, Incomplete]: ...
@_dispatchable
def edge_current_flow_betweenness_centrality(
G: Graph[_Node], normalized: bool | None = True, weight: str | None = None, dtype: type = ..., solver: str = "full"
-): ...
+) -> dict[tuple[Incomplete, Incomplete], float]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi
index 9fe21cad877d..b7f38a4c9b31 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi
@@ -1,3 +1,4 @@
+from _typeshed import Incomplete
from collections.abc import Iterable
from networkx.classes.graph import Graph, _Node
@@ -14,7 +15,7 @@ def current_flow_betweenness_centrality_subset(
weight: str | None = None,
dtype: type = ...,
solver: str = "lu",
-): ...
+) -> dict[Incomplete, float]: ...
@_dispatchable
def edge_current_flow_betweenness_centrality_subset(
G: Graph[_Node],
@@ -24,4 +25,4 @@ def edge_current_flow_betweenness_centrality_subset(
weight: str | None = None,
dtype: type = ...,
solver: str = "lu",
-): ...
+) -> dict[tuple[Incomplete, Incomplete], float]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi
index 00ff9c43f1b1..d7b95eeea326 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi
@@ -1,9 +1,13 @@
+from _typeshed import Incomplete
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
__all__ = ["current_flow_closeness_centrality", "information_centrality"]
@_dispatchable
-def current_flow_closeness_centrality(G: Graph[_Node], weight: str | None = None, dtype: type = ..., solver: str = "lu"): ...
+def current_flow_closeness_centrality(
+ G: Graph[_Node], weight: str | None = None, dtype: type = ..., solver: str = "lu"
+) -> dict[Incomplete, float]: ...
information_centrality = current_flow_closeness_centrality
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi
index 5e1af9216cf8..d0e6f96b92cb 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi
@@ -12,8 +12,8 @@ def eigenvector_centrality(
tol: float | None = 1e-06,
nstart: SupportsGetItem[Incomplete, Incomplete] | None = None,
weight: str | None = None,
-): ...
+) -> dict[Incomplete, float]: ...
@_dispatchable
def eigenvector_centrality_numpy(
G: Graph[_Node], weight: str | None = None, max_iter: int | None = 50, tol: float | None = 0
-): ...
+) -> dict[Incomplete, Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/group.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/group.pyi
index 0efcdbbe4dcf..1e0c00b226c5 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/group.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/group.pyi
@@ -26,12 +26,12 @@ def prominent_group(
endpoints: bool | None = False,
normalized: bool | None = True,
greedy: bool | None = False,
-): ...
+) -> tuple[float, list[Incomplete]]: ...
@_dispatchable
-def group_closeness_centrality(G: Graph[_Node], S: Iterable[Incomplete], weight: str | None = None): ...
+def group_closeness_centrality(G: Graph[_Node], S: Iterable[Incomplete], weight: str | None = None) -> float: ...
@_dispatchable
-def group_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]): ...
+def group_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]) -> float: ...
@_dispatchable
-def group_in_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]): ...
+def group_in_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]) -> float: ...
@_dispatchable
-def group_out_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]): ...
+def group_out_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]) -> float: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi
index 7b75d7ee75ee..4b00562653f8 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi
@@ -9,4 +9,4 @@ __all__ = ["harmonic_centrality"]
@_dispatchable
def harmonic_centrality(
G: Graph[_Node], nbunch: Iterable[Incomplete] | None = None, distance=None, sources: Iterable[Incomplete] | None = None
-): ...
+) -> dict[Incomplete, int]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/katz.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/katz.pyi
index 6f0f4f3bae8b..ca867e0d624a 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/katz.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/katz.pyi
@@ -15,7 +15,7 @@ def katz_centrality(
nstart: SupportsGetItem[Incomplete, Incomplete] | None = None,
normalized: bool | None = True,
weight: str | None = None,
-): ...
+) -> dict[Incomplete, Incomplete]: ...
@_dispatchable
def katz_centrality_numpy(
G: Graph[_Node],
@@ -23,4 +23,4 @@ def katz_centrality_numpy(
beta: float | SupportsGetItem[Incomplete, Incomplete] | None = 1.0,
normalized: bool = True,
weight: str | None = None,
-): ...
+) -> dict[Incomplete, Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/load.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/load.pyi
index cdec3b843e77..d59db805b08f 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/load.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/load.pyi
@@ -1,3 +1,5 @@
+from _typeshed import Incomplete
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
@@ -6,7 +8,7 @@ __all__ = ["load_centrality", "edge_load_centrality"]
@_dispatchable
def newman_betweenness_centrality(
G: Graph[_Node], v=None, cutoff: bool | None = None, normalized: bool | None = True, weight: str | None = None
-): ...
+) -> float | dict[Incomplete, float]: ...
load_centrality = newman_betweenness_centrality
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/percolation.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/percolation.pyi
index f6bee5c6bd05..cc5faab10f72 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/percolation.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/percolation.pyi
@@ -11,4 +11,4 @@ def percolation_centrality(
attribute: str | None = "percolation",
states: SupportsGetItem[Incomplete, Incomplete] | None = None,
weight: str | None = None,
-): ...
+) -> dict[Incomplete, float]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/reaching.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/reaching.pyi
index f99040b4f6ef..d5a6e1479aca 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/reaching.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/reaching.pyi
@@ -7,7 +7,7 @@ from networkx.utils.backends import _dispatchable
__all__ = ["global_reaching_centrality", "local_reaching_centrality"]
@_dispatchable
-def global_reaching_centrality(G: DiGraph[_Node], weight: str | None = None, normalized: bool | None = True): ...
+def global_reaching_centrality(G: DiGraph[_Node], weight: str | None = None, normalized: bool | None = True) -> float: ...
@_dispatchable
def local_reaching_centrality(
G: DiGraph[_Node],
@@ -15,4 +15,4 @@ def local_reaching_centrality(
paths: SupportsGetItem[Incomplete, Incomplete] | None = None,
weight: str | None = None,
normalized: bool | None = True,
-): ...
+) -> float: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/second_order.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/second_order.pyi
index cda7cac85c00..d6f64bcd4bda 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/second_order.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/second_order.pyi
@@ -1,7 +1,9 @@
+from _typeshed import Incomplete
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
__all__ = ["second_order_centrality"]
@_dispatchable
-def second_order_centrality(G: Graph[_Node], weight: str | None = "weight"): ...
+def second_order_centrality(G: Graph[_Node], weight: str | None = "weight") -> dict[Incomplete, float]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi
index 94075f2541b7..21671ced7d77 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi
@@ -1,13 +1,15 @@
+from _typeshed import Incomplete
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
__all__ = ["subgraph_centrality_exp", "subgraph_centrality", "communicability_betweenness_centrality", "estrada_index"]
@_dispatchable
-def subgraph_centrality_exp(G: Graph[_Node]): ...
+def subgraph_centrality_exp(G: Graph[_Node]) -> dict[Incomplete, float]: ...
@_dispatchable
-def subgraph_centrality(G: Graph[_Node]): ...
+def subgraph_centrality(G: Graph[_Node]) -> dict[Incomplete, float]: ...
@_dispatchable
-def communicability_betweenness_centrality(G: Graph[_Node]): ...
+def communicability_betweenness_centrality(G: Graph[_Node]) -> dict[Incomplete, Incomplete]: ...
@_dispatchable
-def estrada_index(G: Graph[_Node]): ...
+def estrada_index(G: Graph[_Node]) -> float: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/trophic.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/trophic.pyi
index f0ae0a5b53f1..4215c89b46d1 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/trophic.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/trophic.pyi
@@ -1,3 +1,5 @@
+from _typeshed import Incomplete
+
from networkx.classes.digraph import DiGraph
from networkx.classes.graph import _Node
from networkx.utils.backends import _dispatchable
@@ -5,8 +7,8 @@ from networkx.utils.backends import _dispatchable
__all__ = ["trophic_levels", "trophic_differences", "trophic_incoherence_parameter"]
@_dispatchable
-def trophic_levels(G: DiGraph[_Node], weight="weight"): ...
+def trophic_levels(G: DiGraph[_Node], weight="weight") -> dict[Incomplete, Incomplete]: ...
@_dispatchable
-def trophic_differences(G: DiGraph[_Node], weight="weight"): ...
+def trophic_differences(G: DiGraph[_Node], weight="weight") -> dict[Incomplete, Incomplete]: ...
@_dispatchable
-def trophic_incoherence_parameter(G: DiGraph[_Node], weight="weight", cannibalism: bool = False): ...
+def trophic_incoherence_parameter(G: DiGraph[_Node], weight="weight", cannibalism: bool = False) -> float: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi
index bf5969f63ea0..4dc2bb55728d 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi
@@ -1,7 +1,9 @@
+from _typeshed import Incomplete
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
__all__ = ["voterank"]
@_dispatchable
-def voterank(G: Graph[_Node], number_of_nodes: int | None = None): ...
+def voterank(G: Graph[_Node], number_of_nodes: int | None = None) -> list[Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/clique.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/clique.pyi
index 06405d42c2bf..c11b7d77d791 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/clique.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/clique.pyi
@@ -36,7 +36,7 @@ def node_clique_number(
def node_clique_number(G: Graph[_Node], nodes=None, cliques: Iterable[Incomplete] | None = None, separate_nodes=False) -> int: ...
def number_of_cliques(G, nodes=None, cliques=None) -> int | dict[Incomplete, Incomplete]: ...
@_dispatchable
-def max_weight_clique(G, weight="weight") -> tuple[Incomplete, Incomplete]: ...
+def max_weight_clique(G, weight="weight") -> tuple[list[Incomplete], int]: ...
class MaxWeightClique:
G: Graph[Incomplete]
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/cluster.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/cluster.pyi
index dfa594aca74b..15a497ec870d 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/cluster.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/cluster.pyi
@@ -1,3 +1,4 @@
+from _typeshed import Incomplete
from collections.abc import Iterable
from networkx.classes.graph import Graph, _Node
@@ -6,16 +7,16 @@ from networkx.utils.backends import _dispatchable
__all__ = ["triangles", "average_clustering", "clustering", "transitivity", "square_clustering", "generalized_degree"]
@_dispatchable
-def triangles(G: Graph[_Node], nodes=None): ...
+def triangles(G: Graph[_Node], nodes=None) -> int | dict[Incomplete, int]: ...
@_dispatchable
def average_clustering(
G: Graph[_Node], nodes: Iterable[_Node] | None = None, weight: str | None = None, count_zeros: bool = True
-): ...
+) -> float: ...
@_dispatchable
-def clustering(G: Graph[_Node], nodes=None, weight: str | None = None): ...
+def clustering(G: Graph[_Node], nodes=None, weight: str | None = None) -> float | int | dict[Incomplete, float | int]: ...
@_dispatchable
-def transitivity(G: Graph[_Node]): ...
+def transitivity(G: Graph[_Node]) -> float: ...
@_dispatchable
-def square_clustering(G: Graph[_Node], nodes: Iterable[_Node] | None = None): ...
+def square_clustering(G: Graph[_Node], nodes: Iterable[_Node] | None = None) -> float | int | dict[Incomplete, float | int]: ...
@_dispatchable
def generalized_degree(G: Graph[_Node], nodes: Iterable[_Node] | None = None): ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/communicability_alg.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/communicability_alg.pyi
index 4cbbc0adb2e4..93ab59130d37 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/communicability_alg.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/communicability_alg.pyi
@@ -1,9 +1,11 @@
+from _typeshed import Incomplete
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
__all__ = ["communicability", "communicability_exp"]
@_dispatchable
-def communicability(G: Graph[_Node]): ...
+def communicability(G: Graph[_Node]) -> dict[dict[Incomplete, Incomplete], dict[Incomplete, float]]: ...
@_dispatchable
-def communicability_exp(G: Graph[_Node]): ...
+def communicability_exp(G: Graph[_Node]) -> dict[dict[Incomplete, Incomplete], dict[Incomplete, float]]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi
index 5729204d3b82..2b3d11cc5a51 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi
@@ -1,3 +1,6 @@
+from _typeshed import Incomplete
+from collections.abc import Iterator
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
from numpy.random import RandomState
@@ -5,4 +8,4 @@ from numpy.random import RandomState
__all__ = ["asyn_fluidc"]
@_dispatchable
-def asyn_fluidc(G: Graph[_Node], k: int, max_iter: int = 100, seed: int | RandomState | None = None): ...
+def asyn_fluidc(G: Graph[_Node], k: int, max_iter: int = 100, seed: int | RandomState | None = None) -> Iterator[Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/label_propagation.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/label_propagation.pyi
index 23840b8cbde7..6d0148179871 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/label_propagation.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/label_propagation.pyi
@@ -1,3 +1,4 @@
+from _collections_abc import dict_values
from _typeshed import Incomplete
from collections.abc import Generator
@@ -14,4 +15,4 @@ def asyn_lpa_communities(
G: Graph[_Node], weight: str | None = None, seed: int | RandomState | None = None
) -> Generator[Incomplete, Incomplete, None]: ...
@_dispatchable
-def label_propagation_communities(G: Graph[_Node]): ...
+def label_propagation_communities(G: Graph[_Node]) -> dict_values[Incomplete, set[Incomplete]]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/louvain.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/louvain.pyi
index 40cf510a5845..103d4bf6e7d8 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/louvain.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/louvain.pyi
@@ -15,7 +15,7 @@ def louvain_communities(
threshold: float | None = 1e-07,
max_level: int | None = None,
seed: int | RandomState | None = None,
-): ...
+) -> list[set[Incomplete]]: ...
@_dispatchable
def louvain_partitions(
G: Graph[_Node],
@@ -23,4 +23,4 @@ def louvain_partitions(
resolution: float | None = 1,
threshold: float | None = 1e-07,
seed: int | RandomState | None = None,
-) -> Generator[Incomplete, None, None]: ...
+) -> Generator[list[set[Incomplete]], None, None]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/modularity_max.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/modularity_max.pyi
index 5cfedb7d5271..701054c23e97 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/modularity_max.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/modularity_max.pyi
@@ -1,3 +1,5 @@
+from _typeshed import Incomplete
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
@@ -6,6 +8,6 @@ __all__ = ["greedy_modularity_communities", "naive_greedy_modularity_communities
@_dispatchable
def greedy_modularity_communities(
G: Graph[_Node], weight: str | None = None, resolution: float | None = 1, cutoff: int | None = 1, best_n: int | None = None
-): ...
+) -> list[set[Incomplete]] | list[frozenset[Incomplete]]: ...
@_dispatchable
def naive_greedy_modularity_communities(G: Graph[_Node], resolution: float = 1, weight: str | None = None): ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/attracting.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/attracting.pyi
index 655b7d32f7b3..b4599cb049d5 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/attracting.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/attracting.pyi
@@ -1,16 +1,14 @@
-from _typeshed import Incomplete
from collections.abc import Generator
from networkx.classes.digraph import DiGraph
from networkx.classes.graph import _Node
-from networkx.classes.multidigraph import MultiDiGraph
from networkx.utils.backends import _dispatchable
__all__ = ["number_attracting_components", "attracting_components", "is_attracting_component"]
@_dispatchable
-def attracting_components(G) -> Generator[Incomplete, None, None]: ...
+def attracting_components(G: DiGraph[_Node]) -> Generator[set[_Node]]: ...
@_dispatchable
-def number_attracting_components(G): ...
+def number_attracting_components(G: DiGraph[_Node]) -> int: ...
@_dispatchable
-def is_attracting_component(G: DiGraph[_Node] | MultiDiGraph[_Node]) -> bool: ...
+def is_attracting_component(G: DiGraph[_Node]) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/biconnected.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/biconnected.pyi
index 80d10295496d..f6b5e78f1401 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/biconnected.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/biconnected.pyi
@@ -1,4 +1,3 @@
-from _typeshed import Incomplete
from collections.abc import Generator
from networkx.classes.graph import Graph, _Node
@@ -9,8 +8,8 @@ __all__ = ["biconnected_components", "biconnected_component_edges", "is_biconnec
@_dispatchable
def is_biconnected(G: Graph[_Node]) -> bool: ...
@_dispatchable
-def biconnected_component_edges(G: Graph[_Node]) -> Generator[Incomplete, Incomplete, None]: ...
+def biconnected_component_edges(G: Graph[_Node]) -> Generator[list[tuple[_Node, _Node]]]: ...
@_dispatchable
-def biconnected_components(G: Graph[_Node]) -> Generator[Incomplete, None, None]: ...
+def biconnected_components(G: Graph[_Node]) -> Generator[list[set[_Node]]]: ...
@_dispatchable
-def articulation_points(G: Graph[_Node]) -> Generator[Incomplete, None, None]: ...
+def articulation_points(G: Graph[_Node]) -> Generator[_Node]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/connected.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/connected.pyi
index 09256c0b6256..e19f09c06929 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/connected.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/connected.pyi
@@ -1,4 +1,3 @@
-from _typeshed import Incomplete
from collections.abc import Generator
from networkx.classes.graph import Graph, _Node
@@ -7,10 +6,10 @@ from networkx.utils.backends import _dispatchable
__all__ = ["number_connected_components", "connected_components", "is_connected", "node_connected_component"]
@_dispatchable
-def connected_components(G: Graph[_Node]) -> Generator[Incomplete, None, None]: ...
+def connected_components(G: Graph[_Node]) -> Generator[set[_Node]]: ...
@_dispatchable
-def number_connected_components(G: Graph[_Node]): ...
+def number_connected_components(G: Graph[_Node]) -> int: ...
@_dispatchable
def is_connected(G: Graph[_Node]) -> bool: ...
@_dispatchable
-def node_connected_component(G: Graph[_Node], n: _Node): ...
+def node_connected_component(G: Graph[_Node], n: _Node) -> set[_Node]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/semiconnected.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/semiconnected.pyi
index 17fc43bac7cf..f83e432c4075 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/semiconnected.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/semiconnected.pyi
@@ -1,7 +1,8 @@
-from networkx.classes.graph import Graph, _Node
+from networkx.classes.digraph import DiGraph
+from networkx.classes.graph import _Node
from networkx.utils.backends import _dispatchable
__all__ = ["is_semiconnected"]
@_dispatchable
-def is_semiconnected(G: Graph[_Node]) -> bool: ...
+def is_semiconnected(G: DiGraph[_Node]) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi
index 7bbf495ae517..bc0bb03a5970 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi
@@ -1,7 +1,7 @@
-from collections.abc import Generator
+from collections.abc import Generator, Iterable
from networkx.classes.digraph import DiGraph
-from networkx.classes.graph import Graph, _Node
+from networkx.classes.graph import _Node
from networkx.utils.backends import _dispatchable
__all__ = [
@@ -13,12 +13,12 @@ __all__ = [
]
@_dispatchable
-def strongly_connected_components(G: Graph[_Node]) -> Generator[set[_Node], None, None]: ...
+def strongly_connected_components(G: DiGraph[_Node]) -> Generator[set[_Node]]: ...
@_dispatchable
-def kosaraju_strongly_connected_components(G: Graph[_Node], source=None) -> Generator[set[_Node], None, None]: ...
+def kosaraju_strongly_connected_components(G: DiGraph[_Node], source: _Node | None = None) -> Generator[set[_Node]]: ...
@_dispatchable
-def number_strongly_connected_components(G: Graph[_Node]) -> int: ...
+def number_strongly_connected_components(G: DiGraph[_Node]) -> int: ...
@_dispatchable
-def is_strongly_connected(G: Graph[_Node]) -> bool: ...
+def is_strongly_connected(G: DiGraph[_Node]) -> bool: ...
@_dispatchable
-def condensation(G: DiGraph[_Node], scc=None) -> DiGraph[int]: ...
+def condensation(G: DiGraph[_Node], scc: Iterable[Iterable[_Node]] | None = None) -> DiGraph[int]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi
index b854f21acd06..ca026575a7e0 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi
@@ -1,13 +1,14 @@
from collections.abc import Generator
-from networkx.classes.graph import Graph, _Node
+from networkx.classes.digraph import DiGraph
+from networkx.classes.graph import _Node
from networkx.utils.backends import _dispatchable
__all__ = ["number_weakly_connected_components", "weakly_connected_components", "is_weakly_connected"]
@_dispatchable
-def weakly_connected_components(G: Graph[_Node]) -> Generator[set[_Node], None, None]: ...
+def weakly_connected_components(G: DiGraph[_Node]) -> Generator[set[_Node]]: ...
@_dispatchable
-def number_weakly_connected_components(G: Graph[_Node]) -> int: ...
+def number_weakly_connected_components(G: DiGraph[_Node]) -> int: ...
@_dispatchable
-def is_weakly_connected(G: Graph[_Node]) -> bool: ...
+def is_weakly_connected(G: DiGraph[_Node]) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi
index 8060b1e332c0..ca37ffb15d70 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi
@@ -31,11 +31,11 @@ def node_connectivity(
G: Graph[_Node], s: _Node | None = None, t: _Node | None = None, flow_func: Callable[..., Incomplete] | None = None
): ...
@_dispatchable
-def average_node_connectivity(G: Graph[_Node], flow_func: Callable[..., Incomplete] | None = None): ...
+def average_node_connectivity(G: Graph[_Node], flow_func: Callable[..., Incomplete] | None = None) -> float: ...
@_dispatchable
def all_pairs_node_connectivity(
G: Graph[_Node], nbunch: Iterable[Incomplete] | None = None, flow_func: Callable[..., Incomplete] | None = None
-): ...
+) -> dict[Incomplete, dict[Incomplete, Incomplete]]: ...
@_dispatchable
def local_edge_connectivity(
G: Graph[_Node],
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi
index d9c41c57195d..4170cc9d37cf 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi
@@ -1,5 +1,6 @@
from _typeshed import Incomplete
from collections.abc import Callable
+from typing_extensions import Never
from networkx.algorithms.flow import edmonds_karp
from networkx.classes.digraph import DiGraph
@@ -17,7 +18,7 @@ def minimum_st_edge_cut(
flow_func: Callable[..., Incomplete] | None = None,
auxiliary: DiGraph[_Node] | None = None,
residual: DiGraph[_Node] | None = None,
-): ...
+) -> set[tuple[Incomplete, Incomplete]]: ...
@_dispatchable
def minimum_st_node_cut(
G: Graph[_Node],
@@ -26,12 +27,12 @@ def minimum_st_node_cut(
flow_func: Callable[..., Incomplete] | None = None,
auxiliary: DiGraph[_Node] | None = None,
residual: DiGraph[_Node] | None = None,
-): ...
+) -> dict[Never, Never] | set[Incomplete]: ...
@_dispatchable
def minimum_node_cut(
G: Graph[_Node], s: _Node | None = None, t: _Node | None = None, flow_func: Callable[..., Incomplete] | None = None
-): ...
+) -> dict[Never, Never] | set[Incomplete]: ...
@_dispatchable
def minimum_edge_cut(
G: Graph[_Node], s: _Node | None = None, t: _Node | None = None, flow_func: Callable[..., Incomplete] | None = None
-): ...
+) -> set[Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi
index e4363950aadf..6b7c1e1a3b2a 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi
@@ -9,5 +9,5 @@ __all__ = ["k_components"]
default_flow_func = edmonds_karp
@_dispatchable
-def k_components(G: Graph[_Node], flow_func: Callable[..., Incomplete] | None = None): ...
+def k_components(G: Graph[_Node], flow_func: Callable[..., Incomplete] | None = None) -> dict[Incomplete, Incomplete]: ...
def build_k_number_dict(kcomps) -> dict[Incomplete, Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/core.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/core.pyi
index acd4b9b7a2f0..386a3c65b0cf 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/core.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/core.pyi
@@ -6,7 +6,7 @@ from networkx.utils.backends import _dispatchable
__all__ = ["core_number", "k_core", "k_shell", "k_crust", "k_corona", "k_truss", "onion_layers"]
@_dispatchable
-def core_number(G: Graph[_Node]): ...
+def core_number(G: Graph[_Node]) -> dict[Incomplete, Incomplete]: ...
@_dispatchable
def k_core(G: Graph[_Node], k: int | None = None, core_number: SupportsGetItem[Incomplete, Incomplete] | None = None): ...
@_dispatchable
@@ -18,4 +18,4 @@ def k_corona(G: Graph[_Node], k: int, core_number: SupportsGetItem[Incomplete, I
@_dispatchable
def k_truss(G: Graph[_Node], k: int): ...
@_dispatchable
-def onion_layers(G: Graph[_Node]): ...
+def onion_layers(G: Graph[_Node]) -> dict[Incomplete, Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/covering.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/covering.pyi
index 2bbc194af9d7..e10e1967bb6f 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/covering.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/covering.pyi
@@ -7,6 +7,6 @@ from networkx.utils.backends import _dispatchable
__all__ = ["min_edge_cover", "is_edge_cover"]
@_dispatchable
-def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable[..., Incomplete] | None = None): ...
+def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable[..., Incomplete] | None = None) -> set[Incomplete]: ...
@_dispatchable
def is_edge_cover(G: Graph[_Node], cover: Iterable[Iterable[Incomplete]]) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/cycles.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/cycles.pyi
index 0c4d9944f4fc..2890429d4516 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/cycles.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/cycles.pyi
@@ -1,8 +1,8 @@
-from _typeshed import Incomplete
from collections.abc import Generator
+from typing import Literal
from networkx.classes.digraph import DiGraph
-from networkx.classes.graph import Graph, _Node
+from networkx.classes.graph import Graph, _NBunch, _Node
from networkx.utils.backends import _dispatchable
__all__ = [
@@ -16,23 +16,18 @@ __all__ = [
]
@_dispatchable
-def cycle_basis(G: Graph[_Node], root: _Node | None = None): ...
+def cycle_basis(G: Graph[_Node], root: _Node | None = None) -> list[list[_Node]]: ...
@_dispatchable
-def simple_cycles(G: Graph[_Node], length_bound: int | None = None) -> Generator[Incomplete, Incomplete, None]: ...
-
-class _NeighborhoodCache(dict[Incomplete, Incomplete]):
- G: Incomplete
-
- def __init__(self, G) -> None: ...
- def __missing__(self, v): ...
-
+def simple_cycles(G: Graph[_Node], length_bound: int | None = None) -> Generator[list[_Node]]: ...
@_dispatchable
-def chordless_cycles(G: DiGraph[_Node], length_bound: int | None = None) -> Generator[Incomplete, Incomplete, None]: ...
+def chordless_cycles(G: DiGraph[_Node], length_bound: int | None = None) -> Generator[list[_Node]]: ...
@_dispatchable
-def recursive_simple_cycles(G: DiGraph[_Node]): ...
+def recursive_simple_cycles(G: DiGraph[_Node]) -> list[list[_Node]]: ...
@_dispatchable
-def find_cycle(G: Graph[_Node], source=None, orientation=None): ...
+def find_cycle(
+ G: Graph[_Node], source: _NBunch[_Node] = None, orientation: Literal["original", "reverse", "ignore"] | None = None
+): ...
@_dispatchable
-def minimum_cycle_basis(G: Graph[_Node], weight: str | None = None): ...
+def minimum_cycle_basis(G: Graph[_Node], weight: str | None = None) -> list[list[_Node]]: ...
@_dispatchable
-def girth(G) -> float | int: ...
+def girth(G: Graph[_Node]) -> float | int: ... # accepts any graph type
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/dag.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/dag.pyi
index b44d34db3690..ba6625a8fcc3 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/dag.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/dag.pyi
@@ -60,6 +60,6 @@ def dag_longest_path(
@_dispatchable
def dag_longest_path_length(G: DiGraph[_Node], weight: str | None = "weight", default_weight: int | None = 1) -> int: ...
@_dispatchable
-def dag_to_branching(G: Graph[_Node]) -> Graph[_Node]: ...
+def dag_to_branching(G: Graph[_Node]) -> DiGraph[_Node]: ...
@_dispatchable
def compute_v_structures(G) -> Generator[tuple[Incomplete, Incomplete, Incomplete]]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/distance_measures.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/distance_measures.pyi
index 26f5a618fdd9..8043d3647d19 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/distance_measures.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/distance_measures.pyi
@@ -1,4 +1,4 @@
-from collections.abc import Callable
+from collections.abc import Callable, Mapping
from typing_extensions import TypeAlias
from networkx.classes.graph import Graph, _Node
@@ -20,22 +20,44 @@ __all__ = [
]
@_dispatchable
-def eccentricity(G: Graph[_Node], v: _Node | None = None, sp=None, weight: str | _WeightFunction | None = None): ...
+def eccentricity(
+ G: Graph[_Node],
+ v: _Node | None = None,
+ sp: Mapping[_Node, Mapping[_Node, int]] | None = None,
+ weight: str | _WeightFunction | None = None,
+) -> int | dict[_Node, int]: ... # TODO: overload on v: dict if v is None else int
@_dispatchable
-def diameter(G: Graph[_Node], e=None, usebounds: bool = False, weight: str | _WeightFunction | None = None): ...
+def diameter(
+ G: Graph[_Node], e: Mapping[_Node, int] | None = None, usebounds: bool = False, weight: str | _WeightFunction | None = None
+) -> int: ...
@_dispatchable
-def harmonic_diameter(G, sp=None, *, weight: str | _WeightFunction | None = None) -> float: ...
+def harmonic_diameter(
+ G: Graph[_Node], sp: Mapping[_Node, Mapping[_Node, int]] | None = None, *, weight: str | _WeightFunction | None = None
+) -> float: ...
@_dispatchable
-def periphery(G: Graph[_Node], e=None, usebounds: bool = False, weight: str | _WeightFunction | None = None): ...
+def periphery(
+ G: Graph[_Node], e: Mapping[_Node, int] | None = None, usebounds: bool = False, weight: str | _WeightFunction | None = None
+) -> list[_Node]: ...
@_dispatchable
-def radius(G: Graph[_Node], e=None, usebounds: bool = False, weight: str | _WeightFunction | None = None): ...
+def radius(
+ G: Graph[_Node], e: Mapping[_Node, int] | None = None, usebounds: bool = False, weight: str | _WeightFunction | None = None
+) -> int: ...
@_dispatchable
-def center(G: Graph[_Node], e=None, usebounds: bool = False, weight: str | _WeightFunction | None = None): ...
+def center(
+ G: Graph[_Node], e: Mapping[_Node, int] | None = None, usebounds: bool = False, weight: str | _WeightFunction | None = None
+) -> list[_Node]: ...
@_dispatchable
-def barycenter(G, weight: str | _WeightFunction | None = None, attr=None, sp=None): ...
+def barycenter(
+ G: Graph[_Node],
+ weight: str | _WeightFunction | None = None,
+ attr: str | None = None,
+ sp: Mapping[_Node, Mapping[_Node, int]] | None = None,
+) -> list[_Node]: ...
@_dispatchable
-def resistance_distance(G: Graph[_Node], nodeA=None, nodeB=None, weight: str | None = None, invert_weight: bool = True): ...
+def resistance_distance(
+ G: Graph[_Node], nodeA: _Node | None = None, nodeB: _Node | None = None, weight: str | None = None, invert_weight: bool = True
+) -> float | dict[_Node, float]: ... # TODO: overload on the nodes: float if both are specified else dict
@_dispatchable
-def effective_graph_resistance(G, weight: str | None = None, invert_weight: bool = True) -> float: ...
+def effective_graph_resistance(G: Graph[_Node], weight: str | None = None, invert_weight: bool = True) -> float: ...
@_dispatchable
-def kemeny_constant(G, *, weight: str | None = None) -> float: ...
+def kemeny_constant(G: Graph[_Node], *, weight: str | None = None) -> float: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/distance_regular.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/distance_regular.pyi
index 4fd942c5f6d9..9061e2e596ce 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/distance_regular.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/distance_regular.pyi
@@ -1,3 +1,6 @@
+from _typeshed import Incomplete
+from collections.abc import Generator
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
@@ -6,7 +9,7 @@ __all__ = ["is_distance_regular", "is_strongly_regular", "intersection_array", "
@_dispatchable
def is_distance_regular(G: Graph[_Node]) -> bool: ...
@_dispatchable
-def global_parameters(b, c): ...
+def global_parameters(b, c) -> Generator[tuple[Incomplete, Incomplete, Incomplete]]: ...
@_dispatchable
def intersection_array(G: Graph[_Node]): ...
@_dispatchable
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/efficiency_measures.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/efficiency_measures.pyi
index 13369a99ef06..8c2205b20e5f 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/efficiency_measures.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/efficiency_measures.pyi
@@ -4,8 +4,8 @@ from networkx.utils.backends import _dispatchable
__all__ = ["efficiency", "local_efficiency", "global_efficiency"]
@_dispatchable
-def efficiency(G, u: _Node, v: _Node): ...
+def efficiency(G, u: _Node, v: _Node) -> float: ...
@_dispatchable
-def global_efficiency(G): ...
+def global_efficiency(G) -> float: ...
@_dispatchable
-def local_efficiency(G): ...
+def local_efficiency(G) -> float: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/mincost.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/mincost.pyi
index 86c8e66dcd6c..7ca50162d01a 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/mincost.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/mincost.pyi
@@ -6,10 +6,16 @@ from networkx.utils.backends import _dispatchable
__all__ = ["min_cost_flow_cost", "min_cost_flow", "cost_of_flow", "max_flow_min_cost"]
@_dispatchable
-def min_cost_flow_cost(G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ...
+def min_cost_flow_cost(
+ G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight"
+) -> int | float: ...
@_dispatchable
-def min_cost_flow(G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ...
+def min_cost_flow(
+ G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight"
+) -> dict[Incomplete, dict[Incomplete, Incomplete]]: ...
@_dispatchable
-def cost_of_flow(G: Graph[_Node], flowDict: SupportsGetItem[Incomplete, Incomplete], weight: str = "weight"): ...
+def cost_of_flow(G: Graph[_Node], flowDict: SupportsGetItem[Incomplete, Incomplete], weight: str = "weight") -> int | float: ...
@_dispatchable
-def max_flow_min_cost(G: Graph[_Node], s: str, t: str, capacity: str = "capacity", weight: str = "weight"): ...
+def max_flow_min_cost(
+ G: Graph[_Node], s: str, t: str, capacity: str = "capacity", weight: str = "weight"
+) -> dict[Incomplete, dict[Incomplete, Incomplete]]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi
index c6028757f936..788176935ea5 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi
@@ -43,4 +43,6 @@ class _DataEssentialsAndFunctions:
def find_leaving_edge(self, Wn, We): ...
@_dispatchable
-def network_simplex(G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ...
+def network_simplex(
+ G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight"
+) -> tuple[int | Incomplete, dict[Incomplete, dict[Incomplete, Incomplete]]]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/utils.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/utils.pyi
index cd5bdaf4bfa2..a935bc29b572 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/utils.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/utils.pyi
@@ -5,11 +5,13 @@ from networkx.utils.backends import _dispatchable
__all__ = ["CurrentEdge", "Level", "GlobalRelabelThreshold", "build_residual_network", "detect_unboundedness", "build_flow_dict"]
class CurrentEdge:
+ __slots__ = ("_edges", "_it", "_curr")
def __init__(self, edges) -> None: ...
def get(self): ...
def move_to_next(self) -> None: ...
class Level:
+ __slots__ = ("active", "inactive")
active: Incomplete
inactive: Incomplete
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/graph_hashing.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/graph_hashing.pyi
index 7232060d585f..9829cc627f79 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/graph_hashing.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/graph_hashing.pyi
@@ -1,3 +1,5 @@
+from _typeshed import Incomplete
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
@@ -10,7 +12,7 @@ def weisfeiler_lehman_graph_hash(
node_attr: str | None = None,
iterations: int | None = 3,
digest_size: int | None = 16,
-): ...
+) -> str: ...
@_dispatchable
def weisfeiler_lehman_subgraph_hashes(
G: Graph[_Node],
@@ -19,4 +21,4 @@ def weisfeiler_lehman_subgraph_hashes(
iterations: int | None = 3,
digest_size: int | None = 16,
include_initial_labels: bool | None = False,
-): ...
+) -> dict[Incomplete, list[str]]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/hierarchy.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/hierarchy.pyi
index e982bfa88a4f..745e0bd1d921 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/hierarchy.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/hierarchy.pyi
@@ -3,4 +3,4 @@ from networkx.utils.backends import _dispatchable
__all__ = ["flow_hierarchy"]
@_dispatchable
-def flow_hierarchy(G, weight: str | None = None): ...
+def flow_hierarchy(G, weight: str | None = None) -> float: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isolate.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isolate.pyi
index afcd43f5f879..95a78fa04f4d 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isolate.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isolate.pyi
@@ -8,4 +8,4 @@ def is_isolate(G: Graph[_Node], n: _Node) -> bool: ...
@_dispatchable
def isolates(G: Graph[_Node]): ...
@_dispatchable
-def number_of_isolates(G: Graph[_Node]): ...
+def number_of_isolates(G: Graph[_Node]) -> int: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi
index a16ea3e8ba11..76b00f5fd01c 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi
@@ -14,6 +14,6 @@ class ISMAGS:
def largest_common_subgraph(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, None]: ...
def analyze_symmetry(self, graph, node_partitions, edge_colors): ...
def is_isomorphic(self, symmetry: bool = False) -> bool: ...
- def subgraph_is_isomorphic(self, symmetry: bool = False): ...
+ def subgraph_is_isomorphic(self, symmetry: bool = False) -> bool: ...
def isomorphisms_iter(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, None]: ...
def subgraph_isomorphisms_iter(self, symmetry: bool = True): ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi
index 7a193aa7fdd8..858ac56d06e8 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi
@@ -1,3 +1,5 @@
+from _typeshed import Incomplete
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
@@ -6,6 +8,6 @@ __all__ = ["rooted_tree_isomorphism", "tree_isomorphism"]
@_dispatchable
def root_trees(t1, root1, t2, root2): ...
@_dispatchable
-def rooted_tree_isomorphism(t1, root1, t2, root2): ...
+def rooted_tree_isomorphism(t1, root1, t2, root2) -> list[tuple[Incomplete, Incomplete]]: ...
@_dispatchable
-def tree_isomorphism(t1: Graph[_Node], t2: Graph[_Node]): ...
+def tree_isomorphism(t1: Graph[_Node], t2: Graph[_Node]) -> list[tuple[Incomplete, Incomplete]]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi
index 93a97d20ea4b..fca4adccedf9 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi
@@ -16,7 +16,7 @@ def pagerank(
nstart: SupportsGetItem[Incomplete, Incomplete] | None = None,
weight: str | None = "weight",
dangling: SupportsGetItem[Incomplete, Incomplete] | None = None,
-): ...
+) -> dict[Incomplete, float]: ...
@_dispatchable
def google_matrix(
G: Graph[_Node],
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/matching.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/matching.pyi
index ee66595d0542..e55e966ed3ca 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/matching.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/matching.pyi
@@ -14,7 +14,7 @@ __all__ = [
]
@_dispatchable
-def maximal_matching(G: Graph[_Node]): ...
+def maximal_matching(G: Graph[_Node]) -> set[Incomplete]: ...
def matching_dict_to_set(matching: Mapping[Incomplete, Incomplete]) -> set[Incomplete]: ...
@_dispatchable
def is_matching(G: Graph[_Node], matching: dict[Incomplete, Incomplete] | Iterable[Iterable[Incomplete]]) -> bool: ...
@@ -23,6 +23,8 @@ def is_maximal_matching(G: Graph[_Node], matching: dict[Incomplete, Incomplete]
@_dispatchable
def is_perfect_matching(G: Graph[_Node], matching: dict[Incomplete, Incomplete] | Iterable[Iterable[Incomplete]]) -> bool: ...
@_dispatchable
-def min_weight_matching(G: Graph[_Node], weight: str | None = "weight"): ...
+def min_weight_matching(G: Graph[_Node], weight: str | None = "weight") -> set[Incomplete]: ...
@_dispatchable
-def max_weight_matching(G: Graph[_Node], maxcardinality: bool | None = False, weight: str | None = "weight"): ...
+def max_weight_matching(
+ G: Graph[_Node], maxcardinality: bool | None = False, weight: str | None = "weight"
+) -> set[Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/minors/contraction.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/minors/contraction.pyi
index 71106f406ea0..0d94d40a8e89 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/minors/contraction.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/minors/contraction.pyi
@@ -1,5 +1,5 @@
from _typeshed import Incomplete
-from collections.abc import Callable
+from collections.abc import Callable, Iterable
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
@@ -7,7 +7,7 @@ from networkx.utils.backends import _dispatchable
__all__ = ["contracted_edge", "contracted_nodes", "equivalence_classes", "identified_nodes", "quotient_graph"]
@_dispatchable
-def equivalence_classes(iterable, relation): ...
+def equivalence_classes(iterable: Iterable[_Node], relation: Callable[[_Node, _Node], bool]) -> set[frozenset[_Node]]: ...
@_dispatchable
def quotient_graph(
G: Graph[_Node],
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/mis.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/mis.pyi
index bbe4abaeb266..b0b6a9914384 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/mis.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/mis.pyi
@@ -10,4 +10,4 @@ __all__ = ["maximal_independent_set"]
@_dispatchable
def maximal_independent_set(
G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, seed: int | RandomState | None = None
-): ...
+) -> list[Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/planar_drawing.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/planar_drawing.pyi
index 5bf598392b16..d4c6164ed122 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/planar_drawing.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/planar_drawing.pyi
@@ -6,7 +6,7 @@ from networkx.utils.backends import _dispatchable
__all__ = ["combinatorial_embedding_to_pos"]
@_dispatchable
-def combinatorial_embedding_to_pos(embedding, fully_triangulate: bool = False): ...
+def combinatorial_embedding_to_pos(embedding, fully_triangulate: bool = False) -> dict[Incomplete, Incomplete]: ...
def set_position(parent, tree, remaining_nodes, delta_x, y_coordinate, pos): ...
def get_canonical_ordering(embedding, outer_face: Sequence[Incomplete]) -> list[Incomplete]: ...
def triangulate_face(embedding, v1, v2): ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/planarity.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/planarity.pyi
index f444db48762a..8fbb3f260c57 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/planarity.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/planarity.pyi
@@ -34,6 +34,26 @@ class ConflictPair:
def lowest(self, planarity_state): ...
class LRPlanarity:
+ __slots__ = [
+ "G",
+ "roots",
+ "height",
+ "lowpt",
+ "lowpt2",
+ "nesting_depth",
+ "parent_edge",
+ "DG",
+ "adjs",
+ "ordered_adjs",
+ "ref",
+ "side",
+ "S",
+ "stack_bottom",
+ "lowpt_edge",
+ "left_ref",
+ "right_ref",
+ "embedding",
+ ]
G: Incomplete
roots: Incomplete
height: Incomplete
@@ -54,7 +74,7 @@ class LRPlanarity:
embedding: Incomplete
def __init__(self, G) -> None: ...
- def lr_planarity(self): ...
+ def lr_planarity(self) -> PlanarEmbedding[Incomplete] | None: ...
def lr_planarity_recursive(self): ...
def dfs_orientation(self, v): ...
def dfs_orientation_recursive(self, v) -> None: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/reciprocity.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/reciprocity.pyi
index 2208e9e00507..de7191d31c0e 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/reciprocity.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/reciprocity.pyi
@@ -1,3 +1,4 @@
+from _typeshed import Incomplete
from collections.abc import Iterable
from networkx.classes.graph import Graph, _Node
@@ -6,6 +7,6 @@ from networkx.utils.backends import _dispatchable
__all__ = ["reciprocity", "overall_reciprocity"]
@_dispatchable
-def reciprocity(G: Graph[_Node], nodes: Iterable[_Node] | None = None): ...
+def reciprocity(G: Graph[_Node], nodes: Iterable[_Node] | None = None) -> float | dict[Incomplete, float | None]: ...
@_dispatchable
def overall_reciprocity(G: Graph[_Node]): ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/richclub.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/richclub.pyi
index abf5cd680b9a..2f2b25d7b987 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/richclub.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/richclub.pyi
@@ -1,3 +1,5 @@
+from _typeshed import Incomplete
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
from numpy.random import RandomState
@@ -5,4 +7,6 @@ from numpy.random import RandomState
__all__ = ["rich_club_coefficient"]
@_dispatchable
-def rich_club_coefficient(G: Graph[_Node], normalized: bool = True, Q: float = 100, seed: int | RandomState | None = None): ...
+def rich_club_coefficient(
+ G: Graph[_Node], normalized: bool = True, Q: float = 100, seed: int | RandomState | None = None
+) -> dict[Incomplete, Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi
index 0faccba54c02..037db5b93ef9 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi
@@ -1,7 +1,6 @@
-from _typeshed import Incomplete, SupportsGetItem
from collections.abc import Callable
-from typing import Any
+from networkx.algorithms.shortest_paths.weighted import _WeightFunc
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
@@ -12,18 +11,18 @@ def astar_path(
G: Graph[_Node],
source: _Node,
target: _Node,
- heuristic: Callable[..., Incomplete] | None = None,
- weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
+ heuristic: Callable[[_Node, _Node], float] | None = None,
+ weight: str | _WeightFunc[_Node] | None = "weight",
*,
cutoff: float | None = None,
-): ...
+) -> list[_Node]: ...
@_dispatchable
def astar_path_length(
G: Graph[_Node],
source: _Node,
target: _Node,
- heuristic: Callable[..., Incomplete] | None = None,
- weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
+ heuristic: Callable[[_Node, _Node], float] | None = None,
+ weight: str | _WeightFunc[_Node] | None = "weight",
*,
cutoff: float | None = None,
-): ...
+) -> float: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi
index ce36193312ab..96c6399f63cb 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi
@@ -1,4 +1,5 @@
from _typeshed import Incomplete, SupportsGetItem
+from collections import defaultdict
from collections.abc import Collection
from networkx.classes.graph import Graph, _Node
@@ -9,8 +10,10 @@ __all__ = ["floyd_warshall", "floyd_warshall_predecessor_and_distance", "reconst
@_dispatchable
def floyd_warshall_numpy(G: Graph[_Node], nodelist: Collection[_Node] | None = None, weight: str | None = "weight"): ...
@_dispatchable
-def floyd_warshall_predecessor_and_distance(G: Graph[_Node], weight: str | None = "weight"): ...
+def floyd_warshall_predecessor_and_distance(
+ G: Graph[_Node], weight: str | None = "weight"
+) -> tuple[dict[Incomplete, dict[Incomplete, Incomplete]], dict[Incomplete, dict[Incomplete, float]]]: ...
@_dispatchable
-def reconstruct_path(source: _Node, target: _Node, predecessors: SupportsGetItem[Incomplete, Incomplete]): ...
+def reconstruct_path(source: _Node, target: _Node, predecessors: SupportsGetItem[Incomplete, Incomplete]) -> list[Incomplete]: ...
@_dispatchable
-def floyd_warshall(G: Graph[_Node], weight: str | None = "weight"): ...
+def floyd_warshall(G: Graph[_Node], weight: str | None = "weight") -> dict[Incomplete, defaultdict[Incomplete, float]]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi
index 0857f5602331..a768381fb942 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi
@@ -1,7 +1,7 @@
-from _typeshed import Incomplete
-from collections.abc import Callable, Generator
+from collections.abc import Generator
from typing import overload
+from networkx.algorithms.shortest_paths.weighted import _WeightFunc
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
@@ -17,55 +17,129 @@ __all__ = [
@_dispatchable
def has_path(G: Graph[_Node], source: _Node, target: _Node) -> bool: ...
-@overload
+@overload # both source and target are specified => (s -> t)
def shortest_path(
- G: Graph[_Node],
- source: _Node | None = None,
- target: _Node | None = None,
- weight: str | Callable[..., Incomplete] | None = None,
- method: str | None = "dijkstra",
-) -> list[_Node]: ...
-@overload
-def shortest_path(
- G: Graph[_Node],
- source: _Node | None = None,
- target: _Node | None = None,
- weight: str | Callable[..., Incomplete] | None = None,
- method: str | None = "dijkstra",
-) -> dict[_Node, list[_Node]]: ...
-@overload
-def shortest_path(
- G: Graph[_Node],
- source: _Node | None = None,
- target: _Node | None = None,
- weight: str | Callable[..., Incomplete] | None = None,
- method: str | None = "dijkstra",
-) -> dict[_Node, list[_Node]]: ...
-@_dispatchable
-def shortest_path_length(
- G: Graph[_Node],
- source: _Node | None = None,
- target: _Node | None = None,
- weight: str | Callable[..., Incomplete] | None = None,
- method: str | None = "dijkstra",
-): ...
-@_dispatchable
-def average_shortest_path_length(
- G: Graph[_Node], weight: str | Callable[..., Incomplete] | None = None, method: str | None = None
-): ...
-@_dispatchable
-def all_shortest_paths(
G: Graph[_Node],
source: _Node,
target: _Node,
- weight: str | Callable[..., Incomplete] | None = None,
+ weight: str | _WeightFunc[_Node] | None = None,
method: str | None = "dijkstra",
-) -> Generator[list[_Node], None, None]: ...
+ *,
+ backend: str | None = None,
+ **backend_kwargs,
+) -> list[_Node]: ...
+@overload # only source is specified => {t1: (s -> t), t2: (s -> t), ...}
+def shortest_path(
+ G: Graph[_Node],
+ source: _Node,
+ target: None = None,
+ weight: str | _WeightFunc[_Node] | None = None,
+ method: str | None = "dijkstra",
+ *,
+ backend: str | None = None,
+ **backend_kwargs,
+) -> dict[_Node, list[_Node]]: ...
+@overload # only target is specified (positional) => {s1: (s1 -> t), s2: (s2 -> t), ...}
+def shortest_path(
+ G: Graph[_Node],
+ source: None,
+ target: _Node,
+ weight: str | _WeightFunc[_Node] | None = None,
+ method: str | None = "dijkstra",
+ *,
+ backend: str | None = None,
+ **backend_kwargs,
+) -> dict[_Node, list[_Node]]: ...
+@overload # only target is specified (keyword) => {s1: (s1 -> t), s2: (s2 -> t), ...}
+def shortest_path(
+ G: Graph[_Node],
+ source: None = None,
+ *,
+ target: _Node,
+ weight: str | _WeightFunc[_Node] | None = None,
+ method: str | None = "dijkstra",
+ backend: str | None = None,
+ **backend_kwargs,
+) -> dict[_Node, list[_Node]]: ...
+@overload
+def shortest_path( # source and target are not specified => generator of (t, {s1: (s1 -> t), s2: (s2 -> t), ...})
+ G: Graph[_Node],
+ source: None = None,
+ target: None = None,
+ weight: str | _WeightFunc[_Node] | None = None,
+ method: str | None = "dijkstra",
+ *,
+ backend: str | None = None,
+ **backend_kwargs,
+) -> Generator[tuple[_Node, dict[str, list[_Node]]]]: ...
+@overload # both source and target are specified => len(s -> t)
+def shortest_path_length(
+ G: Graph[_Node],
+ source: _Node,
+ target: _Node,
+ weight: str | _WeightFunc[_Node] | None = None,
+ method: str | None = "dijkstra",
+ *,
+ backend: str | None = None,
+ **backend_kwargs,
+) -> float: ...
+@overload # only source is specified => {t1: len(s -> t1), t2: len(s -> t2), ...}
+def shortest_path_length(
+ G: Graph[_Node],
+ source: _Node,
+ target: None = None,
+ weight: str | _WeightFunc[_Node] | None = None,
+ method: str | None = "dijkstra",
+ *,
+ backend: str | None = None,
+ **backend_kwargs,
+) -> dict[_Node, float]: ...
+@overload # only target is specified (positional) => {s1: len(s1 -> t), s2: len(s2 -> t), ...}
+def shortest_path_length(
+ G: Graph[_Node],
+ source: None,
+ target: _Node,
+ weight: str | _WeightFunc[_Node] | None = None,
+ method: str | None = "dijkstra",
+ *,
+ backend: str | None = None,
+ **backend_kwargs,
+) -> dict[_Node, float]: ...
+@overload # only target is specified (keyword) => {s1: len(s1 -> t), s2: len(s2 -> t), ...}
+def shortest_path_length(
+ G: Graph[_Node],
+ source: None = None,
+ *,
+ target: _Node,
+ weight: str | _WeightFunc[_Node] | None = None,
+ method: str | None = "dijkstra",
+ backend: str | None = None,
+ **backend_kwargs,
+) -> dict[_Node, float]: ...
+@overload
+def shortest_path_length( # source and target are not specified => generator of (t, {s1: len(s1 -> t), s2: len(s2 -> t), ...})
+ G: Graph[_Node],
+ source: None = None,
+ target: None = None,
+ weight: str | _WeightFunc[_Node] | None = None,
+ method: str | None = "dijkstra",
+ *,
+ backend: str | None = None,
+ **backend_kwargs,
+) -> Generator[tuple[_Node, dict[_Node, float]]]: ...
+@_dispatchable
+def average_shortest_path_length(
+ G: Graph[_Node], weight: str | _WeightFunc[_Node] | None = None, method: str | None = None
+) -> float: ...
+@_dispatchable
+def all_shortest_paths(
+ G: Graph[_Node], source: _Node, target: _Node, weight: str | _WeightFunc[_Node] | None = None, method: str | None = "dijkstra"
+) -> Generator[list[_Node]]: ...
@_dispatchable
def single_source_all_shortest_paths(
- G, source, weight=None, method="dijkstra"
-) -> Generator[tuple[Incomplete, list[list[Incomplete]]]]: ...
+ G: Graph[_Node], source: _Node, weight: str | _WeightFunc[_Node] | None = None, method: str | None = "dijkstra"
+) -> Generator[tuple[_Node, list[list[_Node]]]]: ...
@_dispatchable
def all_pairs_all_shortest_paths(
- G, weight=None, method="dijkstra"
-) -> Generator[tuple[Incomplete, dict[Incomplete, Incomplete]]]: ...
+ G: Graph[_Node], weight: str | _WeightFunc[_Node] | None = None, method: str | None = "dijkstra"
+) -> Generator[tuple[_Node, dict[_Node, list[list[_Node]]]]]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi
index 7b5248b19985..e7008bdc9b2b 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi
@@ -16,19 +16,25 @@ __all__ = [
]
@_dispatchable
-def single_source_shortest_path_length(G: Graph[_Node], source: _Node, cutoff: int | None = None): ...
+def single_source_shortest_path_length(G: Graph[_Node], source: _Node, cutoff: int | None = None) -> dict[Incomplete, int]: ...
@_dispatchable
def single_target_shortest_path_length(G: Graph[_Node], target: _Node, cutoff: int | None = None): ...
@_dispatchable
def all_pairs_shortest_path_length(G: Graph[_Node], cutoff: int | None = None) -> Generator[Incomplete, None, None]: ...
@_dispatchable
-def bidirectional_shortest_path(G: Graph[_Node], source: _Node, target: _Node): ...
+def bidirectional_shortest_path(G: Graph[_Node], source: _Node, target: _Node) -> list[Incomplete]: ...
@_dispatchable
-def single_source_shortest_path(G: Graph[_Node], source: _Node, cutoff: int | None = None): ...
+def single_source_shortest_path(
+ G: Graph[_Node], source: _Node, cutoff: int | None = None
+) -> dict[Incomplete, list[Incomplete]]: ...
@_dispatchable
-def single_target_shortest_path(G: Graph[_Node], target: _Node, cutoff: int | None = None): ...
+def single_target_shortest_path(
+ G: Graph[_Node], target: _Node, cutoff: int | None = None
+) -> dict[Incomplete, list[Incomplete]]: ...
@_dispatchable
-def all_pairs_shortest_path(G: Graph[_Node], cutoff: int | None = None) -> Generator[Incomplete, None, None]: ...
+def all_pairs_shortest_path(
+ G: Graph[_Node], cutoff: int | None = None
+) -> Generator[tuple[Incomplete, dict[Incomplete, list[Incomplete]]]]: ...
@_dispatchable
def predecessor(
G: Graph[_Node], source: _Node, target: _Node | None = None, cutoff: int | None = None, return_seen: bool | None = None
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi
index 28fb31c561ec..5eb7445b0065 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi
@@ -1,6 +1,6 @@
-from _typeshed import Incomplete, SupportsGetItem
-from collections.abc import Callable, Generator
+from collections.abc import Callable, Collection, Generator
from typing import Any
+from typing_extensions import TypeAlias
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
@@ -33,154 +33,114 @@ __all__ = [
"johnson",
]
+_WeightFunc: TypeAlias = Callable[
+ [_Node, _Node, dict[str, Any]], # Any: type of edge data cannot be known statically
+ float | None, # the weight or None to indicate a hidden edge
+]
+
@_dispatchable
def dijkstra_path(
- G: Graph[_Node],
- source: _Node,
- target: _Node,
- weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
-): ...
+ G: Graph[_Node], source: _Node, target: _Node, weight: str | _WeightFunc[_Node] | None = "weight"
+) -> list[_Node]: ...
@_dispatchable
def dijkstra_path_length(
- G: Graph[_Node],
- source: _Node,
- target: _Node,
- weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
-): ...
+ G: Graph[_Node], source: _Node, target: _Node, weight: str | _WeightFunc[_Node] | None = "weight"
+) -> float: ...
@_dispatchable
def single_source_dijkstra_path(
- G: Graph[_Node],
- source: _Node,
- cutoff: float | None = None,
- weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
-): ...
+ G: Graph[_Node], source: _Node, cutoff: float | None = None, weight: str | _WeightFunc[_Node] | None = "weight"
+) -> dict[_Node, list[_Node]]: ...
@_dispatchable
def single_source_dijkstra_path_length(
- G: Graph[_Node],
- source: _Node,
- cutoff: float | None = None,
- weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
-): ...
+ G: Graph[_Node], source: _Node, cutoff: float | None = None, weight: str | _WeightFunc[_Node] | None = "weight"
+) -> dict[_Node, float]: ...
@_dispatchable
def single_source_dijkstra(
G: Graph[_Node],
source: _Node,
target: _Node | None = None,
cutoff: float | None = None,
- weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
-): ...
+ weight: str | _WeightFunc[_Node] | None = "weight",
+) -> tuple[dict[_Node, float], dict[_Node, list[_Node]]] | tuple[float, list[_Node]]: ... # TODO: overload on target
@_dispatchable
def multi_source_dijkstra_path(
- G: Graph[_Node],
- sources,
- cutoff: float | None = None,
- weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
-): ...
+ G: Graph[_Node], sources: Collection[_Node], cutoff: float | None = None, weight: str | _WeightFunc[_Node] | None = "weight"
+) -> dict[_Node, list[_Node]]: ...
@_dispatchable
def multi_source_dijkstra_path_length(
- G: Graph[_Node],
- sources,
- cutoff: float | None = None,
- weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
-): ...
+ G: Graph[_Node], sources: Collection[_Node], cutoff: float | None = None, weight: str | _WeightFunc[_Node] | None = "weight"
+) -> dict[_Node, float]: ...
@_dispatchable
def multi_source_dijkstra(
G: Graph[_Node],
- sources,
+ sources: Collection[_Node],
target: _Node | None = None,
cutoff: float | None = None,
- weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
-): ...
+ weight: str | _WeightFunc[_Node] | None = "weight",
+) -> tuple[dict[_Node, float], dict[_Node, list[_Node]]] | tuple[float, list[_Node]]: ... # TODO: overload on target
@_dispatchable
def dijkstra_predecessor_and_distance(
- G: Graph[_Node],
- source: _Node,
- cutoff: float | None = None,
- weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
-): ...
+ G: Graph[_Node], source: _Node, cutoff: float | None = None, weight: str | _WeightFunc[_Node] | None = "weight"
+) -> tuple[dict[_Node, list[_Node]], dict[_Node, float]]: ...
@_dispatchable
def all_pairs_dijkstra(
- G: Graph[_Node],
- cutoff: float | None = None,
- weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
-) -> Generator[Incomplete, None, None]: ...
+ G: Graph[_Node], cutoff: float | None = None, weight: str | _WeightFunc[_Node] | None = "weight"
+) -> Generator[tuple[_Node, tuple[dict[_Node, float], dict[_Node, list[_Node]]]]]: ...
@_dispatchable
def all_pairs_dijkstra_path_length(
- G: Graph[_Node],
- cutoff: float | None = None,
- weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
-) -> Generator[Incomplete, None, None]: ...
+ G: Graph[_Node], cutoff: float | None = None, weight: str | _WeightFunc[_Node] | None = "weight"
+) -> Generator[tuple[_Node, dict[_Node, float]]]: ...
@_dispatchable
def all_pairs_dijkstra_path(
- G: Graph[_Node],
- cutoff: float | None = None,
- weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
-) -> Generator[Incomplete, None, None]: ...
+ G: Graph[_Node], cutoff: float | None = None, weight: str | _WeightFunc[_Node] | None = "weight"
+) -> Generator[tuple[_Node, dict[_Node, list[_Node]]]]: ...
@_dispatchable
def bellman_ford_predecessor_and_distance(
G: Graph[_Node],
source: _Node,
target: _Node | None = None,
- weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
+ weight: str | _WeightFunc[_Node] | None = "weight",
heuristic: bool = False,
-): ...
+) -> tuple[dict[_Node, list[_Node]], dict[_Node, float]]: ...
@_dispatchable
def bellman_ford_path(
- G: Graph[_Node],
- source: _Node,
- target: _Node,
- weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
-): ...
+ G: Graph[_Node], source: _Node, target: _Node, weight: str | _WeightFunc[_Node] | None = "weight"
+) -> list[_Node]: ...
@_dispatchable
def bellman_ford_path_length(
- G: Graph[_Node],
- source: _Node,
- target: _Node,
- weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
-): ...
+ G: Graph[_Node], source: _Node, target: _Node, weight: str | _WeightFunc[_Node] | None = "weight"
+) -> float: ...
@_dispatchable
def single_source_bellman_ford_path(
- G: Graph[_Node], source: _Node, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight"
-): ...
+ G: Graph[_Node], source: _Node, weight: str | _WeightFunc[_Node] | None = "weight"
+) -> dict[_Node, list[_Node]]: ...
@_dispatchable
def single_source_bellman_ford_path_length(
- G: Graph[_Node], source: _Node, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight"
-): ...
+ G: Graph[_Node], source: _Node, weight: str | _WeightFunc[_Node] | None = "weight"
+) -> dict[_Node, float]: ...
@_dispatchable
def single_source_bellman_ford(
- G: Graph[_Node],
- source: _Node,
- target: _Node | None = None,
- weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
-): ...
+ G: Graph[_Node], source: _Node, target: _Node | None = None, weight: str | _WeightFunc[_Node] | None = "weight"
+) -> tuple[dict[_Node, float], dict[_Node, list[_Node]]] | tuple[float, list[_Node]]: ... # TODO: overload on target
@_dispatchable
def all_pairs_bellman_ford_path_length(
- G: Graph[_Node], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight"
-) -> Generator[Incomplete, None, None]: ...
+ G: Graph[_Node], weight: str | _WeightFunc[_Node] | None = "weight"
+) -> Generator[tuple[_Node, dict[_Node, float]]]: ...
@_dispatchable
def all_pairs_bellman_ford_path(
- G: Graph[_Node], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight"
-) -> Generator[Incomplete, None, None]: ...
+ G: Graph[_Node], weight: str | _WeightFunc[_Node] | None = "weight"
+) -> Generator[tuple[_Node, dict[_Node, list[_Node]]]]: ...
@_dispatchable
def goldberg_radzik(
- G: Graph[_Node], source: _Node, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight"
-): ...
+ G: Graph[_Node], source: _Node, weight: str | _WeightFunc[_Node] | None = "weight"
+) -> tuple[dict[_Node, _Node | None], dict[_Node, float]]: ...
@_dispatchable
-def negative_edge_cycle(
- G: Graph[_Node],
- weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
- heuristic: bool = True,
-): ...
+def negative_edge_cycle(G: Graph[_Node], weight: str | _WeightFunc[_Node] | None = "weight", heuristic: bool = True) -> bool: ...
@_dispatchable
-def find_negative_cycle(
- G: Graph[_Node], source: _Node, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight"
-): ...
+def find_negative_cycle(G: Graph[_Node], source: _Node, weight: str | _WeightFunc[_Node] | None = "weight") -> list[_Node]: ...
@_dispatchable
def bidirectional_dijkstra(
- G: Graph[_Node],
- source: _Node,
- target: _Node,
- weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
-): ...
+ G: Graph[_Node], source: _Node, target: _Node, weight: str | _WeightFunc[_Node] | None = "weight"
+) -> tuple[float, list[_Node]]: ...
@_dispatchable
-def johnson(G: Graph[_Node], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight"): ...
+def johnson(G: Graph[_Node], weight: str | _WeightFunc[_Node] | None = "weight") -> dict[_Node, dict[_Node, list[_Node]]]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/similarity.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/similarity.pyi
index d50ded1280eb..e2fd83794a6e 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/similarity.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/similarity.pyi
@@ -84,7 +84,7 @@ def simrank_similarity(
importance_factor: float = 0.9,
max_iterations: int = 1000,
tolerance: float = 0.0001,
-): ...
+) -> float | dict[Incomplete, Incomplete]: ...
@_dispatchable
def panther_similarity(
G: Graph[_Node],
@@ -95,7 +95,7 @@ def panther_similarity(
delta: float = 0.1,
eps=None,
weight: str | None = "weight",
-): ...
+) -> dict[bytes, bytes]: ...
@_dispatchable
def generate_random_paths(
G: Graph[_Node],
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/smallworld.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/smallworld.pyi
index 665226a3d6ee..3e163c121c7c 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/smallworld.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/smallworld.pyi
@@ -11,6 +11,6 @@ def lattice_reference(
G: Graph[_Node], niter: int = 5, D=None, connectivity: bool = True, seed: int | RandomState | None = None
): ...
@_dispatchable
-def sigma(G: Graph[_Node], niter: int = 100, nrand: int = 10, seed: int | RandomState | None = None): ...
+def sigma(G: Graph[_Node], niter: int = 100, nrand: int = 10, seed: int | RandomState | None = None) -> float: ...
@_dispatchable
-def omega(G: Graph[_Node], niter: int = 5, nrand: int = 10, seed: int | RandomState | None = None): ...
+def omega(G: Graph[_Node], niter: int = 5, nrand: int = 10, seed: int | RandomState | None = None) -> float: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/smetric.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/smetric.pyi
index e1cf4fd2563f..60f6d0ab5d25 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/smetric.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/smetric.pyi
@@ -4,4 +4,4 @@ from networkx.utils.backends import _dispatchable
__all__ = ["s_metric"]
@_dispatchable
-def s_metric(G: Graph[_Node]): ...
+def s_metric(G: Graph[_Node]) -> float: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/structuralholes.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/structuralholes.pyi
index 15060cd5752d..e869afe75614 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/structuralholes.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/structuralholes.pyi
@@ -11,8 +11,12 @@ def mutual_weight(G: Graph[_Node], u, v, weight=None) -> Incomplete | int: ...
@_dispatchable
def normalized_mutual_weight(G: Graph[_Node], u, v, norm=..., weight=None) -> float: ...
@_dispatchable
-def effective_size(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, weight: str | None = None): ...
+def effective_size(
+ G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, weight: str | None = None
+) -> dict[Incomplete, Incomplete]: ...
@_dispatchable
-def constraint(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, weight: str | None = None): ...
+def constraint(
+ G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, weight: str | None = None
+) -> dict[Incomplete, Incomplete]: ...
@_dispatchable
-def local_constraint(G: Graph[_Node], u: _Node, v: _Node, weight: str | None = None): ...
+def local_constraint(G: Graph[_Node], u: _Node, v: _Node, weight: str | None = None) -> float: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/swap.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/swap.pyi
index 529b895d61c0..7378a13a814e 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/swap.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/swap.pyi
@@ -12,4 +12,4 @@ def double_edge_swap(G: Graph[_Node], nswap: int = 1, max_tries: int = 100, seed
@_dispatchable
def connected_double_edge_swap(
G: Graph[_Node], nswap: int = 1, _window_threshold: int = 3, seed: int | RandomState | None = None
-): ...
+) -> int: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tournament.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tournament.pyi
index 5b6046f5c806..0fff43290acb 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tournament.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tournament.pyi
@@ -1,3 +1,6 @@
+from _typeshed import Incomplete
+
+from networkx.classes.digraph import DiGraph
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
from numpy.random import RandomState
@@ -15,13 +18,13 @@ __all__ = [
@_dispatchable
def is_tournament(G: Graph[_Node]) -> bool: ...
@_dispatchable
-def hamiltonian_path(G: Graph[_Node]): ...
+def hamiltonian_path(G: Graph[_Node]) -> list[Incomplete]: ...
@_dispatchable
-def random_tournament(n: int, seed: int | RandomState | None = None): ...
+def random_tournament(n: int, seed: int | RandomState | None = None) -> DiGraph[Incomplete]: ...
@_dispatchable
def tournament_matrix(G: Graph[_Node]): ...
@_dispatchable
-def score_sequence(G: Graph[_Node]): ...
+def score_sequence(G: Graph[_Node]) -> list[Incomplete]: ...
@_dispatchable
def is_reachable(G: Graph[_Node], s: _Node, t: _Node) -> bool: ...
@_dispatchable
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi
index f66eee33c824..4f69602e218a 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi
@@ -25,11 +25,11 @@ def dfs_tree(
@_dispatchable
def dfs_predecessors(
G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable[..., Incomplete] | None = None
-): ...
+) -> dict[Incomplete, Incomplete]: ...
@_dispatchable
def dfs_successors(
G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable[..., Incomplete] | None = None
-): ...
+) -> dict[Incomplete, list[Incomplete]]: ...
@_dispatchable
def dfs_postorder_nodes(
G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable[..., Incomplete] | None = None
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi
index 60bc903c320c..fbdb17d5f8b4 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi
@@ -11,4 +11,4 @@ FORWARD: Final = "forward"
REVERSE: Final = "reverse"
@_dispatchable
-def edge_bfs(G: Graph[_Node], source=None, orientation=None) -> Generator[Incomplete, None, Incomplete]: ...
+def edge_bfs(G: Graph[_Node], source=None, orientation=None) -> Generator[Incomplete, None, None]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi
index a511cd2df35b..1da9da724a2b 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi
@@ -11,4 +11,4 @@ FORWARD: Final = "forward"
REVERSE: Final = "reverse"
@_dispatchable
-def edge_dfs(G: Graph[_Node], source=None, orientation=None) -> Generator[Incomplete, None, Incomplete]: ...
+def edge_dfs(G: Graph[_Node], source=None, orientation=None) -> Generator[Incomplete, None, None]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/branchings.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/branchings.pyi
index 6b08ec183376..f8e76325f13f 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/branchings.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/branchings.pyi
@@ -1,7 +1,7 @@
from _typeshed import Incomplete
-from collections.abc import Iterator
from dataclasses import dataclass
from typing import Final
+from typing_extensions import Self
from networkx.classes.digraph import DiGraph
from networkx.classes.graph import _Node
@@ -66,5 +66,5 @@ class ArborescenceIterator:
def __init__(self, G, weight: str = "weight", minimum: bool = True, init_partition=None) -> None: ...
partition_queue: Incomplete
- def __iter__(self) -> Iterator[Incomplete]: ...
+ def __iter__(self) -> Self: ...
def __next__(self): ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/coding.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/coding.pyi
index 619dc44d5142..1559965dcded 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/coding.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/coding.pyi
@@ -14,6 +14,6 @@ def to_nested_tuple(T: Graph[_Node], root: _Node, canonical_form: bool = False):
@_dispatchable
def from_nested_tuple(sequence: tuple[Incomplete, ...], sensible_relabeling: bool = False): ...
@_dispatchable
-def to_prufer_sequence(T: Graph[_Node]): ...
+def to_prufer_sequence(T: Graph[_Node]) -> list[Incomplete]: ...
@_dispatchable
def from_prufer_sequence(sequence: Iterable[Incomplete]): ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/decomposition.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/decomposition.pyi
index 79889442969e..6d60295ca588 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/decomposition.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/decomposition.pyi
@@ -1,6 +1,9 @@
+from _typeshed import Incomplete
+
+from networkx.classes.graph import Graph
from networkx.utils.backends import _dispatchable
__all__ = ["junction_tree"]
@_dispatchable
-def junction_tree(G): ...
+def junction_tree(G) -> Graph[Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/mst.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/mst.pyi
index f53727cbf46a..2dddfb05e7f2 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/mst.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/mst.pyi
@@ -1,8 +1,9 @@
from _typeshed import Incomplete
-from collections.abc import Callable, Generator, Iterator
+from collections.abc import Callable, Generator
from dataclasses import dataclass
from enum import Enum
from typing import Final, Literal
+from typing_extensions import Self
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
@@ -81,7 +82,7 @@ class SpanningTreeIterator:
def __init__(self, G, weight: str = "weight", minimum: bool = True, ignore_nan: bool = False) -> None: ...
partition_queue: Incomplete
- def __iter__(self) -> Iterator[Incomplete]: ...
+ def __iter__(self) -> Self: ...
def __next__(self): ...
@_dispatchable
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/triads.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/triads.pyi
index f155a93de025..7bd9b3334fe8 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/triads.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/triads.pyi
@@ -1,4 +1,5 @@
from _typeshed import Incomplete
+from collections import defaultdict
from collections.abc import Collection, Generator
from typing import Final
@@ -13,12 +14,12 @@ TRIAD_NAMES: Final[tuple[str, ...]]
TRICODE_TO_NAME: Final[dict[int, str]]
@_dispatchable
-def triadic_census(G: DiGraph[_Node], nodelist: Collection[_Node] | None = None): ...
+def triadic_census(G: DiGraph[_Node], nodelist: Collection[_Node] | None = None) -> dict[str, int]: ...
@_dispatchable
def is_triad(G: Graph[_Node]) -> bool: ...
@_dispatchable
def all_triads(G: DiGraph[_Node]) -> Generator[Incomplete, None, None]: ...
@_dispatchable
-def triads_by_type(G: DiGraph[_Node]): ...
+def triads_by_type(G: DiGraph[_Node]) -> defaultdict[Incomplete, list[Incomplete]]: ...
@_dispatchable
-def triad_type(G: DiGraph[_Node]): ...
+def triad_type(G: DiGraph[_Node]) -> str | None: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/vitality.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/vitality.pyi
index 1d5af2c9935a..3fd2cfe0e482 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/vitality.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/vitality.pyi
@@ -1,7 +1,11 @@
+from _typeshed import Incomplete
+
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
__all__ = ["closeness_vitality"]
@_dispatchable
-def closeness_vitality(G: Graph[_Node], node=None, weight: str | None = None, wiener_index: float | None = None): ...
+def closeness_vitality(
+ G: Graph[_Node], node=None, weight: str | None = None, wiener_index: float | None = None
+) -> float | dict[Incomplete, Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/voronoi.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/voronoi.pyi
index cd21b3d0c246..63f890bf2591 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/voronoi.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/voronoi.pyi
@@ -12,4 +12,4 @@ def voronoi_cells(
G: Graph[_Node],
center_nodes: set[Incomplete],
weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight",
-): ...
+) -> dict[Incomplete, set[Incomplete]]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/wiener.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/wiener.pyi
index 87e87f305c3a..27130c3a4389 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/wiener.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/wiener.pyi
@@ -4,7 +4,7 @@ from networkx.utils.backends import _dispatchable
__all__ = ["wiener_index", "schultz_index", "gutman_index"]
@_dispatchable
-def wiener_index(G: Graph[_Node], weight: str | None = None): ...
+def wiener_index(G: Graph[_Node], weight: str | None = None) -> float: ...
@_dispatchable
def schultz_index(G, weight=None) -> float: ...
@_dispatchable
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/classes/coreviews.pyi b/python/helpers/typeshed/stubs/networkx/networkx/classes/coreviews.pyi
index 286c7db65c4d..ed0114551bfc 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/classes/coreviews.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/classes/coreviews.pyi
@@ -21,6 +21,7 @@ __all__ = [
]
class AtlasView(Mapping[_T, dict[_U, _V]]):
+ __slots__ = ("_atlas",)
def __getstate__(self) -> dict[str, Mapping[_T, dict[_U, _V]]]: ...
def __setstate__(self, state: dict[str, Mapping[_T, dict[_U, _V]]]) -> None: ...
def __init__(self, d: Mapping[_T, dict[_U, _V]]) -> None: ...
@@ -29,10 +30,14 @@ class AtlasView(Mapping[_T, dict[_U, _V]]):
def __getitem__(self, key: _T) -> dict[_U, _V]: ...
def copy(self) -> dict[_T, dict[_U, _V]]: ...
-class AdjacencyView(AtlasView[_T, _U, _V]): ...
-class MultiAdjacencyView(AdjacencyView[_T, _U, _V]): ...
+class AdjacencyView(AtlasView[_T, _U, _V]):
+ __slots__ = ()
+
+class MultiAdjacencyView(AdjacencyView[_T, _U, _V]):
+ __slots__ = ()
class UnionAtlas(Mapping[_T, dict[_U, _V]]):
+ __slots__ = ("_succ", "_pred")
def __init__(self, succ: AtlasView[_T, _U, _V], pred: AtlasView[_T, _U, _V]) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
@@ -40,14 +45,18 @@ class UnionAtlas(Mapping[_T, dict[_U, _V]]):
def copy(self) -> Self: ...
class UnionAdjacency(Mapping[_T, dict[_U, _V]]):
+ __slots__ = ("_succ", "_pred")
def __init__(self, succ: AdjacencyView[_T, _U, _V], pred: AdjacencyView[_T, _U, _V]) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
def __getitem__(self, key: _T) -> dict[_U, _V]: ...
def copy(self) -> Self: ...
-class UnionMultiInner(UnionAtlas[_T, _U, _V]): ...
-class UnionMultiAdjacency(UnionAdjacency[_T, _U, _V]): ...
+class UnionMultiInner(UnionAtlas[_T, _U, _V]):
+ __slots__ = ()
+
+class UnionMultiAdjacency(UnionAdjacency[_T, _U, _V]):
+ __slots__ = ()
class FilterAtlas(Mapping[_T, _U]):
NODE_OK: Callable[[_T], bool]
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/classes/digraph.pyi b/python/helpers/typeshed/stubs/networkx/networkx/classes/digraph.pyi
index 90b403fe4b99..482c2c208c5f 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/classes/digraph.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/classes/digraph.pyi
@@ -1,31 +1,46 @@
-from _typeshed import Incomplete
from collections.abc import Iterator
from functools import cached_property
+from typing import Any
+from typing_extensions import Self
from networkx.classes.coreviews import AdjacencyView
from networkx.classes.graph import Graph, _Node
-from networkx.classes.reportviews import DiDegreeView, OutEdgeView
+from networkx.classes.reportviews import (
+ DiDegreeView,
+ InDegreeView,
+ InEdgeView,
+ InMultiDegreeView,
+ OutDegreeView,
+ OutEdgeView,
+ OutMultiDegreeView,
+)
__all__ = ["DiGraph"]
class DiGraph(Graph[_Node]):
@cached_property
- def succ(self) -> AdjacencyView[_Node, _Node, dict[str, Incomplete]]: ...
+ def succ(self) -> AdjacencyView[_Node, _Node, dict[str, Any]]: ...
@cached_property
- def pred(self) -> AdjacencyView[_Node, _Node, dict[str, Incomplete]]: ...
+ def pred(self) -> AdjacencyView[_Node, _Node, dict[str, Any]]: ...
def has_successor(self, u: _Node, v: _Node) -> bool: ...
def has_predecessor(self, u: _Node, v: _Node) -> bool: ...
def successors(self, n: _Node) -> Iterator[_Node]: ...
+
neighbors = successors
+
def predecessors(self, n: _Node) -> Iterator[_Node]: ...
@cached_property
def out_edges(self) -> OutEdgeView[_Node]: ...
@cached_property
- def in_edges(self) -> OutEdgeView[_Node]: ...
+ def in_edges(self) -> InEdgeView[_Node]: ...
@cached_property
- def in_degree(self) -> DiDegreeView[_Node]: ...
+ def in_degree(self) -> InDegreeView[_Node] | InMultiDegreeView[_Node]: ...
@cached_property
- def out_degree(self) -> DiDegreeView[_Node]: ...
- def to_undirected(self, reciprocal: bool = False, as_view: bool = False): ... # type: ignore[override] # Has an additional `reciprocal` keyword argument
- def reverse(self, copy: bool = True) -> DiGraph[_Node]: ...
- def copy(self, as_view: bool = False) -> DiGraph[_Node]: ...
+ def out_degree(self) -> OutDegreeView[_Node] | OutMultiDegreeView[_Node]: ...
+ def to_undirected(self, reciprocal: bool = False, as_view: bool = False) -> Graph[_Node]: ... # type: ignore[override]
+ # reciprocal : If True, only edges that appear in both directions ... will be kept in the undirected graph.
+ def reverse(self, copy: bool = True) -> Self: ...
+ @cached_property
+ def edges(self) -> OutEdgeView[_Node]: ... # type: ignore[override] # An OutEdgeView of the DiGraph as G.edges or G.edges().
+ @cached_property
+ def degree(self) -> int | DiDegreeView[_Node]: ... # type: ignore[override] # Returns DiDegreeView or int
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/classes/function.pyi b/python/helpers/typeshed/stubs/networkx/networkx/classes/function.pyi
index a200536cf9fb..952bfd4b5a8e 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/classes/function.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/classes/function.pyi
@@ -59,7 +59,7 @@ def neighbors(G, n): ...
def number_of_nodes(G): ...
def number_of_edges(G): ...
def density(G): ...
-def degree_histogram(G): ...
+def degree_histogram(G) -> list[int]: ...
@overload
def is_directed(G: PlanarEmbedding[Hashable]) -> Literal[False]: ... # type: ignore[misc] # Incompatible return types
@overload
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/classes/graph.pyi b/python/helpers/typeshed/stubs/networkx/networkx/classes/graph.pyi
index 557448a229ab..ffdab103eaad 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/classes/graph.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/classes/graph.pyi
@@ -1,5 +1,4 @@
-from _typeshed import Incomplete
-from collections.abc import Callable, Collection, Hashable, Iterable, Iterator, Mapping, MutableMapping
+from collections.abc import Callable, Collection, Hashable, Iterable, Iterator, MutableMapping
from functools import cached_property
from typing import Any, ClassVar, TypeVar, overload
from typing_extensions import Self, TypeAlias
@@ -7,7 +6,7 @@ from typing_extensions import Self, TypeAlias
import numpy
from networkx.classes.coreviews import AdjacencyView, AtlasView
from networkx.classes.digraph import DiGraph
-from networkx.classes.reportviews import DiDegreeView, NodeView, OutEdgeView
+from networkx.classes.reportviews import DegreeView, EdgeView, NodeView
_Node = TypeVar("_Node", bound=Hashable)
_NodeWithData: TypeAlias = tuple[_Node, dict[str, Any]]
@@ -38,12 +37,14 @@ class Graph(Collection[_Node]):
graph_attr_dict_factory: ClassVar[_MapFactory]
graph: dict[str, Any]
+ __networkx_cache__: dict[str, Any]
def to_directed_class(self) -> type[DiGraph[_Node]]: ...
def to_undirected_class(self) -> type[Graph[_Node]]: ...
- def __init__(self, incoming_graph_data: _Data[_Node] | None = None, **attr) -> None: ...
+ def __init__(self, incoming_graph_data: _Data[_Node] | None = None, **attr: Any) -> None: ... # attr: key=value pairs
@cached_property
- def adj(self) -> AdjacencyView[_Node, _Node, dict[str, Incomplete]]: ...
+ def adj(self) -> AdjacencyView[_Node, _Node, dict[str, Any]]: ...
+ # This object is a read-only dict-like structure
@property
def name(self) -> str: ...
@name.setter
@@ -53,7 +54,7 @@ class Graph(Collection[_Node]):
def __contains__(self, n: object) -> bool: ...
def __len__(self) -> int: ...
def add_node(self, node_for_adding: _Node, **attr: Any) -> None: ... # attr: Set or change node attributes using key=value
- def add_nodes_from(self, nodes_for_adding: Iterable[_NodePlus[_Node]], **attr) -> None: ...
+ def add_nodes_from(self, nodes_for_adding: Iterable[_NodePlus[_Node]], **attr: Any) -> None: ... # attr: key=value pairs
def remove_node(self, n: _Node) -> None: ...
def remove_nodes_from(self, nodes: Iterable[_Node]) -> None: ...
@cached_property
@@ -61,12 +62,14 @@ class Graph(Collection[_Node]):
def number_of_nodes(self) -> int: ...
def order(self) -> int: ...
def has_node(self, n: _Node) -> bool: ...
- # attr: Edge data (or labels or objects) can be assigned using keyword arguments
def add_edge(self, u_of_edge: _Node, v_of_edge: _Node, **attr: Any) -> None: ...
- def add_edges_from(self, ebunch_to_add: Iterable[_EdgePlus[_Node]], **attr) -> None: ...
+ # attr: Edge data (or labels or objects) can be assigned using keyword arguments
+ def add_edges_from(self, ebunch_to_add: Iterable[_EdgePlus[_Node]], **attr: Any) -> None: ...
+ # attr: Edge data (or labels or objects) can be assigned using keyword arguments
def add_weighted_edges_from(
- self, ebunch_to_add: Iterable[tuple[_Node, _Node, Incomplete]], weight: str = "weight", **attr
+ self, ebunch_to_add: Iterable[tuple[_Node, _Node, float]], weight: str = "weight", **attr: Any
) -> None: ...
+ # attr: Edge attributes to add/update for all edges.
def remove_edge(self, u: _Node, v: _Node) -> None: ...
def remove_edges_from(self, ebunch: Iterable[_EdgePlus[_Node]]) -> None: ...
@overload
@@ -78,11 +81,12 @@ class Graph(Collection[_Node]):
def has_edge(self, u: _Node, v: _Node) -> bool: ...
def neighbors(self, n: _Node) -> Iterator[_Node]: ...
@cached_property
- def edges(self) -> OutEdgeView[_Node]: ...
- def get_edge_data(self, u: _Node, v: _Node, default=None) -> Mapping[str, Incomplete]: ...
- def adjacency(self) -> Iterator[tuple[_Node, Mapping[_Node, Mapping[str, Incomplete]]]]: ...
+ def edges(self) -> EdgeView[_Node]: ...
+ def get_edge_data(self, u: _Node, v: _Node, default: Any = None) -> dict[str, Any]: ...
+ # default: any Python object
+ def adjacency(self) -> Iterator[tuple[_Node, dict[_Node, dict[str, Any]]]]: ...
@cached_property
- def degree(self) -> DiDegreeView[_Node]: ...
+ def degree(self) -> int | DegreeView[_Node]: ...
def clear(self) -> None: ...
def clear_edges(self) -> None: ...
def is_multigraph(self) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/classes/multidigraph.pyi b/python/helpers/typeshed/stubs/networkx/networkx/classes/multidigraph.pyi
index 0bf2f2fe87cd..374b793d842b 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/classes/multidigraph.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/classes/multidigraph.pyi
@@ -1,25 +1,33 @@
-from _typeshed import Incomplete
from functools import cached_property
+from typing import Any
from networkx.classes.coreviews import MultiAdjacencyView
from networkx.classes.digraph import DiGraph
-from networkx.classes.graph import _Node
+from networkx.classes.graph import _EdgeWithData, _Node
from networkx.classes.multigraph import MultiGraph
-from networkx.classes.reportviews import InMultiDegreeView, OutMultiDegreeView, OutMultiEdgeView
+from networkx.classes.reportviews import (
+ InMultiDegreeView,
+ InMultiEdgeDataView,
+ InMultiEdgeView,
+ OutMultiDegreeView,
+ OutMultiEdgeView,
+)
__all__ = ["MultiDiGraph"]
class MultiDiGraph(MultiGraph[_Node], DiGraph[_Node]):
@cached_property
- def succ(self) -> MultiAdjacencyView[_Node, _Node, dict[str, Incomplete]]: ...
+ def succ(self) -> MultiAdjacencyView[_Node, _Node, dict[str, Any]]: ...
@cached_property
- def pred(self) -> MultiAdjacencyView[_Node, _Node, dict[str, Incomplete]]: ...
+ def pred(self) -> MultiAdjacencyView[_Node, _Node, dict[str, Any]]: ...
@cached_property
- def edges(self) -> OutMultiEdgeView[_Node]: ...
+ def edges(self) -> OutMultiEdgeView[_Node]: ... # type: ignore[override]
+ # Returns: OutMultiEdgeView
@cached_property
def out_edges(self) -> OutMultiEdgeView[_Node]: ...
@cached_property
- def in_edges(self) -> OutMultiEdgeView[_Node]: ...
+ def in_edges(self) -> InMultiEdgeView[_Node] | InMultiEdgeDataView[_Node, _EdgeWithData[_Node]]: ... # type: ignore[override]
+ # Returns : InMultiEdgeView or InMultiEdgeDataView
@cached_property
def in_degree(self) -> InMultiDegreeView[_Node]: ...
@cached_property
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/classes/multigraph.pyi b/python/helpers/typeshed/stubs/networkx/networkx/classes/multigraph.pyi
index 58406cbc3c4b..d0bb1ef27c82 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/classes/multigraph.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/classes/multigraph.pyi
@@ -1,32 +1,50 @@
-from _typeshed import Incomplete
+from collections.abc import Hashable
from functools import cached_property
-from typing import ClassVar
-from typing_extensions import TypeAlias
+from typing import Any, ClassVar, overload
+from typing_extensions import TypeAlias, TypeVar
from networkx.classes.coreviews import MultiAdjacencyView
from networkx.classes.graph import Graph, _MapFactory, _Node
from networkx.classes.multidigraph import MultiDiGraph
-from networkx.classes.reportviews import OutMultiEdgeView
+from networkx.classes.reportviews import MultiEdgeView
_MultiEdge: TypeAlias = tuple[_Node, _Node, int] # noqa: Y047
+_DefaultT = TypeVar("_DefaultT")
+_KeyT = TypeVar("_KeyT", bound=Hashable)
+
__all__ = ["MultiGraph"]
class MultiGraph(Graph[_Node]):
edge_key_dict_factory: ClassVar[_MapFactory]
- def __init__(self, incoming_graph_data=None, multigraph_input: bool | None = None, **attr) -> None: ...
+ def __init__(self, incoming_graph_data=None, multigraph_input: bool | None = None, **attr: Any) -> None: ...
@cached_property
- def adj(self) -> MultiAdjacencyView[_Node, _Node, dict[str, Incomplete]]: ...
+ def adj(self) -> MultiAdjacencyView[_Node, _Node, dict[str, Any]]: ... # data can be any type
def new_edge_key(self, u: _Node, v: _Node) -> int: ...
- def add_edge(self, u_for_edge, v_for_edge, key=None, **attr): ... # type: ignore[override] # Has an additional `key` keyword argument
- def remove_edge(self, u, v, key=None): ...
- def has_edge(self, u: _Node, v: _Node, key=None) -> bool: ...
- def get_edge_data( # type: ignore[override] # Has an additional `key` keyword argument
- self, u, v, key=None, default=None
- ): ...
+ @overload # type: ignore[override] # Has an additional `key` keyword argument
+ def add_edge(self, u_for_edge: _Node, v_for_edge: _Node, key: int | None = None, **attr: Any) -> int: ...
+ @overload
+ def add_edge(self, u_for_edge: _Node, v_for_edge: _Node, key: _KeyT, **attr: Any) -> _KeyT: ...
+ # key : hashable identifier, optional (default=lowest unused integer)
+ def remove_edge(self, u: _Node, v: _Node, key: Hashable | None = None) -> None: ...
+ def has_edge(self, u: _Node, v: _Node, key: Hashable | None = None) -> bool: ...
+ @overload # type: ignore[override]
+ def get_edge_data(
+ self, u: _Node, v: _Node, key: Hashable, default: _DefaultT | None = None
+ ) -> dict[str, Any] | _DefaultT: ...
+ # key : hashable identifier, optional (default=None).
+ # default : any Python object (default=None). Value to return if the specific edge (u, v, key) is not found.
+ # Returns: The edge attribute dictionary.
+ @overload
+ def get_edge_data(
+ self, u: _Node, v: _Node, key: None = None, default: _DefaultT | None = None
+ ) -> dict[Hashable, dict[str, Any] | _DefaultT]: ...
+ # default : any Python object (default=None). Value to return if there are no edges between u and v and no key is specified.
+ # Returns: A dictionary mapping edge keys to attribute dictionaries for each of those edges if no specific key is provided.
def copy(self, as_view: bool = False) -> MultiGraph[_Node]: ...
def to_directed(self, as_view: bool = False) -> MultiDiGraph[_Node]: ...
def to_undirected(self, as_view: bool = False) -> MultiGraph[_Node]: ...
def number_of_edges(self, u: _Node | None = None, v: _Node | None = None) -> int: ...
@cached_property
- def edges(self) -> OutMultiEdgeView[_Node]: ...
+ def edges(self) -> MultiEdgeView[_Node]: ... # type: ignore[override]
+ # Returns: MultiEdgeView
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/classes/reportviews.pyi b/python/helpers/typeshed/stubs/networkx/networkx/classes/reportviews.pyi
index ff9078493a19..dc9175291af4 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/classes/reportviews.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/classes/reportviews.pyi
@@ -35,18 +35,20 @@ __all__ = [
]
class NodeView(Mapping[_Node, dict[str, Any]], AbstractSet[_Node]):
+ __slots__ = ("_nodes",)
def __init__(self, graph: Graph[_Node]) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_Node]: ...
def __getitem__(self, n: _Node) -> dict[str, Any]: ...
def __contains__(self, n: object) -> bool: ...
@overload
- def __call__(self, data: Literal[False] = False, default=None) -> Iterator[_Node]: ...
+ def __call__(self, data: Literal[False] = False, default=None) -> Self: ...
@overload
- def __call__(self, data: Literal[True] | str, default=None) -> Iterator[tuple[_Node, dict[str, Any]]]: ...
- def data(self, data: bool | str = True, default=None) -> NodeDataView[_Node]: ...
+ def __call__(self, data: Literal[True] | str, default=None) -> Self: ...
+ def data(self, data: bool | str = True, default=None) -> Self: ...
class NodeDataView(AbstractSet[_Node]):
+ __slots__ = ("_nodes", "_data", "_default")
def __init__(self, nodedict: Mapping[str, Incomplete], data: bool | str = False, default=None) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[tuple[_Node, Incomplete]]: ... # type: ignore[override]
@@ -55,7 +57,10 @@ class NodeDataView(AbstractSet[_Node]):
class DiDegreeView(Generic[_Node]):
def __init__(self, G: Graph[_Node], nbunch: _NBunch[_Node] = None, weight: None | bool | str = None) -> None: ...
- def __call__(self, nbunch: _NBunch[_Node] = None, weight: None | bool | str = None) -> int | DiDegreeView[_Node]: ...
+ @overload
+ def __call__(self, nbunch: None = None, weight: None | bool | str = None) -> int: ... # type: ignore[overload-overlap]
+ @overload
+ def __call__(self, nbunch: None | Iterable[_Node], weight: None | bool | str = None) -> Self: ...
def __getitem__(self, n: _Node) -> float: ...
def __iter__(self) -> Iterator[tuple[_Node, float]]: ...
def __len__(self) -> int: ...
@@ -70,24 +75,33 @@ class OutMultiDegreeView(DiDegreeView[_Node]): ...
class EdgeViewABC(ABC): ...
class OutEdgeDataView(EdgeViewABC, Generic[_Node, _D]):
+ __slots__ = ("_viewer", "_nbunch", "_data", "_default", "_adjdict", "_nodes_nbrs", "_report")
def __init__(self, viewer, nbunch: _NBunch[_Node] = None, data: bool = False, *, default=None) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_D]: ...
def __contains__(self, e: _Edge[_Node]) -> bool: ...
-class EdgeDataView(OutEdgeDataView[_Node, _D]): ...
-class InEdgeDataView(OutEdgeDataView[_Node, _D]): ...
+class EdgeDataView(OutEdgeDataView[_Node, _D]):
+ __slots__ = ()
+
+class InEdgeDataView(OutEdgeDataView[_Node, _D]):
+ __slots__ = ()
class OutMultiEdgeDataView(OutEdgeDataView[_Node, _D]):
+ __slots__ = ("keys",)
keys: bool
def __init__(
self, viewer, nbunch: _NBunch[_Node] = None, data: bool = False, *, default=None, keys: bool = False
) -> None: ...
-class MultiEdgeDataView(OutEdgeDataView[_Node, _D]): ...
-class InMultiEdgeDataView(OutEdgeDataView[_Node, _D]): ...
+class MultiEdgeDataView(OutEdgeDataView[_Node, _D]):
+ __slots__ = ()
+
+class InMultiEdgeDataView(OutEdgeDataView[_Node, _D]):
+ __slots__ = ()
class OutEdgeView(AbstractSet[Incomplete], Mapping[Incomplete, Incomplete], EdgeViewABC, Generic[_Node]):
+ __slots__ = ("_adjdict", "_graph", "_nodes_nbrs")
def __init__(self, G: Graph[_Node]) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[tuple[_Node, _Node]]: ...
@@ -128,6 +142,7 @@ class OutEdgeView(AbstractSet[Incomplete], Mapping[Incomplete, Incomplete], Edge
) -> OutEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ...
class EdgeView(OutEdgeView[_Node]):
+ __slots__ = ()
dataview = EdgeDataView
# Have to override parent's overloads with the proper return type based on dataview
@overload
@@ -164,6 +179,7 @@ class EdgeView(OutEdgeView[_Node]):
) -> EdgeDataView[_Node, tuple[_Node, _Node, _U]]: ...
class InEdgeView(OutEdgeView[_Node]):
+ __slots__ = ()
dataview = InEdgeDataView
# Have to override parent's overloads with the proper return type based on dataview
@overload
@@ -200,6 +216,7 @@ class InEdgeView(OutEdgeView[_Node]):
) -> InEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ...
class OutMultiEdgeView(OutEdgeView[_Node]):
+ __slots__ = ()
def __iter__(self) -> Iterator[tuple[_Node, _Node, Incomplete]]: ... # type: ignore[override]
def __getitem__(self, e: tuple[_Node, _Node, Incomplete]) -> dict[str, Any]: ... # type: ignore[override]
dataview = OutMultiEdgeDataView
@@ -263,6 +280,7 @@ class OutMultiEdgeView(OutEdgeView[_Node]):
) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, Incomplete, _U]]: ...
class MultiEdgeView(OutMultiEdgeView[_Node]):
+ __slots__ = ()
dataview = MultiEdgeDataView # type: ignore[assignment]
# Have to override parent's overloads with the proper return type based on dataview
@overload # type: ignore[override] # Has an additional `keys` keyword argument
@@ -325,6 +343,7 @@ class MultiEdgeView(OutMultiEdgeView[_Node]):
) -> MultiEdgeDataView[_Node, tuple[_Node, _Node, Incomplete, _U]]: ...
class InMultiEdgeView(OutMultiEdgeView[_Node]):
+ __slots__ = ()
dataview = InMultiEdgeDataView # type: ignore[assignment]
# Have to override parent's overloads with the proper return type based on dataview
@overload # type: ignore[override]
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/drawing/layout.pyi b/python/helpers/typeshed/stubs/networkx/networkx/drawing/layout.pyi
index d25734345473..1d09971ac1fc 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/drawing/layout.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/drawing/layout.pyi
@@ -1,7 +1,12 @@
-from _typeshed import Incomplete
+from collections.abc import Collection, Mapping
+from typing import Any, Literal
+from typing_extensions import TypeAlias
+import numpy as np
+from networkx._typing import Array1D, Array2D, ArrayLike1D, Seed
+from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
-from numpy.random import RandomState
+from numpy.typing import NDArray
__all__ = [
"bipartite_layout",
@@ -22,89 +27,134 @@ __all__ = [
"arf_layout",
]
-def random_layout(G, center=None, dim: int = 2, seed: int | RandomState | None = None, store_pos_as: str | None = None): ...
-def circular_layout(G, scale: float = 1, center=None, dim: int = 2, store_pos_as: str | None = None): ...
-def shell_layout(G, nlist=None, rotate=None, scale: float = 1, center=None, dim: int = 2, store_pos_as: str | None = None): ...
-def bipartite_layout(
- G,
- nodes=None,
- align: str = "vertical",
+_FloatArrayLike1D: TypeAlias = ArrayLike1D[float, np.number[Any]] # Any because we don't care about the bit base
+
+def random_layout(
+ G: Graph[_Node],
+ center: _FloatArrayLike1D | None = None,
+ dim: int = 2,
+ seed: Seed | None = None,
+ store_pos_as: str | None = None,
+) -> dict[_Node, Array1D[np.float32]]: ...
+def circular_layout(
+ G: Graph[_Node], scale: float = 1, center: _FloatArrayLike1D | None = None, dim: int = 2, store_pos_as: str | None = None
+) -> dict[_Node, Array1D[np.float64]]: ...
+def shell_layout(
+ G: Graph[_Node],
+ nlist: Collection[Collection[_Node]] | None = None,
+ rotate: float | None = None,
scale: float = 1,
- center=None,
+ center: _FloatArrayLike1D | None = None,
+ dim: int = 2,
+ store_pos_as: str | None = None,
+) -> dict[_Node, Array1D[np.float64]]: ...
+def bipartite_layout(
+ G: Graph[_Node],
+ nodes: Collection[_Node] | None = None,
+ align: Literal["vertical", "horizontal"] = "vertical",
+ scale: float = 1,
+ center: _FloatArrayLike1D | None = None,
aspect_ratio: float = ...,
store_pos_as: str | None = None,
-): ...
+) -> dict[_Node, Array1D[np.float64]]: ...
def spring_layout(
- G,
- k=None,
- pos=None,
- fixed=None,
+ G: Graph[_Node],
+ k: float | None = None,
+ pos: Mapping[_Node, Collection[float]] | None = None,
+ fixed: Collection[_Node] | None = None,
iterations: int = 50,
threshold: float = 0.0001,
- weight: str = "weight",
- scale: float = 1,
- center=None,
+ weight: str | None = "weight",
+ scale: float | None = 1,
+ center: _FloatArrayLike1D | None = None,
dim: int = 2,
- seed: int | RandomState | None = None,
+ seed: Seed | None = None,
store_pos_as: str | None = None,
*,
- method: str = "auto",
+ method: Literal["auto", "force", "energy"] = "auto",
gravity: float = 1.0,
-): ...
+) -> dict[_Node, Array1D[np.float64]]: ...
fruchterman_reingold_layout = spring_layout
def kamada_kawai_layout(
- G, dist=None, pos=None, weight: str = "weight", scale: float = 1, center=None, dim: int = 2, store_pos_as: str | None = None
-): ...
-def spectral_layout(G, weight: str = "weight", scale: float = 1, center=None, dim: int = 2, store_pos_as: str | None = None): ...
-def planar_layout(G, scale: float = 1, center=None, dim: int = 2, store_pos_as: str | None = None): ...
-def spiral_layout(
- G,
+ G: Graph[_Node],
+ dist: Mapping[_Node, Mapping[_Node, float]] | None = None,
+ pos: Mapping[_Node, Collection[float]] | None = None,
+ weight: str | None = "weight",
scale: float = 1,
- center=None,
+ center: _FloatArrayLike1D | None = None,
+ dim: int = 2,
+ store_pos_as: str | None = None,
+) -> dict[_Node, Array1D[np.float64]]: ...
+def spectral_layout(
+ G: Graph[_Node],
+ weight: str | None = "weight",
+ scale: float = 1,
+ center: _FloatArrayLike1D | None = None,
+ dim: int = 2,
+ store_pos_as: str | None = None,
+) -> dict[_Node, Array1D[np.float64]]: ...
+def planar_layout(
+ G: Graph[_Node], scale: float = 1, center: _FloatArrayLike1D | None = None, dim: int = 2, store_pos_as: str | None = None
+) -> dict[_Node, Array1D[np.float64]]: ...
+def spiral_layout(
+ G: Graph[_Node],
+ scale: float = 1,
+ center: _FloatArrayLike1D | None = None,
dim: int = 2,
resolution: float = 0.35,
equidistant: bool = False,
store_pos_as: str | None = None,
-): ...
+) -> dict[_Node, Array1D[np.float64]]: ...
def multipartite_layout(
- G, subset_key: str = "subset", align: str = "vertical", scale: float = 1, center=None, store_pos_as: str | None = None
-): ...
+ G: Graph[_Node],
+ subset_key: str | Mapping[Any, Collection[_Node]] = "subset", # layers can be "any" hashable
+ align: Literal["vertical", "horizontal"] = "vertical",
+ scale: float = 1,
+ center: _FloatArrayLike1D | None = None,
+ store_pos_as: str | None = None,
+) -> dict[_Node, Array1D[np.float64]]: ...
def arf_layout(
- G,
- pos=None,
+ G: Graph[_Node],
+ pos: Mapping[_Node, Collection[float]] | None = None,
scaling: float = 1,
a: float = 1.1,
etol: float = 1e-06,
dt: float = 0.001,
max_iter: int = 1000,
*,
- seed: int | RandomState | None = None,
+ seed: Seed | None = None,
store_pos_as: str | None = None,
-): ...
+) -> dict[_Node, Array1D[np.float32]]: ...
@_dispatchable
def forceatlas2_layout(
- G,
- pos=None,
+ G: Graph[_Node],
+ pos: Mapping[_Node, Collection[float]] | None = None,
*,
- max_iter=100,
- jitter_tolerance=1.0,
- scaling_ratio=2.0,
+ max_iter: int = 100,
+ jitter_tolerance: float = 1.0,
+ scaling_ratio: float = 2.0,
gravity: float = 1.0,
- distributed_action=False,
- strong_gravity=False,
- node_mass=None,
- node_size=None,
- weight=None,
- dissuade_hubs=False,
- linlog=False,
- seed: int | RandomState | None = None,
+ distributed_action: bool = False,
+ strong_gravity: bool = False,
+ node_mass: Mapping[_Node, float] | None = None,
+ node_size: Mapping[_Node, float] | None = None,
+ weight: str | None = None,
+ dissuade_hubs: bool = False,
+ linlog: bool = False,
+ seed: Seed | None = None,
dim: int = 2,
store_pos_as: str | None = None,
-) -> dict[Incomplete, Incomplete]: ...
-def rescale_layout(pos, scale: float = 1): ...
-def rescale_layout_dict(pos, scale: float = 1): ...
+) -> dict[_Node, Array1D[np.float32]]: ...
+def rescale_layout(pos: NDArray[np.number[Any]], scale: float = 1) -> Array2D[np.float64]: ... # ignore the bit base
+def rescale_layout_dict(pos: Mapping[_Node, Collection[float]], scale: float = 1) -> dict[_Node, Array1D[np.float64]]: ...
def bfs_layout(
- G, start, *, align="vertical", scale=1, center=None, store_pos_as: str | None = None
-) -> dict[Incomplete, Incomplete]: ...
+ G: Graph[_Node],
+ start: _Node,
+ *,
+ align: Literal["vertical", "horizontal"] = "vertical",
+ scale: float = 1,
+ center: _FloatArrayLike1D | None = None,
+ store_pos_as: str | None = None,
+) -> dict[_Node, Array1D[np.float64]]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/drawing/nx_agraph.pyi b/python/helpers/typeshed/stubs/networkx/networkx/drawing/nx_agraph.pyi
index 4082bd6153ec..d3de4c55aae5 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/drawing/nx_agraph.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/drawing/nx_agraph.pyi
@@ -1,37 +1,45 @@
-from _typeshed import Incomplete
-from collections.abc import Callable, Hashable
-from io import TextIOBase
-from typing_extensions import TypeAlias
+from _typeshed import OpenBinaryModeUpdating, OpenTextModeReading, OpenTextModeWriting, SupportsWrite
+from collections.abc import Callable
+from typing import IO, Any, Protocol, TypeVar, type_check_only
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
-
-# from pygraphviz.agraph import AGraph as _AGraph
-_AGraph: TypeAlias = Incomplete
+from pygraphviz.agraph import AGraph # type: ignore[import-not-found] # pyright: ignore[reportMissingImports]
__all__ = ["from_agraph", "to_agraph", "write_dot", "read_dot", "graphviz_layout", "pygraphviz_layout", "view_pygraphviz"]
+_ModeT_contra = TypeVar("_ModeT_contra", bound=str, contravariant=True)
+_FileT_co = TypeVar("_FileT_co", covariant=True)
+
+@type_check_only
+class _SupportsOpen(Protocol[_ModeT_contra, _FileT_co]):
+ def open(self, *, mode: _ModeT_contra) -> _FileT_co: ...
+
@_dispatchable
-def from_agraph(A, create_using=None) -> Graph[Incomplete]: ...
-def to_agraph(N: Graph[Hashable]) -> _AGraph: ...
-def write_dot(G: Graph[Hashable], path: str | TextIOBase) -> None: ...
+def from_agraph(
+ A: AGraph, create_using: Graph[str] | type[Graph[str]] | None = None # TODO: add overloads on `create_using`
+) -> Graph[str]: ...
+def to_agraph(N: Graph[_Node]) -> AGraph: ...
+def write_dot(
+ G: Graph[_Node], path: str | IO[str] | IO[bytes] | _SupportsOpen[OpenTextModeWriting, IO[str] | IO[bytes]]
+) -> None: ...
@_dispatchable
-def read_dot(path: str | TextIOBase) -> Graph[Incomplete]: ...
+def read_dot(path: str | IO[str] | IO[bytes] | _SupportsOpen[OpenTextModeReading, IO[str] | IO[bytes]]) -> Graph[str]: ...
def graphviz_layout(
G: Graph[_Node], prog: str = "neato", root: str | None = None, args: str = ""
) -> dict[_Node, tuple[float, float]]: ...
-
-pygraphviz_layout = graphviz_layout
-
+def pygraphviz_layout(
+ G: Graph[_Node], prog: str = "neato", root: str | None = None, args: str = ""
+) -> dict[_Node, tuple[float, float]]: ...
def view_pygraphviz(
G: Graph[_Node],
- # From implementation looks like Callable could return object since it's always immediatly stringified
- # But judging by documentation this seems like an extra runtime safty thing and not intended
+ # From implementation looks like Callable could return object since it's always immediately stringified
+ # But judging by documentation this seems like an extra runtime safety thing and not intended
# Leaving as str unless anyone reports a valid use-case
- edgelabel: str | Callable[[_Node], str] | None = None,
+ edgelabel: str | Callable[[dict[str, Any]], str] | None = None,
prog: str = "dot",
args: str = "",
suffix: str = "",
- path: str | None = None,
+ path: str | SupportsWrite[bytes] | _SupportsOpen[OpenBinaryModeUpdating, SupportsWrite[bytes]] | None = None,
show: bool = True,
-): ...
+) -> tuple[str, AGraph]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/drawing/nx_latex.pyi b/python/helpers/typeshed/stubs/networkx/networkx/drawing/nx_latex.pyi
index 1dcf1df0f7a8..353ea573e092 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/drawing/nx_latex.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/drawing/nx_latex.pyi
@@ -1,36 +1,70 @@
+from _typeshed import StrPath, SupportsWrite
+from collections.abc import Collection
+from typing_extensions import TypeAlias, TypeVar
+
+from networkx.classes.graph import Graph, _Node
+
__all__ = ["to_latex_raw", "to_latex", "write_latex"]
+# runtime requires a dict but it doesn't mutate it, we use a bounded typevar as
+# a values type to make type checkers treat the dict covariantely
+_PosT = TypeVar("_PosT", bound=Collection[float] | str)
+_Pos: TypeAlias = str | dict[_Node, _PosT]
+
def to_latex_raw(
- G,
- pos: str = "pos",
+ G: Graph[_Node],
+ pos: _Pos[_Node, _PosT] = "pos",
tikz_options: str = "",
default_node_options: str = "",
- node_options: str = "node_options",
- node_label: str = "label",
+ node_options: str | dict[_Node, str] = "node_options",
+ node_label: str | dict[_Node, str] = "label",
default_edge_options: str = "",
- edge_options: str = "edge_options",
- edge_label: str = "label",
- edge_label_options: str = "edge_label_options",
-): ...
+ edge_options: str | dict[tuple[_Node, _Node], str] = "edge_options",
+ edge_label: str | dict[tuple[_Node, _Node], str] = "label",
+ edge_label_options: str | dict[tuple[_Node, _Node], str] = "edge_label_options",
+) -> str: ...
def to_latex(
- Gbunch,
- pos: str = "pos",
+ Gbunch: Graph[_Node] | Collection[Graph[_Node]],
+ pos: _Pos[_Node, _PosT] | Collection[_Pos[_Node, _PosT]] = "pos",
tikz_options: str = "",
default_node_options: str = "",
- node_options: str = "node_options",
- node_label: str = "node_label",
+ node_options: str | dict[_Node, str] = "node_options",
+ node_label: str | dict[_Node, str] = "node_label",
default_edge_options: str = "",
- edge_options: str = "edge_options",
- edge_label: str = "edge_label",
- edge_label_options: str = "edge_label_options",
+ edge_options: str | dict[tuple[_Node, _Node], str] = "edge_options",
+ edge_label: str | dict[tuple[_Node, _Node], str] = "edge_label",
+ edge_label_options: str | dict[tuple[_Node, _Node], str] = "edge_label_options",
caption: str = "",
latex_label: str = "",
- sub_captions=None,
- sub_labels=None,
+ sub_captions: Collection[str] | None = None,
+ sub_labels: Collection[str] | None = None,
n_rows: int = 1,
as_document: bool = True,
document_wrapper: str = ...,
figure_wrapper: str = ...,
subfigure_wrapper: str = ...,
-): ...
-def write_latex(Gbunch, path, **options) -> None: ...
+) -> str: ...
+def write_latex(
+ Gbunch: Graph[_Node] | Collection[Graph[_Node]],
+ path: StrPath | SupportsWrite[str],
+ *,
+ # **options passed to `to_latex`
+ pos: _Pos[_Node, _PosT] | Collection[_Pos[_Node, _PosT]] = "pos",
+ tikz_options: str = "",
+ default_node_options: str = "",
+ node_options: str | dict[_Node, str] = "node_options",
+ node_label: str | dict[_Node, str] = "node_label",
+ default_edge_options: str = "",
+ edge_options: str | dict[tuple[_Node, _Node], str] = "edge_options",
+ edge_label: str | dict[tuple[_Node, _Node], str] = "edge_label",
+ edge_label_options: str | dict[tuple[_Node, _Node], str] = "edge_label_options",
+ caption: str = "",
+ latex_label: str = "",
+ sub_captions: Collection[str] | None = None,
+ sub_labels: Collection[str] | None = None,
+ n_rows: int = 1,
+ as_document: bool = True,
+ document_wrapper: str = ...,
+ figure_wrapper: str = ...,
+ subfigure_wrapper: str = ...,
+) -> None: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/drawing/nx_pydot.pyi b/python/helpers/typeshed/stubs/networkx/networkx/drawing/nx_pydot.pyi
index 1a84f8d510f0..fa0cb03f9944 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/drawing/nx_pydot.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/drawing/nx_pydot.pyi
@@ -1,12 +1,18 @@
+from _typeshed import SupportsRead, SupportsWrite
+from os import PathLike
+from typing import Any
+
+from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
+from pydot import Dot # type: ignore[import-not-found] # pyright: ignore[reportMissingImports]
__all__ = ["write_dot", "read_dot", "graphviz_layout", "pydot_layout", "to_pydot", "from_pydot"]
-def write_dot(G, path) -> None: ...
+def write_dot(G: Graph[_Node], path: str | PathLike[Any] | SupportsWrite[str]) -> None: ...
@_dispatchable
-def read_dot(path): ...
+def read_dot(path: str | PathLike[Any] | SupportsRead[str]) -> Graph[str]: ...
@_dispatchable
-def from_pydot(P): ...
-def to_pydot(N): ...
-def graphviz_layout(G, prog: str = "neato", root=None): ...
-def pydot_layout(G, prog: str = "neato", root=None): ...
+def from_pydot(P: Dot) -> Graph[str]: ...
+def to_pydot(N: Graph[_Node]) -> Dot: ...
+def graphviz_layout(G: Graph[_Node], prog: str = "neato", root: _Node | None = None) -> dict[_Node, tuple[float, float]]: ...
+def pydot_layout(G: Graph[_Node], prog: str = "neato", root: _Node | None = None) -> dict[_Node, tuple[float, float]]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/drawing/nx_pylab.pyi b/python/helpers/typeshed/stubs/networkx/networkx/drawing/nx_pylab.pyi
index 57b2af84afa9..0d7275400d40 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/drawing/nx_pylab.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/drawing/nx_pylab.pyi
@@ -1,6 +1,17 @@
-from _typeshed import Incomplete
-from collections.abc import Collection, Iterable, Sequence
+from _typeshed import Incomplete, SupportsItems
+from collections.abc import Callable, Collection, Hashable, Iterable, Mapping, Sequence
+from typing import Any, Generic, Literal, TypedDict, TypeVar, overload, type_check_only
+from typing_extensions import TypeAlias, Unpack
+import numpy as np
+from matplotlib.axes import Axes # type: ignore[import-not-found]
+from matplotlib.collections import LineCollection, PathCollection # type: ignore[import-not-found]
+from matplotlib.colors import Colormap # type: ignore[import-not-found]
+from matplotlib.patches import FancyArrowPatch # type: ignore[import-not-found]
+from matplotlib.text import Text # type: ignore[import-not-found]
+from matplotlib.typing import ColorType # type: ignore[import-not-found]
+from networkx._typing import Array2D
+from networkx.classes.digraph import DiGraph
from networkx.classes.graph import Graph, _Node
__all__ = [
@@ -23,14 +34,87 @@ __all__ = [
"draw_forceatlas2",
]
+_G = TypeVar("_G", bound=Graph[Any])
+
+# types from matplotlib
+_FontSize: TypeAlias = Literal["xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large"] | float
+_FontWeight: TypeAlias = (
+ Literal[
+ "ultralight",
+ "light",
+ "normal",
+ "regular",
+ "book",
+ "medium",
+ "roman",
+ "semibold",
+ "demibold",
+ "demi",
+ "bold",
+ "heavy",
+ "extra bold",
+ "black",
+ ]
+ | int
+)
+_HAlign: TypeAlias = Literal["left", "center", "right"]
+_VAlign: TypeAlias = Literal["baseline", "bottom", "center", "center_baseline", "top"]
+
+@type_check_only
+class _DrawNetworkxKwds(TypedDict, Generic[_Node], total=False):
+ # draw nodes keywords; keep in sync with draw_networkx_nodes
+ node_color: ColorType | Collection[ColorType] | Collection[float]
+ cmap: str | Colormap | None
+ vmin: float | None
+ vmax: float | None
+ linewidths: float | Collection[float] | None
+ edgecolors: Literal["face", "none"] | ColorType | Collection[ColorType] | Collection[float] | None
+ margins: float | tuple[float, float] | None
+ # draw edges keywords; keep in sync with draw_networkx_edges
+ edgelist: Collection[_Node | Hashable] | None # (u, v, k) for multigraphs and (u, v) for simple graphs
+ width: float | Collection[float]
+ edge_color: ColorType | Collection[ColorType]
+ style: str | Collection[str]
+ arrowstyle: str | Collection[str] | None
+ arrowsize: float | list[int] | list[float]
+ edge_cmap: Colormap | None
+ edge_vmin: float | None
+ edge_vmax: float | None
+ connectionstyle: str | Iterable[str]
+ min_source_margin: int | Collection[int]
+ min_target_margin: int | Collection[int]
+ # draw labels keywords; keep in sync with draw_networkx_labels
+ labels: Mapping[_Node, object] | None
+ font_size: _FontSize | Mapping[_Node, _FontSize]
+ font_color: ColorType | Mapping[_Node, Colormap]
+ font_family: str | Mapping[_Node, str]
+ font_weight: _FontWeight | Mapping[_Node, _FontWeight]
+ bbox: dict[str, Any] | None
+ horizontalalignment: _HAlign
+ verticalalignment: _VAlign
+ clip_on: bool
+ # common keywords
+ nodelist: Sequence[_Node] | None
+ node_size: float | Collection[float]
+ node_shape: str
+ alpha: float | Collection[float] | None
+ label: str | None
+ hide_ticks: bool
+
def apply_matplotlib_colors(
- G: Graph[_Node], src_attr: str, dest_attr: str, map, vmin: float | None = None, vmax: float | None = None, nodes: bool = True
+ G: Graph[_Node],
+ src_attr: str,
+ dest_attr: str,
+ map: str | Colormap,
+ vmin: float | None = None,
+ vmax: float | None = None,
+ nodes: bool = True,
) -> None: ...
def display(
- G: Graph[_Node],
- canvas=None,
+ G: _G,
+ canvas: Axes | None = None,
*,
- pos=...,
+ pos: str | Callable[[_G], Mapping[_Node, Collection[float]]] = ...,
node_visible: str | bool = ...,
node_color: str = ...,
node_size: str | float = ...,
@@ -41,7 +125,7 @@ def display(
node_border_color: str = ...,
edge_visible: str | bool = ...,
edge_width: str | int = ...,
- edge_color=...,
+ edge_color: str | ColorType = ...,
edge_label: str = ...,
edge_style: str = ...,
edge_alpha: str | float = ...,
@@ -51,97 +135,220 @@ def display(
edge_source_margin: str | int = ...,
edge_target_margin: str | int = ...,
hide_ticks: bool = True,
-): ...
-def draw(G: Graph[_Node], pos=None, ax=None, **kwds) -> None: ...
-def draw_networkx(G: Graph[_Node], pos=None, arrows=None, with_labels: bool = True, **kwds) -> None: ...
-def draw_networkx_nodes(
+) -> _G: ...
+def draw(
G: Graph[_Node],
- pos,
- nodelist: Collection[Incomplete] | None = None,
- node_size: Incomplete | int = 300,
- node_color: str | Sequence[str] = "#1f78b4",
+ pos: Mapping[_Node, Collection[float]] | None = None,
+ ax: Axes | None = None,
+ *,
+ with_labels: bool = ..., # default depends on whether a label argument is passed
+ **kwds: Unpack[_DrawNetworkxKwds[_Node]],
+) -> None: ...
+def draw_networkx(
+ G: Graph[_Node],
+ pos: Mapping[_Node, Collection[float]] | None = None,
+ arrows: bool | None = None,
+ with_labels: bool = True,
+ *,
+ ax: Axes | None = None,
+ **kwds: Unpack[_DrawNetworkxKwds[_Node]],
+) -> None: ...
+def draw_networkx_nodes( # keep in sync with _DrawNetworkxKwds above
+ G: Graph[_Node],
+ pos: Mapping[_Node, Collection[float]],
+ nodelist: Collection[_Node] | None = None,
+ node_size: float | Collection[float] = 300,
+ node_color: ColorType | Collection[ColorType] | Collection[float] = "#1f78b4",
node_shape: str = "o",
- alpha=None,
- cmap=None,
- vmin=None,
- vmax=None,
- ax=None,
- linewidths=None,
- edgecolors=None,
- label=None,
- margins=None,
+ alpha: float | Collection[float] | None = None,
+ cmap: str | Colormap | None = None,
+ vmin: float | None = None,
+ vmax: float | None = None,
+ ax: Axes | None = None,
+ linewidths: float | Collection[float] | None = None,
+ edgecolors: Literal["face", "none"] | ColorType | Collection[ColorType] | Collection[float] | None = None,
+ label: str | None = None,
+ margins: float | tuple[float, float] | None = None,
hide_ticks: bool = True,
-): ...
+) -> PathCollection: ...
+@overload # arrows=None -> LineCollection if G is undirected, list[FancyArrowPatch] if G is directed
+def draw_networkx_edges( # keep in sync with _DrawNetworkxKwds above
+ G: Graph[_Node],
+ pos: Mapping[_Node, Collection[float]],
+ edgelist: Collection[_Node | Hashable] | None = None, # (u, v, k) for multigraphs and (u, v) for simple graphs
+ width: float | Collection[float] = 1.0,
+ edge_color: ColorType | Collection[ColorType] = "k",
+ style: str | Collection[str] = "solid",
+ alpha: float | Collection[float] | None = None,
+ arrowstyle: str | Collection[str] | None = None,
+ arrowsize: float | list[int] | list[float] = 10, # documented as int, mpl accepts float
+ edge_cmap: Colormap | None = None,
+ edge_vmin: float | None = None,
+ edge_vmax: float | None = None,
+ ax: Axes | None = None,
+ arrows: None = None,
+ label: str | None = None, # documented as str, mpl accepts any object as it calls str on it
+ node_size: float | Collection[float] = 300,
+ nodelist: Sequence[_Node] | None = None,
+ node_shape: str = "o",
+ connectionstyle: str | Iterable[str] = "arc3",
+ min_source_margin: int | Collection[int] = 0, # documented as int, mpl accepts float
+ min_target_margin: int | Collection[int] = 0, # documented as int, mpl accepts float
+ hide_ticks: bool = True,
+) -> LineCollection | list[FancyArrowPatch]: ...
+@overload # directed graph and arrows=None -> list[FancyArrowPatch]
+def draw_networkx_edges(
+ G: DiGraph[_Node],
+ pos: Mapping[_Node, Collection[float]],
+ edgelist: Collection[_Node | Hashable] | None = None, # (u, v, k) for multigraphs and (u, v) for simple graphs
+ width: float | Collection[float] = 1.0,
+ edge_color: ColorType | Collection[ColorType] = "k",
+ style: str | Collection[str] = "solid",
+ alpha: float | Collection[float] | None = None,
+ arrowstyle: str | Collection[str] | None = None,
+ arrowsize: float | list[int] | list[float] = 10, # documented as int, mpl accepts float
+ edge_cmap: Colormap | None = None,
+ edge_vmin: float | None = None,
+ edge_vmax: float | None = None,
+ ax: Axes | None = None,
+ arrows: None = None,
+ label: str | None = None, # documented as str, mpl accepts any object as it calls str on it
+ node_size: float | Collection[float] = 300,
+ nodelist: Sequence[_Node] | None = None,
+ node_shape: str = "o",
+ connectionstyle: str | Iterable[str] = "arc3",
+ min_source_margin: int | Collection[int] = 0, # documented as int, mpl accepts float
+ min_target_margin: int | Collection[int] = 0, # documented as int, mpl accepts float
+ hide_ticks: bool = True,
+) -> list[FancyArrowPatch]: ...
+@overload # arrows=True -> list[FancyArrowPatch]
def draw_networkx_edges(
G: Graph[_Node],
- pos,
- edgelist=None,
- width: float = 1.0,
- edge_color: str = "k",
- style: str = "solid",
- alpha=None,
- arrowstyle=None,
- arrowsize: int = 10,
- edge_cmap=None,
- edge_vmin=None,
- edge_vmax=None,
- ax=None,
- arrows=None,
- label=None,
- node_size: Incomplete | int = 300,
- nodelist: list[Incomplete] | None = None,
+ pos: Mapping[_Node, Collection[float]],
+ edgelist: Collection[_Node | Hashable] | None = None, # (u, v, k) for multigraphs and (u, v) for simple graphs
+ width: float | Collection[float] = 1.0,
+ edge_color: ColorType | Collection[ColorType] = "k",
+ style: str | Collection[str] = "solid",
+ alpha: float | Collection[float] | None = None,
+ arrowstyle: str | Collection[str] | None = None,
+ arrowsize: float | list[int] | list[float] = 10, # documented as int, mpl accepts float
+ edge_cmap: Colormap | None = None,
+ edge_vmin: float | None = None,
+ edge_vmax: float | None = None,
+ ax: Axes | None = None,
+ *,
+ arrows: Literal[True],
+ label: str | None = None, # documented as str, mpl accepts any object as it calls str on it
+ node_size: float | Collection[float] = 300,
+ nodelist: Sequence[_Node] | None = None,
node_shape: str = "o",
- connectionstyle: str = "arc3",
- min_source_margin: int = 0,
- min_target_margin: int = 0,
+ connectionstyle: str | Iterable[str] = "arc3",
+ min_source_margin: int | Collection[int] = 0, # documented as int, mpl accepts float
+ min_target_margin: int | Collection[int] = 0, # documented as int, mpl accepts float
hide_ticks: bool = True,
-): ...
-def draw_networkx_labels(
+) -> list[FancyArrowPatch]: ...
+@overload # arrows=False -> LineCollection
+def draw_networkx_edges(
G: Graph[_Node],
- pos,
- labels=None,
- font_size: int = 12,
- font_color: str = "k",
- font_family: str = "sans-serif",
- font_weight: str = "normal",
- alpha=None,
- bbox=None,
- horizontalalignment: str = "center",
- verticalalignment: str = "center",
- ax=None,
+ pos: Mapping[_Node, Collection[float]],
+ edgelist: Collection[_Node | Hashable] | None = None, # (u, v, k) for multigraphs and (u, v) for simple graphs
+ width: float | Collection[float] = 1.0,
+ edge_color: ColorType | Collection[ColorType] = "k",
+ style: str | Collection[str] = "solid",
+ alpha: float | Collection[float] | None = None,
+ *,
+ edge_cmap: Colormap | None = None,
+ edge_vmin: float | None = None,
+ edge_vmax: float | None = None,
+ ax: Axes | None = None,
+ arrows: Literal[False],
+ label: str | None = None, # documented as str, mpl accepts any object as it calls str on it
+ node_size: float | Collection[float] = 300,
+ nodelist: Sequence[_Node] | None = None,
+ node_shape: str = "o",
+ hide_ticks: bool = True,
+) -> LineCollection: ...
+def draw_networkx_labels( # keep in sync with _DrawNetworkxKwds above
+ G: Graph[_Node],
+ pos: Mapping[_Node, Collection[float]],
+ labels: Mapping[_Node, object] | None = None, # labels are explicitly converted to str
+ font_size: _FontSize | Mapping[_Node, _FontSize] = 12,
+ font_color: ColorType | Mapping[_Node, Colormap] = "k",
+ font_family: str | Mapping[_Node, str] = "sans-serif",
+ font_weight: _FontWeight | Mapping[_Node, _FontWeight] = "normal",
+ alpha: float | Mapping[_Node, float] | None = None,
+ bbox: dict[str, Any] | None = None, # Any comes from mpl
+ horizontalalignment: _HAlign = "center", # doc is wrong, doesn't really accept array
+ verticalalignment: _VAlign = "center", # doc is wrong, doesn't really accept array
+ ax: Axes | None = None,
clip_on: bool = True,
hide_ticks: bool = True,
-): ...
+) -> dict[_Node, Text]: ...
def draw_networkx_edge_labels(
+ # TODO: find a way to have a covariant list for params annotated with `something | list[Incomplete]`
G: Graph[_Node],
- pos,
- edge_labels=None,
- label_pos: float = 0.5,
- font_size: int = 10,
- font_color: str = "k",
+ pos: Mapping[_Node, Collection[float]],
+ edge_labels: (
+ SupportsItems[
+ Collection[_Node | Hashable], # (u, v, k) for multigraphs and (u, v) for simple graphs
+ object, # labels are explicitly converted to str and nx internally passes non-str
+ ]
+ | None
+ ) = None,
+ label_pos: float | list[Incomplete] = 0.5,
+ font_size: _FontSize | list[Incomplete] = 10,
+ font_color: ColorType | list[Incomplete] = "k",
font_family: str = "sans-serif",
- font_weight: str = "normal",
- alpha=None,
- bbox=None,
- horizontalalignment: str = "center",
- verticalalignment: str = "center",
- ax=None,
- rotate: bool = True,
+ font_weight: _FontWeight | list[Incomplete] = "normal",
+ alpha: float | list[Incomplete] | None = None,
+ bbox: dict[str, Any] | None = None, # Any comes from mpl
+ horizontalalignment: _HAlign | list[Incomplete] = "center",
+ verticalalignment: _VAlign | list[Incomplete] = "center",
+ ax: Axes | None = None,
+ rotate: bool | list[bool] = True,
clip_on: bool = True,
- node_size: int = 300,
- nodelist: list[Incomplete] | None = None,
- connectionstyle: str = "arc3",
+ node_size: float | Collection[float] = 300,
+ nodelist: Sequence[_Node] | None = None,
+ connectionstyle: str | Iterable[str] = "arc3",
hide_ticks: bool = True,
-): ...
-def draw_bipartite(G: Graph[_Node], **kwargs): ...
-def draw_circular(G: Graph[_Node], **kwargs) -> None: ...
-def draw_kamada_kawai(G: Graph[_Node], **kwargs) -> None: ...
-def draw_random(G: Graph[_Node], **kwargs) -> None: ...
-def draw_spectral(G: Graph[_Node], **kwargs) -> None: ...
-def draw_spring(G: Graph[_Node], **kwargs) -> None: ...
-def draw_shell(G: Graph[_Node], nlist=None, **kwargs) -> None: ...
-def draw_planar(G: Graph[_Node], **kwargs) -> None: ...
-def draw_forceatlas2(G: Graph[_Node], **kwargs) -> None: ...
+) -> dict[tuple[_Node, _Node] | tuple[_Node, _Node, Any], Text]: ... # Any is for multigraph key
+def draw_bipartite(
+ G: Graph[_Node], *, ax: Axes | None = None, with_labels: bool = ..., **kwargs: Unpack[_DrawNetworkxKwds[_Node]]
+) -> None: ...
+def draw_circular(
+ G: Graph[_Node], *, ax: Axes | None = None, with_labels: bool = ..., **kwargs: Unpack[_DrawNetworkxKwds[_Node]]
+) -> None: ...
+def draw_kamada_kawai(
+ G: Graph[_Node], *, ax: Axes | None = None, with_labels: bool = ..., **kwargs: Unpack[_DrawNetworkxKwds[_Node]]
+) -> None: ...
+def draw_random(
+ G: Graph[_Node], *, ax: Axes | None = None, with_labels: bool = ..., **kwargs: Unpack[_DrawNetworkxKwds[_Node]]
+) -> None: ...
+def draw_spectral(
+ G: Graph[_Node], *, ax: Axes | None = None, with_labels: bool = ..., **kwargs: Unpack[_DrawNetworkxKwds[_Node]]
+) -> None: ...
+def draw_spring(
+ G: Graph[_Node], *, ax: Axes | None = None, with_labels: bool = ..., **kwargs: Unpack[_DrawNetworkxKwds[_Node]]
+) -> None: ...
+def draw_shell(
+ G: Graph[_Node],
+ nlist: Collection[Collection[_Node]] | None = None,
+ *,
+ ax: Axes | None = None,
+ with_labels: bool = ...,
+ **kwargs: Unpack[_DrawNetworkxKwds[_Node]],
+) -> None: ...
+def draw_planar(
+ G: Graph[_Node], *, ax: Axes | None = None, with_labels: bool = ..., **kwargs: Unpack[_DrawNetworkxKwds[_Node]]
+) -> None: ...
+def draw_forceatlas2(
+ G: Graph[_Node], *, ax: Axes | None = None, with_labels: bool = ..., **kwargs: Unpack[_DrawNetworkxKwds[_Node]]
+) -> None: ...
def apply_alpha(
- colors, alpha: float | Iterable[float], elem_list, cmap=None, vmin: float | None = None, vmax: float | None = None
-): ...
+ colors: ColorType | Collection[ColorType] | Collection[float],
+ alpha: float | Collection[float],
+ elem_list: Collection[object], # nx objects (nodes, edges, labels) but its content is not used!
+ cmap: str | Colormap | None = None,
+ vmin: float | None = None,
+ vmax: float | None = None,
+) -> Array2D[np.float64]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/atlas.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/atlas.pyi
index d90e9a73844e..7b89477ab253 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/generators/atlas.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/atlas.pyi
@@ -1,8 +1,11 @@
import sys
+from _typeshed import Incomplete
from typing import Final
from networkx.utils.backends import _dispatchable
+from ..classes.graph import Graph
+
if sys.version_info >= (3, 11):
from importlib.resources.abc import Traversable
else:
@@ -14,6 +17,6 @@ NUM_GRAPHS: Final = 1253
ATLAS_FILE: Final[Traversable]
@_dispatchable
-def graph_atlas(i): ...
+def graph_atlas(i) -> Graph[Incomplete]: ...
@_dispatchable
-def graph_atlas_g(): ...
+def graph_atlas_g() -> list[Graph[Incomplete]]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/degree_seq.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/degree_seq.pyi
index 325b6d911e6a..0378d273caaf 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/generators/degree_seq.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/degree_seq.pyi
@@ -2,6 +2,11 @@ from _typeshed import Incomplete
from networkx.utils.backends import _dispatchable
+from ..classes.digraph import DiGraph
+from ..classes.graph import Graph
+from ..classes.multidigraph import MultiDiGraph
+from ..classes.multigraph import MultiGraph
+
__all__ = [
"configuration_model",
"directed_configuration_model",
@@ -13,19 +18,21 @@ __all__ = [
]
@_dispatchable
-def configuration_model(deg_sequence, create_using=None, seed=None): ...
+def configuration_model(deg_sequence, create_using=None, seed=None) -> MultiGraph[Incomplete]: ...
@_dispatchable
-def directed_configuration_model(in_degree_sequence, out_degree_sequence, create_using=None, seed=None): ...
+def directed_configuration_model(
+ in_degree_sequence, out_degree_sequence, create_using=None, seed=None
+) -> MultiDiGraph[Incomplete]: ...
@_dispatchable
-def expected_degree_graph(w, seed=None, selfloops: bool = True): ...
+def expected_degree_graph(w, seed=None, selfloops: bool = True) -> Graph[Incomplete]: ...
@_dispatchable
def havel_hakimi_graph(deg_sequence, create_using=None): ...
@_dispatchable
-def directed_havel_hakimi_graph(in_deg_sequence, out_deg_sequence, create_using=None): ...
+def directed_havel_hakimi_graph(in_deg_sequence, out_deg_sequence, create_using=None) -> DiGraph[Incomplete]: ...
@_dispatchable
def degree_sequence_tree(deg_sequence, create_using=None): ...
@_dispatchable
-def random_degree_sequence_graph(sequence, seed=None, tries: int = 10): ...
+def random_degree_sequence_graph(sequence, seed=None, tries: int = 10) -> Graph[Incomplete]: ...
class DegreeSequenceRandomGraph:
rng: Incomplete
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/directed.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/directed.pyi
index d1a121c985da..dbddbecf23c0 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/generators/directed.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/directed.pyi
@@ -1,5 +1,9 @@
+from _typeshed import Incomplete
+
from networkx.utils.backends import _dispatchable
+from ..classes import MultiDiGraph
+
__all__ = ["gn_graph", "gnc_graph", "gnr_graph", "random_k_out_graph", "scale_free_graph"]
@_dispatchable
@@ -23,4 +27,4 @@ def scale_free_graph(
@_dispatchable
def random_uniform_k_out_graph(n: int, k: int, self_loops: bool = True, with_replacement: bool = True, seed=None): ...
@_dispatchable
-def random_k_out_graph(n, k, alpha, self_loops: bool = True, seed=None): ...
+def random_k_out_graph(n, k, alpha, self_loops: bool = True, seed=None) -> MultiDiGraph[Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/duplication.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/duplication.pyi
index 7371b6dc5ffd..387f761bea60 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/generators/duplication.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/duplication.pyi
@@ -1,8 +1,12 @@
+from _typeshed import Incomplete
+
from networkx.utils.backends import _dispatchable
+from ..classes.graph import Graph
+
__all__ = ["partial_duplication_graph", "duplication_divergence_graph"]
@_dispatchable
def partial_duplication_graph(N, n, p, q, seed=None): ...
@_dispatchable
-def duplication_divergence_graph(n, p, seed=None): ...
+def duplication_divergence_graph(n, p, seed=None) -> Graph[Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/geometric.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/geometric.pyi
index 2147ac1b0104..d6493e7f6275 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/generators/geometric.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/geometric.pyi
@@ -23,7 +23,9 @@ def soft_random_geometric_graph(n, radius, dim: int = 2, pos=None, p: float = 2,
@_dispatchable
def geographical_threshold_graph(n, theta, dim: int = 2, pos=None, weight=None, metric=None, p_dist=None, seed=None): ...
@_dispatchable
-def waxman_graph(n, beta: float = 0.4, alpha: float = 0.1, L=None, domain=(0, 0, 1, 1), metric=None, seed=None): ...
+def waxman_graph(
+ n, beta: float = 0.4, alpha: float = 0.1, L=None, domain=(0, 0, 1, 1), metric=None, seed=None
+) -> Graph[Incomplete]: ...
# docstring marks p as int, but it still works with floats. So I think it's better for consistency
@_dispatchable
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/internet_as_graphs.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/internet_as_graphs.pyi
index a6bd04e98414..05932bf9e32d 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/generators/internet_as_graphs.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/internet_as_graphs.pyi
@@ -31,8 +31,8 @@ class AS_graph_generator:
def choose_node_pref_attach(self, node_list): ...
def add_customer(self, i, j) -> None: ...
def add_node(self, i, kind, reg2prob, avg_deg, t_edge_prob): ...
- def add_m_peering_link(self, m, to_kind): ...
- def add_cp_peering_link(self, cp, to_kind): ...
+ def add_m_peering_link(self, m, to_kind) -> bool: ...
+ def add_cp_peering_link(self, cp, to_kind) -> bool: ...
regions: Incomplete
def graph_regions(self, rn) -> None: ...
def add_peering_links(self, from_kind, to_kind) -> None: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/joint_degree_seq.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/joint_degree_seq.pyi
index 2407905149d3..2814dd544138 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/generators/joint_degree_seq.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/joint_degree_seq.pyi
@@ -1,14 +1,19 @@
+from _typeshed import Incomplete
from collections.abc import Mapping, Sequence
from networkx.utils.backends import _dispatchable
from numpy.random import RandomState
+from ..classes.graph import Graph
+
__all__ = ["is_valid_joint_degree", "is_valid_directed_joint_degree", "joint_degree_graph", "directed_joint_degree_graph"]
@_dispatchable
def is_valid_joint_degree(joint_degrees: Mapping[int, Mapping[int, int]]) -> bool: ...
@_dispatchable
-def joint_degree_graph(joint_degrees: Mapping[int, Mapping[int, int]], seed: int | RandomState | None = None): ...
+def joint_degree_graph(
+ joint_degrees: Mapping[int, Mapping[int, int]], seed: int | RandomState | None = None
+) -> Graph[Incomplete]: ...
@_dispatchable
def is_valid_directed_joint_degree(
in_degrees: Sequence[int], out_degrees: Sequence[int], nkk: Mapping[int, Mapping[int, int]]
@@ -19,4 +24,4 @@ def directed_joint_degree_graph(
out_degrees: Sequence[int],
nkk: Mapping[int, Mapping[int, int]],
seed: int | RandomState | None = None,
-): ...
+) -> Graph[Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/random_graphs.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/random_graphs.pyi
index 958a5028e064..10a3b070fead 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/generators/random_graphs.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/random_graphs.pyi
@@ -1,5 +1,9 @@
+from _typeshed import Incomplete
+
from networkx.utils.backends import _dispatchable
+from ..classes.graph import Graph
+
__all__ = [
"fast_gnp_random_graph",
"gnp_random_graph",
@@ -43,11 +47,11 @@ def connected_watts_strogatz_graph(n, k, p, tries: int = 100, seed=None): ...
@_dispatchable
def random_regular_graph(d, n, seed=None): ...
@_dispatchable
-def barabasi_albert_graph(n, m, seed=None, initial_graph=None): ...
+def barabasi_albert_graph(n, m, seed=None, initial_graph=None) -> Graph[Incomplete]: ...
@_dispatchable
-def dual_barabasi_albert_graph(n, m1, m2, p, seed=None, initial_graph=None): ...
+def dual_barabasi_albert_graph(n, m1, m2, p, seed=None, initial_graph=None) -> Graph[Incomplete]: ...
@_dispatchable
-def extended_barabasi_albert_graph(n, m, p, q, seed=None): ...
+def extended_barabasi_albert_graph(n, m, p, q, seed=None) -> Graph[Incomplete]: ...
@_dispatchable
def powerlaw_cluster_graph(n, m, p, seed=None): ...
@_dispatchable
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/spectral_graph_forge.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/spectral_graph_forge.pyi
index a4af66065a7b..f96534191207 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/generators/spectral_graph_forge.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/spectral_graph_forge.pyi
@@ -1,6 +1,10 @@
+from _typeshed import Incomplete
+
from networkx.utils.backends import _dispatchable
+from ..classes.graph import Graph
+
__all__ = ["spectral_graph_forge"]
@_dispatchable
-def spectral_graph_forge(G, alpha, transformation: str = "identity", seed=None): ...
+def spectral_graph_forge(G, alpha, transformation: str = "identity", seed=None) -> Graph[Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/trees.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/trees.pyi
index 8652af12a6a7..9ebd32f0d81f 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/generators/trees.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/trees.pyi
@@ -2,6 +2,8 @@ from _typeshed import Incomplete
from networkx.utils.backends import _dispatchable
+from ..classes.digraph import DiGraph
+
__all__ = [
"prefix_tree",
"prefix_tree_recursive",
@@ -14,9 +16,9 @@ __all__ = [
]
@_dispatchable
-def prefix_tree(paths): ...
+def prefix_tree(paths) -> DiGraph[Incomplete]: ...
@_dispatchable
-def prefix_tree_recursive(paths): ...
+def prefix_tree_recursive(paths) -> DiGraph[Incomplete]: ...
@_dispatchable
def random_labeled_tree(n, *, seed=None): ...
@_dispatchable
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/triads.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/triads.pyi
index 1e536b89355c..4e85d0677afa 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/generators/triads.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/triads.pyi
@@ -1,5 +1,7 @@
+from _typeshed import Incomplete
from typing import Final
+from networkx import DiGraph
from networkx.utils.backends import _dispatchable
__all__ = ["triad_graph"]
@@ -7,4 +9,4 @@ __all__ = ["triad_graph"]
TRIAD_EDGES: Final[dict[str, list[str]]]
@_dispatchable
-def triad_graph(triad_name): ...
+def triad_graph(triad_name) -> DiGraph[Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi b/python/helpers/typeshed/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi
index 6e74030449e9..3ff0fd053a4d 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi
@@ -1,28 +1,45 @@
+from typing import Literal
+
+import numpy as np
+from networkx._typing import Array1D, Seed
+from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
__all__ = ["algebraic_connectivity", "fiedler_vector", "spectral_ordering", "spectral_bisection"]
-class _PCGSolver:
- def __init__(self, A, M) -> None: ...
- def solve(self, B, tol): ...
-
-class _LUSolver:
- def __init__(self, A) -> None: ...
- def solve(self, B, tol=None): ...
-
@_dispatchable
def algebraic_connectivity(
- G, weight: str = "weight", normalized: bool = False, tol: float = 1e-08, method: str = "tracemin_pcg", seed=None
-): ...
+ G: Graph[_Node],
+ weight: str | None = "weight",
+ normalized: bool = False,
+ tol: float = 1e-08,
+ method: Literal["tracemin_pcg", "tracemin_lu", "lanczos", "lobpcg"] = "tracemin_pcg",
+ seed: Seed | None = None,
+) -> float: ...
@_dispatchable
def fiedler_vector(
- G, weight: str = "weight", normalized: bool = False, tol: float = 1e-08, method: str = "tracemin_pcg", seed=None
-): ...
+ G: Graph[_Node],
+ weight: str | None = "weight",
+ normalized: bool = False,
+ tol: float = 1e-08,
+ method: Literal["tracemin_pcg", "tracemin_lu", "lanczos", "lobpcg"] = "tracemin_pcg",
+ seed: Seed | None = None,
+) -> Array1D[np.float64]: ...
@_dispatchable
def spectral_ordering(
- G, weight: str = "weight", normalized: bool = False, tol: float = 1e-08, method: str = "tracemin_pcg", seed=None
-): ...
+ G: Graph[_Node],
+ weight: str | None = "weight",
+ normalized: bool = False,
+ tol: float = 1e-08,
+ method: Literal["tracemin_pcg", "tracemin_lu", "lanczos", "lobpcg"] = "tracemin_pcg",
+ seed: Seed | None = None,
+) -> list[_Node]: ...
@_dispatchable
def spectral_bisection(
- G, weight: str = "weight", normalized: bool = False, tol: float = 1e-08, method: str = "tracemin_pcg", seed=None
-): ...
+ G: Graph[_Node],
+ weight: str | None = "weight",
+ normalized: bool = False,
+ tol: float = 1e-08,
+ method: Literal["tracemin_pcg", "tracemin_lu", "lanczos", "lobpcg"] = "tracemin_pcg",
+ seed: Seed | None = None,
+) -> tuple[set[_Node], set[_Node]]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/linalg/attrmatrix.pyi b/python/helpers/typeshed/stubs/networkx/networkx/linalg/attrmatrix.pyi
index 01fba7355c3b..90b19c231e4d 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/linalg/attrmatrix.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/linalg/attrmatrix.pyi
@@ -1,8 +1,41 @@
+from _typeshed import Incomplete
+from collections.abc import Collection
+from typing import Any, Literal
+
+from networkx._typing import Array2D
+from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
+from numpy.typing import DTypeLike
+from scipy.sparse import lil_array # type: ignore[import-untyped] # pyright: ignore[reportMissingImports]
__all__ = ["attr_matrix", "attr_sparse_matrix"]
@_dispatchable
-def attr_matrix(G, edge_attr=None, node_attr=None, normalized: bool = False, rc_order=None, dtype=None, order=None): ...
+def attr_matrix(
+ G: Graph[_Node],
+ edge_attr: str | None = None,
+ node_attr: str | None = None, # runtime also accepts `Callable[[_Node], object]`, but it is not documented
+ normalized: bool = False, # runtime also accepts `Callable[[_Node, _Node], object]`, but it is not documented
+ rc_order: Collection[_Node] | None = None,
+ dtype: DTypeLike | None = None,
+ order: Literal["C", "F"] | None = None,
+ # TODO: overload on rc_order and node_attr
+ # (rc_order:[node], node_attr:None) -> 2D-array
+ # (rc_order:[any], node_attr:str) -> 2D-array
+ # (rc_order:None, node_attr:None) -> (2D-array, list[node])
+ # (rc_order:None, node_attr:str) -> (2D-array, list[any])
+) -> Array2D[Incomplete] | tuple[Array2D[Incomplete], list[_Node] | list[Any]]: ...
@_dispatchable
-def attr_sparse_matrix(G, edge_attr=None, node_attr=None, normalized: bool = False, rc_order=None, dtype=None): ...
+def attr_sparse_matrix(
+ G: Graph[_Node],
+ edge_attr: str | None = None,
+ node_attr: str | None = None, # runtime also accepts `Callable[[_Node], object]`, but it is not documented
+ normalized: bool = False, # runtime also accepts `Callable[[_Node, _Node], object]`, but it is not documented
+ rc_order: Collection[_Node] | None = None,
+ dtype: DTypeLike | None = None,
+ # TODO: overload on rc_order and node_attr
+ # (rc_order:[node], node_attr:None) -> lil_array
+ # (rc_order:[any], node_attr:str) -> lil_array
+ # (rc_order:None, node_attr:None) -> (lil_array, list[node])
+ # (rc_order:None, node_attr:str) -> (lil_array, list[any])
+) -> lil_array | tuple[lil_array, list[_Node] | list[Any]]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi b/python/helpers/typeshed/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi
index b2713db482ab..6cc9100b9870 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi
@@ -1,9 +1,10 @@
-from _typeshed import Incomplete
from collections.abc import Collection
+from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
+from scipy.sparse import csr_array # type: ignore[import-untyped] # pyright: ignore[reportMissingImports]
__all__ = ["bethe_hessian_matrix"]
@_dispatchable
-def bethe_hessian_matrix(G, r=None, nodelist: Collection[Incomplete] | None = None): ...
+def bethe_hessian_matrix(G: Graph[_Node], r: float | None = None, nodelist: Collection[_Node] | None = None) -> csr_array: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/linalg/graphmatrix.pyi b/python/helpers/typeshed/stubs/networkx/networkx/linalg/graphmatrix.pyi
index d4277651bd65..7d08761770d7 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/linalg/graphmatrix.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/linalg/graphmatrix.pyi
@@ -1,11 +1,31 @@
-from _typeshed import Incomplete
-from collections.abc import Collection
+from collections.abc import Collection, Hashable
+from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
+from numpy.typing import DTypeLike
+from scipy.sparse import csc_array, csr_array # type: ignore[import-untyped] # pyright: ignore[reportMissingImports]
__all__ = ["incidence_matrix", "adjacency_matrix"]
@_dispatchable
-def incidence_matrix(G, nodelist: Collection[Incomplete] | None = None, edgelist=None, oriented: bool = False, weight=None): ...
+def incidence_matrix(
+ G: Graph[_Node],
+ nodelist: Collection[_Node] | None = None,
+ edgelist: (
+ Collection[
+ # Requiring tuples to represent an edge might be too strict as runtime does not check the type of
+ # the collection. We can replace the tuples by `Collection[_Node | Hashable]` if people complain.
+ tuple[_Node, _Node] # for normal graphs, this is (u, v)
+ | tuple[_Node, _Node, Hashable] # for multigraphs, this is (u, v, key)
+ ]
+ | None
+ ) = None,
+ oriented: bool = False,
+ weight: str | None = None,
+ *,
+ dtype: DTypeLike | None = None,
+) -> csc_array: ...
@_dispatchable
-def adjacency_matrix(G, nodelist: Collection[Incomplete] | None = None, dtype=None, weight: str = "weight"): ...
+def adjacency_matrix(
+ G: Graph[_Node], nodelist: Collection[_Node] | None = None, dtype: DTypeLike | None = None, weight: str | None = "weight"
+) -> csr_array: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/linalg/laplacianmatrix.pyi b/python/helpers/typeshed/stubs/networkx/networkx/linalg/laplacianmatrix.pyi
index c8f14ba08ed5..089d31900cfb 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/linalg/laplacianmatrix.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/linalg/laplacianmatrix.pyi
@@ -1,7 +1,12 @@
-from _typeshed import Incomplete
from collections.abc import Collection
+from typing import Literal
+import numpy as np
+from networkx._typing import Array2D
+from networkx.classes.digraph import DiGraph
+from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
+from scipy.sparse import csr_array # type: ignore[import-untyped] # pyright: ignore[reportMissingImports]
__all__ = [
"laplacian_matrix",
@@ -11,14 +16,24 @@ __all__ = [
]
@_dispatchable
-def laplacian_matrix(G, nodelist: Collection[Incomplete] | None = None, weight: str = "weight"): ...
+def laplacian_matrix(G: Graph[_Node], nodelist: Collection[_Node] | None = None, weight: str | None = "weight") -> csr_array: ...
@_dispatchable
-def normalized_laplacian_matrix(G, nodelist: Collection[Incomplete] | None = None, weight: str = "weight"): ...
+def normalized_laplacian_matrix(
+ G: Graph[_Node], nodelist: Collection[_Node] | None = None, weight: str | None = "weight"
+) -> csr_array: ...
@_dispatchable
def directed_laplacian_matrix(
- G, nodelist: Collection[Incomplete] | None = None, weight: str = "weight", walk_type=None, alpha: float = 0.95
-): ...
+ G: DiGraph[_Node],
+ nodelist: Collection[_Node] | None = None,
+ weight: str | None = "weight",
+ walk_type: Literal["random", "lazy", "pagerank"] | None = None,
+ alpha: float = 0.95,
+) -> Array2D[np.float64]: ...
@_dispatchable
def directed_combinatorial_laplacian_matrix(
- G, nodelist: Collection[Incomplete] | None = None, weight: str = "weight", walk_type=None, alpha: float = 0.95
-): ...
+ G: DiGraph[_Node],
+ nodelist: Collection[_Node] | None = None,
+ weight: str | None = "weight",
+ walk_type: Literal["random", "lazy", "pagerank"] | None = None,
+ alpha: float = 0.95,
+) -> Array2D[np.float64]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/linalg/modularitymatrix.pyi b/python/helpers/typeshed/stubs/networkx/networkx/linalg/modularitymatrix.pyi
index c1f9be8d5e11..d7537db42afc 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/linalg/modularitymatrix.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/linalg/modularitymatrix.pyi
@@ -1,11 +1,18 @@
-from _typeshed import Incomplete
from collections.abc import Collection
+import numpy as np
+from networkx._typing import Array2D
+from networkx.classes.digraph import DiGraph
+from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
__all__ = ["modularity_matrix", "directed_modularity_matrix"]
@_dispatchable
-def modularity_matrix(G, nodelist: Collection[Incomplete] | None = None, weight=None): ...
+def modularity_matrix(
+ G: Graph[_Node], nodelist: Collection[_Node] | None = None, weight: str | None = None
+) -> Array2D[np.float64]: ...
@_dispatchable
-def directed_modularity_matrix(G, nodelist: Collection[Incomplete] | None = None, weight=None): ...
+def directed_modularity_matrix(
+ G: DiGraph[_Node], nodelist: Collection[_Node] | None = None, weight: str | None = None
+) -> Array2D[np.float64]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/linalg/spectrum.pyi b/python/helpers/typeshed/stubs/networkx/networkx/linalg/spectrum.pyi
index c30aa5061aa8..05e4455eb7da 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/linalg/spectrum.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/linalg/spectrum.pyi
@@ -1,3 +1,6 @@
+import numpy as np
+from networkx._typing import Array1D
+from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
__all__ = [
@@ -9,12 +12,12 @@ __all__ = [
]
@_dispatchable
-def laplacian_spectrum(G, weight: str = "weight"): ...
+def laplacian_spectrum(G: Graph[_Node], weight: str | None = "weight") -> Array1D[np.float64]: ...
@_dispatchable
-def normalized_laplacian_spectrum(G, weight: str = "weight"): ...
+def normalized_laplacian_spectrum(G: Graph[_Node], weight: str | None = "weight") -> Array1D[np.float64]: ...
@_dispatchable
-def adjacency_spectrum(G, weight: str = "weight"): ...
+def adjacency_spectrum(G: Graph[_Node], weight: str | None = "weight") -> Array1D[np.complex128]: ...
@_dispatchable
-def modularity_spectrum(G): ...
+def modularity_spectrum(G: Graph[_Node]) -> Array1D[np.complex128]: ...
@_dispatchable
-def bethe_hessian_spectrum(G, r=None): ...
+def bethe_hessian_spectrum(G: Graph[_Node], r: float | None = None) -> Array1D[np.float64]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/adjlist.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/adjlist.pyi
index 2f482e88bef1..db9cc2c44455 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/adjlist.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/adjlist.pyi
@@ -1,11 +1,10 @@
-from _typeshed import Incomplete
from collections.abc import Generator
from networkx.utils.backends import _dispatchable
__all__ = ["generate_adjlist", "write_adjlist", "parse_adjlist", "read_adjlist"]
-def generate_adjlist(G, delimiter: str = " ") -> Generator[Incomplete, None, None]: ...
+def generate_adjlist(G, delimiter: str = " ") -> Generator[str, None, None]: ...
def write_adjlist(G, path, comments: str = "#", delimiter: str = " ", encoding: str = "utf-8") -> None: ...
@_dispatchable
def parse_adjlist(lines, comments: str = "#", delimiter=None, create_using=None, nodetype=None): ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/gexf.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/gexf.pyi
index f7b39bd1cd2e..473abbce0ca2 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/gexf.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/gexf.pyi
@@ -1,5 +1,6 @@
from _typeshed import Incomplete
from collections.abc import Generator
+from typing import Final, Literal
from networkx.utils.backends import _dispatchable
@@ -17,7 +18,7 @@ class GEXF:
xml_type: Incomplete
python_type: Incomplete
def construct_types(self) -> None: ...
- convert_bool: Incomplete
+ convert_bool: Final[dict[Literal["true", "false", "True", "False", "0", 0, "1", 1], bool]]
NS_GEXF: Incomplete
NS_VIZ: Incomplete
NS_XSI: Incomplete
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/graph6.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/graph6.pyi
index 3dd12da9f429..5e743d598191 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/graph6.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/graph6.pyi
@@ -7,7 +7,7 @@ from networkx.utils.backends import _dispatchable
__all__ = ["from_graph6_bytes", "read_graph6", "to_graph6_bytes", "write_graph6"]
@_dispatchable
-def from_graph6_bytes(bytes_in): ...
+def from_graph6_bytes(bytes_in) -> Graph[Incomplete]: ...
def to_graph6_bytes(G, nodes=None, header: bool = True): ...
@_dispatchable
def read_graph6(path): ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/graphml.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/graphml.pyi
index 60cc90a5cea5..b2c109cb40f5 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/graphml.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/graphml.pyi
@@ -1,6 +1,6 @@
from _typeshed import Incomplete
from collections.abc import Generator
-from typing import Final
+from typing import Final, Literal
from networkx.utils.backends import _dispatchable
@@ -49,7 +49,7 @@ class GraphML:
xml_type: Incomplete
python_type: Incomplete
def construct_types(self) -> None: ...
- convert_bool: Incomplete
+ convert_bool: Final[dict[Literal["true", "false", "0", 0, "1", 1], bool]]
def get_xml_type(self, key): ...
class GraphMLWriter(GraphML):
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi
index f1745015fad3..28cd6225a41b 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi
@@ -1,8 +1,10 @@
+from typing import Any
+
from networkx.utils.backends import _dispatchable
__all__ = ["adjacency_data", "adjacency_graph"]
-@_dispatchable
-def adjacency_data(G, attrs={"id": "id", "key": "key"}): ...
+# Any: Complex type union
+def adjacency_data(G, attrs={"id": "id", "key": "key"}) -> dict[str, Any]: ...
@_dispatchable
def adjacency_graph(data, directed: bool = False, multigraph: bool = True, attrs={"id": "id", "key": "key"}): ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi
index 6b5155209711..663a83c01e33 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi
@@ -1,7 +1,10 @@
+from typing import Any
+
from networkx.utils.backends import _dispatchable
__all__ = ["cytoscape_data", "cytoscape_graph"]
-def cytoscape_data(G, name: str = "name", ident: str = "id"): ...
+# Any: Complex type union
+def cytoscape_data(G, name: str = "name", ident: str = "id") -> dict[str, Any]: ...
@_dispatchable
def cytoscape_graph(data, name: str = "name", ident: str = "id"): ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi
index a75f916bb626..a27130c8f3de 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi
@@ -1,12 +1,11 @@
-from _typeshed import Incomplete
from collections.abc import Generator
from networkx.utils.backends import _dispatchable
__all__ = ["generate_multiline_adjlist", "write_multiline_adjlist", "parse_multiline_adjlist", "read_multiline_adjlist"]
-def generate_multiline_adjlist(G, delimiter: str = " ") -> Generator[Incomplete, None, None]: ...
-def write_multiline_adjlist(G, path, delimiter: str = " ", comments: str = "#", encoding: str = "utf-8") -> None: ...
+def generate_multiline_adjlist(G, delimiter: str = " ") -> Generator[str, None, None]: ...
+def write_multiline_adjlist(G, path, delimiter=" ", comments="#", encoding="utf-8") -> None: ...
@_dispatchable
def parse_multiline_adjlist(lines, comments: str = "#", delimiter=None, create_using=None, nodetype=None, edgetype=None): ...
@_dispatchable
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/p2g.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/p2g.pyi
index f9da22dd2611..ba1c1b2def09 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/p2g.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/p2g.pyi
@@ -1,7 +1,11 @@
+from _typeshed import Incomplete
+
from networkx.utils.backends import _dispatchable
+from ..classes.multidigraph import MultiDiGraph
+
def write_p2g(G, path, encoding: str = "utf-8") -> None: ...
@_dispatchable
-def read_p2g(path, encoding: str = "utf-8"): ...
+def read_p2g(path, encoding: str = "utf-8") -> MultiDiGraph[Incomplete]: ...
@_dispatchable
-def parse_p2g(lines): ...
+def parse_p2g(lines) -> MultiDiGraph[Incomplete]: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/sparse6.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/sparse6.pyi
index b1e6e56a50d3..2e2b96fea664 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/sparse6.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/sparse6.pyi
@@ -1,9 +1,13 @@
+from _typeshed import Incomplete
+
from networkx.utils.backends import _dispatchable
+from ..classes.graph import Graph
+
__all__ = ["from_sparse6_bytes", "read_sparse6", "to_sparse6_bytes", "write_sparse6"]
@_dispatchable
-def from_sparse6_bytes(string): ...
+def from_sparse6_bytes(string) -> Graph[Incomplete]: ...
def to_sparse6_bytes(G, nodes=None, header: bool = True): ...
@_dispatchable
def read_sparse6(path): ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/utils/__init__.pyi b/python/helpers/typeshed/stubs/networkx/networkx/utils/__init__.pyi
index 960b428e67c1..c615a6e8a8d1 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/utils/__init__.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/utils/__init__.pyi
@@ -1,11 +1,9 @@
from networkx.utils.backends import *
-from networkx.utils.backends import _dispatchable as _dispatchable # for pytype to see the re-export in networkx/__init__.py
from networkx.utils.configs import *
from networkx.utils.configs import NetworkXConfig
from networkx.utils.decorators import *
from networkx.utils.heaps import *
from networkx.utils.misc import *
-from networkx.utils.misc import _clear_cache as _clear_cache # for pytype to see the re-export in networkx/__init__.py
from networkx.utils.random_sequence import *
from networkx.utils.rcm import *
from networkx.utils.union_find import *
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/utils/decorators.pyi b/python/helpers/typeshed/stubs/networkx/networkx/utils/decorators.pyi
index af8b401c8600..c12cc5421171 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/utils/decorators.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/utils/decorators.pyi
@@ -1,4 +1,5 @@
from _typeshed import Incomplete
+from collections.abc import Callable
from typing import NamedTuple
__all__ = ["not_implemented_for", "open_file", "nodes_or_number", "np_random_state", "py_random_state", "argmap"]
@@ -11,8 +12,8 @@ def py_random_state(random_state_argument): ...
class argmap:
def __init__(self, func, *args, try_finally: bool = False) -> None: ...
- def __call__(self, f): ...
- def compile(self, f): ...
+ def __call__(self, f) -> Callable[..., Incomplete]: ...
+ def compile(self, f) -> Callable[..., Incomplete]: ...
def assemble(self, f): ...
@classmethod
def signature(cls, f): ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/utils/heaps.pyi b/python/helpers/typeshed/stubs/networkx/networkx/utils/heaps.pyi
index 95862f2da880..f03e301f9e4b 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/utils/heaps.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/utils/heaps.pyi
@@ -4,15 +4,16 @@ __all__ = ["MinHeap", "PairingHeap", "BinaryHeap"]
class MinHeap:
class _Item:
+ __slots__ = ("key", "value")
key: Incomplete
value: Incomplete
def __init__(self, key, value) -> None: ...
def __init__(self) -> None: ...
- def min(self) -> None: ...
- def pop(self) -> None: ...
- def get(self, key, default=None) -> None: ...
- def insert(self, key, value, allow_increase: bool = False) -> None: ...
+ def min(self) -> tuple[Incomplete, Incomplete]: ...
+ def pop(self) -> tuple[Incomplete, Incomplete]: ...
+ def get(self, key, default=None): ...
+ def insert(self, key, value, allow_increase: bool = False) -> bool: ...
def __nonzero__(self): ...
def __bool__(self) -> bool: ...
def __len__(self) -> int: ...
@@ -20,6 +21,7 @@ class MinHeap:
class PairingHeap(MinHeap):
class _Node(MinHeap._Item):
+ __slots__ = ("left", "next", "prev", "parent")
left: Incomplete
next: Incomplete
prev: Incomplete
@@ -27,14 +29,14 @@ class PairingHeap(MinHeap):
def __init__(self, key, value) -> None: ...
def __init__(self) -> None: ...
- def min(self): ...
- def pop(self): ...
+ def min(self) -> tuple[Incomplete, Incomplete]: ...
+ def pop(self) -> tuple[Incomplete, Incomplete]: ...
def get(self, key, default=None): ...
- def insert(self, key, value, allow_increase: bool = False): ...
+ def insert(self, key, value, allow_increase: bool = False) -> bool: ...
class BinaryHeap(MinHeap):
def __init__(self) -> None: ...
- def min(self): ...
- def pop(self): ...
+ def min(self) -> tuple[Incomplete, Incomplete]: ...
+ def pop(self) -> tuple[Incomplete, Incomplete]: ...
def get(self, key, default=None): ...
- def insert(self, key, value, allow_increase: bool = False): ...
+ def insert(self, key, value, allow_increase: bool = False) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/utils/mapped_queue.pyi b/python/helpers/typeshed/stubs/networkx/networkx/utils/mapped_queue.pyi
index 86e8c0e0ecde..38710ddb601f 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/utils/mapped_queue.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/utils/mapped_queue.pyi
@@ -4,6 +4,7 @@ from collections.abc import Iterator
__all__ = ["MappedQueue"]
class _HeapElement:
+ __slots__ = ["priority", "element", "_hash"]
priority: Incomplete
element: Incomplete
def __init__(self, priority, element) -> None: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/utils/misc.pyi b/python/helpers/typeshed/stubs/networkx/networkx/utils/misc.pyi
index 62fb3c6b3b94..0df8f1814066 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/utils/misc.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/utils/misc.pyi
@@ -52,7 +52,7 @@ class PythonRandomInterface:
def paretovariate(self, shape): ...
def create_py_random_state(random_state: _RandomState = None): ...
-def nodes_equal(nodes1, nodes2): ...
-def edges_equal(edges1, edges2): ...
-def graphs_equal(graph1, graph2): ...
+def nodes_equal(nodes1, nodes2) -> bool: ...
+def edges_equal(edges1, edges2) -> bool: ...
+def graphs_equal(graph1, graph2) -> bool: ...
def _clear_cache(G) -> None: ...
diff --git a/python/helpers/typeshed/stubs/networkx/networkx/utils/random_sequence.pyi b/python/helpers/typeshed/stubs/networkx/networkx/utils/random_sequence.pyi
index 101004bba6ba..e2985019248d 100644
--- a/python/helpers/typeshed/stubs/networkx/networkx/utils/random_sequence.pyi
+++ b/python/helpers/typeshed/stubs/networkx/networkx/utils/random_sequence.pyi
@@ -8,7 +8,7 @@ __all__ = [
]
def powerlaw_sequence(n, exponent: float = 2.0, seed=None): ...
-def zipf_rv(alpha, xmin: int = 1, seed=None): ...
+def zipf_rv(alpha, xmin: int = 1, seed=None) -> int: ...
def cumulative_distribution(distribution): ...
def discrete_sequence(n, distribution=None, cdistribution=None, seed=None): ...
def random_weighted_sample(mapping, k, seed=None): ...
diff --git a/python/helpers/typeshed/stubs/oauthlib/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/oauthlib/@tests/stubtest_allowlist.txt
deleted file mode 100644
index 7159ad88ba1c..000000000000
--- a/python/helpers/typeshed/stubs/oauthlib/@tests/stubtest_allowlist.txt
+++ /dev/null
@@ -1 +0,0 @@
-oauthlib.oauth1.rfc5849.parameters.prepare_headers
diff --git a/python/helpers/typeshed/stubs/oauthlib/METADATA.toml b/python/helpers/typeshed/stubs/oauthlib/METADATA.toml
index 04672bf3475d..dcc24fcec5c9 100644
--- a/python/helpers/typeshed/stubs/oauthlib/METADATA.toml
+++ b/python/helpers/typeshed/stubs/oauthlib/METADATA.toml
@@ -1,6 +1,2 @@
-version = "3.2.*"
+version = "3.3.*"
upstream_repository = "https://github.com/oauthlib/oauthlib"
-partial_stub = true
-
-[tool.stubtest]
-ignore_missing_stub = true
diff --git a/python/helpers/typeshed/stubs/oauthlib/oauthlib/common.pyi b/python/helpers/typeshed/stubs/oauthlib/oauthlib/common.pyi
index 9fd6b272e212..15112d51863c 100644
--- a/python/helpers/typeshed/stubs/oauthlib/oauthlib/common.pyi
+++ b/python/helpers/typeshed/stubs/oauthlib/oauthlib/common.pyi
@@ -52,7 +52,10 @@ class CaseInsensitiveDict(dict[str, Incomplete]):
def __contains__(self, k: object) -> bool: ...
def __delitem__(self, k: str) -> None: ...
def __getitem__(self, k: str): ...
- def get(self, k: str, default=None) -> Incomplete | None: ...
+ @overload
+ def get(self, k: str, default: None = None) -> Incomplete | None: ...
+ @overload
+ def get(self, k: str, default): ...
def __setitem__(self, k: str, v) -> None: ...
def update(self, *args, **kwargs) -> None: ...
diff --git a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi
index 6730205943f7..a909c15b1d78 100644
--- a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi
+++ b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi
@@ -1,8 +1,10 @@
from _typeshed import Incomplete
-from collections.abc import Callable
+from collections.abc import Callable, Mapping
from logging import Logger
from typing import Any, Final
+from oauthlib.common import _HTTPMethod
+
log: Logger
SIGNATURE_HMAC_SHA1: Final[str]
SIGNATURE_HMAC_SHA256: Final[str]
@@ -56,4 +58,11 @@ class Client:
): ...
def get_oauth_signature(self, request): ...
def get_oauth_params(self, request): ...
- def sign(self, uri, http_method: str = "GET", body: str | None = None, headers: dict[str, str] | None = None, realm=None): ...
+ def sign(
+ self,
+ uri: str,
+ http_method: _HTTPMethod = "GET",
+ body: str | dict[str, str] | list[tuple[str, str]] | None = None,
+ headers: Mapping[str, str] | None = None,
+ realm=None,
+ ): ...
diff --git a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth1/rfc5849/parameters.pyi b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth1/rfc5849/parameters.pyi
index 82f078da673c..068ab541d353 100644
--- a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth1/rfc5849/parameters.pyi
+++ b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth1/rfc5849/parameters.pyi
@@ -1,5 +1,5 @@
from _typeshed import Incomplete
-def prepare_headers(oauth_params, headers: Incomplete | None = ..., realm: Incomplete | None = ...): ...
+def prepare_headers(params, headers: Incomplete | None = ..., realm: Incomplete | None = ...): ...
def prepare_form_encoded_body(oauth_params, body): ...
def prepare_request_uri_query(oauth_params, uri): ...
diff --git a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/__init__.pyi b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/__init__.pyi
index 8d5cb1a614b6..117244ab80d8 100644
--- a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/__init__.pyi
+++ b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/__init__.pyi
@@ -58,3 +58,8 @@ from .rfc6749.request_validator import RequestValidator as RequestValidator
from .rfc6749.tokens import BearerToken as BearerToken, OAuth2Token as OAuth2Token
from .rfc6749.utils import is_secure_transport as is_secure_transport
from .rfc8628.clients import DeviceClient as DeviceClient
+from .rfc8628.endpoints import (
+ DeviceApplicationServer as DeviceApplicationServer,
+ DeviceAuthorizationEndpoint as DeviceAuthorizationEndpoint,
+)
+from .rfc8628.grant_types import DeviceCodeGrant as DeviceCodeGrant
diff --git a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc6749/endpoints/pre_configured.pyi b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc6749/endpoints/pre_configured.pyi
index 581c565c82e5..02414844d9fc 100644
--- a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc6749/endpoints/pre_configured.pyi
+++ b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc6749/endpoints/pre_configured.pyi
@@ -2,6 +2,7 @@ from _typeshed import Unused
from collections.abc import Callable
from oauthlib.common import Request
+from oauthlib.oauth2.rfc8628.grant_types import DeviceCodeGrant
from ..grant_types import (
AuthorizationCodeGrant,
@@ -24,6 +25,7 @@ class Server(AuthorizationEndpoint, IntrospectEndpoint, TokenEndpoint, ResourceE
password_grant: ResourceOwnerPasswordCredentialsGrant
credentials_grant: ClientCredentialsGrant
refresh_grant: RefreshTokenGrant
+ device_code_grant: DeviceCodeGrant
bearer: BearerToken
def __init__(
self,
diff --git a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc6749/endpoints/token.pyi b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc6749/endpoints/token.pyi
index 5634512740a0..421ff886a122 100644
--- a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc6749/endpoints/token.pyi
+++ b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc6749/endpoints/token.pyi
@@ -23,7 +23,7 @@ class TokenEndpoint(BaseEndpoint):
self,
uri: str,
http_method: _HTTPMethod = "POST",
- body: str | None = None,
+ body: str | dict[str, str] | list[tuple[str, str]] | None = None,
headers: dict[str, str] | None = None,
credentials=None,
grant_type_for_scope=None,
diff --git a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc6749/parameters.pyi b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc6749/parameters.pyi
index 0d8fdfcc0987..c82a710d5205 100644
--- a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc6749/parameters.pyi
+++ b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc6749/parameters.pyi
@@ -44,3 +44,4 @@ def parse_token_response(
body: str | bytes | bytearray, scope: str | set[object] | tuple[object] | list[object] | None = None
) -> OAuth2Token: ...
def validate_token_parameters(params: dict[str, Incomplete]) -> None: ...
+def parse_expires(params: dict[str, Incomplete]) -> tuple[int | None, float | None, float | None]: ...
diff --git a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc6749/request_validator.pyi b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc6749/request_validator.pyi
index a057ee5aab69..4c60b62ec170 100644
--- a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc6749/request_validator.pyi
+++ b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc6749/request_validator.pyi
@@ -1,11 +1,12 @@
from collections.abc import Mapping
from logging import Logger
-from typing import Literal, TypedDict
+from typing import Literal, TypedDict, type_check_only
from typing_extensions import NotRequired
from oauthlib.common import Request
from oauthlib.oauth2.rfc6749.clients import Client
+@type_check_only
class _BearerToken(TypedDict):
token_type: Literal["Bearer"]
access_token: str
@@ -14,6 +15,7 @@ class _BearerToken(TypedDict):
refresh_token: NotRequired[str]
state: NotRequired[str]
+@type_check_only
class _AuthorizationCode(TypedDict):
code: str
state: NotRequired[str]
@@ -57,3 +59,4 @@ class RequestValidator:
def is_pkce_required(self, client_id: str, request: Request) -> bool: ...
def get_code_challenge(self, code: str, request: Request) -> str: ...
def get_code_challenge_method(self, code: str, request: Request) -> str: ...
+ def is_origin_allowed(self, client_id: str, origin, request: Request, *args, **kwargs) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc6749/tokens.pyi b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc6749/tokens.pyi
index a0cdc5bdfcf8..d55acfe0f56f 100644
--- a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc6749/tokens.pyi
+++ b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc6749/tokens.pyi
@@ -46,11 +46,13 @@ def signed_token_generator(private_pem: str, **kwargs) -> Callable[[Request], st
def get_token_from_header(request: Request) -> str | None: ...
class TokenBase:
+ __slots__ = ()
def __call__(self, request: Request, refresh_token: bool = False) -> None: ...
def validate_request(self, request: Request) -> bool: ...
def estimate_type(self, request: Request) -> int: ...
class BearerToken(TokenBase):
+ __slots__ = ("request_validator", "token_generator", "refresh_token_generator", "expires_in")
request_validator: RequestValidator | None
token_generator: Callable[[Request], str]
refresh_token_generator: Callable[[Request], str]
diff --git a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/__init__.pyi b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/__init__.pyi
index cb35af91145e..8963764427d2 100644
--- a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/__init__.pyi
+++ b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/__init__.pyi
@@ -1,3 +1,9 @@
from logging import Logger
+from .errors import (
+ AuthorizationPendingError as AuthorizationPendingError,
+ ExpiredTokenError as ExpiredTokenError,
+ SlowDownError as SlowDownError,
+)
+
log: Logger
diff --git a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/endpoints/__init__.pyi b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/endpoints/__init__.pyi
new file mode 100644
index 000000000000..65712957c40d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/endpoints/__init__.pyi
@@ -0,0 +1,2 @@
+from .device_authorization import DeviceAuthorizationEndpoint as DeviceAuthorizationEndpoint
+from .pre_configured import DeviceApplicationServer as DeviceApplicationServer
diff --git a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/endpoints/device_authorization.pyi b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/endpoints/device_authorization.pyi
new file mode 100644
index 000000000000..ee67416c128a
--- /dev/null
+++ b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/endpoints/device_authorization.pyi
@@ -0,0 +1,32 @@
+from collections.abc import Callable
+from logging import Logger
+
+from oauthlib.common import Request, _HTTPMethod
+from oauthlib.oauth2.rfc6749.endpoints.base import BaseEndpoint
+from oauthlib.openid.connect.core.request_validator import RequestValidator
+
+log: Logger
+
+class DeviceAuthorizationEndpoint(BaseEndpoint):
+ request_validator: RequestValidator
+ user_code_generator: Callable[[None], str] | None
+ def __init__(
+ self,
+ request_validator: RequestValidator,
+ verification_uri: str,
+ expires_in: int = 1800,
+ interval: int | None = None,
+ verification_uri_complete: str | None = None,
+ user_code_generator: Callable[[None], str] | None = None,
+ ) -> None: ...
+ @property
+ def interval(self) -> int | None: ...
+ @property
+ def expires_in(self) -> int: ...
+ @property
+ def verification_uri(self) -> str: ...
+ def verification_uri_complete(self, user_code: str) -> str | None: ...
+ def validate_device_authorization_request(self, request: Request) -> None: ...
+ def create_device_authorization_response(
+ self, uri: str, http_method: _HTTPMethod = "POST", body: str | None = None, headers: dict[str, str] | None = None
+ ) -> tuple[dict[str, str], dict[str, str | int], int]: ...
diff --git a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/endpoints/pre_configured.pyi b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/endpoints/pre_configured.pyi
new file mode 100644
index 000000000000..943520667914
--- /dev/null
+++ b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/endpoints/pre_configured.pyi
@@ -0,0 +1,16 @@
+from collections.abc import Callable
+
+from oauthlib.openid.connect.core.request_validator import RequestValidator
+
+from .device_authorization import DeviceAuthorizationEndpoint
+
+class DeviceApplicationServer(DeviceAuthorizationEndpoint):
+ def __init__(
+ self,
+ request_validator: RequestValidator,
+ verification_uri: str,
+ interval: int = 5,
+ verification_uri_complete: str | None = None,
+ user_code_generator: Callable[[None], str] | None = None,
+ **kwargs,
+ ) -> None: ...
diff --git a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/errors.pyi b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/errors.pyi
new file mode 100644
index 000000000000..9858cb379e23
--- /dev/null
+++ b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/errors.pyi
@@ -0,0 +1,13 @@
+from oauthlib.oauth2.rfc6749.errors import OAuth2Error
+
+class AuthorizationPendingError(OAuth2Error):
+ error: str
+
+class SlowDownError(OAuth2Error):
+ error: str
+
+class ExpiredTokenError(OAuth2Error):
+ error: str
+
+class AccessDenied(OAuth2Error):
+ error: str
diff --git a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/grant_types/__init__.pyi b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/grant_types/__init__.pyi
new file mode 100644
index 000000000000..6163747ce035
--- /dev/null
+++ b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/grant_types/__init__.pyi
@@ -0,0 +1 @@
+from .device_code import DeviceCodeGrant as DeviceCodeGrant
diff --git a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/grant_types/device_code.pyi b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/grant_types/device_code.pyi
new file mode 100644
index 000000000000..0f70cb3b542b
--- /dev/null
+++ b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/grant_types/device_code.pyi
@@ -0,0 +1,8 @@
+from oauthlib.common import Request
+from oauthlib.oauth2.rfc6749.grant_types.base import GrantTypeBase
+from oauthlib.oauth2.rfc6749.tokens import TokenBase
+
+class DeviceCodeGrant(GrantTypeBase):
+ def create_authorization_response(self, request: Request, token_handler: TokenBase) -> tuple[dict[str, str], str, int]: ...
+ def validate_token_request(self, request: Request) -> None: ...
+ def create_token_response(self, request: Request, token_handler: TokenBase) -> tuple[dict[str, str], str, int]: ...
diff --git a/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/request_validator.pyi b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/request_validator.pyi
new file mode 100644
index 000000000000..9fa7b042c5a0
--- /dev/null
+++ b/python/helpers/typeshed/stubs/oauthlib/oauthlib/oauth2/rfc8628/request_validator.pyi
@@ -0,0 +1,5 @@
+from oauthlib.common import Request
+from oauthlib.oauth2 import RequestValidator as OAuth2RequestValidator
+
+class RequestValidator(OAuth2RequestValidator):
+ def client_authentication_required(self, request: Request, *args, **kwargs) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/oauthlib/oauthlib/openid/connect/core/endpoints/pre_configured.pyi b/python/helpers/typeshed/stubs/oauthlib/oauthlib/openid/connect/core/endpoints/pre_configured.pyi
index 0b6aae6a772e..379d9cd847bf 100644
--- a/python/helpers/typeshed/stubs/oauthlib/oauthlib/openid/connect/core/endpoints/pre_configured.pyi
+++ b/python/helpers/typeshed/stubs/oauthlib/oauthlib/openid/connect/core/endpoints/pre_configured.pyi
@@ -18,6 +18,7 @@ from oauthlib.oauth2.rfc6749.grant_types import (
)
from oauthlib.oauth2.rfc6749.request_validator import RequestValidator as OAuth2RequestValidator
from oauthlib.oauth2.rfc6749.tokens import BearerToken
+from oauthlib.oauth2.rfc8628.grant_types import DeviceCodeGrant
from ..grant_types import AuthorizationCodeGrant, HybridGrant, ImplicitGrant
from ..grant_types.dispatchers import (
@@ -37,6 +38,7 @@ class Server(AuthorizationEndpoint, IntrospectEndpoint, TokenEndpoint, ResourceE
openid_connect_auth: AuthorizationCodeGrant
openid_connect_implicit: ImplicitGrant
openid_connect_hybrid: HybridGrant
+ device_code_grant: DeviceCodeGrant
bearer: BearerToken
jwt: JWTToken
auth_grant_choice: AuthorizationCodeGrantDispatcher
diff --git a/python/helpers/typeshed/stubs/oauthlib/oauthlib/openid/connect/core/tokens.pyi b/python/helpers/typeshed/stubs/oauthlib/oauthlib/openid/connect/core/tokens.pyi
index 081db3dec53a..39c52b1d0753 100644
--- a/python/helpers/typeshed/stubs/oauthlib/oauthlib/openid/connect/core/tokens.pyi
+++ b/python/helpers/typeshed/stubs/oauthlib/oauthlib/openid/connect/core/tokens.pyi
@@ -6,6 +6,7 @@ from oauthlib.oauth2.rfc6749.tokens import TokenBase as TokenBase
from .request_validator import RequestValidator
class JWTToken(TokenBase):
+ __slots__ = ("request_validator", "token_generator", "refresh_token_generator", "expires_in")
request_validator: RequestValidator
token_generator: Callable[[Request], str] | Callable[[Request, bool], str]
refresh_token_generator: Callable[[Request], str] | Callable[[Request, bool], str]
diff --git a/python/helpers/typeshed/stubs/openpyxl/@tests/test_cases/check_base_descriptors.py b/python/helpers/typeshed/stubs/openpyxl/@tests/test_cases/check_base_descriptors.py
index a0d5e6d03330..858892a974bc 100644
--- a/python/helpers/typeshed/stubs/openpyxl/@tests/test_cases/check_base_descriptors.py
+++ b/python/helpers/typeshed/stubs/openpyxl/@tests/test_cases/check_base_descriptors.py
@@ -236,7 +236,7 @@ with_descriptors.set_tuple_none = 0
with_descriptors.set_tuple_none = 0.0
with_descriptors.set_tuple_none = None
with_descriptors.set_tuple_none = "none" # pyright: ignore[reportAttributeAccessIssue] # false negative in mypy
-with_descriptors.set_tuple_none = object() # pyright: ignore[reportAttributeAccessIssue] # false negative in mypy
+with_descriptors.set_tuple_none = object() # type: ignore
with_descriptors.noneset_tuple = "a"
diff --git a/python/helpers/typeshed/stubs/openpyxl/@tests/test_cases/check_nested_descriptors.py b/python/helpers/typeshed/stubs/openpyxl/@tests/test_cases/check_nested_descriptors.py
index 1526334acbe2..3d36ab215fff 100644
--- a/python/helpers/typeshed/stubs/openpyxl/@tests/test_cases/check_nested_descriptors.py
+++ b/python/helpers/typeshed/stubs/openpyxl/@tests/test_cases/check_nested_descriptors.py
@@ -222,15 +222,13 @@ with_descriptors.set_tuple_none = 0
with_descriptors.set_tuple_none = 0.0
with_descriptors.set_tuple_none = None
with_descriptors.set_tuple_none = "none" # pyright: ignore[reportAttributeAccessIssue] # false negative in mypy
-with_descriptors.set_tuple_none = object() # pyright: ignore[reportAttributeAccessIssue] # false negative in mypy
+with_descriptors.set_tuple_none = object() # type: ignore
with_descriptors.set_tuple_none = cast(_HasTagAndGet[Literal["a"]], _)
with_descriptors.set_tuple_none = cast( # pyright: ignore[reportAttributeAccessIssue] # false negative in mypy
_HasTagAndGet[str], _
)
with_descriptors.set_tuple_none = cast(_HasTagAndGet[None], _)
-with_descriptors.set_tuple_none = cast( # pyright: ignore[reportAttributeAccessIssue] # false negative in mypy
- _HasTagAndGet[object], _
-)
+with_descriptors.set_tuple_none = cast(_HasTagAndGet[object], _) # type: ignore
with_descriptors.noneset_tuple = "a"
diff --git a/python/helpers/typeshed/stubs/openpyxl/openpyxl/__init__.pyi b/python/helpers/typeshed/stubs/openpyxl/openpyxl/__init__.pyi
index de5224812ce7..627a7afc5720 100644
--- a/python/helpers/typeshed/stubs/openpyxl/openpyxl/__init__.pyi
+++ b/python/helpers/typeshed/stubs/openpyxl/openpyxl/__init__.pyi
@@ -1,5 +1,5 @@
from _typeshed import StrPath, SupportsRead, SupportsWrite
-from typing import IO, Literal, Protocol
+from typing import IO, Literal, Protocol, type_check_only
from typing_extensions import TypeAlias
from openpyxl.compat.numbers import NUMPY as NUMPY
@@ -27,5 +27,6 @@ _VisibilityType: TypeAlias = Literal["visible", "hidden", "veryHidden"] # noqa:
_ZipFileFileProtocol: TypeAlias = StrPath | IO[bytes] | SupportsRead[bytes] # noqa: Y047
_ZipFileFileWriteProtocol: TypeAlias = StrPath | IO[bytes] | SupportsWrite[bytes] # noqa: Y047
+@type_check_only
class _Decodable(Protocol): # noqa: Y046
def decode(self, encoding: str, /) -> str: ...
diff --git a/python/helpers/typeshed/stubs/openpyxl/openpyxl/cell/cell.pyi b/python/helpers/typeshed/stubs/openpyxl/openpyxl/cell/cell.pyi
index fb5cbb54545c..2b75f5a281fa 100644
--- a/python/helpers/typeshed/stubs/openpyxl/openpyxl/cell/cell.pyi
+++ b/python/helpers/typeshed/stubs/openpyxl/openpyxl/cell/cell.pyi
@@ -36,6 +36,7 @@ def get_type(t: type, value: object) -> Literal["n", "s", "d", "f"] | None: ...
def get_time_format(t: _TimeTypes) -> str: ...
class Cell(StyleableObject):
+ __slots__ = ("row", "column", "_value", "data_type", "parent", "_hyperlink", "_comment")
row: int
column: int
data_type: str
@@ -82,6 +83,7 @@ class Cell(StyleableObject):
def comment(self, value: Comment | None) -> None: ...
class MergedCell(StyleableObject):
+ __slots__ = ("row", "column")
data_type: str
comment: Comment | None
hyperlink: Hyperlink | None
diff --git a/python/helpers/typeshed/stubs/openpyxl/openpyxl/cell/read_only.pyi b/python/helpers/typeshed/stubs/openpyxl/openpyxl/cell/read_only.pyi
index b8dd7cf3226e..5635de13ee80 100644
--- a/python/helpers/typeshed/stubs/openpyxl/openpyxl/cell/read_only.pyi
+++ b/python/helpers/typeshed/stubs/openpyxl/openpyxl/cell/read_only.pyi
@@ -12,6 +12,7 @@ from openpyxl.workbook.child import _WorkbookChild
from openpyxl.worksheet._read_only import ReadOnlyWorksheet
class ReadOnlyCell:
+ __slots__ = ("parent", "row", "column", "_value", "data_type", "_style_id")
parent: _WorkbookChild | ReadOnlyWorksheet
row: Incomplete
column: Incomplete
@@ -58,6 +59,7 @@ class ReadOnlyCell:
def value(self, value: None) -> None: ...
class EmptyCell:
+ __slots__ = ()
value: Incomplete
is_date: bool
font: Incomplete
diff --git a/python/helpers/typeshed/stubs/openpyxl/openpyxl/descriptors/sequence.pyi b/python/helpers/typeshed/stubs/openpyxl/openpyxl/descriptors/sequence.pyi
index 246ab1164f19..ba5cb0640f08 100644
--- a/python/helpers/typeshed/stubs/openpyxl/openpyxl/descriptors/sequence.pyi
+++ b/python/helpers/typeshed/stubs/openpyxl/openpyxl/descriptors/sequence.pyi
@@ -1,6 +1,6 @@
from _typeshed import Incomplete, Unused
from collections.abc import Generator, Iterable, Sized
-from typing import Any, Protocol, TypeVar
+from typing import Any, Protocol, TypeVar, type_check_only
from typing_extensions import Self
from openpyxl.descriptors import Strict
@@ -13,10 +13,12 @@ from .base import Alias, Descriptor
_T = TypeVar("_T")
_ContainerT = TypeVar("_ContainerT")
+@type_check_only
class _SupportsFromTree(Protocol):
@classmethod
def from_tree(cls, node: _SerialisableTreeElement) -> Any: ...
+@type_check_only
class _SupportsToTree(Protocol):
def to_tree(self) -> Element: ...
@@ -47,6 +49,7 @@ class ValueSequence(Sequence[_ContainerT]):
) -> Generator[Element, None, None]: ...
def from_tree(self, node: _HasGet[_T]) -> _T: ...
+@type_check_only
class _NestedSequenceToTreeObj(Sized, Iterable[_SupportsToTree], Protocol): ...
# See `Sequence` for the meaning of `_ContainerT`.
diff --git a/python/helpers/typeshed/stubs/openpyxl/openpyxl/descriptors/serialisable.pyi b/python/helpers/typeshed/stubs/openpyxl/openpyxl/descriptors/serialisable.pyi
index eee7d3bce7ea..b9e62a294ef3 100644
--- a/python/helpers/typeshed/stubs/openpyxl/openpyxl/descriptors/serialisable.pyi
+++ b/python/helpers/typeshed/stubs/openpyxl/openpyxl/descriptors/serialisable.pyi
@@ -1,6 +1,6 @@
from _typeshed import ConvertibleToInt, Incomplete, SupportsIter
from collections.abc import Iterator
-from typing import Any, ClassVar, Final, Protocol
+from typing import Any, ClassVar, Final, Protocol, type_check_only
from typing_extensions import Self
from openpyxl.descriptors import MetaSerialisable
@@ -9,7 +9,10 @@ from openpyxl.xml.functions import Element
from ..xml._functions_overloads import _HasAttrib, _HasGet, _HasTagAndGet, _HasText, _SupportsFindChartLines
# For any override directly re-using Serialisable.from_tree
+@type_check_only
class _ChildSerialisableTreeElement(_HasAttrib, _HasText, SupportsIter[Incomplete], Protocol): ...
+
+@type_check_only
class _SerialisableTreeElement(_HasGet[object], _SupportsFindChartLines, _ChildSerialisableTreeElement, Protocol): ...
KEYWORDS: Final[frozenset[str]]
diff --git a/python/helpers/typeshed/stubs/openpyxl/openpyxl/formula/tokenizer.pyi b/python/helpers/typeshed/stubs/openpyxl/openpyxl/formula/tokenizer.pyi
index 2aafed4d0357..f37992ae87a6 100644
--- a/python/helpers/typeshed/stubs/openpyxl/openpyxl/formula/tokenizer.pyi
+++ b/python/helpers/typeshed/stubs/openpyxl/openpyxl/formula/tokenizer.pyi
@@ -30,6 +30,7 @@ class Tokenizer:
def render(self): ...
class Token:
+ __slots__ = ["value", "type", "subtype"]
LITERAL: Final = "LITERAL"
OPERAND: Final = "OPERAND"
FUNC: Final = "FUNC"
diff --git a/python/helpers/typeshed/stubs/openpyxl/openpyxl/pivot/table.pyi b/python/helpers/typeshed/stubs/openpyxl/openpyxl/pivot/table.pyi
index 17bf54d48e43..c90e97612c17 100644
--- a/python/helpers/typeshed/stubs/openpyxl/openpyxl/pivot/table.pyi
+++ b/python/helpers/typeshed/stubs/openpyxl/openpyxl/pivot/table.pyi
@@ -417,7 +417,7 @@ class ConditionalFormatList(Serialisable):
tagname: ClassVar[str]
conditionalFormat: Incomplete
__attrs__: ClassVar[tuple[str, ...]]
- def __init__(self, conditionalFormat=..., count: Incomplete | None = ...) -> None: ...
+ def __init__(self, conditionalFormat=(), count=None) -> None: ...
def by_priority(self): ...
@property
def count(self) -> int: ...
diff --git a/python/helpers/typeshed/stubs/openpyxl/openpyxl/styles/cell_style.pyi b/python/helpers/typeshed/stubs/openpyxl/openpyxl/styles/cell_style.pyi
index c1867a7b356f..6852b377d20b 100644
--- a/python/helpers/typeshed/stubs/openpyxl/openpyxl/styles/cell_style.pyi
+++ b/python/helpers/typeshed/stubs/openpyxl/openpyxl/styles/cell_style.pyi
@@ -19,6 +19,7 @@ class ArrayDescriptor(Generic[_T]):
def __set__(self, instance: MutableSequence[_T], value: _T) -> None: ...
class StyleArray(array[int]):
+ __slots__ = ()
tagname: ClassVar[str]
fontId: ArrayDescriptor[int]
fillId: ArrayDescriptor[int]
diff --git a/python/helpers/typeshed/stubs/openpyxl/openpyxl/styles/proxy.pyi b/python/helpers/typeshed/stubs/openpyxl/openpyxl/styles/proxy.pyi
index 2b458bd5c204..1fd18127d71e 100644
--- a/python/helpers/typeshed/stubs/openpyxl/openpyxl/styles/proxy.pyi
+++ b/python/helpers/typeshed/stubs/openpyxl/openpyxl/styles/proxy.pyi
@@ -1,6 +1,7 @@
from typing_extensions import deprecated
class StyleProxy:
+ __slots__ = "__target"
def __init__(self, target) -> None: ...
def __getattr__(self, attr: str): ...
def __setattr__(self, attr: str, value) -> None: ...
diff --git a/python/helpers/typeshed/stubs/openpyxl/openpyxl/styles/styleable.pyi b/python/helpers/typeshed/stubs/openpyxl/openpyxl/styles/styleable.pyi
index 07744bd3ecdb..1601d769d14b 100644
--- a/python/helpers/typeshed/stubs/openpyxl/openpyxl/styles/styleable.pyi
+++ b/python/helpers/typeshed/stubs/openpyxl/openpyxl/styles/styleable.pyi
@@ -34,6 +34,7 @@ class StyleArrayDescriptor:
def __get__(self, instance: StyleableObject, cls: Unused) -> bool: ...
class StyleableObject:
+ __slots__ = ("parent", "_style")
font: StyleDescriptor
fill: StyleDescriptor
border: StyleDescriptor
diff --git a/python/helpers/typeshed/stubs/openpyxl/openpyxl/worksheet/_writer.pyi b/python/helpers/typeshed/stubs/openpyxl/openpyxl/worksheet/_writer.pyi
index 6261170ee21d..92ca8dc7b9a6 100644
--- a/python/helpers/typeshed/stubs/openpyxl/openpyxl/worksheet/_writer.pyi
+++ b/python/helpers/typeshed/stubs/openpyxl/openpyxl/worksheet/_writer.pyi
@@ -1,6 +1,6 @@
from _typeshed import Incomplete, ReadableBuffer, StrPath, Unused
from collections.abc import Generator, Iterable
-from typing import Protocol
+from typing import Protocol, type_check_only
from typing_extensions import TypeAlias
from openpyxl.cell import _CellOrMergedCell
@@ -8,6 +8,7 @@ from openpyxl.worksheet._write_only import WriteOnlyWorksheet
from openpyxl.worksheet.worksheet import Worksheet
# WorksheetWriter.read has an explicit BytesIO branch. Let's make sure this protocol is viable for BytesIO too.
+@type_check_only
class _SupportsCloseAndWrite(Protocol):
def write(self, buffer: ReadableBuffer, /) -> Unused: ...
def close(self) -> Unused: ...
diff --git a/python/helpers/typeshed/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi b/python/helpers/typeshed/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi
index d26a47dc59f8..d1f955ab2ad9 100644
--- a/python/helpers/typeshed/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi
+++ b/python/helpers/typeshed/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi
@@ -1,5 +1,5 @@
from _typeshed import ConvertibleToInt, Incomplete
-from typing import ClassVar, Literal, Protocol
+from typing import ClassVar, Literal, Protocol, type_check_only
from typing_extensions import TypeAlias
from openpyxl.descriptors.base import (
@@ -36,6 +36,7 @@ _DataValidationOperator: TypeAlias = Literal[
"between", "notBetween", "equal", "notEqual", "lessThan", "lessThanOrEqual", "greaterThan", "greaterThanOrEqual"
]
+@type_check_only
class _HasCoordinate(Protocol):
coordinate: str | CellRange
diff --git a/python/helpers/typeshed/stubs/opentracing/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/opentracing/@tests/stubtest_allowlist.txt
index 7c96a34055f8..9f41ee7c2a11 100644
--- a/python/helpers/typeshed/stubs/opentracing/@tests/stubtest_allowlist.txt
+++ b/python/helpers/typeshed/stubs/opentracing/@tests/stubtest_allowlist.txt
@@ -1,3 +1,4 @@
+# They raise ModuleNotFoundError so they are not present at stubtest runtime:
opentracing.harness.api_check
opentracing.harness.scope_check
opentracing.scope_managers.gevent
diff --git a/python/helpers/typeshed/stubs/opentracing/METADATA.toml b/python/helpers/typeshed/stubs/opentracing/METADATA.toml
index 70555adff660..80a499c5b6a3 100644
--- a/python/helpers/typeshed/stubs/opentracing/METADATA.toml
+++ b/python/helpers/typeshed/stubs/opentracing/METADATA.toml
@@ -1,6 +1,2 @@
version = "2.4.*"
upstream_repository = "https://github.com/opentracing/opentracing-python"
-partial_stub = true
-
-[tool.stubtest]
-ignore_missing_stub = true
diff --git a/python/helpers/typeshed/stubs/opentracing/opentracing/logs.pyi b/python/helpers/typeshed/stubs/opentracing/opentracing/logs.pyi
index 15cda689b09d..8aa6c11f3e89 100644
--- a/python/helpers/typeshed/stubs/opentracing/opentracing/logs.pyi
+++ b/python/helpers/typeshed/stubs/opentracing/opentracing/logs.pyi
@@ -1,5 +1,7 @@
-ERROR_KIND: str
-ERROR_OBJECT: str
-EVENT: str
-MESSAGE: str
-STACK: str
+from typing import Final
+
+ERROR_KIND: Final = "error.kind"
+ERROR_OBJECT: Final = "error.object"
+EVENT: Final = "event"
+MESSAGE: Final = "message"
+STACK: Final = "stack"
diff --git a/python/helpers/typeshed/stubs/opentracing/opentracing/propagation.pyi b/python/helpers/typeshed/stubs/opentracing/opentracing/propagation.pyi
index 81307c63f882..3c9607b8f405 100644
--- a/python/helpers/typeshed/stubs/opentracing/opentracing/propagation.pyi
+++ b/python/helpers/typeshed/stubs/opentracing/opentracing/propagation.pyi
@@ -1,8 +1,10 @@
+from typing import Final
+
class UnsupportedFormatException(Exception): ...
class InvalidCarrierException(Exception): ...
class SpanContextCorruptedException(Exception): ...
class Format:
- BINARY: str
- TEXT_MAP: str
- HTTP_HEADERS: str
+ BINARY: Final = "binary"
+ TEXT_MAP: Final = "text_map"
+ HTTP_HEADERS: Final = "http_headers"
diff --git a/python/helpers/typeshed/stubs/paramiko/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/paramiko/@tests/stubtest_allowlist.txt
index bd194ca1043d..fdabe6f8a4b8 100644
--- a/python/helpers/typeshed/stubs/paramiko/@tests/stubtest_allowlist.txt
+++ b/python/helpers/typeshed/stubs/paramiko/@tests/stubtest_allowlist.txt
@@ -1,3 +1 @@
-paramiko.SFTPServer.__init__
-paramiko.sftp_server.SFTPServer.__init__
paramiko.util.SupportsClose
diff --git a/python/helpers/typeshed/stubs/paramiko/@tests/stubtest_allowlist_darwin.txt b/python/helpers/typeshed/stubs/paramiko/@tests/stubtest_allowlist_darwin.txt
index 62983197e021..c510f2c7e366 100644
--- a/python/helpers/typeshed/stubs/paramiko/@tests/stubtest_allowlist_darwin.txt
+++ b/python/helpers/typeshed/stubs/paramiko/@tests/stubtest_allowlist_darwin.txt
@@ -1,2 +1,3 @@
paramiko._winapi
+paramiko.win_openssh.*
paramiko.win_pageant
diff --git a/python/helpers/typeshed/stubs/paramiko/@tests/stubtest_allowlist_linux.txt b/python/helpers/typeshed/stubs/paramiko/@tests/stubtest_allowlist_linux.txt
index 62983197e021..c510f2c7e366 100644
--- a/python/helpers/typeshed/stubs/paramiko/@tests/stubtest_allowlist_linux.txt
+++ b/python/helpers/typeshed/stubs/paramiko/@tests/stubtest_allowlist_linux.txt
@@ -1,2 +1,3 @@
paramiko._winapi
+paramiko.win_openssh.*
paramiko.win_pageant
diff --git a/python/helpers/typeshed/stubs/paramiko/METADATA.toml b/python/helpers/typeshed/stubs/paramiko/METADATA.toml
index 9358422c4178..1531573c8118 100644
--- a/python/helpers/typeshed/stubs/paramiko/METADATA.toml
+++ b/python/helpers/typeshed/stubs/paramiko/METADATA.toml
@@ -1,10 +1,8 @@
-version = "3.5.*"
+version = "4.0.*"
upstream_repository = "https://github.com/paramiko/paramiko"
# Requires a version of cryptography where cryptography.hazmat.primitives.ciphers.Cipher is generic
requires = ["cryptography>=37.0.0"]
-partial_stub = true
[tool.stubtest]
-ignore_missing_stub = true
# linux and darwin are equivalent
-platforms = ["linux", "win32"]
+ci_platforms = ["linux", "win32"]
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/__init__.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/__init__.pyi
index 7073775c5d2e..648141acf7eb 100644
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/__init__.pyi
+++ b/python/helpers/typeshed/stubs/paramiko/paramiko/__init__.pyi
@@ -1,3 +1,6 @@
+from typing import Final
+
+from paramiko import util as util
from paramiko.agent import Agent as Agent, AgentKey as AgentKey
from paramiko.channel import Channel as Channel, ChannelFile as ChannelFile
from paramiko.client import (
@@ -9,7 +12,6 @@ from paramiko.client import (
)
from paramiko.common import io_sleep as io_sleep
from paramiko.config import SSHConfig as SSHConfig, SSHConfigDict as SSHConfigDict
-from paramiko.dsskey import DSSKey as DSSKey
from paramiko.ecdsakey import ECDSAKey as ECDSAKey
from paramiko.ed25519key import Ed25519Key as Ed25519Key
from paramiko.file import BufferedFile as BufferedFile
@@ -39,8 +41,7 @@ from paramiko.ssh_exception import (
)
from paramiko.transport import SecurityOptions as SecurityOptions, Transport as Transport
-__author__: str
-__license__: str
-
-# Names in __all__ with no definition:
-# util
+__version__: Final[str]
+__author__: Final[str]
+__license__: Final[str]
+key_classes: list[type[PKey]]
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/_version.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/_version.pyi
deleted file mode 100644
index 8faa8a2d7728..000000000000
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/_version.pyi
+++ /dev/null
@@ -1,2 +0,0 @@
-__version_info__: tuple[int, int, int]
-__version__: str
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/_winapi.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/_winapi.pyi
index e2baa2db37e3..bbc62bb52075 100644
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/_winapi.pyi
+++ b/python/helpers/typeshed/stubs/paramiko/paramiko/_winapi.pyi
@@ -3,7 +3,6 @@ import ctypes
import sys
from _typeshed import Incomplete
from types import TracebackType
-from typing import Any
from typing_extensions import Self
if sys.platform == "win32":
@@ -18,14 +17,14 @@ if sys.platform == "win32":
def handle_nonzero_success(result: int) -> None: ...
GMEM_MOVEABLE: int
- GlobalAlloc: Any
- GlobalLock: Any
- GlobalUnlock: Any
- GlobalSize: Any
- CreateFileMapping: Any
- MapViewOfFile: Any
- UnmapViewOfFile: Any
- RtlMoveMemory: Any
+ GlobalAlloc: Incomplete
+ GlobalLock: Incomplete
+ GlobalUnlock: Incomplete
+ GlobalSize: Incomplete
+ CreateFileMapping: Incomplete
+ MapViewOfFile: Incomplete
+ UnmapViewOfFile: Incomplete
+ RtlMoveMemory: Incomplete
class MemoryMap:
name: str
@@ -75,21 +74,31 @@ if sys.platform == "win32":
class TOKEN_USER(ctypes.Structure):
num: int
+ SID: Incomplete
+ ATTRIBUTES: Incomplete
class SECURITY_DESCRIPTOR(ctypes.Structure):
- SECURITY_DESCRIPTOR_CONTROL: Any
+ SECURITY_DESCRIPTOR_CONTROL: Incomplete
REVISION: int
+ Revision: int
+ Sbz1: Incomplete
+ Control: Incomplete
+ Owner: Incomplete
+ Group: Incomplete
+ Sacl: Incomplete
+ Dacl: Incomplete
class SECURITY_ATTRIBUTES(ctypes.Structure):
nLength: int
- lpSecurityDescriptor: Any
- def __init__(self, *args: Any, **kwargs: Any) -> None: ...
+ lpSecurityDescriptor: int
+ bInheritHandle: bool
+ def __init__(self, *args, **kwargs) -> None: ...
@property
- def descriptor(self) -> Any: ...
+ def descriptor(self): ...
@descriptor.setter
- def descriptor(self, value: Any) -> None: ...
+ def descriptor(self, value) -> None: ...
- def GetTokenInformation(token: Any, information_class: Any) -> Any: ...
- def OpenProcessToken(proc_handle: Any, access: Any) -> Any: ...
+ def GetTokenInformation(token, information_class): ...
+ def OpenProcessToken(proc_handle, access): ...
def get_current_user() -> TOKEN_USER: ...
def get_security_attributes_for_user(user: TOKEN_USER | None = None) -> SECURITY_ATTRIBUTES: ...
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/agent.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/agent.pyi
index 0d1886ef3d6c..16621e9fa5d2 100644
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/agent.pyi
+++ b/python/helpers/typeshed/stubs/paramiko/paramiko/agent.pyi
@@ -1,21 +1,31 @@
+import sys
from _typeshed import ReadableBuffer
+from collections.abc import Mapping
+from logging import _ExcInfoType
from socket import _RetAddress, socket
from threading import Thread
-from typing import Protocol
+from typing import Final, Protocol, type_check_only
from paramiko.channel import Channel
from paramiko.message import Message, _LikeBytes
from paramiko.pkey import PKey
from paramiko.transport import Transport
+@type_check_only
class _AgentProxy(Protocol):
def connect(self) -> None: ...
def close(self) -> None: ...
-cSSH2_AGENTC_REQUEST_IDENTITIES: bytes
-SSH2_AGENT_IDENTITIES_ANSWER: int
-cSSH2_AGENTC_SIGN_REQUEST: bytes
-SSH2_AGENT_SIGN_RESPONSE: int
+cSSH2_AGENTC_REQUEST_IDENTITIES: Final[bytes]
+SSH2_AGENT_IDENTITIES_ANSWER: Final = 12
+cSSH2_AGENTC_SIGN_REQUEST: Final[bytes]
+SSH2_AGENT_SIGN_RESPONSE: Final = 14
+
+SSH_AGENT_RSA_SHA2_256: Final = 2
+SSH_AGENT_RSA_SHA2_512: Final = 4
+ALGORITHM_FLAG_MAP: Final[dict[str, int]]
+key: str
+value: int
class AgentSSH:
def __init__(self) -> None: ...
@@ -33,6 +43,15 @@ class AgentRemoteProxy(AgentProxyThread):
def __init__(self, agent: AgentClientProxy, chan: Channel) -> None: ...
def get_connection(self) -> tuple[socket, _RetAddress]: ...
+if sys.platform == "win32":
+ from .win_openssh import OpenSSHAgentConnection
+ from .win_pageant import PageantConnection
+
+ def get_agent_connection() -> PageantConnection | OpenSSHAgentConnection | None: ...
+
+else:
+ def get_agent_connection() -> socket | None: ...
+
class AgentClientProxy:
thread: Thread
def __init__(self, chanRemote: Channel) -> None: ...
@@ -64,6 +83,16 @@ class AgentKey(PKey):
name: str
comment: str
def __init__(self, agent: AgentSSH, blob: ReadableBuffer, comment: str = "") -> None: ...
+ def log(
+ self,
+ level: int,
+ msg: object,
+ *args: object,
+ exc_info: _ExcInfoType = None,
+ stack_info: bool = False,
+ stacklevel: int = 1,
+ extra: Mapping[str, object] | None = None,
+ ) -> None: ...
def asbytes(self) -> bytes: ...
def get_name(self) -> str: ...
def sign_ssh_data(self, data: _LikeBytes, algorithm: str | None = None) -> Message: ...
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/auth_handler.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/auth_handler.pyi
index bb062b8590bf..46e65a286538 100644
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/auth_handler.pyi
+++ b/python/helpers/typeshed/stubs/paramiko/paramiko/auth_handler.pyi
@@ -2,6 +2,7 @@ from collections.abc import Callable
from threading import Event
from typing_extensions import TypeAlias
+from paramiko.message import Message
from paramiko.pkey import PKey
from paramiko.ssh_gss import _SSH_GSSAuth
from paramiko.transport import Transport
@@ -46,3 +47,12 @@ class GssapiWithMicAuthHandler:
def auth_username(self) -> str: ...
@property
def gss_host(self) -> str: ...
+
+class AuthOnlyHandler(AuthHandler):
+ def send_auth_request(
+ self, username: str, method: str, finish_message: Callable[[Message], None] | None = None
+ ) -> list[str]: ...
+ def auth_none(self, username: str) -> list[str]: ... # type: ignore[override]
+ def auth_publickey(self, username: str, key: PKey) -> list[str]: ... # type: ignore[override]
+ def auth_password(self, username: str, password: str) -> list[str]: ... # type: ignore[override]
+ def auth_interactive(self, username: str, handler: _InteractiveCallback, submethods: str = "") -> list[str]: ... # type: ignore[override]
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/client.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/client.pyi
index 6462fcd8cffd..805347da6c9f 100644
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/client.pyi
+++ b/python/helpers/typeshed/stubs/paramiko/paramiko/client.pyi
@@ -1,6 +1,6 @@
from _typeshed import FileDescriptorOrPath
from collections.abc import Iterable, Mapping
-from typing import NoReturn, Protocol
+from typing import NoReturn, Protocol, type_check_only
from paramiko.auth_strategy import AuthStrategy
from paramiko.channel import Channel, ChannelFile, ChannelStderrFile, ChannelStdinFile
@@ -10,6 +10,7 @@ from paramiko.sftp_client import SFTPClient
from paramiko.transport import Transport, _SocketLike
from paramiko.util import ClosingContextManager
+@type_check_only
class _TransportFactory(Protocol):
def __call__(
self,
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/common.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/common.pyi
index c895dfd312ba..abe1a14e7fee 100644
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/common.pyi
+++ b/python/helpers/typeshed/stubs/paramiko/paramiko/common.pyi
@@ -1,97 +1,102 @@
+import logging
+from typing import Final
+
def byte_ord(c: int | str) -> int: ...
def byte_chr(c: int) -> bytes: ...
def byte_mask(c: int, mask: int) -> bytes: ...
-MSG_DISCONNECT: int
-MSG_IGNORE: int
-MSG_UNIMPLEMENTED: int
-MSG_DEBUG: int
-MSG_SERVICE_REQUEST: int
-MSG_SERVICE_ACCEPT: int
-MSG_KEXINIT: int
-MSG_NEWKEYS: int
-MSG_USERAUTH_REQUEST: int
-MSG_USERAUTH_FAILURE: int
-MSG_USERAUTH_SUCCESS: int
-MSG_USERAUTH_BANNER: int
-MSG_USERAUTH_PK_OK: int
-MSG_USERAUTH_INFO_REQUEST: int
-MSG_USERAUTH_INFO_RESPONSE: int
-MSG_USERAUTH_GSSAPI_RESPONSE: int
-MSG_USERAUTH_GSSAPI_TOKEN: int
-MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE: int
-MSG_USERAUTH_GSSAPI_ERROR: int
-MSG_USERAUTH_GSSAPI_ERRTOK: int
-MSG_USERAUTH_GSSAPI_MIC: int
-HIGHEST_USERAUTH_MESSAGE_ID: int
-MSG_GLOBAL_REQUEST: int
-MSG_REQUEST_SUCCESS: int
-MSG_REQUEST_FAILURE: int
-MSG_CHANNEL_OPEN: int
-MSG_CHANNEL_OPEN_SUCCESS: int
-MSG_CHANNEL_OPEN_FAILURE: int
-MSG_CHANNEL_WINDOW_ADJUST: int
-MSG_CHANNEL_DATA: int
-MSG_CHANNEL_EXTENDED_DATA: int
-MSG_CHANNEL_EOF: int
-MSG_CHANNEL_CLOSE: int
-MSG_CHANNEL_REQUEST: int
-MSG_CHANNEL_SUCCESS: int
-MSG_CHANNEL_FAILURE: int
+MSG_DISCONNECT: Final = 1
+MSG_IGNORE: Final = 2
+MSG_UNIMPLEMENTED: Final = 3
+MSG_DEBUG: Final = 4
+MSG_SERVICE_REQUEST: Final = 5
+MSG_SERVICE_ACCEPT: Final = 6
+MSG_EXT_INFO: Final = 7
+MSG_KEXINIT: Final = 20
+MSG_NEWKEYS: Final = 21
+MSG_USERAUTH_REQUEST: Final = 50
+MSG_USERAUTH_FAILURE: Final = 51
+MSG_USERAUTH_SUCCESS: Final = 52
+MSG_USERAUTH_BANNER: Final = 53
+MSG_USERAUTH_PK_OK: Final = 60
+MSG_USERAUTH_INFO_REQUEST: Final = 60
+MSG_USERAUTH_INFO_RESPONSE: Final = 61
+MSG_USERAUTH_GSSAPI_RESPONSE: Final = 60
+MSG_USERAUTH_GSSAPI_TOKEN: Final = 61
+MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE: Final = 63
+MSG_USERAUTH_GSSAPI_ERROR: Final = 64
+MSG_USERAUTH_GSSAPI_ERRTOK: Final = 65
+MSG_USERAUTH_GSSAPI_MIC: Final = 66
+HIGHEST_USERAUTH_MESSAGE_ID: Final = 79
+MSG_GLOBAL_REQUEST: Final = 80
+MSG_REQUEST_SUCCESS: Final = 81
+MSG_REQUEST_FAILURE: Final = 82
+MSG_CHANNEL_OPEN: Final = 90
+MSG_CHANNEL_OPEN_SUCCESS: Final = 91
+MSG_CHANNEL_OPEN_FAILURE: Final = 92
+MSG_CHANNEL_WINDOW_ADJUST: Final = 93
+MSG_CHANNEL_DATA: Final = 94
+MSG_CHANNEL_EXTENDED_DATA: Final = 95
+MSG_CHANNEL_EOF: Final = 96
+MSG_CHANNEL_CLOSE: Final = 97
+MSG_CHANNEL_REQUEST: Final = 98
+MSG_CHANNEL_SUCCESS: Final = 99
+MSG_CHANNEL_FAILURE: Final = 100
-cMSG_DISCONNECT: bytes
-cMSG_IGNORE: bytes
-cMSG_UNIMPLEMENTED: bytes
-cMSG_DEBUG: bytes
-cMSG_SERVICE_REQUEST: bytes
-cMSG_SERVICE_ACCEPT: bytes
-cMSG_KEXINIT: bytes
-cMSG_NEWKEYS: bytes
-cMSG_USERAUTH_REQUEST: bytes
-cMSG_USERAUTH_FAILURE: bytes
-cMSG_USERAUTH_SUCCESS: bytes
-cMSG_USERAUTH_BANNER: bytes
-cMSG_USERAUTH_PK_OK: bytes
-cMSG_USERAUTH_INFO_REQUEST: bytes
-cMSG_USERAUTH_INFO_RESPONSE: bytes
-cMSG_USERAUTH_GSSAPI_RESPONSE: bytes
-cMSG_USERAUTH_GSSAPI_TOKEN: bytes
-cMSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE: bytes
-cMSG_USERAUTH_GSSAPI_ERROR: bytes
-cMSG_USERAUTH_GSSAPI_ERRTOK: bytes
-cMSG_USERAUTH_GSSAPI_MIC: bytes
-cMSG_GLOBAL_REQUEST: bytes
-cMSG_REQUEST_SUCCESS: bytes
-cMSG_REQUEST_FAILURE: bytes
-cMSG_CHANNEL_OPEN: bytes
-cMSG_CHANNEL_OPEN_SUCCESS: bytes
-cMSG_CHANNEL_OPEN_FAILURE: bytes
-cMSG_CHANNEL_WINDOW_ADJUST: bytes
-cMSG_CHANNEL_DATA: bytes
-cMSG_CHANNEL_EXTENDED_DATA: bytes
-cMSG_CHANNEL_EOF: bytes
-cMSG_CHANNEL_CLOSE: bytes
-cMSG_CHANNEL_REQUEST: bytes
-cMSG_CHANNEL_SUCCESS: bytes
-cMSG_CHANNEL_FAILURE: bytes
+cMSG_DISCONNECT: Final[bytes]
+cMSG_IGNORE: Final[bytes]
+cMSG_UNIMPLEMENTED: Final[bytes]
+cMSG_DEBUG: Final[bytes]
+cMSG_SERVICE_REQUEST: Final[bytes]
+cMSG_SERVICE_ACCEPT: Final[bytes]
+cMSG_EXT_INFO: Final[bytes]
+cMSG_KEXINIT: Final[bytes]
+cMSG_NEWKEYS: Final[bytes]
+cMSG_USERAUTH_REQUEST: Final[bytes]
+cMSG_USERAUTH_FAILURE: Final[bytes]
+cMSG_USERAUTH_SUCCESS: Final[bytes]
+cMSG_USERAUTH_BANNER: Final[bytes]
+cMSG_USERAUTH_PK_OK: Final[bytes]
+cMSG_USERAUTH_INFO_REQUEST: Final[bytes]
+cMSG_USERAUTH_INFO_RESPONSE: Final[bytes]
+cMSG_USERAUTH_GSSAPI_RESPONSE: Final[bytes]
+cMSG_USERAUTH_GSSAPI_TOKEN: Final[bytes]
+cMSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE: Final[bytes]
+cMSG_USERAUTH_GSSAPI_ERROR: Final[bytes]
+cMSG_USERAUTH_GSSAPI_ERRTOK: Final[bytes]
+cMSG_USERAUTH_GSSAPI_MIC: Final[bytes]
+cMSG_GLOBAL_REQUEST: Final[bytes]
+cMSG_REQUEST_SUCCESS: Final[bytes]
+cMSG_REQUEST_FAILURE: Final[bytes]
+cMSG_CHANNEL_OPEN: Final[bytes]
+cMSG_CHANNEL_OPEN_SUCCESS: Final[bytes]
+cMSG_CHANNEL_OPEN_FAILURE: Final[bytes]
+cMSG_CHANNEL_WINDOW_ADJUST: Final[bytes]
+cMSG_CHANNEL_DATA: Final[bytes]
+cMSG_CHANNEL_EXTENDED_DATA: Final[bytes]
+cMSG_CHANNEL_EOF: Final[bytes]
+cMSG_CHANNEL_CLOSE: Final[bytes]
+cMSG_CHANNEL_REQUEST: Final[bytes]
+cMSG_CHANNEL_SUCCESS: Final[bytes]
+cMSG_CHANNEL_FAILURE: Final[bytes]
MSG_NAMES: dict[int, str]
-AUTH_SUCCESSFUL: int
-AUTH_PARTIALLY_SUCCESSFUL: int
-AUTH_FAILED: int
+AUTH_SUCCESSFUL: Final = 0
+AUTH_PARTIALLY_SUCCESSFUL: Final = 1
+AUTH_FAILED: Final = 2
-OPEN_SUCCEEDED: int
-OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED: int
-OPEN_FAILED_CONNECT_FAILED: int
-OPEN_FAILED_UNKNOWN_CHANNEL_TYPE: int
-OPEN_FAILED_RESOURCE_SHORTAGE: int
+OPEN_SUCCEEDED: Final = 0
+OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED: Final = 1
+OPEN_FAILED_CONNECT_FAILED: Final = 2
+OPEN_FAILED_UNKNOWN_CHANNEL_TYPE: Final = 3
+OPEN_FAILED_RESOURCE_SHORTAGE: Final = 4
CONNECTION_FAILED_CODE: dict[int, str]
-DISCONNECT_SERVICE_NOT_AVAILABLE: int
-DISCONNECT_AUTH_CANCELLED_BY_USER: int
-DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE: int
+DISCONNECT_SERVICE_NOT_AVAILABLE: Final = 7
+DISCONNECT_AUTH_CANCELLED_BY_USER: Final = 13
+DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE: Final = 14
zero_byte: bytes
one_byte: bytes
@@ -112,17 +117,17 @@ o777: int
o700: int
o70: int
-DEBUG: int
-INFO: int
-WARNING: int
-ERROR: int
-CRITICAL: int
+DEBUG = logging.DEBUG
+INFO = logging.INFO
+WARNING = logging.WARNING
+ERROR = logging.ERROR
+CRITICAL = logging.CRITICAL
io_sleep: float
-DEFAULT_WINDOW_SIZE: int
-DEFAULT_MAX_PACKET_SIZE: int
+DEFAULT_WINDOW_SIZE: Final[int]
+DEFAULT_MAX_PACKET_SIZE: Final[int]
-MIN_WINDOW_SIZE: int
-MIN_PACKET_SIZE: int
-MAX_WINDOW_SIZE: int
+MIN_WINDOW_SIZE: Final[int]
+MIN_PACKET_SIZE: Final[int]
+MAX_WINDOW_SIZE: Final[int]
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/config.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/config.pyi
index 831dccfcabe4..41dc6375e29d 100644
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/config.pyi
+++ b/python/helpers/typeshed/stubs/paramiko/paramiko/config.pyi
@@ -6,6 +6,7 @@ from typing_extensions import Self
from paramiko.ssh_exception import ConfigParseError as ConfigParseError, CouldNotCanonicalize as CouldNotCanonicalize
+invoke_import_error: ImportError | None
SSH_PORT: int
class SSHConfig:
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/dsskey.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/dsskey.pyi
deleted file mode 100644
index 59b419275cbf..000000000000
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/dsskey.pyi
+++ /dev/null
@@ -1,35 +0,0 @@
-from _typeshed import FileDescriptorOrPath, ReadableBuffer
-from collections.abc import Callable
-from typing import IO
-
-from paramiko.message import Message
-from paramiko.pkey import PKey
-
-class DSSKey(PKey):
- p: int | None
- q: int | None
- g: int | None
- y: int | None
- x: int | None
- public_blob: None
- size: int
- def __init__(
- self,
- msg: Message | None = None,
- data: ReadableBuffer | None = None,
- filename: FileDescriptorOrPath | None = None,
- password: str | None = None,
- vals: tuple[int, int, int, int] | None = None,
- file_obj: IO[str] | None = None,
- ) -> None: ...
- def asbytes(self) -> bytes: ...
- def __hash__(self) -> int: ...
- def get_name(self) -> str: ...
- def get_bits(self) -> int: ...
- def can_sign(self) -> bool: ...
- def sign_ssh_data(self, data: bytes, algorithm: str | None = None) -> Message: ...
- def verify_ssh_sig(self, data: bytes, msg: Message) -> bool: ...
- def write_private_key_file(self, filename: FileDescriptorOrPath, password: str | None = None) -> None: ...
- def write_private_key(self, file_obj: IO[str], password: str | None = None) -> None: ...
- @staticmethod
- def generate(bits: int = 1024, progress_func: Callable[..., object] | None = None) -> DSSKey: ...
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/hostkeys.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/hostkeys.pyi
index 5c9031b7da33..c9d93b374af9 100644
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/hostkeys.pyi
+++ b/python/helpers/typeshed/stubs/paramiko/paramiko/hostkeys.pyi
@@ -1,11 +1,13 @@
from _typeshed import FileDescriptorOrPath
from collections.abc import Iterator, Mapping, MutableMapping
+from typing import type_check_only
from typing_extensions import Self
from paramiko.pkey import PKey
+# Internal to HostKeys.lookup(). Calls itself "SubDict".
+@type_check_only
class _SubDict(MutableMapping[str, PKey]):
- # Internal to HostKeys.lookup()
def __init__(self, hostname: str, entries: list[HostKeyEntry], hostkeys: HostKeys) -> None: ...
def __iter__(self) -> Iterator[str]: ...
def __len__(self) -> int: ...
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/message.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/message.pyi
index ac6a9decd1f4..ef87f97b4eb2 100644
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/message.pyi
+++ b/python/helpers/typeshed/stubs/paramiko/paramiko/message.pyi
@@ -1,9 +1,10 @@
from _typeshed import ReadableBuffer
from collections.abc import Iterable
from io import BytesIO
-from typing import Any, Protocol
+from typing import Any, Protocol, type_check_only
from typing_extensions import TypeAlias
+@type_check_only
class _SupportsAsBytes(Protocol):
def asbytes(self) -> bytes: ...
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/packet.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/packet.pyi
index f2511c6ce882..1dce422c6b2b 100644
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/packet.pyi
+++ b/python/helpers/typeshed/stubs/paramiko/paramiko/packet.pyi
@@ -23,6 +23,8 @@ class Packetizer:
def __init__(self, socket: socket) -> None: ...
@property
def closed(self) -> bool: ...
+ def reset_seqno_out(self) -> None: ...
+ def reset_seqno_in(self) -> None: ...
def set_log(self, log: Logger) -> None: ...
def set_outbound_cipher(
self,
@@ -55,7 +57,7 @@ class Packetizer:
def get_mac_size_in(self) -> int: ...
def get_mac_size_out(self) -> int: ...
def need_rekey(self) -> bool: ...
- def set_keepalive(self, interval: int, callback: Callable[[], object]) -> None: ...
+ def set_keepalive(self, interval: float, callback: Callable[[], object]) -> None: ...
def read_timer(self) -> None: ...
def start_handshake(self, timeout: float) -> None: ...
def handshake_timed_out(self) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/pipe.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/pipe.pyi
index e9b1635ec2bc..4cc8e54b09b4 100644
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/pipe.pyi
+++ b/python/helpers/typeshed/stubs/paramiko/paramiko/pipe.pyi
@@ -1,9 +1,11 @@
-from typing import Protocol
+from typing import Protocol, type_check_only
+@type_check_only
class _BasePipe(Protocol):
def clear(self) -> None: ...
def set(self) -> None: ...
+@type_check_only
class _Pipe(_BasePipe, Protocol):
def close(self) -> None: ...
def fileno(self) -> int: ...
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/pkey.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/pkey.pyi
index c6defb22e3e4..0a3cd83ddd4e 100644
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/pkey.pyi
+++ b/python/helpers/typeshed/stubs/paramiko/paramiko/pkey.pyi
@@ -12,7 +12,14 @@ _BytesT = TypeVar("_BytesT", bound=bytes | bytearray)
def _unpad_openssh(data: _BytesT) -> _BytesT: ...
+class UnknownKeyType(Exception):
+ key_type: str | type | None
+ key_bytes: bytes | None
+ def __init__(self, key_type: str | type | None = None, key_bytes: bytes | None = None) -> None: ...
+
class PKey:
+ name: str
+ HASHES: dict[str, type]
public_blob: PublicBlob | None
BEGIN_TAG: Pattern[str]
END_TAG: Pattern[str]
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/proxy.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/proxy.pyi
index ad7971947f37..c22af8eb32d8 100644
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/proxy.pyi
+++ b/python/helpers/typeshed/stubs/paramiko/paramiko/proxy.pyi
@@ -4,6 +4,8 @@ from typing import Any
from paramiko.util import ClosingContextManager
+subprocess_import_error: ImportError | None
+
class ProxyCommand(ClosingContextManager):
cmd: list[str]
process: Popen[Any]
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/sftp.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/sftp.pyi
index ec0b050692ac..afcfc224f3d9 100644
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/sftp.pyi
+++ b/python/helpers/typeshed/stubs/paramiko/paramiko/sftp.pyi
@@ -51,6 +51,7 @@ SFTP_FLAG_EXCL: int
CMD_NAMES: dict[int, str]
+class int64(int): ...
class SFTPError(Exception): ...
class BaseSFTP:
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/sftp_server.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/sftp_server.pyi
index 656ebc5fda08..b4a289e8e7fb 100644
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/sftp_server.pyi
+++ b/python/helpers/typeshed/stubs/paramiko/paramiko/sftp_server.pyi
@@ -19,7 +19,13 @@ class SFTPServer(BaseSFTP, SubsystemHandler):
server: SFTPServerInterface
sock: Channel | None
def __init__(
- self, channel: Channel, name: str, server: ServerInterface, sftp_si: type[SFTPServerInterface], *largs: Any, **kwargs: Any
+ self,
+ channel: Channel,
+ name: str,
+ server: ServerInterface,
+ sftp_si: type[SFTPServerInterface] = ...,
+ *args: Any,
+ **kwargs: Any,
) -> None: ...
def start_subsystem(self, name: str, transport: Transport, channel: Channel) -> None: ...
def finish_subsystem(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/ssh_exception.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/ssh_exception.pyi
index bdf34ff1f4c7..ddd60331d0ad 100644
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/ssh_exception.pyi
+++ b/python/helpers/typeshed/stubs/paramiko/paramiko/ssh_exception.pyi
@@ -16,6 +16,8 @@ class PartialAuthentication(AuthenticationException):
allowed_types: list[str]
def __init__(self, types: list[str]) -> None: ...
+class UnableToAuthenticate(AuthenticationException): ...
+
class ChannelException(SSHException):
code: int
text: str
@@ -27,6 +29,8 @@ class BadHostKeyException(SSHException):
expected_key: PKey
def __init__(self, hostname: str, got_key: PKey, expected_key: PKey) -> None: ...
+class IncompatiblePeer(SSHException): ...
+
class ProxyCommandFailure(SSHException):
command: str
error: str
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/ssh_gss.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/ssh_gss.pyi
index 89f234681848..49d6ca88d8c4 100644
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/ssh_gss.pyi
+++ b/python/helpers/typeshed/stubs/paramiko/paramiko/ssh_gss.pyi
@@ -25,8 +25,6 @@ class _SSH_GSSAPI_OLD(_SSH_GSSAuth):
def credentials_delegated(self) -> bool: ...
def save_client_creds(self, client_token: str) -> None: ...
-_SSH_GSSAPI = _SSH_GSSAPI_OLD
-
class _SSH_GSSAPI_NEW(_SSH_GSSAuth):
def __init__(self, auth_method: str, gss_deleg_creds: bool) -> None: ...
def ssh_init_sec_context(
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/transport.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/transport.pyi
index 3b5606ec6545..6b2f2df1c279 100644
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/transport.pyi
+++ b/python/helpers/typeshed/stubs/paramiko/paramiko/transport.pyi
@@ -4,10 +4,10 @@ from logging import Logger
from socket import socket
from threading import Condition, Event, Lock, Thread
from types import ModuleType
-from typing import Any, Protocol
+from typing import Any, Protocol, type_check_only
from typing_extensions import TypeAlias
-from paramiko.auth_handler import AuthHandler, _InteractiveCallback
+from paramiko.auth_handler import AuthHandler, AuthOnlyHandler, _InteractiveCallback
from paramiko.channel import Channel
from paramiko.message import Message
from paramiko.packet import Packetizer
@@ -21,6 +21,7 @@ from paramiko.util import ClosingContextManager
_Addr: TypeAlias = tuple[str, int]
_SocketLike: TypeAlias = str | _Addr | socket | Channel | ProxyCommand
+@type_check_only
class _KexEngine(Protocol):
def start_kex(self) -> None: ...
def parse_next(self, ptype: int, m: Message) -> None: ...
@@ -96,6 +97,8 @@ class Transport(Thread, ClosingContextManager):
@property
def preferred_keys(self) -> Sequence[str]: ...
@property
+ def preferred_pubkeys(self) -> Sequence[str]: ...
+ @property
def preferred_kex(self) -> Sequence[str]: ...
@property
def preferred_compression(self) -> Sequence[str]: ...
@@ -133,7 +136,7 @@ class Transport(Thread, ClosingContextManager):
def open_sftp_client(self) -> SFTPClient | None: ...
def send_ignore(self, byte_count: int | None = None) -> None: ...
def renegotiate_keys(self) -> None: ...
- def set_keepalive(self, interval: int) -> None: ...
+ def set_keepalive(self, interval: float) -> None: ...
def global_request(self, kind: str, data: Iterable[Any] | None = None, wait: bool = True) -> Message | None: ...
def accept(self, timeout: float | None = None) -> Channel | None: ...
def connect(
@@ -172,6 +175,7 @@ class Transport(Thread, ClosingContextManager):
def run(self) -> None: ...
class SecurityOptions:
+ __slots__ = "_transport"
def __init__(self, transport: Transport) -> None: ...
@property
def ciphers(self) -> Sequence[str]: ...
@@ -201,3 +205,9 @@ class ChannelMap:
def delete(self, chanid: int) -> None: ...
def values(self) -> list[Channel]: ...
def __len__(self) -> int: ...
+
+class ServiceRequestingTransport(Transport):
+ def ensure_session(self) -> None: ...
+ def get_auth_handler(self) -> AuthOnlyHandler: ...
+ def auth_password(self, username: str, password: str, fallback: bool = True) -> list[str]: ... # type: ignore[override]
+ def auth_publickey(self, username: str, key: PKey) -> list[str]: ... # type: ignore[override]
diff --git a/python/helpers/typeshed/stubs/paramiko/paramiko/win_pageant.pyi b/python/helpers/typeshed/stubs/paramiko/paramiko/win_pageant.pyi
index 5fdf8e41602e..3cc870bb0719 100644
--- a/python/helpers/typeshed/stubs/paramiko/paramiko/win_pageant.pyi
+++ b/python/helpers/typeshed/stubs/paramiko/paramiko/win_pageant.pyi
@@ -1,5 +1,6 @@
import ctypes
import sys
+from _typeshed import Incomplete
from typing import Literal
from typing_extensions import TypeAlias
@@ -9,7 +10,10 @@ if sys.platform == "win32":
ULONG_PTR: TypeAlias = ctypes.c_uint64 | ctypes.c_uint32
- class COPYDATASTRUCT(ctypes.Structure): ...
+ class COPYDATASTRUCT(ctypes.Structure):
+ num_data: Incomplete
+ data_size: Incomplete
+ data_loc: Incomplete
class PageantConnection:
def __init__(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/parsimonious/parsimonious/expressions.pyi b/python/helpers/typeshed/stubs/parsimonious/parsimonious/expressions.pyi
index a5445dd24e3c..fcc6965fa442 100644
--- a/python/helpers/typeshed/stubs/parsimonious/parsimonious/expressions.pyi
+++ b/python/helpers/typeshed/stubs/parsimonious/parsimonious/expressions.pyi
@@ -21,6 +21,7 @@ def expression(callable: _CALLABLE_TYPE, rule_name: str, grammar: Grammar) -> Ex
IN_PROGRESS: object
class Expression(StrAndRepr):
+ __slots__ = ["name", "identity_tuple"]
name: str
identity_tuple: tuple[str]
def __init__(self, name: str = "") -> None: ...
@@ -31,6 +32,7 @@ class Expression(StrAndRepr):
def as_rule(self) -> str: ...
class Literal(Expression):
+ __slots__ = ["literal"]
literal: str
identity_tuple: tuple[str, str] # type: ignore[assignment]
def __init__(self, literal: str, name: str = "") -> None: ...
@@ -38,6 +40,7 @@ class Literal(Expression):
class TokenMatcher(Literal): ...
class Regex(Expression):
+ __slots__ = ["re"]
re: Pattern[str]
identity_tuple: tuple[str, Pattern[str]] # type: ignore[assignment]
def __init__(
@@ -54,6 +57,7 @@ class Regex(Expression):
) -> None: ...
class Compound(Expression):
+ __slots__ = ["members"]
members: collections.abc.Sequence[Expression]
def __init__(self, *members: Expression, **kwargs: Any) -> None: ...
@@ -61,12 +65,14 @@ class Sequence(Compound): ...
class OneOf(Compound): ...
class Lookahead(Compound):
+ __slots__ = ["negativity"]
negativity: bool
def __init__(self, member: Expression, *, negative: bool = False, **kwargs: Any) -> None: ...
def Not(term: Expression) -> Lookahead: ...
class Quantifier(Compound):
+ __slots__ = ["min", "max"]
min: int
max: float
def __init__(self, member: Expression, *, min: int = 0, max: float = ..., name: str = "", **kwargs: Any) -> None: ...
diff --git a/python/helpers/typeshed/stubs/parsimonious/parsimonious/nodes.pyi b/python/helpers/typeshed/stubs/parsimonious/parsimonious/nodes.pyi
index 1f6b45cb987c..1d67f2f2fd0c 100644
--- a/python/helpers/typeshed/stubs/parsimonious/parsimonious/nodes.pyi
+++ b/python/helpers/typeshed/stubs/parsimonious/parsimonious/nodes.pyi
@@ -8,6 +8,7 @@ from parsimonious.expressions import Expression
from parsimonious.grammar import Grammar
class Node:
+ __slots__ = ["expr", "full_text", "start", "end", "children"]
expr: Expression
full_text: str
start: int
@@ -25,6 +26,7 @@ class Node:
def __repr__(self, top_level: bool = True) -> str: ...
class RegexNode(Node):
+ __slots__ = ["match"]
match: Match[str]
class RuleDecoratorMeta(type): ...
diff --git a/python/helpers/typeshed/stubs/parsimonious/parsimonious/utils.pyi b/python/helpers/typeshed/stubs/parsimonious/parsimonious/utils.pyi
index eea5d11851d9..b9440d08abca 100644
--- a/python/helpers/typeshed/stubs/parsimonious/parsimonious/utils.pyi
+++ b/python/helpers/typeshed/stubs/parsimonious/parsimonious/utils.pyi
@@ -6,5 +6,6 @@ class StrAndRepr: ...
def evaluate_string(string: str | ast.AST) -> Any: ...
class Token(StrAndRepr):
+ __slots__ = ["type"]
type: str
def __init__(self, type: str) -> None: ...
diff --git a/python/helpers/typeshed/stubs/peewee/METADATA.toml b/python/helpers/typeshed/stubs/peewee/METADATA.toml
index 361b69d0ed35..4f56e0596b2b 100644
--- a/python/helpers/typeshed/stubs/peewee/METADATA.toml
+++ b/python/helpers/typeshed/stubs/peewee/METADATA.toml
@@ -1,4 +1,4 @@
-version = "3.18.1"
+version = "3.18.2"
upstream_repository = "https://github.com/coleifer/peewee"
# We're not providing stubs for all playhouse modules right now
# https://github.com/python/typeshed/pull/11731#issuecomment-2065729058
diff --git a/python/helpers/typeshed/stubs/peewee/peewee.pyi b/python/helpers/typeshed/stubs/peewee/peewee.pyi
index b57924b321d7..4d6d227d3bd7 100644
--- a/python/helpers/typeshed/stubs/peewee/peewee.pyi
+++ b/python/helpers/typeshed/stubs/peewee/peewee.pyi
@@ -241,36 +241,36 @@ class ColumnBase(Node):
__or__: Incomplete
def __add__(self, rhs: Any) -> Expression: ...
__sub__: Incomplete
- __mul__: Callable[[Self, Any], Expression]
- __div__: Callable[[Self, Any], Expression]
- __truediv__: Callable[[Self, Any], Expression]
- __xor__: Callable[[Self, Any], Expression]
+ __mul__: ClassVar[Callable[[Self, Any], Expression]]
+ __div__: ClassVar[Callable[[Self, Any], Expression]]
+ __truediv__: ClassVar[Callable[[Self, Any], Expression]]
+ __xor__: ClassVar[Callable[[Self, Any], Expression]]
def __radd__(self, rhs: Any) -> Expression: ...
- __rsub__: Callable[[Self, Any], Expression]
- __rmul__: Callable[[Self, Any], Expression]
- __rdiv__: Callable[[Self, Any], Expression]
- __rtruediv__: Callable[[Self, Any], Expression]
- __rand__: Callable[[Self, Any], Expression]
- __ror__: Callable[[Self, Any], Expression]
- __rxor__: Callable[[Self, Any], Expression]
+ __rsub__: ClassVar[Callable[[Self, Any], Expression]]
+ __rmul__: ClassVar[Callable[[Self, Any], Expression]]
+ __rdiv__: ClassVar[Callable[[Self, Any], Expression]]
+ __rtruediv__: ClassVar[Callable[[Self, Any], Expression]]
+ __rand__: ClassVar[Callable[[Self, Any], Expression]]
+ __ror__: ClassVar[Callable[[Self, Any], Expression]]
+ __rxor__: ClassVar[Callable[[Self, Any], Expression]]
def __eq__(self, rhs) -> Expression: ... # type: ignore[override]
def __ne__(self, rhs) -> Expression: ... # type: ignore[override]
- __lt__: Callable[[Self, Any], Expression]
- __le__: Callable[[Self, Any], Expression]
- __gt__: Callable[[Self, Any], Expression]
- __ge__: Callable[[Self, Any], Expression]
- __lshift__: Callable[[Self, Any], Expression]
- __rshift__: Callable[[Self, Any], Expression]
- __mod__: Callable[[Self, Any], Expression]
- __pow__: Callable[[Self, Any], Expression]
- like: Callable[[Self, Any], Expression]
- ilike: Callable[[Self, Any], Expression]
- bin_and: Callable[[Self, Any], Expression]
- bin_or: Callable[[Self, Any], Expression]
- in_: Callable[[Self, Any], Expression]
- not_in: Callable[[Self, Any], Expression]
- regexp: Callable[[Self, Any], Expression]
- iregexp: Callable[[Self, Any], Expression]
+ __lt__: ClassVar[Callable[[Self, Any], Expression]]
+ __le__: ClassVar[Callable[[Self, Any], Expression]]
+ __gt__: ClassVar[Callable[[Self, Any], Expression]]
+ __ge__: ClassVar[Callable[[Self, Any], Expression]]
+ __lshift__: ClassVar[Callable[[Self, Any], Expression]]
+ __rshift__: ClassVar[Callable[[Self, Any], Expression]]
+ __mod__: ClassVar[Callable[[Self, Any], Expression]]
+ __pow__: ClassVar[Callable[[Self, Any], Expression]]
+ like: ClassVar[Callable[[Self, Any], Expression]]
+ ilike: ClassVar[Callable[[Self, Any], Expression]]
+ bin_and: ClassVar[Callable[[Self, Any], Expression]]
+ bin_or: ClassVar[Callable[[Self, Any], Expression]]
+ in_: ClassVar[Callable[[Self, Any], Expression]]
+ not_in: ClassVar[Callable[[Self, Any], Expression]]
+ regexp: ClassVar[Callable[[Self, Any], Expression]]
+ iregexp: ClassVar[Callable[[Self, Any], Expression]]
def is_null(self, is_null: bool = ...) -> Expression: ...
def contains(self, rhs) -> Expression: ...
def startswith(self, rhs) -> Expression: ...
diff --git a/python/helpers/typeshed/stubs/pexpect/pexpect/spawnbase.pyi b/python/helpers/typeshed/stubs/pexpect/pexpect/spawnbase.pyi
index 384606784601..b236faeb7053 100644
--- a/python/helpers/typeshed/stubs/pexpect/pexpect/spawnbase.pyi
+++ b/python/helpers/typeshed/stubs/pexpect/pexpect/spawnbase.pyi
@@ -1,7 +1,7 @@
from asyncio import ReadTransport
from collections.abc import Awaitable, Callable, Iterable
from re import Match, Pattern
-from typing import IO, AnyStr, Generic, Literal, Protocol, TextIO, overload
+from typing import IO, AnyStr, Generic, Literal, Protocol, TextIO, overload, type_check_only
from typing_extensions import TypeAlias
from ._async import PatternWaiter
@@ -17,6 +17,7 @@ class _NullCoder:
@staticmethod
def decode(b: str, final: bool = False): ...
+@type_check_only
class _Logfile(Protocol):
def write(self, s, /) -> object: ...
def flush(self) -> object: ...
diff --git a/python/helpers/typeshed/stubs/pika/pika/adapters/blocking_connection.pyi b/python/helpers/typeshed/stubs/pika/pika/adapters/blocking_connection.pyi
index 41a5dc3af5a7..4dece0843e82 100644
--- a/python/helpers/typeshed/stubs/pika/pika/adapters/blocking_connection.pyi
+++ b/python/helpers/typeshed/stubs/pika/pika/adapters/blocking_connection.pyi
@@ -13,6 +13,7 @@ from ..spec import BasicProperties
LOGGER: Logger
class _CallbackResult:
+ __slots__ = ("_value_class", "_ready", "_values")
def __init__(self, value_class=None) -> None: ...
def reset(self) -> None: ...
def __bool__(self) -> bool: ...
@@ -37,11 +38,13 @@ class _IoloopTimerContext:
def is_ready(self): ...
class _TimerEvt:
+ __slots__ = ("timer_id", "_callback")
timer_id: Incomplete
def __init__(self, callback) -> None: ...
def dispatch(self) -> None: ...
class _ConnectionBlockedUnblockedEvtBase:
+ __slots__ = ("_callback", "_method_frame")
def __init__(self, callback, method_frame) -> None: ...
def dispatch(self) -> None: ...
@@ -91,18 +94,21 @@ class BlockingConnection:
class _ChannelPendingEvt: ...
class _ConsumerDeliveryEvt(_ChannelPendingEvt):
+ __slots__ = ("method", "properties", "body")
method: Incomplete
properties: Incomplete
body: Incomplete
def __init__(self, method, properties, body) -> None: ...
class _ConsumerCancellationEvt(_ChannelPendingEvt):
+ __slots__ = ("method_frame",)
method_frame: Incomplete
def __init__(self, method_frame) -> None: ...
@property
def method(self): ...
class _ReturnedMessageEvt(_ChannelPendingEvt):
+ __slots__ = ("callback", "channel", "method", "properties", "body")
callback: Incomplete
channel: Incomplete
method: Incomplete
@@ -112,12 +118,14 @@ class _ReturnedMessageEvt(_ChannelPendingEvt):
def dispatch(self) -> None: ...
class ReturnedMessage:
+ __slots__ = ("method", "properties", "body")
method: Incomplete
properties: Incomplete
body: Incomplete
def __init__(self, method, properties, body) -> None: ...
class _ConsumerInfo:
+ __slots__ = ("consumer_tag", "auto_ack", "on_message_callback", "alternate_event_sink", "state")
SETTING_UP: int
ACTIVE: int
TEARING_DOWN: int
@@ -138,6 +146,7 @@ class _ConsumerInfo:
def cancelled_by_broker(self): ...
class _QueueConsumerGeneratorInfo:
+ __slots__ = ("params", "consumer_tag", "pending_events")
params: Incomplete
consumer_tag: Incomplete
pending_events: Incomplete
diff --git a/python/helpers/typeshed/stubs/pika/pika/adapters/gevent_connection.pyi b/python/helpers/typeshed/stubs/pika/pika/adapters/gevent_connection.pyi
index 0979dbfcdd16..ab30dd6c4f83 100644
--- a/python/helpers/typeshed/stubs/pika/pika/adapters/gevent_connection.pyi
+++ b/python/helpers/typeshed/stubs/pika/pika/adapters/gevent_connection.pyi
@@ -1,4 +1,3 @@
-from _typeshed import Incomplete
from logging import Logger
from pika.adapters.base_connection import BaseConnection
@@ -10,17 +9,15 @@ LOGGER: Logger
class GeventConnection(BaseConnection):
def __init__(
self,
- parameters: Incomplete | None = ...,
- on_open_callback: Incomplete | None = ...,
- on_open_error_callback: Incomplete | None = ...,
- on_close_callback: Incomplete | None = ...,
- custom_ioloop: Incomplete | None = ...,
- internal_connection_workflow: bool = ...,
+ parameters=None,
+ on_open_callback=None,
+ on_open_error_callback=None,
+ on_close_callback=None,
+ custom_ioloop=None,
+ internal_connection_workflow: bool = True,
) -> None: ...
@classmethod
- def create_connection(
- cls, connection_configs, on_done, custom_ioloop: Incomplete | None = ..., workflow: Incomplete | None = ...
- ): ...
+ def create_connection(cls, connection_configs, on_done, custom_ioloop=None, workflow=None): ...
class _TSafeCallbackQueue:
def __init__(self) -> None: ...
@@ -33,7 +30,7 @@ class _GeventSelectorIOLoop(AbstractSelectorIOLoop):
READ: int
WRITE: int
ERROR: int
- def __init__(self, gevent_hub: Incomplete | None = ...) -> None: ...
+ def __init__(self, gevent_hub=None) -> None: ...
def close(self) -> None: ...
def start(self) -> None: ...
def stop(self) -> None: ...
@@ -45,13 +42,14 @@ class _GeventSelectorIOLoop(AbstractSelectorIOLoop):
def remove_handler(self, fd) -> None: ...
class _GeventSelectorIOServicesAdapter(SelectorIOServicesAdapter):
- def getaddrinfo(self, host, port, on_done, family: int = ..., socktype: int = ..., proto: int = ..., flags: int = ...): ...
+ def getaddrinfo(self, host, port, on_done, family: int = 0, socktype: int = 0, proto: int = 0, flags: int = 0): ...
class _GeventIOLoopIOHandle(AbstractIOReference):
def __init__(self, subject) -> None: ...
def cancel(self): ...
class _GeventAddressResolver:
+ __slots__ = ("_loop", "_on_done", "_greenlet", "_ga_host", "_ga_port", "_ga_family", "_ga_socktype", "_ga_proto", "_ga_flags")
def __init__(self, native_loop, host, port, family, socktype, proto, flags, on_done) -> None: ...
def start(self) -> None: ...
def cancel(self): ...
diff --git a/python/helpers/typeshed/stubs/pika/pika/adapters/select_connection.pyi b/python/helpers/typeshed/stubs/pika/pika/adapters/select_connection.pyi
index 4eed5e1f351e..8b3309410e20 100644
--- a/python/helpers/typeshed/stubs/pika/pika/adapters/select_connection.pyi
+++ b/python/helpers/typeshed/stubs/pika/pika/adapters/select_connection.pyi
@@ -23,6 +23,7 @@ class SelectConnection(BaseConnection):
def create_connection(cls, connection_configs, on_done, custom_ioloop=None, workflow=None): ...
class _Timeout:
+ __slots__ = ("deadline", "callback")
deadline: Incomplete
callback: Incomplete
def __init__(self, deadline, callback) -> None: ...
diff --git a/python/helpers/typeshed/stubs/pika/pika/adapters/utils/selector_ioloop_adapter.pyi b/python/helpers/typeshed/stubs/pika/pika/adapters/utils/selector_ioloop_adapter.pyi
index 91dd227fa3ed..17f1305f95fc 100644
--- a/python/helpers/typeshed/stubs/pika/pika/adapters/utils/selector_ioloop_adapter.pyi
+++ b/python/helpers/typeshed/stubs/pika/pika/adapters/utils/selector_ioloop_adapter.pyi
@@ -55,6 +55,7 @@ class SelectorIOServicesAdapter(
def remove_writer(self, fd): ...
class _FileDescriptorCallbacks:
+ __slots__ = ("reader", "writer")
reader: Incomplete
writer: Incomplete
def __init__(self, reader=None, writer=None) -> None: ...
diff --git a/python/helpers/typeshed/stubs/pika/pika/connection.pyi b/python/helpers/typeshed/stubs/pika/pika/connection.pyi
index 689bca9363fe..c8725542f6d5 100644
--- a/python/helpers/typeshed/stubs/pika/pika/connection.pyi
+++ b/python/helpers/typeshed/stubs/pika/pika/connection.pyi
@@ -17,6 +17,24 @@ PRODUCT: str
LOGGER: Logger
class Parameters:
+ __slots__ = (
+ "_blocked_connection_timeout",
+ "_channel_max",
+ "_client_properties",
+ "_connection_attempts",
+ "_credentials",
+ "_frame_max",
+ "_heartbeat",
+ "_host",
+ "_locale",
+ "_port",
+ "_retry_delay",
+ "_socket_timeout",
+ "_stack_timeout",
+ "_ssl_options",
+ "_virtual_host",
+ "_tcp_options",
+ )
DEFAULT_USERNAME: str
DEFAULT_PASSWORD: str
DEFAULT_BLOCKED_CONNECTION_TIMEOUT: None
@@ -106,6 +124,7 @@ class Parameters:
def tcp_options(self, value: dict[Incomplete, Incomplete] | None) -> None: ...
class ConnectionParameters(Parameters):
+ __slots__ = ()
def __init__(
self,
host: str = ...,
@@ -127,9 +146,11 @@ class ConnectionParameters(Parameters):
) -> None: ...
class URLParameters(Parameters):
+ __slots__ = ("_all_url_query_values",)
def __init__(self, url: str) -> None: ...
class SSLOptions:
+ __slots__ = ("context", "server_hostname")
context: ssl.SSLContext
server_hostname: str | None
def __init__(self, context: ssl.SSLContext, server_hostname: str | None = None) -> None: ...
diff --git a/python/helpers/typeshed/stubs/pika/pika/credentials.pyi b/python/helpers/typeshed/stubs/pika/pika/credentials.pyi
index 5fba83c452a3..9e6288b7b5f4 100644
--- a/python/helpers/typeshed/stubs/pika/pika/credentials.pyi
+++ b/python/helpers/typeshed/stubs/pika/pika/credentials.pyi
@@ -1,8 +1,9 @@
from logging import Logger
-from typing import ClassVar, Protocol
+from typing import ClassVar, Protocol, type_check_only
from .spec import Connection
+@type_check_only
class _Credentials(Protocol):
TYPE: ClassVar[str]
erase_on_connect: bool
diff --git a/python/helpers/typeshed/stubs/pika/pika/exchange_type.pyi b/python/helpers/typeshed/stubs/pika/pika/exchange_type.pyi
index ef55b20411f3..af625976ee47 100644
--- a/python/helpers/typeshed/stubs/pika/pika/exchange_type.pyi
+++ b/python/helpers/typeshed/stubs/pika/pika/exchange_type.pyi
@@ -1,7 +1,19 @@
-from enum import Enum
+import sys
-class ExchangeType(Enum):
- direct = "direct"
- fanout = "fanout"
- headers = "headers"
- topic = "topic"
+if sys.version_info >= (3, 11):
+ from enum import StrEnum
+
+ class ExchangeType(StrEnum):
+ direct = "direct"
+ fanout = "fanout"
+ headers = "headers"
+ topic = "topic"
+
+else:
+ from enum import Enum
+
+ class ExchangeType(str, Enum):
+ direct = "direct"
+ fanout = "fanout"
+ headers = "headers"
+ topic = "topic"
diff --git a/python/helpers/typeshed/stubs/pony/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/pony/@tests/stubtest_allowlist.txt
new file mode 100644
index 000000000000..5592e76d682c
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/@tests/stubtest_allowlist.txt
@@ -0,0 +1,14 @@
+# Tests should not be part of the stubs
+pony.orm.tests.*
+
+# Modules with ImportError, cannot import third-party libraries:
+pony.flask.*
+pony.orm.dbproviders.cockroach
+pony.orm.dbproviders.mysql
+pony.orm.dbproviders.oracle
+pony.orm.dbproviders.postgres
+pony.orm.integration.bottle_plugin
+pony.orm.examples.bottle_example
+
+# TODO: Incomplete issues in examples dir:
+pony.orm.examples.*
diff --git a/python/helpers/typeshed/stubs/pony/METADATA.toml b/python/helpers/typeshed/stubs/pony/METADATA.toml
new file mode 100644
index 000000000000..4110f557f94f
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/METADATA.toml
@@ -0,0 +1,3 @@
+version = "0.7.*"
+upstream_repository = "https://github.com/ponyorm/pony"
+requires = ["types-psycopg2", "types-PyMySQL"]
diff --git a/python/helpers/typeshed/stubs/pony/pony/__init__.pyi b/python/helpers/typeshed/stubs/pony/pony/__init__.pyi
new file mode 100644
index 000000000000..0bcdbcbd0c60
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/__init__.pyi
@@ -0,0 +1,14 @@
+from typing import Final, Literal
+from typing_extensions import TypeAlias
+
+_Mode: TypeAlias = Literal[
+ "GAE-LOCAL", "GAE-SERVER", "MOD_WSGI", "INTERACTIVE", "FCGI-FLUP", "UWSGI", "FLASK", "CHERRYPY", "BOTTLE", "UNKNOWN"
+]
+__version__: Final[str]
+
+def detect_mode() -> _Mode: ...
+
+MODE: Final[_Mode]
+MAIN_FILE: Final[str | None]
+MAIN_DIR: Final[str | None]
+PONY_DIR: Final[str]
diff --git a/python/helpers/typeshed/stubs/pony/pony/converting.pyi b/python/helpers/typeshed/stubs/pony/pony/converting.pyi
new file mode 100644
index 000000000000..631da5e69398
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/converting.pyi
@@ -0,0 +1,48 @@
+import re
+from _typeshed import ConvertibleToInt
+from collections.abc import Callable, Sequence
+from datetime import date, datetime, time, timedelta
+from typing import Any, Literal
+
+class ValidationError(ValueError): ...
+
+def check_ip(s: str) -> str: ...
+def check_positive(s: ConvertibleToInt) -> int: ...
+def check_identifier(s: str) -> str: ...
+
+isbn_re: re.Pattern[str]
+
+def isbn10_checksum(digits: Sequence[ConvertibleToInt]) -> str: ...
+def isbn13_checksum(digits: Sequence[ConvertibleToInt]) -> str: ...
+def check_isbn(s: str, convert_to: Literal[10, 13] | None = None) -> str: ...
+def isbn10_to_isbn13(s: str) -> str: ...
+def isbn13_to_isbn10(s: str) -> str: ...
+
+email_re: re.Pattern[str]
+rfc2822_email_re: re.Pattern[str]
+
+def check_email(s: str) -> str: ...
+def check_rfc2822_email(s: str) -> str: ...
+
+date_str_list: list[str]
+date_re_list: list[re.Pattern[str]]
+time_str: str
+time_re: re.Pattern[str]
+datetime_re_list: list[re.Pattern[str]]
+month_lists: list[list[str]]
+month_list: list[str]
+i: int
+month: str
+month_dict: dict[str, int]
+
+def str2date(s: str) -> date: ...
+def str2time(s: str) -> time: ...
+def str2datetime(s: str) -> datetime: ...
+def str2timedelta(s: str) -> timedelta: ...
+def timedelta2str(td: timedelta) -> str: ...
+
+converters: dict[type | str, tuple[Callable[[str], Any], type[str], str | None]] # Any type from types above
+
+def str2py(
+ value: str, type: str | type | tuple[Callable[[str], Any], type[str], str | None] | None
+) -> Any: ... # Any type from types above
diff --git a/python/helpers/typeshed/stubs/pony/pony/flask/__init__.pyi b/python/helpers/typeshed/stubs/pony/pony/flask/__init__.pyi
new file mode 100644
index 000000000000..ce220f1b7d60
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/flask/__init__.pyi
@@ -0,0 +1,17 @@
+from _typeshed import Incomplete
+from types import ModuleType
+from typing import Protocol
+
+# Protocol for flask.Flask class
+class _Flask(Protocol):
+ def before_request(self, f): ...
+ def after_request(self, f): ...
+ def teardown_request(self, f): ...
+
+flask_lib: ModuleType
+request: Incomplete
+
+class Pony:
+ app: _Flask | None
+ def __init__(self, app: _Flask | None = None) -> None: ...
+ def init_app(self, app: _Flask) -> None: ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/flask/example/__init__.pyi b/python/helpers/typeshed/stubs/pony/pony/flask/example/__init__.pyi
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/python/helpers/typeshed/stubs/pony/pony/flask/example/app.pyi b/python/helpers/typeshed/stubs/pony/pony/flask/example/app.pyi
new file mode 100644
index 000000000000..b45476eba0d9
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/flask/example/app.pyi
@@ -0,0 +1,8 @@
+from _typeshed import Incomplete
+
+from pony.flask import _Flask
+
+app: _Flask
+login_manager: Incomplete
+
+def load_user(user_id): ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/flask/example/config.pyi b/python/helpers/typeshed/stubs/pony/pony/flask/example/config.pyi
new file mode 100644
index 000000000000..0a7fba4bec91
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/flask/example/config.pyi
@@ -0,0 +1 @@
+config: dict[str, bool | str | dict[str, str | bool]]
diff --git a/python/helpers/typeshed/stubs/pony/pony/flask/example/models.pyi b/python/helpers/typeshed/stubs/pony/pony/flask/example/models.pyi
new file mode 100644
index 000000000000..290f90e958b2
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/flask/example/models.pyi
@@ -0,0 +1,10 @@
+from datetime import datetime
+
+from pony.orm.core import Database, Entity
+
+db: Database
+
+class User(Entity):
+ login: str
+ password: str
+ last_login: datetime | None
diff --git a/python/helpers/typeshed/stubs/pony/pony/flask/example/views.pyi b/python/helpers/typeshed/stubs/pony/pony/flask/example/views.pyi
new file mode 100644
index 000000000000..2043cc5ca582
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/flask/example/views.pyi
@@ -0,0 +1,4 @@
+def index() -> str: ...
+def login(): ...
+def reg(): ...
+def logout(): ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/options.pyi b/python/helpers/typeshed/stubs/pony/pony/options.pyi
new file mode 100644
index 000000000000..c65f52a795c0
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/options.pyi
@@ -0,0 +1,39 @@
+from typing import Final
+
+DEBUG: Final[bool]
+STATIC_DIR: Final[None]
+CUT_TRACEBACK: Final[bool]
+STD_DOCTYPE: Final[str]
+STD_STYLESHEETS: Final[list[tuple[str, ...]]]
+BASE_STYLESHEETS_PLACEHOLDER: Final[str]
+COMPONENT_STYLESHEETS_PLACEHOLDER: Final[str]
+SCRIPTS_PLACEHOLDER: Final[str]
+RELOADING_CHECK_INTERVAL: Final[float]
+LOG_TO_SQLITE: Final[None]
+LOGGING_LEVEL: Final[None]
+LOGGING_PONY_LEVEL: Final[None]
+MAX_SESSION_CTIME: Final[int]
+MAX_SESSION_MTIME: Final[int]
+MAX_LONGLIFE_SESSION: Final[int]
+COOKIE_SERIALIZATION_TYPE: Final[str]
+COOKIE_NAME: Final[str]
+COOKIE_PATH: Final[str]
+COOKIE_DOMAIN: Final[None]
+HASH_ALGORITHM: Final[None]
+SESSION_STORAGE: Final[None]
+MEMCACHE: Final[None]
+ALTERNATIVE_SESSION_MEMCACHE: Final[None]
+ALTERNATIVE_ORM_MEMCACHE: Final[None]
+ALTERNATIVE_TEMPLATING_MEMCACHE: Final[None]
+ALTERNATIVE_RESPONSE_MEMCACHE: Final[None]
+PICKLE_START_OFFSET: Final[int]
+PICKLE_HTML_AS_PLAIN_STR: Final[bool]
+RESTORE_ESCAPES: Final[bool]
+SOURCE_ENCODING: Final[None]
+CONSOLE_ENCODING: Final[None]
+MAX_FETCH_COUNT: Final[None]
+CONSOLE_WIDTH: Final[int]
+SIMPLE_ALIASES: Final[bool]
+INNER_JOIN_SYNTAX: Final[bool]
+DEBUGGING_REMOVE_ADDR: Final[bool]
+DEBUGGING_RESTORE_ESCAPES: Final[bool]
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/__init__.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/__init__.pyi
new file mode 100644
index 000000000000..e1dd6b0275cb
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/__init__.pyi
@@ -0,0 +1 @@
+from pony.orm.core import *
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/asttranslation.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/asttranslation.pyi
new file mode 100644
index 000000000000..6b3cfcc0e7fe
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/asttranslation.pyi
@@ -0,0 +1,139 @@
+import ast
+import sys
+from _typeshed import Incomplete
+from collections.abc import Callable, Generator
+from typing import Any, TypeVar
+
+_T = TypeVar("_T")
+
+class TranslationError(Exception): ...
+
+pre_method_caches: dict[type[ASTTranslator], dict[type[ast.AST], Callable[..., Any]]]
+post_method_caches: dict[type[ASTTranslator], dict[type[ast.AST], Callable[..., Any]]]
+
+class ASTTranslator:
+ tree: Incomplete
+ def __init__(translator, tree) -> None: ...
+ def dispatch(translator, node: ast.AST) -> None: ...
+ def call(translator, method: Callable[[ASTTranslator, ast.AST], _T], node: ast.AST) -> _T | None: ...
+ def default_pre(translator, node: ast.AST) -> None: ...
+ def default_post(translator, node: ast.AST) -> None: ...
+
+def priority(p: int): ...
+def binop_src(op: str, node) -> str: ...
+def ast2src(tree): ...
+def get_child_nodes(node: ast.AST) -> Generator[ast.AST]: ...
+
+class PythonTranslator(ASTTranslator):
+ def __init__(translator, tree) -> None: ...
+ def call(translator, method, node) -> None: ...
+ def default_pre(translator, node: ast.AST): ...
+ def default_post(translator, node: ast.AST) -> None: ...
+ def postGeneratorExp(translator, node: ast.GeneratorExp) -> str: ...
+ def postcomprehension(translator, node: ast.comprehension) -> str: ...
+ def postGenExprIf(translator, node) -> str: ...
+ def postExpr(translator, node: ast.Expr) -> str: ...
+ def postIfExp(translator, node: ast.IfExp) -> str: ...
+ def postLambda(translator, node: ast.Lambda) -> str: ...
+ def postarguments(translator, node: ast.arguments) -> str: ...
+ def postarg(translator, node: ast.arg) -> str: ...
+ def postOr(translator, node: ast.Or) -> str: ...
+ def postAnd(translator, node: ast.And) -> str: ...
+ def postNot(translator, node: ast.Not) -> str: ...
+ def postCompare(translator, node: ast.Compare) -> str: ...
+ def postEq(translator, node: ast.Eq) -> str: ...
+ def postNotEq(translator, node: ast.NotEq) -> str: ...
+ def postLt(translator, node: ast.Lt) -> str: ...
+ def postLtE(translator, node: ast.LtE) -> str: ...
+ def postGt(translator, node: ast.Gt) -> str: ...
+ def postGtE(translator, node: ast.GtE) -> str: ...
+ def postIs(translator, node: ast.Is) -> str: ...
+ def postIsNot(translator, node: ast.IsNot) -> str: ...
+ def postIn(translator, node: ast.In) -> str: ...
+ def postNotIn(translator, node: ast.NotIn) -> str: ...
+ def postBitOr(translator, node: ast.BitOr) -> str: ...
+ def postBitXor(translator, node: ast.BitXor) -> str: ...
+ def postBitAnd(translator, node: ast.BitAnd) -> str: ...
+ def postLShift(translator, node: ast.LShift) -> str: ...
+ def postRShift(translator, node: ast.RShift) -> str: ...
+ def postAdd(translator, node: ast.Add) -> str: ...
+ def postSub(translator, node: ast.Sub) -> str: ...
+ def postMult(translator, node: ast.Mult): ...
+ def postMatMult(translator, node: ast.MatMult) -> None: ...
+ def postDiv(translator, node: ast.Div) -> str: ...
+ def postFloorDiv(translator, node: ast.FloorDiv) -> str: ...
+ def postMod(translator, node: ast.Mod) -> str: ...
+ def postUSub(translator, node: ast.USub) -> str: ...
+ def postUAdd(translator, node: ast.UAdd) -> str: ...
+ def postInvert(translator, node: ast.Invert) -> str: ...
+ def postPow(translator, node: ast.Pow) -> str: ...
+ def postAttribute(translator, node: ast.Attribute) -> str: ...
+ def postCall(translator, node: ast.Call) -> str: ...
+ def postkeyword(translator, node: ast.keyword) -> str: ...
+ def postStarred(translator, node: ast.Starred) -> str: ...
+ def postSubscript(translator, node: ast.Subscript) -> str: ...
+ def postIndex(translator, node: ast.Index) -> str: ...
+ def postSlice(translator, node: ast.Slice) -> str: ...
+ def postConstant(translator, node: ast.Constant) -> str: ...
+ if sys.version_info >= (3, 14):
+ def postNameConstant(translator, node: ast.Constant) -> str: ...
+ def postNum(translator, node: ast.Constant) -> str: ...
+ def postStr(translator, node: ast.Constant) -> str: ...
+ def postBytes(translator, node: ast.Constant) -> str: ...
+ else:
+ def postNameConstant(translator, node: ast.NameConstant) -> str: ...
+ def postNum(translator, node: ast.Num) -> str: ...
+ def postStr(translator, node: ast.Str) -> str: ...
+ def postBytes(translator, node: ast.Bytes) -> str: ...
+
+ def postList(translator, node: ast.List) -> str: ...
+ def postTuple(translator, node: ast.Tuple) -> str: ...
+ def postDict(translator, node: ast.Dict) -> str: ...
+ def postSet(translator, node: ast.Set) -> str: ...
+ def postName(translator, node: ast.Name) -> str: ...
+ def postJoinedStr(self, node: ast.JoinedStr) -> str: ...
+ def postFormattedValue(self, node: ast.FormattedValue) -> str: ...
+
+nonexternalizable_types: tuple[type[ast.AST], ...]
+
+class PreTranslator(ASTTranslator):
+ def __init__(translator, tree, globals, locals, special_functions, const_functions, outer_names=()) -> None: ...
+ def dispatch(translator, node) -> None: ...
+ def preGeneratorExp(translator, node: ast.GeneratorExp) -> bool: ...
+ def preLambda(translator, node: ast.Lambda) -> bool: ...
+ def postName(translator, node: ast.Name) -> None: ...
+ def postSlice(translator, node: ast.Slice) -> None: ...
+ def postStarred(translator, node: ast.Starred) -> None: ...
+ def postConstant(translator, node: ast.Constant) -> None: ...
+ if sys.version_info >= (3, 14):
+ def postNum(translator, node: ast.Constant) -> None: ...
+ def postStr(translator, node: ast.Constant) -> None: ...
+ def postBytes(translator, node: ast.Constant) -> None: ...
+ else:
+ def postNum(translator, node: ast.Num) -> None: ...
+ def postStr(translator, node: ast.Str) -> None: ...
+ def postBytes(translator, node: ast.Bytes) -> None: ...
+
+ def postDict(translator, node: ast.Dict) -> None: ...
+ def postList(translator, node: ast.List) -> None: ...
+ def postkeyword(translator, node: ast.keyword) -> None: ...
+ def postIndex(translator, node: ast.Index) -> None: ...
+ def postCall(translator, node: ast.Call) -> None: ...
+ def postCompare(translator, node: ast.Compare) -> None: ...
+ def post_binop(translator, node: ast.BinOp) -> None: ...
+ def postBitOr(translator, node: ast.BitOr) -> None: ...
+ def postBitXor(translator, node: ast.BitXor) -> None: ...
+ def postBitAnd(translator, node: ast.BitAnd) -> None: ...
+ def postLShift(translator, node: ast.LShift) -> None: ...
+ def postRShift(translator, node: ast.RShift) -> None: ...
+ def postAdd(translator, node: ast.Add) -> None: ...
+ def postSub(translator, node: ast.Sub) -> None: ...
+ def postMult(translator, node: ast.Mult) -> None: ...
+ def postMatMult(translator, node: ast.MatMult) -> None: ...
+ def postDiv(translator, node: ast.Div) -> None: ...
+ def postFloorDiv(translator, node: ast.FloorDiv) -> None: ...
+ def postMod(translator, node: ast.Mod) -> None: ...
+
+extractors_cache: dict[str | int, tuple[Incomplete, dict[Incomplete, Incomplete]]]
+
+def create_extractors(code_key: str | int, tree, globals, locals, special_functions, const_functions, outer_names=()): ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/core.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/core.pyi
new file mode 100644
index 000000000000..87c311910ab5
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/core.pyi
@@ -0,0 +1,917 @@
+import ast
+import itertools
+import re
+import types
+from _typeshed import Incomplete
+from collections import defaultdict
+from collections.abc import Callable, Generator
+from logging import Logger
+from typing import Literal, NoReturn, TypeVar
+from typing_extensions import Self, TypeAlias, deprecated
+
+import pony as pony
+from pony.orm.asttranslation import TranslationError as TranslationError
+from pony.orm.dbapiprovider import (
+ DatabaseError as DatabaseError,
+ DataError as DataError,
+ DBException as DBException,
+ Error as Error,
+ IntegrityError as IntegrityError,
+ InterfaceError as InterfaceError,
+ InternalError as InternalError,
+ NotSupportedError as NotSupportedError,
+ OperationalError as OperationalError,
+ ProgrammingError as ProgrammingError,
+ Warning as Warning,
+)
+from pony.orm.ormtypes import (
+ Array,
+ FloatArray as FloatArray,
+ IntArray as IntArray,
+ Json as Json,
+ LongStr as LongStr,
+ LongUnicode as LongUnicode,
+ StrArray as StrArray,
+ raw_sql as raw_sql,
+)
+from pony.py23compat import buffer as buffer, unicode as unicode
+from pony.utils import between as between, coalesce as coalesce, concat as concat, localbase
+
+_T = TypeVar("_T")
+_KnownProvider: TypeAlias = Literal["sqlite", "postgres", "mysql", "oracle"]
+
+__all__ = [
+ "pony",
+ "DBException",
+ "RowNotFound",
+ "MultipleRowsFound",
+ "TooManyRowsFound",
+ "Warning",
+ "Error",
+ "InterfaceError",
+ "DatabaseError",
+ "DataError",
+ "OperationalError",
+ "IntegrityError",
+ "InternalError",
+ "ProgrammingError",
+ "NotSupportedError",
+ "OrmError",
+ "ERDiagramError",
+ "DBSchemaError",
+ "MappingError",
+ "BindingError",
+ "TableDoesNotExist",
+ "TableIsNotEmpty",
+ "ConstraintError",
+ "CacheIndexError",
+ "ObjectNotFound",
+ "MultipleObjectsFoundError",
+ "TooManyObjectsFoundError",
+ "OperationWithDeletedObjectError",
+ "TransactionError",
+ "ConnectionClosedError",
+ "TransactionIntegrityError",
+ "IsolationError",
+ "CommitException",
+ "RollbackException",
+ "UnrepeatableReadError",
+ "OptimisticCheckError",
+ "UnresolvableCyclicDependency",
+ "UnexpectedError",
+ "DatabaseSessionIsOver",
+ "PonyRuntimeWarning",
+ "DatabaseContainsIncorrectValue",
+ "DatabaseContainsIncorrectEmptyValue",
+ "TranslationError",
+ "ExprEvalError",
+ "PermissionError",
+ "Database",
+ "sql_debug",
+ "set_sql_debug",
+ "sql_debugging",
+ "show",
+ "PrimaryKey",
+ "Required",
+ "Optional",
+ "Set",
+ "Discriminator",
+ "composite_key",
+ "composite_index",
+ "flush",
+ "commit",
+ "rollback",
+ "db_session",
+ "with_transaction",
+ "make_proxy",
+ "LongStr",
+ "LongUnicode",
+ "Json",
+ "IntArray",
+ "StrArray",
+ "FloatArray",
+ "select",
+ "left_join",
+ "get",
+ "exists",
+ "delete",
+ "count",
+ "sum",
+ "min",
+ "max",
+ "avg",
+ "group_concat",
+ "distinct",
+ "JOIN",
+ "desc",
+ "between",
+ "concat",
+ "coalesce",
+ "raw_sql",
+ "buffer",
+ "unicode",
+ "get_current_user",
+ "set_current_user",
+ "perm",
+ "has_perm",
+ "get_user_groups",
+ "get_user_roles",
+ "get_object_labels",
+ "user_groups_getter",
+ "user_roles_getter",
+ "obj_labels_getter",
+]
+
+suppress_debug_change: bool
+
+def sql_debug(value: bool) -> None: ...
+def set_sql_debug(debug: bool = True, show_values=None) -> None: ...
+
+orm_logger: Logger
+sql_logger: Logger
+orm_log_level: int
+
+def log_orm(msg: object) -> None: ...
+def args2str(args: list[object] | tuple[object] | dict[object, object]) -> str: ...
+
+class OrmError(Exception): ...
+class ERDiagramError(OrmError): ...
+class DBSchemaError(OrmError): ...
+class MappingError(OrmError): ...
+class BindingError(OrmError): ...
+class TableDoesNotExist(OrmError): ...
+class TableIsNotEmpty(OrmError): ...
+class ConstraintError(OrmError): ...
+class CacheIndexError(OrmError): ...
+class RowNotFound(OrmError): ...
+class MultipleRowsFound(OrmError): ...
+class TooManyRowsFound(OrmError): ...
+class PermissionError(OrmError): ...
+
+class ObjectNotFound(OrmError):
+ def __init__(
+ exc, entity: Entity, pkval: object | tuple[object, ...] | None = None # pkval passing to repr() builtins function
+ ) -> None: ...
+
+class MultipleObjectsFoundError(OrmError): ...
+class TooManyObjectsFoundError(OrmError): ...
+class OperationWithDeletedObjectError(OrmError): ...
+class TransactionError(OrmError): ...
+class ConnectionClosedError(TransactionError): ...
+
+class TransactionIntegrityError(TransactionError):
+ def __init__(exc, msg, original_exc=None) -> None: ...
+
+class CommitException(TransactionError):
+ def __init__(exc, msg, exceptions) -> None: ...
+
+class PartialCommitException(TransactionError):
+ def __init__(exc, msg, exceptions) -> None: ...
+
+class RollbackException(TransactionError):
+ def __init__(exc, msg, exceptions) -> None: ...
+
+class DatabaseSessionIsOver(TransactionError): ...
+
+TransactionRolledBack = DatabaseSessionIsOver
+
+class IsolationError(TransactionError): ...
+class UnrepeatableReadError(IsolationError): ...
+class OptimisticCheckError(IsolationError): ...
+class UnresolvableCyclicDependency(TransactionError): ...
+
+class UnexpectedError(TransactionError):
+ def __init__(exc, msg, original_exc) -> None: ...
+
+class ExprEvalError(TranslationError):
+ def __init__(exc, src, cause) -> None: ...
+
+class PonyInternalException(Exception): ...
+class OptimizationFailed(PonyInternalException): ...
+
+class UseAnotherTranslator(PonyInternalException):
+ translator: Incomplete
+ def __init__(self, translator) -> None: ...
+
+class PonyRuntimeWarning(RuntimeWarning): ...
+class DatabaseContainsIncorrectValue(PonyRuntimeWarning): ...
+class DatabaseContainsIncorrectEmptyValue(DatabaseContainsIncorrectValue): ...
+
+class PrefetchContext:
+ database: Incomplete
+ attrs_to_prefetch_dict: Incomplete
+ entities_to_prefetch: Incomplete
+ relations_to_prefetch_cache: Incomplete
+ def __init__(self, database=None) -> None: ...
+ def copy(self): ...
+ def __enter__(self) -> None: ...
+ def __exit__(
+ self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None
+ ) -> None: ...
+ def get_frozen_attrs_to_prefetch(self, entity): ...
+ def get_relations_to_prefetch(self, entity): ...
+
+class Local(localbase):
+ def __init__(local) -> None: ...
+ @property
+ def prefetch_context(local): ...
+ def push_debug_state(local, debug, show_values) -> None: ...
+ def pop_debug_state(local) -> None: ...
+
+local: Local
+
+def flush() -> None: ...
+def commit() -> None: ...
+def rollback() -> None: ...
+
+class DBSessionContextManager:
+ __slots__ = (
+ "retry",
+ "retry_exceptions",
+ "allowed_exceptions",
+ "immediate",
+ "ddl",
+ "serializable",
+ "strict",
+ "optimistic",
+ "sql_debug",
+ "show_values",
+ )
+ retry: int
+ ddl: bool
+ serializable: bool
+ immediate: bool
+ strict: bool
+ optimistic: bool
+ retry_exceptions: tuple[type[Exception], ...]
+ allowed_exceptions: tuple[type[Exception], ...]
+ sql_debug: bool | None
+ show_values: bool | None
+ def __init__(
+ db_session,
+ retry: int = 0,
+ immediate: bool = False,
+ ddl: bool = False,
+ serializable: bool = False,
+ strict: bool = False,
+ optimistic: bool = True,
+ retry_exceptions: tuple[type[Exception], ...] = ...,
+ allowed_exceptions: tuple[type[Exception], ...] = (),
+ sql_debug: bool | None = None,
+ show_values: bool | None = None,
+ ) -> None: ...
+ def __call__(db_session, *args, **kwargs): ...
+ def __enter__(db_session) -> None: ...
+ def __exit__(db_session, exc_type=None, exc=None, tb=None) -> None: ...
+
+db_session: DBSessionContextManager
+
+class SQLDebuggingContextManager:
+ debug: bool
+ show_values: Incomplete
+ def __init__(self, debug: bool = True, show_values=None) -> None: ...
+ def __call__(self, *args, **kwargs): ...
+ def __enter__(self) -> None: ...
+ def __exit__(self, exc_type=None, exc=None, tb=None) -> None: ...
+
+sql_debugging: SQLDebuggingContextManager
+
+def throw_db_session_is_over(action: str, obj: Entity, attr: Attribute | None = None) -> NoReturn: ...
+@deprecated("@with_transaction decorator is deprecated, use @db_session decorator instead.")
+def with_transaction(*args, **kwargs): ...
+
+known_providers: tuple[_KnownProvider, ...]
+
+class OnConnectDecorator:
+ @staticmethod
+ def check_provider(provider: str | None) -> None: ...
+ provider: _KnownProvider | None
+ database: Incomplete
+ def __init__(self, database: Database, provider: str | None) -> None: ...
+ def __call__(self, func: types.FunctionType | None = None, provider: str | None = None) -> Self: ...
+
+db_id_counter: itertools.count[int]
+
+class Database:
+ def __deepcopy__(self, memo) -> Self: ...
+ id: Incomplete
+ priority: int
+ entities: Incomplete
+ schema: Incomplete
+ Entity: type[Entity]
+ on_connect: OnConnectDecorator
+ provider: Incomplete
+ def __init__(self, *args, **kwargs) -> None: ...
+ def call_on_connect(database, con) -> None: ...
+ def bind(self, *args, **kwargs) -> None: ...
+ @property
+ def last_sql(database): ...
+ @property
+ def local_stats(database): ...
+ def merge_local_stats(database) -> None: ...
+ @property
+ def global_stats(database): ...
+ @property
+ @deprecated("global_stats_lock is deprecated, just use global_stats property without any locking.")
+ def global_stats_lock(database): ...
+ def get_connection(database): ...
+ def disconnect(database) -> None: ...
+ def flush(database) -> None: ...
+ def commit(database) -> None: ...
+ def rollback(database) -> None: ...
+ def execute(database, sql, globals=None, locals=None): ...
+ def select(database, sql, globals=None, locals=None, frame_depth: int = 0): ...
+ def get(database, sql, globals=None, locals=None): ...
+ def exists(database, sql, globals=None, locals=None): ...
+ def insert(database, table_name, returning=None, **kwargs): ...
+ def generate_mapping(database, filename=None, check_tables: bool = True, create_tables: bool = False): ...
+ def drop_table(database, table_name, if_exists: bool = False, with_all_data: bool = False) -> None: ...
+ def drop_all_tables(database, with_all_data: bool = False) -> None: ...
+ def create_tables(database, check_tables: bool = False) -> None: ...
+ def check_tables(database) -> None: ...
+ def set_perms_for(database, *entities) -> Generator[None]: ...
+ def to_json(database, data, include=(), exclude=(), converter=None, with_schema: bool = True, schema_hash=None): ...
+ def from_json(database, changes, observer=None): ...
+
+def basic_converter(x): ...
+def perm(*args, **kwargs) -> AccessRule: ...
+def pop_names_from_kwargs(typename, kwargs, *kwnames): ...
+
+class AccessRule:
+ def __init__(rule, database, entities, permissions, groups, roles, labels) -> None: ...
+ def exclude(rule, *args) -> None: ...
+
+def has_perm(user, perm, x) -> bool: ...
+def can_view(user, x) -> bool: ...
+def can_edit(user, x) -> bool: ...
+def can_create(user, x) -> bool: ...
+def can_delete(user, x) -> bool: ...
+def get_current_user(): ...
+def set_current_user(user) -> None: ...
+
+anybody_frozenset: frozenset[str]
+
+def get_user_groups(user): ...
+def get_user_roles(user, obj): ...
+def get_object_labels(obj): ...
+
+usergroup_functions: list[Incomplete]
+
+def user_groups_getter(cls=None): ...
+
+userrole_functions: list[Incomplete]
+
+def user_roles_getter(user_cls=None, obj_cls=None): ...
+
+objlabel_functions: list[Incomplete]
+
+def obj_labels_getter(cls=None): ...
+
+class DbLocal(localbase):
+ stats: Incomplete
+ last_sql: Incomplete
+ def __init__(dblocal) -> None: ...
+
+class QueryStat:
+ def __init__(stat, sql, duration=None) -> None: ...
+ def copy(stat): ...
+ def query_executed(stat, duration) -> None: ...
+ def merge(stat, stat2) -> None: ...
+ @property
+ def avg_time(stat): ...
+
+num_counter: itertools.count[int]
+
+class SessionCache:
+ is_alive: bool
+ num: int
+ database: Database
+ objects: set[Incomplete]
+ indexes: defaultdict[Incomplete, dict[Incomplete, Incomplete]] | None
+ seeds: defaultdict[Incomplete, set[Incomplete]] | None
+ max_id_cache: dict[Incomplete, Incomplete] | None
+ collection_statistics: dict[Incomplete, Incomplete] | None
+ for_update: set[Incomplete] | None
+ noflush_counter: int
+ modified_collections: defaultdict[Incomplete, set[Incomplete]] | None
+ objects_to_save: list[Incomplete] | None
+ saved_objects: list[Incomplete] | None
+ query_results: dict[Incomplete, Incomplete] | None
+ dbvals_deduplication_cache: defaultdict[Incomplete, dict[Incomplete, Incomplete]] | None
+ modified: bool
+ db_session: Incomplete
+ immediate: bool
+ connection: Incomplete
+ in_transaction: bool
+ saved_fk_state: Incomplete
+ perm_cache: Incomplete
+ user_roles_cache: defaultdict[Incomplete, dict[Incomplete, Incomplete]] | None
+ obj_labels_cache: dict[Incomplete, Incomplete] | None
+ def __init__(cache, database: Database) -> None: ...
+ def connect(cache): ...
+ def reconnect(cache, exc): ...
+ def prepare_connection_for_query_execution(cache): ...
+ def flush_and_commit(cache) -> None: ...
+ def commit(cache) -> None: ...
+ def rollback(cache) -> None: ...
+ def release(cache) -> None: ...
+ def close(cache, rollback: bool = True) -> None: ...
+ def flush_disabled(cache) -> Generator[None]: ...
+ def flush(cache) -> None: ...
+ def call_after_save_hooks(cache) -> None: ...
+ def update_simple_index(cache, obj, attr, old_val, new_val, undo) -> None: ...
+ def db_update_simple_index(cache, obj, attr, old_dbval, new_dbval) -> None: ...
+ def update_composite_index(cache, obj, attrs, prev_vals, new_vals, undo) -> None: ...
+ def db_update_composite_index(cache, obj, attrs, prev_vals, new_vals) -> None: ...
+
+class NotLoadedValueType: ...
+
+NOT_LOADED: NotLoadedValueType
+
+class DefaultValueType: ...
+
+DEFAULT: DefaultValueType
+
+class DescWrapper:
+ attr: Attribute
+ def __init__(self, attr: Attribute) -> None: ...
+ def __call__(self) -> Self: ...
+ def __eq__(self, other: object) -> bool: ...
+ def __ne__(self, other: object) -> bool: ...
+ def __hash__(self) -> int: ...
+
+attr_id_counter: itertools.count[int]
+
+class Attribute:
+ __slots__ = (
+ "nullable",
+ "is_required",
+ "is_discriminator",
+ "is_unique",
+ "is_part_of_unique_index",
+ "is_pk",
+ "is_collection",
+ "is_relation",
+ "is_basic",
+ "is_string",
+ "is_volatile",
+ "is_implicit",
+ "id",
+ "pk_offset",
+ "pk_columns_offset",
+ "py_type",
+ "sql_type",
+ "entity",
+ "name",
+ "lazy",
+ "lazy_sql_cache",
+ "args",
+ "auto",
+ "default",
+ "reverse",
+ "composite_keys",
+ "column",
+ "columns",
+ "col_paths",
+ "_columns_checked",
+ "converters",
+ "kwargs",
+ "cascade_delete",
+ "index",
+ "reverse_index",
+ "original_default",
+ "sql_default",
+ "py_check",
+ "hidden",
+ "optimistic",
+ "fk_name",
+ "type_has_empty_value",
+ "interleave",
+ )
+ nullable: bool | None
+ is_required: bool
+ is_discriminator: bool
+ is_unique: bool | None
+ is_part_of_unique_index: bool | None
+ is_pk: bool
+ is_collection: bool
+ is_relation: bool
+ is_basic: bool
+ is_string: bool
+ is_volatile: bool
+ is_implicit: bool
+ id: int
+ pk_offset: int | None
+ pk_columns_offset: int
+ py_type: type | str | types.FunctionType | Array
+ sql_type: Incomplete
+ entity: Incomplete
+ name: Incomplete
+ lazy: bool
+ lazy_sql_cache: Incomplete
+ args: tuple[Incomplete, ...]
+ auto: bool
+ default: Incomplete
+ reverse: str | Attribute | None
+ composite_keys: list[tuple[Incomplete, int]]
+ column: str | None
+ columns: list[str] | tuple[str, ...]
+ col_paths: list[Incomplete]
+ converters: list[Incomplete]
+ kwargs: dict[str, Incomplete]
+ cascade_delete: bool | None
+ index: str | bool | None
+ reverse_index: Incomplete
+ original_default: Incomplete
+ sql_default: str | bool | None
+ py_check: Callable[..., bool] | None
+ hidden: bool
+ optimistic: bool | None
+ fk_name: str | None
+ type_has_empty_value: bool
+ interleave: bool | None
+ def __deepcopy__(attr, memo): ...
+ def __init__(attr, py_type: type | str | types.FunctionType | Array, *args, **kwargs) -> None: ...
+ def linked(attr) -> None: ...
+ def __lt__(attr, other): ...
+ def validate(attr, val, obj=None, entity=None, from_db: bool = False): ...
+ def parse_value(attr, row, offsets, dbvals_deduplication_cache): ...
+ def load(attr, obj: Entity): ...
+ def __get__(attr, obj, cls=None): ...
+ def get(attr, obj): ...
+ def __set__(attr, obj, new_val, undo_funcs=None) -> None: ...
+ def db_set(attr, obj, new_dbval, is_reverse_call: bool = False) -> None: ...
+ def update_reverse(attr, obj, old_val, new_val, undo_funcs) -> None: ...
+ def db_update_reverse(attr, obj, old_dbval, new_dbval) -> None: ...
+ def __delete__(attr, obj) -> None: ...
+ def get_raw_values(attr, val): ...
+ def get_columns(attr) -> list[str] | tuple[str, ...]: ...
+ @property
+ def asc(attr) -> Self: ...
+ @property
+ def desc(attr) -> DescWrapper: ...
+ def describe(attr) -> str: ...
+
+class Optional(Attribute):
+ __slots__: list[str] = []
+
+class Required(Attribute):
+ __slots__: list[str] = []
+ def validate(attr, val, obj=None, entity=None, from_db: bool = False): ...
+
+class Discriminator(Required):
+ __slots__ = ["code2cls"]
+ code2cls: dict[Incomplete, Incomplete]
+ def __init__(attr, py_type, *args, **kwargs) -> None: ...
+ @staticmethod
+ def create_default_attr(entity) -> None: ...
+ def process_entity_inheritance(attr, entity) -> None: ...
+ def validate(attr, val, obj=None, entity=None, from_db: bool = False): ...
+ def load(attr, obj) -> None: ...
+ def __get__(attr, obj, cls=None): ...
+ def __set__(attr, obj, new_val) -> None: ... # type: ignore[override]
+ def db_set(attr, obj, new_dbval) -> None: ... # type: ignore[override]
+ def update_reverse(attr, obj, old_val, new_val, undo_funcs) -> None: ...
+
+class Index:
+ __slots__ = ("entity", "attrs", "is_pk", "is_unique")
+ entity: Incomplete
+ attrs: list[Incomplete]
+ is_pk: bool
+ is_unique: bool
+ def __init__(index, *attrs, **options) -> None: ...
+
+def composite_index(*attrs) -> None: ...
+def composite_key(*attrs) -> None: ...
+
+class PrimaryKey(Required):
+ __slots__: list[str] = []
+ def __new__(cls, *args, **kwargs): ...
+
+class Collection(Attribute):
+ __slots__ = (
+ "table",
+ "wrapper_class",
+ "symmetric",
+ "reverse_column",
+ "reverse_columns",
+ "nplus1_threshold",
+ "cached_load_sql",
+ "cached_add_m2m_sql",
+ "cached_remove_m2m_sql",
+ "cached_count_sql",
+ "cached_empty_sql",
+ "reverse_fk_name",
+ )
+ table: str | list[str] | tuple[str, ...] | None
+ wrapper_class: Incomplete
+ symmetric: bool
+ reverse_column: Incomplete
+ reverse_columns: Incomplete
+ nplus1_threshold: int
+ cached_load_sql: dict[int, Incomplete]
+ cached_add_m2m_sql: tuple[Incomplete, Incomplete] | None
+ cached_remove_m2m_sql: tuple[Incomplete, Incomplete] | None
+ cached_count_sql: tuple[Incomplete, Incomplete] | None
+ cached_empty_sql: tuple[Incomplete, Incomplete, Incomplete] | None
+ reverse_fk_name: Incomplete
+ def __init__(attr, py_type, *args, **kwargs) -> None: ...
+ def load(attr, obj) -> None: ...
+ def __get__(attr, obj, cls=None) -> None: ...
+ def __set__(attr, obj, val) -> None: ... # type: ignore[override]
+ def __delete__(attr, obj) -> None: ...
+ def prepare(attr, obj, val, fromdb: bool = False) -> None: ...
+ def set(attr, obj, val, fromdb: bool = False) -> None: ...
+
+class SetData(set[Incomplete]):
+ __slots__ = ("is_fully_loaded", "added", "removed", "absent", "count")
+ is_fully_loaded: bool
+ added: Incomplete
+ removed: Incomplete
+ absent: Incomplete
+ count: int | None
+ def __init__(setdata) -> None: ...
+
+def construct_batchload_criteria_list(
+ alias, columns, converters, batch_size, row_value_syntax, start: int = 0, from_seeds: bool = True
+): ...
+
+class Set(Collection):
+ __slots__: list[str] = []
+ def validate(attr, val, obj=None, entity=None, from_db: bool = False): ...
+ def prefetch_load_all(attr, objects): ...
+ def load(attr, obj, items=None): ...
+ def construct_sql_m2m(attr, batch_size: int = 1, items_count: int = 0): ...
+ def copy(attr, obj): ...
+ def __get__(attr, obj, cls=None): ...
+ def __set__(attr, obj, new_items, undo_funcs=None) -> None: ...
+ def __delete__(attr, obj) -> None: ...
+ def reverse_add(attr, objects, item, undo_funcs) -> None: ...
+ def db_reverse_add(attr, objects, item) -> None: ...
+ def reverse_remove(attr, objects, item, undo_funcs) -> None: ...
+ def db_reverse_remove(attr, objects, item) -> None: ...
+ def get_m2m_columns(attr, is_reverse: bool = False): ...
+ def remove_m2m(attr, removed) -> None: ...
+ def add_m2m(attr, added) -> None: ...
+ def drop_table(attr, with_all_data: bool = False) -> None: ...
+
+def unpickle_setwrapper(obj, attrname, items): ...
+
+class SetIterator:
+ def __init__(self, wrapper) -> None: ...
+ def __iter__(self): ...
+ def next(self): ...
+ __next__ = next
+
+class SetInstance:
+ __slots__ = ("_obj_", "_attr_", "_attrnames_")
+ def __init__(wrapper, obj, attr) -> None: ...
+ def __reduce__(wrapper): ...
+ def copy(wrapper): ...
+ def __nonzero__(wrapper): ...
+ def is_empty(wrapper): ...
+ def __len__(wrapper) -> int: ...
+ def count(wrapper): ...
+ def __iter__(wrapper): ...
+ def __eq__(wrapper, other): ...
+ def __ne__(wrapper, other): ...
+ def __add__(wrapper, new_items): ...
+ def __sub__(wrapper, items): ...
+ def __contains__(wrapper, item) -> bool: ...
+ def create(wrapper, **kwargs): ...
+ def add(wrapper, new_items) -> None: ...
+ def __iadd__(wrapper, items): ...
+ def remove(wrapper, items) -> None: ...
+ def __isub__(wrapper, items): ...
+ def clear(wrapper) -> None: ...
+ def load(wrapper) -> None: ...
+ def select(wrapper, *args, **kwargs): ...
+ filter = select
+ def limit(wrapper, limit=None, offset=None): ...
+ def page(wrapper, pagenum, pagesize: int = 10): ...
+ def order_by(wrapper, *args): ...
+ def sort_by(wrapper, *args): ...
+ def random(wrapper, limit): ...
+
+def unpickle_multiset(obj, attrnames, items): ...
+
+class Multiset:
+ __slots__ = ["_obj_", "_attrnames_", "_items_"]
+ def __init__(multiset, obj, attrnames, items) -> None: ...
+ def __reduce__(multiset): ...
+ def distinct(multiset): ...
+ def __nonzero__(multiset): ...
+ def __len__(multiset) -> int: ...
+ def __iter__(multiset): ...
+ def __eq__(multiset, other): ...
+ def __ne__(multiset, other): ...
+ def __contains__(multiset, item) -> bool: ...
+
+class EntityIter:
+ entity: Incomplete
+ def __init__(self, entity) -> None: ...
+ def next(self) -> None: ...
+ __next__ = next
+
+entity_id_counter: itertools.count[int]
+new_instance_id_counter: itertools.count[int]
+select_re: re.Pattern[str]
+lambda_re: re.Pattern[str]
+
+class EntityMeta(type):
+ def __new__(meta, name, bases, cls_dict): ...
+ def __init__(entity, name, bases, cls_dict) -> None: ...
+ def __iter__(entity): ...
+ def __getitem__(entity, key): ...
+ def exists(entity, *args, **kwargs): ...
+ def get(entity, *args, **kwargs): ...
+ def get_for_update(entity, *args, **kwargs): ...
+ def get_by_sql(entity, sql, globals=None, locals=None): ...
+ def select(entity, *args, **kwargs): ...
+ def select_by_sql(entity, sql, globals=None, locals=None): ...
+ def select_random(entity, limit): ...
+ def describe(entity) -> str: ...
+ def drop_table(entity, with_all_data: bool = False) -> None: ...
+
+def populate_criteria_list(
+ criteria_list, columns, converters, operations, params_count: int = 0, table_alias=None, optimistic: bool = False
+) -> int: ...
+
+statuses: set[str]
+del_statuses: set[str]
+created_or_deleted_statuses: set[str]
+saved_statuses: set[str]
+
+def throw_object_was_deleted(obj: Entity) -> NoReturn: ...
+def unpickle_entity(d): ...
+def safe_repr(obj: Entity) -> str: ...
+def make_proxy(obj: Entity) -> EntityProxy: ...
+
+class EntityProxy:
+ def __init__(self, obj: Entity) -> None: ...
+ def __getattr__(self, name: str): ...
+ def __setattr__(self, name: str, value) -> None: ...
+ def __eq__(self, other) -> bool: ...
+ def __ne__(self, other) -> bool: ...
+
+class Entity(metaclass=EntityMeta):
+ __slots__ = (
+ "_session_cache_",
+ "_status_",
+ "_pkval_",
+ "_newid_",
+ "_dbvals_",
+ "_vals_",
+ "_rbits_",
+ "_wbits_",
+ "_save_pos_",
+ "__weakref__",
+ )
+ def __reduce__(obj): ...
+ def __init__(obj, *args, **kwargs) -> None: ...
+ def get_pk(obj): ...
+ def __lt__(entity, other): ...
+ def __le__(entity, other): ...
+ def __gt__(entity, other): ...
+ def __ge__(entity, other): ...
+ def load(obj, *attrs) -> None: ...
+ def delete(obj) -> None: ...
+ def set(obj, **kwargs) -> None: ...
+ def find_updated_attributes(obj): ...
+ def flush(obj) -> None: ...
+ def before_insert(obj) -> None: ...
+ def before_update(obj) -> None: ...
+ def before_delete(obj) -> None: ...
+ def after_insert(obj) -> None: ...
+ def after_update(obj) -> None: ...
+ def after_delete(obj) -> None: ...
+ def to_dict(
+ obj, only=None, exclude=None, with_collections: bool = False, with_lazy: bool = False, related_objects: bool = False
+ ): ...
+ def to_json(obj, include=(), exclude=(), converter=None, with_schema: bool = True, schema_hash=None): ...
+
+def string2ast(s: str) -> ast.Expr: ...
+def get_globals_and_locals(args, kwargs, frame_depth, from_generator=False): ...
+def make_query(args, frame_depth, left_join: bool = False) -> Query: ...
+def select(*args): ...
+def left_join(*args): ...
+def get(*args): ...
+def exists(*args): ...
+def delete(*args): ...
+def make_aggrfunc(std_func): ...
+
+count: Incomplete
+sum: Incomplete
+min: Incomplete
+max: Incomplete
+avg: Incomplete
+group_concat: Incomplete
+distinct: Incomplete
+
+def JOIN(expr: _T) -> _T: ...
+def desc(expr): ...
+def extract_vars(code_key, filter_num, extractors, globals, locals, cells=None): ...
+def unpickle_query(query_result: _T) -> _T: ...
+
+class Query:
+ def __init__(query, code_key, tree, globals, locals, cells=None, left_join: bool = False) -> None: ...
+ def __reduce__(query): ...
+ def get_sql(query): ...
+ def prefetch(query, *args): ...
+ def show(query, width=None, stream=None) -> None: ...
+ def get(query): ...
+ def first(query): ...
+ def without_distinct(query): ...
+ def distinct(query): ...
+ def exists(query): ...
+ def delete(query, bulk=None): ...
+ def __len__(query) -> int: ...
+ def __iter__(query): ...
+ def order_by(query, *args): ...
+ def sort_by(query, *args): ...
+ def filter(query, *args, **kwargs): ...
+ def where(query, *args, **kwargs): ...
+ def __getitem__(query, key): ...
+ def fetch(query, limit=None, offset=None): ...
+ def limit(query, limit=None, offset=None): ...
+ def page(query, pagenum, pagesize: int = 10): ...
+ def sum(query, distinct=None): ...
+ def avg(query, distinct=None): ...
+ def group_concat(query, sep=None, distinct=None): ...
+ def min(query): ...
+ def max(query): ...
+ def count(query, distinct=None): ...
+ def for_update(query, nowait: bool = False, skip_locked: bool = False): ...
+ def random(query, limit): ...
+ def to_json(query, include=(), exclude=(), converter=None, with_schema: bool = True, schema_hash=None): ...
+
+class QueryResultIterator:
+ __slots__ = ("_query_result", "_position")
+ def __init__(self, query_result) -> None: ...
+ def next(self): ...
+ __next__ = next
+ def __length_hint__(self) -> int: ...
+
+def make_query_result_method_error_stub(name: str, title: str | None = None) -> Callable[..., NoReturn]: ...
+
+class QueryResult:
+ __slots__ = ("_query", "_limit", "_offset", "_items", "_expr_type", "_col_names")
+ def __init__(self, query, limit, offset, lazy) -> None: ...
+ def __iter__(self): ...
+ def __len__(self) -> int: ...
+ def __getitem__(self, key): ...
+ def __contains__(self, item) -> bool: ...
+ def index(self, item): ...
+ def __eq__(self, other): ...
+ def __ne__(self, other): ...
+ def __lt__(self, other): ...
+ def __le__(self, other): ...
+ def __gt__(self, other): ...
+ def __ge__(self, other): ...
+ def __reversed__(self): ...
+ def reverse(self) -> None: ...
+ def sort(self, *args, **kwargs) -> None: ...
+ def shuffle(self) -> None: ...
+ def show(self, width=None, stream=None): ...
+ def to_json(self, include=(), exclude=(), converter=None, with_schema: bool = True, schema_hash=None): ...
+ def __add__(self, other): ...
+ def __radd__(self, other): ...
+ def to_list(self): ...
+ __setitem__: Incomplete
+ __delitem__: Incomplete
+ __iadd__: Incomplete
+ __imul__: Incomplete
+ __mul__: Incomplete
+ __rmul__: Incomplete
+ append: Incomplete
+ clear: Incomplete
+ extend: Incomplete
+ insert: Incomplete
+ pop: Incomplete
+ remove: Incomplete
+
+def strcut(s: str, width: int) -> str: ...
+def show(entity) -> None: ...
+
+special_functions: set[Incomplete]
+const_functions: set[type]
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/dbapiprovider.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/dbapiprovider.pyi
new file mode 100644
index 000000000000..ce0c0a5e3eff
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/dbapiprovider.pyi
@@ -0,0 +1,216 @@
+import json
+import re
+import types
+from _typeshed import Incomplete
+from collections.abc import Iterable
+from typing import ClassVar
+
+from pony.utils import localbase
+
+class DBException(Exception):
+ def __init__(exc, original_exc, *args) -> None: ...
+
+class Warning(DBException): ...
+class Error(DBException): ...
+class InterfaceError(Error): ...
+class DatabaseError(Error): ...
+class DataError(DatabaseError): ...
+class OperationalError(DatabaseError): ...
+class IntegrityError(DatabaseError): ...
+class InternalError(DatabaseError): ...
+class ProgrammingError(DatabaseError): ...
+class NotSupportedError(DatabaseError): ...
+
+def wrap_dbapi_exceptions(func, provider, *args, **kwargs): ...
+def unexpected_args(attr, args) -> None: ...
+
+version_re: re.Pattern[str]
+
+def get_version_tuple(s: str): ...
+
+class DBAPIProvider:
+ paramstyle: ClassVar[str]
+ quote_char: ClassVar[str]
+ max_params_count: ClassVar[int]
+ max_name_len: ClassVar[int]
+ table_if_not_exists_syntax: ClassVar[bool]
+ index_if_not_exists_syntax: ClassVar[bool]
+ max_time_precision: ClassVar[int]
+ default_time_precision: ClassVar[int]
+ uint64_support: ClassVar[bool]
+ varchar_default_max_len: ClassVar[int | None]
+ dialect: ClassVar[str | None]
+ dbapi_module: ClassVar[types.ModuleType | None]
+ dbschema_cls: ClassVar[type | None]
+ translator_cls: ClassVar[type | None]
+ sqlbuilder_cls: ClassVar[type | None]
+ array_converter_cls: ClassVar[type | None]
+ name_before_table: ClassVar[str]
+ default_schema_name: ClassVar[str | None]
+ fk_types: ClassVar[dict[str, str]]
+ converter_classes: Incomplete
+ def __init__(provider, _database, *args, **kwargs) -> None: ...
+ def inspect_connection(provider, connection) -> None: ...
+ def normalize_name(provider, name): ...
+ def get_default_entity_table_name(provider, entity): ...
+ def get_default_m2m_table_name(provider, attr, reverse): ...
+ def get_default_column_names(provider, attr, reverse_pk_columns=None): ...
+ def get_default_m2m_column_names(provider, entity): ...
+ def get_default_index_name(
+ provider, table_name, column_names, is_pk: bool = False, is_unique: bool = False, m2m: bool = False
+ ): ...
+ def get_default_fk_name(provider, child_table_name, parent_table_name, child_column_names): ...
+ def split_table_name(provider, table_name): ...
+ def base_name(provider, name): ...
+ def quote_name(provider, name: str | Iterable[str]) -> str: ...
+ def format_table_name(provider, name): ...
+ def normalize_vars(provider, vars, vartypes) -> None: ...
+ def ast2sql(provider, ast): ...
+ def should_reconnect(provider, exc): ...
+ def connect(provider): ...
+ def set_transaction_mode(provider, connection, cache) -> None: ...
+ def commit(provider, connection, cache=None) -> None: ...
+ def rollback(provider, connection, cache=None) -> None: ...
+ def release(provider, connection, cache=None) -> None: ...
+ def drop(provider, connection, cache=None) -> None: ...
+ def disconnect(provider) -> None: ...
+ def execute(provider, cursor, sql, arguments=None, returning_id: bool = False): ...
+ def get_converter_by_py_type(provider, py_type): ...
+ def get_converter_by_attr(provider, attr): ...
+ def get_pool(provider, *args, **kwargs): ...
+ def table_exists(provider, connection, table_name, case_sensitive: bool = True) -> None: ...
+ def index_exists(provider, connection, table_name, index_name, case_sensitive: bool = True) -> None: ...
+ def fk_exists(provider, connection, table_name, fk_name, case_sensitive: bool = True) -> None: ...
+ def table_has_data(provider, connection, table_name): ...
+ def disable_fk_checks(provider, connection) -> None: ...
+ def enable_fk_checks(provider, connection, prev_state) -> None: ...
+ def drop_table(provider, connection, table_name) -> None: ...
+
+class Pool(localbase):
+ forked_connections: list[tuple[Incomplete, int | None]]
+ dbapi_module: types.ModuleType
+ args: tuple[Incomplete, ...]
+ kwargs: dict[str, Incomplete]
+ con: Incomplete
+ pid: int | None
+ def __init__(pool, dbapi_module: types.ModuleType, *args, **kwargs) -> None: ...
+ def connect(pool) -> tuple[Incomplete, bool]: ...
+ def release(pool, con) -> None: ...
+ def drop(pool, con) -> None: ...
+ def disconnect(pool) -> None: ...
+
+class Converter:
+ EQ: str
+ NE: str
+ optimistic: bool
+ def __deepcopy__(converter, memo): ...
+ def __init__(converter, provider, py_type, attr=None) -> None: ...
+ def init(converter, kwargs) -> None: ...
+ def validate(converter, val, obj=None): ...
+ def py2sql(converter, val): ...
+ def sql2py(converter, val): ...
+ def val2dbval(self, val, obj=None): ...
+ def dbval2val(self, dbval, obj=None): ...
+ def dbvals_equal(self, x, y): ...
+ def get_sql_type(converter, attr=None): ...
+ def get_fk_type(converter, sql_type): ...
+
+class NoneConverter(Converter):
+ def __init__(converter, provider, py_type, attr=None) -> None: ...
+ def get_sql_type(converter, attr=None) -> None: ...
+ def get_fk_type(converter, sql_type) -> None: ...
+
+class BoolConverter(Converter):
+ def validate(converter, val, obj=None): ...
+ def sql2py(converter, val): ...
+ def sql_type(converter): ...
+
+class StrConverter(Converter):
+ def __init__(converter, provider, py_type, attr=None) -> None: ...
+ def init(converter, kwargs) -> None: ...
+ def validate(converter, val, obj=None): ...
+ def sql_type(converter): ...
+
+class IntConverter(Converter):
+ signed_types: Incomplete
+ unsigned_types: Incomplete
+ def init(converter, kwargs) -> None: ...
+ def validate(converter, val, obj=None): ...
+ def sql2py(converter, val): ...
+ def sql_type(converter): ...
+
+class RealConverter(Converter):
+ EQ: str
+ NE: str
+ default_tolerance: float
+ optimistic: bool
+ def init(converter, kwargs) -> None: ...
+ def validate(converter, val, obj=None): ...
+ def dbvals_equal(converter, x, y): ...
+ def sql2py(converter, val): ...
+ def sql_type(converter): ...
+
+class DecimalConverter(Converter):
+ def __init__(converter, provider, py_type, attr=None) -> None: ...
+ def init(converter, kwargs) -> None: ...
+ def validate(converter, val, obj=None): ...
+ def sql2py(converter, val): ...
+ def sql_type(converter): ...
+
+class BlobConverter(Converter):
+ def validate(converter, val, obj=None): ...
+ def sql2py(converter, val): ...
+ def sql_type(converter): ...
+
+class DateConverter(Converter):
+ def validate(converter, val, obj=None): ...
+ def sql2py(converter, val): ...
+ def sql_type(converter): ...
+
+class ConverterWithMicroseconds(Converter):
+ def __init__(converter, provider, py_type, attr=None) -> None: ...
+ def init(converter, kwargs) -> None: ...
+ def round_microseconds_to_precision(converter, microseconds, precision): ...
+ def sql_type(converter): ...
+
+class TimeConverter(ConverterWithMicroseconds):
+ sql_type_name: ClassVar[str]
+ def validate(converter, val, obj=None): ...
+ def sql2py(converter, val): ...
+
+class TimedeltaConverter(ConverterWithMicroseconds):
+ sql_type_name: ClassVar[str]
+ def validate(converter, val, obj=None): ...
+ def sql2py(converter, val): ...
+
+class DatetimeConverter(ConverterWithMicroseconds):
+ sql_type_name: ClassVar[str]
+ def validate(converter, val, obj=None): ...
+ def sql2py(converter, val): ...
+
+class UuidConverter(Converter):
+ def __init__(converter, provider, py_type, attr=None) -> None: ...
+ def validate(converter, val, obj=None): ...
+ def py2sql(converter, val): ...
+ sql2py = validate
+ def sql_type(converter): ...
+
+class JsonConverter(Converter):
+ json_kwargs: Incomplete
+
+ class JsonEncoder(json.JSONEncoder):
+ def default(converter, obj): ...
+
+ def validate(converter, val, obj=None): ...
+ def val2dbval(converter, val, obj=None): ...
+ def dbval2val(converter, dbval, obj=None): ...
+ def dbvals_equal(converter, x, y): ...
+ def sql_type(converter): ...
+
+class ArrayConverter(Converter):
+ array_types: Incomplete
+ def __init__(converter, provider, py_type, attr=None) -> None: ...
+ def validate(converter, val, obj=None): ...
+ def dbval2val(converter, dbval, obj=None): ...
+ def val2dbval(converter, val, obj=None): ...
+ def sql_type(converter): ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/dbproviders/__init__.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/dbproviders/__init__.pyi
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/dbproviders/cockroach.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/dbproviders/cockroach.pyi
new file mode 100644
index 000000000000..2a3cfa5c7a2d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/dbproviders/cockroach.pyi
@@ -0,0 +1,49 @@
+from _typeshed import Incomplete
+from typing import ClassVar
+
+from pony.orm import dbapiprovider
+from pony.orm.dbproviders.postgres import (
+ PGArrayConverter,
+ PGBlobConverter,
+ PGColumn,
+ PGIntConverter,
+ PGProvider,
+ PGSchema,
+ PGSQLBuilder,
+ PGTimedeltaConverter,
+ PGTranslator,
+)
+
+NoneType: type[None]
+
+class CRColumn(PGColumn):
+ auto_template: ClassVar[str]
+
+class CRSchema(PGSchema):
+ column_class: ClassVar[type[CRColumn]]
+
+class CRTranslator(PGTranslator): ...
+class CRSQLBuilder(PGSQLBuilder): ...
+
+class CRIntConverter(PGIntConverter):
+ signed_types: Incomplete
+ unsigned_types: Incomplete
+
+class CRBlobConverter(PGBlobConverter):
+ def sql_type(converter): ...
+
+class CRTimedeltaConverter(PGTimedeltaConverter): ...
+
+class PGUuidConverter(dbapiprovider.UuidConverter):
+ def py2sql(converter, val): ...
+
+class CRArrayConverter(PGArrayConverter):
+ array_types: Incomplete
+
+class CRProvider(PGProvider):
+ dbschema_cls: ClassVar[type[CRSchema]]
+ translator_cls: ClassVar[type[CRTranslator]]
+ sqlbuilder_cls: ClassVar[type[CRSQLBuilder]]
+ array_converter_cls: ClassVar[type[CRArrayConverter]]
+
+provider_cls = CRProvider
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/dbproviders/mysql.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/dbproviders/mysql.pyi
new file mode 100644
index 000000000000..79e9dbc4ed09
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/dbproviders/mysql.pyi
@@ -0,0 +1,102 @@
+import types
+from _typeshed import Incomplete
+from typing import ClassVar
+
+from pony.orm import dbapiprovider, dbschema
+from pony.orm.dbapiprovider import DBAPIProvider
+from pony.orm.sqlbuilding import SQLBuilder, Value
+from pony.orm.sqltranslation import SQLTranslator
+
+NoneType: type[None]
+mysql_module_name: str
+
+class MySQLColumn(dbschema.Column):
+ auto_template: ClassVar[str]
+
+class MySQLSchema(dbschema.DBSchema):
+ dialect: ClassVar[str]
+ column_class: ClassVar[type[MySQLColumn]]
+
+class MySQLTranslator(SQLTranslator):
+ dialect: ClassVar[str]
+
+class MySQLValue(Value):
+ __slots__: list[str] = []
+
+class MySQLBuilder(SQLBuilder):
+ dialect: ClassVar[str]
+ value_class: ClassVar[type[MySQLValue]]
+ def CONCAT(builder, *args): ...
+ def TRIM(builder, expr, chars=None): ...
+ def LTRIM(builder, expr, chars=None): ...
+ def RTRIM(builder, expr, chars=None): ...
+ def TO_INT(builder, expr): ...
+ def TO_REAL(builder, expr): ...
+ def TO_STR(builder, expr): ...
+ def YEAR(builder, expr): ...
+ def MONTH(builder, expr): ...
+ def DAY(builder, expr): ...
+ def HOUR(builder, expr): ...
+ def MINUTE(builder, expr): ...
+ def SECOND(builder, expr): ...
+ def DATE_ADD(builder, expr, delta): ...
+ def DATE_SUB(builder, expr, delta): ...
+ def DATE_DIFF(builder, expr1, expr2): ...
+ def DATETIME_ADD(builder, expr, delta): ...
+ def DATETIME_SUB(builder, expr, delta): ...
+ def DATETIME_DIFF(builder, expr1, expr2): ...
+ def JSON_QUERY(builder, expr, path): ...
+ def JSON_VALUE(builder, expr, path, type): ...
+ def JSON_NONZERO(builder, expr): ...
+ def JSON_ARRAY_LENGTH(builder, value): ...
+ def JSON_EQ(builder, left, right): ...
+ def JSON_NE(builder, left, right): ...
+ def JSON_CONTAINS(builder, expr, path, key): ...
+ @classmethod
+ def wrap_param_to_json_array(cls, values): ...
+ def JSON_PARAM(builder, expr): ...
+
+class MySQLStrConverter(dbapiprovider.StrConverter):
+ def sql_type(converter): ...
+
+class MySQLRealConverter(dbapiprovider.RealConverter):
+ def sql_type(converter): ...
+
+class MySQLBlobConverter(dbapiprovider.BlobConverter):
+ def sql_type(converter): ...
+
+class MySQLTimeConverter(dbapiprovider.TimeConverter):
+ def sql2py(converter, val): ...
+
+class MySQLTimedeltaConverter(dbapiprovider.TimedeltaConverter): ...
+
+class MySQLUuidConverter(dbapiprovider.UuidConverter):
+ def sql_type(converter): ...
+
+class MySQLJsonConverter(dbapiprovider.JsonConverter):
+ EQ: str
+ NE: str
+ def init(self, kwargs) -> None: ...
+
+class MySQLProvider(DBAPIProvider):
+ dialect: ClassVar[str]
+ varchar_default_max_len: ClassVar[int]
+ dbapi_module: ClassVar[types.ModuleType]
+ dbschema_cls: ClassVar[type[MySQLSchema]]
+ translator_cls: ClassVar[type[MySQLTranslator]]
+ sqlbuilder_cls: ClassVar[type[MySQLBuilder]]
+ fk_types: ClassVar[dict[str, str]]
+ converter_classes: Incomplete
+ def normalize_name(provider, name): ...
+ def inspect_connection(provider, connection) -> None: ...
+ def should_reconnect(provider, exc): ...
+ def get_pool(provider, *args, **kwargs): ...
+ def set_transaction_mode(provider, connection, cache) -> None: ...
+ def release(provider, connection, cache=None) -> None: ...
+ def table_exists(provider, connection, table_name, case_sensitive: bool = True): ...
+ def index_exists(provider, connection, table_name, index_name, case_sensitive: bool = True): ...
+ def fk_exists(provider, connection, table_name, fk_name, case_sensitive: bool = True): ...
+
+provider_cls = MySQLProvider
+
+def str2datetime(s): ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/dbproviders/oracle.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/dbproviders/oracle.pyi
new file mode 100644
index 000000000000..220e58f4099d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/dbproviders/oracle.pyi
@@ -0,0 +1,159 @@
+import re
+from _typeshed import Incomplete
+from typing import ClassVar
+
+from pony.orm import dbapiprovider, sqltranslation
+from pony.orm.dbapiprovider import DBAPIProvider
+from pony.orm.dbschema import Column, DBObject, DBSchema, Table
+from pony.orm.sqlbuilding import SQLBuilder
+
+NoneType: type[None]
+
+class OraTable(Table):
+ def get_objects_to_create(table, created_tables=None): ...
+
+class OraSequence(DBObject):
+ typename: ClassVar[str]
+ def __init__(sequence, table, name=None) -> None: ...
+ def exists(sequence, provider, connection, case_sensitive: bool = True): ...
+ def get_create_command(sequence): ...
+
+trigger_template: str
+
+class OraTrigger(DBObject):
+ typename: ClassVar[str]
+ def __init__(trigger, table, column, sequence) -> None: ...
+ def exists(trigger, provider, connection, case_sensitive: bool = True): ...
+ def get_create_command(trigger): ...
+
+class OraColumn(Column):
+ auto_template: ClassVar[None] # type: ignore[assignment]
+
+class OraSchema(DBSchema):
+ dialect: ClassVar[str]
+ table_class: ClassVar[type[OraTable]]
+ column_class: ClassVar[type[OraColumn]]
+
+class OraNoneMonad(sqltranslation.NoneMonad):
+ def __init__(monad, value=None) -> None: ...
+
+class OraConstMonad(sqltranslation.ConstMonad):
+ @staticmethod
+ def new(value): ...
+
+class OraTranslator(sqltranslation.SQLTranslator):
+ dialect: ClassVar[str]
+ NoneMonad = OraNoneMonad
+ ConstMonad = OraConstMonad
+
+class OraBuilder(SQLBuilder):
+ dialect: ClassVar[str]
+ def INSERT(builder, table_name, columns, values, returning=None): ...
+ def SELECT_FOR_UPDATE(builder, nowait, skip_locked, *sections): ...
+ def SELECT(builder, *sections): ...
+ def ROWID(builder, *expr_list): ...
+ def LIMIT(builder, limit, offset=None) -> None: ...
+ def TO_REAL(builder, expr): ...
+ def TO_STR(builder, expr): ...
+ def DATE(builder, expr): ...
+ def RANDOM(builder): ...
+ def MOD(builder, a, b): ...
+ def DATE_ADD(builder, expr, delta): ...
+ def DATE_SUB(builder, expr, delta): ...
+ def DATE_DIFF(builder, expr1, expr2): ...
+ def DATETIME_ADD(builder, expr, delta): ...
+ def DATETIME_SUB(builder, expr, delta): ...
+ def DATETIME_DIFF(builder, expr1, expr2): ...
+ def build_json_path(builder, path): ...
+ def JSON_QUERY(builder, expr, path): ...
+ json_value_type_mapping: Incomplete
+ def JSON_VALUE(builder, expr, path, type): ...
+ def JSON_NONZERO(builder, expr): ...
+ def JSON_CONTAINS(builder, expr, path, key): ...
+ def JSON_ARRAY_LENGTH(builder, value) -> None: ...
+ def GROUP_CONCAT(builder, distinct, expr, sep=None): ...
+
+json_item_re: re.Pattern[str]
+
+class OraBoolConverter(dbapiprovider.BoolConverter):
+ def py2sql(converter, val): ...
+ def sql2py(converter, val): ...
+ def sql_type(converter): ...
+
+class OraStrConverter(dbapiprovider.StrConverter):
+ def validate(converter, val, obj=None): ...
+ def sql2py(converter, val): ...
+ def sql_type(converter): ...
+
+class OraIntConverter(dbapiprovider.IntConverter):
+ signed_types: Incomplete
+ unsigned_types: Incomplete
+ def init(self, kwargs) -> None: ...
+
+class OraRealConverter(dbapiprovider.RealConverter):
+ def sql_type(converter): ...
+
+class OraDecimalConverter(dbapiprovider.DecimalConverter):
+ def sql_type(converter): ...
+
+class OraBlobConverter(dbapiprovider.BlobConverter):
+ def sql2py(converter, val): ...
+
+class OraDateConverter(dbapiprovider.DateConverter):
+ def sql2py(converter, val): ...
+
+class OraTimeConverter(dbapiprovider.TimeConverter):
+ def __init__(converter, provider, py_type, attr=None) -> None: ...
+ def sql2py(converter, val): ...
+ def py2sql(converter, val): ...
+
+class OraTimedeltaConverter(dbapiprovider.TimedeltaConverter):
+ def __init__(converter, provider, py_type, attr=None) -> None: ...
+
+class OraDatetimeConverter(dbapiprovider.DatetimeConverter): ...
+
+class OraUuidConverter(dbapiprovider.UuidConverter):
+ def sql_type(converter): ...
+
+class OraJsonConverter(dbapiprovider.JsonConverter):
+ json_kwargs: Incomplete
+ optimistic: bool
+ def sql2py(converter, dbval): ...
+ def sql_type(converter): ...
+
+class OraProvider(DBAPIProvider):
+ dialect: ClassVar[str]
+ varchar_default_max_len: ClassVar[int]
+ dbschema_cls: ClassVar[type[OraSchema]]
+ translator_cls: ClassVar[type[OraTranslator]]
+ sqlbuilder_cls: ClassVar[type[OraBuilder]]
+ converter_classes: Incomplete
+ def inspect_connection(provider, connection) -> None: ...
+ def should_reconnect(provider, exc): ...
+ def normalize_name(provider, name): ...
+ def normalize_vars(provider, vars, vartypes) -> None: ...
+ def set_transaction_mode(provider, connection, cache) -> None: ...
+ def execute(provider, cursor, sql, arguments=None, returning_id: bool = False): ...
+ def get_pool(provider, *args, **kwargs): ...
+ def table_exists(provider, connection, table_name, case_sensitive: bool = True): ...
+ def index_exists(provider, connection, table_name, index_name, case_sensitive: bool = True): ...
+ def fk_exists(provider, connection, table_name, fk_name, case_sensitive: bool = True): ...
+ def table_has_data(provider, connection, table_name): ...
+ def drop_table(provider, connection, table_name) -> None: ...
+
+provider_cls = OraProvider
+
+def to_int_or_decimal(val): ...
+def to_decimal(val): ...
+def output_type_handler(cursor, name, defaultType, size, precision, scale): ...
+
+class OraPool:
+ forked_pools: Incomplete
+ def __init__(pool, **kwargs) -> None: ...
+ def connect(pool): ...
+ def release(pool, con) -> None: ...
+ def drop(pool, con) -> None: ...
+ def disconnect(pool) -> None: ...
+
+def get_inputsize(arg): ...
+def set_input_sizes(cursor, arguments) -> None: ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/dbproviders/postgres.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/dbproviders/postgres.pyi
new file mode 100644
index 000000000000..f3aef861eebe
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/dbproviders/postgres.pyi
@@ -0,0 +1,105 @@
+import types
+from _typeshed import Incomplete
+from collections.abc import Iterable
+from typing import ClassVar
+
+from pony.orm import dbapiprovider, dbschema
+from pony.orm.dbapiprovider import DBAPIProvider, Pool
+from pony.orm.sqlbuilding import SQLBuilder, Value
+from pony.orm.sqltranslation import SQLTranslator
+from psycopg2._psycopg import _Connection
+
+NoneType: type[None]
+
+class PGColumn(dbschema.Column):
+ auto_template: ClassVar[str]
+
+class PGSchema(dbschema.DBSchema):
+ dialect: ClassVar[str]
+ column_class: ClassVar[type[PGColumn]]
+
+class PGTranslator(SQLTranslator):
+ dialect: ClassVar[str]
+
+class PGValue(Value): ...
+
+class PGSQLBuilder(SQLBuilder):
+ dialect: ClassVar[str]
+ value_class: ClassVar[type[PGValue]]
+ def INSERT(builder, table_name, columns, values, returning=None): ...
+ def TO_INT(builder, expr): ...
+ def TO_STR(builder, expr): ...
+ def TO_REAL(builder, expr): ...
+ def DATE(builder, expr): ...
+ def RANDOM(builder): ...
+ def DATE_ADD(builder, expr, delta): ...
+ def DATE_SUB(builder, expr, delta): ...
+ def DATE_DIFF(builder, expr1, expr2): ...
+ def DATETIME_ADD(builder, expr, delta): ...
+ def DATETIME_SUB(builder, expr, delta): ...
+ def DATETIME_DIFF(builder, expr1, expr2): ...
+ def eval_json_path(builder, values: Iterable[int | str]) -> str: ... # type: ignore[override]
+ def JSON_QUERY(builder, expr, path): ...
+ json_value_type_mapping: dict[type, str]
+ def JSON_VALUE(builder, expr, path, type): ...
+ def JSON_NONZERO(builder, expr): ...
+ def JSON_CONCAT(builder, left, right): ...
+ def JSON_CONTAINS(builder, expr, path, key): ...
+ def JSON_ARRAY_LENGTH(builder, value): ...
+ def GROUP_CONCAT(builder, distinct, expr, sep=None): ...
+ def ARRAY_INDEX(builder, col, index): ...
+ def ARRAY_CONTAINS(builder, key, not_in, col): ...
+ def ARRAY_SUBSET(builder, array1, not_in, array2): ...
+ def ARRAY_LENGTH(builder, array): ...
+ def ARRAY_SLICE(builder, array, start, stop): ...
+ def MAKE_ARRAY(builder, *items): ...
+
+class PGIntConverter(dbapiprovider.IntConverter):
+ signed_types: Incomplete
+ unsigned_types: Incomplete
+
+class PGRealConverter(dbapiprovider.RealConverter):
+ def sql_type(converter): ...
+
+class PGBlobConverter(dbapiprovider.BlobConverter):
+ def sql_type(converter): ...
+
+class PGTimedeltaConverter(dbapiprovider.TimedeltaConverter): ...
+class PGDatetimeConverter(dbapiprovider.DatetimeConverter): ...
+
+class PGUuidConverter(dbapiprovider.UuidConverter):
+ def py2sql(converter, val): ...
+
+class PGJsonConverter(dbapiprovider.JsonConverter):
+ def sql_type(self): ...
+
+class PGArrayConverter(dbapiprovider.ArrayConverter):
+ array_types: dict[type, tuple[str, type]]
+
+class PGPool(Pool):
+ def release(pool, con) -> None: ...
+
+ADMIN_SHUTDOWN: str
+
+class PGProvider(DBAPIProvider):
+ dialect: ClassVar[str]
+ dbapi_module: ClassVar[types.ModuleType]
+ dbschema_cls: ClassVar[type[PGSchema]]
+ translator_cls: ClassVar[type[PGTranslator]]
+ sqlbuilder_cls: ClassVar[type[PGSQLBuilder]]
+ array_converter_cls: ClassVar[type[PGArrayConverter]]
+ default_schema_name: ClassVar[str]
+ fk_types: ClassVar[dict[str, str]]
+ converter_classes: list[tuple[type | tuple[type], type]]
+ def normalize_name(provider, name: str) -> str: ...
+ def inspect_connection(provider, connection: _Connection) -> None: ...
+ def should_reconnect(provider, exc: BaseException | None) -> bool: ...
+ def get_pool(provider, *args, **kwargs) -> PGPool: ...
+ def set_transaction_mode(provider, connection: _Connection, cache) -> None: ...
+ def execute(provider, cursor, sql, arguments=None, returning_id: bool = False): ...
+ def table_exists(provider, connection: _Connection, table_name: str, case_sensitive: bool = True): ...
+ def index_exists(provider, connection: _Connection, table_name: str, index_name, case_sensitive: bool = True): ...
+ def fk_exists(provider, connection: _Connection, table_name: str, fk_name, case_sensitive: bool = True): ...
+ def drop_table(provider, connection: _Connection, table_name: str) -> None: ...
+
+provider_cls = PGProvider
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/dbproviders/sqlite.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/dbproviders/sqlite.pyi
new file mode 100644
index 000000000000..89f8baa53f73
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/dbproviders/sqlite.pyi
@@ -0,0 +1,220 @@
+import re
+import sys
+import types
+from _typeshed import Incomplete, StrOrBytesPath
+from sqlite3 import Connection as _Connection
+from typing import Any, ClassVar, overload
+
+from pony.orm import dbapiprovider, dbschema
+from pony.orm.dbapiprovider import DBAPIProvider, Pool
+from pony.orm.sqlbuilding import SQLBuilder, Value
+from pony.orm.sqltranslation import SQLTranslator
+from pony.utils import localbase
+
+class SqliteExtensionUnavailable(Exception): ...
+
+NoneType: type[None]
+
+class SQLiteForeignKey(dbschema.ForeignKey):
+ def get_create_command(foreign_key) -> None: ...
+
+class SQLiteSchema(dbschema.DBSchema):
+ dialect: ClassVar[str]
+ fk_class: ClassVar[type[SQLiteForeignKey]]
+
+def make_overriden_string_func(sqlop): ...
+
+class SQLiteTranslator(SQLTranslator):
+ dialect: ClassVar[str]
+ sqlite_version: tuple[int, int, int]
+ StringMixin_UPPER: Incomplete
+ StringMixin_LOWER: Incomplete
+
+class SQLiteValue(Value):
+ __slots__: list[str] = []
+
+class SQLiteBuilder(SQLBuilder):
+ dialect: ClassVar[str]
+ least_func_name: ClassVar[str]
+ greatest_func_name: ClassVar[str]
+ value_class: ClassVar[type[SQLiteValue]]
+ def __init__(builder, provider, ast) -> None: ...
+ def SELECT_FOR_UPDATE(builder, nowait, skip_locked, *sections): ...
+ def INSERT(builder, table_name, columns, values, returning=None): ...
+ def STRING_SLICE(builder, expr, start, stop): ...
+ def IN(builder, expr1, x): ...
+ def NOT_IN(builder, expr1, x): ...
+ def TODAY(builder): ...
+ def NOW(builder): ...
+ def YEAR(builder, expr): ...
+ def MONTH(builder, expr): ...
+ def DAY(builder, expr): ...
+ def HOUR(builder, expr): ...
+ def MINUTE(builder, expr): ...
+ def SECOND(builder, expr): ...
+ def datetime_add(builder, funcname, expr, td): ...
+ def DATE_ADD(builder, expr, delta): ...
+ def DATE_SUB(builder, expr, delta): ...
+ def DATE_DIFF(builder, expr1, expr2): ...
+ def DATETIME_ADD(builder, expr, delta): ...
+ def DATETIME_SUB(builder, expr, delta): ...
+ def DATETIME_DIFF(builder, expr1, expr2): ...
+ def RANDOM(builder): ...
+ PY_UPPER: Incomplete
+ PY_LOWER: Incomplete
+ def FLOAT_EQ(builder, a, b): ...
+ def FLOAT_NE(builder, a, b): ...
+ def JSON_QUERY(builder, expr, path): ...
+ json_value_type_mapping: Incomplete
+ def JSON_VALUE(builder, expr, path, type): ...
+ def JSON_NONZERO(builder, expr): ...
+ def JSON_ARRAY_LENGTH(builder, value): ...
+ def JSON_CONTAINS(builder, expr, path, key): ...
+ def ARRAY_INDEX(builder, col, index): ...
+ def ARRAY_CONTAINS(builder, key, not_in, col): ...
+ def ARRAY_SUBSET(builder, array1, not_in, array2): ...
+ def ARRAY_LENGTH(builder, array): ...
+ def ARRAY_SLICE(builder, array, start, stop): ...
+ def MAKE_ARRAY(builder, *items): ...
+
+class SQLiteIntConverter(dbapiprovider.IntConverter):
+ def sql_type(converter): ...
+
+class SQLiteDecimalConverter(dbapiprovider.DecimalConverter):
+ inf: Incomplete
+ neg_inf: Incomplete
+ NaN: Incomplete
+ def sql2py(converter, val): ...
+ def py2sql(converter, val): ...
+
+class SQLiteDateConverter(dbapiprovider.DateConverter):
+ def sql2py(converter, val): ...
+ def py2sql(converter, val): ...
+
+class SQLiteTimeConverter(dbapiprovider.TimeConverter):
+ def sql2py(converter, val): ...
+ def py2sql(converter, val): ...
+
+class SQLiteTimedeltaConverter(dbapiprovider.TimedeltaConverter):
+ def sql2py(converter, val): ...
+ def py2sql(converter, val): ...
+
+class SQLiteDatetimeConverter(dbapiprovider.DatetimeConverter):
+ def sql2py(converter, val): ...
+ def py2sql(converter, val): ...
+
+class SQLiteJsonConverter(dbapiprovider.JsonConverter):
+ json_kwargs: Incomplete
+
+def dumps(items): ...
+
+class SQLiteArrayConverter(dbapiprovider.ArrayConverter):
+ array_types: Incomplete
+ def dbval2val(converter, dbval, obj=None): ...
+ def val2dbval(converter, val, obj=None): ...
+
+class LocalExceptions(localbase):
+ exc_info: Incomplete
+ keep_traceback: bool
+ def __init__(self) -> None: ...
+
+local_exceptions: LocalExceptions
+
+def keep_exception(func): ...
+
+class SQLiteProvider(DBAPIProvider):
+ dialect: ClassVar[str]
+ local_exceptions: LocalExceptions
+ dbapi_module: ClassVar[types.ModuleType]
+ dbschema_cls: ClassVar[type[SQLiteSchema]]
+ translator_cls: ClassVar[type[SQLiteTranslator]]
+ sqlbuilder_cls: ClassVar[type[SQLiteBuilder]]
+ array_converter_cls: ClassVar[type[SQLiteArrayConverter]]
+ server_version: tuple[int, int, int]
+ converter_classes: Incomplete
+ def __init__(provider, database, filename, **kwargs) -> None: ...
+ def inspect_connection(provider, conn) -> None: ...
+ def restore_exception(provider) -> None: ...
+ def acquire_lock(provider) -> None: ...
+ def release_lock(provider) -> None: ...
+ def set_transaction_mode(provider, connection: _Connection, cache) -> None: ...
+ def commit(provider, connection: _Connection, cache=None) -> None: ...
+ def rollback(provider, connection: _Connection, cache=None) -> None: ...
+ def drop(provider, connection: _Connection, cache=None) -> None: ...
+ def release(provider, connection: _Connection, cache=None) -> None: ...
+ def get_pool(provider, is_shared_memory_db, filename, create_db: bool = False, **kwargs): ...
+ def table_exists(provider, connection: _Connection, table_name: str, case_sensitive: bool = True): ...
+ def index_exists(provider, connection: _Connection, table_name: str, index_name, case_sensitive: bool = True): ...
+ def fk_exists(provider, connection: _Connection, table_name: str, fk_name) -> None: ... # type: ignore[override]
+ def check_json1(provider, connection: _Connection) -> bool: ...
+
+provider_cls = SQLiteProvider
+
+def make_string_function(name, base_func): ...
+
+py_upper: Incomplete
+py_lower: Incomplete
+
+@overload
+def py_json_unwrap(value: str) -> str | None: ...
+@overload
+def py_json_unwrap(value: Any) -> None: ...
+
+path_cache: Incomplete
+json_path_re: re.Pattern[str]
+
+def py_json_extract(expr, *paths): ...
+def py_json_query(expr, path, with_wrapper): ...
+def py_json_value(expr, path): ...
+def py_json_contains(expr, path, key): ...
+def py_json_nonzero(expr, path): ...
+def py_json_array_length(expr, path=None): ...
+def wrap_array_func(func): ...
+def py_array_index(array, index): ...
+def py_array_contains(array, item): ...
+def py_array_subset(array, items): ...
+def py_array_length(array): ...
+def py_array_slice(array, start, stop): ...
+def py_make_array(*items): ...
+@overload
+def py_string_slice(s: None, start: str | int | None, end: str | int | None) -> None: ...
+@overload
+def py_string_slice(s: str, start: str | int | None, end: str | int | None) -> str: ...
+
+class SQLitePool(Pool):
+ is_shared_memory_db: bool | None
+ filename: StrOrBytesPath
+ create_db: bool | None
+ kwargs: dict[str, Incomplete]
+ if sys.version_info >= (3, 12):
+ def __init__(
+ pool,
+ is_shared_memory_db: bool | None,
+ filename: StrOrBytesPath,
+ create_db: bool | None,
+ *,
+ timeout: float = 5.0,
+ detect_types: int = 0,
+ check_same_thread: bool = True,
+ factory: type[_Connection],
+ cached_statements: int = 128,
+ uri: bool = False,
+ autocommit: bool = ...,
+ ) -> None: ...
+ else:
+ def __init__(
+ pool,
+ is_shared_memory_db: bool | None,
+ filename: StrOrBytesPath,
+ create_db: bool | None,
+ *,
+ timeout: float = 5.0,
+ detect_types: int = 0,
+ check_same_thread: bool = True,
+ factory: type[_Connection],
+ cached_statements: int = 128,
+ uri: bool = False,
+ ) -> None: ...
+
+ def disconnect(pool) -> None: ...
+ def drop(pool, con: _Connection) -> None: ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/dbschema.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/dbschema.pyi
new file mode 100644
index 000000000000..686ca5f2dc7e
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/dbschema.pyi
@@ -0,0 +1,86 @@
+from _typeshed import Incomplete
+from typing import ClassVar
+
+from pony.orm.dbapiprovider import DBAPIProvider
+
+class DBSchema:
+ dialect: ClassVar[str | None]
+ inline_fk_syntax: ClassVar[bool]
+ named_foreign_keys: ClassVar[bool]
+ table_class: ClassVar[type[Table]]
+ column_class: ClassVar[type[Column]]
+ index_class: ClassVar[type[DBIndex]]
+ fk_class: ClassVar[type[ForeignKey]]
+ provider: DBAPIProvider
+ tables: dict[Incomplete, Incomplete]
+ constraints: dict[Incomplete, Incomplete]
+ indent: str
+ command_separator: str
+ uppercase: bool
+ names: dict[Incomplete, Incomplete]
+ def __init__(schema, provider: DBAPIProvider, uppercase: bool = True) -> None: ...
+ def column_list(schema, columns): ...
+ def case(schema, s: str) -> str: ...
+ def add_table(schema, table_name, entity=None): ...
+ def order_tables_to_create(schema): ...
+ def generate_create_script(schema): ...
+ def create_tables(schema, provider: DBAPIProvider, connection) -> None: ...
+ def check_tables(schema, provider: DBAPIProvider, connection) -> None: ...
+
+class DBObject:
+ def create(table, provider, connection) -> None: ...
+
+class Table(DBObject):
+ typename: ClassVar[str]
+ def __init__(table, name, schema, entity=None) -> None: ...
+ def add_entity(table, entity) -> None: ...
+ def exists(table, provider: DBAPIProvider, connection, case_sensitive: bool = True): ...
+ def get_create_command(table): ...
+ def format_option(table, name, value): ...
+ def get_objects_to_create(table, created_tables: set[Table] | None = None) -> list[Table]: ...
+ def add_column(table, column_name, sql_type, converter, is_not_null: bool | None = None, sql_default=None): ...
+ def add_index(table, index_name, columns, is_pk: bool = False, is_unique=None, m2m: bool = False): ...
+ def add_foreign_key(
+ table,
+ fk_name,
+ child_columns,
+ parent_table,
+ parent_columns,
+ index_name=None,
+ on_delete: bool = False,
+ interleave: bool = False,
+ ): ...
+
+class Column:
+ auto_template: ClassVar[str]
+ def __init__(column, name, table, sql_type, converter, is_not_null: bool | None = None, sql_default=None) -> None: ...
+ def get_sql(column) -> str: ...
+
+class Constraint(DBObject):
+ schema: DBSchema
+ name: str | None
+ def __init__(constraint, name: str | None, schema: DBSchema) -> None: ...
+
+class DBIndex(Constraint):
+ typename: ClassVar[str]
+ def __init__(index, name: str | None, table, columns, is_pk: bool = False, is_unique=None) -> None: ...
+ def exists(index, provider, connection, case_sensitive: bool = True): ...
+ def get_sql(index) -> str: ...
+ def get_create_command(index): ...
+
+class ForeignKey(Constraint):
+ typename: ClassVar[str]
+ def __init__(
+ foreign_key,
+ name,
+ child_table,
+ child_columns,
+ parent_table,
+ parent_columns,
+ index_name,
+ on_delete,
+ interleave: bool = False,
+ ) -> None: ...
+ def exists(foreign_key, provider, connection, case_sensitive: bool = True): ...
+ def get_sql(foreign_key) -> str: ...
+ def get_create_command(foreign_key): ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/decompiling.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/decompiling.pyi
new file mode 100644
index 000000000000..83f56630b590
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/decompiling.pyi
@@ -0,0 +1,135 @@
+import ast
+from _typeshed import Incomplete
+
+class DecompileError(NotImplementedError): ...
+
+ast_cache: dict[int, tuple[Incomplete | None, set[Incomplete]]]
+
+def decompile(x): ...
+def simplify(clause): ...
+
+class InvalidQuery(Exception): ...
+
+def binop(node_type): ...
+
+operator_mapping: dict[str, type[ast.cmpop]]
+
+def clean_assign(node): ...
+def make_const(value): ...
+def is_const(value) -> bool: ...
+def unwrap_str(key) -> str: ...
+
+class Decompiler:
+ def __init__(decompiler, code, start: int = 0, end=None) -> None: ...
+ def get_instructions(decompiler) -> None: ...
+ def analyze_jumps(decompiler) -> None: ...
+ def decompile(decompiler) -> None: ...
+ def pop_items(decompiler, size): ...
+ def store(decompiler, node) -> None: ...
+ BINARY_POWER: Incomplete
+ BINARY_MULTIPLY: Incomplete
+ BINARY_DIVIDE: Incomplete
+ BINARY_FLOOR_DIVIDE: Incomplete
+ BINARY_ADD: Incomplete
+ BINARY_SUBTRACT: Incomplete
+ BINARY_LSHIFT: Incomplete
+ BINARY_RSHIFT: Incomplete
+ BINARY_AND: Incomplete
+ BINARY_XOR: Incomplete
+ BINARY_OR: Incomplete
+ BINARY_TRUE_DIVIDE = BINARY_DIVIDE
+ BINARY_MODULO: Incomplete
+ def BINARY_OP(decompiler, opcode): ...
+ def BINARY_SLICE(decompiler): ...
+ def BINARY_SUBSCR(decompiler): ...
+ def BUILD_CONST_KEY_MAP(decompiler, length): ...
+ def BUILD_LIST(decompiler, size): ...
+ def BUILD_MAP(decompiler, length): ...
+ def BUILD_SET(decompiler, size): ...
+ def BUILD_SLICE(decompiler, size): ...
+ def BUILD_TUPLE(decompiler, size): ...
+ def BUILD_STRING(decompiler, count): ...
+ def CALL_FUNCTION(decompiler, argc, star=None, star2=None): ...
+ def CACHE(decompiler) -> None: ...
+ def CALL(decompiler, argc): ...
+ def CALL_FUNCTION_VAR(decompiler, argc): ...
+ def CALL_FUNCTION_KW(decompiler, argc): ...
+ def CALL_FUNCTION_VAR_KW(decompiler, argc): ...
+ def CALL_FUNCTION_EX(decompiler, argc): ...
+ def CALL_METHOD(decompiler, argc): ...
+ def COMPARE_OP(decompiler, op): ...
+ def COPY(decompiler, _) -> None: ...
+ def COPY_FREE_VARS(decompiler, n) -> None: ...
+ def CONTAINS_OP(decompiler, invert): ...
+ def DUP_TOP(decompiler): ...
+ def FOR_ITER(decompiler, endpos): ...
+ def FORMAT_VALUE(decompiler, flags): ...
+ def GEN_START(decompiler, kind) -> None: ...
+ def GET_ITER(decompiler) -> None: ...
+ def JUMP_IF_FALSE(decompiler, endpos): ...
+ JUMP_IF_FALSE_OR_POP = JUMP_IF_FALSE
+ def JUMP_IF_NOT_EXC_MATCH(decompiler, endpos) -> None: ...
+ def JUMP_IF_TRUE(decompiler, endpos): ...
+ JUMP_IF_TRUE_OR_POP = JUMP_IF_TRUE
+ def conditional_jump(decompiler, endpos, if_true): ...
+ def conditional_jump_old(decompiler, endpos, if_true): ...
+ def conditional_jump_new(decompiler, endpos, if_true): ...
+ def conditional_jump_none_impl(decompiler, endpos, negate): ...
+ def jump_if_none(decompiler, endpos): ...
+ def jump_if_not_none(decompiler, endpos): ...
+ def process_target(decompiler, pos, partial: bool = False) -> None: ...
+ def JUMP_FORWARD(decompiler, endpos): ...
+ def KW_NAMES(decompiler, kw_names) -> None: ...
+ def IS_OP(decompiler, invert): ...
+ def LIST_APPEND(decompiler, offset) -> None: ...
+ def LIST_EXTEND(decompiler, offset): ...
+ def LIST_TO_TUPLE(decompiler): ...
+ def LOAD_ATTR(decompiler, attr_name, push_null): ...
+ def LOAD_CLOSURE(decompiler, freevar): ...
+ def LOAD_CONST(decompiler, const_value): ...
+ def LOAD_DEREF(decompiler, freevar): ...
+ def LOAD_FAST(decompiler, varname): ...
+ LOAD_FAST_AND_CLEAR = LOAD_FAST
+ def LOAD_GLOBAL(decompiler, varname, push_null): ...
+ def LOAD_METHOD(decompiler, methname): ...
+ LOOKUP_METHOD = LOAD_METHOD
+ def LOAD_NAME(decompiler, varname): ...
+ def MAKE_CELL(decompiler, freevar) -> None: ...
+ def MAKE_CLOSURE(decompiler, argc): ...
+ def MAKE_FUNCTION(decompiler, argc): ...
+ POP_JUMP_BACKWARD_IF_FALSE = JUMP_IF_FALSE
+ POP_JUMP_BACKWARD_IF_TRUE = JUMP_IF_TRUE
+ POP_JUMP_FORWARD_IF_FALSE = JUMP_IF_FALSE
+ POP_JUMP_FORWARD_IF_TRUE = JUMP_IF_TRUE
+ POP_JUMP_IF_FALSE = JUMP_IF_FALSE
+ POP_JUMP_IF_TRUE = JUMP_IF_TRUE
+ POP_JUMP_BACKWARD_IF_NONE = jump_if_none
+ POP_JUMP_BACKWARD_IF_NOT_NONE = jump_if_not_none
+ POP_JUMP_FORWARD_IF_NONE = jump_if_none
+ POP_JUMP_FORWARD_IF_NOT_NONE = jump_if_not_none
+ def POP_TOP(decompiler) -> None: ...
+ def PRECALL(decompiler, argc) -> None: ...
+ def PUSH_NULL(decompiler) -> None: ...
+ def RETURN_VALUE(decompiler): ...
+ def RETURN_CONST(decompiler, val): ...
+ def RETURN_GENERATOR(decompiler) -> None: ...
+ def RESUME(decompiler, where) -> None: ...
+ def ROT_TWO(decompiler) -> None: ...
+ def ROT_THREE(decompiler) -> None: ...
+ def SETUP_LOOP(decompiler, endpos) -> None: ...
+ def STORE_ATTR(decompiler, attrname) -> None: ...
+ def STORE_DEREF(decompiler, freevar) -> None: ...
+ def STORE_FAST(decompiler, varname) -> None: ...
+ def STORE_MAP(decompiler) -> None: ...
+ def STORE_SUBSCR(decompiler) -> None: ...
+ def SWAP(decompiler, _) -> None: ...
+ def UNARY_POSITIVE(decompiler): ...
+ def UNARY_NEGATIVE(decompiler): ...
+ def UNARY_NOT(decompiler): ...
+ def UNARY_INVERT(decompiler): ...
+ def UNPACK_SEQUENCE(decompiler, count): ...
+ def YIELD_VALUE(decompiler, _=None): ...
+
+test_lines: str
+
+def test(test_line=None) -> None: ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/examples/__init__.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/examples/__init__.pyi
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/examples/alessandro_bug.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/examples/alessandro_bug.pyi
new file mode 100644
index 000000000000..f8e36522aaf7
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/examples/alessandro_bug.pyi
@@ -0,0 +1,51 @@
+from _typeshed import Incomplete
+
+from pony.orm import *
+from pony.orm.core import Database, Entity
+
+database: Database
+
+class User(Entity):
+ __slots__ = ()
+ user_id: PrimaryKey
+ owned_pokemons: Incomplete
+ is_admin: Incomplete
+ is_banned: Incomplete
+ @staticmethod
+ def get_or_create(user_id: int) -> User: ...
+ @staticmethod
+ def get_by_id(user_id: int) -> User: ...
+ def catch_pokemon(self, pokemon: Pokemon): ...
+ def remove_pokemon(self, pokemon: Pokemon): ...
+ favorite_color: Incomplete
+ def set_favorite_color(self, color: tuple[Incomplete, ...]): ...
+
+class Pokemon(Entity):
+ __slots__ = ()
+ name: Incomplete
+ pokemon_id: Incomplete
+ sprite: Incomplete
+ is_shiny: Incomplete
+ owner: Incomplete
+ spawned_chat_id: Incomplete
+ spawned_message_id: Incomplete
+ @property
+ def captured(self) -> bool: ...
+ def caught_by(self, user: User): ...
+
+class Chat(Entity):
+ __slots__ = ()
+ chat_id: Incomplete
+ active: Incomplete
+ def activate(self) -> None: ...
+ def deactivate(self) -> None: ...
+ @staticmethod
+ def get_or_create(chat_id: int) -> Chat: ...
+ @staticmethod
+ def get_by_id(chat_id: int) -> Chat: ...
+
+def spawn_pokemon(
+ chat_id: int, message_id: int, pokemon_json: dict[Incomplete, Incomplete], is_shiny: bool = False
+) -> Pokemon: ...
+def get_spawned_pokemon(chat_id: int, message_id: int) -> Pokemon | None: ...
+def setup() -> None: ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/examples/bottle_example.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/examples/bottle_example.pyi
new file mode 100644
index 000000000000..5ea35b2aacd0
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/examples/bottle_example.pyi
@@ -0,0 +1,6 @@
+from pony.orm.examples.estore import *
+
+def all_products() -> str: ...
+def show_product(id: int) -> str: ...
+def edit_product(id: int) -> str: ...
+def save_product(id: int) -> None: ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/examples/bug_ben.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/examples/bug_ben.pyi
new file mode 100644
index 000000000000..3b7ecb074f0e
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/examples/bug_ben.pyi
@@ -0,0 +1,19 @@
+from _typeshed import Incomplete
+
+from pony.orm.core import Database, Entity
+
+db: Database
+
+class ReconciledPayments(Entity):
+ id: Incomplete
+ foo: Incomplete
+ add_on_id: Incomplete
+
+class ContractAddOns(Entity):
+ id: Incomplete
+ reconciled_payments: Incomplete
+
+r1: ReconciledPayments
+r2: ReconciledPayments
+c1: ContractAddOns
+old_val: Incomplete
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/examples/compositekeys.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/examples/compositekeys.pyi
new file mode 100644
index 000000000000..1d48e601587f
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/examples/compositekeys.pyi
@@ -0,0 +1,89 @@
+from _typeshed import Incomplete
+
+from pony.orm.core import Database, Entity
+
+db: Database
+
+class Group(Entity):
+ __slots__ = ()
+ dept: Incomplete
+ year: Incomplete
+ spec: Incomplete
+ students: Incomplete
+ courses: Incomplete
+ lessons: Incomplete
+
+class Department(Entity):
+ __slots__ = ()
+ number: Incomplete
+ faculty: Incomplete
+ name: Incomplete
+ groups: Incomplete
+ teachers: Incomplete
+
+class Faculty(Entity):
+ __slots__ = ()
+ number: Incomplete
+ name: Incomplete
+ depts: Incomplete
+
+class Student(Entity):
+ __slots__ = ()
+ name: Incomplete
+ group: Incomplete
+ dob: Incomplete
+ grades: Incomplete
+
+class Grade(Entity):
+ __slots__ = ()
+ student: Incomplete
+ task: Incomplete
+ date: Incomplete
+ value: Incomplete
+
+class Task(Entity):
+ __slots__ = ()
+ course: Incomplete
+ type: Incomplete
+ number: Incomplete
+ descr: Incomplete
+ grades: Incomplete
+
+class Course(Entity):
+ __slots__ = ()
+ subject: Incomplete
+ semester: Incomplete
+ groups: Incomplete
+ tasks: Incomplete
+ lessons: Incomplete
+ teachers: Incomplete
+
+class Subject(Entity):
+ __slots__ = ()
+ name: Incomplete
+ descr: Incomplete
+ courses: Incomplete
+
+class Room(Entity):
+ __slots__ = ()
+ building: Incomplete
+ number: Incomplete
+ floor: Incomplete
+ schedules: Incomplete
+
+class Teacher(Entity):
+ __slots__ = ()
+ dept: Incomplete
+ name: Incomplete
+ courses: Incomplete
+ lessons: Incomplete
+
+class Lesson(Entity):
+ __slots__ = ()
+ groups: Incomplete
+ course: Incomplete
+ room: Incomplete
+ teacher: Incomplete
+ date: Incomplete
+
+def test_queries() -> None: ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/examples/demo.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/examples/demo.pyi
new file mode 100644
index 000000000000..b2b31939bb9b
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/examples/demo.pyi
@@ -0,0 +1,34 @@
+from _typeshed import Incomplete
+
+from pony.orm.core import Database, Entity
+
+db: Database
+
+class Customer(Entity):
+ __slots__ = ()
+ id: Incomplete
+ name: Incomplete
+ email: Incomplete
+ orders: Incomplete
+
+class Order(Entity):
+ __slots__ = ()
+ id: Incomplete
+ total_price: Incomplete
+ customer: Incomplete
+ items: Incomplete
+
+class Product(Entity):
+ __slots__ = ()
+ id: Incomplete
+ name: Incomplete
+ price: Incomplete
+ items: Incomplete
+
+class OrderItem(Entity):
+ __slots__ = ()
+ quantity: Incomplete
+ order: Incomplete
+ product: Incomplete
+
+def populate_database() -> None: ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/examples/estore.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/examples/estore.pyi
new file mode 100644
index 000000000000..8fdc234bab8d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/examples/estore.pyi
@@ -0,0 +1,64 @@
+from _typeshed import Incomplete
+
+from pony.orm.core import Database, Entity
+
+db: Database
+
+class Customer(Entity):
+ __slots__ = ()
+ email: Incomplete
+ password: Incomplete
+ name: Incomplete
+ country: Incomplete
+ address: Incomplete
+ cart_items: Incomplete
+ orders: Incomplete
+
+class Product(Entity):
+ __slots__ = ()
+ id: Incomplete
+ name: Incomplete
+ categories: Incomplete
+ description: Incomplete
+ picture: Incomplete
+ price: Incomplete
+ quantity: Incomplete
+ cart_items: Incomplete
+ order_items: Incomplete
+
+class CartItem(Entity):
+ __slots__ = ()
+ quantity: Incomplete
+ customer: Incomplete
+ product: Incomplete
+
+class OrderItem(Entity):
+ __slots__ = ()
+ quantity: Incomplete
+ price: Incomplete
+ order: Incomplete
+ product: Incomplete
+
+class Order(Entity):
+ __slots__ = ()
+ id: Incomplete
+ state: Incomplete
+ date_created: Incomplete
+ date_shipped: Incomplete
+ date_delivered: Incomplete
+ total_price: Incomplete
+ customer: Incomplete
+ items: Incomplete
+
+class Category(Entity):
+ __slots__ = ()
+ name: Incomplete
+ products: Incomplete
+
+CREATED: str
+SHIPPED: str
+DELIVERED: str
+CANCELLED: str
+
+def populate_database() -> None: ...
+def test_queries() -> None: ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/examples/inheritance1.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/examples/inheritance1.pyi
new file mode 100644
index 000000000000..24518002ee50
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/examples/inheritance1.pyi
@@ -0,0 +1,46 @@
+from _typeshed import Incomplete
+
+from pony.orm.core import Database, Entity
+
+db: Database
+
+class Person(Entity):
+ __slots__ = ()
+ id: Incomplete
+ name: Incomplete
+ dob: Incomplete
+ ssn: Incomplete
+
+class Student(Person):
+ __slots__ = ()
+ group: Incomplete
+ mentor: Incomplete
+ attend_courses: Incomplete
+
+class Teacher(Person):
+ __slots__ = ()
+ teach_courses: Incomplete
+ apprentices: Incomplete
+ salary: Incomplete
+
+class Assistant(Student, Teacher):
+ __slots__ = ()
+
+class Professor(Teacher):
+ __slots__ = ()
+ position: Incomplete
+
+class Group(Entity):
+ __slots__ = ()
+ number: Incomplete
+ students: Incomplete
+
+class Course(Entity):
+ __slots__ = ()
+ name: Incomplete
+ semester: Incomplete
+ students: Incomplete
+ teachers: Incomplete
+
+def populate_database() -> None: ...
+def show_all_persons() -> None: ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/examples/numbers.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/examples/numbers.pyi
new file mode 100644
index 000000000000..ab8105fc29c9
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/examples/numbers.pyi
@@ -0,0 +1,21 @@
+from _typeshed import Incomplete
+
+from pony.orm.core import Database, Entity
+
+db: Database
+
+class Numbers(Entity):
+ __slots__ = ()
+ id: Incomplete
+ int8: Incomplete
+ int16: Incomplete
+ int24: Incomplete
+ int32: Incomplete
+ int64: Incomplete
+ uint8: Incomplete
+ uint16: Incomplete
+ uint24: Incomplete
+ uint32: Incomplete
+
+def populate_database() -> None: ...
+def test_data() -> None: ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/examples/session01.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/examples/session01.pyi
new file mode 100644
index 000000000000..418f87b14dd5
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/examples/session01.pyi
@@ -0,0 +1,15 @@
+from _typeshed import Incomplete
+
+from pony.orm.core import Database, Entity
+
+db: Database
+
+class Person(Entity):
+ name: str
+ age: int
+
+p1: Person
+p2: Person
+x: int
+y: int
+q: Incomplete
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/examples/university1.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/examples/university1.pyi
new file mode 100644
index 000000000000..ced29c56889d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/examples/university1.pyi
@@ -0,0 +1,47 @@
+from _typeshed import Incomplete
+from decimal import Decimal as Decimal
+
+from pony.orm.core import Database, Entity
+
+db: Database
+
+class Department(Entity):
+ __slots__ = ()
+ number: Incomplete
+ name: Incomplete
+ groups: Incomplete
+ courses: Incomplete
+
+class Group(Entity):
+ __slots__ = ()
+ number: Incomplete
+ major: Incomplete
+ dept: Incomplete
+ students: Incomplete
+
+class Course(Entity):
+ __slots__ = ()
+ name: Incomplete
+ semester: Incomplete
+ lect_hours: Incomplete
+ lab_hours: Incomplete
+ credits: Incomplete
+ dept: Incomplete
+ students: Incomplete
+
+class Student(Entity):
+ __slots__ = ()
+ id: Incomplete
+ name: Incomplete
+ dob: Incomplete
+ tel: Incomplete
+ picture: Incomplete
+ gpa: Incomplete
+ group: Incomplete
+ courses: Incomplete
+
+params: dict[str, dict[str, str | bool] | dict[str, str | int]]
+
+def populate_database() -> None: ...
+def print_students(students) -> None: ...
+def test_queries() -> None: ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/examples/university2.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/examples/university2.pyi
new file mode 100644
index 000000000000..cc5baed9e4f0
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/examples/university2.pyi
@@ -0,0 +1,99 @@
+from _typeshed import Incomplete
+
+from pony.orm.core import Database, Entity
+
+db: Database
+
+class Faculty(Entity):
+ __slots__ = ()
+ number: Incomplete
+ name: Incomplete
+ departments: Incomplete
+
+class Department(Entity):
+ __slots__ = ()
+ number: Incomplete
+ name: Incomplete
+ faculty: Incomplete
+ teachers: Incomplete
+ majors: Incomplete
+ groups: Incomplete
+
+class Group(Entity):
+ __slots__ = ()
+ number: Incomplete
+ grad_year: Incomplete
+ department: Incomplete
+ lessons: Incomplete
+ students: Incomplete
+
+class Student(Entity):
+ __slots__ = ()
+ name: Incomplete
+ scholarship: Incomplete
+ group: Incomplete
+ grades: Incomplete
+
+class Major(Entity):
+ __slots__ = ()
+ name: Incomplete
+ department: Incomplete
+ courses: Incomplete
+
+class Subject(Entity):
+ __slots__ = ()
+ name: Incomplete
+ courses: Incomplete
+ teachers: Incomplete
+
+class Course(Entity):
+ __slots__ = ()
+ major: Incomplete
+ subject: Incomplete
+ semester: Incomplete
+ lect_hours: Incomplete
+ pract_hours: Incomplete
+ credit: Incomplete
+ lessons: Incomplete
+ grades: Incomplete
+
+class Lesson(Entity):
+ __slots__ = ()
+ day_of_week: Incomplete
+ meeting_time: Incomplete
+ classroom: Incomplete
+ course: Incomplete
+ teacher: Incomplete
+ groups: Incomplete
+
+class Grade(Entity):
+ __slots__ = ()
+ student: Incomplete
+ course: Incomplete
+ teacher: Incomplete
+ date: Incomplete
+ value: Incomplete
+
+class Teacher(Entity):
+ __slots__ = ()
+ name: Incomplete
+ degree: Incomplete
+ department: Incomplete
+ subjects: Incomplete
+ lessons: Incomplete
+ grades: Incomplete
+
+class Building(Entity):
+ __slots__ = ()
+ number: Incomplete
+ description: Incomplete
+ classrooms: Incomplete
+
+class Classroom(Entity):
+ __slots__ = ()
+ building: Incomplete
+ number: Incomplete
+ description: Incomplete
+ lessons: Incomplete
+
+def test_queries() -> None: ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/integration/__init__.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/integration/__init__.pyi
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/integration/bottle_plugin.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/integration/bottle_plugin.pyi
new file mode 100644
index 000000000000..d8bf1727386c
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/integration/bottle_plugin.pyi
@@ -0,0 +1,6 @@
+def is_allowed_exception(e: BaseException | None) -> bool: ...
+
+class PonyPlugin:
+ name: str
+ api: int
+ def apply(self, callback, route): ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/ormtypes.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/ormtypes.pyi
new file mode 100644
index 000000000000..6ae9e0566dba
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/ormtypes.pyi
@@ -0,0 +1,156 @@
+from _typeshed import Incomplete
+from collections.abc import Mapping
+from typing import Any
+from typing_extensions import Self
+
+NoneType: type[None]
+
+class LongStr(str):
+ lazy: bool
+
+LongUnicode = LongStr
+
+class SetType:
+ __slots__ = "item_type"
+ def __deepcopy__(self, memo) -> Self: ...
+ item_type: Incomplete
+ def __init__(self, item_type) -> None: ...
+ def __eq__(self, other): ...
+ def __ne__(self, other): ...
+ def __hash__(self) -> int: ...
+
+class FuncType:
+ __slots__ = "func"
+ def __deepcopy__(self, memo) -> Self: ...
+ func: Incomplete
+ def __init__(self, func) -> None: ...
+ def __eq__(self, other): ...
+ def __ne__(self, other): ...
+ def __hash__(self) -> int: ...
+
+class MethodType:
+ __slots__ = ("obj", "func")
+ def __deepcopy__(self, memo) -> Self: ...
+ obj: Incomplete
+ func: Incomplete
+ def __init__(self, method) -> None: ...
+ def __eq__(self, other): ...
+ def __ne__(self, other): ...
+ def __hash__(self) -> int: ...
+
+raw_sql_cache: dict[str, Incomplete]
+
+def parse_raw_sql(sql: str): ...
+def raw_sql(sql: str, result_type=None) -> RawSQL: ...
+
+class RawSQL:
+ def __deepcopy__(self, memo) -> None: ...
+ sql: str
+ result_type: Incomplete
+ def __init__(
+ self, sql: str, globals: dict[str, Any] | None = None, locals: Mapping[str, object] | None = None, result_type=None
+ ) -> None: ...
+
+class RawSQLType:
+ def __deepcopy__(self, memo) -> Self: ...
+ sql: str
+ items: Incomplete
+ types: Incomplete
+ result_type: Incomplete
+ def __init__(self, sql: str, items, types, result_type) -> None: ...
+ def __hash__(self) -> int: ...
+ def __eq__(self, other) -> bool: ...
+ def __ne__(self, other) -> bool: ...
+
+class QueryType:
+ query_key: Incomplete
+ translator: Incomplete
+ limit: Incomplete
+ offset: Incomplete
+ def __init__(self, query, limit=None, offset=None) -> None: ...
+ def __hash__(self) -> int: ...
+ def __eq__(self, other): ...
+ def __ne__(self, other): ...
+
+def normalize(value): ...
+def normalize_type(t): ...
+
+coercions: Incomplete
+
+def coerce_types(t1, t2): ...
+def are_comparable_types(t1, t2, op: str = "=="): ...
+
+class TrackedValue:
+ obj_ref: Incomplete
+ attr: Incomplete
+ def __init__(self, obj, attr) -> None: ...
+ @classmethod
+ def make(cls, obj, attr, value): ...
+ def get_untracked(self) -> None: ...
+
+def tracked_method(func): ...
+
+class TrackedDict(TrackedValue, dict[Incomplete, Incomplete]):
+ def __init__(self, obj, attr, value) -> None: ...
+ def __reduce__(self): ...
+ __setitem__: Incomplete
+ __delitem__: Incomplete
+ def update(self, *args, **kwargs): ...
+ setdefault: Incomplete
+ pop: Incomplete
+ popitem: Incomplete
+ clear: Incomplete
+ def get_untracked(self): ...
+
+class TrackedList(TrackedValue, list[Incomplete]):
+ def __init__(self, obj, attr, value) -> None: ...
+ def __reduce__(self): ...
+ __setitem__: Incomplete
+ __delitem__: Incomplete
+ extend: Incomplete
+ append: Incomplete
+ pop: Incomplete
+ remove: Incomplete
+ insert: Incomplete
+ reverse: Incomplete
+ sort: Incomplete
+ clear: Incomplete
+ def get_untracked(self): ...
+
+def validate_item(item_type, item): ...
+
+class TrackedArray(TrackedList):
+ item_type: Incomplete
+ def __init__(self, obj, attr, value) -> None: ...
+ def extend(self, items) -> None: ...
+ def append(self, item) -> None: ...
+ def insert(self, index, item) -> None: ...
+ def __setitem__(self, index, item) -> None: ...
+ def __contains__(self, item) -> bool: ...
+
+class Json:
+ @classmethod
+ def default_empty_value(cls): ...
+ wrapped: Incomplete
+ def __init__(self, wrapped) -> None: ...
+
+class Array:
+ item_type: type | None
+ @classmethod
+ def default_empty_value(cls): ...
+
+class IntArray(Array):
+ item_type: type[int]
+
+class StrArray(Array):
+ item_type: type[str]
+
+class FloatArray(Array):
+ item_type: type[float]
+
+numeric_types: set[type]
+comparable_types: set[type]
+primitive_types: set[type]
+function_types: set[type]
+type_normalization_dict: dict[type, type]
+array_types: dict[type, type[Array]]
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/serialization.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/serialization.pyi
new file mode 100644
index 000000000000..b8acc580ce37
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/serialization.pyi
@@ -0,0 +1,32 @@
+from _typeshed import Incomplete
+from collections import defaultdict
+from collections.abc import Iterable
+from datetime import date, datetime
+from decimal import Decimal
+
+from pony.orm.core import Database, Entity
+
+class Bag:
+ database: Database
+ session_cache: Incomplete
+ entity_configs: dict[Entity, tuple[Incomplete, bool]]
+ objects: defaultdict[type[Entity], set[Entity]]
+ vars: dict[Incomplete, Incomplete]
+ dicts: defaultdict[Incomplete, dict[Incomplete, Incomplete]]
+ def __init__(bag, database: Database) -> None: ...
+ def config(
+ bag,
+ entity: Entity,
+ only=None,
+ exclude=None,
+ with_collections: bool = True,
+ with_lazy: bool = False,
+ related_objects: bool = True,
+ ) -> tuple[Incomplete, bool]: ...
+ def put(bag, x: Entity | Iterable[Entity]) -> None: ...
+ def to_dict(bag): ...
+ def to_json(bag) -> str: ...
+
+def to_dict(objects): ...
+def to_json(objects) -> str: ...
+def json_converter(x: datetime | date | Decimal) -> str: ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/sqlbuilding.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/sqlbuilding.pyi
new file mode 100644
index 000000000000..abfe2f849511
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/sqlbuilding.pyi
@@ -0,0 +1,165 @@
+import sys
+import types
+from _typeshed import Incomplete
+from collections.abc import Iterable
+from typing import ClassVar
+
+class AstError(Exception): ...
+
+class Param:
+ __slots__ = ("style", "id", "paramkey", "converter", "optimistic")
+ style: Incomplete
+ id: Incomplete
+ paramkey: Incomplete
+ converter: Incomplete
+ optimistic: bool
+ def __init__(param, paramstyle, paramkey, converter=None, optimistic: bool = False) -> None: ...
+ def eval(param, values): ...
+
+class CompositeParam(Param):
+ __slots__ = ("items", "func")
+ items: Iterable[Param | Value]
+ func: Incomplete
+ def __init__(param, paramstyle, paramkey, items: Iterable[Param | Value], func) -> None: ...
+ def eval(param, values): ...
+
+class Value:
+ __slots__ = ("paramstyle", "value")
+ paramstyle: Incomplete
+ value: Incomplete
+ def __init__(self, paramstyle, value) -> None: ...
+ def quote_str(self, s: str) -> str: ...
+
+def flat(tree): ...
+def flat_conditions(conditions): ...
+def join(delimiter, items): ...
+def move_conditions_from_inner_join_to_where(sections): ...
+def make_binary_op(symbol, default_parentheses: bool = False): ...
+def make_unary_func(symbol): ...
+def indentable(method): ...
+
+class SQLBuilder:
+ dialect: ClassVar[str | None]
+ param_class: ClassVar[type[Param]]
+ composite_param_class: ClassVar[type[CompositeParam]]
+ value_class: ClassVar[type[Value]]
+ indent_spaces: ClassVar[str]
+ least_func_name: ClassVar[str]
+ greatest_func_name: ClassVar[str]
+ def __init__(builder, provider, ast) -> None: ...
+ def __call__(builder, ast): ...
+ def INSERT(builder, table_name, columns, values, returning=None): ...
+ def DEFAULT(builder): ...
+ def UPDATE(builder, table_name, pairs, where=None): ...
+ def DELETE(builder, alias, from_ast, where=None): ...
+ def SELECT(builder, *sections): ...
+ def SELECT_FOR_UPDATE(builder, nowait, skip_locked, *sections): ...
+ def EXISTS(builder, *sections): ...
+ def NOT_EXISTS(builder, *sections): ...
+ def ALL(builder, *expr_list): ...
+ def DISTINCT(builder, *expr_list): ...
+ def AGGREGATES(builder, *expr_list): ...
+ def AS(builder, expr, alias): ...
+ def compound_name(builder, name_parts): ...
+ def sql_join(builder, join_type, sources): ...
+ def FROM(builder, *sources): ...
+ def INNER_JOIN(builder, *sources): ...
+ def LEFT_JOIN(builder, *sources): ...
+ def WHERE(builder, *conditions): ...
+ def HAVING(builder, *conditions): ...
+ def GROUP_BY(builder, *expr_list): ...
+ def UNION(builder, kind, *sections): ...
+ def INTERSECT(builder, *sections): ...
+ def EXCEPT(builder, *sections): ...
+ def ORDER_BY(builder, *order_list): ...
+ def DESC(builder, expr): ...
+ def LIMIT(builder, limit, offset=None): ...
+ def COLUMN(builder, table_alias, col_name): ...
+ def PARAM(builder, paramkey, converter=None, optimistic: bool = False): ...
+ def make_param(builder, param_class, paramkey, *args): ...
+ def make_composite_param(builder, paramkey, items, func): ...
+ def STAR(builder, table_alias): ...
+ def ROW(builder, *items): ...
+ def VALUE(builder, value): ...
+ def AND(builder, *cond_list): ...
+ def OR(builder, *cond_list): ...
+ def NOT(builder, condition): ...
+ def POW(builder, expr1, expr2): ...
+ EQ: Incomplete
+ NE: Incomplete
+ LT: Incomplete
+ LE: Incomplete
+ GT: Incomplete
+ GE: Incomplete
+ ADD: Incomplete
+ SUB: Incomplete
+ MUL: Incomplete
+ DIV: Incomplete
+ FLOORDIV: Incomplete
+ def MOD(builder, a, b): ...
+ def FLOAT_EQ(builder, a, b): ...
+ def FLOAT_NE(builder, a, b): ...
+ def CONCAT(builder, *args): ...
+ def NEG(builder, expr): ...
+ def IS_NULL(builder, expr): ...
+ def IS_NOT_NULL(builder, expr): ...
+ def LIKE(builder, expr, template, escape=None): ...
+ def NOT_LIKE(builder, expr, template, escape=None): ...
+ def BETWEEN(builder, expr1, expr2, expr3): ...
+ def NOT_BETWEEN(builder, expr1, expr2, expr3): ...
+ def IN(builder, expr1, x): ...
+ def NOT_IN(builder, expr1, x): ...
+ def COUNT(builder, distinct, *expr_list): ...
+ def SUM(builder, distinct, expr): ...
+ def AVG(builder, distinct, expr): ...
+ def GROUP_CONCAT(builder, distinct, expr, sep=None): ...
+ UPPER: Incomplete
+ LOWER: Incomplete
+ LENGTH: Incomplete
+ ABS: Incomplete
+ def COALESCE(builder, *args): ...
+ def MIN(builder, distinct, *args): ...
+ def MAX(builder, distinct, *args): ...
+ def SUBSTR(builder, expr, start, len=None): ...
+ def STRING_SLICE(builder, expr, start, stop): ...
+ def CASE(builder, expr, cases, default=None): ...
+ def IF(builder, cond, then, else_): ...
+ def TRIM(builder, expr, chars=None): ...
+ def LTRIM(builder, expr, chars=None): ...
+ def RTRIM(builder, expr, chars=None): ...
+ def REPLACE(builder, str, from_, to): ...
+ def TO_INT(builder, expr): ...
+ def TO_STR(builder, expr): ...
+ def TO_REAL(builder, expr): ...
+ def TODAY(builder): ...
+ def NOW(builder): ...
+ def DATE(builder, expr): ...
+ def YEAR(builder, expr): ...
+ def MONTH(builder, expr): ...
+ def DAY(builder, expr): ...
+ def HOUR(builder, expr): ...
+ def MINUTE(builder, expr): ...
+ def SECOND(builder, expr): ...
+ def RANDOM(builder): ...
+ def RAWSQL(builder, sql): ...
+ def build_json_path(builder, path): ...
+ if sys.version_info >= (3, 10):
+ @classmethod
+ def eval_json_path(cls, values: Iterable[int | str | types.EllipsisType | slice]) -> str: ...
+ else:
+ @classmethod
+ def eval_json_path(cls, values: Iterable[int | str | type | slice]) -> str: ...
+
+ def JSON_QUERY(builder, expr, path) -> None: ...
+ def JSON_VALUE(builder, expr, path, type) -> None: ...
+ def JSON_NONZERO(builder, expr) -> None: ...
+ def JSON_CONCAT(builder, left, right) -> None: ...
+ def JSON_CONTAINS(builder, expr, path, key) -> None: ...
+ def JSON_ARRAY_LENGTH(builder, value) -> None: ...
+ def JSON_PARAM(builder, expr): ...
+ def ARRAY_INDEX(builder, col, index) -> None: ...
+ def ARRAY_CONTAINS(builder, key, not_in, col) -> None: ...
+ def ARRAY_SUBSET(builder, array1, not_in, array2) -> None: ...
+ def ARRAY_LENGTH(builder, array) -> None: ...
+ def ARRAY_SLICE(builder, array, start, stop) -> None: ...
+ def MAKE_ARRAY(builder, *items) -> None: ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/sqlsymbols.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/sqlsymbols.pyi
new file mode 100644
index 000000000000..237991537b91
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/sqlsymbols.pyi
@@ -0,0 +1,88 @@
+from typing import Final
+
+symbols: Final[list[str]]
+SELECT: Final = "SELECT"
+INSERT: Final = "INSERT"
+UPDATE: Final = "UPDATE"
+DELETE: Final = "DELETE"
+SELECT_FOR_UPDATE: Final = "SELECT_FOR_UPDATE"
+FROM: Final = "FROM"
+INNER_JOIN: Final = "INNER_JOIN"
+LEFT_JOIN: Final = "LEFT_JOIN"
+WHERE: Final = "WHERE"
+GROUP_BY: Final = "GROUP_BY"
+HAVING: Final = "HAVING"
+UNION: Final = "UNION"
+INTERSECT: Final = "INTERSECT"
+EXCEPT: Final = "EXCEPT"
+ORDER_BY: Final = "ORDER_BY"
+LIMIT: Final = "LIMIT"
+ASC: Final = "ASC"
+DESC: Final = "DESC"
+DISTINCT: Final = "DISTINCT"
+ALL: Final = "ALL"
+AGGREGATES: Final = "AGGREGATES"
+AS: Final = "AS"
+COUNT: Final = "COUNT"
+SUM: Final = "SUM"
+MIN: Final = "MIN"
+MAX: Final = "MAX"
+AVG: Final = "AVG"
+TABLE: Final = "TABLE"
+COLUMN: Final = "COLUMN"
+PARAM: Final = "PARAM"
+VALUE: Final = "VALUE"
+AND: Final = "AND"
+OR: Final = "OR"
+NOT: Final = "NOT"
+EQ: Final = "EQ"
+NE: Final = "NE"
+LT: Final = "LT"
+LE: Final = "LE"
+GT: Final = "GT"
+GE: Final = "GE"
+IS_NULL: Final = "IS_NULL"
+IS_NOT_NULL: Final = "IS_NOT_NULL"
+LIKE: Final = "LIKE"
+NOT_LIKE: Final = "NOT_LIKE"
+BETWEEN: Final = "BETWEEN"
+NOT_BETWEEN: Final = "NOT_BETWEEN"
+IN: Final = "IN"
+NOT_IN: Final = "NOT_IN"
+EXISTS: Final = "EXISTS"
+NOT_EXISTS: Final = "NOT_EXISTS"
+ROW: Final = "ROW"
+ADD: Final = "ADD"
+SUB: Final = "SUB"
+MUL: Final = "MUL"
+DIV: Final = "DIV"
+POW: Final = "POW"
+NEG: Final = "NEG"
+ABS: Final = "ABS"
+UPPER: Final = "UPPER"
+LOWER: Final = "LOWER"
+CONCAT: Final = "CONCAT"
+STRIN: Final = "STRIN"
+SUBSTR: Final = "SUBSTR"
+LENGTH: Final = "LENGTH"
+TRIM: Final = "TRIM"
+LTRIM: Final = "LTRIM"
+RTRIM: Final = "RTRIM"
+REPLACE: Final = "REPLACE"
+CASE: Final = "CASE"
+COALESCE: Final = "COALESCE"
+TO_INT: Final = "TO_INT"
+RANDOM: Final = "RANDOM"
+DATE: Final = "DATE"
+YEAR: Final = "YEAR"
+MONTH: Final = "MONTH"
+DAY: Final = "DAY"
+HOUR: Final = "HOUR"
+MINUTE: Final = "MINUTE"
+SECOND: Final = "SECOND"
+TODAY: Final = "TODAY"
+NOW: Final = "NOW"
+DATE_ADD: Final = "DATE_ADD"
+DATE_SUB: Final = "DATE_SUB"
+DATETIME_ADD: Final = "DATETIME_ADD"
+DATETIME_SUB: Final = "DATETIME_SUB"
diff --git a/python/helpers/typeshed/stubs/pony/pony/orm/sqltranslation.pyi b/python/helpers/typeshed/stubs/pony/pony/orm/sqltranslation.pyi
new file mode 100644
index 000000000000..816405de10c2
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/orm/sqltranslation.pyi
@@ -0,0 +1,773 @@
+import ast
+import itertools
+import re
+import sys
+import types
+from _typeshed import Incomplete
+from collections.abc import Generator, Iterable, Sequence
+from datetime import date, datetime, time, timedelta
+from decimal import Decimal
+from random import random
+from typing import Any, ClassVar, NoReturn
+from typing_extensions import Self
+
+from pony.orm import core
+from pony.orm.asttranslation import ASTTranslator
+from pony.orm.ormtypes import raw_sql
+from pony.utils import between, coalesce, concat, localbase
+
+NoneType: type[None]
+
+def check_comparable(left_monad: Monad, right_monad: Monad, op: str = "==") -> None: ...
+
+class IncomparableTypesError(TypeError):
+ type1: Incomplete
+ type2: Incomplete
+ def __init__(exc, type1, type2) -> None: ...
+
+def sqland(items): ...
+def sqlor(items): ...
+def join_tables(alias1, alias2, columns1, columns2): ...
+def type2str(t) -> str: ...
+
+class Local(localbase):
+ translators: list[SQLTranslator]
+ def __init__(local) -> None: ...
+ @property
+ def translator(self) -> SQLTranslator: ...
+
+translator_counter: itertools.count[int]
+local: Local
+
+class SQLTranslator(ASTTranslator):
+ dialect: ClassVar[str | None]
+ row_value_syntax: ClassVar[bool]
+ json_path_wildcard_syntax: ClassVar[bool]
+ json_values_are_comparable: ClassVar[bool]
+ rowid_support: ClassVar[bool]
+ registered_functions: dict[types.FunctionType, type[FuncMonad]]
+ def __enter__(translator) -> None: ...
+ def __exit__(translator, exc_type, exc_val, exc_tb) -> None: ...
+ def default_post(translator, node) -> None: ...
+ def dispatch(translator, node): ...
+ def dispatch_external(translator, node) -> None: ...
+ def call(translator, method, node): ...
+ def deepcopy(translator): ...
+ def __init__(
+ translator,
+ tree,
+ parent_translator,
+ code_key=None,
+ filter_num=None,
+ extractors=None,
+ vars=None,
+ vartypes=None,
+ left_join: bool = False,
+ optimize=None,
+ ) -> None: ...
+ def init(
+ translator,
+ tree,
+ parent_translator,
+ code_key=None,
+ filter_num=None,
+ extractors=None,
+ vars=None,
+ vartypes=None,
+ left_join: bool = False,
+ optimize=None,
+ ): ...
+ @property
+ def namespace(translator): ...
+ def can_be_optimized(translator): ...
+ def process_query_qual(
+ translator, prev_translator, prev_limit, prev_offset, names, try_extend_prev_query: bool = False
+ ) -> None: ...
+ def construct_subquery_ast(
+ translator, limit=None, offset=None, aliases=None, star=None, distinct=None, is_not_null_checks: bool = False
+ ): ...
+ def construct_sql_ast(
+ translator,
+ limit=None,
+ offset=None,
+ distinct=None,
+ aggr_func_name=None,
+ aggr_func_distinct=None,
+ sep=None,
+ for_update: bool = False,
+ nowait: bool = False,
+ skip_locked: bool = False,
+ is_not_null_checks: bool = False,
+ ): ...
+ def construct_delete_sql_ast(translator): ...
+ def get_used_attrs(translator): ...
+ def without_order(translator) -> Self: ...
+ def order_by_numbers(translator, numbers: Iterable[int]) -> Self: ...
+ def order_by_attributes(translator, attrs: Iterable[core.DescWrapper | core.Attribute]) -> Self: ...
+ def apply_kwfilters(translator, filterattrs, original_names: bool = False) -> Self: ...
+ def apply_lambda(
+ translator, func_id, filter_num, order_by, func_ast, argnames, original_names, extractors, vars, vartypes
+ ) -> Self: ...
+ def preGeneratorExp(translator, node: ast.GeneratorExp) -> QuerySetMonad: ...
+ def postExpr(translator, node: ast.Expr): ...
+ def preCompare(translator, node: ast.Compare): ...
+ def postConstant(translator, node: ast.Constant) -> ConstMonad: ...
+ if sys.version_info >= (3, 14):
+ def postNameConstant(translator, node: ast.Constant): ...
+ def postNum(translator, node: ast.Constant) -> ConstMonad: ...
+ def postStr(translator, node: ast.Constant) -> ConstMonad: ...
+ def postBytes(translator, node: ast.Constant) -> ConstMonad: ...
+ else:
+ def postNameConstant(translator, node: ast.NameConstant): ...
+ def postNum(translator, node: ast.Num) -> ConstMonad: ...
+ def postStr(translator, node: ast.Str) -> ConstMonad: ...
+ def postBytes(translator, node: ast.Bytes) -> ConstMonad: ...
+
+ def postList(translator, node: ast.List) -> ListMonad: ...
+ def postTuple(translator, node: ast.Tuple) -> ListMonad: ...
+ def postName(translator, node: ast.Name) -> Monad: ...
+ def resolve_name(translator, name) -> Monad: ...
+ def postAdd(translator, node: ast.Add): ...
+ def postSub(translator, node: ast.Sub): ...
+ def postMult(translator, node: ast.Mult): ...
+ def postMatMult(translator, node: ast.MatMult) -> NoReturn: ...
+ def postDiv(translator, node: ast.Div): ...
+ def postFloorDiv(translator, node: ast.FloorDiv): ...
+ def postMod(translator, node: ast.Mod): ...
+ def postLShift(translator, node: ast.LShift) -> NoReturn: ...
+ def postRShift(translator, node: ast.RShift) -> NoReturn: ...
+ def postPow(translator, node: ast.Pow): ...
+ def postUSub(translator, node: ast.USub): ...
+ def postAttribute(translator, node: ast.Attribute): ...
+ def postAnd(translator, node: ast.And) -> AndMonad: ...
+ def postOr(translator, node: ast.Or) -> OrMonad: ...
+ def postBitOr(translator, node: ast.BitOr): ...
+ def postBitAnd(translator, node: ast.BitAnd): ...
+ def postBitXor(translator, node: ast.BitXor): ...
+ def postNot(translator, node: ast.Not): ...
+ def preCall(translator, node: ast.Call): ...
+ def postCall(translator, node: ast.Call): ...
+ def postkeyword(translator, node: ast.keyword) -> None: ...
+ def postSubscript(translator, node: ast.Subscript): ...
+ def postSlice(translator, node: ast.Slice) -> None: ...
+ def postIndex(translator, node: ast.Index): ...
+ def postIfExp(translator, node: ast.IfExp) -> ExprMonad: ...
+ def postJoinedStr(translator, node: ast.JoinedStr) -> StringExprMonad: ...
+ def postFormattedValue(translator, node: ast.FormattedValue): ...
+
+def combine_limit_and_offset(limit, offset, limit2, offset2) -> tuple[Incomplete, Incomplete]: ...
+def coerce_monads(m1, m2, for_comparison: bool = False): ...
+
+max_alias_length: int
+
+class SqlQuery:
+ translator: Incomplete
+ parent_sqlquery: SqlQuery | None
+ left_join: bool
+ from_ast: list[Incomplete]
+ conditions: list[Incomplete]
+ outer_conditions: list[Incomplete]
+ tablerefs: dict[Incomplete, Incomplete]
+ alias_counters: dict[Incomplete, Incomplete]
+ expr_counter: itertools.count[int]
+ used_from_subquery: bool
+ def __init__(sqlquery, translator, parent_sqlquery: SqlQuery | None = None, left_join: bool = False) -> None: ...
+ def get_tableref(sqlquery, name_path): ...
+ def add_tableref(sqlquery, name_path, parent_tableref, attr) -> JoinedTableRef: ...
+ def make_alias(sqlquery, name: str) -> str: ...
+ def join_table(sqlquery, parent_alias, alias, table_name, join_cond) -> None: ...
+
+class TableRef:
+ sqlquery: SqlQuery
+ alias: str
+ name_path: str
+ entity: Incomplete
+ joined: bool
+ can_affect_distinct: bool
+ used_attrs: set[Incomplete]
+ def __init__(tableref, sqlquery: SqlQuery, name: str, entity) -> None: ...
+ def make_join(tableref, pk_only: bool = False) -> tuple[str, Incomplete]: ...
+
+class ExprTableRef(TableRef):
+ def __init__(tableref, sqlquery: SqlQuery, name: str, subquery_ast, expr_names, expr_aliases) -> None: ...
+ def make_join(tableref, pk_only: bool = False) -> tuple[str, Incomplete]: ...
+
+class StarTableRef(TableRef):
+ def __init__(tableref, sqlquery: SqlQuery, name: str, entity, subquery_ast) -> None: ...
+ def make_join(tableref, pk_only: bool = False) -> tuple[str, Incomplete]: ...
+
+class ExprJoinedTableRef:
+ def __init__(tableref, sqlquery: SqlQuery, parent_tableref, parent_columns, name, entity) -> None: ...
+ def make_join(tableref, pk_only: bool = False) -> tuple[str, Incomplete]: ...
+
+class JoinedTableRef:
+ sqlquery: SqlQuery
+ name_path: str
+ var_name: str | None
+ alias: str | None
+ optimized: bool | None
+ parent_tableref: Incomplete
+ attr: Incomplete
+ entity: Incomplete
+ joined: bool
+ can_affect_distinct: bool
+ used_attrs: set[Incomplete]
+ def __init__(tableref, sqlquery: SqlQuery, name_path: str, parent_tableref, attr) -> None: ...
+ def make_join(tableref, pk_only: bool = False) -> tuple[str, Incomplete]: ...
+
+def wrap_monad_method(cls_name: str, func: types.FunctionType): ...
+
+class MonadMeta(type):
+ def __new__(meta, cls_name: str, bases: tuple[type, ...], cls_dict: dict[str, Any]): ...
+
+class MonadMixin(metaclass=MonadMeta): ...
+
+class Monad(metaclass=MonadMeta):
+ disable_distinct: ClassVar[bool]
+ disable_ordering: ClassVar[bool]
+ node: Incomplete
+ translator: SQLTranslator
+ type: Incomplete
+ nullable: bool
+ def __init__(monad, type, nullable: bool = True) -> None: ...
+ def mixin_init(monad) -> None: ...
+ def to_single_cell_value(monad): ...
+ def cmp(monad, op, monad2): ...
+ def contains(monad, item, not_in: bool = False) -> None: ...
+ def nonzero(monad): ...
+ def negate(monad): ...
+ def getattr(monad, attrname): ...
+ def len(monad) -> None: ...
+ def count(monad, distinct=None): ...
+ def aggregate(monad, func_name, distinct=None, sep=None): ...
+ def __call__(monad, *args, **kwargs) -> None: ...
+ def __getitem__(monad, key) -> None: ...
+ def __add__(monad, monad2) -> None: ...
+ def __sub__(monad, monad2) -> None: ...
+ def __mul__(monad, monad2) -> None: ...
+ def __truediv__(monad, monad2) -> None: ...
+ def __floordiv__(monad, monad2) -> None: ...
+ def __pow__(monad, monad2) -> None: ...
+ def __neg__(monad) -> None: ...
+ def __or__(monad, monad2) -> None: ...
+ def __and__(monad, monad2) -> None: ...
+ def __xor__(monad, monad2) -> None: ...
+ def abs(monad) -> None: ...
+ def cast_from_json(monad, type) -> None: ...
+ def to_int(monad): ...
+ def to_str(monad): ...
+ def to_real(monad): ...
+
+def distinct_from_monad(distinct, default=None): ...
+
+class RawSQLMonad(Monad):
+ def __init__(monad, rawtype, varkey, nullable: bool = True) -> None: ...
+ def contains(monad, item, not_in: bool = False): ...
+ def nonzero(monad): ...
+ def getsql(monad, sqlquery=None): ...
+
+typeerror_re_1: re.Pattern[str]
+typeerror_re_2: re.Pattern[str]
+
+def reraise_improved_typeerror(exc: Exception, func_name: str | tuple[str, ...], orig_func_name: str) -> NoReturn: ...
+def raise_forgot_parentheses(monad: Monad) -> NoReturn: ...
+
+class MethodMonad(Monad):
+ def __init__(monad, parent, attrname) -> None: ...
+ def getattr(monad, attrname) -> None: ...
+ def __call__(monad, *args, **kwargs): ...
+ def contains(monad, item, not_in: bool = False) -> None: ...
+ def nonzero(monad) -> None: ...
+ def negate(monad) -> None: ...
+ def aggregate(monad, func_name, distinct=None, sep=None) -> None: ...
+ def __getitem__(monad, key) -> None: ...
+ def __add__(monad, monad2) -> None: ...
+ def __sub__(monad, monad2) -> None: ...
+ def __mul__(monad, monad2) -> None: ...
+ def __truediv__(monad, monad2) -> None: ...
+ def __floordiv__(monad, monad2) -> None: ...
+ def __pow__(monad, monad2) -> None: ...
+ def __neg__(monad) -> None: ...
+ def abs(monad) -> None: ...
+
+class EntityMonad(Monad):
+ def __init__(monad, entity) -> None: ...
+ def __getitem__(monad, *args) -> None: ...
+
+class ListMonad(Monad):
+ def __init__(monad, items) -> None: ...
+ def contains(monad, x, not_in: bool = False): ...
+ def getsql(monad, sqlquery=None): ...
+
+class BufferMixin(MonadMixin): ...
+class UuidMixin(MonadMixin): ...
+
+def make_numeric_binop(op, sqlop): ...
+
+class NumericMixin(MonadMixin):
+ def mixin_init(monad) -> None: ...
+ __add__: Incomplete
+ __sub__: Incomplete
+ __mul__: Incomplete
+ __truediv__: Incomplete
+ __floordiv__: Incomplete
+ __mod__: Incomplete
+ __and__: Incomplete
+ __or__: Incomplete
+ __xor__: Incomplete
+ def __pow__(monad, monad2): ...
+ def __neg__(monad): ...
+ def abs(monad): ...
+ def nonzero(monad): ...
+ def negate(monad): ...
+
+def numeric_attr_factory(name): ...
+def make_datetime_binop(op, sqlop): ...
+
+class DateMixin(MonadMixin):
+ def mixin_init(monad) -> None: ...
+ attr_year: Incomplete
+ attr_month: Incomplete
+ attr_day: Incomplete
+ def __add__(monad, other): ...
+ def __sub__(monad, other): ...
+
+class TimeMixin(MonadMixin):
+ def mixin_init(monad) -> None: ...
+ attr_hour: Incomplete
+ attr_minute: Incomplete
+ attr_second: Incomplete
+
+class TimedeltaMixin(MonadMixin):
+ def mixin_init(monad) -> None: ...
+
+class DatetimeMixin(DateMixin):
+ def mixin_init(monad) -> None: ...
+ def call_date(monad): ...
+ attr_hour: Incomplete
+ attr_minute: Incomplete
+ attr_second: Incomplete
+ def __add__(monad, other): ...
+ def __sub__(monad, other): ...
+
+def make_string_binop(op, sqlop): ...
+def make_string_func(sqlop): ...
+
+class StringMixin(MonadMixin):
+ def mixin_init(monad) -> None: ...
+ __add__: Incomplete
+ def __getitem__(monad, index): ...
+ def negate(monad): ...
+ def nonzero(monad): ...
+ def len(monad): ...
+ def contains(monad, item, not_in: bool = False): ...
+ call_upper: Incomplete
+ call_lower: Incomplete
+ def call_startswith(monad, arg): ...
+ def call_endswith(monad, arg): ...
+ def strip(monad, chars, strip_type): ...
+ def call_strip(monad, chars=None): ...
+ def call_lstrip(monad, chars=None): ...
+ def call_rstrip(monad, chars=None): ...
+
+class JsonMixin:
+ disable_distinct: ClassVar[bool]
+ disable_ordering: ClassVar[bool]
+ def mixin_init(monad) -> None: ...
+ def get_path(monad): ...
+ def __getitem__(monad, key): ...
+ def contains(monad, key, not_in: bool = False): ...
+ def __or__(monad, other): ...
+ def len(monad): ...
+ def cast_from_json(monad, type): ...
+ def nonzero(monad): ...
+
+class ArrayMixin(MonadMixin):
+ def contains(monad, key, not_in: bool = False): ...
+ def len(monad): ...
+ def nonzero(monad): ...
+ def __getitem__(monad, index): ...
+
+class ObjectMixin(MonadMixin):
+ def mixin_init(monad) -> None: ...
+ def negate(monad): ...
+ def nonzero(monad): ...
+ def getattr(monad, attrname): ...
+ def requires_distinct(monad, joined: bool = False): ...
+
+class ObjectIterMonad(ObjectMixin, Monad):
+ def __init__(monad, tableref, entity) -> None: ...
+ def getsql(monad, sqlquery=None): ...
+ def requires_distinct(monad, joined: bool = False): ...
+
+class AttrMonad(Monad):
+ @staticmethod
+ def new(parent, attr, *args, **kwargs) -> AttrMonad: ...
+ def __new__(cls, parent, attr): ...
+ def __init__(monad, parent, attr) -> None: ...
+ def getsql(monad, sqlquery=None): ...
+
+class ObjectAttrMonad(ObjectMixin, AttrMonad):
+ def __init__(monad, parent, attr) -> None: ...
+
+class StringAttrMonad(StringMixin, AttrMonad): ...
+class NumericAttrMonad(NumericMixin, AttrMonad): ...
+class DateAttrMonad(DateMixin, AttrMonad): ...
+class TimeAttrMonad(TimeMixin, AttrMonad): ...
+class TimedeltaAttrMonad(TimedeltaMixin, AttrMonad): ...
+class DatetimeAttrMonad(DatetimeMixin, AttrMonad): ...
+class BufferAttrMonad(BufferMixin, AttrMonad): ...
+class UuidAttrMonad(UuidMixin, AttrMonad): ...
+class JsonAttrMonad(JsonMixin, AttrMonad): ...
+class ArrayAttrMonad(ArrayMixin, AttrMonad): ...
+
+class ParamMonad(Monad):
+ @staticmethod
+ def new(t, paramkey) -> ParamMonad: ...
+ def __new__(cls, *args, **kwargs): ...
+ def __init__(monad, t, paramkey) -> None: ...
+ def getsql(monad, sqlquery=None): ...
+
+class ObjectParamMonad(ObjectMixin, ParamMonad):
+ def __init__(monad, entity, paramkey) -> None: ...
+ def getsql(monad, sqlquery=None): ...
+ def requires_distinct(monad, joined: bool = False) -> None: ...
+
+class StringParamMonad(StringMixin, ParamMonad): ...
+class NumericParamMonad(NumericMixin, ParamMonad): ...
+class DateParamMonad(DateMixin, ParamMonad): ...
+class TimeParamMonad(TimeMixin, ParamMonad): ...
+class TimedeltaParamMonad(TimedeltaMixin, ParamMonad): ...
+class DatetimeParamMonad(DatetimeMixin, ParamMonad): ...
+class BufferParamMonad(BufferMixin, ParamMonad): ...
+class UuidParamMonad(UuidMixin, ParamMonad): ...
+
+class ArrayParamMonad(ArrayMixin, ParamMonad):
+ def __init__(monad, t, paramkey, list_monad=None) -> None: ...
+ def contains(monad, key, not_in: bool = False): ...
+
+class JsonParamMonad(JsonMixin, ParamMonad):
+ def getsql(monad, sqlquery=None): ...
+
+class ExprMonad(Monad):
+ @staticmethod
+ def new(t, sql, nullable: bool = True) -> ExprMonad: ...
+ def __new__(cls, *args, **kwargs): ...
+ def __init__(monad, type, sql, nullable: bool = True) -> None: ...
+ def getsql(monad, sqlquery=None): ...
+
+class ObjectExprMonad(ObjectMixin, ExprMonad):
+ def getsql(monad, sqlquery=None): ...
+
+class StringExprMonad(StringMixin, ExprMonad): ...
+class NumericExprMonad(NumericMixin, ExprMonad): ...
+class DateExprMonad(DateMixin, ExprMonad): ...
+class TimeExprMonad(TimeMixin, ExprMonad): ...
+class TimedeltaExprMonad(TimedeltaMixin, ExprMonad): ...
+class DatetimeExprMonad(DatetimeMixin, ExprMonad): ...
+class JsonExprMonad(JsonMixin, ExprMonad): ...
+class ArrayExprMonad(ArrayMixin, ExprMonad): ...
+
+class JsonItemMonad(JsonMixin, Monad):
+ def __init__(monad, parent, key) -> None: ...
+ def get_path(monad): ...
+ def to_int(monad): ...
+ def to_str(monad): ...
+ def to_real(monad): ...
+ def cast_from_json(monad, type): ...
+ def getsql(monad): ...
+
+class ConstMonad(Monad):
+ @staticmethod
+ def new(value) -> ConstMonad: ...
+ def __new__(cls, value): ...
+ def __init__(monad, value) -> None: ...
+ def getsql(monad, sqlquery=None): ...
+
+class NoneMonad(ConstMonad):
+ type = NoneType
+ def __new__(cls, value=None): ...
+ def __init__(monad, value=None) -> None: ...
+ def cmp(monad, op, monad2): ...
+ def contains(monad, item, not_in: bool = False): ...
+ def nonzero(monad): ...
+ def negate(monad): ...
+ def getattr(monad, attrname): ...
+ def len(monad): ...
+ def count(monad, distinct=None): ...
+ def aggregate(monad, func_name, distinct=None, sep=None): ...
+ def __call__(monad, *args, **kwargs): ...
+ def __getitem__(monad, key): ...
+ def __add__(monad, monad2): ...
+ def __sub__(monad, monad2): ...
+ def __mul__(monad, monad2): ...
+ def __truediv__(monad, monad2): ...
+ def __floordiv__(monad, monad2): ...
+ def __pow__(monad, monad2): ...
+ def __neg__(monad): ...
+ def __or__(monad, monad2): ...
+ def __and__(monad, monad2): ...
+ def __xor__(monad, monad2): ...
+ def abs(monad): ...
+ def to_int(monad): ...
+ def to_str(monad): ...
+ def to_real(monad): ...
+
+class EllipsisMonad(ConstMonad): ...
+
+class StringConstMonad(StringMixin, ConstMonad):
+ def len(monad): ...
+
+class JsonConstMonad(JsonMixin, ConstMonad): ...
+class BufferConstMonad(BufferMixin, ConstMonad): ...
+class NumericConstMonad(NumericMixin, ConstMonad): ...
+class DateConstMonad(DateMixin, ConstMonad): ...
+class TimeConstMonad(TimeMixin, ConstMonad): ...
+class TimedeltaConstMonad(TimedeltaMixin, ConstMonad): ...
+class DatetimeConstMonad(DatetimeMixin, ConstMonad): ...
+
+class BoolMonad(Monad):
+ def __init__(monad, nullable: bool = True) -> None: ...
+ def nonzero(monad): ...
+
+sql_negation: dict[str, str]
+
+class BoolExprMonad(BoolMonad):
+ def __init__(monad, sql, nullable: bool = True) -> None: ...
+ def getsql(monad, sqlquery=None): ...
+ def negate(monad): ...
+
+cmp_ops: dict[str, str]
+cmp_negate: dict[str, str]
+
+class CmpMonad(BoolMonad):
+ EQ: str
+ NE: str
+ def __init__(monad, op: str, left, right) -> None: ...
+ def negate(monad): ...
+ def getsql(monad, sqlquery=None): ...
+
+class LogicalBinOpMonad(BoolMonad):
+ def __init__(monad, operands) -> None: ...
+ def getsql(monad, sqlquery=None): ...
+
+class AndMonad(LogicalBinOpMonad):
+ binop: str
+
+class OrMonad(LogicalBinOpMonad):
+ binop: str
+
+class NotMonad(BoolMonad):
+ def __init__(monad, operand) -> None: ...
+ def negate(monad): ...
+ def getsql(monad, sqlquery=None): ...
+
+class HybridFuncMonad(Monad):
+ def __init__(monad, func_type, func_name, *params) -> None: ...
+ def __call__(monad, *args, **kwargs): ...
+
+class HybridMethodMonad(HybridFuncMonad):
+ def __init__(monad, parent, attrname, func) -> None: ...
+
+registered_functions: dict[types.FunctionType, type[FuncMonad]]
+
+class FuncMonadMeta(MonadMeta):
+ def __new__(meta, cls_name: str, bases: tuple[type, ...], cls_dict: dict[str, Any]): ...
+
+class FuncMonad(Monad, metaclass=FuncMonadMeta):
+ def __call__(monad, *args, **kwargs): ...
+
+def get_classes(classinfo) -> Generator[Incomplete]: ...
+
+class FuncIsinstanceMonad(FuncMonad):
+ func = isinstance
+ def call(monad, obj, classinfo): ...
+
+class FuncBufferMonad(FuncMonad):
+ func: type[bytes]
+ def call(monad, source, encoding=None, errors=None): ...
+
+class FuncBoolMonad(FuncMonad):
+ func: type[bool]
+ def call(monad, x): ...
+
+class FuncIntMonad(FuncMonad):
+ func: type[int]
+ def call(monad, x): ...
+
+class FuncStrMonad(FuncMonad):
+ func: type[str]
+ def call(monad, x): ...
+
+class FuncFloatMonad(FuncMonad):
+ func: type[float]
+ def call(monad, x): ...
+
+class FuncDecimalMonad(FuncMonad):
+ func: type[Decimal]
+ def call(monad, x): ...
+
+class FuncDateMonad(FuncMonad):
+ func: type[date]
+ def call(monad, year, month, day): ...
+ def call_today(monad): ...
+
+class FuncTimeMonad(FuncMonad):
+ func: type[time]
+ def call(monad, *args): ...
+
+class FuncTimedeltaMonad(FuncMonad):
+ func: type[timedelta]
+ def call(monad, days=None, seconds=None, microseconds=None, milliseconds=None, minutes=None, hours=None, weeks=None): ...
+
+class FuncDatetimeMonad(FuncDateMonad):
+ func: type[datetime]
+ def call(monad, year, month, day, hour=None, minute=None, second=None, microsecond=None): ...
+ def call_now(monad): ...
+
+class FuncBetweenMonad(FuncMonad):
+ func = between
+ def call(monad, x, a, b): ...
+
+class FuncConcatMonad(FuncMonad):
+ func = concat
+ def call(monad, *args): ...
+
+class FuncLenMonad(FuncMonad):
+ func = len
+ def call(monad, x): ...
+
+class FuncGetattrMonad(FuncMonad):
+ func = getattr
+ def call(monad, obj_monad, name_monad): ...
+
+class FuncRawSQLMonad(FuncMonad):
+ func = raw_sql
+ def call(monad, *args) -> None: ...
+
+class FuncCountMonad(FuncMonad):
+ func: Incomplete
+ def call(monad, x=None, distinct=None): ...
+
+class FuncAbsMonad(FuncMonad):
+ func = abs
+ def call(monad, x): ...
+
+class FuncSumMonad(FuncMonad):
+ func: Incomplete
+ def call(monad, x, distinct=None): ...
+
+class FuncAvgMonad(FuncMonad):
+ func: Incomplete
+ def call(monad, x, distinct=None): ...
+
+class FuncGroupConcatMonad(FuncMonad):
+ func: Incomplete
+ def call(monad, x, sep=None, distinct=None): ...
+
+class FuncCoalesceMonad(FuncMonad):
+ func = coalesce
+ def call(monad, *args): ...
+
+class FuncDistinctMonad(FuncMonad):
+ func: Incomplete
+ def call(monad, x): ...
+
+class FuncMinMonad(FuncMonad):
+ func: Incomplete
+ def call(monad, *args): ...
+
+class FuncMaxMonad(FuncMonad):
+ func: Incomplete
+ def call(monad, *args): ...
+
+def minmax(monad, sqlop, *args): ...
+
+class FuncSelectMonad(FuncMonad):
+ func = core.select
+ def call(monad, queryset): ...
+
+class FuncExistsMonad(FuncMonad):
+ func = core.exists
+ def call(monad, arg): ...
+
+class FuncDescMonad(FuncMonad):
+ func = core.desc
+ def call(monad, expr): ...
+
+class DescMonad(Monad):
+ def __init__(monad, expr) -> None: ...
+ def getsql(monad): ...
+
+class JoinMonad(Monad):
+ def __init__(monad, type) -> None: ...
+ def __call__(monad, x): ...
+
+class FuncRandomMonad(FuncMonad):
+ func = random
+ def __init__(monad, type) -> None: ...
+ def __call__(monad): ...
+
+class SetMixin(MonadMixin):
+ forced_distinct: bool
+ def call_distinct(monad): ...
+
+def make_attrset_binop(op, sqlop): ...
+
+class AttrSetMonad(SetMixin, Monad):
+ def __init__(monad, parent, attr) -> None: ...
+ def cmp(monad, op, monad2) -> None: ...
+ def contains(monad, item, not_in: bool = False): ...
+ def getattr(monad, name): ...
+ def call_select(monad): ...
+ call_filter = call_select
+ def call_exists(monad): ...
+ def requires_distinct(monad, joined: bool = False, for_count: bool = False): ...
+ def count(monad, distinct=None): ...
+ len = count
+ def aggregate(monad, func_name, distinct=None, sep=None): ...
+ def nonzero(monad): ...
+ def negate(monad): ...
+ call_is_empty = negate
+ def make_tableref(monad, sqlquery): ...
+ def make_expr_list(monad): ...
+ def getsql(monad, sqlquery=None): ...
+ __add__: Incomplete
+ __sub__: Incomplete
+ __mul__: Incomplete
+ __truediv__: Incomplete
+ __floordiv__: Incomplete
+
+def make_numericset_binop(op, sqlop): ...
+
+class NumericSetExprMonad(SetMixin, Monad):
+ def __init__(monad, op, sqlop, left, right) -> None: ...
+ def aggregate(monad, func_name, distinct=None, sep=None): ...
+ def getsql(monad, sqlquery=None): ...
+ __add__: Incomplete
+ __sub__: Incomplete
+ __mul__: Incomplete
+ __truediv__: Incomplete
+ __floordiv__: Incomplete
+
+class QuerySetMonad(SetMixin, Monad):
+ nogroup: bool
+ def __init__(monad, subtranslator) -> None: ...
+ def to_single_cell_value(monad): ...
+ def requires_distinct(monad, joined: bool = False) -> None: ...
+ def call_limit(monad, limit=None, offset=None): ...
+ def contains(monad, item, not_in: bool = False): ...
+ def nonzero(monad): ...
+ def negate(monad): ...
+ def count(monad, distinct=None): ...
+ len = count
+ def aggregate(monad, func_name, distinct=None, sep=None): ...
+ def call_count(monad, distinct=None): ...
+ def call_sum(monad, distinct=None): ...
+ def call_min(monad): ...
+ def call_max(monad): ...
+ def call_avg(monad, distinct=None): ...
+ def call_group_concat(monad, sep=None, distinct=None): ...
+ def getsql(monad): ...
+
+def find_or_create_having_ast(sections: list[Sequence[str]]): ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/py23compat.pyi b/python/helpers/typeshed/stubs/pony/pony/py23compat.pyi
new file mode 100644
index 000000000000..0854571aa135
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/py23compat.pyi
@@ -0,0 +1,13 @@
+PYPY: bool
+PY36: bool
+PY37: bool
+PY38: bool
+PY39: bool
+PY310: bool
+PY311: bool
+PY312: bool
+unicode = str
+buffer = bytes
+int_types: tuple[type[int]]
+
+def cmp(a, b): ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/thirdparty/__init__.pyi b/python/helpers/typeshed/stubs/pony/pony/thirdparty/__init__.pyi
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/python/helpers/typeshed/stubs/pony/pony/thirdparty/decorator.pyi b/python/helpers/typeshed/stubs/pony/pony/thirdparty/decorator.pyi
new file mode 100644
index 000000000000..1f521275e4a8
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/thirdparty/decorator.pyi
@@ -0,0 +1,31 @@
+import re
+from _typeshed import Incomplete
+from collections.abc import Callable
+from inspect import getfullargspec as getfullargspec
+from typing import Final
+
+__version__: Final[str]
+__all__ = ["decorator", "FunctionMaker", "contextmanager"]
+
+def get_init(cls: object) -> Callable[..., None]: ...
+
+DEF: re.Pattern[str]
+
+class FunctionMaker:
+ shortsignature: Incomplete
+ name: Incomplete
+ doc: Incomplete
+ module: Incomplete
+ annotations: Incomplete
+ signature: Incomplete
+ dict: Incomplete
+ defaults: Incomplete
+ def __init__(self, func=None, name=None, signature=None, defaults=None, doc=None, module=None, funcdict=None) -> None: ...
+ def update(self, func, **kw) -> None: ...
+ def make(self, src_templ, evaldict=None, addsource: bool = False, **attrs): ...
+ @classmethod
+ def create(cls, obj, body, evaldict, defaults=None, doc=None, module=None, addsource: bool = True, **attrs): ...
+
+def decorator(caller, func=None): ...
+
+contextmanager: Incomplete
diff --git a/python/helpers/typeshed/stubs/pony/pony/utils/__init__.pyi b/python/helpers/typeshed/stubs/pony/pony/utils/__init__.pyi
new file mode 100644
index 000000000000..f08d95e954ed
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/utils/__init__.pyi
@@ -0,0 +1,2 @@
+from .properties import *
+from .utils import *
diff --git a/python/helpers/typeshed/stubs/pony/pony/utils/properties.pyi b/python/helpers/typeshed/stubs/pony/pony/utils/properties.pyi
new file mode 100644
index 000000000000..912a26d34900
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/utils/properties.pyi
@@ -0,0 +1,16 @@
+from _typeshed import Incomplete
+
+class cached_property:
+ func: Incomplete
+ def __init__(self, func) -> None: ...
+ def __get__(self, obj, cls): ...
+
+class class_property:
+ func: Incomplete
+ def __init__(self, func) -> None: ...
+ def __get__(self, instance, cls): ...
+
+class class_cached_property:
+ func: Incomplete
+ def __init__(self, func) -> None: ...
+ def __get__(self, obj, cls): ...
diff --git a/python/helpers/typeshed/stubs/pony/pony/utils/utils.pyi b/python/helpers/typeshed/stubs/pony/pony/utils/utils.pyi
new file mode 100644
index 000000000000..79f9e6cb83b0
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pony/pony/utils/utils.pyi
@@ -0,0 +1,86 @@
+import ast
+import io
+import re
+from _typeshed import Incomplete, Unused
+from collections.abc import Callable, Iterable
+from datetime import datetime
+from threading import local as _localbase
+from types import CodeType, FunctionType, TracebackType
+from typing import Any, NoReturn, overload
+
+localbase = _localbase
+
+class PonyDeprecationWarning(DeprecationWarning): ...
+
+def deprecated(stacklevel: int, message: str) -> None: ...
+def decorator(caller, func=None): ...
+def decorator_with_params(dec): ...
+def cut_traceback(func): ...
+
+cut_traceback_depth: int
+
+@overload
+def reraise(exc_type: Unused, exc: None, tb: TracebackType | None) -> None: ...
+@overload
+def reraise(exc_type: Unused, exc: BaseException, tb: TracebackType | None) -> NoReturn: ...
+def throw(exc_type: Exception | Callable[..., Exception], *args, **kwargs) -> NoReturn: ...
+def truncate_repr(s: object, max_len: int = 100) -> str: ...
+
+codeobjects: dict[int, CodeType]
+
+def get_codeobject_id(codeobject: CodeType) -> int: ...
+
+lambda_args_cache: dict[int | ast.Lambda, list[str]]
+
+def get_lambda_args(func: FunctionType | ast.Lambda) -> list[str]: ...
+def error_method(*args: Unused, **kwargs: Unused) -> NoReturn: ...
+def is_ident(string: str) -> bool: ...
+def split_name(name: str) -> list[str]: ...
+def uppercase_name(name: str) -> str: ...
+def lowercase_name(name: str) -> str: ...
+def camelcase_name(name: str) -> str: ...
+def mixedcase_name(name: str) -> str: ...
+def import_module(name: str): ...
+def is_absolute_path(filename: str) -> bool: ...
+def absolutize_path(filename: str, frame_depth: int) -> str: ...
+def current_timestamp() -> str: ...
+def datetime2timestamp(d: datetime) -> str: ...
+def timestamp2datetime(t: str) -> datetime: ...
+
+expr1_re: re.Pattern[str]
+expr2_re: re.Pattern[str]
+expr3_re: re.Pattern[str]
+
+def parse_expr(s: str, pos: int = 0) -> tuple[str, bool]: ...
+def tostring(x): ...
+def strjoin(
+ sep: str, strings: Iterable[str], source_encoding: str = "ascii", dest_encoding: str | None = None
+) -> str | bytes: ...
+def count(*args, **kwargs): ...
+def avg(iter: Iterable[float | None]) -> float | None: ...
+@overload
+def group_concat(items: None, sep: str = ",") -> None: ...
+@overload
+def group_concat(items: Iterable[object], sep: str = ",") -> str: ...
+def coalesce(*args: Any) -> Any: ...
+def distinct(iter): ...
+def concat(*args) -> str: ...
+def between(x: float, a: float, b: float) -> bool: ...
+def is_utf8(encoding: str) -> bool: ...
+def pickle_ast(val): ...
+def unpickle_ast(pickled: io.BytesIO): ...
+def copy_ast(tree): ...
+
+class HashableDict(dict[Incomplete, Incomplete]):
+ def __hash__(self) -> int: ... # type: ignore[override]
+ def __deepcopy__(self, memo): ...
+ __setitem__: Incomplete
+ __delitem__: Incomplete
+ clear: Incomplete
+ pop: Incomplete
+ popitem: Incomplete
+ setdefault: Incomplete
+ update: Incomplete
+
+def deref_proxy(value): ...
+def deduplicate(value, deduplication_cache): ...
diff --git a/python/helpers/typeshed/stubs/protobuf/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/protobuf/@tests/stubtest_allowlist.txt
index 1d7f7f7a98d6..08d9389d4263 100644
--- a/python/helpers/typeshed/stubs/protobuf/@tests/stubtest_allowlist.txt
+++ b/python/helpers/typeshed/stubs/protobuf/@tests/stubtest_allowlist.txt
@@ -31,3 +31,7 @@ google.protobuf.descriptor.OneofDescriptor
# Runtime does not have __iter__ (yet...): hack in spirit of https://github.com/python/typeshed/issues/7813
google.protobuf.internal.well_known_types.ListValue.__iter__
+
+# It's a list at runtime, but if we do that pyright complains about incompatible overrides
+# in subclasses that use a tuple for __slots__.
+google.protobuf.message.Message.__slots__
diff --git a/python/helpers/typeshed/stubs/protobuf/google/_upb/_message.pyi b/python/helpers/typeshed/stubs/protobuf/google/_upb/_message.pyi
index bb188bcbf4f1..dd741f8a034c 100644
--- a/python/helpers/typeshed/stubs/protobuf/google/_upb/_message.pyi
+++ b/python/helpers/typeshed/stubs/protobuf/google/_upb/_message.pyi
@@ -78,18 +78,18 @@ class EnumValueDescriptor:
@final
class ExtensionDict:
- def __contains__(self, other) -> bool: ...
- def __delitem__(self, other) -> None: ...
- def __eq__(self, other: object) -> bool: ...
- def __ge__(self, other: object) -> bool: ...
- def __getitem__(self, index): ...
- def __gt__(self, other: object) -> bool: ...
+ def __contains__(self, other, /) -> bool: ...
+ def __delitem__(self, other, /) -> None: ...
+ def __eq__(self, other: object, /) -> bool: ...
+ def __ge__(self, other: object, /) -> bool: ...
+ def __getitem__(self, index, /): ...
+ def __gt__(self, other: object, /) -> bool: ...
def __iter__(self): ...
- def __le__(self, other: object) -> bool: ...
+ def __le__(self, other: object, /) -> bool: ...
def __len__(self) -> int: ...
- def __lt__(self, other: object) -> bool: ...
- def __ne__(self, other: object) -> bool: ...
- def __setitem__(self, index, object) -> None: ...
+ def __lt__(self, other: object, /) -> bool: ...
+ def __ne__(self, other: object, /) -> bool: ...
+ def __setitem__(self, index, object, /) -> None: ...
@final
class ExtensionIterator:
@@ -201,16 +201,16 @@ class Message:
def SetInParent(self): ...
def UnknownFields(self): ...
def WhichOneof(self, object, /): ...
- def __contains__(self, other) -> bool: ...
+ def __contains__(self, other, /) -> bool: ...
def __deepcopy__(self, memo=None): ...
- def __delattr__(self, name): ...
- def __eq__(self, other: object) -> bool: ...
- def __ge__(self, other: object) -> bool: ...
- def __gt__(self, other: object) -> bool: ...
- def __le__(self, other: object) -> bool: ...
- def __lt__(self, other: object) -> bool: ...
- def __ne__(self, other: object) -> bool: ...
- def __setattr__(self, name, value): ...
+ def __delattr__(self, name, /): ...
+ def __eq__(self, other: object, /) -> bool: ...
+ def __ge__(self, other: object, /) -> bool: ...
+ def __gt__(self, other: object, /) -> bool: ...
+ def __le__(self, other: object, /) -> bool: ...
+ def __lt__(self, other: object, /) -> bool: ...
+ def __ne__(self, other: object, /) -> bool: ...
+ def __setattr__(self, name, value, /): ...
@final
class MessageMeta(type): ...
@@ -253,16 +253,16 @@ class RepeatedCompositeContainer:
def reverse(self): ...
def sort(self, *args, **kwargs): ... # incomplete
def __deepcopy__(self, memo=None): ...
- def __delitem__(self, other) -> None: ...
- def __eq__(self, other: object) -> bool: ...
- def __ge__(self, other: object) -> bool: ...
- def __getitem__(self, index): ...
- def __gt__(self, other: object) -> bool: ...
- def __le__(self, other: object) -> bool: ...
+ def __delitem__(self, other, /) -> None: ...
+ def __eq__(self, other: object, /) -> bool: ...
+ def __ge__(self, other: object, /) -> bool: ...
+ def __getitem__(self, index, /): ...
+ def __gt__(self, other: object, /) -> bool: ...
+ def __le__(self, other: object, /) -> bool: ...
def __len__(self) -> int: ...
- def __lt__(self, other: object) -> bool: ...
- def __ne__(self, other: object) -> bool: ...
- def __setitem__(self, index, object) -> None: ...
+ def __lt__(self, other: object, /) -> bool: ...
+ def __ne__(self, other: object, /) -> bool: ...
+ def __setitem__(self, index, object, /) -> None: ...
@final
class RepeatedScalarContainer:
@@ -276,17 +276,17 @@ class RepeatedScalarContainer:
def reverse(self): ...
def sort(self, *args, **kwargs): ... # incomplete
def __deepcopy__(self, memo=None): ...
- def __delitem__(self, other) -> None: ...
- def __eq__(self, other: object) -> bool: ...
- def __ge__(self, other: object) -> bool: ...
- def __getitem__(self, index): ...
- def __gt__(self, other: object) -> bool: ...
- def __le__(self, other: object) -> bool: ...
+ def __delitem__(self, other, /) -> None: ...
+ def __eq__(self, other: object, /) -> bool: ...
+ def __ge__(self, other: object, /) -> bool: ...
+ def __getitem__(self, index, /): ...
+ def __gt__(self, other: object, /) -> bool: ...
+ def __le__(self, other: object, /) -> bool: ...
def __len__(self) -> int: ...
- def __lt__(self, other: object) -> bool: ...
- def __ne__(self, other: object) -> bool: ...
+ def __lt__(self, other: object, /) -> bool: ...
+ def __ne__(self, other: object, /) -> bool: ...
def __reduce__(self): ...
- def __setitem__(self, index, object) -> None: ...
+ def __setitem__(self, index, object, /) -> None: ...
@final
class ServiceDescriptor:
@@ -304,7 +304,7 @@ class ServiceDescriptor:
@final
class UnknownFieldSet:
def __init__(self, *args, **kwargs) -> None: ... # incomplete
- def __getitem__(self, index): ...
+ def __getitem__(self, index, /): ...
def __len__(self) -> int: ...
def SetAllowOversizeProtos(object, /): ... # incomplete
diff --git a/python/helpers/typeshed/stubs/protobuf/google/protobuf/internal/containers.pyi b/python/helpers/typeshed/stubs/protobuf/google/protobuf/internal/containers.pyi
index 75261371607e..bdcd5208b9d6 100644
--- a/python/helpers/typeshed/stubs/protobuf/google/protobuf/internal/containers.pyi
+++ b/python/helpers/typeshed/stubs/protobuf/google/protobuf/internal/containers.pyi
@@ -1,5 +1,5 @@
from collections.abc import Callable, Iterable, Iterator, MutableMapping, Sequence
-from typing import Any, Protocol, SupportsIndex, TypeVar, overload
+from typing import Any, Protocol, SupportsIndex, TypeVar, overload, type_check_only
from typing_extensions import Self
from google.protobuf.descriptor import Descriptor
@@ -12,11 +12,13 @@ _K = TypeVar("_K", bound=bool | int | str)
_ScalarV = TypeVar("_ScalarV", bound=bool | int | float | str | bytes)
_MessageV = TypeVar("_MessageV", bound=Message)
+@type_check_only
class _ValueChecker(Protocol[_T]):
def CheckValue(self, proposed_value: _T) -> _T: ...
def DefaultValue(self) -> _T: ...
class BaseContainer(Sequence[_T]):
+ __slots__ = ["_message_listener", "_values"]
def __init__(self, message_listener: MessageListener) -> None: ...
def __len__(self) -> int: ...
def __ne__(self, other: object) -> bool: ...
@@ -29,6 +31,7 @@ class BaseContainer(Sequence[_T]):
def __getitem__(self, key: slice) -> list[_T]: ...
class RepeatedScalarFieldContainer(BaseContainer[_ScalarV]):
+ __slots__ = ["_type_checker"]
def __init__(self, message_listener: MessageListener, type_checker: _ValueChecker[_ScalarV]) -> None: ...
def append(self, value: _ScalarV) -> None: ...
def insert(self, key: int, value: _ScalarV) -> None: ...
@@ -44,6 +47,7 @@ class RepeatedScalarFieldContainer(BaseContainer[_ScalarV]):
def __eq__(self, other: object) -> bool: ...
class RepeatedCompositeFieldContainer(BaseContainer[_MessageV]):
+ __slots__ = ["_message_descriptor"]
def __init__(self, message_listener: MessageListener, message_descriptor: Descriptor) -> None: ...
def add(self, **kwargs: Any) -> _MessageV: ...
def append(self, value: _MessageV) -> None: ...
@@ -56,6 +60,7 @@ class RepeatedCompositeFieldContainer(BaseContainer[_MessageV]):
def __eq__(self, other: object) -> bool: ...
class ScalarMap(MutableMapping[_K, _ScalarV]):
+ __slots__ = ["_key_checker", "_value_checker", "_values", "_message_listener", "_entry_descriptor"]
def __init__(
self,
message_listener: MessageListener,
@@ -72,13 +77,16 @@ class ScalarMap(MutableMapping[_K, _ScalarV]):
@overload
def get(self, key: _K, default: None = None) -> _ScalarV | None: ...
@overload
- def get(self, key: _K, default: _ScalarV | _T) -> _ScalarV | _T: ...
+ def get(self, key: _K, default: _ScalarV) -> _ScalarV: ...
+ @overload
+ def get(self, key: _K, default: _T) -> _ScalarV | _T: ...
def setdefault(self, key: _K, value: _ScalarV | None = None) -> _ScalarV: ...
def MergeFrom(self, other: Self): ...
def InvalidateIterators(self) -> None: ...
def GetEntryClass(self) -> GeneratedProtocolMessageType: ...
class MessageMap(MutableMapping[_K, _MessageV]):
+ __slots__ = ["_key_checker", "_values", "_message_listener", "_message_descriptor", "_entry_descriptor"]
def __init__(
self,
message_listener: MessageListener,
@@ -95,7 +103,9 @@ class MessageMap(MutableMapping[_K, _MessageV]):
@overload
def get(self, key: _K, default: None = None) -> _MessageV | None: ...
@overload
- def get(self, key: _K, default: _MessageV | _T) -> _MessageV | _T: ...
+ def get(self, key: _K, default: _MessageV) -> _MessageV: ...
+ @overload
+ def get(self, key: _K, default: _T) -> _MessageV | _T: ...
def get_or_create(self, key: _K) -> _MessageV: ...
def setdefault(self, key: _K, value: _MessageV | None = None) -> _MessageV: ...
def MergeFrom(self, other: Self): ...
diff --git a/python/helpers/typeshed/stubs/protobuf/google/protobuf/internal/enum_type_wrapper.pyi b/python/helpers/typeshed/stubs/protobuf/google/protobuf/internal/enum_type_wrapper.pyi
index 95b5b4bb2566..ca207f214950 100644
--- a/python/helpers/typeshed/stubs/protobuf/google/protobuf/internal/enum_type_wrapper.pyi
+++ b/python/helpers/typeshed/stubs/protobuf/google/protobuf/internal/enum_type_wrapper.pyi
@@ -1,4 +1,4 @@
-from typing import Generic, TypeVar
+from typing import Generic, TypeVar, type_check_only
from google.protobuf.descriptor import EnumDescriptor
@@ -9,6 +9,7 @@ _V = TypeVar("_V", bound=int)
# NOTE: this doesn't actually inherit from type,
# but mypy doesn't support metaclasses that don't inherit from type,
# so we pretend it does in the stubs...
+@type_check_only
class _EnumTypeWrapper(type, Generic[_V]):
DESCRIPTOR: EnumDescriptor
def __init__(self, enum_type: EnumDescriptor) -> None: ...
diff --git a/python/helpers/typeshed/stubs/protobuf/google/protobuf/internal/extension_dict.pyi b/python/helpers/typeshed/stubs/protobuf/google/protobuf/internal/extension_dict.pyi
index ecf56a360d20..3071e4aa2ade 100644
--- a/python/helpers/typeshed/stubs/protobuf/google/protobuf/internal/extension_dict.pyi
+++ b/python/helpers/typeshed/stubs/protobuf/google/protobuf/internal/extension_dict.pyi
@@ -1,5 +1,5 @@
from collections.abc import Iterator
-from typing import Any, Generic, TypeVar
+from typing import Any, Generic, TypeVar, type_check_only
from google.protobuf.descriptor import FieldDescriptor
from google.protobuf.internal.containers import RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer
@@ -11,6 +11,7 @@ _ExtenderMessageT = TypeVar(
bound=Message | RepeatedScalarFieldContainer[Any] | RepeatedCompositeFieldContainer[Any] | bool | float | str | bytes,
)
+@type_check_only
class _ExtensionFieldDescriptor(FieldDescriptor, Generic[_ContainerMessageT, _ExtenderMessageT]): ...
class _ExtensionDict(Generic[_ContainerMessageT]):
diff --git a/python/helpers/typeshed/stubs/protobuf/google/protobuf/internal/well_known_types.pyi b/python/helpers/typeshed/stubs/protobuf/google/protobuf/internal/well_known_types.pyi
index 4ed2f895c762..69649998db4f 100644
--- a/python/helpers/typeshed/stubs/protobuf/google/protobuf/internal/well_known_types.pyi
+++ b/python/helpers/typeshed/stubs/protobuf/google/protobuf/internal/well_known_types.pyi
@@ -7,6 +7,7 @@ from typing_extensions import TypeAlias
from google.protobuf import struct_pb2
class Any:
+ __slots__ = ()
type_url: str
value: Incomplete
def Pack(self, msg, type_url_prefix: str = "type.googleapis.com/", deterministic=None) -> None: ...
@@ -15,6 +16,7 @@ class Any:
def Is(self, descriptor) -> bool: ...
class Timestamp:
+ __slots__ = ()
def ToJsonString(self) -> str: ...
seconds: int
nanos: int
@@ -32,6 +34,7 @@ class Timestamp:
def FromDatetime(self, dt: datetime) -> None: ...
class Duration:
+ __slots__ = ()
def ToJsonString(self) -> str: ...
seconds: int
nanos: int
@@ -48,6 +51,7 @@ class Duration:
def FromTimedelta(self, td: timedelta) -> None: ...
class FieldMask:
+ __slots__ = ()
def ToJsonString(self) -> str: ...
def FromJsonString(self, value: tAny) -> None: ...
def IsValidForDescriptor(self, message_descriptor: tAny): ...
@@ -59,19 +63,11 @@ class FieldMask:
self, source: tAny, destination: tAny, replace_message_field: bool = False, replace_repeated_field: bool = False
) -> None: ...
-class _FieldMaskTree:
- def __init__(self, field_mask: Incomplete | None = ...) -> None: ...
- def MergeFromFieldMask(self, field_mask: tAny) -> None: ...
- def AddPath(self, path: tAny): ...
- def ToFieldMask(self, field_mask: tAny) -> None: ...
- def IntersectPath(self, path: tAny, intersection: tAny): ...
- def AddLeafNodes(self, prefix: tAny, node: tAny) -> None: ...
- def MergeMessage(self, source: tAny, destination: tAny, replace_message: tAny, replace_repeated: tAny) -> None: ...
-
_StructValue: TypeAlias = struct_pb2.Struct | struct_pb2.ListValue | str | float | bool | None
_StructValueArg: TypeAlias = _StructValue | Mapping[str, _StructValueArg] | Sequence[_StructValueArg]
class Struct:
+ __slots__: tuple[()] = ()
def __getitem__(self, key: str) -> _StructValue: ...
def __setitem__(self, key: str, value: _StructValueArg) -> None: ...
def __delitem__(self, key: str) -> None: ...
@@ -85,6 +81,7 @@ class Struct:
def update(self, dictionary: SupportsItems[str, _StructValueArg]) -> None: ...
class ListValue:
+ __slots__: tuple[()] = ()
def __len__(self) -> int: ...
def append(self, value: _StructValue) -> None: ...
def extend(self, elem_seq: Iterable[_StructValue]) -> None: ...
diff --git a/python/helpers/typeshed/stubs/protobuf/google/protobuf/message.pyi b/python/helpers/typeshed/stubs/protobuf/google/protobuf/message.pyi
index ea1d636ee261..73eb6b411e41 100644
--- a/python/helpers/typeshed/stubs/protobuf/google/protobuf/message.pyi
+++ b/python/helpers/typeshed/stubs/protobuf/google/protobuf/message.pyi
@@ -12,6 +12,7 @@ class DecodeError(Error): ...
class EncodeError(Error): ...
class Message:
+ __slots__: tuple[()] = ()
DESCRIPTOR: Descriptor | _upb_Descriptor
def __deepcopy__(self, memo: Any = None) -> Self: ...
def __eq__(self, other_msg): ...
diff --git a/python/helpers/typeshed/stubs/psutil/METADATA.toml b/python/helpers/typeshed/stubs/psutil/METADATA.toml
index 9832d06c03a9..85e2bcc2e4e8 100644
--- a/python/helpers/typeshed/stubs/psutil/METADATA.toml
+++ b/python/helpers/typeshed/stubs/psutil/METADATA.toml
@@ -2,4 +2,4 @@ version = "7.0.*"
upstream_repository = "https://github.com/giampaolo/psutil"
[tool.stubtest]
-platforms = ["darwin", "linux", "win32"]
+ci_platforms = ["darwin", "linux", "win32"]
diff --git a/python/helpers/typeshed/stubs/psutil/psutil/__init__.pyi b/python/helpers/typeshed/stubs/psutil/psutil/__init__.pyi
index f17d3ac7057e..5c6778fa3fba 100644
--- a/python/helpers/typeshed/stubs/psutil/psutil/__init__.pyi
+++ b/python/helpers/typeshed/stubs/psutil/psutil/__init__.pyi
@@ -244,11 +244,11 @@ def wait_procs(
) -> tuple[list[Process], list[Process]]: ...
def cpu_count(logical: bool = True) -> int | None: ...
@overload
-def cpu_freq(percpu: Literal[False] = ...) -> scpufreq: ...
+def cpu_freq(percpu: Literal[False] = False) -> scpufreq: ...
@overload
def cpu_freq(percpu: Literal[True]) -> list[scpufreq]: ...
@overload
-def cpu_times(percpu: Literal[False] = ...) -> scputimes: ...
+def cpu_times(percpu: Literal[False] = False) -> scputimes: ...
@overload
def cpu_times(percpu: Literal[True]) -> list[scputimes]: ...
@overload
diff --git a/python/helpers/typeshed/stubs/psutil/psutil/_psosx.pyi b/python/helpers/typeshed/stubs/psutil/psutil/_psosx.pyi
index 075aba89aef9..dee1fd6ed291 100644
--- a/python/helpers/typeshed/stubs/psutil/psutil/_psosx.pyi
+++ b/python/helpers/typeshed/stubs/psutil/psutil/_psosx.pyi
@@ -61,13 +61,13 @@ def cpu_freq(): ...
disk_usage: Any
disk_io_counters: Any
-def disk_partitions(all: bool = ...): ...
+def disk_partitions(all: bool = False): ...
def sensors_battery(): ...
net_io_counters: Any
net_if_addrs: Any
-def net_connections(kind: str = ...): ...
+def net_connections(kind: str = "inet"): ...
def net_if_stats(): ...
def boot_time(): ...
def users(): ...
@@ -79,6 +79,7 @@ def is_zombie(pid): ...
def wrap_exceptions(fun): ...
class Process:
+ __slots__ = ["_cache", "_name", "_ppid", "pid"]
pid: Any
def __init__(self, pid) -> None: ...
def oneshot_enter(self) -> None: ...
@@ -99,9 +100,9 @@ class Process:
def num_ctx_switches(self): ...
def num_threads(self): ...
def open_files(self): ...
- def net_connections(self, kind: str = ...): ...
+ def net_connections(self, kind: str = "inet"): ...
def num_fds(self): ...
- def wait(self, timeout: Incomplete | None = ...): ...
+ def wait(self, timeout=None): ...
def nice_get(self): ...
def nice_set(self, value): ...
def status(self): ...
diff --git a/python/helpers/typeshed/stubs/psycopg2/psycopg2/_psycopg.pyi b/python/helpers/typeshed/stubs/psycopg2/psycopg2/_psycopg.pyi
index abb744901c03..3a1b46606cbd 100644
--- a/python/helpers/typeshed/stubs/psycopg2/psycopg2/_psycopg.pyi
+++ b/python/helpers/typeshed/stubs/psycopg2/psycopg2/_psycopg.pyi
@@ -66,6 +66,7 @@ UNKNOWN: _type
REPLICATION_LOGICAL: int
REPLICATION_PHYSICAL: int
+@type_check_only
class _ISQLQuoteProto(Protocol):
# Objects conforming this protocol should implement a getquoted() and optionally a prepare() method.
# The real ISQLQuote class is implemented below with more stuff.
@@ -85,6 +86,7 @@ __libpq_version__: int
_T_co = TypeVar("_T_co", covariant=True)
+@type_check_only
class _SupportsReadAndReadline(SupportsRead[_T_co], SupportsReadline[_T_co], Protocol[_T_co]): ...
class cursor:
@@ -207,7 +209,7 @@ class Column:
def __len__(self) -> int: ...
def __lt__(self, other, /): ...
def __ne__(self, other, /): ...
- def __setstate__(self, state): ...
+ def __setstate__(self, state, /): ...
class ConnectionInfo:
# Note: the following properties can be None if their corresponding libpq function
@@ -275,7 +277,7 @@ class Error(Exception):
pgerror: str | None
def __init__(self, *args, **kwargs) -> None: ...
def __reduce__(self): ...
- def __setstate__(self, state): ...
+ def __setstate__(self, state, /): ...
class DatabaseError(Error): ...
class DataError(DatabaseError): ...
diff --git a/python/helpers/typeshed/stubs/psycopg2/psycopg2/extras.pyi b/python/helpers/typeshed/stubs/psycopg2/psycopg2/extras.pyi
index 2c0587efa00d..97c67b40863a 100644
--- a/python/helpers/typeshed/stubs/psycopg2/psycopg2/extras.pyi
+++ b/python/helpers/typeshed/stubs/psycopg2/psycopg2/extras.pyi
@@ -15,6 +15,7 @@ from psycopg2._psycopg import (
ReplicationConnection as _replicationConnection,
ReplicationCursor as _replicationCursor,
ReplicationMessage as ReplicationMessage,
+ _Vars,
connection as _connection,
cursor as _cursor,
quote_ident as quote_ident,
@@ -29,6 +30,7 @@ from psycopg2._range import (
RangeCaster as RangeCaster,
register_range as register_range,
)
+from psycopg2.sql import Composable
_T_cur = TypeVar("_T_cur", bound=_cursor)
@@ -106,7 +108,7 @@ class RealDictConnection(_connection):
class RealDictCursor(DictCursorBase):
def __init__(self, *args, **kwargs) -> None: ...
column_mapping: Any
- def execute(self, query, vars=None): ...
+ def execute(self, query: str | bytes | Composable, vars: _Vars = None) -> None: ...
def callproc(self, procname, vars=None): ...
def fetchone(self) -> RealDictRow | None: ... # type: ignore[override]
def fetchmany(self, size: int | None = None) -> list[RealDictRow]: ... # type: ignore[override]
diff --git a/python/helpers/typeshed/stubs/pyaudio/METADATA.toml b/python/helpers/typeshed/stubs/pyaudio/METADATA.toml
index 68f013087238..d05035bf5989 100644
--- a/python/helpers/typeshed/stubs/pyaudio/METADATA.toml
+++ b/python/helpers/typeshed/stubs/pyaudio/METADATA.toml
@@ -4,6 +4,6 @@ version = "0.2.*"
[tool.stubtest]
# linux and win32 are equivalent
-platforms = ["darwin", "linux"]
+ci_platforms = ["darwin", "linux"]
apt_dependencies = ["portaudio19-dev"]
brew_dependencies = ["portaudio"]
diff --git a/python/helpers/typeshed/stubs/pycocotools/pycocotools/__init__.pyi b/python/helpers/typeshed/stubs/pycocotools/pycocotools/__init__.pyi
index 04adef9dad84..129b5a07c312 100644
--- a/python/helpers/typeshed/stubs/pycocotools/pycocotools/__init__.pyi
+++ b/python/helpers/typeshed/stubs/pycocotools/pycocotools/__init__.pyi
@@ -1,6 +1,7 @@
-from typing import TypedDict
+from typing import TypedDict, type_check_only
# Unused in this module, but imported in multiple submodules.
+@type_check_only
class _EncodedRLE(TypedDict): # noqa: Y049
size: list[int]
counts: str | bytes
diff --git a/python/helpers/typeshed/stubs/pycocotools/pycocotools/coco.pyi b/python/helpers/typeshed/stubs/pycocotools/pycocotools/coco.pyi
index dfb4b3ca4c7c..2dc2f2e35ca4 100644
--- a/python/helpers/typeshed/stubs/pycocotools/pycocotools/coco.pyi
+++ b/python/helpers/typeshed/stubs/pycocotools/pycocotools/coco.pyi
@@ -1,6 +1,6 @@
from collections.abc import Collection, Sequence
from pathlib import Path
-from typing import Generic, Literal, TypedDict, TypeVar, overload
+from typing import Generic, Literal, TypedDict, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
import numpy as np
@@ -10,6 +10,7 @@ from . import _EncodedRLE
PYTHON_VERSION: int
+@type_check_only
class _Image(TypedDict):
id: int
width: int
@@ -18,10 +19,12 @@ class _Image(TypedDict):
_TPolygonSegmentation: TypeAlias = list[list[float]]
+@type_check_only
class _RLE(TypedDict):
size: list[int]
counts: list[int]
+@type_check_only
class _Annotation(TypedDict):
id: int
image_id: int
@@ -33,6 +36,7 @@ class _Annotation(TypedDict):
_TSeg = TypeVar("_TSeg", _TPolygonSegmentation, _RLE, _EncodedRLE)
+@type_check_only
class _AnnotationG(TypedDict, Generic[_TSeg]):
id: int
image_id: int
@@ -42,11 +46,13 @@ class _AnnotationG(TypedDict, Generic[_TSeg]):
bbox: list[float]
iscrowd: int
+@type_check_only
class _Category(TypedDict):
id: int
name: str
supercategory: str
+@type_check_only
class _Dataset(TypedDict):
images: list[_Image]
annotations: list[_Annotation]
diff --git a/python/helpers/typeshed/stubs/pycocotools/pycocotools/cocoeval.pyi b/python/helpers/typeshed/stubs/pycocotools/pycocotools/cocoeval.pyi
index 262b9dc3f8dd..e402feaf4214 100644
--- a/python/helpers/typeshed/stubs/pycocotools/pycocotools/cocoeval.pyi
+++ b/python/helpers/typeshed/stubs/pycocotools/pycocotools/cocoeval.pyi
@@ -1,4 +1,4 @@
-from typing import Literal, TypedDict
+from typing import Literal, TypedDict, type_check_only
from typing_extensions import TypeAlias
import numpy as np
@@ -9,6 +9,7 @@ from .coco import COCO
_NDFloatArray: TypeAlias = npt.NDArray[np.float64]
_TIOU: TypeAlias = Literal["segm", "bbox", "keypoints"]
+@type_check_only
class _ImageEvaluationResult(TypedDict):
image_id: int
category_id: int
@@ -22,6 +23,7 @@ class _ImageEvaluationResult(TypedDict):
gtIgnore: _NDFloatArray
dtIgnore: _NDFloatArray
+@type_check_only
class _EvaluationResult(TypedDict):
params: Params
counts: list[int]
diff --git a/python/helpers/typeshed/stubs/pycocotools/pycocotools/mask.pyi b/python/helpers/typeshed/stubs/pycocotools/pycocotools/mask.pyi
index 3ce14d3b1f4a..6f75c9e38f22 100644
--- a/python/helpers/typeshed/stubs/pycocotools/pycocotools/mask.pyi
+++ b/python/helpers/typeshed/stubs/pycocotools/pycocotools/mask.pyi
@@ -16,7 +16,7 @@ def iou(
gt: _NDArrayUInt32 | list[float] | list[_EncodedRLE],
pyiscrowd: list[int] | _NDArrayUInt8,
) -> list[Any] | _NDArrayFloat64: ...
-def merge(rleObjs: list[_EncodedRLE], intersect: int = ...) -> _EncodedRLE: ...
+def merge(rleObjs: list[_EncodedRLE], intersect: int = 0) -> _EncodedRLE: ...
# ignore an "overlapping overloads" error due to _NDArrayInt32 being an alias for `Incomplete` for now
@overload
diff --git a/python/helpers/typeshed/stubs/pycurl/METADATA.toml b/python/helpers/typeshed/stubs/pycurl/METADATA.toml
index d6f49acb07b0..f4c8a993b104 100644
--- a/python/helpers/typeshed/stubs/pycurl/METADATA.toml
+++ b/python/helpers/typeshed/stubs/pycurl/METADATA.toml
@@ -2,4 +2,4 @@ version = "7.45.6"
upstream_repository = "https://github.com/pycurl/pycurl"
[tool.stubtest]
-platforms = ["darwin", "linux", "win32"]
+ci_platforms = ["darwin", "linux", "win32"]
diff --git a/python/helpers/typeshed/stubs/pyflakes/METADATA.toml b/python/helpers/typeshed/stubs/pyflakes/METADATA.toml
index 2308bd579d7b..6c88c0c0ec41 100644
--- a/python/helpers/typeshed/stubs/pyflakes/METADATA.toml
+++ b/python/helpers/typeshed/stubs/pyflakes/METADATA.toml
@@ -1,2 +1,2 @@
-version = "~=3.3.2"
+version = "3.4.*"
upstream_repository = "https://github.com/PyCQA/pyflakes"
diff --git a/python/helpers/typeshed/stubs/pyflakes/pyflakes/checker.pyi b/python/helpers/typeshed/stubs/pyflakes/pyflakes/checker.pyi
index 45486100fa6c..0b87aa5a84e6 100644
--- a/python/helpers/typeshed/stubs/pyflakes/pyflakes/checker.pyi
+++ b/python/helpers/typeshed/stubs/pyflakes/pyflakes/checker.pyi
@@ -187,8 +187,13 @@ else:
if sys.version_info >= (3, 14):
_NameConstant: TypeAlias = Never
+ _TemplateStr: TypeAlias = ast.TemplateStr
+ _Interpolation: TypeAlias = ast.Interpolation
else:
_NameConstant: TypeAlias = ast.NameConstant
+ # The methods using these should never be called on Python < 3.14.
+ _TemplateStr: TypeAlias = Never
+ _Interpolation: TypeAlias = Never
class Checker:
nodeDepth: int
@@ -308,6 +313,8 @@ class Checker:
def KEYWORD(self, tree: ast.keyword, omit: _OmitType = None) -> None: ...
def FORMATTEDVALUE(self, tree: ast.FormattedValue, omit: _OmitType = None) -> None: ...
def JOINEDSTR(self, node: ast.AST) -> None: ...
+ def TEMPLATESTR(self, node: _TemplateStr) -> None: ...
+ def INTERPOLATION(self, tree: _Interpolation, omit: _OmitType = None) -> None: ...
def DICT(self, node: ast.Dict) -> None: ...
def IF(self, node: ast.If) -> None: ...
def IFEXP(self, node: ast.If) -> None: ...
diff --git a/python/helpers/typeshed/stubs/pyflakes/pyflakes/messages.pyi b/python/helpers/typeshed/stubs/pyflakes/pyflakes/messages.pyi
index cb7c3833a8d1..4db703f30c7c 100644
--- a/python/helpers/typeshed/stubs/pyflakes/pyflakes/messages.pyi
+++ b/python/helpers/typeshed/stubs/pyflakes/pyflakes/messages.pyi
@@ -101,6 +101,7 @@ class RaiseNotImplemented(Message): ...
class InvalidPrintSyntax(Message): ...
class IsLiteral(Message): ...
class FStringMissingPlaceholders(Message): ...
+class TStringMissingPlaceholders(Message): ...
class StringDotFormatExtraPositionalArguments(Message):
message_args: tuple[str]
diff --git a/python/helpers/typeshed/stubs/pyinstaller/METADATA.toml b/python/helpers/typeshed/stubs/pyinstaller/METADATA.toml
index 386a17ce9350..51b28d26c358 100644
--- a/python/helpers/typeshed/stubs/pyinstaller/METADATA.toml
+++ b/python/helpers/typeshed/stubs/pyinstaller/METADATA.toml
@@ -1,2 +1,2 @@
-version = "6.14.*"
+version = "6.15.*"
upstream_repository = "https://github.com/pyinstaller/pyinstaller"
diff --git a/python/helpers/typeshed/stubs/pyinstaller/PyInstaller/compat.pyi b/python/helpers/typeshed/stubs/pyinstaller/PyInstaller/compat.pyi
index 81193e19ee58..5031aaeae671 100644
--- a/python/helpers/typeshed/stubs/pyinstaller/PyInstaller/compat.pyi
+++ b/python/helpers/typeshed/stubs/pyinstaller/PyInstaller/compat.pyi
@@ -15,6 +15,7 @@ is_py310: Final[bool]
is_py311: Final[bool]
is_py312: Final[bool]
is_py313: Final[bool]
+is_py314: Final[bool]
is_win: Final[bool]
is_win_10: Final[bool]
is_win_11: Final[bool]
diff --git a/python/helpers/typeshed/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi b/python/helpers/typeshed/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi
index ae19c98e180d..83df57a0ca30 100644
--- a/python/helpers/typeshed/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi
+++ b/python/helpers/typeshed/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi
@@ -11,6 +11,17 @@ class _SupportsGraphident(Protocol):
# code, filename and packagepath are always initialized to None. But they can be given a value later.
class Node:
# Compiled code. See stdlib.builtins.compile
+ __slots__ = [
+ "code",
+ "filename",
+ "graphident",
+ "identifier",
+ "packagepath",
+ "_deferred_imports",
+ "_global_attr_names",
+ "_starimported_ignored_module_names",
+ "_submodule_basename_to_node",
+ ]
code: CodeType | None
filename: str | None
graphident: str
diff --git a/python/helpers/typeshed/stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi b/python/helpers/typeshed/stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi
index 26878976bdaa..0fc169607cc0 100644
--- a/python/helpers/typeshed/stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi
+++ b/python/helpers/typeshed/stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi
@@ -4,12 +4,13 @@ from _typeshed import StrOrBytesPath
from collections.abc import Iterable
from importlib.metadata import PackagePath as _PackagePath
from pathlib import Path
-from typing import Final, TypedDict
+from typing import Final, TypedDict, type_check_only
CONDA_ROOT: Final[Path]
CONDA_META_DIR: Final[Path]
PYTHONPATH_PREFIXES: Final[list[Path]]
+@type_check_only
class _RawDict(TypedDict):
name: str
version: str
diff --git a/python/helpers/typeshed/stubs/pynput/METADATA.toml b/python/helpers/typeshed/stubs/pynput/METADATA.toml
index 4b63115669c3..ef8d6c438859 100644
--- a/python/helpers/typeshed/stubs/pynput/METADATA.toml
+++ b/python/helpers/typeshed/stubs/pynput/METADATA.toml
@@ -2,4 +2,4 @@ version = "~=1.8.1"
upstream_repository = "https://github.com/moses-palmer/pynput"
[tool.stubtest]
-platforms = ["darwin", "linux", "win32"]
+ci_platforms = ["darwin", "linux", "win32"]
diff --git a/python/helpers/typeshed/stubs/pynput/pynput/_util.pyi b/python/helpers/typeshed/stubs/pynput/pynput/_util.pyi
index c561e504bca2..a0e8904770d3 100644
--- a/python/helpers/typeshed/stubs/pynput/pynput/_util.pyi
+++ b/python/helpers/typeshed/stubs/pynput/pynput/_util.pyi
@@ -3,13 +3,14 @@ from _typeshed import OptExcInfo
from collections.abc import Callable
from queue import Queue
from types import ModuleType, TracebackType
-from typing import Any, ClassVar, Generic, TypedDict, TypeVar
+from typing import Any, ClassVar, Generic, TypedDict, TypeVar, type_check_only
from typing_extensions import ParamSpec, Self
_T = TypeVar("_T")
_AbstractListenerT = TypeVar("_AbstractListenerT", bound=AbstractListener)
_P = ParamSpec("_P")
+@type_check_only
class _RESOLUTIONS(TypedDict):
darwin: str
uinput: str
diff --git a/python/helpers/typeshed/stubs/pyperclip/METADATA.toml b/python/helpers/typeshed/stubs/pyperclip/METADATA.toml
index d8fd275f4016..885e7747f335 100644
--- a/python/helpers/typeshed/stubs/pyperclip/METADATA.toml
+++ b/python/helpers/typeshed/stubs/pyperclip/METADATA.toml
@@ -2,5 +2,5 @@ version = "1.9.*"
upstream_repository = "https://github.com/asweigart/pyperclip"
[tool.stubtest]
-platforms = ["win32", "linux", "darwin"]
+ci_platforms = ["win32", "linux", "darwin"]
apt_dependencies = ["xclip"]
diff --git a/python/helpers/typeshed/stubs/pyserial/METADATA.toml b/python/helpers/typeshed/stubs/pyserial/METADATA.toml
index 77a573699df3..effb2598ba68 100644
--- a/python/helpers/typeshed/stubs/pyserial/METADATA.toml
+++ b/python/helpers/typeshed/stubs/pyserial/METADATA.toml
@@ -2,5 +2,5 @@ version = "3.5.*"
upstream_repository = "https://github.com/pyserial/pyserial"
[tool.stubtest]
-platforms = ["darwin", "linux", "win32"]
+ci_platforms = ["darwin", "linux", "win32"]
extras = ["cp2110"]
diff --git a/python/helpers/typeshed/stubs/pyserial/serial/serialposix.pyi b/python/helpers/typeshed/stubs/pyserial/serial/serialposix.pyi
index e5251f81c655..84f84c9e1614 100644
--- a/python/helpers/typeshed/stubs/pyserial/serial/serialposix.pyi
+++ b/python/helpers/typeshed/stubs/pyserial/serial/serialposix.pyi
@@ -71,7 +71,7 @@ class Serial(SerialBase, PlatformSpecific):
def write(self, b: ReadableBuffer, /) -> int | None: ...
def reset_input_buffer(self) -> None: ...
def reset_output_buffer(self) -> None: ...
- def send_break(self, duration: float = ...) -> None: ...
+ def send_break(self, duration: float = 0.25) -> None: ...
@property
def cts(self) -> bool: ...
@property
@@ -82,8 +82,8 @@ class Serial(SerialBase, PlatformSpecific):
def cd(self) -> bool: ...
@property
def out_waiting(self) -> int: ...
- def set_input_flow_control(self, enable: bool = ...) -> None: ...
- def set_output_flow_control(self, enable: bool = ...) -> None: ...
+ def set_input_flow_control(self, enable: bool = True) -> None: ...
+ def set_output_flow_control(self, enable: bool = True) -> None: ...
def nonblocking(self) -> None: ...
class PosixPollSerial(Serial): ...
diff --git a/python/helpers/typeshed/stubs/pyserial/serial/tools/list_ports_osx.pyi b/python/helpers/typeshed/stubs/pyserial/serial/tools/list_ports_osx.pyi
index eb193d82e659..49746028a3f7 100644
--- a/python/helpers/typeshed/stubs/pyserial/serial/tools/list_ports_osx.pyi
+++ b/python/helpers/typeshed/stubs/pyserial/serial/tools/list_ports_osx.pyi
@@ -33,4 +33,4 @@ if sys.platform == "darwin":
def scan_interfaces() -> list[SuitableSerialInterface]: ...
def search_for_locationID_in_interfaces(serial_interfaces: list[SuitableSerialInterface], locationID: int) -> str | None: ...
- def comports(include_links: bool = ...) -> list[ListPortInfo]: ...
+ def comports(include_links: bool = False) -> list[ListPortInfo]: ...
diff --git a/python/helpers/typeshed/stubs/pyserial/serial/urlhandler/protocol_spy.pyi b/python/helpers/typeshed/stubs/pyserial/serial/urlhandler/protocol_spy.pyi
index b5c6d243ef40..e1454586fabe 100644
--- a/python/helpers/typeshed/stubs/pyserial/serial/urlhandler/protocol_spy.pyi
+++ b/python/helpers/typeshed/stubs/pyserial/serial/urlhandler/protocol_spy.pyi
@@ -1,11 +1,11 @@
from collections.abc import Generator
-from typing import TextIO
+from typing import TextIO, type_check_only
import serial
def sixteen(data: bytes) -> Generator[tuple[str, str] | tuple[None, None], None, None]: ...
def hexdump(data: bytes) -> Generator[tuple[int, str], None, None]: ...
-
+@type_check_only
class _Formatter:
def rx(self, data: bytes) -> None: ...
def tx(self, data: bytes) -> None: ...
diff --git a/python/helpers/typeshed/stubs/pysftp/METADATA.toml b/python/helpers/typeshed/stubs/pysftp/METADATA.toml
index 926abe3cdc5a..8296a25da395 100644
--- a/python/helpers/typeshed/stubs/pysftp/METADATA.toml
+++ b/python/helpers/typeshed/stubs/pysftp/METADATA.toml
@@ -1,3 +1,6 @@
version = "0.2.*"
upstream_repository = "https://bitbucket.org/dundeemt/pysftp"
requires = ["types-paramiko"]
+
+[tool.stubtest]
+stubtest_requirements = ["paramiko~=3.0"]
diff --git a/python/helpers/typeshed/stubs/python-crontab/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/python-crontab/@tests/stubtest_allowlist.txt
index ca0f86d94e9b..51b8a2b6fb81 100644
--- a/python/helpers/typeshed/stubs/python-crontab/@tests/stubtest_allowlist.txt
+++ b/python/helpers/typeshed/stubs/python-crontab/@tests/stubtest_allowlist.txt
@@ -2,3 +2,4 @@
crontabs.CronTabs.__new__
# stub does not have *args argument "args", but function doesn't actually accept positional args
crontab.CronTab.remove_all
+crontab.OrderedVariableList.__init__
diff --git a/python/helpers/typeshed/stubs/python-crontab/METADATA.toml b/python/helpers/typeshed/stubs/python-crontab/METADATA.toml
index 7e2ebbb739ba..c379fed74189 100644
--- a/python/helpers/typeshed/stubs/python-crontab/METADATA.toml
+++ b/python/helpers/typeshed/stubs/python-crontab/METADATA.toml
@@ -1,2 +1,3 @@
-version = "3.2.*"
+version = "3.3.*"
upstream_repository = "https://gitlab.com/doctormo/python-crontab"
+requires = ["types-croniter"]
diff --git a/python/helpers/typeshed/stubs/python-crontab/cronlog.pyi b/python/helpers/typeshed/stubs/python-crontab/cronlog.pyi
index f21d45161808..4cde497b944f 100644
--- a/python/helpers/typeshed/stubs/python-crontab/cronlog.pyi
+++ b/python/helpers/typeshed/stubs/python-crontab/cronlog.pyi
@@ -1,6 +1,7 @@
from _typeshed import StrOrBytesPath
from codecs import StreamReaderWriter
from collections.abc import Generator, Iterator
+from datetime import datetime
from types import TracebackType
from typing_extensions import Self
@@ -20,6 +21,8 @@ class LogReader:
def __iter__(self) -> Iterator[str]: ...
def readlines(self, until: int = ...) -> Generator[tuple[int, str], None, None]: ...
+def cron_date_to_datetime(cron_str: str) -> datetime: ...
+
class CronLog(LogReader):
user: str | None
def __init__(self, filename: StrOrBytesPath = ..., user: str | None = ...) -> None: ...
diff --git a/python/helpers/typeshed/stubs/python-crontab/crontab.pyi b/python/helpers/typeshed/stubs/python-crontab/crontab.pyi
index 63b64d008a7e..c228171d38d0 100644
--- a/python/helpers/typeshed/stubs/python-crontab/crontab.pyi
+++ b/python/helpers/typeshed/stubs/python-crontab/crontab.pyi
@@ -1,35 +1,51 @@
import re
import subprocess
-from _typeshed import Incomplete
+from _typeshed import Incomplete, StrPath
from builtins import range as _range
from collections import OrderedDict
from collections.abc import Callable, Generator, Iterable, Iterator
from datetime import datetime
from logging import Logger
from types import TracebackType
-from typing import Any, SupportsIndex, overload
+from typing import Any, Final, Literal, Protocol, SupportsIndex, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias
+from croniter.croniter import croniter
from cronlog import CronLog
_User: TypeAlias = str | bool | None
+_K = TypeVar("_K")
+_V = TypeVar("_V")
-__pkgname__: str
-ITEMREX: re.Pattern[str]
-SPECREX: re.Pattern[str]
-DEVNULL: str
-WEEK_ENUM: list[str]
-MONTH_ENUM: list[str | None]
-SPECIALS: dict[str, str]
-SPECIAL_IGNORE: list[str]
-S_INFO: list[dict[str, Any]]
-WINOS: bool
-POSIX: bool
-SYSTEMV: bool
-ZERO_PAD: bool
+# cron_descriptor.Options class
+@type_check_only
+class _Options(Protocol):
+ casing_type: Literal[1, 2, 3]
+ verbose: bool
+ day_of_week_start_index_zero: bool
+ use_24hour_time_format: bool
+ locale_location: StrPath | None
+ locale_code: str | None
+ def __init__(self) -> None: ...
+
+__pkgname__: Final[str]
+__version__: Final[str]
+ITEMREX: Final[re.Pattern[str]]
+SPECREX: Final[re.Pattern[str]]
+DEVNULL: Final[str]
+WEEK_ENUM: Final[list[str]]
+MONTH_ENUM: Final[list[str | None]]
+SPECIALS_CONVERSION: Final[bool]
+SPECIALS: Final[dict[str, str]]
+SPECIAL_IGNORE: Final[list[str]]
+S_INFO: Final[list[dict[str, str | int | list[str] | list[str | None]]]]
+WINOS: Final[bool]
+POSIX: Final[bool]
+SYSTEMV: Final[bool]
+ZERO_PAD: Final[bool]
LOG: Logger
-CRON_COMMAND: str
-SHELL: str
+CRON_COMMAND: Final[str]
+SHELL: Final[str]
current_user: Callable[[], str | None]
class Process:
@@ -50,7 +66,7 @@ class CronTab:
crons: list[CronItem] | None
filen: str | None
cron_command: str
- env: OrderedVariableList | None
+ env: OrderedVariableList[Incomplete, Incomplete] | None
root: bool
intab: str | None
tabfile: str | None
@@ -73,22 +89,22 @@ class CronTab:
item: CronItem,
line: str = ...,
read: bool = ...,
- before: str | re.Pattern[str] | list[CronItem] | tuple[CronItem, ...] | Generator[CronItem, Any, Any] | None = ...,
+ before: str | re.Pattern[str] | list[CronItem] | tuple[CronItem, ...] | Generator[CronItem] | None = ...,
) -> None: ...
def write(self, filename: str | None = ..., user: _User = ..., errors: bool = ...) -> None: ...
def write_to_user(self, user: bool | str = ...) -> None: ...
# Usually `kwargs` are just `now: datetime | None`, but technically this can
# work for `CronItem` subclasses, which might define other kwargs.
- def run_pending(self, **kwargs: Any) -> Iterator[str]: ...
+ def run_pending(self, *, now: datetime | None = ..., **kwargs: Any) -> Iterator[str]: ...
def run_scheduler(self, timeout: int = -1, cadence: int = 60, warp: bool = False) -> Iterator[str]: ...
- def render(self, errors: bool = ..., specials: bool | None = ...) -> str: ...
+ def render(self, errors: bool = ...) -> str: ...
def new(
self,
command: str = ...,
comment: str = ...,
user: str | None = ...,
pre_comment: bool = ...,
- before: str | re.Pattern[str] | list[CronItem] | tuple[CronItem, ...] | Generator[CronItem, Any, Any] | None = ...,
+ before: str | re.Pattern[str] | list[CronItem] | tuple[CronItem, ...] | Generator[CronItem] | None = ...,
) -> CronItem: ...
def find_command(self, command: str | re.Pattern[str]) -> Iterator[CronItem]: ...
def find_comment(self, comment: str | re.Pattern[str]) -> Iterator[CronItem]: ...
@@ -116,7 +132,7 @@ class CronItem:
comment: str
command: str | None
last_run: datetime | None
- env: OrderedVariableList
+ env: OrderedVariableList[Incomplete, Incomplete]
pre_comment: bool
marker: str | None
stdin: str | None
@@ -133,7 +149,7 @@ class CronItem:
def enable(self, enabled: bool = ...) -> bool: ...
def is_enabled(self) -> bool: ...
def is_valid(self) -> bool: ...
- def render(self, specials: bool = ...) -> str: ...
+ def render(self) -> str: ...
def every_reboot(self) -> None: ...
def every(self, unit: int = ...) -> Every: ...
def setall(self, *args: Any) -> None: ...
@@ -157,10 +173,18 @@ class CronItem:
def frequency_at_hour(self, year: None = None, month: None = None, day: None = None, hour: None = None) -> int: ...
def run_pending(self, now: datetime | None = ...) -> int | str: ...
def run(self) -> str: ...
- # TODO: use types from `croniter` module here:
- def schedule(self, date_from: datetime | None = ...): ...
- # TODO: use types from `cron_descriptor` here:
- def description(self, **kw): ...
+ def schedule(self, date_from: datetime | None = ...) -> croniter: ...
+ def description(
+ self,
+ *,
+ options: _Options | None = None,
+ casing_type: Literal[1, 2, 3] = 2,
+ verbose: bool = False,
+ day_of_week_start_index_zero: bool = True,
+ use_24hour_time_format: bool = ...,
+ locale_location: StrPath | None = None,
+ locale_code: str | None = ...,
+ ) -> str | None: ...
@property
def log(self) -> CronLog: ...
@property
@@ -202,7 +226,7 @@ class CronSlices(list[CronSlice]):
def is_valid(cls, *args: Any) -> bool: ...
def setall(self, *slices: str) -> None: ...
def clean_render(self) -> str: ...
- def render(self, specials: bool = ...) -> str: ...
+ def render(self) -> str: ...
def clear(self) -> None: ...
def frequency(self, year: int | None = ...) -> int: ...
def frequency_per_year(self, year: int | None = ...) -> int: ...
@@ -288,11 +312,12 @@ class CronRange:
def __gt__(self, value: object) -> bool: ...
def __int__(self) -> int: ...
-# TODO: make generic
-class OrderedVariableList(OrderedDict[Incomplete, Incomplete]):
- job: Incomplete
- def __init__(self, *args: Any, **kw: Any) -> None: ...
+class OrderedVariableList(OrderedDict[_K, _V]):
+ job: CronItem | None
+ # You cannot actually pass `*args`, it will raise an exception,
+ # also known kwargs are added:
+ def __init__(self, *, job: CronItem | None = None, **kw: _V) -> None: ...
@property
- def previous(self): ...
+ def previous(self) -> Self | None: ...
def all(self) -> Self: ...
- def __getitem__(self, key): ...
+ def __getitem__(self, key: _K) -> _V: ...
diff --git a/python/helpers/typeshed/stubs/python-datemath/METADATA.toml b/python/helpers/typeshed/stubs/python-datemath/METADATA.toml
deleted file mode 100644
index c66bb84067e4..000000000000
--- a/python/helpers/typeshed/stubs/python-datemath/METADATA.toml
+++ /dev/null
@@ -1,8 +0,0 @@
-version = "3.0.1"
-upstream_repository = "https://github.com/nickmaccarthy/python-datemath"
-# Requires a version of arrow with a `py.typed` file
-requires = ["arrow>=1.0.1"]
-obsolete_since = "3.0.2" # Released on 2024-09-11
-
-[tool.stubtest]
-ignore_missing_stub = true
diff --git a/python/helpers/typeshed/stubs/python-datemath/datemath/__init__.pyi b/python/helpers/typeshed/stubs/python-datemath/datemath/__init__.pyi
deleted file mode 100644
index ecb00250aa45..000000000000
--- a/python/helpers/typeshed/stubs/python-datemath/datemath/__init__.pyi
+++ /dev/null
@@ -1,12 +0,0 @@
-from datetime import datetime
-
-import arrow
-
-from .helpers import DateMathException as DateMathException, parse as parse
-
-def dm(
- expr: str, *, now: arrow.Arrow | None = ..., tz: str = ..., type: str | None = ..., roundDown: bool = ...
-) -> arrow.Arrow: ...
-def datemath(
- expr: str, *, now: arrow.Arrow | None = ..., tz: str = ..., type: str | None = ..., roundDown: bool = ...
-) -> datetime: ...
diff --git a/python/helpers/typeshed/stubs/python-datemath/datemath/helpers.pyi b/python/helpers/typeshed/stubs/python-datemath/datemath/helpers.pyi
deleted file mode 100644
index a8063825e2af..000000000000
--- a/python/helpers/typeshed/stubs/python-datemath/datemath/helpers.pyi
+++ /dev/null
@@ -1,8 +0,0 @@
-import arrow
-
-class DateMathException(Exception): ...
-
-def parse(
- expression: str, now: arrow.Arrow | None = None, tz: str = "UTC", type: str | None = None, roundDown: bool = True
-) -> arrow.Arrow: ...
-def __getattr__(name: str): ... # incomplete module
diff --git a/python/helpers/typeshed/stubs/python-dateutil/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/python-dateutil/@tests/stubtest_allowlist.txt
index 852c593a1288..a0c201aa1cac 100644
--- a/python/helpers/typeshed/stubs/python-dateutil/@tests/stubtest_allowlist.txt
+++ b/python/helpers/typeshed/stubs/python-dateutil/@tests/stubtest_allowlist.txt
@@ -1,5 +1,3 @@
-dateutil.parser._tzparser.__init__
-dateutil.parser.parserinfo.convertyear
dateutil.rrule.weekday.__init__
dateutil.tz.tz.tzoffset.instance
dateutil.tz.tz.tzstr.instance
diff --git a/python/helpers/typeshed/stubs/python-dateutil/@tests/stubtest_allowlist_darwin.txt b/python/helpers/typeshed/stubs/python-dateutil/@tests/stubtest_allowlist_darwin.txt
new file mode 100644
index 000000000000..b667fc149971
--- /dev/null
+++ b/python/helpers/typeshed/stubs/python-dateutil/@tests/stubtest_allowlist_darwin.txt
@@ -0,0 +1,3 @@
+# Cannot import these Windows packages at stubtest runtime:
+dateutil.tzwin
+dateutil.tz.win
diff --git a/python/helpers/typeshed/stubs/python-dateutil/@tests/stubtest_allowlist_linux.txt b/python/helpers/typeshed/stubs/python-dateutil/@tests/stubtest_allowlist_linux.txt
new file mode 100644
index 000000000000..b667fc149971
--- /dev/null
+++ b/python/helpers/typeshed/stubs/python-dateutil/@tests/stubtest_allowlist_linux.txt
@@ -0,0 +1,3 @@
+# Cannot import these Windows packages at stubtest runtime:
+dateutil.tzwin
+dateutil.tz.win
diff --git a/python/helpers/typeshed/stubs/python-dateutil/METADATA.toml b/python/helpers/typeshed/stubs/python-dateutil/METADATA.toml
index 5f2be1e4ef5b..9aa35b672cc2 100644
--- a/python/helpers/typeshed/stubs/python-dateutil/METADATA.toml
+++ b/python/helpers/typeshed/stubs/python-dateutil/METADATA.toml
@@ -1,6 +1,2 @@
version = "2.9.*"
upstream_repository = "https://github.com/dateutil/dateutil"
-partial_stub = true
-
-[tool.stubtest]
-ignore_missing_stub = true
diff --git a/python/helpers/typeshed/stubs/python-dateutil/dateutil/__init__.pyi b/python/helpers/typeshed/stubs/python-dateutil/dateutil/__init__.pyi
index e69de29bb2d1..9fb5d4b1fe59 100644
--- a/python/helpers/typeshed/stubs/python-dateutil/dateutil/__init__.pyi
+++ b/python/helpers/typeshed/stubs/python-dateutil/dateutil/__init__.pyi
@@ -0,0 +1,5 @@
+from dateutil import easter, parser, relativedelta, rrule, tz, utils, zoneinfo
+
+__all__ = ["easter", "parser", "relativedelta", "rrule", "tz", "utils", "zoneinfo"]
+
+def __dir__() -> list[str]: ...
diff --git a/python/helpers/typeshed/stubs/python-dateutil/dateutil/_common.pyi b/python/helpers/typeshed/stubs/python-dateutil/dateutil/_common.pyi
index 75bf74c526e3..af892a5d7a0d 100644
--- a/python/helpers/typeshed/stubs/python-dateutil/dateutil/_common.pyi
+++ b/python/helpers/typeshed/stubs/python-dateutil/dateutil/_common.pyi
@@ -1,6 +1,7 @@
from typing_extensions import Self
class weekday:
+ __slots__ = ["weekday", "n"]
def __init__(self, weekday: int, n: int | None = None) -> None: ...
def __call__(self, n: int) -> Self: ...
def __eq__(self, other: object) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/python-dateutil/dateutil/_version.pyi b/python/helpers/typeshed/stubs/python-dateutil/dateutil/_version.pyi
new file mode 100644
index 000000000000..840633ef6e91
--- /dev/null
+++ b/python/helpers/typeshed/stubs/python-dateutil/dateutil/_version.pyi
@@ -0,0 +1,6 @@
+from typing import Final
+
+__version__: Final[str]
+version: Final[str]
+__version_tuple__: Final[tuple[int, int, int]]
+version_tuple: Final[tuple[int, int, int]]
diff --git a/python/helpers/typeshed/stubs/python-dateutil/dateutil/easter.pyi b/python/helpers/typeshed/stubs/python-dateutil/dateutil/easter.pyi
index 952d119142e5..695faa222541 100644
--- a/python/helpers/typeshed/stubs/python-dateutil/dateutil/easter.pyi
+++ b/python/helpers/typeshed/stubs/python-dateutil/dateutil/easter.pyi
@@ -1,8 +1,10 @@
from datetime import date
-from typing import Literal
+from typing import Final, Literal
-EASTER_JULIAN: Literal[1]
-EASTER_ORTHODOX: Literal[2]
-EASTER_WESTERN: Literal[3]
+__all__ = ["easter", "EASTER_JULIAN", "EASTER_ORTHODOX", "EASTER_WESTERN"]
+
+EASTER_JULIAN: Final = 1
+EASTER_ORTHODOX: Final = 2
+EASTER_WESTERN: Final = 3
def easter(year: int, method: Literal[1, 2, 3] = 3) -> date: ...
diff --git a/python/helpers/typeshed/stubs/python-dateutil/dateutil/parser/__init__.pyi b/python/helpers/typeshed/stubs/python-dateutil/dateutil/parser/__init__.pyi
index 68f96ff238b8..1041c050d7a7 100644
--- a/python/helpers/typeshed/stubs/python-dateutil/dateutil/parser/__init__.pyi
+++ b/python/helpers/typeshed/stubs/python-dateutil/dateutil/parser/__init__.pyi
@@ -1,68 +1,12 @@
-from collections.abc import Callable, Mapping
-from datetime import datetime, tzinfo
-from typing import IO, Any
-from typing_extensions import TypeAlias
-
+from ._parser import (
+ DEFAULTPARSER as DEFAULTPARSER,
+ DEFAULTTZPARSER as DEFAULTTZPARSER,
+ ParserError as ParserError,
+ UnknownTimezoneWarning as UnknownTimezoneWarning,
+ parse as parse,
+ parser as parser,
+ parserinfo as parserinfo,
+)
from .isoparser import isoparse as isoparse, isoparser as isoparser
-_FileOrStr: TypeAlias = bytes | str | IO[str] | IO[Any]
-_TzData: TypeAlias = tzinfo | int | str | None
-_TzInfo: TypeAlias = Mapping[str, _TzData] | Callable[[str, int], _TzData]
-
-class parserinfo:
- JUMP: list[str]
- WEEKDAYS: list[tuple[str, ...]]
- MONTHS: list[tuple[str, ...]]
- HMS: list[tuple[str, str, str]]
- AMPM: list[tuple[str, str]]
- UTCZONE: list[str]
- PERTAIN: list[str]
- TZOFFSET: dict[str, int]
- def __init__(self, dayfirst: bool = False, yearfirst: bool = False) -> None: ...
- def jump(self, name: str) -> bool: ...
- def weekday(self, name: str) -> int | None: ...
- def month(self, name: str) -> int | None: ...
- def hms(self, name: str) -> int | None: ...
- def ampm(self, name: str) -> int | None: ...
- def pertain(self, name: str) -> bool: ...
- def utczone(self, name: str) -> bool: ...
- def tzoffset(self, name: str) -> int | None: ...
- def convertyear(self, year: int) -> int: ...
- def validate(self, res: datetime) -> bool: ...
-
-class parser:
- def __init__(self, info: parserinfo | None = None) -> None: ...
- def parse(
- self,
- timestr: _FileOrStr,
- default: datetime | None = None,
- ignoretz: bool = False,
- tzinfos: _TzInfo | None = None,
- *,
- dayfirst: bool | None = ...,
- yearfirst: bool | None = ...,
- fuzzy: bool = ...,
- fuzzy_with_tokens: bool = ...,
- ) -> datetime: ...
-
-DEFAULTPARSER: parser
-
-def parse(
- timestr: _FileOrStr,
- parserinfo: parserinfo | None = None,
- *,
- dayfirst: bool | None = ...,
- yearfirst: bool | None = ...,
- ignoretz: bool = ...,
- fuzzy: bool = ...,
- fuzzy_with_tokens: bool = ...,
- default: datetime | None = ...,
- tzinfos: _TzInfo | None = ...,
-) -> datetime: ...
-
-class _tzparser: ...
-
-DEFAULTTZPARSER: _tzparser
-
-class ParserError(ValueError): ...
-class UnknownTimezoneWarning(RuntimeWarning): ...
+__all__ = ["parse", "parser", "parserinfo", "isoparse", "isoparser", "ParserError", "UnknownTimezoneWarning"]
diff --git a/python/helpers/typeshed/stubs/python-dateutil/dateutil/parser/_parser.pyi b/python/helpers/typeshed/stubs/python-dateutil/dateutil/parser/_parser.pyi
new file mode 100644
index 000000000000..e4784c89c109
--- /dev/null
+++ b/python/helpers/typeshed/stubs/python-dateutil/dateutil/parser/_parser.pyi
@@ -0,0 +1,136 @@
+import re
+from _typeshed import Incomplete, SupportsRead
+from collections.abc import Callable, Mapping
+from datetime import _TzInfo, datetime
+from io import StringIO
+from typing import IO, Any
+from typing_extensions import Self, TypeAlias
+
+_FileOrStr: TypeAlias = bytes | str | IO[str] | IO[Any]
+_TzData: TypeAlias = _TzInfo | int | str | None
+_TzInfos: TypeAlias = Mapping[str, _TzData] | Callable[[str, int], _TzData]
+
+__all__ = ["parse", "parserinfo", "ParserError"]
+
+class _timelex:
+ _split_decimal: re.Pattern[str]
+ instream: StringIO | SupportsRead[str]
+ charstack: list[str]
+ tokenstack: list[str]
+ eof: bool
+ def __init__(self, instream: str | bytes | bytearray | SupportsRead[str]) -> None: ...
+ def get_token(self) -> str | None: ...
+ def __iter__(self) -> Self: ...
+ def __next__(self) -> str: ...
+ def next(self) -> str: ...
+ @classmethod
+ def split(cls, s: str) -> list[str]: ...
+ @classmethod
+ def isword(cls, nextchar: str) -> bool: ...
+ @classmethod
+ def isnum(cls, nextchar: str) -> bool: ...
+ @classmethod
+ def isspace(cls, nextchar: str) -> bool: ...
+
+class _resultbase:
+ def __init__(self) -> None: ...
+ def _repr(self, classname: str) -> str: ...
+ def __len__(self) -> int: ...
+
+class parserinfo:
+ JUMP: list[str]
+ WEEKDAYS: list[tuple[str, str]]
+ MONTHS: list[tuple[str, str] | tuple[str, str, str]]
+ HMS: list[tuple[str, str, str]]
+ AMPM: list[tuple[str, str]]
+ UTCZONE: list[str]
+ PERTAIN: list[str]
+ TZOFFSET: dict[str, int]
+ def __init__(self, dayfirst: bool = False, yearfirst: bool = False) -> None: ...
+ def jump(self, name: str) -> bool: ...
+ def weekday(self, name: str) -> int | None: ...
+ def month(self, name: str) -> int | None: ...
+ def hms(self, name: str) -> int | None: ...
+ def ampm(self, name: str) -> int | None: ...
+ def pertain(self, name: str) -> bool: ...
+ def utczone(self, name: str) -> bool: ...
+ def tzoffset(self, name: str) -> int | None: ...
+ def convertyear(self, year: int, century_specified: bool = False) -> int: ...
+ def validate(self, res: datetime) -> bool: ...
+
+class _ymd(list[Incomplete]):
+ century_specified: bool
+ dstridx: int | None
+ mstridx: int | None
+ ystridx: int | None
+ def __init__(self, *args, **kwargs) -> None: ...
+ @property
+ def has_year(self) -> bool: ...
+ @property
+ def has_month(self) -> bool: ...
+ @property
+ def has_day(self) -> bool: ...
+ def could_be_day(self, value): ...
+ def append(self, val, label=None): ...
+ def _resolve_from_stridxs(self, strids): ...
+ def resolve_ymd(self, yearfirst: bool | None, dayfirst: bool | None): ...
+
+class parser:
+ info: parserinfo
+ def __init__(self, info: parserinfo | None = None) -> None: ...
+ def parse(
+ self,
+ timestr: _FileOrStr,
+ default: datetime | None = None,
+ ignoretz: bool = False,
+ tzinfos: _TzInfos | None = None,
+ *,
+ dayfirst: bool | None = ...,
+ yearfirst: bool | None = ...,
+ fuzzy: bool = ...,
+ fuzzy_with_tokens: bool = ...,
+ ) -> datetime: ...
+
+DEFAULTPARSER: parser
+
+def parse(
+ timestr: _FileOrStr,
+ parserinfo: parserinfo | None = None,
+ *,
+ dayfirst: bool | None = ...,
+ yearfirst: bool | None = ...,
+ ignoretz: bool = ...,
+ fuzzy: bool = ...,
+ fuzzy_with_tokens: bool = ...,
+ default: datetime | None = ...,
+ tzinfos: _TzInfos | None = ...,
+) -> datetime: ...
+
+class _tzparser:
+ class _result(_resultbase):
+ __slots__ = ["stdabbr", "stdoffset", "dstabbr", "dstoffset", "start", "end"]
+ stdabbr: str | None
+ stdoffset: int | None
+ dstabbr: str | None
+ dstoffset: int | None
+ start: _attr
+ end: _attr
+
+ class _attr(_resultbase):
+ __slots__ = ["month", "week", "weekday", "yday", "jyday", "day", "time"]
+ month: int | None
+ week: int | None
+ weekday: int | None
+ yday: int | None
+ jyday: int | None
+ day: int | None
+ time: int | None
+
+ def __init__(self): ...
+
+ def parse(self, tzstr: str | re.Pattern[str]) -> _result | None: ...
+
+DEFAULTTZPARSER: _tzparser
+
+class ParserError(ValueError): ...
+class UnknownTimezoneWarning(RuntimeWarning): ...
diff --git a/python/helpers/typeshed/stubs/python-dateutil/dateutil/parser/isoparser.pyi b/python/helpers/typeshed/stubs/python-dateutil/dateutil/parser/isoparser.pyi
index fc5e46d97e50..51a9c153af81 100644
--- a/python/helpers/typeshed/stubs/python-dateutil/dateutil/parser/isoparser.pyi
+++ b/python/helpers/typeshed/stubs/python-dateutil/dateutil/parser/isoparser.pyi
@@ -5,6 +5,8 @@ from typing_extensions import TypeAlias
_Readable: TypeAlias = SupportsRead[str | bytes]
_TakesAscii: TypeAlias = str | bytes | _Readable
+__all__ = ["isoparse", "isoparser"]
+
class isoparser:
def __init__(self, sep: str | bytes | None = None): ...
def isoparse(self, dt_str: _TakesAscii) -> datetime: ...
diff --git a/python/helpers/typeshed/stubs/python-dateutil/dateutil/relativedelta.pyi b/python/helpers/typeshed/stubs/python-dateutil/dateutil/relativedelta.pyi
index 9de928158249..90f155f70717 100644
--- a/python/helpers/typeshed/stubs/python-dateutil/dateutil/relativedelta.pyi
+++ b/python/helpers/typeshed/stubs/python-dateutil/dateutil/relativedelta.pyi
@@ -17,6 +17,8 @@ FR: weekday
SA: weekday
SU: weekday
+__all__ = ["relativedelta", "MO", "TU", "WE", "TH", "FR", "SA", "SU"]
+
class relativedelta:
years: int
months: int
diff --git a/python/helpers/typeshed/stubs/python-dateutil/dateutil/rrule.pyi b/python/helpers/typeshed/stubs/python-dateutil/dateutil/rrule.pyi
index 22b7c983505c..c63010871f87 100644
--- a/python/helpers/typeshed/stubs/python-dateutil/dateutil/rrule.pyi
+++ b/python/helpers/typeshed/stubs/python-dateutil/dateutil/rrule.pyi
@@ -1,17 +1,48 @@
import datetime
from _typeshed import Incomplete
-from collections.abc import Iterable, Iterator, Sequence
-from typing_extensions import TypeAlias
+from collections.abc import Generator, Iterable, Iterator, Sequence
+from typing import Final, Literal
+from typing_extensions import Self, TypeAlias
from ._common import weekday as weekdaybase
-YEARLY: int
-MONTHLY: int
-WEEKLY: int
-DAILY: int
-HOURLY: int
-MINUTELY: int
-SECONDLY: int
+__all__ = [
+ "rrule",
+ "rruleset",
+ "rrulestr",
+ "YEARLY",
+ "MONTHLY",
+ "WEEKLY",
+ "DAILY",
+ "HOURLY",
+ "MINUTELY",
+ "SECONDLY",
+ "MO",
+ "TU",
+ "WE",
+ "TH",
+ "FR",
+ "SA",
+ "SU",
+]
+
+M366MASK: Final[tuple[int, ...]]
+MDAY366MASK: Final[tuple[int, ...]]
+MDAY365MASK: Final[tuple[int, ...]]
+NMDAY366MASK: Final[tuple[int, ...]]
+NMDAY365MASK: Final[list[int]]
+M366RANGE: Final[tuple[int, ...]]
+M365RANGE: Final[tuple[int, ...]]
+WDAYMASK: Final[list[int]]
+M365MASK: Final[tuple[int, ...]]
+FREQNAMES: Final[list[str]]
+YEARLY: Final = 0
+MONTHLY: Final = 1
+WEEKLY: Final = 2
+DAILY: Final = 3
+HOURLY: Final = 4
+MINUTELY: Final = 5
+SECONDLY: Final = 6
class weekday(weekdaybase): ...
@@ -25,20 +56,20 @@ SA: weekday
SU: weekday
class rrulebase:
- def __init__(self, cache: bool = False) -> None: ...
+ def __init__(self, cache: bool | None = False) -> None: ...
def __iter__(self) -> Iterator[datetime.datetime]: ...
def __getitem__(self, item): ...
- def __contains__(self, item): ...
- def count(self): ...
+ def __contains__(self, item) -> bool: ...
+ def count(self) -> int | None: ...
def before(self, dt, inc: bool = False): ...
def after(self, dt, inc: bool = False): ...
- def xafter(self, dt, count=None, inc: bool = False): ...
- def between(self, after, before, inc: bool = False, count: int = 1): ...
+ def xafter(self, dt, count=None, inc: bool = False) -> Generator[Incomplete]: ...
+ def between(self, after, before, inc: bool = False, count: int = 1) -> list[Incomplete]: ...
class rrule(rrulebase):
def __init__(
self,
- freq,
+ freq: Literal[0, 1, 2, 3, 4, 5, 6],
dtstart: datetime.date | None = None,
interval: int = 1,
wkst: weekday | int | None = None,
@@ -54,13 +85,50 @@ class rrule(rrulebase):
byhour: int | Iterable[int] | None = None,
byminute: int | Iterable[int] | None = None,
bysecond: int | Iterable[int] | None = None,
- cache: bool = False,
+ cache: bool | None = False,
) -> None: ...
- def replace(self, **kwargs): ...
+ def replace(
+ self,
+ *,
+ freq: Literal[0, 1, 2, 3, 4, 5, 6] = ...,
+ dtstart: datetime.date | None = ...,
+ interval: int = ...,
+ wkst: weekday | int | None = ...,
+ count: int | None = ...,
+ until: datetime.date | int | None = ...,
+ bysetpos: int | Iterable[int] | None = None,
+ bymonth: int | Iterable[int] | None = None,
+ bymonthday: int | Iterable[int] | None = None,
+ byyearday: int | Iterable[int] | None = None,
+ byeaster: int | Iterable[int] | None = None,
+ byweekno: int | Iterable[int] | None = None,
+ byweekday: int | weekday | Iterable[int] | Iterable[weekday] | None = None,
+ byhour: int | Iterable[int] | None = None,
+ byminute: int | Iterable[int] | None = None,
+ bysecond: int | Iterable[int] | None = None,
+ cache: bool | None = ...,
+ ) -> Self: ...
_RRule: TypeAlias = rrule
class _iterinfo:
+ __slots__ = [
+ "rrule",
+ "lastyear",
+ "lastmonth",
+ "yearlen",
+ "nextyearlen",
+ "yearordinal",
+ "yearweekday",
+ "mmask",
+ "mrange",
+ "mdaymask",
+ "nmdaymask",
+ "wdaymask",
+ "wnomask",
+ "nwdaymask",
+ "eastermask",
+ ]
rrule: _RRule
def __init__(self, rrule: _RRule) -> None: ...
yearlen: int | None
@@ -77,14 +145,14 @@ class _iterinfo:
eastermask: Sequence[int] | None
lastyear: int | None
lastmonth: int | None
- def rebuild(self, year, month): ...
- def ydayset(self, year, month, day): ...
- def mdayset(self, year, month, day): ...
- def wdayset(self, year, month, day): ...
- def ddayset(self, year, month, day): ...
- def htimeset(self, hour, minute, second): ...
- def mtimeset(self, hour, minute, second): ...
- def stimeset(self, hour, minute, second): ...
+ def rebuild(self, year: int, month: int) -> None: ...
+ def ydayset(self, year: int, month: int, day: int) -> tuple[Iterable[int | None], int, int]: ...
+ def mdayset(self, year: int, month: int, day: int) -> tuple[Iterable[int | None], int, int]: ...
+ def wdayset(self, year: int, month: int, day: int) -> tuple[Iterable[int | None], int, int]: ...
+ def ddayset(self, year: int, month: int, day: int) -> tuple[Iterable[int | None], int, int]: ...
+ def htimeset(self, hour: int, minute: int, second: int) -> list[datetime.time]: ...
+ def mtimeset(self, hour: int, minute: int, second: int) -> list[datetime.time]: ...
+ def stimeset(self, hour: int, minute: int, second: int) -> tuple[datetime.time, ...]: ...
class rruleset(rrulebase):
class _genitem:
@@ -99,13 +167,25 @@ class rruleset(rrulebase):
def __eq__(self, other) -> bool: ...
def __ne__(self, other) -> bool: ...
- def __init__(self, cache: bool = False) -> None: ...
- def rrule(self, rrule: _RRule): ...
- def rdate(self, rdate): ...
- def exrule(self, exrule): ...
- def exdate(self, exdate): ...
+ def __init__(self, cache: bool | None = False) -> None: ...
+ def rrule(self, rrule: _RRule) -> None: ...
+ def rdate(self, rdate) -> None: ...
+ def exrule(self, exrule) -> None: ...
+ def exdate(self, exdate) -> None: ...
class _rrulestr:
- def __call__(self, s, **kwargs) -> rrule | rruleset: ...
+ def __call__(
+ self,
+ s: str,
+ *,
+ dtstart: datetime.date | None = None,
+ cache: bool | None = False,
+ unfold: bool = False,
+ forceset: bool = False,
+ compatible: bool = False,
+ ignoretz: bool = False,
+ tzids=None,
+ tzinfos=None,
+ ) -> rrule | rruleset: ...
rrulestr: _rrulestr
diff --git a/python/helpers/typeshed/stubs/python-dateutil/dateutil/tz/__init__.pyi b/python/helpers/typeshed/stubs/python-dateutil/dateutil/tz/__init__.pyi
index 334ca4825094..3dbbe3199855 100644
--- a/python/helpers/typeshed/stubs/python-dateutil/dateutil/tz/__init__.pyi
+++ b/python/helpers/typeshed/stubs/python-dateutil/dateutil/tz/__init__.pyi
@@ -1,6 +1,12 @@
+import sys
+from datetime import datetime
+from typing_extensions import Self
+
+from ._common import tzrangebase
from .tz import (
datetime_ambiguous as datetime_ambiguous,
datetime_exists as datetime_exists,
+ enfold as enfold,
gettz as gettz,
resolve_imaginary as resolve_imaginary,
tzfile as tzfile,
@@ -12,4 +18,50 @@ from .tz import (
tzutc as tzutc,
)
+# UTC, tzwin, tzwinlocal are defined in this class
+# otherwise pyright complains about unknown import symbol:
+if sys.platform == "win32":
+ class tzwinbase(tzrangebase):
+ hasdst: bool
+ def __eq__(self, other: tzwinbase) -> bool: ... # type: ignore[override]
+ @staticmethod
+ def list() -> list[str]: ...
+ def display(self) -> str | None: ...
+ def transitions(self, year: int) -> tuple[datetime, datetime] | None: ...
+
+ class tzwin(tzwinbase):
+ hasdst: bool
+ def __init__(self, name: str) -> None: ...
+ def __reduce__(self) -> tuple[type[Self], tuple[str, ...]]: ... # type: ignore[override]
+
+ class tzwinlocal(tzwinbase):
+ hasdst: bool
+ def __init__(self) -> None: ...
+ def __reduce__(self) -> tuple[type[Self], tuple[str, ...]]: ... # type: ignore[override]
+
+else:
+ tzwin: None
+ tzwinlocal: None
+
UTC: tzutc
+
+__all__ = [
+ "tzutc",
+ "tzoffset",
+ "tzlocal",
+ "tzfile",
+ "tzrange",
+ "tzstr",
+ "tzical",
+ "tzwin",
+ "tzwinlocal",
+ "gettz",
+ "enfold",
+ "datetime_ambiguous",
+ "datetime_exists",
+ "resolve_imaginary",
+ "UTC",
+ "DeprecatedTzFormatWarning",
+]
+
+class DeprecatedTzFormatWarning(Warning): ...
diff --git a/python/helpers/typeshed/stubs/python-dateutil/dateutil/tz/_common.pyi b/python/helpers/typeshed/stubs/python-dateutil/dateutil/tz/_common.pyi
index 4e64822fa09c..7e9b8957c34b 100644
--- a/python/helpers/typeshed/stubs/python-dateutil/dateutil/tz/_common.pyi
+++ b/python/helpers/typeshed/stubs/python-dateutil/dateutil/tz/_common.pyi
@@ -2,13 +2,13 @@ import abc
from datetime import datetime, timedelta, tzinfo
from typing import ClassVar
+ZERO: timedelta
+
+__all__ = ["tzname_in_python2", "enfold"]
+
def tzname_in_python2(namefunc): ...
def enfold(dt: datetime, fold: int = 1): ...
-class _DatetimeWithFold(datetime):
- @property
- def fold(self): ...
-
# Doesn't actually have ABCMeta as the metaclass at runtime,
# but mypy complains if we don't have it in the stub.
# See discussion in #8908
diff --git a/python/helpers/typeshed/stubs/python-dateutil/dateutil/tz/tz.pyi b/python/helpers/typeshed/stubs/python-dateutil/dateutil/tz/tz.pyi
index c129277343c1..475ace6a4bd7 100644
--- a/python/helpers/typeshed/stubs/python-dateutil/dateutil/tz/tz.pyi
+++ b/python/helpers/typeshed/stubs/python-dateutil/dateutil/tz/tz.pyi
@@ -1,32 +1,41 @@
-import datetime
-from typing import ClassVar, Literal, Protocol, TypeVar
+import sys
+from datetime import datetime, timedelta, tzinfo
+from typing import ClassVar, Literal, Protocol, TypeVar, type_check_only
from ..relativedelta import relativedelta
-from ._common import _tzinfo as _tzinfo, enfold as enfold, tzname_in_python2 as tzname_in_python2, tzrangebase as tzrangebase
+from ._common import _tzinfo, enfold as enfold, tzrangebase
-_DT = TypeVar("_DT", bound=datetime.datetime)
+if sys.platform == "win32":
+ from .win import tzwin as tzwin, tzwinlocal as tzwinlocal
+else:
+ tzwin: None
+ tzwinlocal: None
-ZERO: datetime.timedelta
-EPOCH: datetime.datetime
+_DT = TypeVar("_DT", bound=datetime)
+
+ZERO: timedelta
+EPOCH: datetime
EPOCHORDINAL: int
-class tzutc(datetime.tzinfo):
- def utcoffset(self, dt: datetime.datetime | None) -> datetime.timedelta | None: ...
- def dst(self, dt: datetime.datetime | None) -> datetime.timedelta | None: ...
- def tzname(self, dt: datetime.datetime | None) -> str: ...
- def is_ambiguous(self, dt: datetime.datetime | None) -> bool: ...
+class tzutc(tzinfo):
+ def utcoffset(self, dt: datetime | None) -> timedelta | None: ...
+ def dst(self, dt: datetime | None) -> timedelta | None: ...
+ def tzname(self, dt: datetime | None) -> str: ...
+ def is_ambiguous(self, dt: datetime | None) -> bool: ...
def fromutc(self, dt: _DT) -> _DT: ...
def __eq__(self, other): ...
__hash__: ClassVar[None] # type: ignore[assignment]
def __ne__(self, other): ...
__reduce__ = object.__reduce__
-class tzoffset(datetime.tzinfo):
+UTC: tzutc
+
+class tzoffset(tzinfo):
def __init__(self, name, offset) -> None: ...
- def utcoffset(self, dt: datetime.datetime | None) -> datetime.timedelta | None: ...
- def dst(self, dt: datetime.datetime | None) -> datetime.timedelta | None: ...
- def is_ambiguous(self, dt: datetime.datetime | None) -> bool: ...
- def tzname(self, dt: datetime.datetime | None) -> str: ...
+ def utcoffset(self, dt: datetime | None) -> timedelta | None: ...
+ def dst(self, dt: datetime | None) -> timedelta | None: ...
+ def is_ambiguous(self, dt: datetime | None) -> bool: ...
+ def tzname(self, dt: datetime | None) -> str: ...
def fromutc(self, dt: _DT) -> _DT: ...
def __eq__(self, other): ...
__hash__: ClassVar[None] # type: ignore[assignment]
@@ -37,21 +46,30 @@ class tzoffset(datetime.tzinfo):
class tzlocal(_tzinfo):
def __init__(self) -> None: ...
- def utcoffset(self, dt: datetime.datetime | None) -> datetime.timedelta | None: ...
- def dst(self, dt: datetime.datetime | None) -> datetime.timedelta | None: ...
- def tzname(self, dt: datetime.datetime | None) -> str: ...
- def is_ambiguous(self, dt: datetime.datetime | None) -> bool: ...
+ def utcoffset(self, dt: datetime | None) -> timedelta | None: ...
+ def dst(self, dt: datetime | None) -> timedelta | None: ...
+ def tzname(self, dt: datetime | None) -> str: ...
+ def is_ambiguous(self, dt: datetime | None) -> bool: ...
def __eq__(self, other): ...
__hash__: ClassVar[None] # type: ignore[assignment]
def __ne__(self, other): ...
__reduce__ = object.__reduce__
class _ttinfo:
+ __slots__ = ["offset", "delta", "isdst", "abbr", "isstd", "isgmt", "dstoffset"]
+ offset: float
+ delta: timedelta
+ isdst: bool
+ abbr: str
+ isstd: bool
+ isgmt: bool
+ dstoffset: timedelta
def __init__(self) -> None: ...
def __eq__(self, other): ...
__hash__: ClassVar[None] # type: ignore[assignment]
def __ne__(self, other): ...
+@type_check_only
class _TZFileReader(Protocol):
# optional attribute:
# name: str
@@ -60,10 +78,10 @@ class _TZFileReader(Protocol):
class tzfile(_tzinfo):
def __init__(self, fileobj: str | _TZFileReader, filename: str | None = None) -> None: ...
- def is_ambiguous(self, dt: datetime.datetime | None, idx: int | None = None) -> bool: ...
- def utcoffset(self, dt: datetime.datetime | None) -> datetime.timedelta | None: ...
- def dst(self, dt: datetime.datetime | None) -> datetime.timedelta | None: ...
- def tzname(self, dt: datetime.datetime | None) -> str: ...
+ def is_ambiguous(self, dt: datetime | None, idx: int | None = None) -> bool: ...
+ def utcoffset(self, dt: datetime | None) -> timedelta | None: ...
+ def dst(self, dt: datetime | None) -> timedelta | None: ...
+ def tzname(self, dt: datetime | None) -> str: ...
def __eq__(self, other): ...
__hash__: ClassVar[None] # type: ignore[assignment]
def __ne__(self, other): ...
@@ -75,13 +93,13 @@ class tzrange(tzrangebase):
def __init__(
self,
stdabbr: str,
- stdoffset: int | datetime.timedelta | None = None,
+ stdoffset: int | timedelta | None = None,
dstabbr: str | None = None,
- dstoffset: int | datetime.timedelta | None = None,
+ dstoffset: int | timedelta | None = None,
start: relativedelta | None = None,
end: relativedelta | None = None,
) -> None: ...
- def transitions(self, year: int) -> tuple[datetime.datetime, datetime.datetime]: ...
+ def transitions(self, year: int) -> tuple[datetime, datetime]: ...
def __eq__(self, other): ...
class tzstr(tzrange):
@@ -90,6 +108,7 @@ class tzstr(tzrange):
@classmethod
def instance(cls, name, offset) -> tzoffset: ...
+@type_check_only
class _ICalReader(Protocol):
# optional attribute:
# name: str
@@ -103,12 +122,14 @@ class tzical:
TZFILES: list[str]
TZPATHS: list[str]
-def datetime_exists(dt: datetime.datetime, tz: datetime.tzinfo | None = None) -> bool: ...
-def datetime_ambiguous(dt: datetime.datetime, tz: datetime.tzinfo | None = None) -> bool: ...
-def resolve_imaginary(dt: datetime.datetime) -> datetime.datetime: ...
+def datetime_exists(dt: datetime, tz: tzinfo | None = None) -> bool: ...
+def datetime_ambiguous(dt: datetime, tz: tzinfo | None = None) -> bool: ...
+def resolve_imaginary(dt: datetime) -> datetime: ...
+# Singleton type defined locally in a function. Calls itself "GettzFunc".
+@type_check_only
class _GetTZ:
- def __call__(self, name: str | None = ...) -> datetime.tzinfo | None: ...
- def nocache(self, name: str | None) -> datetime.tzinfo | None: ...
+ def __call__(self, name: str | None = ...) -> tzinfo | None: ...
+ def nocache(self, name: str | None) -> tzinfo | None: ...
gettz: _GetTZ
diff --git a/python/helpers/typeshed/stubs/python-dateutil/dateutil/tz/win.pyi b/python/helpers/typeshed/stubs/python-dateutil/dateutil/tz/win.pyi
new file mode 100644
index 000000000000..bae9c4e9956a
--- /dev/null
+++ b/python/helpers/typeshed/stubs/python-dateutil/dateutil/tz/win.pyi
@@ -0,0 +1,26 @@
+import sys
+from ctypes import _Pointer, c_wchar
+from datetime import datetime, timedelta
+from typing import Any, ClassVar, Final
+
+from dateutil.tz import tzwin as tzwin, tzwinlocal as tzwinlocal
+
+if sys.platform == "win32":
+ from winreg import _KeyType
+
+ __all__ = ["tzwin", "tzwinlocal", "tzres"]
+
+ ONEWEEK: timedelta
+ TZKEYNAMENT: Final[str]
+ TZKEYNAME9X: Final[str]
+ TZLOCALKEYNAME: Final[str]
+ TZKEYNAME: Final[str]
+
+ class tzres:
+ p_wchar: ClassVar[type[_Pointer[c_wchar]]]
+ def __init__(self, tzres_loc="tzres.dll"): ...
+ def load_name(self, offset): ...
+ def name_from_string(self, tzname_str: str): ...
+
+ def picknthweekday(year: int, month: int, dayofweek: int, hour: int, minute: int, whichweek: int) -> datetime: ...
+ def valuestodict(key: _KeyType) -> dict[str, Any]: ... # keys and values in dict are results of winreg.EnumValue() function
diff --git a/python/helpers/typeshed/stubs/python-dateutil/dateutil/tzwin.pyi b/python/helpers/typeshed/stubs/python-dateutil/dateutil/tzwin.pyi
new file mode 100644
index 000000000000..f021d35938e6
--- /dev/null
+++ b/python/helpers/typeshed/stubs/python-dateutil/dateutil/tzwin.pyi
@@ -0,0 +1,4 @@
+import sys
+
+if sys.platform == "win32":
+ from .tz.win import tzres as tzres, tzwin as tzwin, tzwinlocal as tzwinlocal
diff --git a/python/helpers/typeshed/stubs/python-dateutil/dateutil/utils.pyi b/python/helpers/typeshed/stubs/python-dateutil/dateutil/utils.pyi
index 8c9f5e44a294..512c241832c9 100644
--- a/python/helpers/typeshed/stubs/python-dateutil/dateutil/utils.pyi
+++ b/python/helpers/typeshed/stubs/python-dateutil/dateutil/utils.pyi
@@ -1,5 +1,5 @@
-from datetime import datetime, timedelta, tzinfo
+from datetime import _TzInfo, datetime, timedelta
-def default_tzinfo(dt: datetime, tzinfo: tzinfo) -> datetime: ...
-def today(tzinfo: tzinfo | None = None) -> datetime: ...
+def today(tzinfo: _TzInfo | None = None) -> datetime: ...
+def default_tzinfo(dt: datetime, tzinfo: _TzInfo) -> datetime: ...
def within_delta(dt1: datetime, dt2: datetime, delta: timedelta) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/python-dateutil/dateutil/zoneinfo/__init__.pyi b/python/helpers/typeshed/stubs/python-dateutil/dateutil/zoneinfo/__init__.pyi
index 423e003dc095..3be08148bf08 100644
--- a/python/helpers/typeshed/stubs/python-dateutil/dateutil/zoneinfo/__init__.pyi
+++ b/python/helpers/typeshed/stubs/python-dateutil/dateutil/zoneinfo/__init__.pyi
@@ -1,17 +1,44 @@
from _typeshed import Incomplete
-from typing import IO
-from typing_extensions import TypeAlias
+from collections.abc import Callable
+from io import BytesIO
+from tarfile import _Fileobj
+from typing import Final, TypeVar, overload
+from typing_extensions import Self, TypeAlias, deprecated
+
+from dateutil.tz import tzfile as _tzfile
+
+_T = TypeVar("_T")
+_MetadataType: TypeAlias = dict[str, Incomplete]
__all__ = ["get_zonefile_instance", "gettz", "gettz_db_metadata"]
-_MetadataType: TypeAlias = dict[str, Incomplete]
+ZONEFILENAME: Final[str]
+METADATA_FN: Final[str]
+
+class tzfile(_tzfile):
+ def __reduce__(self) -> tuple[Callable[[str], Self], tuple[str, ...]]: ...
+
+def getzoneinfofile_stream() -> BytesIO | None: ...
class ZoneInfoFile:
- zones: dict[Incomplete, Incomplete]
+ zones: dict[str, _tzfile]
metadata: _MetadataType | None
- def __init__(self, zonefile_stream: IO[bytes] | None = None) -> None: ...
- def get(self, name, default=None): ...
+ def __init__(self, zonefile_stream: _Fileobj | None = None) -> None: ...
+ @overload
+ def get(self, name: str, default: None = None) -> _tzfile | None: ...
+ @overload
+ def get(self, name: str, default: _tzfile) -> _tzfile: ...
+ @overload
+ def get(self, name: str, default: _T) -> _tzfile | _T: ...
def get_zonefile_instance(new_instance: bool = False) -> ZoneInfoFile: ...
-def gettz(name): ...
+@deprecated(
+ "zoneinfo.gettz() will be removed in future versions, to use the dateutil-provided "
+ "zoneinfo files, instantiate a ZoneInfoFile object and use ZoneInfoFile.zones.get() instead."
+)
+def gettz(name: str) -> _tzfile: ...
+@deprecated(
+ "zoneinfo.gettz_db_metadata() will be removed in future versions, to use the "
+ "dateutil-provided zoneinfo files, ZoneInfoFile object and query the 'metadata' attribute instead."
+)
def gettz_db_metadata() -> _MetadataType: ...
diff --git a/python/helpers/typeshed/stubs/python-dateutil/dateutil/zoneinfo/rebuild.pyi b/python/helpers/typeshed/stubs/python-dateutil/dateutil/zoneinfo/rebuild.pyi
index 18e2d1c50b2d..9aae2bdcba44 100644
--- a/python/helpers/typeshed/stubs/python-dateutil/dateutil/zoneinfo/rebuild.pyi
+++ b/python/helpers/typeshed/stubs/python-dateutil/dateutil/zoneinfo/rebuild.pyi
@@ -1,7 +1,4 @@
from _typeshed import StrOrBytesPath
-from collections.abc import Sequence
-from tarfile import TarInfo
+from collections.abc import Iterable
-def rebuild(
- filename: StrOrBytesPath, tag=None, format: str = "gz", zonegroups: Sequence[str | TarInfo] = [], metadata=None
-) -> None: ...
+def rebuild(filename: StrOrBytesPath, tag=None, format: str = "gz", zonegroups: Iterable[str] = [], metadata=None) -> None: ...
diff --git a/python/helpers/typeshed/stubs/python-http-client/python_http_client/client.pyi b/python/helpers/typeshed/stubs/python-http-client/python_http_client/client.pyi
index f47cebc70bc8..aceb5f6cbaa8 100644
--- a/python/helpers/typeshed/stubs/python-http-client/python_http_client/client.pyi
+++ b/python/helpers/typeshed/stubs/python-http-client/python_http_client/client.pyi
@@ -1,16 +1,17 @@
from email.message import Message
-from typing import Final
+from http.client import HTTPResponse
+from typing import Any, Final
class Response:
- def __init__(self, response) -> None: ...
+ def __init__(self, response: HTTPResponse) -> None: ...
@property
def status_code(self) -> int: ...
@property
- def body(self): ...
+ def body(self) -> bytes: ...
@property
def headers(self) -> Message: ...
@property
- def to_dict(self): ...
+ def to_dict(self) -> dict[str, Any] | None: ... # dict of response from API if body is not empty
class Client:
methods: Final[set[str]]
diff --git a/python/helpers/typeshed/stubs/python-http-client/python_http_client/exceptions.pyi b/python/helpers/typeshed/stubs/python-http-client/python_http_client/exceptions.pyi
index 4852c02d679d..d896698698c1 100644
--- a/python/helpers/typeshed/stubs/python-http-client/python_http_client/exceptions.pyi
+++ b/python/helpers/typeshed/stubs/python-http-client/python_http_client/exceptions.pyi
@@ -1,15 +1,19 @@
from email.message import Message
-from typing import Final
+from typing import Any, Final, overload
+from urllib.error import HTTPError as _HTTPError
class HTTPError(Exception):
status_code: int
reason: str
- body: str
+ body: bytes
headers: Message
- def __init__(self, *args) -> None: ...
- def __reduce__(self): ...
+ @overload
+ def __init__(self, status_code: int, reason: str, body: bytes, headers: Message, /) -> None: ...
+ @overload
+ def __init__(self, http_error: _HTTPError, /) -> None: ...
+ def __reduce__(self) -> tuple[type[HTTPError], tuple[int, str, bytes, Message]]: ...
@property
- def to_dict(self): ...
+ def to_dict(self) -> dict[str, Any]: ... # dict of response error from the API
class BadRequestsError(HTTPError): ...
class UnauthorizedError(HTTPError): ...
@@ -25,4 +29,4 @@ class GatewayTimeoutError(HTTPError): ...
err_dict: Final[dict[int, type[HTTPError]]]
-def handle_error(error) -> HTTPError: ...
+def handle_error(error: _HTTPError) -> HTTPError: ...
diff --git a/python/helpers/typeshed/stubs/python-jenkins/METADATA.toml b/python/helpers/typeshed/stubs/python-jenkins/METADATA.toml
index c6777f45f7d3..fdf458654ee0 100644
--- a/python/helpers/typeshed/stubs/python-jenkins/METADATA.toml
+++ b/python/helpers/typeshed/stubs/python-jenkins/METADATA.toml
@@ -1,3 +1,3 @@
-version = "1.8.*"
+version = "~=1.8.3"
upstream_repository = "https://opendev.org/jjb/python-jenkins"
requires = ["types-requests"]
diff --git a/python/helpers/typeshed/stubs/python-jenkins/jenkins/__init__.pyi b/python/helpers/typeshed/stubs/python-jenkins/jenkins/__init__.pyi
index 0394676ed018..4dd80855bd7f 100644
--- a/python/helpers/typeshed/stubs/python-jenkins/jenkins/__init__.pyi
+++ b/python/helpers/typeshed/stubs/python-jenkins/jenkins/__init__.pyi
@@ -2,7 +2,7 @@ from _typeshed import Incomplete
from collections.abc import Mapping, MutableMapping, Sequence
from re import Pattern
from typing import Any, Final, Literal, overload
-from typing_extensions import TypeAlias
+from typing_extensions import TypeAlias, deprecated
import requests
from requests.models import Request, Response
@@ -14,6 +14,7 @@ LAUNCHER_JNLP: Final[str]
LAUNCHER_WINDOWS_SERVICE: Final[str]
DEFAULT_HEADERS: Final[dict[str, str]]
DEFAULT_TIMEOUT: Final[float]
+DEFAULT_RETRIES: Final = 0
INFO: Final[str]
PLUGIN_INFO: Final[str]
CRUMB_URL: Final[str]
@@ -96,7 +97,9 @@ class Jenkins:
auth: _Auth | None
crumb: Mapping[str, Incomplete] | bool | Incomplete
timeout: int
- def __init__(self, url: str, username: str | None = None, password: str | None = None, timeout: int = ...) -> None: ...
+ def __init__(
+ self, url: str, username: str | None = None, password: str | None = None, timeout: int = ..., retries: int = 0
+ ) -> None: ...
def maybe_add_crumb(self, req: Request) -> None: ...
def get_job_info(self, name: str, depth: int = 0, fetch_all_builds: bool = False) -> _JSON: ...
def get_job_info_regex(
@@ -112,7 +115,7 @@ class Jenkins:
def get_queue_item(self, number: int, depth: int = 0) -> _JSON: ...
def get_build_info(self, name: str, number: int, depth: int = 0) -> _JSON: ...
def get_build_env_vars(self, name: str, number: int, depth: int = 0) -> _JSON | None: ...
- def get_build_test_report(self, name: str, number: int, depth: int = 0) -> _JSON | None: ...
+ def get_build_test_report(self, name: str, number: int, depth: int = 0, tree: str | None = None) -> _JSON | None: ...
def get_build_artifact(self, name: str, number: int, artifact: str) -> _JSON: ...
def get_build_artifact_as_bytes(self, name: str, number: int, artifact: str) -> bytes: ...
def get_build_stages(self, name: str, number: int) -> _JSON: ...
@@ -121,6 +124,7 @@ class Jenkins:
def get_info(self, item: str = "", query: str | None = None) -> _JSON: ...
def get_whoami(self, depth: int = 0) -> _JSON: ...
def get_version(self) -> str: ...
+ @deprecated("Deprecated since 0.4.9. Use `get_plugins` instead.")
def get_plugins_info(self, depth: int = 2) -> _JSON: ...
def get_plugin_info(self, name: str, depth: int = 2) -> _JSON: ...
def get_plugins(self, depth: int = 2) -> _JSON: ...
@@ -179,6 +183,7 @@ class Jenkins:
def delete_build(self, name: str, number: int) -> None: ...
def wipeout_job_workspace(self, name: str) -> None: ...
def get_running_builds(self) -> list[_JSON]: ...
+ def get_nodes_with_info(self, depth: int = 0) -> list[_JSON]: ...
def get_nodes(self, depth: int = 0) -> list[_JSON]: ...
def get_node_info(self, name: str, depth: int = 0) -> _JSON: ...
def node_exists(self, name: str) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/python-nmap/nmap/nmap.pyi b/python/helpers/typeshed/stubs/python-nmap/nmap/nmap.pyi
index 9e4eb4d04692..884a9b363743 100644
--- a/python/helpers/typeshed/stubs/python-nmap/nmap/nmap.pyi
+++ b/python/helpers/typeshed/stubs/python-nmap/nmap/nmap.pyi
@@ -1,28 +1,33 @@
from collections.abc import Callable, Iterable, Iterator
-from typing import Any, TypedDict, TypeVar
+from typing import Any, TypedDict, TypeVar, type_check_only
from typing_extensions import TypeAlias
_T = TypeVar("_T")
_Callback: TypeAlias = Callable[[str, _Result], object]
+@type_check_only
class _Result(TypedDict):
nmap: _ResultNmap
scan: dict[str, PortScannerHostDict]
+@type_check_only
class _ResultNmap(TypedDict):
command_line: str
scaninfo: _ResultNmapInfo
scanstats: _ResultNampStats
+@type_check_only
class _ResultNmapInfo(TypedDict, total=False):
error: str
warning: str
protocol: _ResultNampInfoProtocol
+@type_check_only
class _ResultNampInfoProtocol(TypedDict):
method: str
services: str
+@type_check_only
class _ResultNampStats(TypedDict):
timestr: str
elapsed: str
@@ -30,14 +35,17 @@ class _ResultNampStats(TypedDict):
downhosts: str
totalhosts: str
+@type_check_only
class _ResulHostUptime(TypedDict):
seconds: str
lastboot: str
+@type_check_only
class _ResultHostNames(TypedDict):
type: str
name: str
+@type_check_only
class _ResultHostPort(TypedDict):
conf: str
cpe: str
diff --git a/python/helpers/typeshed/stubs/python-xlib/Xlib/display.pyi b/python/helpers/typeshed/stubs/python-xlib/Xlib/display.pyi
index 263f6e869476..535e3e2e0139 100644
--- a/python/helpers/typeshed/stubs/python-xlib/Xlib/display.pyi
+++ b/python/helpers/typeshed/stubs/python-xlib/Xlib/display.pyi
@@ -1,7 +1,7 @@
from collections.abc import Callable, Iterable, Sequence
from re import Pattern
from types import FunctionType, MethodType
-from typing import Any, Literal, TypedDict, overload
+from typing import Any, Literal, TypedDict, overload, type_check_only
from typing_extensions import TypeAlias
from Xlib import error
@@ -22,6 +22,7 @@ _ResourceBaseClass: TypeAlias = (
)
# Is the type of the `_resource_baseclasses` variable, defined in this file at runtime
+@type_check_only
class _ResourceBaseClassesType(TypedDict): # noqa: Y049
resource: type[resource.Resource]
drawable: type[drawable.Drawable]
diff --git a/python/helpers/typeshed/stubs/python-xlib/Xlib/rdb.pyi b/python/helpers/typeshed/stubs/python-xlib/Xlib/rdb.pyi
index a31cbff9c88f..e330353a01ec 100644
--- a/python/helpers/typeshed/stubs/python-xlib/Xlib/rdb.pyi
+++ b/python/helpers/typeshed/stubs/python-xlib/Xlib/rdb.pyi
@@ -1,7 +1,7 @@
from _typeshed import SupportsDunderGT, SupportsDunderLT, SupportsRead
from collections.abc import Iterable, Mapping, Sequence
from re import Pattern
-from typing import Any, Final, Protocol, TypeVar, overload
+from typing import Any, Final, Protocol, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
from Xlib.display import Display
@@ -15,6 +15,7 @@ _DB: TypeAlias = dict[str, tuple[_DB, ...]]
# so this is a slightly less precise version of the _DB alias for parameter annotations
_DB_Param: TypeAlias = dict[str, Any]
+@type_check_only
class _SupportsComparisons(SupportsDunderLT[_T_contra], SupportsDunderGT[_T_contra], Protocol[_T_contra]): ...
comment_re: Final[Pattern[str]]
diff --git a/python/helpers/typeshed/stubs/pytz/pytz/__init__.pyi b/python/helpers/typeshed/stubs/pytz/pytz/__init__.pyi
index 78b0a8c4e506..2f243cbb3bf4 100644
--- a/python/helpers/typeshed/stubs/pytz/pytz/__init__.pyi
+++ b/python/helpers/typeshed/stubs/pytz/pytz/__init__.pyi
@@ -1,7 +1,7 @@
import datetime
from _typeshed import Unused
from collections.abc import Mapping
-from typing import ClassVar
+from typing import ClassVar, type_check_only
from .exceptions import (
AmbiguousTimeError as AmbiguousTimeError,
@@ -12,6 +12,7 @@ from .exceptions import (
from .tzinfo import BaseTzInfo as BaseTzInfo, DstTzInfo, StaticTzInfo
# Actually named UTC and then masked with a singleton with the same name
+@type_check_only
class _UTCclass(BaseTzInfo):
def localize(self, dt: datetime.datetime, is_dst: bool | None = False) -> datetime.datetime: ...
def normalize(self, dt: datetime.datetime, is_dst: bool | None = False) -> datetime.datetime: ...
diff --git a/python/helpers/typeshed/stubs/pywin32/@tests/stubtest_allowlist_win32.txt b/python/helpers/typeshed/stubs/pywin32/@tests/stubtest_allowlist_win32.txt
index c2329ad6412d..37ea55f8e223 100644
--- a/python/helpers/typeshed/stubs/pywin32/@tests/stubtest_allowlist_win32.txt
+++ b/python/helpers/typeshed/stubs/pywin32/@tests/stubtest_allowlist_win32.txt
@@ -22,9 +22,6 @@ win32com.makegw.*
(win32.lib.)?pywintypes.__import_pywin32_system_module__
# COM object servers scripts
-win32com.server.factory
-win32com.server.localserver
-win32com.server.register
win32com.servers.*
# Active X Scripts
win32com(ext)?.axscript.client.pyscript_rexec
diff --git a/python/helpers/typeshed/stubs/pywin32/METADATA.toml b/python/helpers/typeshed/stubs/pywin32/METADATA.toml
index 338759b1d81b..7e375492009f 100644
--- a/python/helpers/typeshed/stubs/pywin32/METADATA.toml
+++ b/python/helpers/typeshed/stubs/pywin32/METADATA.toml
@@ -1,5 +1,6 @@
-version = "310.*"
+version = "311.*"
upstream_repository = "https://github.com/mhammond/pywin32"
[tool.stubtest]
-platforms = ["win32"]
+supported_platforms = ["win32"]
+ci_platforms = ["win32"]
diff --git a/python/helpers/typeshed/stubs/pywin32/_win32typing.pyi b/python/helpers/typeshed/stubs/pywin32/_win32typing.pyi
index 63777e1e05d5..3dd44c61c1e1 100644
--- a/python/helpers/typeshed/stubs/pywin32/_win32typing.pyi
+++ b/python/helpers/typeshed/stubs/pywin32/_win32typing.pyi
@@ -1667,7 +1667,7 @@ class PySecBufferDesc:
Version: Incomplete
Buffer: Incomplete
def append(self, buffer, /) -> None: ...
- def __getitem__(self, index: SupportsIndex) -> PySecBuffer: ...
+ def __getitem__(self, index: SupportsIndex, /) -> PySecBuffer: ...
class PyTOKEN_GROUPS: ...
class PyTOKEN_PRIVILEGES: ...
diff --git a/python/helpers/typeshed/stubs/pywin32/pythoncom.pyi b/python/helpers/typeshed/stubs/pywin32/pythoncom.pyi
index 0e0c3bc0147c..657a736f0c55 100644
--- a/python/helpers/typeshed/stubs/pywin32/pythoncom.pyi
+++ b/python/helpers/typeshed/stubs/pywin32/pythoncom.pyi
@@ -47,9 +47,9 @@ def CoUnmarshalInterface(Stm: _win32typing.PyIStream, riid: _win32typing.PyIID,
def CoReleaseMarshalData(Stm: _win32typing.PyIStream, /) -> None: ...
def CoGetObject(name: str, iid: _win32typing.PyIID, bindOpts: Incomplete | None = ..., /) -> _win32typing.PyIUnknown: ...
def CoUninitialize() -> None: ...
-def CoRegisterClassObject(iid: _win32typing.PyIID, factory: _win32typing.PyIUnknown, context, flags, /): ...
+def CoRegisterClassObject(iid: _win32typing.PyIID, factory: _win32typing.PyIUnknown, context, flags, /) -> int: ...
def CoResumeClassObjects() -> None: ...
-def CoRevokeClassObject(reg, /) -> None: ...
+def CoRevokeClassObject(reg: int, /) -> None: ...
def CoTreatAsClass(clsidold: _win32typing.PyIID, clsidnew: _win32typing.PyIID, /) -> None: ...
def CoWaitForMultipleHandles(Flags, Timeout, Handles: list[int], /): ...
def Connect(cls, /) -> _win32typing.PyIDispatch: ...
diff --git a/python/helpers/typeshed/stubs/pywin32/win32/lib/win32con.pyi b/python/helpers/typeshed/stubs/pywin32/win32/lib/win32con.pyi
index a64e7d157553..6a7da2eb4913 100644
--- a/python/helpers/typeshed/stubs/pywin32/win32/lib/win32con.pyi
+++ b/python/helpers/typeshed/stubs/pywin32/win32/lib/win32con.pyi
@@ -607,6 +607,8 @@ IDC_NO: Final = 32648
IDC_HAND: Final = 32649
IDC_APPSTARTING: Final = 32650
IDC_HELP: Final = 32651
+IDC_PIN: Final = 32671
+IDC_PERSON: Final = 32672
IMAGE_BITMAP: Final = 0
IMAGE_ICON: Final = 1
IMAGE_CURSOR: Final = 2
diff --git a/python/helpers/typeshed/stubs/pywin32/win32/win32console.pyi b/python/helpers/typeshed/stubs/pywin32/win32/win32console.pyi
index c442b30ecdd6..f59d23db73da 100644
--- a/python/helpers/typeshed/stubs/pywin32/win32/win32console.pyi
+++ b/python/helpers/typeshed/stubs/pywin32/win32/win32console.pyi
@@ -24,7 +24,7 @@ def GetNumberOfConsoleFonts(): ...
def SetConsoleTitle(ConsoleTitle: str) -> None: ...
def GetConsoleTitle(): ...
@overload
-def GenerateConsoleCtrlEvent(CtrlEvent: Literal[1], ProcessGroupId: Literal[0] = ...) -> NoReturn: ...
+def GenerateConsoleCtrlEvent(CtrlEvent: Literal[1], ProcessGroupId: Literal[0] = 0) -> NoReturn: ...
@overload
def GenerateConsoleCtrlEvent(CtrlEvent: Literal[0, 1], ProcessGroupId: int) -> None: ...
def GetStdHandle(StdHandle: int) -> _win32typing.PyConsoleScreenBuffer: ...
diff --git a/python/helpers/typeshed/stubs/pywin32/win32/win32security.pyi b/python/helpers/typeshed/stubs/pywin32/win32/win32security.pyi
index 98309da326e0..eed2a902ad81 100644
--- a/python/helpers/typeshed/stubs/pywin32/win32/win32security.pyi
+++ b/python/helpers/typeshed/stubs/pywin32/win32/win32security.pyi
@@ -41,7 +41,7 @@ def LogonUserEx(
Username: str, Domain: str, Password: str, LogonType, LogonProvider
) -> tuple[int, _win32typing.PySID, Incomplete, Incomplete]: ...
def LookupAccountName(systemName: str | None, accountName: str, /) -> tuple[_win32typing.PySID, str, int]: ...
-def LookupAccountSid(systemName: str, sid: _win32typing.PySID, /) -> tuple[str, str, Incomplete]: ...
+def LookupAccountSid(systemName: str | None, sid: _win32typing.PySID, /) -> tuple[str, str, Incomplete]: ...
def GetBinarySid(SID: str, /) -> _win32typing.PySID: ...
def SetSecurityInfo(
handle: int,
diff --git a/python/helpers/typeshed/stubs/pywin32/win32com/client/__init__.pyi b/python/helpers/typeshed/stubs/pywin32/win32com/client/__init__.pyi
index c4c3f2a4e1ad..987a842edbec 100644
--- a/python/helpers/typeshed/stubs/pywin32/win32com/client/__init__.pyi
+++ b/python/helpers/typeshed/stubs/pywin32/win32com/client/__init__.pyi
@@ -1,4 +1,5 @@
-from _typeshed import Incomplete
+from _typeshed import Incomplete, Unused
+from collections.abc import Iterator
from typing import Final
from typing_extensions import TypeAlias
@@ -62,12 +63,12 @@ class CoClassBaseClass:
def __init__(self, oobj: Incomplete | None = ...) -> None: ...
def __getattr__(self, attr: str): ...
def __setattr__(self, attr: str, value) -> None: ...
- def __maybe__call__(self, *args, **kwargs): ...
- def __maybe__str__(self, *args): ...
- def __maybe__int__(self, *args): ...
- def __maybe__iter__(self): ...
- def __maybe__len__(self): ...
- def __maybe__bool__(self): ...
+ def __call__(self, *args, **kwargs): ...
+ def __str__(self, *args: Unused) -> str: ... # noqa: Y029
+ def __int__(self, *args: Unused) -> int: ...
+ def __iter__(self) -> Iterator[Incomplete]: ...
+ def __len__(self) -> int: ...
+ def __bool__(self) -> bool: ...
class VARIANT:
varianttype: Incomplete
diff --git a/python/helpers/typeshed/stubs/pywin32/win32com/server/factory.pyi b/python/helpers/typeshed/stubs/pywin32/win32com/server/factory.pyi
new file mode 100644
index 000000000000..3de546181158
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pywin32/win32com/server/factory.pyi
@@ -0,0 +1,9 @@
+from _typeshed import Unused
+from collections.abc import Iterable
+
+from _win32typing import PyIClassFactory, PyIID
+
+def RegisterClassFactories(
+ clsids: Iterable[PyIID], flags: int | None = None, clsctx: int | None = None
+) -> list[tuple[PyIClassFactory, int]]: ...
+def RevokeClassFactories(infos: Iterable[tuple[Unused, int]]) -> None: ...
diff --git a/python/helpers/typeshed/stubs/pywin32/win32com/server/localserver.pyi b/python/helpers/typeshed/stubs/pywin32/win32com/server/localserver.pyi
new file mode 100644
index 000000000000..dd0f6c43efb0
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pywin32/win32com/server/localserver.pyi
@@ -0,0 +1,9 @@
+from collections.abc import Iterable
+from typing import Final
+
+from _win32typing import PyIID
+
+usage: Final[str]
+
+def serve(clsids: Iterable[PyIID]) -> None: ...
+def main() -> None: ...
diff --git a/python/helpers/typeshed/stubs/pywin32/win32com/server/register.pyi b/python/helpers/typeshed/stubs/pywin32/win32com/server/register.pyi
new file mode 100644
index 000000000000..78fb2c6899fe
--- /dev/null
+++ b/python/helpers/typeshed/stubs/pywin32/win32com/server/register.pyi
@@ -0,0 +1,68 @@
+from collections.abc import Callable, Iterable, Mapping
+from typing import Final, Literal, Protocol, TypedDict, TypeVar, type_check_only
+from typing_extensions import Unpack
+
+from _win32typing import PyHKEY, PyIID
+
+_T = TypeVar("_T", PyHKEY, int)
+
+@type_check_only
+class _RegisterClass(Protocol):
+ _reg_clsid_: PyIID
+
+@type_check_only
+class _RegisterFlag(TypedDict, total=False):
+ quiet: bool
+ debug: bool
+ finalize_register: Callable[[], None]
+
+@type_check_only
+class _UnregisterFlag(TypedDict, total=False):
+ quiet: bool
+ finalize_unregister: Callable[[], None]
+
+@type_check_only
+class _ElevatedFlag(TypedDict, total=False):
+ quiet: bool
+ unattended: bool
+ hwnd: int
+
+@type_check_only
+class _CommandFlag(_RegisterFlag, _UnregisterFlag, _ElevatedFlag): # type: ignore[misc]
+ ...
+
+CATID_PythonCOMServer: Final = "{B3EF80D0-68E2-11D0-A689-00C04FD658FF}"
+
+def recurse_delete_key(path: str | None, base: PyHKEY | int = -2147483648) -> None: ...
+def RegisterServer(
+ clsid: PyIID,
+ pythonInstString: str | None = None,
+ desc: str | None = None,
+ progID: str | None = None,
+ verProgID: str | None = None,
+ defIcon: str | None = None,
+ threadingModel: Literal["apartment", "both", "free", "neutral"] = "both",
+ policy: str | None = None,
+ catids: list[PyIID] = [],
+ other: Mapping[str, str] = {},
+ addPyComCat: bool | None = None,
+ dispatcher: str | None = None,
+ clsctx: int | None = None,
+ addnPath: str | None = None,
+) -> None: ...
+def GetUnregisterServerKeys(
+ clsid: PyIID, progID: str | None = None, verProgID: str | None = None, customKeys: Iterable[tuple[str, _T]] | None = None
+) -> list[tuple[str, _T | int]]: ...
+def UnregisterServer(
+ clsid: PyIID,
+ progID: str | None = None,
+ verProgID: str | None = None,
+ customKeys: Iterable[tuple[str, PyHKEY | int]] | None = None,
+) -> None: ...
+def GetRegisteredServerOption(clsid: PyIID, optionName: str) -> str | None: ...
+def RegisterClasses(*classes: type[_RegisterClass], **flags: Unpack[_RegisterFlag]) -> None: ...
+def UnregisterClasses(*classes: type[_RegisterClass], **flags: Unpack[_UnregisterFlag]) -> None: ...
+def UnregisterInfoClasses(*classes: type[_RegisterClass]) -> list[tuple[str, PyHKEY | int]]: ...
+def ReExecuteElevated(flags: _ElevatedFlag) -> None: ...
+def UseCommandLine(*classes: type[_RegisterClass], **flags: Unpack[_CommandFlag]) -> list[tuple[str, PyHKEY | int]] | None: ...
+def RegisterPyComCategory() -> None: ...
diff --git a/python/helpers/typeshed/stubs/pywin32/win32comext/propsys/pscon.pyi b/python/helpers/typeshed/stubs/pywin32/win32comext/propsys/pscon.pyi
index f142fe8e7c6f..799bc0fa1382 100644
--- a/python/helpers/typeshed/stubs/pywin32/win32comext/propsys/pscon.pyi
+++ b/python/helpers/typeshed/stubs/pywin32/win32comext/propsys/pscon.pyi
@@ -652,6 +652,7 @@ PKEY_Link_TargetUrl: Incomplete
PKEY_Shell_SFGAOFlagsStrings: Incomplete
PKEY_Software_DateLastUsed: Incomplete
PKEY_Software_ProductName: Incomplete
+PKEY_Software_ProductVersion: Incomplete
PKEY_Sync_Comments: Incomplete
PKEY_Sync_ConflictDescription: Incomplete
PKEY_Sync_ConflictFirstLocation: Incomplete
diff --git a/python/helpers/typeshed/stubs/pywin32/win32comext/shell/shell.pyi b/python/helpers/typeshed/stubs/pywin32/win32comext/shell/shell.pyi
index 7688b08f819a..8b63eda438ff 100644
--- a/python/helpers/typeshed/stubs/pywin32/win32comext/shell/shell.pyi
+++ b/python/helpers/typeshed/stubs/pywin32/win32comext/shell/shell.pyi
@@ -98,7 +98,7 @@ def SHCreateShellItem(
) -> _win32typing.PyIShellItem: ...
def SHOpenFolderAndSelectItems(Folder: _win32typing.PyIDL, Items: tuple[_win32typing.PyIDL, ...], Flags=...) -> None: ...
def SHCreateStreamOnFileEx(
- File: str, Mode: int, Attributes: int, Create: bool, Template: None = ...
+ File: str, Mode: int, Attributes: int, Create: bool, Template: None = None
) -> _win32typing.PyIStream: ...
def SetCurrentProcessExplicitAppUserModelID(AppID: str, /) -> None: ...
def GetCurrentProcessExplicitAppUserModelID() -> str: ...
diff --git a/python/helpers/typeshed/stubs/pyxdg/xdg/Menu.pyi b/python/helpers/typeshed/stubs/pyxdg/xdg/Menu.pyi
index 77738a4615a7..e2c288e85326 100644
--- a/python/helpers/typeshed/stubs/pyxdg/xdg/Menu.pyi
+++ b/python/helpers/typeshed/stubs/pyxdg/xdg/Menu.pyi
@@ -147,7 +147,7 @@ class XMLMenuBuilder:
def parse_default_directory_dir(self, filename: str, parent: str) -> None: ...
def parse_merge_file(self, value: str, child: Menu | MenuEntry, filename: str, parent: str) -> None: ...
def parse_merge_dir(self, value: str, child: Menu | MenuEntry, filename: str, parent: str) -> None: ...
- def parse_default_merge_dirs(self, child, filename: str, parent: str) -> None: ...
+ def parse_default_merge_dirs(self, child: Menu | MenuEntry, filename: str, parent: str) -> None: ...
def merge_file(self, filename: str, child: Unused, parent: Menu) -> None: ...
def parse_legacy_dir(self, dir_: str, prefix: str, filename: str, parent: str) -> None: ...
def merge_legacy_dir(self, dir_: str, prefix: str, filename: str, parent: str) -> Menu: ...
diff --git a/python/helpers/typeshed/stubs/regex/METADATA.toml b/python/helpers/typeshed/stubs/regex/METADATA.toml
index f0719a7db61a..ce89b537b668 100644
--- a/python/helpers/typeshed/stubs/regex/METADATA.toml
+++ b/python/helpers/typeshed/stubs/regex/METADATA.toml
@@ -1,2 +1,2 @@
-version = "2024.11.6"
+version = "2025.7.34"
upstream_repository = "https://github.com/mrabarnett/mrab-regex"
diff --git a/python/helpers/typeshed/stubs/reportlab/reportlab/graphics/barcode/qr.pyi b/python/helpers/typeshed/stubs/reportlab/reportlab/graphics/barcode/qr.pyi
index d680aa8b304d..817ba00d72e0 100644
--- a/python/helpers/typeshed/stubs/reportlab/reportlab/graphics/barcode/qr.pyi
+++ b/python/helpers/typeshed/stubs/reportlab/reportlab/graphics/barcode/qr.pyi
@@ -1,4 +1,5 @@
from _typeshed import Incomplete
+from typing import type_check_only
from reportlab.graphics.shapes import Rect
from reportlab.graphics.widgetbase import Widget
@@ -7,11 +8,13 @@ from reportlab.platypus.flowables import Flowable
__all__ = ["QrCodeWidget"]
+@type_check_only
class _isLevel(Validator):
def test(self, x): ...
isLevel: _isLevel
+@type_check_only
class _isUnicodeOrQRList(Validator):
def test(self, x): ...
def normalize(self, x): ...
diff --git a/python/helpers/typeshed/stubs/reportlab/reportlab/graphics/shapes.pyi b/python/helpers/typeshed/stubs/reportlab/reportlab/graphics/shapes.pyi
index e2fd9b268bd3..f9d290b79a2c 100644
--- a/python/helpers/typeshed/stubs/reportlab/reportlab/graphics/shapes.pyi
+++ b/python/helpers/typeshed/stubs/reportlab/reportlab/graphics/shapes.pyi
@@ -1,7 +1,7 @@
from _typeshed import Incomplete, SupportsItems
from abc import abstractmethod
from collections.abc import Iterable, Sequence
-from typing import Any, Final, Literal, NoReturn, TypedDict
+from typing import Any, Final, Literal, NoReturn, TypedDict, type_check_only
from typing_extensions import Self, TypeAlias, Unpack
from reportlab.lib.colors import Color
@@ -25,6 +25,7 @@ _PathOp: TypeAlias = (
# NOTE: These are derived from _attrMap and can optionally be
# verified at runtime
+@type_check_only
class _GroupKwArgs(TypedDict, total=False):
transform: tuple[float, float, float, float, float, float] | list[float] | list[int]
# NOTE: This should be used with care, since it will replace elements
@@ -35,6 +36,7 @@ class _GroupKwArgs(TypedDict, total=False):
fillOverprint: _BoolLike
overprintMask: _BoolLike
+@type_check_only
class _DrawingKwArgs(_GroupKwArgs, total=False):
# TODO: Restrict to supported formats?
formats: list[str] | tuple[str, ...]
@@ -50,6 +52,7 @@ class _DrawingKwArgs(_GroupKwArgs, total=False):
initialFontName: str | None
initialFontSize: float | None
+@type_check_only
class _LineShapeKwArgs(TypedDict, total=False):
strokeColor: Color | None
strokeWidth: float
@@ -61,11 +64,13 @@ class _LineShapeKwArgs(TypedDict, total=False):
strokeOverprint: _BoolLike
overprintMask: _BoolLike
+@type_check_only
class _PathKwArgs(_LineShapeKwArgs, total=False):
fillColor: Color | None
fillOpacity: float
fillOverprint: _BoolLike
+@type_check_only
class _AllPathKwArgs(_PathKwArgs, total=False):
points: list[float] | None
operators: list[float] | None
@@ -73,17 +78,21 @@ class _AllPathKwArgs(_PathKwArgs, total=False):
autoclose: Literal["svg", "pdf"] | None
fillMode: Literal[0, 1]
+@type_check_only
class _SolidShapeKwArgs(_PathKwArgs, total=False):
fillMode: Literal[0, 1]
+@type_check_only
class _DefinePathKwArgs(_SolidShapeKwArgs, total=False):
autoclose: Literal["svg", "pdf"] | None
bbox: tuple[float, float, float, float] | None
+@type_check_only
class _WedgeKwArgs(_SolidShapeKwArgs, total=False):
radius1: float | None
yradius1: float | None
+@type_check_only
class _StringKwArgs(TypedDict, total=False):
fontName: str
fontSize: float
@@ -161,6 +170,7 @@ class Drawing(Group, Flowable):
class _DrawingEditorMixin: ...
+@type_check_only
class _isStrokeDashArray(Validator):
def test(self, x): ...
diff --git a/python/helpers/typeshed/stubs/reportlab/reportlab/lib/colors.pyi b/python/helpers/typeshed/stubs/reportlab/reportlab/lib/colors.pyi
index ed615bae2e1c..362233967f88 100644
--- a/python/helpers/typeshed/stubs/reportlab/reportlab/lib/colors.pyi
+++ b/python/helpers/typeshed/stubs/reportlab/reportlab/lib/colors.pyi
@@ -1,5 +1,5 @@
from collections.abc import Iterable, Iterator
-from typing import Final, Literal, TypeVar, overload
+from typing import Final, Literal, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias
_ColorT = TypeVar("_ColorT", bound=Color)
@@ -288,7 +288,7 @@ def describe(aColor: Color, mode: Literal[1]) -> str: ...
def describe(aColor: Color, mode: Literal[2]) -> tuple[str, float]: ...
def hue2rgb(m1: float, m2: float, h: float) -> float: ...
def hsl2rgb(h: float, s: float, l: float) -> tuple[float, float, float]: ...
-
+@type_check_only
class _cssParse:
def pcVal(self, v: str) -> float: ...
def rgbPcVal(self, v: str) -> float: ...
@@ -300,6 +300,7 @@ class _cssParse:
cssParse: _cssParse
+@type_check_only
class _toColor:
extraColorsNS: dict[str, Color]
def __init__(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/reportlab/reportlab/lib/rparsexml.pyi b/python/helpers/typeshed/stubs/reportlab/reportlab/lib/rparsexml.pyi
index 4bff57d0bd6a..62816ccd098f 100644
--- a/python/helpers/typeshed/stubs/reportlab/reportlab/lib/rparsexml.pyi
+++ b/python/helpers/typeshed/stubs/reportlab/reportlab/lib/rparsexml.pyi
@@ -1,8 +1,10 @@
from _typeshed import Incomplete
+from typing import type_check_only
RequirePyRXP: int
simpleparse: int
+@type_check_only
class _smartDecode:
@staticmethod
def __call__(s): ...
diff --git a/python/helpers/typeshed/stubs/reportlab/reportlab/lib/utils.pyi b/python/helpers/typeshed/stubs/reportlab/reportlab/lib/utils.pyi
index bb22eef1f3f7..8aafa063ccf3 100644
--- a/python/helpers/typeshed/stubs/reportlab/reportlab/lib/utils.pyi
+++ b/python/helpers/typeshed/stubs/reportlab/reportlab/lib/utils.pyi
@@ -4,7 +4,7 @@ from _typeshed import Incomplete, SupportsItems
from collections.abc import Generator, Iterable
from os import PathLike
from types import TracebackType
-from typing import AnyStr, Final, Literal, TypeVar, overload
+from typing import AnyStr, Final, Literal, TypeVar, overload, type_check_only
from reportlab.lib.rltempfile import get_rl_tempdir as get_rl_tempdir, get_rl_tempfile as get_rl_tempfile
@@ -19,6 +19,7 @@ _VT = TypeVar("_VT")
__version__: Final[str]
+@type_check_only
class _UNSET_:
@staticmethod
def __bool__() -> Literal[False]: ...
diff --git a/python/helpers/typeshed/stubs/reportlab/reportlab/pdfbase/ttfonts.pyi b/python/helpers/typeshed/stubs/reportlab/reportlab/pdfbase/ttfonts.pyi
index d410830bd2e8..a9441c8731c9 100644
--- a/python/helpers/typeshed/stubs/reportlab/reportlab/pdfbase/ttfonts.pyi
+++ b/python/helpers/typeshed/stubs/reportlab/reportlab/pdfbase/ttfonts.pyi
@@ -183,4 +183,4 @@ class ShapedStr(str):
def shapeStr(s: str, fontName: str, fontSize: float, force: bool = False): ...
def freshTTFont(ttfn, ttfpath, **kwds) -> TTFont: ...
def makeShapedFragWord(w, K: list[Incomplete] = [], V: list[Incomplete] = []) -> type[ShapedFragWord]: ...
-def shapeFragWord(w, features=..., force: bool = False): ...
+def shapeFragWord(w, features=None, force: bool = False): ...
diff --git a/python/helpers/typeshed/stubs/reportlab/reportlab/platypus/doctemplate.pyi b/python/helpers/typeshed/stubs/reportlab/reportlab/platypus/doctemplate.pyi
index 5dc5ca0c6d7e..57b083ff1f2f 100644
--- a/python/helpers/typeshed/stubs/reportlab/reportlab/platypus/doctemplate.pyi
+++ b/python/helpers/typeshed/stubs/reportlab/reportlab/platypus/doctemplate.pyi
@@ -1,7 +1,7 @@
from _typeshed import Incomplete
from abc import abstractmethod
from collections.abc import Callable
-from typing import IO, Any, Literal, Protocol
+from typing import IO, Any, Literal, Protocol, type_check_only
from typing_extensions import Self, TypeAlias
from reportlab.pdfgen.canvas import Canvas
@@ -33,6 +33,7 @@ __all__ = (
# type vars didn't seem to work for this one
_PageCallback: TypeAlias = Callable[[Canvas, Any], object]
+@type_check_only
class _CanvasMaker(Protocol):
# NOTE: This matches a subset of Canvas.__init__
def __call__(
diff --git a/python/helpers/typeshed/stubs/reportlab/reportlab/platypus/flowables.pyi b/python/helpers/typeshed/stubs/reportlab/reportlab/platypus/flowables.pyi
index b51aa216c3da..76dc086703ff 100644
--- a/python/helpers/typeshed/stubs/reportlab/reportlab/platypus/flowables.pyi
+++ b/python/helpers/typeshed/stubs/reportlab/reportlab/platypus/flowables.pyi
@@ -1,6 +1,6 @@
from _typeshed import Incomplete, SupportsRead, Unused
from collections.abc import Callable, Iterable, Sequence
-from typing import Any, Literal, NoReturn, Protocol
+from typing import Any, Literal, NoReturn, Protocol, type_check_only
from typing_extensions import Self, TypeAlias
from reportlab.lib.colors import Color
@@ -64,6 +64,7 @@ _FlowableSublist: TypeAlias = Flowable | list[Flowable] | tuple[Flowable, ...]
# NOTE: Technically can only be list or tuple, but would be annoying for variance
_NestedFlowable: TypeAlias = Flowable | Sequence[_NestedFlowable]
+@type_check_only
class _StyledFlowableFactory(Protocol):
# NOTE: We leave style at Any so people can specify a specifc property set
def __call__(self, value: str, /, *, style: Any) -> Flowable: ...
diff --git a/python/helpers/typeshed/stubs/reportlab/reportlab/platypus/para.pyi b/python/helpers/typeshed/stubs/reportlab/reportlab/platypus/para.pyi
index 5ed3412baad3..a83dce246445 100644
--- a/python/helpers/typeshed/stubs/reportlab/reportlab/platypus/para.pyi
+++ b/python/helpers/typeshed/stubs/reportlab/reportlab/platypus/para.pyi
@@ -1,6 +1,6 @@
from _typeshed import Incomplete, Unused
from collections.abc import Callable, Mapping
-from typing import Any, Final, Literal, Protocol, TypedDict, TypeVar, overload
+from typing import Any, Final, Literal, Protocol, TypedDict, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias, Unpack
from reportlab.lib.colors import Color
@@ -15,14 +15,17 @@ _Op: TypeAlias = _SupportsWidthAndExecute | str | float | tuple[str, Unpack[tupl
# NOTE: Output from pyRXP xml parser
_ParsedText: TypeAlias = tuple[str, dict[str, Any], list[_ParsedText], Any] | list[_ParsedText] | str
+@type_check_only
class _LineOpHandler(Protocol):
def start_at(self, x: float, y: float, para: paragraphEngine, canvas: Canvas, textobject: PDFTextObject) -> None: ...
def end_at(self, x: float, y: float, para: paragraphEngine, canvas: Canvas, textobject: PDFTextObject) -> None: ...
+@type_check_only
class _SupportsWidthAndExecute(Protocol):
def width(self, engine) -> float: ...
def execute(self, engine, textobject: PDFTextObject, canvas: Canvas) -> object: ...
+@type_check_only
class _SimpleStyleKwargs(TypedDict, total=False):
fontName: str
fontSize: float
diff --git a/python/helpers/typeshed/stubs/reportlab/reportlab/platypus/tableofcontents.pyi b/python/helpers/typeshed/stubs/reportlab/reportlab/platypus/tableofcontents.pyi
index c947ec8ad109..8159bde6ae53 100644
--- a/python/helpers/typeshed/stubs/reportlab/reportlab/platypus/tableofcontents.pyi
+++ b/python/helpers/typeshed/stubs/reportlab/reportlab/platypus/tableofcontents.pyi
@@ -1,6 +1,6 @@
from _typeshed import Unused
from collections.abc import Callable, Iterable, Sequence
-from typing import Any, Final, Literal, TypedDict, TypeVar, overload
+from typing import Any, Final, Literal, TypedDict, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias, Unpack
from reportlab.lib.styles import ParagraphStyle, PropertySet
@@ -12,6 +12,7 @@ _T = TypeVar("_T")
_Entry: TypeAlias = tuple[int, str, int] | tuple[int, str, int, str | None] | Sequence[int | str | None]
_SequencerFormat: TypeAlias = Literal["I", "i", "123", "ABC", "abc"]
+@type_check_only
class _TableOfContentsKwargs(TypedDict, total=False):
rightColumnWidth: float
levelStyles: list[PropertySet] # should be ParagraphStyle
@@ -19,6 +20,7 @@ class _TableOfContentsKwargs(TypedDict, total=False):
dotsMinLevel: int
formatter: Callable[[int], str] | None
+@type_check_only
class _SimpleIndexKwargs(TypedDict, total=False):
style: Iterable[PropertySet] | PropertySet | None # should be ParagraphStyle
dot: str | None
diff --git a/python/helpers/typeshed/stubs/requests-oauthlib/requests_oauthlib/oauth1_session.pyi b/python/helpers/typeshed/stubs/requests-oauthlib/requests_oauthlib/oauth1_session.pyi
index e97a83ba0a5f..a6e089ec90d7 100644
--- a/python/helpers/typeshed/stubs/requests-oauthlib/requests_oauthlib/oauth1_session.pyi
+++ b/python/helpers/typeshed/stubs/requests-oauthlib/requests_oauthlib/oauth1_session.pyi
@@ -1,6 +1,6 @@
from _typeshed import Incomplete
from logging import Logger
-from typing import TypedDict
+from typing import TypedDict, type_check_only
from typing_extensions import TypeAlias
import requests
@@ -11,6 +11,7 @@ from . import OAuth1
# should be dict[str, str] but could look different
_ParsedToken: TypeAlias = dict[str, Incomplete]
+@type_check_only
class _TokenDict(TypedDict, total=False):
oauth_token: Incomplete # oauthlib.oauth1.Client.resource_owner_key
oauth_token_secret: Incomplete # oauthlib.oauth1.Client.resource_token_secret
diff --git a/python/helpers/typeshed/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi b/python/helpers/typeshed/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi
index 300230fd1ce3..1ad322a9f42c 100644
--- a/python/helpers/typeshed/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi
+++ b/python/helpers/typeshed/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi
@@ -1,6 +1,6 @@
from _typeshed import Incomplete
from logging import Logger
-from typing import Any, Literal, Protocol, TypedDict, overload
+from typing import Any, Literal, Protocol, TypedDict, overload, type_check_only
from typing_extensions import TypeAlias
import requests
@@ -9,15 +9,19 @@ from requests.cookies import RequestsCookieJar
_Token: TypeAlias = dict[str, Incomplete] # oauthlib.oauth2.Client.token
+@type_check_only
class _AccessTokenResponseHook(Protocol):
def __call__(self, response: requests.Response, /) -> requests.Response: ...
+@type_check_only
class _RefreshTokenResponseHook(Protocol):
def __call__(self, response: requests.Response, /) -> requests.Response: ...
+@type_check_only
class _ProtectedRequestHook(Protocol):
def __call__(self, url, headers, data, /) -> tuple[Incomplete, Incomplete, Incomplete]: ...
+@type_check_only
class _ComplianceHooks(TypedDict):
access_token_response: set[_AccessTokenResponseHook]
refresh_token_response: set[_RefreshTokenResponseHook]
diff --git a/python/helpers/typeshed/stubs/requests/requests/adapters.pyi b/python/helpers/typeshed/stubs/requests/requests/adapters.pyi
index 2f8e4d75cd97..208c7264d694 100644
--- a/python/helpers/typeshed/stubs/requests/requests/adapters.pyi
+++ b/python/helpers/typeshed/stubs/requests/requests/adapters.pyi
@@ -1,7 +1,7 @@
from _typeshed import Incomplete
from collections.abc import Mapping
from ssl import SSLContext
-from typing import Literal, TypedDict
+from typing import Literal, TypedDict, type_check_only
from typing_extensions import NotRequired, deprecated
import urllib3
@@ -38,11 +38,13 @@ from .utils import (
)
# Arguments to urllib3 connection_from_host() functions (except pool_kwargs).
+@type_check_only
class _HostParams(TypedDict):
host: str
scheme: str
port: int
+@type_check_only
class _PoolKwargs(TypedDict):
ssl_context: NotRequired[SSLContext]
ca_certs: NotRequired[str]
diff --git a/python/helpers/typeshed/stubs/requests/requests/help.pyi b/python/helpers/typeshed/stubs/requests/requests/help.pyi
index f36d62ff20dd..697afb1be11f 100644
--- a/python/helpers/typeshed/stubs/requests/requests/help.pyi
+++ b/python/helpers/typeshed/stubs/requests/requests/help.pyi
@@ -1,21 +1,27 @@
-from typing import TypedDict
+from typing import TypedDict, type_check_only
+@type_check_only
class _VersionDict(TypedDict):
version: str
+@type_check_only
class _OptionalVersionDict(TypedDict):
version: str | None
+@type_check_only
class _PlatformDict(TypedDict):
system: str
release: str
+@type_check_only
class _ImplementationDict(_VersionDict):
name: str
+@type_check_only
class _PyOpenSSLDict(_OptionalVersionDict):
openssl_version: str
+@type_check_only
class _InfoDict(TypedDict):
platform: _PlatformDict
implementation: _ImplementationDict
diff --git a/python/helpers/typeshed/stubs/requests/requests/sessions.pyi b/python/helpers/typeshed/stubs/requests/requests/sessions.pyi
index ec2211c6bc4e..eaeffb94c7cd 100644
--- a/python/helpers/typeshed/stubs/requests/requests/sessions.pyi
+++ b/python/helpers/typeshed/stubs/requests/requests/sessions.pyi
@@ -1,6 +1,6 @@
from _typeshed import SupportsItems, SupportsRead, Unused
from collections.abc import Callable, Iterable, Mapping, MutableMapping
-from typing import Any, TypedDict
+from typing import Any, TypedDict, type_check_only
from typing_extensions import Self, TypeAlias
from . import adapters, auth as _auth, compat, cookies, exceptions, hooks, models, status_codes, utils
@@ -105,6 +105,7 @@ _HeadersUpdateMapping: TypeAlias = Mapping[str, str | bytes | None]
_Timeout: TypeAlias = float | tuple[float, float] | tuple[float, None]
_Verify: TypeAlias = bool | str
+@type_check_only
class _Settings(TypedDict):
verify: _Verify | None
proxies: _TextMapping
diff --git a/python/helpers/typeshed/stubs/seaborn/seaborn/_core/groupby.pyi b/python/helpers/typeshed/stubs/seaborn/seaborn/_core/groupby.pyi
index e4100d0d8fc8..f466aee67341 100644
--- a/python/helpers/typeshed/stubs/seaborn/seaborn/_core/groupby.pyi
+++ b/python/helpers/typeshed/stubs/seaborn/seaborn/_core/groupby.pyi
@@ -7,7 +7,6 @@ from pandas import DataFrame
# pandas._typing.AggFuncTypeFrame is partially Unknown
_AggFuncTypeBase: TypeAlias = Callable[..., Incomplete] | str | ufunc
-# Using Hashable instead of HashableT to work around pytype issue
_AggFuncTypeDictFrame: TypeAlias = Mapping[Hashable, _AggFuncTypeBase | list[_AggFuncTypeBase]]
_AggFuncTypeFrame: TypeAlias = _AggFuncTypeBase | list[_AggFuncTypeBase] | _AggFuncTypeDictFrame
diff --git a/python/helpers/typeshed/stubs/seaborn/seaborn/_stats/aggregation.pyi b/python/helpers/typeshed/stubs/seaborn/seaborn/_stats/aggregation.pyi
index d14b8e67388b..cf30b12a2dc4 100644
--- a/python/helpers/typeshed/stubs/seaborn/seaborn/_stats/aggregation.pyi
+++ b/python/helpers/typeshed/stubs/seaborn/seaborn/_stats/aggregation.pyi
@@ -11,7 +11,7 @@ class Agg(Stat):
@dataclass
class Est(Stat):
func: str | Callable[[Vector], float] = "mean"
- errorbar: str | tuple[str, float] = ... # ("ci", 95) # pytype parse error
+ errorbar: str | tuple[str, float] = ("ci", 95)
n_boot: int = 1000
seed: int | None = None
diff --git a/python/helpers/typeshed/stubs/seaborn/seaborn/distributions.pyi b/python/helpers/typeshed/stubs/seaborn/seaborn/distributions.pyi
index 0f426084bf8f..06ecfb7197e0 100644
--- a/python/helpers/typeshed/stubs/seaborn/seaborn/distributions.pyi
+++ b/python/helpers/typeshed/stubs/seaborn/seaborn/distributions.pyi
@@ -1,5 +1,5 @@
from collections.abc import Iterable
-from typing import Any, Literal, Protocol, TypeVar
+from typing import Any, Literal, Protocol, TypeVar, type_check_only
from typing_extensions import TypeAlias, deprecated
from matplotlib.axes import Axes
@@ -17,6 +17,7 @@ __all__ = ["displot", "histplot", "kdeplot", "ecdfplot", "rugplot", "distplot"]
_T = TypeVar("_T")
_OneOrPair: TypeAlias = _T | tuple[_T, _T]
+@type_check_only
class _Fit(Protocol):
def fit(self, a: ArrayLike) -> tuple[ArrayLike, ...]: ...
def pdf(self, x: ArrayLike, *params: ArrayLike) -> ArrayLike: ...
diff --git a/python/helpers/typeshed/stubs/seaborn/seaborn/external/kde.pyi b/python/helpers/typeshed/stubs/seaborn/seaborn/external/kde.pyi
index 96b36651eb33..e886570721d1 100644
--- a/python/helpers/typeshed/stubs/seaborn/seaborn/external/kde.pyi
+++ b/python/helpers/typeshed/stubs/seaborn/seaborn/external/kde.pyi
@@ -1,5 +1,5 @@
from collections.abc import Callable
-from typing import Any, Literal, Protocol
+from typing import Any, Literal, Protocol, type_check_only
from typing_extensions import TypeAlias
import numpy as np
@@ -9,6 +9,7 @@ __all__ = ["gaussian_kde"]
# define a "Gaussian KDE" protocol so that we can also pass `scipy.stats.gaussian_kde` to
# functions that expect it without adding a dependency on scipy
+@type_check_only
class _GaussianKDELike(Protocol):
dataset: NDArray[np.float64]
def __init__(self, dataset: ArrayLike, bw_method: Any | None = ..., weights: ArrayLike | None = ...) -> None: ...
diff --git a/python/helpers/typeshed/stubs/seaborn/seaborn/matrix.pyi b/python/helpers/typeshed/stubs/seaborn/seaborn/matrix.pyi
index 3a9a25e54590..34ba5bb99aad 100644
--- a/python/helpers/typeshed/stubs/seaborn/seaborn/matrix.pyi
+++ b/python/helpers/typeshed/stubs/seaborn/seaborn/matrix.pyi
@@ -1,26 +1,41 @@
from _typeshed import Incomplete
from collections.abc import Hashable, Iterable, Mapping, Sequence
-from typing import Literal
+from typing import Literal, TypedDict, type_check_only
from typing_extensions import Self, TypeAlias
import numpy as np
+import pandas as pd
from matplotlib.axes import Axes
-from matplotlib.colors import Colormap, ListedColormap
+from matplotlib.colors import Colormap, ListedColormap, Normalize
from matplotlib.gridspec import GridSpec
from matplotlib.typing import ColorType
-from numpy._typing import _ArrayLike, _ArrayLikeInt_co
+from numpy._typing import _ArrayLikeInt_co
from numpy.typing import ArrayLike, NDArray
-from pandas import DataFrame, Index, Series
from .axisgrid import Grid
# pandas._typing.ListLikeU is partially Unknown
-_ListLikeU: TypeAlias = Sequence[Incomplete] | np.ndarray[Incomplete, Incomplete] | Series[Incomplete] | Index[Incomplete]
+_ListLikeU: TypeAlias = Sequence[Incomplete] | NDArray[Incomplete] | pd.Series[Incomplete] | pd.Index[Incomplete]
+_ConvertibleToDataFrame: TypeAlias = (
+ _ListLikeU
+ | pd.DataFrame
+ | dict[Incomplete, Incomplete]
+ | Iterable[_ListLikeU | tuple[Hashable, _ListLikeU] | dict[Incomplete, Incomplete]]
+ | None
+)
+_FlatOrNestedSequenceOfColors: TypeAlias = (
+ Sequence[ColorType]
+ | Sequence[Iterable[ColorType]]
+ | NDArray[Incomplete]
+ | pd.Index[Incomplete]
+ | pd.Series[Incomplete]
+ | pd.DataFrame
+)
__all__ = ["heatmap", "clustermap"]
def heatmap(
- data: DataFrame | _ArrayLike[Incomplete],
+ data: pd.DataFrame | ArrayLike,
*,
vmin: float | None = None,
vmax: float | None = None,
@@ -38,24 +53,37 @@ def heatmap(
square: bool = False,
xticklabels: Literal["auto"] | bool | int | Sequence[str] = "auto",
yticklabels: Literal["auto"] | bool | int | Sequence[str] = "auto",
- mask: NDArray[np.bool_] | DataFrame | None = None,
+ mask: NDArray[np.bool_] | pd.DataFrame | None = None,
ax: Axes | None = None,
+ # Kwargs below passed to matplotlib.axes.Axes.pcolormesh
+ alpha: float | None = None,
+ norm: str | Normalize | None = None,
+ shading: Literal["flat", "nearest", "gouraud", "auto"] | None = None,
+ antialiased: bool = False,
**kwargs,
) -> Axes: ...
+@type_check_only
+class _Dendogram(TypedDict):
+ icoord: list[list[float]]
+ dcoord: list[list[float]]
+ ivl: list[str]
+ leaves: list[int]
+ color_list: list[str]
+ leaves_color_list: list[str]
class _DendrogramPlotter:
axis: int
- array: NDArray[Incomplete]
- data: DataFrame
+ array: NDArray[np.floating]
+ data: pd.DataFrame
shape: tuple[int, int]
metric: str
method: str
label: bool
rotate: bool
- linkage: NDArray[Incomplete]
- dendrogram: dict[str, list[Incomplete]]
- xticks: list[float] | NDArray[Incomplete]
- yticks: list[float] | NDArray[Incomplete]
+ linkage: NDArray[np.floating]
+ dendrogram: _Dendogram
+ xticks: list[float] | NDArray[np.floating]
+ yticks: list[float] | NDArray[np.floating]
xticklabels: list[str]
yticklabels: list[str]
ylabel: str
@@ -63,19 +91,26 @@ class _DendrogramPlotter:
dependent_coord: list[list[float]]
independent_coord: list[list[float]]
def __init__(
- self, data: DataFrame, linkage: NDArray[Incomplete] | None, metric: str, method: str, axis: int, label: bool, rotate: bool
+ self,
+ data: pd.DataFrame,
+ linkage: NDArray[np.floating] | None,
+ metric: str,
+ method: str,
+ axis: int,
+ label: bool,
+ rotate: bool,
) -> None: ...
@property
- def calculated_linkage(self) -> NDArray[Incomplete]: ...
- def calculate_dendrogram(self) -> dict[str, list[Incomplete]]: ...
+ def calculated_linkage(self) -> NDArray[np.float64]: ...
+ def calculate_dendrogram(self) -> _Dendogram: ...
@property
def reordered_ind(self) -> list[int]: ...
def plot(self, ax: Axes, tree_kws: dict[str, Incomplete]) -> Self: ...
def dendrogram(
- data: DataFrame,
+ data: pd.DataFrame,
*,
- linkage: NDArray[Incomplete] | None = None,
+ linkage: NDArray[np.floating] | None = None,
axis: int = 1,
label: bool = True,
metric: str = "euclidean",
@@ -86,13 +121,13 @@ def dendrogram(
) -> _DendrogramPlotter: ...
class ClusterGrid(Grid):
- data: DataFrame
- data2d: DataFrame
- mask: DataFrame
- row_colors: Incomplete
- row_color_labels: Incomplete
- col_colors: Incomplete
- col_color_labels: Incomplete
+ data: pd.DataFrame
+ data2d: pd.DataFrame
+ mask: pd.DataFrame
+ row_colors: list[list[tuple[float, float, float]]] | None
+ row_color_labels: list[str] | None
+ col_colors: list[list[tuple[float, float, float]]] | None
+ col_color_labels: list[str] | None
gs: GridSpec
ax_row_dendrogram: Axes
ax_col_dendrogram: Axes
@@ -101,44 +136,38 @@ class ClusterGrid(Grid):
ax_heatmap: Axes
ax_cbar: Axes | None
cax: Axes | None
- cbar_pos: Incomplete
+ cbar_pos: tuple[float, float, float, float] | None
dendrogram_row: _DendrogramPlotter | None
dendrogram_col: _DendrogramPlotter | None
def __init__(
self,
- data: (
- _ListLikeU
- | DataFrame
- | dict[Incomplete, Incomplete]
- | Iterable[_ListLikeU | tuple[Hashable, _ListLikeU] | dict[Incomplete, Incomplete]]
- | None
- ),
+ data: _ConvertibleToDataFrame,
pivot_kws: Mapping[str, Incomplete] | None = None,
z_score: int | None = None,
standard_scale: int | None = None,
figsize: tuple[float, float] | None = None,
- row_colors=None,
- col_colors=None,
- mask: NDArray[np.bool_] | DataFrame | None = None,
+ row_colors: _FlatOrNestedSequenceOfColors | None = None,
+ col_colors: _FlatOrNestedSequenceOfColors | None = None,
+ mask: NDArray[np.bool_] | pd.DataFrame | None = None,
dendrogram_ratio: float | tuple[float, float] | None = None,
colors_ratio: float | tuple[float, float] | None = None,
cbar_pos: tuple[float, float, float, float] | None = None,
) -> None: ...
def format_data(
self,
- data: DataFrame,
+ data: pd.DataFrame,
pivot_kws: Mapping[str, Incomplete] | None,
z_score: int | None = None,
standard_scale: int | None = None,
- ) -> DataFrame: ...
+ ) -> pd.DataFrame: ...
@staticmethod
- def z_score(data2d: DataFrame, axis: int = 1) -> DataFrame: ...
+ def z_score(data2d: pd.DataFrame, axis: int = 1) -> pd.DataFrame: ...
@staticmethod
- def standard_scale(data2d: DataFrame, axis: int = 1) -> DataFrame: ...
- def dim_ratios(self, colors: Incomplete | None, dendrogram_ratio: float, colors_ratio: float) -> list[float]: ...
+ def standard_scale(data2d: pd.DataFrame, axis: int = 1) -> pd.DataFrame: ...
+ def dim_ratios(self, colors: ArrayLike | None, dendrogram_ratio: float, colors_ratio: float) -> list[float]: ...
@staticmethod
def color_list_to_matrix_and_cmap(
- colors: Sequence[ColorType], ind: _ArrayLikeInt_co, axis: int = 0
+ colors: _FlatOrNestedSequenceOfColors, ind: _ArrayLikeInt_co, axis: int = 0
) -> tuple[NDArray[np.int_], ListedColormap]: ...
def plot_dendrograms(
self,
@@ -146,8 +175,8 @@ class ClusterGrid(Grid):
col_cluster: bool,
metric: str,
method: str,
- row_linkage: NDArray[Incomplete] | None,
- col_linkage: NDArray[Incomplete] | None,
+ row_linkage: NDArray[np.floating] | None,
+ col_linkage: NDArray[np.floating] | None,
tree_kws: dict[str, Incomplete] | None,
) -> None: ...
def plot_colors(self, xind: _ArrayLikeInt_co, yind: _ArrayLikeInt_co, **kws) -> None: ...
@@ -159,20 +188,14 @@ class ClusterGrid(Grid):
colorbar_kws: dict[str, Incomplete] | None,
row_cluster: bool,
col_cluster: bool,
- row_linkage: NDArray[Incomplete] | None,
- col_linkage: NDArray[Incomplete] | None,
+ row_linkage: NDArray[np.floating] | None,
+ col_linkage: NDArray[np.floating] | None,
tree_kws: dict[str, Incomplete] | None,
**kws,
) -> Self: ...
def clustermap(
- data: (
- _ListLikeU
- | DataFrame
- | dict[Incomplete, Incomplete]
- | Iterable[_ListLikeU | tuple[Hashable, _ListLikeU] | dict[Incomplete, Incomplete]]
- | None
- ),
+ data: _ConvertibleToDataFrame,
*,
pivot_kws: dict[str, Incomplete] | None = None,
method: str = "average",
@@ -183,11 +206,11 @@ def clustermap(
cbar_kws: dict[str, Incomplete] | None = None,
row_cluster: bool = True,
col_cluster: bool = True,
- row_linkage: NDArray[Incomplete] | None = None,
- col_linkage: NDArray[Incomplete] | None = None,
- row_colors=None,
- col_colors=None,
- mask: NDArray[np.bool_] | DataFrame | None = None,
+ row_linkage: NDArray[np.floating] | None = None,
+ col_linkage: NDArray[np.floating] | None = None,
+ row_colors: _FlatOrNestedSequenceOfColors | None = None,
+ col_colors: _FlatOrNestedSequenceOfColors | None = None,
+ mask: NDArray[np.bool_] | pd.DataFrame | None = None,
dendrogram_ratio: float | tuple[float, float] = 0.2,
colors_ratio: float | tuple[float, float] = 0.03,
cbar_pos: tuple[float, float, float, float] | None = (0.02, 0.8, 0.05, 0.18),
diff --git a/python/helpers/typeshed/stubs/setuptools/METADATA.toml b/python/helpers/typeshed/stubs/setuptools/METADATA.toml
index 4d664b235b07..e4b0a7d01058 100644
--- a/python/helpers/typeshed/stubs/setuptools/METADATA.toml
+++ b/python/helpers/typeshed/stubs/setuptools/METADATA.toml
@@ -7,5 +7,5 @@ it is no longer included with `types-setuptools`.
[tool.stubtest]
# darwin is equivalent to linux for OS-specific methods
-platforms = ["linux", "win32"]
+ci_platforms = ["linux", "win32"]
stubtest_requirements = ["tomli"]
diff --git a/python/helpers/typeshed/stubs/setuptools/setuptools/_distutils/filelist.pyi b/python/helpers/typeshed/stubs/setuptools/setuptools/_distutils/filelist.pyi
index a5be13d3ce7d..3e58a792fdff 100644
--- a/python/helpers/typeshed/stubs/setuptools/setuptools/_distutils/filelist.pyi
+++ b/python/helpers/typeshed/stubs/setuptools/setuptools/_distutils/filelist.pyi
@@ -9,7 +9,7 @@ class FileList:
files: list[str]
def __init__(self, warn: Unused = None, debug_print: Unused = None) -> None: ...
def set_allfiles(self, allfiles: Iterable[str]) -> None: ...
- def findall(self, dir: StrPath = ...) -> None: ...
+ def findall(self, dir: StrPath = ".") -> None: ...
def debug_print(self, msg: object) -> None: ...
def append(self, item: str) -> None: ...
def extend(self, items: Iterable[str]) -> None: ...
diff --git a/python/helpers/typeshed/stubs/setuptools/setuptools/command/editable_wheel.pyi b/python/helpers/typeshed/stubs/setuptools/setuptools/command/editable_wheel.pyi
index 3080f4d690a1..989289829a49 100644
--- a/python/helpers/typeshed/stubs/setuptools/setuptools/command/editable_wheel.pyi
+++ b/python/helpers/typeshed/stubs/setuptools/setuptools/command/editable_wheel.pyi
@@ -77,4 +77,3 @@ class _NamespaceInstaller(namespaces.Installer):
class InformationOnly(SetuptoolsWarning): ...
class LinksNotSupported(errors.FileError): ...
-class _DebuggingTips(SetuptoolsWarning): ...
diff --git a/python/helpers/typeshed/stubs/setuptools/setuptools/config/pyprojecttoml.pyi b/python/helpers/typeshed/stubs/setuptools/setuptools/config/pyprojecttoml.pyi
index f44ffcdb95d4..45febbdafb2d 100644
--- a/python/helpers/typeshed/stubs/setuptools/setuptools/config/pyprojecttoml.pyi
+++ b/python/helpers/typeshed/stubs/setuptools/setuptools/config/pyprojecttoml.pyi
@@ -4,7 +4,6 @@ from typing import Any
from typing_extensions import Self
from ..dist import Distribution
-from ..warnings import SetuptoolsWarning
from . import expand
def load_file(filepath: StrPath) -> dict[Incomplete, Incomplete]: ...
@@ -45,6 +44,3 @@ class _EnsurePackagesDiscovered(expand.EnsurePackagesDiscovered):
def __exit__(
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
) -> None: ...
-
-class _BetaConfiguration(SetuptoolsWarning): ...
-class _InvalidFile(SetuptoolsWarning): ...
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/__init__.pyi b/python/helpers/typeshed/stubs/shapely/shapely/__init__.pyi
index a36042aeba82..22e9b97f7ee6 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/__init__.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/__init__.pyi
@@ -1,6 +1,7 @@
from typing import Final
from . import affinity as affinity
+from ._coverage import *
from ._geometry import *
from .constructive import *
from .coordinates import *
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/_coverage.pyi b/python/helpers/typeshed/stubs/shapely/shapely/_coverage.pyi
new file mode 100644
index 000000000000..4d5b7b7d57ed
--- /dev/null
+++ b/python/helpers/typeshed/stubs/shapely/shapely/_coverage.pyi
@@ -0,0 +1,15 @@
+from typing import overload
+
+import numpy as np
+
+from ._typing import ArrayLike, GeoArray, GeoArrayLikeSeq, OptGeoArrayLike
+from .geometry import Polygon
+
+__all__ = ["coverage_invalid_edges", "coverage_is_valid", "coverage_simplify"]
+
+def coverage_is_valid(geometry: OptGeoArrayLike, gap_width: float = 0.0, **kwargs) -> np.bool_: ...
+def coverage_invalid_edges(geometry: OptGeoArrayLike, gap_width: float = 0.0, **kwargs) -> GeoArray: ...
+@overload
+def coverage_simplify(geometry: Polygon, tolerance: ArrayLike[float], *, simplify_boundary: bool = True) -> Polygon: ...
+@overload
+def coverage_simplify(geometry: GeoArrayLikeSeq, tolerance: ArrayLike[float], *, simplify_boundary: bool = True) -> GeoArray: ...
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/_geometry.pyi b/python/helpers/typeshed/stubs/shapely/shapely/_geometry.pyi
index eb2cdab6cec9..d2e2055bce02 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/_geometry.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/_geometry.pyi
@@ -52,23 +52,23 @@ class GeometryType(IntEnum):
GEOMETRYCOLLECTION = 7
@overload
-def get_type_id(geometry: Geometry | None, **kwargs) -> int: ...
+def get_type_id(geometry: Geometry | None, **kwargs) -> np.int32: ...
@overload
def get_type_id(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.int64]: ...
@overload
-def get_dimensions(geometry: Geometry | None, **kwargs) -> int: ...
+def get_dimensions(geometry: Geometry | None, **kwargs) -> np.int32: ...
@overload
def get_dimensions(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.int64]: ...
@overload
-def get_coordinate_dimension(geometry: Geometry | None, **kwargs) -> int: ...
+def get_coordinate_dimension(geometry: Geometry | None, **kwargs) -> np.int32: ...
@overload
def get_coordinate_dimension(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.int64]: ...
@overload
-def get_num_coordinates(geometry: Geometry | None, **kwargs) -> int: ...
+def get_num_coordinates(geometry: Geometry | None, **kwargs) -> np.int32: ...
@overload
def get_num_coordinates(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.int64]: ...
@overload
-def get_srid(geometry: Geometry | None, **kwargs) -> int: ...
+def get_srid(geometry: Geometry | None, **kwargs) -> np.int32: ...
@overload
def get_srid(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.int64]: ...
@overload
@@ -78,19 +78,19 @@ def set_srid(geometry: OptGeoArrayLikeSeq, srid: ArrayLike[SupportsIndex], **kwa
@overload
def set_srid(geometry: OptGeoArrayLike, srid: ArrayLikeSeq[SupportsIndex], **kwargs) -> GeoArray: ...
@overload
-def get_x(point: Geometry | None, **kwargs) -> float: ...
+def get_x(point: Geometry | None, **kwargs) -> np.float64: ...
@overload
def get_x(point: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.float64]: ...
@overload
-def get_y(point: Geometry | None, **kwargs) -> float: ...
+def get_y(point: Geometry | None, **kwargs) -> np.float64: ...
@overload
def get_y(point: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.float64]: ...
@overload
-def get_z(point: Geometry | None, **kwargs) -> float: ...
+def get_z(point: Geometry | None, **kwargs) -> np.float64: ...
@overload
def get_z(point: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.float64]: ...
@overload
-def get_m(point: Geometry | None, **kwargs) -> float: ...
+def get_m(point: Geometry | None, **kwargs) -> np.float64: ...
@overload
def get_m(point: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.float64]: ...
@overload
@@ -104,7 +104,7 @@ def get_point(geometry: OptGeoArrayLikeSeq, index: ArrayLike[SupportsIndex], **k
@overload
def get_point(geometry: OptGeoArrayLike, index: ArrayLikeSeq[SupportsIndex], **kwargs) -> GeoArray: ...
@overload
-def get_num_points(geometry: Geometry | None, **kwargs) -> int: ...
+def get_num_points(geometry: Geometry | None, **kwargs) -> np.int32: ...
@overload
def get_num_points(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.int64]: ...
@overload
@@ -126,7 +126,7 @@ def get_interior_ring(geometry: OptGeoArrayLikeSeq, index: ArrayLike[SupportsInd
@overload
def get_interior_ring(geometry: OptGeoArrayLike, index: ArrayLikeSeq[SupportsIndex], **kwargs) -> GeoArray: ...
@overload
-def get_num_interior_rings(geometry: Geometry | None, **kwargs) -> int: ...
+def get_num_interior_rings(geometry: Geometry | None, **kwargs) -> np.int32: ...
@overload
def get_num_interior_rings(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.int64]: ...
@overload
@@ -158,11 +158,11 @@ def get_rings(geometry: OptGeoArrayLike, return_index: Literal[True]) -> tuple[G
@overload
def get_rings(geometry: OptGeoArrayLike, return_index: bool) -> GeoArray | tuple[GeoArray, NDArray[np.int64]]: ...
@overload
-def get_num_geometries(geometry: Geometry | None, **kwargs) -> int: ...
+def get_num_geometries(geometry: Geometry | None, **kwargs) -> np.int32: ...
@overload
def get_num_geometries(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.int64]: ...
@overload
-def get_precision(geometry: Geometry | None, **kwargs) -> float: ...
+def get_precision(geometry: Geometry | None, **kwargs) -> np.float64: ...
@overload
def get_precision(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.float64]: ...
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/algorithms/cga.pyi b/python/helpers/typeshed/stubs/shapely/shapely/algorithms/cga.pyi
index d3d7ea164660..de6ecd5ed1cc 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/algorithms/cga.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/algorithms/cga.pyi
@@ -1,3 +1,5 @@
+import numpy as np
+
from ..geometry import LinearRing
-def signed_area(ring: LinearRing) -> float: ...
+def signed_area(ring: LinearRing) -> np.float64: ...
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/constructive.pyi b/python/helpers/typeshed/stubs/shapely/shapely/constructive.pyi
index f3a74f56fe17..ba1ba4e6ea59 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/constructive.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/constructive.pyi
@@ -429,60 +429,79 @@ def voronoi_polygons(
ordered: bool = False,
**kwargs,
) -> GeometryCollection[Polygon] | LineString | MultiLineString | None: ...
-@overload
+@overload # `geometry` as sequence-like
def voronoi_polygons(
geometry: OptGeoArrayLikeSeq,
tolerance: ArrayLike[float] = 0.0,
extend_to: OptGeoArrayLike = None,
only_edges: ArrayLike[bool] = False,
- ordered: bool = False,
+ ordered: ArrayLike[bool] = False,
**kwargs,
) -> GeoArray: ...
-@overload
+@overload # `tolerance` as sequence-like
def voronoi_polygons(
geometry: OptGeoArrayLike,
tolerance: ArrayLikeSeq[float],
extend_to: OptGeoArrayLike = None,
only_edges: ArrayLike[bool] = False,
- ordered: bool = False,
+ ordered: ArrayLike[bool] = False,
**kwargs,
) -> GeoArray: ...
@overload
-def voronoi_polygons(
+def voronoi_polygons( # `extend_to` as positional sequence-like
geometry: OptGeoArrayLike,
tolerance: ArrayLike[float],
extend_to: OptGeoArrayLikeSeq,
only_edges: ArrayLike[bool] = False,
- ordered: bool = False,
+ ordered: ArrayLike[bool] = False,
**kwargs,
) -> GeoArray: ...
-@overload
+@overload # `extend_to` as keyword sequence-like
def voronoi_polygons(
geometry: OptGeoArrayLike,
tolerance: ArrayLike[float] = 0.0,
*,
extend_to: OptGeoArrayLikeSeq,
only_edges: ArrayLike[bool] = False,
- ordered: bool = False,
+ ordered: ArrayLike[bool] = False,
**kwargs,
) -> GeoArray: ...
@overload
-def voronoi_polygons(
+def voronoi_polygons( # `only_edges` as positional sequence-like
geometry: OptGeoArrayLike,
tolerance: ArrayLike[float],
extend_to: OptGeoArrayLike,
only_edges: ArrayLikeSeq[bool],
- ordered: bool = False,
+ ordered: ArrayLike[bool] = False,
**kwargs,
) -> GeoArray: ...
@overload
-def voronoi_polygons(
+def voronoi_polygons( # `only_edges` as keyword sequence-like
geometry: OptGeoArrayLike,
tolerance: ArrayLike[float] = 0.0,
extend_to: OptGeoArrayLike = None,
*,
only_edges: ArrayLikeSeq[bool],
- ordered: bool = False,
+ ordered: ArrayLike[bool] = False,
+ **kwargs,
+) -> GeoArray: ...
+@overload # `ordered` as positional sequence-like
+def voronoi_polygons(
+ geometry: OptGeoArrayLike,
+ tolerance: ArrayLike[float],
+ extend_to: OptGeoArrayLike,
+ only_edges: ArrayLike[bool],
+ ordered: ArrayLikeSeq[bool],
+ **kwargs,
+) -> GeoArray: ...
+@overload # `ordered` as keyword sequence-like
+def voronoi_polygons(
+ geometry: OptGeoArrayLike,
+ tolerance: ArrayLike[float] = 0.0,
+ extend_to: OptGeoArrayLike = None,
+ *,
+ only_edges: ArrayLike[bool] = False,
+ ordered: ArrayLikeSeq[bool],
**kwargs,
) -> GeoArray: ...
@overload
@@ -511,26 +530,18 @@ def minimum_bounding_circle(geometry: Geometry | None, **kwargs) -> Polygon | Po
@overload
def minimum_bounding_circle(geometry: OptGeoArrayLikeSeq, **kwargs) -> GeoArray: ...
@overload
-def maximum_inscribed_circle(geometry: Point, tolerance: float | None = None, **kwargs) -> Point: ...
-@overload
-def maximum_inscribed_circle(
- geometry: LineString | Polygon | BaseMultipartGeometry, tolerance: float | None = None, **kwargs
-): ...
-@overload
-def maximum_inscribed_circle(geometry: Geometry, tolerance: float | None = None, **kwargs) -> Polygon | Point: ...
+def maximum_inscribed_circle(geometry: Polygon | MultiPolygon, tolerance: float | None = None, **kwargs) -> LineString: ...
@overload
def maximum_inscribed_circle(geometry: None, tolerance: float | None = None, **kwargs) -> None: ...
@overload
-def maximum_inscribed_circle(geometry: Geometry | None, tolerance: float | None = None, **kwargs) -> Polygon | Point | None: ...
+def maximum_inscribed_circle(
+ geometry: Polygon | MultiPolygon | None, tolerance: float | None = None, **kwargs
+) -> LineString | None: ...
@overload
def maximum_inscribed_circle(geometry: OptGeoArrayLikeSeq, tolerance: ArrayLike[float] | None = None, **kwargs) -> GeoArray: ...
@overload
-def orient_polygons(geometry: Point, *, exterior_cw: bool = False, **kwargs) -> Point: ...
+def maximum_inscribed_circle(geometry: OptGeoArrayLike, tolerance: ArrayLikeSeq[float], **kwargs) -> GeoArray: ...
@overload
-def orient_polygons(geometry: Geometry, *, exterior_cw: bool = False, **kwargs) -> BaseGeometry: ...
-@overload
-def orient_polygons(geometry: None, *, exterior_cw: bool = False, **kwargs) -> None: ...
-@overload
-def orient_polygons(geometry: Geometry | None, *, exterior_cw: bool = False, **kwargs) -> BaseGeometry | None: ...
+def orient_polygons(geometry: OptGeoT, *, exterior_cw: bool = False, **kwargs) -> OptGeoT: ...
@overload
def orient_polygons(geometry: OptGeoArrayLikeSeq, *, exterior_cw: bool = False, **kwargs) -> GeoArray: ...
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/creation.pyi b/python/helpers/typeshed/stubs/shapely/shapely/creation.pyi
index db0a7f75f0f5..193100448eaa 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/creation.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/creation.pyi
@@ -12,18 +12,18 @@ from .geometry import GeometryCollection, LinearRing, LineString, MultiLineStrin
from .lib import Geometry
__all__ = [
- "points",
- "linestrings",
- "linearrings",
- "polygons",
- "multipoints",
- "multilinestrings",
- "multipolygons",
- "geometrycollections",
"box",
- "prepare",
"destroy_prepared",
"empty",
+ "geometrycollections",
+ "linearrings",
+ "linestrings",
+ "multilinestrings",
+ "multipoints",
+ "multipolygons",
+ "points",
+ "polygons",
+ "prepare",
]
class HandleNaN(ParamEnum):
@@ -31,7 +31,7 @@ class HandleNaN(ParamEnum):
skip = 1
error = 2
-_HandleNaN: TypeAlias = Literal[0, 1, 2] | HandleNaN
+_HandleNaN: TypeAlias = Literal["allow", "skip", "error"] | HandleNaN
@overload
def points(
@@ -40,7 +40,7 @@ def points(
z: float | None = None,
indices: None = None,
*,
- handle_nan: _HandleNaN = 0,
+ handle_nan: _HandleNaN = ...,
out: None = None,
**kwargs, # acts as x
) -> Point: ...
@@ -51,7 +51,7 @@ def points(
z: None = None,
indices: None = None,
*,
- handle_nan: _HandleNaN = 0,
+ handle_nan: _HandleNaN = ...,
out: None = None,
**kwargs, # acts as x, y[, z]
) -> Point: ...
@@ -62,7 +62,7 @@ def points(
z: Sequence[float] | None = None,
indices: ArrayLikeSeq[int] | None = None,
*,
- handle_nan: _HandleNaN = 0,
+ handle_nan: _HandleNaN = ...,
out: NDArray[np.object_] | None = None,
**kwargs,
) -> GeoArray: ...
@@ -73,7 +73,7 @@ def points(
z: None = None,
indices: ArrayLikeSeq[int] | None = None,
*,
- handle_nan: _HandleNaN = 0,
+ handle_nan: _HandleNaN = ...,
out: NDArray[np.object_] | None = None,
**kwargs,
) -> GeoArray: ...
@@ -84,7 +84,7 @@ def points(
z: ArrayLike[float] | None = None,
indices: ArrayLikeSeq[int] | None = None,
*,
- handle_nan: _HandleNaN = 0,
+ handle_nan: _HandleNaN = ...,
out: NDArray[np.object_] | None = None,
**kwargs,
) -> Point | GeoArray: ...
@@ -95,7 +95,7 @@ def points(
z: ArrayLike[float] | None = None,
indices: ArrayLikeSeq[int] | None = None,
*,
- handle_nan: _HandleNaN = 0,
+ handle_nan: _HandleNaN = ...,
out: NDArray[np.object_] | None = None,
**kwargs,
) -> Point | GeoArray: ...
@@ -106,7 +106,7 @@ def linestrings(
z: Sequence[float] | None = None,
indices: None = None,
*,
- handle_nan: _HandleNaN = 0,
+ handle_nan: _HandleNaN = ...,
out: None = None,
**kwargs,
) -> LineString: ...
@@ -117,7 +117,7 @@ def linestrings(
z: None = None,
indices: None = None,
*,
- handle_nan: _HandleNaN = 0,
+ handle_nan: _HandleNaN = ...,
out: None = None,
**kwargs,
) -> LineString: ...
@@ -128,7 +128,7 @@ def linestrings(
z: None = None,
indices: ArrayLikeSeq[int] | None = None,
*,
- handle_nan: _HandleNaN = 0,
+ handle_nan: _HandleNaN = ...,
out: NDArray[np.object_] | None = None,
**kwargs,
) -> GeoArray: ...
@@ -139,7 +139,7 @@ def linestrings(
z: ArrayLikeSeq[float] | None = None,
indices: ArrayLikeSeq[int] | None = None,
*,
- handle_nan: _HandleNaN = 0,
+ handle_nan: _HandleNaN = ...,
out: NDArray[np.object_] | None = None,
**kwargs,
) -> LineString | GeoArray: ...
@@ -150,7 +150,7 @@ def linearrings(
z: Sequence[float] | None = None,
indices: None = None,
*,
- handle_nan: _HandleNaN = 0,
+ handle_nan: _HandleNaN = ...,
out: None = None,
**kwargs,
) -> LinearRing: ...
@@ -161,7 +161,7 @@ def linearrings(
z: None = None,
indices: None = None,
*,
- handle_nan: _HandleNaN = 0,
+ handle_nan: _HandleNaN = ...,
out: None = None,
**kwargs,
) -> LinearRing: ...
@@ -172,7 +172,7 @@ def linearrings(
z: None = None,
indices: ArrayLikeSeq[int] | None = None,
*,
- handle_nan: _HandleNaN = 0,
+ handle_nan: _HandleNaN = ...,
out: NDArray[np.object_] | None = None,
**kwargs,
) -> GeoArray: ...
@@ -183,7 +183,7 @@ def linearrings(
z: ArrayLikeSeq[float] | None = None,
indices: ArrayLikeSeq[int] | None = None,
*,
- handle_nan: _HandleNaN = 0,
+ handle_nan: _HandleNaN = ...,
out: NDArray[np.object_] | None = None,
**kwargs,
) -> LinearRing | GeoArray: ...
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/decorators.pyi b/python/helpers/typeshed/stubs/shapely/shapely/decorators.pyi
index 2d0aa31dd4b7..fe5131950cec 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/decorators.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/decorators.pyi
@@ -1,4 +1,4 @@
-from collections.abc import Callable, Iterable
+from collections.abc import Callable, Container
from typing import TypeVar
_F = TypeVar("_F", bound=Callable[..., object])
@@ -9,4 +9,4 @@ class requires_geos:
def __call__(self, func: _F) -> _F: ...
def multithreading_enabled(func: _F) -> _F: ...
-def deprecate_positional(should_be_kwargs: Iterable[str], category: type[Warning] = ...) -> Callable[..., object]: ...
+def deprecate_positional(should_be_kwargs: Container[str], category: type[Warning] = ...) -> Callable[..., object]: ...
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/geometry/base.pyi b/python/helpers/typeshed/stubs/shapely/shapely/geometry/base.pyi
index 75da5ee5e05d..b641a608375e 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/geometry/base.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/geometry/base.pyi
@@ -31,6 +31,7 @@ class JOIN_STYLE:
bevel: Literal[BufferJoinStyle.bevel]
class BaseGeometry(Geometry):
+ __slots__: list[str] = []
@deprecated(
"Directly calling 'BaseGeometry()' is deprecated. To create an empty geometry, "
"use one of the subclasses instead, for example 'GeometryCollection()'."
@@ -63,8 +64,8 @@ class BaseGeometry(Geometry):
def __xor__(self, other: OptGeoArrayLikeSeq) -> GeoArray: ...
@overload
def __xor__(self, other: None) -> None: ...
- def __eq__(self, other: object) -> bool: ...
- def __ne__(self, other: object) -> bool: ...
+ def __eq__(self, other: object, /) -> bool: ...
+ def __ne__(self, other: object, /) -> bool: ...
def __hash__(self) -> int: ...
@property
def coords(self) -> CoordinateSequence: ...
@@ -127,7 +128,7 @@ class BaseGeometry(Geometry):
single_sided: bool = False,
*,
quadsegs: int | None = None, # deprecated
- resolution: int | None = None, # to be deprecated
+ resolution: int | None = None, # deprecated
) -> Polygon: ...
def simplify(self, tolerance: float, preserve_topology: bool = True) -> BaseGeometry: ...
def normalize(self) -> BaseGeometry: ...
@@ -226,7 +227,7 @@ class BaseGeometry(Geometry):
@overload
def dwithin(self, other: OptGeoArrayLike, distance: ArrayLikeSeq[float]) -> NDArray[np.bool_]: ...
@overload
- def equals_exact(self, other: Geometry | None, tolerance: float = 0.0, *, normalize: Literal[False] = False) -> bool: ...
+ def equals_exact(self, other: Geometry | None, tolerance: float = 0.0, *, normalize: bool = False) -> bool: ...
@overload
def equals_exact(
self, other: OptGeoArrayLikeSeq, tolerance: float = 0.0, *, normalize: bool = False
@@ -264,6 +265,7 @@ class BaseGeometry(Geometry):
_GeoT_co = TypeVar("_GeoT_co", bound=Geometry, default=BaseGeometry, covariant=True)
class BaseMultipartGeometry(BaseGeometry, Generic[_GeoT_co]):
+ __slots__: list[str] = []
@property
def coords(self) -> NoReturn: ...
@property
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/geometry/collection.pyi b/python/helpers/typeshed/stubs/shapely/shapely/geometry/collection.pyi
index 455e39d2c706..adfe1cc648f6 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/geometry/collection.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/geometry/collection.pyi
@@ -7,6 +7,7 @@ from .base import BaseMultipartGeometry, GeometrySequence, _GeoT_co
class GeometryCollection(BaseMultipartGeometry[_GeoT_co]):
# Overloads of __new__ are used because mypy is unable to narrow the typevar otherwise
+ __slots__: list[str] = []
@overload
def __new__(
self, geoms: BaseMultipartGeometry[_GeoT_co] | GeometrySequence[BaseMultipartGeometry[_GeoT_co]] | Collection[_GeoT_co]
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/geometry/linestring.pyi b/python/helpers/typeshed/stubs/shapely/shapely/geometry/linestring.pyi
index 44176310d338..4c5b37ab4df0 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/geometry/linestring.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/geometry/linestring.pyi
@@ -15,6 +15,7 @@ __all__ = ["LineString"]
_ConvertibleToLineString: TypeAlias = LineString | ArrayLikeSeq[float] | Iterable[Point | Iterable[SupportsFloat]]
class LineString(BaseGeometry):
+ __slots__: list[str] = []
def __new__(self, coordinates: _ConvertibleToLineString | None = None) -> Self: ...
def svg(self, scale_factor: float = 1.0, stroke_color: str | None = None, opacity: float | None = None) -> str: ... # type: ignore[override]
def offset_curve(
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/geometry/multilinestring.pyi b/python/helpers/typeshed/stubs/shapely/shapely/geometry/multilinestring.pyi
index b911938cda43..c4c561f4f803 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/geometry/multilinestring.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/geometry/multilinestring.pyi
@@ -8,6 +8,7 @@ from .multipoint import MultiPoint
__all__ = ["MultiLineString"]
class MultiLineString(BaseMultipartGeometry[LineString]):
+ __slots__: list[str] = []
def __new__(self, lines: BaseMultipartGeometry | Collection[_ConvertibleToLineString] | None = None) -> Self: ...
def svg(self, scale_factor: float = 1.0, stroke_color: str | None = None, opacity: float | None = None) -> str: ... # type: ignore[override]
# more precise base overrides
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/geometry/multipoint.pyi b/python/helpers/typeshed/stubs/shapely/shapely/geometry/multipoint.pyi
index dddc39d9c269..6647a93404d5 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/geometry/multipoint.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/geometry/multipoint.pyi
@@ -13,6 +13,7 @@ class MultiPoint(BaseMultipartGeometry[Point]):
# * `Sequence` is more correct but it will lead to False positives with common types
# like np.ndarray, pd.Index, pd.Series, ...
# I went with Collection as false negatives seem better to me than false positives in this case
+ __slots__: list[str] = []
def __new__(self, points: MultiPoint | Collection[_PointLike] | None = None) -> Self: ...
def svg(self, scale_factor: float = 1.0, fill_color: str | None = None, opacity: float | None = None) -> str: ... # type: ignore[override]
# more precise base overrides
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/geometry/multipolygon.pyi b/python/helpers/typeshed/stubs/shapely/shapely/geometry/multipolygon.pyi
index 95da6beef6eb..eb3428ee6f1a 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/geometry/multipolygon.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/geometry/multipolygon.pyi
@@ -8,6 +8,7 @@ from .polygon import Polygon, _PolygonHolesLike, _PolygonShellLike
__all__ = ["MultiPolygon"]
class MultiPolygon(BaseMultipartGeometry[Polygon]):
+ __slots__: list[str] = []
def __new__(
self,
polygons: (
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/geometry/point.pyi b/python/helpers/typeshed/stubs/shapely/shapely/geometry/point.pyi
index e9ac4e18169e..f68ae98bc2ed 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/geometry/point.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/geometry/point.pyi
@@ -11,6 +11,7 @@ __all__ = ["Point"]
_PointLike: TypeAlias = Point | Iterable[float] | ArrayLikeSeq[float]
class Point(BaseGeometry):
+ __slots__: list[str] = []
@overload # no args: empty point
def __new__(self) -> Self: ...
@overload # one arg: (x, y[, z]) tuple or a Point instance
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/geometry/polygon.pyi b/python/helpers/typeshed/stubs/shapely/shapely/geometry/polygon.pyi
index ad5ad49990ab..6d2fd90725a4 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/geometry/polygon.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/geometry/polygon.pyi
@@ -13,6 +13,7 @@ _PolygonShellLike: TypeAlias = Polygon | _ConvertibleToLinearRing | None
_PolygonHolesLike: TypeAlias = Collection[_ConvertibleToLinearRing | None] | None
class LinearRing(LineString):
+ __slots__: list[str] = []
def __new__(self, coordinates: _ConvertibleToLinearRing | None = None) -> Self: ...
@property
def is_ccw(self) -> bool: ...
@@ -28,6 +29,7 @@ class InteriorRingSequence:
def __getitem__(self, key: slice) -> list[LinearRing]: ...
class Polygon(BaseGeometry):
+ __slots__: list[str] = []
def __new__(self, shell: _PolygonShellLike = None, holes: _PolygonHolesLike = None) -> Self: ...
@property
def exterior(self) -> LinearRing: ...
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/io.pyi b/python/helpers/typeshed/stubs/shapely/shapely/io.pyi
index 9b840b4874b8..54b17de3fa0d 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/io.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/io.pyi
@@ -17,7 +17,7 @@ _OutputDimension: TypeAlias = Literal[2, 3, 4]
# Mypy and stubtest aren't happy with the following definition and
# raise is a reserved keyword, so we cannot use the class syntax of enums
-# DecodingErrorOptions = ParamEnum("DecodingErrorOptions", {"ignore": 0, "warn": 1, "raise": 2})
+# DecodingErrorOptions = ParamEnum("DecodingErrorOptions", {"ignore": 0, "warn": 1, "raise": 2, "fix": 3})
DecodingErrorOptions: Incomplete
class WKBFlavorOptions(ParamEnum):
@@ -128,26 +128,30 @@ def to_geojson(geometry: Geometry, indent: int | None = None, **kwargs) -> str:
@overload
def to_geojson(geometry: OptGeoArrayLikeSeq, indent: int | None = None, **kwargs) -> NDArray[np.str_]: ...
@overload
-def from_wkt(geometry: None, on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs) -> None: ...
+def from_wkt(geometry: None, on_invalid: Literal["raise", "warn", "ignore", "fix"] = "raise", **kwargs) -> None: ...
@overload
-def from_wkt(geometry: str, on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs) -> BaseGeometry: ... # type: ignore[overload-overlap]
+def from_wkt(geometry: str, on_invalid: Literal["raise", "warn", "ignore", "fix"] = "raise", **kwargs) -> BaseGeometry: ... # type: ignore[overload-overlap]
@overload
def from_wkt(
- geometry: ArrayLikeSeq[str | None], on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs
+ geometry: ArrayLikeSeq[str | None], on_invalid: Literal["raise", "warn", "ignore", "fix"] = "raise", **kwargs
) -> GeoArray: ...
@overload
-def from_wkb(geometry: None, on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs) -> None: ...
-@overload
-def from_wkb(geometry: str | bytes, on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs) -> BaseGeometry: ... # type: ignore[overload-overlap]
+def from_wkb(geometry: None, on_invalid: Literal["raise", "warn", "ignore", "fix"] = "raise", **kwargs) -> None: ...
@overload
def from_wkb(
- geometry: ArrayLikeSeq[str | bytes | None], on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs
+ geometry: str | bytes, on_invalid: Literal["raise", "warn", "ignore", "fix"] = "raise", **kwargs
+) -> BaseGeometry: ... # type: ignore[overload-overlap]
+@overload
+def from_wkb(
+ geometry: ArrayLikeSeq[str | bytes | None], on_invalid: Literal["raise", "warn", "ignore", "fix"] = "raise", **kwargs
) -> GeoArray: ...
@overload
-def from_geojson(geometry: None, on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs) -> None: ...
-@overload
-def from_geojson(geometry: str | bytes, on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs) -> BaseGeometry: ... # type: ignore[overload-overlap]
+def from_geojson(geometry: None, on_invalid: Literal["raise", "warn", "ignore", "fix"] = "raise", **kwargs) -> None: ...
@overload
def from_geojson(
- geometry: ArrayLikeSeq[str | bytes | None], on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs
+ geometry: str | bytes, on_invalid: Literal["raise", "warn", "ignore", "fix"] = "raise", **kwargs
+) -> BaseGeometry: ... # type: ignore[overload-overlap]
+@overload
+def from_geojson(
+ geometry: ArrayLikeSeq[str | bytes | None], on_invalid: Literal["raise", "warn", "ignore", "fix"] = "raise", **kwargs
) -> GeoArray: ...
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/lib.pyi b/python/helpers/typeshed/stubs/shapely/shapely/lib.pyi
index a3b3d82bb9f2..33546b37d28c 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/lib.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/lib.pyi
@@ -144,12 +144,12 @@ registry: list[type[Geometry]]
class Geometry:
def __hash__(self) -> int: ...
- def __eq__(self, other: object) -> bool: ...
- def __ne__(self, other: object) -> bool: ...
- def __ge__(self, other: Never) -> bool: ...
- def __gt__(self, other: Never) -> bool: ...
- def __le__(self, other: Never) -> bool: ...
- def __lt__(self, other: Never) -> bool: ...
+ def __eq__(self, other: object, /) -> bool: ...
+ def __ne__(self, other: object, /) -> bool: ...
+ def __ge__(self, other: Never, /) -> bool: ...
+ def __gt__(self, other: Never, /) -> bool: ...
+ def __le__(self, other: Never, /) -> bool: ...
+ def __lt__(self, other: Never, /) -> bool: ...
@final
class STRtree:
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/linear.pyi b/python/helpers/typeshed/stubs/shapely/shapely/linear.pyi
index c7be17806dd8..10701f0c5ed7 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/linear.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/linear.pyi
@@ -30,7 +30,7 @@ def line_interpolate_point(
@overload
def line_locate_point(
line: LineString | MultiLineString | GeometryCollection | None, other: Point | None, normalized: bool = False, **kwargs
-) -> float: ...
+) -> np.float64: ...
@overload
def line_locate_point(
line: LineString | MultiLineString | GeometryCollection | None, other: OptGeoArrayLikeSeq, normalized: bool = False, **kwargs
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/measurement.pyi b/python/helpers/typeshed/stubs/shapely/shapely/measurement.pyi
index 69d9a0c40654..065e6b831d09 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/measurement.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/measurement.pyi
@@ -8,22 +8,22 @@ from .lib import Geometry
__all__ = [
"area",
- "distance",
"bounds",
- "total_bounds",
- "length",
- "hausdorff_distance",
+ "distance",
"frechet_distance",
- "minimum_clearance",
+ "hausdorff_distance",
+ "length",
"minimum_bounding_radius",
+ "minimum_clearance",
+ "total_bounds",
]
@overload
-def area(geometry: Geometry | None, **kwargs) -> float: ...
+def area(geometry: Geometry | None, **kwargs) -> np.float64: ...
@overload
def area(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.float64]: ...
@overload
-def distance(a: Geometry | None, b: Geometry | None, **kwargs) -> float: ...
+def distance(a: Geometry | None, b: Geometry | None, **kwargs) -> np.float64: ...
@overload
def distance(a: OptGeoArrayLikeSeq, b: OptGeoArrayLike, **kwargs) -> NDArray[np.float64]: ...
@overload
@@ -31,11 +31,11 @@ def distance(a: OptGeoArrayLike, b: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.
def bounds(geometry: OptGeoArrayLike, **kwargs) -> NDArray[np.float64]: ...
def total_bounds(geometry: OptGeoArrayLike, **kwargs) -> NDArray[np.float64]: ...
@overload
-def length(geometry: Geometry | None, **kwargs) -> float: ...
+def length(geometry: Geometry | None, **kwargs) -> np.float64: ...
@overload
def length(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.float64]: ...
@overload
-def hausdorff_distance(a: Geometry | None, b: Geometry | None, densify: float | None = None, **kwargs) -> float: ...
+def hausdorff_distance(a: Geometry | None, b: Geometry | None, densify: float | None = None, **kwargs) -> np.float64: ...
@overload
def hausdorff_distance(a: OptGeoArrayLike, b: OptGeoArrayLike, densify: ArrayLikeSeq[float], **kwargs) -> NDArray[np.float64]: ...
@overload
@@ -47,7 +47,7 @@ def hausdorff_distance(
a: OptGeoArrayLike, b: OptGeoArrayLikeSeq, densify: ArrayLike[float] | None = None, **kwargs
) -> NDArray[np.float64]: ...
@overload
-def frechet_distance(a: Geometry | None, b: Geometry | None, densify: float | None = None, **kwargs) -> float: ...
+def frechet_distance(a: Geometry | None, b: Geometry | None, densify: float | None = None, **kwargs) -> np.float64: ...
@overload
def frechet_distance(a: OptGeoArrayLike, b: OptGeoArrayLike, densify: ArrayLikeSeq[float], **kwargs) -> NDArray[np.float64]: ...
@overload
@@ -59,10 +59,10 @@ def frechet_distance(
a: OptGeoArrayLike, b: OptGeoArrayLikeSeq, densify: ArrayLike[float] | None = None, **kwargs
) -> NDArray[np.float64]: ...
@overload
-def minimum_clearance(geometry: Geometry | None, **kwargs) -> float: ...
+def minimum_clearance(geometry: Geometry | None, **kwargs) -> np.float64: ...
@overload
def minimum_clearance(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.float64]: ...
@overload
-def minimum_bounding_radius(geometry: Geometry | None, **kwargs) -> float: ...
+def minimum_bounding_radius(geometry: Geometry | None, **kwargs) -> np.float64: ...
@overload
def minimum_bounding_radius(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.float64]: ...
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/predicates.pyi b/python/helpers/typeshed/stubs/shapely/shapely/predicates.pyi
index 3b4fe369b980..a9e39dfadead 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/predicates.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/predicates.pyi
@@ -1,5 +1,6 @@
+import sys
from typing import Any, Literal, overload
-from typing_extensions import TypeGuard
+from typing_extensions import TypeAlias, TypeGuard
import numpy as np
from numpy.typing import NDArray
@@ -8,6 +9,13 @@ from ._typing import ArrayLike, ArrayLikeSeq, OptGeoArrayLike, OptGeoArrayLikeSe
from .geometry.base import BaseGeometry
from .lib import Geometry
+if sys.version_info >= (3, 10):
+ _NPTrue: TypeAlias = np.bool_[Literal[True]]
+ _NPFalse: TypeAlias = np.bool_[Literal[False]]
+else:
+ _NPTrue: TypeAlias = np.bool_
+ _NPFalse: TypeAlias = np.bool_
+
__all__ = [
"contains",
"contains_properly",
@@ -43,57 +51,61 @@ __all__ = [
]
@overload
-def has_z(geometry: Geometry | None, **kwargs) -> bool: ...
+def has_z(geometry: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def has_z(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ...
@overload
-def has_m(geometry: Geometry | None, **kwargs) -> bool: ...
+def has_m(geometry: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def has_m(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ...
@overload
-def is_ccw(geometry: Geometry | None, **kwargs) -> bool: ...
+def is_ccw(geometry: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def is_ccw(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ...
@overload
-def is_closed(geometry: Geometry | None, **kwargs) -> bool: ...
+def is_closed(geometry: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def is_closed(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ...
@overload
-def is_empty(geometry: Geometry | None, **kwargs) -> bool: ...
+def is_empty(geometry: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def is_empty(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ...
@overload
-def is_geometry(geometry: Geometry, **kwargs) -> Literal[True]: ...
+def is_geometry(geometry: Geometry, **kwargs) -> _NPTrue: ...
+@overload
+def is_geometry(geometry: None, **kwargs) -> _NPFalse: ...
@overload
def is_geometry(geometry: ArrayLikeSeq[Any], **kwargs) -> NDArray[np.bool_]: ... # type: ignore[overload-overlap]
@overload
def is_geometry(geometry: object, **kwargs) -> TypeGuard[BaseGeometry]: ...
@overload
-def is_missing(geometry: Geometry, **kwargs) -> Literal[True]: ...
+def is_missing(geometry: Geometry, **kwargs) -> _NPFalse: ...
+@overload
+def is_missing(geometry: None, **kwargs) -> _NPTrue: ...
@overload
def is_missing(geometry: ArrayLikeSeq[Any], **kwargs) -> NDArray[np.bool_]: ... # type: ignore[overload-overlap]
@overload
-def is_missing(geometry: object, **kwargs) -> TypeGuard[BaseGeometry]: ...
+def is_missing(geometry: object, **kwargs) -> TypeGuard[None]: ...
@overload
-def is_prepared(geometry: Geometry | None, **kwargs) -> bool: ...
+def is_prepared(geometry: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def is_prepared(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ...
@overload
-def is_valid_input(geometry: Geometry | None, **kwargs) -> Literal[True]: ...
+def is_valid_input(geometry: Geometry | None, **kwargs) -> _NPTrue: ...
@overload
def is_valid_input(geometry: ArrayLikeSeq[Any], **kwargs) -> NDArray[np.bool_]: ... # type: ignore[overload-overlap]
@overload
def is_valid_input(geometry: object, **kwargs) -> TypeGuard[BaseGeometry | None]: ...
@overload
-def is_ring(geometry: Geometry | None, **kwargs) -> bool: ...
+def is_ring(geometry: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def is_ring(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ...
@overload
-def is_simple(geometry: Geometry | None, **kwargs) -> bool: ...
+def is_simple(geometry: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def is_simple(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ...
@overload
-def is_valid(geometry: Geometry | None, **kwargs) -> bool: ...
+def is_valid(geometry: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def is_valid(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ...
@overload
@@ -103,67 +115,67 @@ def is_valid_reason(geometry: Geometry, **kwargs) -> str: ...
@overload
def is_valid_reason(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.object_]: ...
@overload
-def crosses(a: Geometry | None, b: Geometry | None, **kwargs) -> bool: ...
+def crosses(a: Geometry | None, b: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def crosses(a: OptGeoArrayLikeSeq, b: OptGeoArrayLike, **kwargs) -> NDArray[np.bool_]: ...
@overload
def crosses(a: OptGeoArrayLike, b: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ...
@overload
-def contains(a: Geometry | None, b: Geometry | None, **kwargs) -> bool: ...
+def contains(a: Geometry | None, b: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def contains(a: OptGeoArrayLikeSeq, b: OptGeoArrayLike, **kwargs) -> NDArray[np.bool_]: ...
@overload
def contains(a: OptGeoArrayLike, b: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ...
@overload
-def contains_properly(a: Geometry | None, b: Geometry | None, **kwargs) -> bool: ...
+def contains_properly(a: Geometry | None, b: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def contains_properly(a: OptGeoArrayLikeSeq, b: OptGeoArrayLike, **kwargs) -> NDArray[np.bool_]: ...
@overload
def contains_properly(a: OptGeoArrayLike, b: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ...
@overload
-def covered_by(a: Geometry | None, b: Geometry | None, **kwargs) -> bool: ...
+def covered_by(a: Geometry | None, b: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def covered_by(a: OptGeoArrayLikeSeq, b: OptGeoArrayLike, **kwargs) -> NDArray[np.bool_]: ...
@overload
def covered_by(a: OptGeoArrayLike, b: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ...
@overload
-def covers(a: Geometry | None, b: Geometry | None, **kwargs) -> bool: ...
+def covers(a: Geometry | None, b: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def covers(a: OptGeoArrayLikeSeq, b: OptGeoArrayLike, **kwargs) -> NDArray[np.bool_]: ...
@overload
def covers(a: OptGeoArrayLike, b: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ...
@overload
-def disjoint(a: Geometry | None, b: Geometry | None, **kwargs) -> bool: ...
+def disjoint(a: Geometry | None, b: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def disjoint(a: OptGeoArrayLikeSeq, b: OptGeoArrayLike, **kwargs) -> NDArray[np.bool_]: ...
@overload
def disjoint(a: OptGeoArrayLike, b: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ...
@overload
-def equals(a: Geometry | None, b: Geometry | None, **kwargs) -> bool: ...
+def equals(a: Geometry | None, b: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def equals(a: OptGeoArrayLikeSeq, b: OptGeoArrayLike, **kwargs) -> NDArray[np.bool_]: ...
@overload
def equals(a: OptGeoArrayLike, b: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ...
@overload
-def intersects(a: Geometry | None, b: Geometry | None, **kwargs) -> bool: ...
+def intersects(a: Geometry | None, b: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def intersects(a: OptGeoArrayLikeSeq, b: OptGeoArrayLike, **kwargs) -> NDArray[np.bool_]: ...
@overload
def intersects(a: OptGeoArrayLike, b: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ...
@overload
-def overlaps(a: Geometry | None, b: Geometry | None, **kwargs) -> bool: ...
+def overlaps(a: Geometry | None, b: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def overlaps(a: OptGeoArrayLikeSeq, b: OptGeoArrayLike, **kwargs) -> NDArray[np.bool_]: ...
@overload
def overlaps(a: OptGeoArrayLike, b: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ...
@overload
-def touches(a: Geometry | None, b: Geometry | None, **kwargs) -> bool: ...
+def touches(a: Geometry | None, b: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def touches(a: OptGeoArrayLikeSeq, b: OptGeoArrayLike, **kwargs) -> NDArray[np.bool_]: ...
@overload
def touches(a: OptGeoArrayLike, b: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ...
@overload
-def within(a: Geometry | None, b: Geometry | None, **kwargs) -> bool: ...
+def within(a: Geometry | None, b: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def within(a: OptGeoArrayLikeSeq, b: OptGeoArrayLike, **kwargs) -> NDArray[np.bool_]: ...
@overload
@@ -171,7 +183,7 @@ def within(a: OptGeoArrayLike, b: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bo
@overload
def equals_exact(
a: Geometry | None, b: Geometry | None, tolerance: float = 0.0, *, normalize: bool = False, **kwargs
-) -> bool: ...
+) -> np.bool_: ...
@overload
def equals_exact(
a: OptGeoArrayLike, b: OptGeoArrayLike, tolerance: ArrayLikeSeq[float], *, normalize: bool = False, **kwargs
@@ -185,7 +197,7 @@ def equals_exact(
a: OptGeoArrayLike, b: OptGeoArrayLikeSeq, tolerance: ArrayLike[float] = 0.0, *, normalize: bool = False, **kwargs
) -> NDArray[np.bool_]: ...
@overload
-def equals_identical(a: Geometry | None, b: Geometry | None, **kwargs) -> bool: ...
+def equals_identical(a: Geometry | None, b: Geometry | None, **kwargs) -> np.bool_: ...
@overload
def equals_identical(a: OptGeoArrayLikeSeq, b: OptGeoArrayLike, **kwargs) -> NDArray[np.bool_]: ...
@overload
@@ -201,19 +213,19 @@ def relate(a: OptGeoArrayLikeSeq, b: OptGeoArrayLike, **kwargs) -> NDArray[np.ob
@overload
def relate(a: OptGeoArrayLike, b: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.object_]: ...
@overload
-def relate_pattern(a: Geometry | None, b: Geometry | None, pattern: str, **kwargs) -> bool: ...
+def relate_pattern(a: Geometry | None, b: Geometry | None, pattern: str, **kwargs) -> np.bool_: ...
@overload
def relate_pattern(a: OptGeoArrayLikeSeq, b: OptGeoArrayLike, pattern: str, **kwargs) -> NDArray[np.bool_]: ...
@overload
def relate_pattern(a: OptGeoArrayLike, b: OptGeoArrayLikeSeq, pattern: str, **kwargs) -> NDArray[np.bool_]: ...
@overload
-def dwithin(a: Geometry | None, b: Geometry | None, distance: float, **kwargs) -> bool: ...
+def dwithin(a: Geometry | None, b: Geometry | None, distance: float, **kwargs) -> np.bool_: ...
@overload
def dwithin(a: OptGeoArrayLikeSeq, b: OptGeoArrayLike, distance: float, **kwargs) -> NDArray[np.bool_]: ...
@overload
def dwithin(a: OptGeoArrayLike, b: OptGeoArrayLikeSeq, distance: float, **kwargs) -> NDArray[np.bool_]: ...
@overload
-def contains_xy(geom: Geometry | None, x: float, y: float, **kwargs) -> bool: ...
+def contains_xy(geom: Geometry | None, x: float, y: float, **kwargs) -> np.bool_: ...
@overload
def contains_xy(geom: OptGeoArrayLike, x: ArrayLikeSeq[float], y: None = None, **kwargs) -> NDArray[np.bool_]: ...
@overload
@@ -223,7 +235,7 @@ def contains_xy(geom: Geometry | None, x: ArrayLikeSeq[float], y: ArrayLike[floa
@overload
def contains_xy(geom: OptGeoArrayLikeSeq, x: ArrayLike[float], y: ArrayLike[float], **kwargs) -> NDArray[np.bool_]: ...
@overload
-def intersects_xy(geom: Geometry | None, x: float, y: float, **kwargs) -> bool: ...
+def intersects_xy(geom: Geometry | None, x: float, y: float, **kwargs) -> np.bool_: ...
@overload
def intersects_xy(geom: OptGeoArrayLike, x: ArrayLikeSeq[float], y: None = None, **kwargs) -> NDArray[np.bool_]: ...
@overload
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/set_operations.pyi b/python/helpers/typeshed/stubs/shapely/shapely/set_operations.pyi
index ccc6d3c8e91c..a243b3028e5c 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/set_operations.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/set_operations.pyi
@@ -1,4 +1,5 @@
from typing import overload
+from typing_extensions import deprecated
from ._typing import GeoArray, OptGeoArrayLike, OptGeoArrayLikeSeq
from .geometry.base import BaseGeometry
@@ -54,8 +55,10 @@ def symmetric_difference(a: OptGeoArrayLikeSeq, b: OptGeoArrayLike, grid_size: f
@overload
def symmetric_difference(a: OptGeoArrayLike, b: OptGeoArrayLikeSeq, grid_size: float | None = None, **kwargs) -> GeoArray: ...
@overload
+@deprecated("symmetric_difference_all behaves incorrectly and will be removed in a future version.")
def symmetric_difference_all(geometries: OptGeoArrayLike, axis: None = None, **kwargs) -> BaseGeometry: ...
@overload
+@deprecated("symmetric_difference_all behaves incorrectly and will be removed in a future version.")
def symmetric_difference_all(geometries: OptGeoArrayLikeSeq, axis: int, **kwargs) -> BaseGeometry | GeoArray: ...
@overload
def union(a: Geometry, b: Geometry, grid_size: float | None = None, **kwargs) -> BaseGeometry: ...
@@ -86,10 +89,7 @@ def coverage_union(a: OptGeoArrayLike, b: OptGeoArrayLike, *, axis: int, **kwarg
def coverage_union_all(geometries: OptGeoArrayLike, axis: None = None, **kwargs) -> BaseGeometry: ...
@overload
def coverage_union_all(geometries: OptGeoArrayLikeSeq, axis: int, **kwargs) -> BaseGeometry | GeoArray: ...
-@overload
-def disjoint_subset_union(a: OptGeoArrayLike, b: OptGeoArrayLike, *, axis: None = None, **kwargs) -> BaseGeometry: ...
-@overload
-def disjoint_subset_union(a: OptGeoArrayLike, b: OptGeoArrayLike, *, axis: int, **kwargs) -> BaseGeometry | GeoArray: ...
+def disjoint_subset_union(a: OptGeoArrayLike, b: OptGeoArrayLike, **kwargs) -> BaseGeometry | GeoArray: ...
@overload
def disjoint_subset_union_all(geometries: OptGeoArrayLike, *, axis: None = None, **kwargs) -> BaseGeometry: ...
@overload
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/strtree.pyi b/python/helpers/typeshed/stubs/shapely/shapely/strtree.pyi
index d85da2e733c9..0e03e3ffc338 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/strtree.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/strtree.pyi
@@ -40,7 +40,7 @@ class STRtree:
) -> NDArray[np.int64]: ...
# nearest may return `None` if the tree is empty, use the "Any trick"
@overload
- def nearest(self, geometry: Geometry) -> int | Any: ...
+ def nearest(self, geometry: Geometry) -> np.int64 | Any: ...
@overload
def nearest(self, geometry: GeoArrayLikeSeq) -> NDArray[np.int64] | Any: ...
@overload # return_distance=False
diff --git a/python/helpers/typeshed/stubs/shapely/shapely/vectorized/__init__.pyi b/python/helpers/typeshed/stubs/shapely/shapely/vectorized/__init__.pyi
index 327128e4c6fd..d4db8f593412 100644
--- a/python/helpers/typeshed/stubs/shapely/shapely/vectorized/__init__.pyi
+++ b/python/helpers/typeshed/stubs/shapely/shapely/vectorized/__init__.pyi
@@ -1,4 +1,5 @@
from typing import overload
+from typing_extensions import deprecated
import numpy as np
from numpy.typing import NDArray
@@ -8,30 +9,38 @@ from ..lib import Geometry
from ..prepared import PreparedGeometry
@overload
-def contains(geometry: Geometry | PreparedGeometry[Geometry], x: float, y: float) -> bool: ...
+@deprecated("Use 'shapely.contains_xy' instead (available since shapely 2.0.0).")
+def contains(geometry: Geometry | PreparedGeometry[Geometry], x: float, y: float) -> np.bool_: ...
@overload
+@deprecated("Use 'shapely.contains_xy' instead (available since shapely 2.0.0).")
def contains(
geometry: Geometry | PreparedGeometry[Geometry], x: ArrayLikeSeq[float], y: ArrayLike[float]
) -> NDArray[np.bool_]: ...
@overload
+@deprecated("Use 'shapely.contains_xy' instead (available since shapely 2.0.0).")
def contains(
geometry: Geometry | PreparedGeometry[Geometry], x: ArrayLike[float], y: ArrayLikeSeq[float]
) -> NDArray[np.bool_]: ...
@overload
+@deprecated("Use 'shapely.contains_xy' instead (available since shapely 2.0.0).")
def contains(
geometry: Geometry | PreparedGeometry[Geometry], x: ArrayLike[float], y: ArrayLike[float]
-) -> bool | NDArray[np.bool_]: ...
+) -> np.bool_ | NDArray[np.bool_]: ...
@overload
-def touches(geometry: Geometry | PreparedGeometry[Geometry], x: float, y: float) -> bool: ...
+@deprecated("Use 'shapely.intersects_xy' instead (available since shapely 2.0.0).")
+def touches(geometry: Geometry | PreparedGeometry[Geometry], x: float, y: float) -> np.bool_: ...
@overload
+@deprecated("Use 'shapely.intersects_xy' instead (available since shapely 2.0.0).")
def touches(
geometry: Geometry | PreparedGeometry[Geometry], x: ArrayLikeSeq[float], y: ArrayLike[float]
) -> NDArray[np.bool_]: ...
@overload
+@deprecated("Use 'shapely.intersects_xy' instead (available since shapely 2.0.0).")
def touches(
geometry: Geometry | PreparedGeometry[Geometry], x: ArrayLike[float], y: ArrayLikeSeq[float]
) -> NDArray[np.bool_]: ...
@overload
+@deprecated("Use 'shapely.intersects_xy' instead (available since shapely 2.0.0).")
def touches(
geometry: Geometry | PreparedGeometry[Geometry], x: ArrayLike[float], y: ArrayLike[float]
-) -> bool | NDArray[np.bool_]: ...
+) -> np.bool_ | NDArray[np.bool_]: ...
diff --git a/python/helpers/typeshed/stubs/simplejson/simplejson/__init__.pyi b/python/helpers/typeshed/stubs/simplejson/simplejson/__init__.pyi
index aec7c35da6b2..7705280f31ef 100644
--- a/python/helpers/typeshed/stubs/simplejson/simplejson/__init__.pyi
+++ b/python/helpers/typeshed/stubs/simplejson/simplejson/__init__.pyi
@@ -15,156 +15,156 @@ _T = TypeVar("_T")
@overload
def dumps(
obj: Any,
- skipkeys: bool = ...,
- ensure_ascii: bool = ...,
- check_circular: bool = ...,
- allow_nan: bool = ...,
+ skipkeys: bool = False,
+ ensure_ascii: bool = True,
+ check_circular: bool = True,
+ allow_nan: bool = False,
*,
cls: type[JSONEncoder],
- indent: str | int | None = ...,
- separators: tuple[str, str] | None = ...,
- encoding: str | None = ...,
- default: Callable[[Any], Any] | None = ...,
- use_decimal: bool = ...,
- namedtuple_as_object: bool = ...,
- tuple_as_array: bool = ...,
- bigint_as_string: bool = ...,
- sort_keys: bool = ...,
- item_sort_key: Callable[[Any], SupportsRichComparison] | None = ...,
- for_json: bool = ...,
- ignore_nan: bool = ...,
- int_as_string_bitcount: int | None = ...,
- iterable_as_array: bool = ...,
+ indent: str | int | None = None,
+ separators: tuple[str, str] | None = None,
+ encoding: str | None = "utf-8",
+ default: Callable[[Any], Any] | None = None,
+ use_decimal: bool = True,
+ namedtuple_as_object: bool = True,
+ tuple_as_array: bool = True,
+ bigint_as_string: bool = False,
+ sort_keys: bool = False,
+ item_sort_key: Callable[[Any], SupportsRichComparison] | None = None,
+ for_json: bool = False,
+ ignore_nan: bool = False,
+ int_as_string_bitcount: int | None = None,
+ iterable_as_array: bool = False,
**kw: Any,
) -> str: ...
@overload
def dumps(
obj: Any,
- skipkeys: bool = ...,
- ensure_ascii: bool = ...,
- check_circular: bool = ...,
- allow_nan: bool = ...,
- cls: type[JSONEncoder] | None = ...,
- indent: str | int | None = ...,
- separators: tuple[str, str] | None = ...,
- encoding: str | None = ...,
- default: Callable[[Any], Any] | None = ...,
- use_decimal: bool = ...,
- namedtuple_as_object: bool = ...,
- tuple_as_array: bool = ...,
- bigint_as_string: bool = ...,
- sort_keys: bool = ...,
- item_sort_key: Callable[[Any], SupportsRichComparison] | None = ...,
- for_json: bool = ...,
- ignore_nan: bool = ...,
- int_as_string_bitcount: int | None = ...,
- iterable_as_array: bool = ...,
+ skipkeys: bool = False,
+ ensure_ascii: bool = True,
+ check_circular: bool = True,
+ allow_nan: bool = False,
+ cls: type[JSONEncoder] | None = None,
+ indent: str | int | None = None,
+ separators: tuple[str, str] | None = None,
+ encoding: str | None = "utf-8",
+ default: Callable[[Any], Any] | None = None,
+ use_decimal: bool = True,
+ namedtuple_as_object: bool = True,
+ tuple_as_array: bool = True,
+ bigint_as_string: bool = False,
+ sort_keys: bool = False,
+ item_sort_key: Callable[[Any], SupportsRichComparison] | None = None,
+ for_json: bool = False,
+ ignore_nan: bool = False,
+ int_as_string_bitcount: int | None = None,
+ iterable_as_array: bool = False,
) -> str: ...
@overload
def dump(
obj: Any,
fp: IO[str],
- skipkeys: bool = ...,
- ensure_ascii: bool = ...,
- check_circular: bool = ...,
- allow_nan: bool = ...,
+ skipkeys: bool = False,
+ ensure_ascii: bool = True,
+ check_circular: bool = True,
+ allow_nan: bool = False,
*,
cls: type[JSONEncoder],
- indent: str | int | None = ...,
- separators: tuple[str, str] | None = ...,
- encoding: str | None = ...,
- default: Callable[[Any], Any] | None = ...,
- use_decimal: bool = ...,
- namedtuple_as_object: bool = ...,
- tuple_as_array: bool = ...,
- bigint_as_string: bool = ...,
- sort_keys: bool = ...,
- item_sort_key: Callable[[Any], SupportsRichComparison] | None = ...,
- for_json: bool = ...,
- ignore_nan: bool = ...,
- int_as_string_bitcount: int | None = ...,
- iterable_as_array: bool = ...,
+ indent: str | int | None = None,
+ separators: tuple[str, str] | None = None,
+ encoding: str | None = "utf-8",
+ default: Callable[[Any], Any] | None = None,
+ use_decimal: bool = True,
+ namedtuple_as_object: bool = True,
+ tuple_as_array: bool = True,
+ bigint_as_string: bool = False,
+ sort_keys: bool = False,
+ item_sort_key: Callable[[Any], SupportsRichComparison] | None = None,
+ for_json: bool = False,
+ ignore_nan: bool = False,
+ int_as_string_bitcount: int | None = None,
+ iterable_as_array: bool = False,
**kw: Any,
) -> None: ...
@overload
def dump(
obj: Any,
fp: IO[str],
- skipkeys: bool = ...,
- ensure_ascii: bool = ...,
- check_circular: bool = ...,
- allow_nan: bool = ...,
- cls: type[JSONEncoder] | None = ...,
- indent: str | int | None = ...,
- separators: tuple[str, str] | None = ...,
- encoding: str | None = ...,
- default: Callable[[Any], Any] | None = ...,
- use_decimal: bool = ...,
- namedtuple_as_object: bool = ...,
- tuple_as_array: bool = ...,
- bigint_as_string: bool = ...,
- sort_keys: bool = ...,
- item_sort_key: Callable[[Any], SupportsRichComparison] | None = ...,
- for_json: bool = ...,
- ignore_nan: bool = ...,
- int_as_string_bitcount: int | None = ...,
- iterable_as_array: bool = ...,
+ skipkeys: bool = False,
+ ensure_ascii: bool = True,
+ check_circular: bool = True,
+ allow_nan: bool = False,
+ cls: type[JSONEncoder] | None = None,
+ indent: str | int | None = None,
+ separators: tuple[str, str] | None = None,
+ encoding: str | None = "utf-8",
+ default: Callable[[Any], Any] | None = None,
+ use_decimal: bool = True,
+ namedtuple_as_object: bool = True,
+ tuple_as_array: bool = True,
+ bigint_as_string: bool = False,
+ sort_keys: bool = False,
+ item_sort_key: Callable[[Any], SupportsRichComparison] | None = None,
+ for_json: bool = False,
+ ignore_nan: bool = False,
+ int_as_string_bitcount: int | None = None,
+ iterable_as_array: bool = False,
) -> None: ...
@overload
def loads(
s: _LoadsString,
- encoding: str | None = ...,
+ encoding: str | None = None,
*,
cls: type[JSONDecoder],
- object_hook: Callable[[dict[Any, Any]], Any] | None = ...,
- parse_float: Callable[[str], Any] | None = ...,
- parse_int: Callable[[str], Any] | None = ...,
- parse_constant: Callable[[str], Any] | None = ...,
- object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = ...,
- use_decimal: bool = ...,
- allow_nan: bool = ...,
+ object_hook: Callable[[dict[Any, Any]], Any] | None = None,
+ parse_float: Callable[[str], Any] | None = None,
+ parse_int: Callable[[str], Any] | None = None,
+ parse_constant: Callable[[str], Any] | None = None,
+ object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None,
+ use_decimal: bool = False,
+ allow_nan: bool = False,
**kw: Any,
) -> Any: ...
@overload
def loads(
s: _LoadsString,
- encoding: str | None = ...,
- cls: type[JSONDecoder] | None = ...,
- object_hook: Callable[[dict[Any, Any]], Any] | None = ...,
- parse_float: Callable[[str], Any] | None = ...,
- parse_int: Callable[[str], Any] | None = ...,
- parse_constant: Callable[[str], Any] | None = ...,
- object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = ...,
- use_decimal: bool = ...,
- allow_nan: bool = ...,
+ encoding: str | None = None,
+ cls: type[JSONDecoder] | None = None,
+ object_hook: Callable[[dict[Any, Any]], Any] | None = None,
+ parse_float: Callable[[str], Any] | None = None,
+ parse_int: Callable[[str], Any] | None = None,
+ parse_constant: Callable[[str], Any] | None = None,
+ object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None,
+ use_decimal: bool = False,
+ allow_nan: bool = False,
) -> Any: ...
@overload
def load(
fp: IO[str],
- encoding: str | None = ...,
+ encoding: str | None = None,
*,
cls: type[JSONDecoder],
- object_hook: Callable[[dict[Any, Any]], Any] | None = ...,
- parse_float: Callable[[str], Any] | None = ...,
- parse_int: Callable[[str], Any] | None = ...,
- parse_constant: Callable[[str], Any] | None = ...,
- object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = ...,
- use_decimal: bool = ...,
- allow_nan: bool = ...,
+ object_hook: Callable[[dict[Any, Any]], Any] | None = None,
+ parse_float: Callable[[str], Any] | None = None,
+ parse_int: Callable[[str], Any] | None = None,
+ parse_constant: Callable[[str], Any] | None = None,
+ object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None,
+ use_decimal: bool = False,
+ allow_nan: bool = False,
**kw: Any,
) -> Any: ...
@overload
def load(
fp: IO[str],
- encoding: str | None = ...,
- cls: type[JSONDecoder] | None = ...,
- object_hook: Callable[[dict[Any, Any]], Any] | None = ...,
- parse_float: Callable[[str], Any] | None = ...,
- parse_int: Callable[[str], Any] | None = ...,
- parse_constant: Callable[[str], Any] | None = ...,
- object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = ...,
- use_decimal: bool = ...,
- allow_nan: bool = ...,
+ encoding: str | None = None,
+ cls: type[JSONDecoder] | None = None,
+ object_hook: Callable[[dict[Any, Any]], Any] | None = None,
+ parse_float: Callable[[str], Any] | None = None,
+ parse_int: Callable[[str], Any] | None = None,
+ parse_constant: Callable[[str], Any] | None = None,
+ object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None,
+ use_decimal: bool = False,
+ allow_nan: bool = False,
) -> Any: ...
def simple_first(kv: tuple[_T, object]) -> tuple[bool, _T]: ...
diff --git a/python/helpers/typeshed/stubs/simplejson/simplejson/decoder.pyi b/python/helpers/typeshed/stubs/simplejson/simplejson/decoder.pyi
index 8f9dc05065b4..4afa6ea9360c 100644
--- a/python/helpers/typeshed/stubs/simplejson/simplejson/decoder.pyi
+++ b/python/helpers/typeshed/stubs/simplejson/simplejson/decoder.pyi
@@ -15,18 +15,18 @@ class JSONDecoder:
def __init__(
self,
- encoding: str | None = ...,
- object_hook: Callable[[dict[Any, Any]], Any] | None = ...,
- parse_float: Callable[[str], Any] | None = ...,
- parse_int: Callable[[str], Any] | None = ...,
- parse_constant: Callable[[str], Any] | None = ...,
- strict: bool = ...,
- object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = ...,
- allow_nan: bool = ...,
+ encoding: str | None = None,
+ object_hook: Callable[[dict[Any, Any]], Any] | None = None,
+ parse_float: Callable[[str], Any] | None = None,
+ parse_int: Callable[[str], Any] | None = None,
+ parse_constant: Callable[[str], Any] | None = None,
+ strict: bool = True,
+ object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None,
+ allow_nan: bool = False,
) -> None: ...
- def decode(self, s: str, _w: Callable[[str, int], Match[str]] = ..., _PY3: Literal[True] = ...) -> Any: ...
+ def decode(self, s: str, _w: Callable[[str, int], Match[str]] = ..., _PY3: Literal[True] = True) -> Any: ...
def raw_decode(
- self, s: str, idx: int = ..., _w: Callable[[str, int], Match[str]] = ..., _PY3: Literal[True] = ...
+ self, s: str, idx: int = 0, _w: Callable[[str, int], Match[str]] = ..., _PY3: Literal[True] = True
) -> tuple[Any, int]: ...
__all__ = ["JSONDecoder"]
diff --git a/python/helpers/typeshed/stubs/simplejson/simplejson/encoder.pyi b/python/helpers/typeshed/stubs/simplejson/simplejson/encoder.pyi
index 41017f0c1d98..15378765980d 100644
--- a/python/helpers/typeshed/stubs/simplejson/simplejson/encoder.pyi
+++ b/python/helpers/typeshed/stubs/simplejson/simplejson/encoder.pyi
@@ -31,24 +31,24 @@ class JSONEncoder:
def __init__(
self,
- skipkeys: bool = ...,
- ensure_ascii: bool = ...,
- check_circular: bool = ...,
- allow_nan: bool = ...,
- sort_keys: bool = ...,
- indent: str | int | None = ...,
- separators: tuple[str, str] | None = ...,
- encoding: str = ...,
- default: Callable[[Any], Any] | None = ...,
- use_decimal: bool = ...,
- namedtuple_as_object: bool = ...,
- tuple_as_array: bool = ...,
- bigint_as_string: bool = ...,
- item_sort_key: Callable[[Any], SupportsRichComparison] | None = ...,
- for_json: bool = ...,
- ignore_nan: bool = ...,
- int_as_string_bitcount: int | None = ...,
- iterable_as_array: bool = ...,
+ skipkeys: bool = False,
+ ensure_ascii: bool = True,
+ check_circular: bool = True,
+ allow_nan: bool = False,
+ sort_keys: bool = False,
+ indent: str | int | None = None,
+ separators: tuple[str, str] | None = None,
+ encoding: str = "utf-8",
+ default: Callable[[Any], Any] | None = None,
+ use_decimal: bool = True,
+ namedtuple_as_object: bool = True,
+ tuple_as_array: bool = True,
+ bigint_as_string: bool = False,
+ item_sort_key: Callable[[Any], SupportsRichComparison] | None = None,
+ for_json: bool = False,
+ ignore_nan: bool = False,
+ int_as_string_bitcount: int | None = None,
+ iterable_as_array: bool = False,
) -> None: ...
def encode(self, o: Any) -> str: ...
def default(self, o: Any) -> NoReturn: ...
@@ -56,5 +56,5 @@ class JSONEncoder:
class JSONEncoderForHTML(JSONEncoder): ...
-def encode_basestring(s: str | bytes, _PY3: Literal[True] = ..., _q: str = ...) -> str: ...
+def encode_basestring(s: str | bytes, _PY3: Literal[True] = True, _q: str = '"') -> str: ...
def encode_basestring_ascii(s: str | bytes, /) -> str: ...
diff --git a/python/helpers/typeshed/stubs/singledispatch/singledispatch.pyi b/python/helpers/typeshed/stubs/singledispatch/singledispatch.pyi
index 8a04562c1ac6..feafcc251c88 100644
--- a/python/helpers/typeshed/stubs/singledispatch/singledispatch.pyi
+++ b/python/helpers/typeshed/stubs/singledispatch/singledispatch.pyi
@@ -1,9 +1,10 @@
from collections.abc import Callable, Mapping
-from typing import Any, Generic, TypeVar, overload
+from typing import Any, Generic, TypeVar, overload, type_check_only
_T = TypeVar("_T")
_S = TypeVar("_S")
+@type_check_only
class _SingleDispatchCallable(Generic[_T]):
registry: Mapping[Any, Callable[..., _T]]
def dispatch(self, cls: Any) -> Callable[..., _T]: ...
diff --git a/python/helpers/typeshed/stubs/slumber/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/slumber/@tests/stubtest_allowlist.txt
deleted file mode 100644
index 15230d95a77b..000000000000
--- a/python/helpers/typeshed/stubs/slumber/@tests/stubtest_allowlist.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-slumber.API.__init__
-slumber.Resource.as_raw
diff --git a/python/helpers/typeshed/stubs/slumber/slumber/__init__.pyi b/python/helpers/typeshed/stubs/slumber/slumber/__init__.pyi
index cd581707085a..b9dd54415e37 100644
--- a/python/helpers/typeshed/stubs/slumber/slumber/__init__.pyi
+++ b/python/helpers/typeshed/stubs/slumber/slumber/__init__.pyi
@@ -2,7 +2,7 @@ from typing import Any
from typing_extensions import Self
from requests import Response, Session
-from requests.sessions import _Auth, _Data, _Files
+from requests.sessions import _Auth, _Data, _Files, _ParamsMappingValueType
from .serialize import Serializer
@@ -15,14 +15,13 @@ class ResourceAttributesMixin:
class Resource(ResourceAttributesMixin):
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def __call__(self, id: str | None = None, format: str | None = None, url_override: str | None = None) -> Self: ...
- def as_raw(self) -> Self: ...
- def get(self, **kwargs: Any) -> Response: ...
- def options(self, **kwargs: Any) -> Response: ...
- def head(self, **kwargs: Any) -> Response: ...
- def post(self, data: _Data | None = None, files: _Files | None = None, **kwargs: Any) -> Response: ...
- def patch(self, data: _Data | None = None, files: _Files | None = None, **kwargs: Any) -> Response: ...
- def put(self, data: _Data | None = None, files: _Files | None = None, **kwargs: Any) -> Response: ...
- def delete(self, **kwargs: Any) -> Response: ...
+ def get(self, **kwargs: _ParamsMappingValueType) -> Response: ...
+ def options(self, **kwargs: _ParamsMappingValueType) -> Response: ...
+ def head(self, **kwargs: _ParamsMappingValueType) -> Response: ...
+ def post(self, data: _Data | None = None, files: _Files | None = None, **kwargs: _ParamsMappingValueType) -> Response: ...
+ def patch(self, data: _Data | None = None, files: _Files | None = None, **kwargs: _ParamsMappingValueType) -> Response: ...
+ def put(self, data: _Data | None = None, files: _Files | None = None, **kwargs: _ParamsMappingValueType) -> Response: ...
+ def delete(self, **kwargs: _ParamsMappingValueType) -> Response: ...
def url(self) -> str: ...
class API(ResourceAttributesMixin):
@@ -35,5 +34,4 @@ class API(ResourceAttributesMixin):
append_slash: bool = True,
session: Session | None = None,
serializer: Serializer | None = None,
- raw: bool = ...,
) -> None: ...
diff --git a/python/helpers/typeshed/stubs/tensorflow/tensorflow/__init__.pyi b/python/helpers/typeshed/stubs/tensorflow/tensorflow/__init__.pyi
index 502113f1ce9a..d4b264a99b84 100644
--- a/python/helpers/typeshed/stubs/tensorflow/tensorflow/__init__.pyi
+++ b/python/helpers/typeshed/stubs/tensorflow/tensorflow/__init__.pyi
@@ -99,6 +99,7 @@ class Tensor:
@property
def op(self) -> Operation: ...
def numpy(self) -> AnyArray: ...
+ def __array__(self, dtype: DTypeLike | None = None) -> AnyArray: ...
def __int__(self) -> int: ...
def __abs__(self, name: str | None = None) -> Tensor: ...
def __add__(self, other: TensorCompatible) -> Tensor: ...
diff --git a/python/helpers/typeshed/stubs/tensorflow/tensorflow/_aliases.pyi b/python/helpers/typeshed/stubs/tensorflow/tensorflow/_aliases.pyi
index d8beae33eb11..6bc6918a6b21 100644
--- a/python/helpers/typeshed/stubs/tensorflow/tensorflow/_aliases.pyi
+++ b/python/helpers/typeshed/stubs/tensorflow/tensorflow/_aliases.pyi
@@ -5,7 +5,6 @@ from collections.abc import Iterable, Mapping, Sequence
from typing import Any, Protocol, TypeVar
from typing_extensions import TypeAlias
-import numpy # pytype needs the unaliased import to resolve DTypeLike
import numpy as np
import numpy.typing as npt
import tensorflow as tf
@@ -55,7 +54,7 @@ SparseTensorCompatible: TypeAlias = TensorCompatible | tf.SparseTensor
TensorOrArray: TypeAlias = tf.Tensor | AnyArray
ShapeLike: TypeAlias = tf.TensorShape | Iterable[ScalarTensorCompatible | None] | int | tf.Tensor
-DTypeLike: TypeAlias = DType | str | numpy.dtype[Any] | int
+DTypeLike: TypeAlias = DType | str | np.dtype[Any] | int
ContainerTensors: TypeAlias = ContainerGeneric[tf.Tensor]
ContainerTensorsLike: TypeAlias = ContainerGeneric[TensorLike]
diff --git a/python/helpers/typeshed/stubs/tensorflow/tensorflow/io/__init__.pyi b/python/helpers/typeshed/stubs/tensorflow/tensorflow/io/__init__.pyi
index 4f7a2f795d94..51f45b5fd315 100644
--- a/python/helpers/typeshed/stubs/tensorflow/tensorflow/io/__init__.pyi
+++ b/python/helpers/typeshed/stubs/tensorflow/tensorflow/io/__init__.pyi
@@ -48,19 +48,16 @@ class TFRecordWriter:
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
-# Also defaults are missing here because pytype crashes when a default is present reported
-# in this [issue](https://github.com/google/pytype/issues/1410#issue-1669793588). After
-# next release the defaults can be added back.
class FixedLenFeature(NamedTuple):
shape: ShapeLike
dtype: DTypeLike
- default_value: TensorCompatible | None = ...
+ default_value: TensorCompatible | None = None
class FixedLenSequenceFeature(NamedTuple):
shape: ShapeLike
dtype: DTypeLike
- allow_missing: bool = ...
- default_value: TensorCompatible | None = ...
+ allow_missing: bool = False
+ default_value: TensorCompatible | None = None
class VarLenFeature(NamedTuple):
dtype: DTypeLike
@@ -70,7 +67,7 @@ class SparseFeature(NamedTuple):
value_key: str
dtype: DTypeLike
size: int | list[int]
- already_sorted: bool = ...
+ already_sorted: bool = False
class RaggedFeature(NamedTuple):
# Mypy doesn't support nested NamedTuples, but at runtime they actually do use
@@ -94,12 +91,12 @@ class RaggedFeature(NamedTuple):
length: int
dtype: DTypeLike
- value_key: str | None = ...
+ value_key: str | None = None
partitions: tuple[ # type: ignore[name-defined]
RowSplits | RowLengths | RowStarts | RowLimits | ValueRowIds | UniformRowLength, ...
- ] = ...
+ ] = ()
row_splits_dtype: DTypeLike = ...
- validate: bool = ...
+ validate: bool = False
def parse_example(
serialized: TensorCompatible, features: _FeatureSpecs, example_names: Iterable[str] | None = None, name: str | None = None
diff --git a/python/helpers/typeshed/stubs/toposort/toposort.pyi b/python/helpers/typeshed/stubs/toposort/toposort.pyi
index 35ad36b6f955..964dfe28f629 100644
--- a/python/helpers/typeshed/stubs/toposort/toposort.pyi
+++ b/python/helpers/typeshed/stubs/toposort/toposort.pyi
@@ -1,11 +1,12 @@
from _typeshed import SupportsItems
from collections.abc import Iterable, Iterator
-from typing import Any, Protocol, TypeVar
+from typing import Any, Protocol, TypeVar, type_check_only
_KT_co = TypeVar("_KT_co", covariant=True)
_VT_co = TypeVar("_VT_co", covariant=True)
_T = TypeVar("_T")
+@type_check_only
class _SupportsItemsAndLen(SupportsItems[_KT_co, _VT_co], Protocol[_KT_co, _VT_co]):
def __len__(self) -> int: ...
diff --git a/python/helpers/typeshed/stubs/tqdm/tqdm/dask.pyi b/python/helpers/typeshed/stubs/tqdm/tqdm/dask.pyi
index 28dd1195ca80..4ee807b781ef 100644
--- a/python/helpers/typeshed/stubs/tqdm/tqdm/dask.pyi
+++ b/python/helpers/typeshed/stubs/tqdm/tqdm/dask.pyi
@@ -1,11 +1,12 @@
from _typeshed import Incomplete
from collections.abc import Callable
-from typing import ClassVar
+from typing import ClassVar, type_check_only
from typing_extensions import Self
__all__ = ["TqdmCallback"]
# dask.callbacks.Callback
+@type_check_only
class _Callback:
active: ClassVar[set[tuple[Callable[..., Incomplete] | None, ...]]]
def __init__(
diff --git a/python/helpers/typeshed/stubs/tqdm/tqdm/rich.pyi b/python/helpers/typeshed/stubs/tqdm/tqdm/rich.pyi
index 394fd1c5cb47..9af999b21a49 100644
--- a/python/helpers/typeshed/stubs/tqdm/tqdm/rich.pyi
+++ b/python/helpers/typeshed/stubs/tqdm/tqdm/rich.pyi
@@ -1,7 +1,7 @@
from _typeshed import Incomplete, SupportsWrite
from abc import ABC, abstractmethod
from collections.abc import Iterable, Mapping
-from typing import NoReturn, TypeVar, overload
+from typing import NoReturn, TypeVar, overload, type_check_only
from .std import tqdm as std_tqdm
@@ -10,6 +10,7 @@ __all__ = ["tqdm_rich", "trrange", "tqdm", "trange"]
_T = TypeVar("_T")
# Actually rich.progress.ProgressColumn
+@type_check_only
class _ProgressColumn(ABC):
max_refresh: float | None
def __init__(self, table_column: Incomplete | None = ...) -> None: ...
diff --git a/python/helpers/typeshed/stubs/tqdm/tqdm/utils.pyi b/python/helpers/typeshed/stubs/tqdm/tqdm/utils.pyi
index f18408e606dd..7633d2b2df45 100644
--- a/python/helpers/typeshed/stubs/tqdm/tqdm/utils.pyi
+++ b/python/helpers/typeshed/stubs/tqdm/tqdm/utils.pyi
@@ -1,7 +1,7 @@
from _typeshed import Incomplete
from collections.abc import Callable, Mapping
from re import Pattern
-from typing import Protocol, TypeVar
+from typing import Protocol, TypeVar, type_check_only
from typing_extensions import ParamSpec
CUR_OS: str
@@ -15,6 +15,7 @@ class FormatReplace:
def __init__(self, replace: str = "") -> None: ...
def __format__(self, _) -> str: ...
+@type_check_only
class _Has__Comparable(Protocol):
_comparable: Incomplete
diff --git a/python/helpers/typeshed/stubs/translationstring/translationstring/__init__.pyi b/python/helpers/typeshed/stubs/translationstring/translationstring/__init__.pyi
index 5b2f11cae811..51bf7f775717 100644
--- a/python/helpers/typeshed/stubs/translationstring/translationstring/__init__.pyi
+++ b/python/helpers/typeshed/stubs/translationstring/translationstring/__init__.pyi
@@ -1,8 +1,9 @@
from collections.abc import Callable
from gettext import NullTranslations
-from typing import Any, Protocol
+from typing import Any, Protocol, type_check_only
from typing_extensions import Self
+@type_check_only
class _TranslationStringFactory(Protocol):
def __call__(
self,
@@ -12,6 +13,7 @@ class _TranslationStringFactory(Protocol):
context: str | None = ...,
) -> TranslationString: ...
+@type_check_only
class _ChameleonTranslate(Protocol):
def __call__(
self,
@@ -22,9 +24,11 @@ class _ChameleonTranslate(Protocol):
default: str | None = ...,
) -> TranslationString: ...
+@type_check_only
class _TranslatorPolicy(Protocol):
def __call__(self, translations: NullTranslations, tstring: str, domain: str | None, context: str | None) -> str: ...
+@type_check_only
class _Translator(Protocol):
def __call__(
self,
@@ -34,11 +38,13 @@ class _Translator(Protocol):
context: str | None = None,
) -> str: ...
+@type_check_only
class _PluralizerPolicy(Protocol):
def __call__(
self, translations: NullTranslations, singular: str, plural: str, n: int, domain: str | None, context: str | None
) -> str: ...
+@type_check_only
class _Pluralizer(Protocol):
def __call__(
self,
@@ -51,6 +57,7 @@ class _Pluralizer(Protocol):
) -> str: ...
class TranslationString(str):
+ __slots__ = ("domain", "context", "default", "mapping")
domain: str | None
context: str | None
default: str
diff --git a/python/helpers/typeshed/stubs/uWSGI/METADATA.toml b/python/helpers/typeshed/stubs/uWSGI/METADATA.toml
index 9807d0b14a09..9324d956c585 100644
--- a/python/helpers/typeshed/stubs/uWSGI/METADATA.toml
+++ b/python/helpers/typeshed/stubs/uWSGI/METADATA.toml
@@ -12,4 +12,4 @@ extra_description = """\
# Run stubtest on MacOS as well, to check that the
# uWSGI-specific parts of stubtest_third_party.py
# also work there
-platforms = ["linux", "darwin"]
+ci_platforms = ["linux", "darwin"]
diff --git a/python/helpers/typeshed/stubs/uWSGI/uwsgi.pyi b/python/helpers/typeshed/stubs/uWSGI/uwsgi.pyi
index d42c32b30074..8d37a83ecf6b 100644
--- a/python/helpers/typeshed/stubs/uWSGI/uwsgi.pyi
+++ b/python/helpers/typeshed/stubs/uWSGI/uwsgi.pyi
@@ -2,13 +2,14 @@ from _typeshed import HasFileno, OptExcInfo, ReadOnlyBuffer
from _typeshed.wsgi import WSGIApplication
from collections.abc import Callable
from types import ModuleType
-from typing import Any, Literal, Protocol, final, overload
+from typing import Any, Literal, Protocol, final, overload, type_check_only
from typing_extensions import Self, TypeAlias
import uwsgidecorators
_TrueOrNone: TypeAlias = Literal[True] | None
+@type_check_only
class _RPCCallable(Protocol):
def __call__(self, *args: bytes) -> bytes | None: ...
diff --git a/python/helpers/typeshed/stubs/ujson/METADATA.toml b/python/helpers/typeshed/stubs/ujson/METADATA.toml
index b0b13fe94506..6f9cb91f0c74 100644
--- a/python/helpers/typeshed/stubs/ujson/METADATA.toml
+++ b/python/helpers/typeshed/stubs/ujson/METADATA.toml
@@ -1,2 +1,3 @@
version = "5.10.*"
upstream_repository = "https://github.com/ultrajson/ultrajson"
+obsolete_since = "5.11.0" # Released on 2025-08-20
diff --git a/python/helpers/typeshed/stubs/vobject/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/vobject/@tests/stubtest_allowlist.txt
index ff95be452de5..c794a11e3ecc 100644
--- a/python/helpers/typeshed/stubs/vobject/@tests/stubtest_allowlist.txt
+++ b/python/helpers/typeshed/stubs/vobject/@tests/stubtest_allowlist.txt
@@ -9,8 +9,6 @@ vobject.win32tz
# python2 compat
vobject.base.basestring
vobject.base.str_
-vobject.base.to_unicode
-vobject.base.to_basestring
vobject.base.unicode_type
# implementation details that users shouldn't depend on
diff --git a/python/helpers/typeshed/stubs/vobject/vobject/__init__.pyi b/python/helpers/typeshed/stubs/vobject/vobject/__init__.pyi
index f2c0c922b49b..bda5a171276a 100644
--- a/python/helpers/typeshed/stubs/vobject/vobject/__init__.pyi
+++ b/python/helpers/typeshed/stubs/vobject/vobject/__init__.pyi
@@ -1,6 +1,5 @@
-from .base import VERSION as VERSION, Component
-
-__version__ = VERSION
+from . import icalendar as icalendar, vcard as vcard
+from .base import VERSION as VERSION, Component, readComponents as readComponents, readOne as readOne
def iCalendar() -> Component: ...
def vCard() -> Component: ...
diff --git a/python/helpers/typeshed/stubs/vobject/vobject/base.pyi b/python/helpers/typeshed/stubs/vobject/vobject/base.pyi
index 931aabc870ce..5fbc52905c76 100644
--- a/python/helpers/typeshed/stubs/vobject/vobject/base.pyi
+++ b/python/helpers/typeshed/stubs/vobject/vobject/base.pyi
@@ -1,11 +1,18 @@
import logging
-from _typeshed import Incomplete, SupportsWrite
-from collections.abc import Iterable, Iterator
-from typing import Any, Final, Literal, TypeVar, overload
+import re
+from _typeshed import Incomplete, MaybeNone, SupportsWrite
+from collections.abc import Generator, Iterator
+from typing import Any, AnyStr, Final, Literal, TypeVar, overload
+from typing_extensions import Self
_V = TypeVar("_V", bound=VBase)
_W = TypeVar("_W", bound=SupportsWrite[bytes])
+VERSION: Final[str]
+
+def to_unicode(value: str | bytes | bytearray) -> str: ...
+def to_basestring(s: str | bytes) -> bytes: ...
+
logger: logging.Logger
DEBUG: bool
CR: str
@@ -15,8 +22,6 @@ SPACE: str
TAB: str
SPACEORTAB: str
-VERSION: Final[str]
-
class VBase:
group: Incomplete | None
behavior: Incomplete | None
@@ -41,44 +46,53 @@ class VBase:
@overload
def serialize(self, buf: _W, lineLength: int = 75, validate: bool = True, behavior=None, *args: Any, **kwargs: Any) -> _W: ...
-def toVName(name, stripNum: int = 0, upper: bool = False): ...
+def toVName(name: str, stripNum: int = 0, upper: bool = False) -> str: ...
class ContentLine(VBase):
- name: Incomplete
- encoded: Incomplete
- params: Incomplete
- singletonparams: Incomplete
- isNative: Incomplete
- lineNumber: Incomplete
- value: Incomplete
+ name: str
+ encoded: bool
+ params: dict[Incomplete, list[Incomplete]]
+ singletonparams: list[Incomplete]
+ isNative: bool
+ lineNumber: int | None
+ value: str
def __init__(
- self, name, params, value, group=None, encoded: bool = False, isNative: bool = False, lineNumber=None, *args, **kwds
+ self,
+ name: str,
+ params: dict[Incomplete, list[Incomplete]],
+ value: str,
+ group=None,
+ encoded: bool = False,
+ isNative: bool = False,
+ lineNumber: int | None = None,
+ *args,
+ **kwds,
) -> None: ...
@classmethod
- def duplicate(cls, copyit): ...
+ def duplicate(cls, copyit) -> Self: ...
def copy(self, copyit) -> None: ...
def __eq__(self, other): ...
def __getattr__(self, name: str): ...
def __setattr__(self, name: str, value) -> None: ...
def __delattr__(self, name: str) -> None: ...
- def valueRepr(self): ...
+ def valueRepr(self) -> str: ...
def __unicode__(self) -> str: ...
def prettyPrint(self, level: int = 0, tabwidth: int = 3) -> None: ...
class Component(VBase):
contents: dict[str, list[VBase]]
- name: Incomplete
+ name: str
useBegin: bool
- def __init__(self, name=None, *args, **kwds) -> None: ...
+ def __init__(self, name: str | None = None, *args, **kwds) -> None: ...
@classmethod
- def duplicate(cls, copyit): ...
+ def duplicate(cls, copyit) -> Self: ...
def copy(self, copyit) -> None: ...
- def setProfile(self, name) -> None: ...
+ def setProfile(self, name: str) -> None: ...
def __getattr__(self, name: str): ...
- normal_attributes: Incomplete
+ normal_attributes: list[str]
def __setattr__(self, name: str, value) -> None: ...
def __delattr__(self, name: str) -> None: ...
- def getChildValue(self, childName, default=None, childNumber: int = 0): ...
+ def getChildValue(self, childName: str, default=None, childNumber: int = 0): ...
@overload
def add(self, objOrName: _V, group: str | None = None) -> _V: ...
@overload
@@ -91,45 +105,47 @@ class Component(VBase):
def add(self, objOrName: str, group: str | None = None) -> Any: ... # returns VBase sub-class
def remove(self, obj) -> None: ...
def getChildren(self) -> list[Incomplete]: ...
- def components(self) -> Iterable[Component]: ...
- def lines(self): ...
- def sortChildKeys(self): ...
- def getSortedChildren(self): ...
+ def components(self) -> Generator[Component]: ...
+ def lines(self) -> Generator[ContentLine]: ...
+ def sortChildKeys(self) -> list[Incomplete]: ...
+ def getSortedChildren(self) -> list[Incomplete]: ...
def setBehaviorFromVersionLine(self, versionLine) -> None: ...
def transformChildrenToNative(self) -> None: ...
def transformChildrenFromNative(self, clearBehavior: bool = True) -> None: ...
def prettyPrint(self, level: int = 0, tabwidth: int = 3) -> None: ...
class VObjectError(Exception):
- msg: Incomplete
- lineNumber: Incomplete
- def __init__(self, msg, lineNumber=None) -> None: ...
+ msg: str
+ lineNumber: int
+ def __init__(self, msg: str, lineNumber: int | None = None) -> None: ...
class ParseError(VObjectError): ...
class ValidateError(VObjectError): ...
class NativeError(VObjectError): ...
-patterns: Incomplete
-param_values_re: Incomplete
-params_re: Incomplete
-line_re: Incomplete
-begin_re: Incomplete
+patterns: dict[str, str]
+param_values_re: re.Pattern[str]
+params_re: re.Pattern[str]
+line_re: re.Pattern[str]
+begin_re: re.Pattern[str]
-def parseParams(string): ...
-def parseLine(line, lineNumber=None): ...
+def parseParams(string: str) -> list[list[Any]]: ... # Any was taken from re module stubs
+def parseLine(
+ line: str, lineNumber: int | None = None
+) -> tuple[str, list[list[Any]], str | MaybeNone, str | MaybeNone]: ... # Any is result of parseParams()
-wrap_re: Incomplete
-logical_lines_re: Incomplete
+wrap_re: re.Pattern[str]
+logical_lines_re: re.Pattern[str]
testLines: str
-def getLogicalLines(fp, allowQP: bool = True) -> None: ...
-def textLineToContentLine(text, n=None): ...
-def dquoteEscape(param): ...
-def foldOneLine(outbuf, input, lineLength: int = 75) -> None: ...
-def defaultSerialize(obj, buf, lineLength): ...
+def getLogicalLines(fp, allowQP: bool = True) -> Generator[tuple[str, int]]: ...
+def textLineToContentLine(text, n: int | None = None) -> ContentLine: ...
+def dquoteEscape(param: str) -> str: ...
+def foldOneLine(outbuf: SupportsWrite[AnyStr], input: AnyStr, lineLength: int = 75) -> None: ...
+def defaultSerialize(obj: Component | ContentLine, buf, lineLength: int): ...
class Stack:
- stack: Incomplete
+ stack: list[Incomplete]
def __len__(self) -> int: ...
def top(self): ...
def topName(self): ...
@@ -141,7 +157,7 @@ def readComponents(
streamOrString, validate: bool = False, transform: bool = True, ignoreUnreadable: bool = False, allowQP: bool = False
) -> Iterator[Component]: ...
def readOne(stream, validate: bool = False, transform: bool = True, ignoreUnreadable: bool = False, allowQP: bool = False): ...
-def registerBehavior(behavior, name=None, default: bool = False, id=None) -> None: ...
-def getBehavior(name, id=None): ...
-def newFromBehavior(name, id=None): ...
-def backslashEscape(s): ...
+def registerBehavior(behavior, name: str | None = None, default: bool = False, id=None) -> None: ...
+def getBehavior(name: str, id=None): ...
+def newFromBehavior(name: str, id=None) -> Component | ContentLine: ...
+def backslashEscape(s: str) -> str: ...
diff --git a/python/helpers/typeshed/stubs/vobject/vobject/change_tz.pyi b/python/helpers/typeshed/stubs/vobject/vobject/change_tz.pyi
index af45ff738bd3..d9aa1f516094 100644
--- a/python/helpers/typeshed/stubs/vobject/vobject/change_tz.pyi
+++ b/python/helpers/typeshed/stubs/vobject/vobject/change_tz.pyi
@@ -1,10 +1,20 @@
+import datetime
+import optparse
from collections.abc import Sequence
+from typing import Final, Literal
-def change_tz(cal, new_timezone, default, utc_only: bool = False, utc_tz=...) -> None: ...
+from .base import Component
+
+version: Final[str]
+
+def change_tz(
+ cal: Component,
+ new_timezone: datetime._TzInfo | None,
+ default: datetime._TzInfo | None,
+ utc_only: bool = False,
+ utc_tz: datetime._TzInfo | None = ...,
+) -> None: ...
def show_timezones() -> None: ...
def convert_events(utc_only: bool, args: Sequence[str]) -> None: ...
def main() -> None: ...
-
-version: str
-
-def get_options(): ...
+def get_options() -> tuple[optparse.Values, Literal[False]] | tuple[optparse.Values, list[str]]: ...
diff --git a/python/helpers/typeshed/stubs/vobject/vobject/icalendar.pyi b/python/helpers/typeshed/stubs/vobject/vobject/icalendar.pyi
index 66d8c8b7cf3b..327b28e207bf 100644
--- a/python/helpers/typeshed/stubs/vobject/vobject/icalendar.pyi
+++ b/python/helpers/typeshed/stubs/vobject/vobject/icalendar.pyi
@@ -1,7 +1,8 @@
import datetime
from _typeshed import Incomplete
-from datetime import timedelta
-from typing import Any, Final
+from collections.abc import Iterable
+from datetime import timedelta, tzinfo
+from typing import Final, Literal, overload
from .base import Component
from .behavior import Behavior
@@ -15,11 +16,14 @@ FREQUENCIES: Final[tuple[str, ...]]
ZERO_DELTA: Final[timedelta]
twoHours: Final[timedelta]
+@overload
+def toUnicode(s: None) -> None: ...
+@overload
def toUnicode(s: str | bytes) -> str: ...
-def registerTzid(tzid, tzinfo) -> None: ...
-def getTzid(tzid, smart: bool = True): ...
+def registerTzid(tzid: str | bytes, tzinfo) -> None: ...
+def getTzid(tzid: str, smart: bool = True): ...
-utc: Any # dateutil.tz.tz.tzutc
+utc: tzinfo # dateutil.tz.tz.tzutc (subclass of tzinfo)
class TimezoneComponent(Component):
isNative: bool
@@ -29,16 +33,16 @@ class TimezoneComponent(Component):
useBegin: bool
def __init__(self, tzinfo=None, *args, **kwds) -> None: ...
@classmethod
- def registerTzinfo(cls, tzinfo): ...
+ def registerTzinfo(cls, tzinfo) -> str | None: ...
def gettzinfo(self): ...
tzid: Incomplete
daylight: Incomplete
standard: Incomplete
- def settzinfo(self, tzinfo, start: int = 2000, end: int = 2030): ...
+ def settzinfo(self, tzinfo, start: int = 2000, end: int = 2030) -> None: ...
normal_attributes: Incomplete
@staticmethod
- def pickTzid(tzinfo, allowUTC: bool = False): ...
- def prettyPrint(self, level, tabwidth) -> None: ... # type: ignore[override]
+ def pickTzid(tzinfo, allowUTC: bool = False) -> str | None: ...
+ def prettyPrint(self, level: int, tabwidth: int) -> None: ... # type: ignore[override]
class RecurringComponent(Component):
isNative: bool
@@ -203,26 +207,30 @@ class FreeBusy(PeriodBehavior):
class RRule(Behavior): ...
-utcDateTimeList: Incomplete
-dateTimeOrDateList: Incomplete
-textList: Incomplete
+utcDateTimeList: list[str]
+dateTimeOrDateList: list[str]
+textList: list[str]
-def numToDigits(num, places): ...
-def timedeltaToString(delta): ...
-def timeToString(dateOrDateTime): ...
-def dateToString(date): ...
-def dateTimeToString(dateTime, convertToUTC: bool = False): ...
-def deltaToOffset(delta): ...
+def numToDigits(num: float | None, places: int) -> str: ...
+def timedeltaToString(delta: datetime.timedelta) -> str: ...
+def timeToString(dateOrDateTime: datetime.date | datetime.datetime) -> str: ...
+def dateToString(date: datetime.date) -> str: ...
+def dateTimeToString(dateTime: datetime.datetime, convertToUTC: bool = False) -> str: ...
+def deltaToOffset(delta: datetime.timedelta) -> str: ...
def periodToString(period, convertToUTC: bool = False): ...
-def isDuration(s): ...
-def stringToDate(s): ...
-def stringToDateTime(s, tzinfo: datetime.tzinfo | None = None, strict: bool = False) -> datetime.datetime: ...
+def isDuration(s: str) -> bool: ...
+def stringToDate(s: str) -> datetime.date: ...
+def stringToDateTime(s: str, tzinfo: datetime._TzInfo | None = None, strict: bool = False) -> datetime.datetime: ...
escapableCharList: str
-def stringToTextValues(s, listSeparator: str = ",", charList=None, strict: bool = False): ...
-def stringToDurations(s, strict: bool = False): ...
+def stringToTextValues(
+ s: str, listSeparator: str = ",", charList: Iterable[str] | None = None, strict: bool = False
+) -> list[str]: ...
+def stringToDurations(s: str, strict: bool = False) -> list[datetime.timedelta]: ...
def parseDtstart(contentline, allowSignatureMismatch: bool = False): ...
-def stringToPeriod(s, tzinfo=None): ...
-def getTransition(transitionTo, year, tzinfo): ...
-def tzinfo_eq(tzinfo1, tzinfo2, startYear: int = 2000, endYear: int = 2020): ...
+def stringToPeriod(s: str, tzinfo=None): ...
+def getTransition(transitionTo: Literal["daylight", "standard"], year: int, tzinfo: datetime._TzInfo): ...
+def tzinfo_eq(
+ tzinfo1: datetime._TzInfo | None, tzinfo2: datetime._TzInfo | None, startYear: int = 2000, endYear: int = 2020
+) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/vobject/vobject/ics_diff.pyi b/python/helpers/typeshed/stubs/vobject/vobject/ics_diff.pyi
index d80341d95167..7f43415738d7 100644
--- a/python/helpers/typeshed/stubs/vobject/vobject/ics_diff.pyi
+++ b/python/helpers/typeshed/stubs/vobject/vobject/ics_diff.pyi
@@ -1,7 +1,13 @@
-def getSortKey(component): ...
-def sortByUID(components): ...
-def deleteExtraneous(component, ignore_dtstamp: bool = False) -> None: ...
+import optparse
+from collections.abc import Iterable
+from typing import Literal
+
+from .base import Component
+
+def getSortKey(component: Component) -> str: ...
+def sortByUID(components: Iterable[Component]) -> list[Component]: ...
+def deleteExtraneous(component: Component, ignore_dtstamp: bool = False) -> None: ...
def diff(left, right): ...
def prettyDiff(leftObj, rightObj) -> None: ...
def main() -> None: ...
-def getOptions(): ...
+def getOptions() -> tuple[Literal[False], Literal[False]] | tuple[optparse.Values, list[str]]: ...
diff --git a/python/helpers/typeshed/stubs/vobject/vobject/vcard.pyi b/python/helpers/typeshed/stubs/vobject/vobject/vcard.pyi
index f70f98b6160b..7707566f95ea 100644
--- a/python/helpers/typeshed/stubs/vobject/vobject/vcard.pyi
+++ b/python/helpers/typeshed/stubs/vobject/vobject/vcard.pyi
@@ -1,13 +1,14 @@
-from _typeshed import Incomplete
+from typing import AnyStr
+from .base import ContentLine
from .behavior import Behavior
class Name:
- family: Incomplete
- given: Incomplete
- additional: Incomplete
- prefix: Incomplete
- suffix: Incomplete
+ family: str | list[str]
+ given: str | list[str]
+ additional: str | list[str]
+ prefix: str | list[str]
+ suffix: str | list[str]
def __init__(
self,
family: str | list[str] = "",
@@ -17,17 +18,17 @@ class Name:
suffix: str | list[str] = "",
) -> None: ...
@staticmethod
- def toString(val): ...
- def __eq__(self, other): ...
+ def toString(val: str | list[str] | tuple[str, ...]) -> str: ...
+ def __eq__(self, other: object) -> bool: ...
class Address:
- box: Incomplete
- extended: Incomplete
- street: Incomplete
- city: Incomplete
- region: Incomplete
- code: Incomplete
- country: Incomplete
+ box: str | list[str]
+ extended: str | list[str]
+ street: str | list[str]
+ city: str | list[str]
+ region: str | list[str]
+ code: str | list[str]
+ country: str | list[str]
def __init__(
self,
street: str | list[str] = "",
@@ -39,29 +40,29 @@ class Address:
extended: str | list[str] = "",
) -> None: ...
@staticmethod
- def toString(val, join_char: str = "\n"): ...
- lines: Incomplete
- one_line: Incomplete
- def __eq__(self, other): ...
+ def toString(val: str | list[str] | tuple[str, ...], join_char: str = "\n") -> str: ...
+ lines: tuple[str, ...]
+ one_line: tuple[str, ...]
+ def __eq__(self, other: object) -> bool: ...
class VCardTextBehavior(Behavior):
allowGroup: bool
base64string: str
@classmethod
- def decode(cls, line) -> None: ...
+ def decode(cls, line: ContentLine) -> None: ...
@classmethod
- def encode(cls, line) -> None: ...
+ def encode(cls, line: ContentLine) -> None: ...
class VCardBehavior(Behavior):
allowGroup: bool
- defaultBehavior: Incomplete
+ defaultBehavior: type[VCardTextBehavior]
class VCard3_0(VCardBehavior):
name: str
description: str
versionString: str
isComponent: bool
- sortFirst: Incomplete
+ sortFirst: tuple[str, ...]
@classmethod
def generateImplicitParameters(cls, obj) -> None: ...
@@ -82,17 +83,17 @@ class Photo(VCardTextBehavior):
name: str
description: str
@classmethod
- def valueRepr(cls, line): ...
+ def valueRepr(cls, line: ContentLine) -> str: ...
@classmethod
def serialize(cls, obj, buf, lineLength, validate, *args, **kwargs) -> None: ... # type: ignore[override]
-def toListOrString(string): ...
-def splitFields(string): ...
-def toList(stringOrList): ...
+def toListOrString(string: str) -> str | list[str]: ...
+def splitFields(string: str) -> list[str | list[str]]: ...
+def toList(stringOrList: AnyStr | list[AnyStr]) -> list[AnyStr]: ...
def serializeFields(obj, order=None): ...
-NAME_ORDER: Incomplete
-ADDRESS_ORDER: Incomplete
+NAME_ORDER: tuple[str, ...]
+ADDRESS_ORDER: tuple[str, ...]
class NameBehavior(VCardBehavior):
hasNative: bool
diff --git a/python/helpers/typeshed/stubs/vobject/vobject/win32tz.pyi b/python/helpers/typeshed/stubs/vobject/vobject/win32tz.pyi
index 1cf86d5f13c1..8b47f8be0479 100644
--- a/python/helpers/typeshed/stubs/vobject/vobject/win32tz.pyi
+++ b/python/helpers/typeshed/stubs/vobject/vobject/win32tz.pyi
@@ -1,23 +1,27 @@
import datetime
import sys
+import winreg
from _typeshed import Incomplete
+from typing import Any, SupportsIndex
if sys.platform == "win32":
- handle: Incomplete
- tzparent: Incomplete
- parentsize: Incomplete
- localkey: Incomplete
- WEEKS: Incomplete
- def list_timezones(): ...
+ handle: winreg.HKEYType
+ tzparent: winreg.HKEYType
+ parentsize: int
+ localkey: winreg.HKEYType
+ WEEKS: datetime.timedelta
+ def list_timezones() -> list[str]: ...
class win32tz(datetime.tzinfo):
- data: Incomplete
- def __init__(self, name) -> None: ...
- def utcoffset(self, dt): ...
- def dst(self, dt): ...
- def tzname(self, dt): ...
+ data: win32tz_data
+ def __init__(self, name: str | None) -> None: ...
+ def utcoffset(self, dt: datetime.datetime) -> datetime.timedelta: ... # type: ignore[override]
+ def dst(self, dt: datetime.datetime) -> datetime.timedelta: ... # type: ignore[override]
+ def tzname(self, dt: datetime.datetime) -> str | None: ... # type: ignore[override]
- def pickNthWeekday(year, month, dayofweek, hour, minute, whichweek): ...
+ def pickNthWeekday(
+ year: SupportsIndex, month: SupportsIndex, dayofweek: int, hour: SupportsIndex, minute: SupportsIndex, whichweek: int
+ ) -> datetime.datetime | None: ...
class win32tz_data:
display: Incomplete
@@ -35,6 +39,6 @@ if sys.platform == "win32":
dstweeknumber: Incomplete
dsthour: Incomplete
dstminute: Incomplete
- def __init__(self, path) -> None: ...
+ def __init__(self, path: str | None) -> None: ...
- def valuesToDict(key): ...
+ def valuesToDict(key: winreg._KeyType) -> dict[str, Any]: ...
diff --git a/python/helpers/typeshed/stubs/waitress/METADATA.toml b/python/helpers/typeshed/stubs/waitress/METADATA.toml
index b6fe76b59efb..9423798e9ae4 100644
--- a/python/helpers/typeshed/stubs/waitress/METADATA.toml
+++ b/python/helpers/typeshed/stubs/waitress/METADATA.toml
@@ -3,4 +3,4 @@ upstream_repository = "https://github.com/Pylons/waitress"
[tool.stubtest]
# linux and darwin are equivalent
-platforms = ["linux", "win32"]
+ci_platforms = ["linux", "win32"]
diff --git a/python/helpers/typeshed/stubs/watchpoints/watchpoints/watch.pyi b/python/helpers/typeshed/stubs/watchpoints/watchpoints/watch.pyi
index 320bc4afdbac..a10b9c456beb 100644
--- a/python/helpers/typeshed/stubs/watchpoints/watchpoints/watch.pyi
+++ b/python/helpers/typeshed/stubs/watchpoints/watchpoints/watch.pyi
@@ -3,7 +3,7 @@ from _typeshed import SupportsWrite, TraceFunction
from collections.abc import Callable
from pdb import Pdb
from types import FrameType
-from typing import Any, Literal, Protocol, TypeVar
+from typing import Any, Literal, Protocol, TypeVar, type_check_only
from typing_extensions import TypeAlias
from .watch_element import WatchElement
@@ -51,7 +51,7 @@ class Watch:
self,
*,
callback: Callable[[FrameType, WatchElement, tuple[str, str, int | None]], None] = ...,
- pdb: Literal[True] = ...,
+ pdb: Literal[True] = True,
file: str | SupportsWrite[str] = ...,
stack_limit: int | None = 5,
custom_printer: Callable[[Any], None] = ..., # User-defined printing callback
@@ -64,5 +64,6 @@ class Watch:
def uninstall(self, func: _Identifier = "watch") -> None: ...
def unwatch(self, *args: object) -> None: ...
+@type_check_only
class _TraceFunc(Protocol):
def __call__(self, frame: FrameType, event: str, arg: object) -> _TraceFunc: ...
diff --git a/python/helpers/typeshed/stubs/watchpoints/watchpoints/watch_print.pyi b/python/helpers/typeshed/stubs/watchpoints/watchpoints/watch_print.pyi
index 715d914daf07..9fedf7a6fb44 100644
--- a/python/helpers/typeshed/stubs/watchpoints/watchpoints/watch_print.pyi
+++ b/python/helpers/typeshed/stubs/watchpoints/watchpoints/watch_print.pyi
@@ -16,8 +16,8 @@ class WatchPrint:
def __init__(
self,
file: str | SupportsWrite[str] | None = ...,
- stack_limit: int | None = ...,
- custom_printer: Callable[[Any], None] | None = ..., # User-defined printing callback
+ stack_limit: int | None = None,
+ custom_printer: Callable[[Any], None] | None = None, # User-defined printing callback
) -> None: ...
def __call__(self, frame: FrameType, elem: WatchElement, exec_info: tuple[str, str, int | None]) -> None: ...
def getsourceline(self, exec_info: tuple[str, str, int | None]) -> str: ...
diff --git a/python/helpers/typeshed/stubs/wurlitzer/wurlitzer.pyi b/python/helpers/typeshed/stubs/wurlitzer/wurlitzer.pyi
index 6e68f5f45291..848c6383f04c 100644
--- a/python/helpers/typeshed/stubs/wurlitzer/wurlitzer.pyi
+++ b/python/helpers/typeshed/stubs/wurlitzer/wurlitzer.pyi
@@ -5,8 +5,9 @@ import io
import logging
from _typeshed import SupportsWrite
from contextlib import _GeneratorContextManager
+from threading import Thread
from types import TracebackType
-from typing import Any, Final, Literal, Protocol, TextIO, TypeVar, overload
+from typing import Any, Final, Literal, Protocol, TextIO, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias
STDOUT: Final = 2
@@ -17,6 +18,7 @@ _T_contra = TypeVar("_T_contra", contravariant=True)
_StreamOutT = TypeVar("_StreamOutT", bound=_Stream[str] | _Stream[bytes])
_StreamErrT = TypeVar("_StreamErrT", bound=_Stream[str] | _Stream[bytes])
+@type_check_only
class _Stream(SupportsWrite[_T_contra], Protocol):
def seek(self, offset: int, whence: int = ..., /) -> int: ...
@@ -29,6 +31,10 @@ _InteractiveShell: TypeAlias = Any
class Wurlitzer:
flush_interval: float
encoding: str | None
+ thread: Thread | None
+ handle: tuple[
+ _LogPipe | SupportsWrite[str] | SupportsWrite[bytes] | None, _LogPipe | SupportsWrite[str] | SupportsWrite[bytes] | None
+ ]
def __init__(
self,
@@ -37,7 +43,11 @@ class Wurlitzer:
encoding: str | None = ...,
bufsize: int | None = ...,
) -> None: ...
- def __enter__(self): ...
+ def __enter__(
+ self,
+ ) -> tuple[
+ _LogPipe | SupportsWrite[str] | SupportsWrite[bytes] | None, _LogPipe | SupportsWrite[str] | SupportsWrite[bytes] | None
+ ]: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
) -> None: ...
diff --git a/python/helpers/typeshed/stubs/xlrd/xlrd/sheet.pyi b/python/helpers/typeshed/stubs/xlrd/xlrd/sheet.pyi
index 9d6193654642..8a42beaaccc1 100644
--- a/python/helpers/typeshed/stubs/xlrd/xlrd/sheet.pyi
+++ b/python/helpers/typeshed/stubs/xlrd/xlrd/sheet.pyi
@@ -42,6 +42,7 @@ cellty_from_fmtty: Final[dict[int, int]]
ctype_text: Final[dict[int, str]]
class Cell(BaseObject):
+ __slots__ = ["ctype", "value", "xf_index"]
ctype: int
value: str
xf_index: int | None
@@ -58,6 +59,18 @@ class Colinfo(BaseObject):
collapsed: int
class Rowinfo(BaseObject):
+ __slots__ = (
+ "height",
+ "has_default_height",
+ "outline_level",
+ "outline_group_starts_ends",
+ "hidden",
+ "height_mismatch",
+ "has_default_xf_index",
+ "xf_index",
+ "additional_space_above",
+ "additional_space_below",
+ )
height: int | None
has_default_height: int | None
outline_level: int | None
diff --git a/python/helpers/typeshed/stubs/yt-dlp/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/yt-dlp/@tests/stubtest_allowlist.txt
new file mode 100644
index 000000000000..eec37a338479
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/@tests/stubtest_allowlist.txt
@@ -0,0 +1,28 @@
+# Extractors will not be stubbed at this time.
+yt_dlp.extractor.*
+# Postprocessors will not be stubbed at this time.
+yt_dlp.postprocessor.*
+# Won't be covered.
+yt_dlp.__main__
+yt_dlp.__pyinstaller.*
+yt_dlp.compat.(shutil|types|urllib).*
+yt_dlp.dependencies.*
+yt_dlp.jsinterp.Debugger.sys
+yt_dlp.networking.impersonate.ImpersonateTarget._DT
+yt_dlp.utils.xattr
+# Deprecated
+yt_dlp.YoutubeDL.(YoutubeDL.)?parse_outtmpl
+yt_dlp.downloader.(common.)?FileDownloader.parse_bytes
+yt_dlp.networking.(common.)?Response.(code|info|get(code|url|header))
+yt_dlp.utils._legacy.decode_png
+# ``except IndexError`` is sufficient.
+yt_dlp.utils.(_utils.)?(PlaylistEntries|(Lazy|Paged)List).IndexError
+# Reports 'not a function'.
+yt_dlp.networking.(common.)?(HEAD|PATCH|PUT)Request
+# This is partially typed.
+yt_dlp.utils.(_utils.)?is_iterable_like
+# Generated with functools.partial.
+yt_dlp.utils.(_utils.)?prepend_extension
+yt_dlp.utils.(_utils.)?replace_extension
+# Unsure why this is here.
+yt_dlp.utils.jslib.devalue.TYPE_CHECKING
diff --git a/python/helpers/typeshed/stubs/yt-dlp/METADATA.toml b/python/helpers/typeshed/stubs/yt-dlp/METADATA.toml
new file mode 100644
index 000000000000..15f950ac7ddf
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/METADATA.toml
@@ -0,0 +1,3 @@
+version = "2025.8.20"
+upstream_repository = "https://github.com/yt-dlp/yt-dlp"
+requires = ["websockets"]
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/YoutubeDL.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/YoutubeDL.pyi
new file mode 100644
index 000000000000..5f00db4b5c3f
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/YoutubeDL.pyi
@@ -0,0 +1,126 @@
+import types
+from collections.abc import Callable, Collection, Iterable, Iterator, Mapping
+from functools import cached_property
+from types import TracebackType
+from typing import Any
+from typing_extensions import Self, TypeAlias
+from urllib.request import Request
+
+from yt_dlp.cache import Cache
+from yt_dlp.cookies import YoutubeDLCookieJar
+from yt_dlp.networking import RequestDirector, RequestHandler, Response
+from yt_dlp.utils import Namespace
+
+from . import _Params
+from .extractor.common import InfoExtractor, _InfoDict
+from .postprocessor.common import PostProcessor
+from .utils._utils import _ProgressState
+
+_FormatSelector: TypeAlias = Callable[[Mapping[str, Any]], Iterator[Any]]
+
+class YoutubeDL:
+ params: _Params
+ cache: Cache
+ format_selector: _FormatSelector
+ archive: set[str]
+ def __init__(self, params: _Params | None = None, auto_init: bool = True) -> None: ...
+ def warn_if_short_id(self, argv: list[str]) -> None: ...
+ def add_info_extractor(self, ie: InfoExtractor) -> None: ...
+ def get_info_extractor(self, ie_key: str) -> InfoExtractor: ...
+ def add_default_info_extractors(self) -> None: ...
+ def add_post_processor(self, pp: PostProcessor, when: str = "post_process") -> None: ...
+ def add_post_hook(self, ph: Callable[..., object]) -> None: ...
+ def add_close_hook(self, ch: Callable[..., object]) -> None: ...
+ def add_progress_hook(self, ph: Callable[..., object]) -> None: ...
+ def add_postprocessor_hook(self, ph: Callable[..., object]) -> None: ...
+ def to_stdout(self, message: str, skip_eol: bool = False, quiet: bool | None = None) -> None: ...
+ def to_screen(self, message: str, skip_eol: bool = False, quiet: bool | None = None, only_once: bool = False) -> None: ...
+ def to_stderr(self, message: str, only_once: bool = False) -> None: ...
+ def to_console_title(
+ self, message: str | None = None, progress_state: _ProgressState | None = None, percent: int | None = None
+ ) -> None: ...
+ def save_console_title(self) -> None: ...
+ def restore_console_title(self) -> None: ...
+ def __enter__(self) -> Self: ...
+ def save_cookies(self) -> None: ...
+ def __exit__(self, *args: object) -> None: ...
+ def close(self) -> None: ...
+ def trouble(self, message: str | None = None, tb: TracebackType | None = None, is_error: bool = True) -> None: ...
+ Styles: Namespace
+ def report_warning(self, message: str, only_once: bool = False) -> None: ...
+ def deprecation_warning(self, message: str, *, stacklevel: int = 0) -> None: ...
+ def deprecated_feature(self, message: str) -> None: ...
+ def report_error(self, message: str, tb: types.TracebackType | None = None, is_error: bool = True) -> None: ...
+ def write_debug(self, message: str, only_once: bool = False) -> None: ...
+ def report_file_already_downloaded(self, file_name: str) -> None: ...
+ def report_file_delete(self, file_name: str) -> None: ...
+ def raise_no_formats(self, info: str, forced: bool = False, *, msg: str | None = None) -> None: ...
+ def get_output_path(self, dir_type: str = "", filename: str | None = None) -> str: ...
+ @staticmethod
+ def escape_outtmpl(outtmpl: str) -> str: ...
+ @classmethod
+ def validate_outtmpl(cls, outtmpl: str) -> ValueError | None: ...
+ def prepare_outtmpl(self, outtmpl: str, info_dict: _InfoDict, sanitize: bool = False) -> tuple[str, dict[str, Any]]: ...
+ def evaluate_outtmpl(self, outtmpl: str, info_dict: _InfoDict, sanitize: bool = False) -> str: ...
+ def prepare_filename(
+ self, info_dict: _InfoDict, dir_type: str = "", *, outtmpl: str | None = None, warn: bool = False
+ ) -> str: ...
+ @staticmethod
+ def add_extra_info(info_dict: _InfoDict, extra_info: Mapping[str, Any]) -> None: ...
+ def extract_info(
+ self,
+ url: str,
+ download: bool = True,
+ ie_key: str | None = None,
+ extra_info: Any | None = None,
+ process: bool = True,
+ force_generic_extractor: bool = False,
+ ) -> _InfoDict: ...
+ def add_default_extra_info(self, ie_result: _InfoDict, ie: InfoExtractor, url: str) -> None: ...
+ def process_ie_result(
+ self, ie_result: _InfoDict, download: bool = True, extra_info: Mapping[str, Any] | None = None
+ ) -> _InfoDict: ...
+ def build_format_selector(self, format_spec: str) -> _FormatSelector: ...
+ def sort_formats(self, info_dict: _InfoDict) -> None: ...
+ def process_video_result(self, info_dict: _InfoDict, download: bool = True) -> _InfoDict: ...
+ def process_subtitles(
+ self, video_id: str, normal_subtitles: Mapping[str, Any], automatic_captions: Mapping[str, Any]
+ ) -> dict[str, Any] | None: ...
+ def dl(self, name: str, info: _InfoDict, subtitle: bool = False, test: bool = False) -> bool: ...
+ def existing_file(self, filepaths: Iterable[str], *, default_overwrite: bool = True) -> str | None: ...
+ def process_info(self, info_dict: _InfoDict) -> None: ...
+ def download(self, url_list: Collection[str]) -> None: ...
+ def download_with_info_file(self, info_filename: str) -> int: ...
+ @staticmethod
+ def sanitize_info(info_dict: _InfoDict, remove_private_keys: bool = False) -> _InfoDict | None: ...
+ @staticmethod
+ def filter_requested_info(info_dict: _InfoDict, actually_filter: bool = True) -> _InfoDict | None: ...
+ @staticmethod
+ def post_extract(info_dict: _InfoDict) -> None: ...
+ def run_pp(self, pp: PostProcessor, infodict: _InfoDict) -> _InfoDict: ...
+ def run_all_pps(self, key: str, info: _InfoDict, *, additional_pps: Collection[PostProcessor] | None = None) -> _InfoDict: ...
+ def pre_process(
+ self, ie_info: _InfoDict, key: str = "pre_process", files_to_move: Mapping[str, Any] | None = None
+ ) -> tuple[_InfoDict, list[str] | None]: ...
+ def post_process(self, filename: str, info: _InfoDict, files_to_move: Mapping[str, Any] | None = None) -> _InfoDict: ...
+ def in_download_archive(self, info_dict: _InfoDict) -> bool: ...
+ def record_download_archive(self, info_dict: _InfoDict) -> None: ...
+ @staticmethod
+ def format_resolution(format: Mapping[str, Any], default: str = "unknown") -> str: ...
+ def render_formats_table(self, info_dict: _InfoDict) -> str | None: ...
+ def render_thumbnails_table(self, info_dict: _InfoDict) -> str | None: ...
+ def render_subtitles_table(self, video_id: str, subtitles: Iterable[Mapping[str, Any]]) -> str | None: ...
+ def list_formats(self, info_dict: _InfoDict) -> None: ...
+ def list_thumbnails(self, info_dict: _InfoDict) -> None: ...
+ def list_subtitles(self, video_id: str, subtitles: Iterable[Mapping[str, Any]], name: str = "subtitles") -> None: ...
+ def print_debug_header(self) -> None: ...
+ @cached_property
+ def proxies(self) -> dict[str, Any]: ...
+ @cached_property
+ def cookiejar(self) -> YoutubeDLCookieJar: ...
+ def urlopen(self, req: Request | str) -> Response: ...
+ def build_request_director(
+ self, handlers: Collection[RequestHandler], preferences: Collection[Any] | None = None
+ ) -> RequestDirector: ...
+ def encode(self, s: str) -> bytes: ...
+ def get_encoding(self) -> str: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/__init__.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/__init__.pyi
new file mode 100644
index 000000000000..f94cac72ab47
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/__init__.pyi
@@ -0,0 +1,256 @@
+import optparse
+from collections.abc import Callable, Collection, Iterator, Mapping
+from typing import Any, Literal, NamedTuple, Protocol, TypedDict, type_check_only
+from typing_extensions import NotRequired
+
+from .extractor import gen_extractors, list_extractors
+from .networking.impersonate import ImpersonateTarget
+from .YoutubeDL import YoutubeDL
+
+__all__ = ["YoutubeDL", "gen_extractors", "list_extractors", "main", "parse_options"]
+
+@type_check_only
+class _LoggerProtocol(Protocol): # noqa: Y046
+ def __init__(self, ydl: YoutubeDL | None = None) -> None: ...
+ def debug(self, message: str) -> None: ...
+ def info(self, message: str) -> None: ...
+ def warning(self, message: str, *, once: bool = ..., only_once: bool = ...) -> None: ...
+ def error(self, message: str) -> None: ...
+ def stdout(self, message: str) -> None: ...
+ def stderr(self, message: str) -> None: ...
+
+@type_check_only
+class _RetrySleepFunctions(TypedDict, total=False):
+ default: Callable[[int], int]
+ file_access: Callable[[int], int]
+ fragment: Callable[[int], int]
+
+@type_check_only
+class _ProgressTemplateValue(TypedDict, total=False): # noqa: Y049
+ info: str
+ progress: str
+
+@type_check_only
+class _ExternalDownloader(TypedDict, total=False):
+ dash: str
+ default: str
+ ftp: str
+ http: str
+ m3u8: str
+ mms: str
+ rtmp: str
+ rtsp: str
+
+@type_check_only
+class _DownloadRange(TypedDict):
+ end_time: int
+ index: NotRequired[int]
+ start_time: int
+ title: NotRequired[str]
+
+@type_check_only
+class _Color(TypedDict, total=False):
+ stderr: Literal["always", "auto", "no_color", "never"]
+ stdout: Literal["always", "auto", "no_color", "never"]
+
+_ProgressTemplate = TypedDict(
+ "_ProgressTemplate",
+ {
+ "download": _ProgressTemplateValue,
+ "download-title": _ProgressTemplateValue,
+ "postprocess": _ProgressTemplateValue,
+ "postprocess-title": _ProgressTemplateValue,
+ },
+)
+
+@type_check_only
+class _Params(TypedDict, total=False):
+ usenetrc: bool | None
+ netrc_location: str | None
+ netrc_cmd: str | None
+ username: str | None
+ password: str | None
+ twofactor: str | None
+ videopassword: str | None
+ ap_mso: str | None
+ ap_username: str | None
+ ap_password: str | None
+ client_certificate: str | None
+ client_certificate_key: str | None
+ client_certificate_password: str | None
+ quiet: bool | None
+ no_warnings: bool | None
+ forceurl: bool | None
+ forcetitle: str | None
+ forceid: bool | None
+ forcethumbnail: bool | None
+ forcedescription: bool | None
+ forceduration: str | None
+ forcefilename: bool | None
+ forceprint: Mapping[str, Collection[str]] | Collection[str] | None
+ print_to_file: Mapping[str, tuple[str, str]] | None
+ forcejson: bool | None
+ dump_single_json: bool | None
+ force_write_download_archive: str | None
+ simulate: str | None
+ skip_download: str | None
+ format: str | Callable[[Mapping[str, Any]], Mapping[str, Any]] | None
+ allow_unplayable_formats: bool | None
+ ignore_no_formats_error: bool | None
+ format_sort: Collection[str] | None
+ format_sort_force: str | None
+ allow_multiple_video_streams: bool | None
+ allow_multiple_audio_streams: bool | None
+ check_formats: bool | Literal["selected"] | None
+ listformats: bool | None
+ outtmpl: str | Mapping[str, str] | None
+ outtmpl_na_placeholder: str | None
+ paths: str | None
+ restrictfilenames: bool | None
+ windowsfilenames: bool | None
+ ignoreerrors: bool | Literal["only_download"] | None
+ force_generic_extractor: bool | None
+ allowed_extractors: Collection[str] | None
+ ratelimit: int | None
+ throttledratelimit: int | None
+ overwrites: bool | None
+ retries: int | None
+ file_access_retries: int | None
+ fragment_retries: int | None
+ extractor_retries: int | None
+ retry_sleep_functions: _RetrySleepFunctions | None
+ skip_unavailable_fragments: bool | None
+ keep_fragments: bool | None
+ concurrent_fragment_downloads: int | None
+ buffersize: int | None
+ noresizebuffer: bool | None
+ http_chunk_size: int | None
+ continuedl: bool | None
+ noprogress: bool | None
+ progress_with_newline: bool | None
+ progress_template: _ProgressTemplate | None
+ playliststart: int | None
+ playlistend: int | None
+ playlistreverse: bool | None
+ playlistrandom: bool | None
+ lazy_playlist: bool | None
+ noplaylist: bool | None
+ logtostderr: bool | None
+ consoletitle: str | None
+ nopart: bool | None
+ updatetime: bool | None
+ writedescription: bool | None
+ writeannotations: bool | None
+ writeinfojson: bool | None
+ allow_playlist_files: bool | None
+ clean_infojson: bool | None
+ getcomments: bool | None
+ writethumbnail: bool | None
+ write_all_thumbnails: bool | None
+ writelink: bool | None
+ writeurllink: bool | None
+ writewebloclink: bool | None
+ writedesktoplink: bool | None
+ writesubtitles: bool | None
+ writeautomaticsub: bool | None
+ allsubtitles: bool | None
+ listsubtitles: bool | None
+ subtitlesformat: str | None
+ subtitleslangs: Collection[str] | None
+ matchtitle: bool | None
+ rejecttitle: bool | None
+ prefer_free_formats: bool | None
+ trim_file_name: int | None
+ verbose: bool | None
+ test: bool | None
+ keepvideo: str | None
+ min_filesize: int | None
+ max_filesize: int | None
+ min_views: str | None
+ max_views: str | None
+ daterange: str | None
+ cachedir: str | None
+ age_limit: str | None
+ download_archive: str | None
+ break_on_existing: str | None
+ break_on_reject: bool | None
+ break_per_url: bool | None
+ skip_playlist_after_errors: bool | None
+ cookiefile: str | None
+ cookiesfrombrowser: tuple[str, ...] | None
+ legacyserverconnect: bool | None
+ nocheckcertificate: bool | None
+ prefer_insecure: str | None
+ enable_file_urls: str | None
+ http_headers: Mapping[str, str] | None
+ proxy: str | None
+ socket_timeout: int | None
+ bidi_workaround: bool | None
+ debug_printtraffic: bool | None
+ prefer_ffmpeg: bool | None
+ include_ads: bool | None
+ default_search: str | None
+ dynamic_mpd: bool | None
+ extractor_args: Mapping[str, Mapping[str, Any]] | None
+ youtube_include_dash_manifest: bool | None
+ youtube_include_hls_manifest: bool | None
+ encoding: str | None
+ extract_flat: bool | Literal["in_playlist", "discard", "discard_in_playlist"] | None
+ live_from_start: bool | None
+ warn_when_outdated: bool | None
+ wait_for_video: tuple[int, int] | None
+ mark_watched: bool | None
+ merge_output_format: str | None
+ final_ext: str | None
+ postprocessors: Collection[Mapping[str, Any]]
+ fixup: Literal["never", "warn", "detect_or_warn"] | None
+ source_address: str | None
+ call_home: bool | None
+ sleep_interval_requests: int | None
+ sleep_interval: int | None
+ max_sleep_interval: int | None
+ sleep_interval_subtitles: int | None
+ external_downloader: _ExternalDownloader | None
+ download_ranges: Callable[[Any, YoutubeDL], Iterator[_DownloadRange]] | None
+ force_keyframes_at_cuts: bool | None
+ list_thumbnails: str | None
+ playlist_items: Collection[int] | None
+ xattr_set_filesize: bool | None
+ match_filter: NotRequired[Callable[[Mapping[str, Any], bool], str | None] | Callable[[Mapping[str, Any]], str | None] | None]
+ color: _Color | None
+ ffmpeg_location: str | None
+ hls_prefer_native: bool | None
+ hls_use_mpegts: bool | None
+ hls_split_discontinuity: bool | None
+ max_downloads: int | None
+ dump_intermediate_pages: bool | None
+ listformats_table: bool | None
+ write_pages: bool | None
+ external_downloader_args: Literal["default"] | Mapping[str, Collection[str]] | Collection[str] | None
+ postprocessor_args: Mapping[str, Collection[str]] | Collection[str] | None
+ geo_verification_proxy: str | None
+ geo_bypass: bool | None
+ geo_bypass_country: str | None
+ geo_bypass_ip_block: str | None
+ compat_opts: dict[str, Any] | None
+ logger: _LoggerProtocol
+ # Undocumented fields below.
+ _deprecation_warnings: Collection[str] | None
+ _warnings: Collection[str] | None
+ autonumber_size: int | None
+ autonumber_start: int | None
+ cn_verification_proxy: str | None
+ load_pages: bool | None
+ youtube_print_sig_code: bool | None
+ progress_hooks: list[Callable[[Mapping[str, Any]], object]]
+ impersonate: ImpersonateTarget
+
+@type_check_only
+class _ParsedOptions(NamedTuple):
+ parser: optparse.OptionParser
+ options: optparse.Values
+ urls: Collection[str]
+ ydl_opts: _Params
+
+def parse_options(argv: Collection[str] | None = None) -> _ParsedOptions: ...
+def main(argv: list[str] | None = None) -> int: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/aes.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/aes.pyi
new file mode 100644
index 000000000000..299a0604fd27
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/aes.pyi
@@ -0,0 +1,42 @@
+from _typeshed import ReadableBuffer
+from typing import Literal
+
+__all__ = [
+ "aes_cbc_decrypt",
+ "aes_cbc_decrypt_bytes",
+ "aes_cbc_encrypt",
+ "aes_cbc_encrypt_bytes",
+ "aes_ctr_decrypt",
+ "aes_ctr_encrypt",
+ "aes_decrypt",
+ "aes_decrypt_text",
+ "aes_ecb_decrypt",
+ "aes_ecb_encrypt",
+ "aes_encrypt",
+ "aes_gcm_decrypt_and_verify",
+ "aes_gcm_decrypt_and_verify_bytes",
+ "key_expansion",
+ "pad_block",
+ "pkcs7_padding",
+ "unpad_pkcs7",
+]
+
+def aes_cbc_decrypt_bytes(data: bytes, key: bytes, iv: bytes) -> bytes: ...
+def aes_gcm_decrypt_and_verify_bytes(data: bytes, key: bytes, tag: bytes, nonce: bytes) -> bytes: ...
+def aes_cbc_encrypt_bytes(
+ data: bytes, key: bytes, iv: bytes, *, padding_mode: Literal["pkcs7", "iso7816", "whitespace", "zero"]
+) -> bytes: ...
+def unpad_pkcs7(data: list[int]) -> list[int]: ...
+def pkcs7_padding(data: list[int]) -> list[int]: ...
+def pad_block(block: list[int], padding_mode: Literal["pkcs7", "iso7816", "whitespace", "zero"]) -> list[int]: ...
+def aes_ecb_encrypt(data: list[int], key: list[int], iv: list[int] | None = None) -> list[int]: ...
+def aes_ecb_decrypt(data: list[int], key: list[int], iv: list[int] | None = None) -> list[int]: ...
+def aes_ctr_decrypt(data: list[int], key: list[int], iv: list[int]) -> list[int]: ...
+def aes_ctr_encrypt(data: list[int], key: list[int], iv: list[int]) -> list[int]: ...
+def aes_cbc_decrypt(data: list[int], key: list[int], iv: list[int]) -> list[int]: ...
+def aes_cbc_encrypt(data: list[int], key: list[int], iv: list[int], *, padding_mode: str = "pkcs7") -> list[int]: ...
+def aes_gcm_decrypt_and_verify(data: list[int], key: list[int], tag: list[int], nonce: list[int]) -> list[int]: ...
+def aes_encrypt(data: list[int], expanded_key: list[int]) -> list[int]: ...
+def aes_decrypt(data: list[int], expanded_key: list[int]) -> list[int]: ...
+def aes_decrypt_text(data: str | ReadableBuffer, password: str, key_size_bytes: int) -> str: ...
+def key_expansion(data: list[int]) -> list[int]: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/cache.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/cache.pyi
new file mode 100644
index 000000000000..ca24d93fddcf
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/cache.pyi
@@ -0,0 +1,21 @@
+from typing import Any, Literal
+
+from .YoutubeDL import YoutubeDL
+
+class Cache:
+ def __init__(self, ydl: YoutubeDL) -> None: ...
+ @property
+ def enabled(self) -> bool: ...
+ def store(
+ self, section: str, key: str, data: Any, dtype: Literal["json"] = "json" # data is anything JSON serializable.
+ ) -> None: ...
+ def load(
+ self,
+ section: str,
+ key: str,
+ dtype: Literal["json"] = "json",
+ default: Any = None, # Returned if not enabled or if the cache entry is not found.
+ *,
+ min_ver: str | None = None,
+ ) -> Any: ... # Anything JSON serializable.
+ def remove(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/compat/__init__.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/compat/__init__.pyi
new file mode 100644
index 000000000000..cfa7f4a18eb6
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/compat/__init__.pyi
@@ -0,0 +1,12 @@
+import urllib
+import urllib.request
+import xml.etree.ElementTree as etree
+
+from yt_dlp.networking import Request
+
+class compat_HTMLParseError(ValueError): ...
+
+def compat_etree_fromstring(text: str) -> etree.Element[str]: ...
+def compat_ord(c: str) -> int: ...
+def compat_expanduser(path: str) -> str: ...
+def urllib_req_to_req(urllib_request: urllib.request.Request) -> Request: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/compat/compat_utils.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/compat/compat_utils.pyi
new file mode 100644
index 000000000000..0ca913da582d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/compat/compat_utils.pyi
@@ -0,0 +1,21 @@
+import types
+from collections.abc import Callable, Collection
+from typing import Any, NamedTuple
+
+class _Package(NamedTuple):
+ name: str
+ version: str
+
+def get_package_info(module: types.ModuleType) -> _Package: ...
+
+class EnhancedModule(types.ModuleType):
+ def __bool__(self) -> bool: ...
+ def __getattribute__(self, attr: str) -> Any: ...
+
+def passthrough_module(
+ parent: types.ModuleType,
+ child: str | types.ModuleType,
+ allowed_attributes: Collection[str] = ...,
+ *,
+ callback: Callable[[str], object] = ...,
+) -> types.ModuleType: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/compat/imghdr.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/compat/imghdr.pyi
new file mode 100644
index 000000000000..703b7e450dc1
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/compat/imghdr.pyi
@@ -0,0 +1,3 @@
+from _typeshed import FileDescriptorOrPath
+
+def what(file: FileDescriptorOrPath | None = None, h: bytes | None = None) -> str | None: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/cookies.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/cookies.pyi
new file mode 100644
index 000000000000..927b5173970a
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/cookies.pyi
@@ -0,0 +1,104 @@
+from collections.abc import Collection, Iterator, KeysView
+from enum import Enum
+from http.cookiejar import Cookie, CookiePolicy, MozillaCookieJar
+from http.cookies import SimpleCookie
+from typing import TextIO, TypeVar
+
+from . import _LoggerProtocol
+from .minicurses import MultilinePrinter
+from .utils._utils import YoutubeDLError
+from .YoutubeDL import YoutubeDL
+
+CHROMIUM_BASED_BROWSERS: set[str] = ...
+SUPPORTED_BROWSERS: set[str] = ...
+
+class _LinuxKeyring(Enum):
+ BASICTEXT = 5
+ GNOMEKEYRING = 4
+ KWALLET = 1
+ KWALLET5 = 2
+ KWALLET6 = 3
+
+SUPPORTED_KEYRINGS: KeysView[str]
+
+class YDLLogger(_LoggerProtocol):
+ def warning(self, message: str, only_once: bool = False) -> None: ... # type: ignore[override]
+
+ class ProgressBar(MultilinePrinter):
+ def print(self, message: str) -> None: ...
+
+ def progress_bar(self) -> ProgressBar: ...
+
+class CookieLoadError(YoutubeDLError): ...
+
+class YoutubeDLCookieJar(MozillaCookieJar):
+ def __init__(self, filename: str | None = None, delayload: bool = False, policy: CookiePolicy | None = None) -> None: ...
+ def open(self, file: str, *, write: bool = False) -> Iterator[TextIO]: ...
+ def get_cookie_header(self, url: str) -> str: ...
+ def get_cookies_for_url(self, url: str) -> list[Cookie]: ...
+ def load(self, filename: str | None = None, ignore_discard: bool = True, ignore_expires: bool = True) -> None: ...
+ def save(self, filename: str | None = None, ignore_discard: bool = True, ignore_expires: bool = True) -> None: ...
+
+def load_cookies(cookie_file: str, browser_specification: str | None, ydl: YoutubeDL) -> YoutubeDLCookieJar: ...
+def extract_cookies_from_browser(
+ browser_name: str,
+ profile: str | None = None,
+ logger: _LoggerProtocol = ...,
+ *,
+ keyring: _LinuxKeyring | None = None,
+ container: str | None = None,
+) -> YoutubeDLCookieJar: ...
+
+_T = TypeVar("_T", bound=MozillaCookieJar)
+
+def parse_safari_cookies(data: bytes, jar: _T | None = None, logger: _LoggerProtocol = ...) -> _T: ...
+
+class ChromeCookieDecryptor:
+ def decrypt(self, encrypted_value: bytes) -> str: ...
+
+class LinuxChromeCookieDecryptor(ChromeCookieDecryptor):
+ def __init__(
+ self,
+ browser_keyring_name: str,
+ logger: _LoggerProtocol,
+ *,
+ keyring: _LinuxKeyring | None = None,
+ meta_version: int | None = None,
+ ) -> None: ...
+ @staticmethod
+ def derive_key(password: bytes) -> bytes: ...
+
+class MacChromeCookieDecryptor(ChromeCookieDecryptor):
+ def __init__(self, browser_keyring_name: str, logger: YDLLogger, meta_version: int | None = None) -> None: ...
+ @staticmethod
+ def derive_key(password: bytes) -> bytes: ...
+
+class WindowsChromeCookieDecryptor(ChromeCookieDecryptor):
+ def __init__(self, browser_root: str, logger: YDLLogger, meta_version: int | None = None) -> None: ...
+
+def get_cookie_decryptor(
+ browser_root: str,
+ browser_keyring_name: str,
+ logger: _LoggerProtocol,
+ *,
+ keyring: _LinuxKeyring | None = None,
+ meta_version: int | None = None,
+) -> ChromeCookieDecryptor: ...
+
+class ParserError(Exception): ...
+
+class DataParser:
+ def __init__(self, data: bytes, logger: YDLLogger) -> None: ...
+ def read_bytes(self, num_bytes: int) -> bytes: ...
+ def expect_bytes(self, expected_value: bytes, message: str) -> None: ...
+ def read_uint(self, big_endian: bool = False) -> int: ...
+ def read_double(self, big_endian: bool = False) -> float: ...
+ def read_cstring(self) -> bytes: ...
+ def skip(self, num_bytes: int, description: str = "unknown") -> None: ...
+ def skip_to(self, offset: int, description: str = "unknown") -> None: ...
+ def skip_to_end(self, description: str = "unknown") -> None: ...
+
+def pbkdf2_sha1(password: bytes, salt: bytes, iterations: int, key_length: int) -> bytes: ...
+
+class LenientSimpleCookie(SimpleCookie):
+ def load(self, data: str | Collection[str]) -> None: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/__init__.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/__init__.pyi
new file mode 100644
index 000000000000..98ad67c2b7d5
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/__init__.pyi
@@ -0,0 +1,31 @@
+from collections.abc import Mapping
+from typing import Any, Literal
+from typing_extensions import TypeAlias
+
+from ..extractor.common import _InfoDict
+from ..utils._utils import NO_DEFAULT
+from .common import FileDownloader
+
+__all__ = ["FileDownloader", "get_suitable_downloader", "shorten_protocol_name"]
+
+_Protocol: TypeAlias = Literal[
+ "dash_frag_urls",
+ "ftps",
+ "http_dash_segments",
+ "http_dash_segments_generator",
+ "https",
+ "m3u8",
+ "m3u8_frag_urls",
+ "m3u8_native",
+ "rtmp_ffmpeg",
+ "websocket_frag",
+]
+
+def get_suitable_downloader(
+ info_dict: _InfoDict,
+ params: Mapping[str, Any] = {},
+ default: FileDownloader | type[NO_DEFAULT] = ...,
+ protocol: _Protocol | None = None,
+ to_stdout: bool = False,
+) -> FileDownloader: ...
+def shorten_protocol_name(proto: _Protocol, simplify: bool = False) -> str: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/bunnycdn.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/bunnycdn.pyi
new file mode 100644
index 000000000000..086c8646065c
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/bunnycdn.pyi
@@ -0,0 +1,17 @@
+import threading
+from collections.abc import Mapping
+
+from ..extractor.common import _InfoDict
+from ..utils.networking import HTTPHeaderDict
+from .common import FileDownloader
+
+class BunnyCdnFD(FileDownloader):
+ def real_download(self, filename: str, info_dict: _InfoDict) -> bool | None: ...
+ def ping_thread(
+ self,
+ stop_event: threading.Event,
+ url: str,
+ headers: HTTPHeaderDict | Mapping[str, str] | None,
+ secret: str,
+ context_id: str,
+ ) -> None: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/common.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/common.pyi
new file mode 100644
index 000000000000..e70d9ed12160
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/common.pyi
@@ -0,0 +1,88 @@
+from _typeshed import OpenBinaryMode, OpenTextMode
+from collections.abc import Callable, Mapping
+from typing import IO, Any, AnyStr, TypedDict, type_check_only
+
+from ..extractor.common import _InfoDict
+from ..utils._utils import NO_DEFAULT, Namespace
+from ..YoutubeDL import YoutubeDL
+
+@type_check_only
+class _FileDownloaderParams(TypedDict):
+ buffersize: int
+ continuedl: bool
+ external_downloader_args: dict[str, list[str]] | list[str] | None
+ file_access_retries: int
+ hls_use_mpegts: bool
+ http_chunk_size: int | None
+ max_filesize: int | None
+ min_filesize: int | None
+ nopart: bool
+ noprogress: bool
+ noresizebuffer: bool
+ progress_delta: float | None
+ progress_template: dict[str, str]
+ quiet: bool
+ ratelimit: int | None
+ retries: int
+ retry_sleep_functions: dict[str, Callable[..., object]]
+ test: bool
+ throttledratelimit: int | None
+ updatetime: bool
+ verbose: bool
+ xattr_set_filesize: bool
+
+class FileDownloader:
+ params: _FileDownloaderParams | None
+ def __init__(self, ydl: YoutubeDL, params: _FileDownloaderParams) -> None: ...
+ def to_screen(self, message: str, skip_eol: bool = False, quiet: bool | None = None, only_once: bool = False) -> None: ...
+ @property
+ def FD_NAME(cls) -> str: ...
+ @staticmethod
+ def format_seconds(seconds: int | None) -> str: ...
+ @classmethod
+ def format_eta(cls, seconds: int | None) -> str: ...
+ @staticmethod
+ def calc_percent(byte_counter: float, data_len: float | None) -> float: ...
+ @staticmethod
+ def format_percent(percent: float | None) -> str: ...
+ @classmethod
+ def calc_eta(
+ cls,
+ start_or_rate: int | None,
+ now_or_remaining: float | None,
+ total: int | type[NO_DEFAULT] = ...,
+ current: int | type[NO_DEFAULT] = ...,
+ ) -> float | int | None: ...
+ @staticmethod
+ def calc_speed(start: float, now: float, bytes: int) -> float | None: ...
+ @staticmethod
+ def format_speed(speed: int | None) -> str: ...
+ @staticmethod
+ def format_retries(retries: int) -> float | int: ...
+ @staticmethod
+ def filesize_or_none(unencoded_filename: AnyStr) -> int | None: ...
+ @staticmethod
+ def best_block_size(elapsed_time: float, bytes: int) -> int: ...
+ def slow_down(self, start_time: float, now: float, byte_counter: int) -> None: ...
+ def temp_name(self, filename: str) -> str: ...
+ def undo_temp_name(self, filename: str) -> str: ...
+ def ytdl_filename(self, filename: str) -> str: ...
+ # Wrapper that can accept arbitrary function.
+ def wrap_file_access(action: str, *, fatal: bool = False) -> Any: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
+ def sanitize_open(self, filename: str, open_mode: OpenTextMode | OpenBinaryMode) -> tuple[IO[Any], str]: ...
+ def try_remove(self, filename: str) -> None: ...
+ def try_rename(self, old_filename: str, new_filename: str) -> None: ...
+ def try_utime(self, filename: str, last_modified_hdr: str | None) -> int | None: ...
+ def report_destination(self, filename: str) -> None: ...
+ ProgressStyles: Namespace
+ def report_progress(self, s: Mapping[str, Any]) -> None: ...
+ def report_resuming_byte(self, resume_len: int) -> None: ...
+ def report_retry(
+ self, err: str, count: int, retries: int, frag_index: int | type[NO_DEFAULT] = ..., fatal: bool = True
+ ) -> None: ...
+ def report_unable_to_resume(self) -> None: ...
+ @staticmethod
+ def supports_manifest(manifest: str) -> bool: ...
+ def download(self, filename: str, info_dict: _InfoDict, subtitle: bool = False) -> bool: ...
+ def real_download(self, filename: str, info_dict: _InfoDict) -> bool | None: ...
+ def add_progress_hook(self, ph: Callable[[str], object]) -> None: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/dash.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/dash.pyi
new file mode 100644
index 000000000000..d5870c348919
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/dash.pyi
@@ -0,0 +1,8 @@
+from typing import Literal
+
+from ..extractor.common import _InfoDict
+from .fragment import FragmentFD
+
+class DashSegmentsFD(FragmentFD):
+ FD_NAME: Literal["dashsegments"]
+ def real_download(self, filename: str, info_dict: _InfoDict) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/external.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/external.pyi
new file mode 100644
index 000000000000..d181a0065903
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/external.pyi
@@ -0,0 +1,62 @@
+import enum
+import functools
+from _typeshed import Unused
+from collections.abc import Iterable, Mapping
+from typing import Any, Literal
+
+from ..extractor.common import _InfoDict
+from .fragment import FragmentFD
+
+class Features(enum.Enum):
+ TO_STDOUT = 1
+ MULTIPLE_FORMATS = 2
+
+class ExternalFD(FragmentFD):
+ SUPPORTED_PROTOCOLS: tuple[str, ...]
+ SUPPORTED_FEATURES: tuple[Features, ...]
+ @classmethod
+ def get_basename(cls) -> str: ...
+ @property
+ def EXE_NAME(cls) -> str: ...
+ @functools.cached_property
+ def exe(self) -> str: ...
+ @classmethod
+ def available(cls, path: str | None = None) -> str | Literal[False]: ...
+ @classmethod
+ def supports(cls, info_dict: _InfoDict) -> bool: ...
+ @classmethod
+ def can_download(cls, info_dict: _InfoDict, path: str | None = None) -> bool: ...
+
+class CurlFD(ExternalFD):
+ AVAILABLE_OPT: str
+
+class AxelFD(ExternalFD):
+ AVAILABLE_OPT: str
+
+class WgetFD(ExternalFD):
+ AVAILABLE_OPT: str
+
+class Aria2cFD(ExternalFD):
+ AVAILABLE_OPT: str
+ SUPPORTED_PROTOCOLS: tuple[str, ...]
+ @staticmethod
+ def supports_manifest(manifest: str) -> bool: ...
+ def aria2c_rpc(self, rpc_port: int, rpc_secret: str, method: str, params: Iterable[str] = ()) -> Any: ...
+
+class HttpieFD(ExternalFD):
+ AVAILABLE_OPT: str
+ EXE_NAME: str
+
+class FFmpegFD(ExternalFD):
+ SUPPORTED_PROTOCOLS: tuple[str, ...]
+ SUPPORTED_FEATURES: tuple[Features, ...]
+ @classmethod
+ def available(cls, path: str | None = None) -> bool: ... # type: ignore[override]
+ def on_process_started(self, proc: Unused, stdin: Unused) -> None: ...
+ @classmethod
+ def can_merge_formats(cls, info_dict: _InfoDict, params: Mapping[str, Any]) -> bool: ...
+
+class AVconvFD(FFmpegFD): ...
+
+def list_external_downloaders() -> list[str]: ...
+def get_external_downloader(external_downloader: str) -> type[ExternalFD]: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/f4m.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/f4m.pyi
new file mode 100644
index 000000000000..edc815a470d1
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/f4m.pyi
@@ -0,0 +1,32 @@
+import io
+from _typeshed import SupportsWrite
+from collections.abc import Iterable, Mapping
+from typing import Any
+from xml.etree.ElementTree import Element
+
+from .fragment import FragmentFD
+
+class DataTruncatedError(Exception): ...
+
+class FlvReader(io.BytesIO):
+ def read_bytes(self, n: int) -> bytes: ...
+ def read_unsigned_long_long(self) -> int: ...
+ def read_unsigned_int(self) -> int: ...
+ def read_unsigned_char(self) -> str: ...
+ def read_string(self) -> bytes: ...
+ def read_box_info(self) -> tuple[int, bytes, bytes]: ...
+ def read_asrt(self) -> dict[str, Any]: ...
+ def read_afrt(self) -> dict[str, Any]: ...
+ def read_abst(self) -> dict[str, Any]: ...
+ def read_bootstrap_info(self) -> dict[str, Any]: ...
+
+def read_bootstrap_info(bootstrap_bytes: bytes) -> dict[str, Any]: ...
+def build_fragments_list(boot_info: Mapping[str, Any]) -> list[tuple[Any, int]]: ...
+def write_unsigned_int(stream: SupportsWrite[bytes], val: int) -> None: ...
+def write_unsigned_int_24(stream: SupportsWrite[bytes], val: int) -> None: ...
+def write_flv_header(stream: SupportsWrite[bytes]) -> None: ...
+def write_metadata_tag(stream: SupportsWrite[bytes], metadata: bytes) -> None: ...
+def remove_encrypted_media(media: Iterable[Element]) -> list[Any]: ...
+def get_base_url(manifest: str) -> str | None: ...
+
+class F4mFD(FragmentFD): ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/fc2.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/fc2.pyi
new file mode 100644
index 000000000000..714890013741
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/fc2.pyi
@@ -0,0 +1,3 @@
+from .common import FileDownloader
+
+class FC2LiveFD(FileDownloader): ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/fragment.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/fragment.pyi
new file mode 100644
index 000000000000..7c3e4e6347ab
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/fragment.pyi
@@ -0,0 +1,37 @@
+from collections.abc import Callable, Collection, Mapping, Sequence
+from concurrent.futures.thread import ThreadPoolExecutor
+from typing import Any
+
+from ..extractor.common import _InfoDict
+from .common import FileDownloader
+from .http import HttpFD
+
+class HttpQuietDownloader(HttpFD):
+ def to_screen(self, *args: Any, **kargs: Any) -> None: ... # This method is a no-op.
+ to_console_title = to_screen
+
+class FragmentFD(FileDownloader):
+ def report_retry_fragment(self, err: str, frag_index: int, count: int, retries: int) -> None: ...
+ def report_skip_fragment(self, frag_index: int, err: str | None = None) -> None: ...
+ def decrypter(self, info_dict: _InfoDict) -> Callable[[Mapping[str, Any], bytes], bytes]: ...
+ def download_and_append_fragments_multiple(
+ self,
+ *args: tuple[Mapping[str, Any], Collection[Mapping[str, Any]], _InfoDict],
+ is_fatal: Callable[[int], bool] = ...,
+ pack_func: Callable[[str, int], bytes] = ...,
+ finish_func: Callable[[], Any] | None = None,
+ tpe: ThreadPoolExecutor | None = None,
+ interrupt_trigger: Sequence[bool] = (True,),
+ ) -> bool: ...
+ def download_and_append_fragments(
+ self,
+ ctx: Mapping[str, Any],
+ fragments: Collection[Mapping[str, Any]],
+ info_dict: _InfoDict,
+ *,
+ is_fatal: Callable[[int], bool] = ...,
+ pack_func: Callable[[str, int], bytes] = ...,
+ finish_func: Callable[[], object] | None = None,
+ tpe: ThreadPoolExecutor | None = None,
+ interrupt_trigger: Sequence[bool] = (True,),
+ ) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/hls.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/hls.pyi
new file mode 100644
index 000000000000..7382bfd510ec
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/hls.pyi
@@ -0,0 +1,7 @@
+from ..extractor.common import _InfoDict
+from .fragment import FragmentFD
+
+class HlsFD(FragmentFD):
+ FD_NAME: str
+ @classmethod
+ def can_download(cls, manifest: str, info_dict: _InfoDict, allow_unplayable_formats: bool = False) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/http.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/http.pyi
new file mode 100644
index 000000000000..7447e07f208f
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/http.pyi
@@ -0,0 +1,3 @@
+from .common import FileDownloader
+
+class HttpFD(FileDownloader): ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/ism.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/ism.pyi
new file mode 100644
index 000000000000..f439b30d4efd
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/ism.pyi
@@ -0,0 +1,29 @@
+import struct
+from _typeshed import SupportsWrite
+from collections.abc import Collection, Mapping
+from typing import Any
+
+from .fragment import FragmentFD
+
+u8: struct.Struct
+u88: struct.Struct
+u16: struct.Struct
+u1616: struct.Struct
+u32: struct.Struct
+u64: struct.Struct
+s88: struct.Struct
+s16: struct.Struct
+s1616: struct.Struct
+s32: struct.Struct
+unity_matrix: bytes
+TRACK_ENABLED: int
+TRACK_IN_MOVIE: int
+TRACK_IN_PREVIEW: int
+SELF_CONTAINED: int
+
+def box(box_type: bytes, payload: bytes) -> bytes: ...
+def full_box(box_type: bytes, version: int, flags: int, payload: bytes) -> bytes: ...
+def write_piff_header(stream: SupportsWrite[bytes], params: Mapping[str, Any]) -> None: ...
+def extract_box_data(data: bytes, box_sequence: Collection[bytes]) -> bytes | None: ...
+
+class IsmFD(FragmentFD): ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/mhtml.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/mhtml.pyi
new file mode 100644
index 000000000000..0651d95a3a63
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/mhtml.pyi
@@ -0,0 +1,3 @@
+from .fragment import FragmentFD
+
+class MhtmlFD(FragmentFD): ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/niconico.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/niconico.pyi
new file mode 100644
index 000000000000..2aceb6d1d735
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/niconico.pyi
@@ -0,0 +1,3 @@
+from .common import FileDownloader
+
+class NiconicoLiveFD(FileDownloader): ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/rtmp.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/rtmp.pyi
new file mode 100644
index 000000000000..3c7c4ced4efe
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/rtmp.pyi
@@ -0,0 +1,5 @@
+from .common import FileDownloader
+
+def rtmpdump_version() -> str: ...
+
+class RtmpFD(FileDownloader): ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/rtsp.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/rtsp.pyi
new file mode 100644
index 000000000000..313d7c09fcd6
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/rtsp.pyi
@@ -0,0 +1,5 @@
+from ..extractor.common import _InfoDict
+from .common import FileDownloader
+
+class RtspFD(FileDownloader):
+ def real_download(self, filename: str, info_dict: _InfoDict) -> bool: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/websocket.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/websocket.pyi
new file mode 100644
index 000000000000..1b0780b24805
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/websocket.pyi
@@ -0,0 +1,11 @@
+from _typeshed import SupportsWrite
+
+from ..extractor.common import _InfoDict
+from .common import FileDownloader
+
+class FFmpegSinkFD(FileDownloader):
+ def real_download(self, filename: str, info_dict: _InfoDict) -> bool: ...
+ async def real_connection(self, sink: SupportsWrite[bytes], info_dict: _InfoDict) -> None: ...
+
+class WebSocketFragmentFD(FFmpegSinkFD):
+ async def real_connection(self, sink: SupportsWrite[bytes], info_dict: _InfoDict) -> None: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/youtube_live_chat.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/youtube_live_chat.pyi
new file mode 100644
index 000000000000..d579c67224bf
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/downloader/youtube_live_chat.pyi
@@ -0,0 +1,9 @@
+from typing import Any
+
+from ..extractor.common import _InfoDict
+from .fragment import FragmentFD
+
+class YoutubeLiveChatFD(FragmentFD):
+ def real_download(self, filename: str, info_dict: _InfoDict) -> bool: ...
+ @staticmethod
+ def parse_live_timestamp(action: dict[str, Any]) -> int | None: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/extractor/__init__.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/extractor/__init__.pyi
new file mode 100644
index 000000000000..2e610f6cb134
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/extractor/__init__.pyi
@@ -0,0 +1,8 @@
+from .common import InfoExtractor
+
+def gen_extractor_classes() -> list[type[InfoExtractor]]: ...
+def gen_extractors() -> list[InfoExtractor]: ...
+def list_extractor_classes(age_limit: int | None = None) -> list[type[InfoExtractor]]: ...
+def list_extractors(age_limit: int | None = None) -> list[InfoExtractor]: ...
+def get_info_extractor(ie_name: str) -> InfoExtractor: ...
+def import_extractors() -> None: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/extractor/common.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/extractor/common.pyi
new file mode 100644
index 000000000000..5cd06e6d0d20
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/extractor/common.pyi
@@ -0,0 +1,868 @@
+import re
+from _typeshed import Unused
+from collections.abc import Callable, Collection, Iterable, Iterator, Mapping, Sequence
+from functools import cached_property
+from json.decoder import JSONDecoder
+from typing import Any, Literal, TypedDict, TypeVar, type_check_only
+from typing_extensions import Required, TypeAlias
+from urllib.request import Request, _DataType
+from xml.etree import ElementTree as ET
+
+from ..cache import Cache
+from ..cookies import LenientSimpleCookie, YoutubeDLCookieJar
+from ..networking.common import Response, _RequestData
+from ..networking.impersonate import ImpersonateTarget
+from ..utils._utils import NO_DEFAULT, RetryManager as _RetryManager
+from ..YoutubeDL import YoutubeDL
+
+@type_check_only
+class _InfoDict(TypedDict, total=False):
+ age_limit: int
+ availability: Literal["private", "premium_only", "subscriber_only", "needs_auth", "unlisted", "public"] | None
+ available_at: int
+ creator: str | None
+ comment_count: int | None
+ duration: int | None
+ formats: list[dict[str, Any]] | None
+ id: Required[str]
+ like_count: int | None
+ tags: list[str] | None
+ thumbnail: str | None
+ timestamp: int | float | None
+ title: str | None
+ uploader: str | None
+ url: str | None
+
+_StrNoDefaultOrNone: TypeAlias = str | None | type[NO_DEFAULT]
+_T = TypeVar("_T")
+
+class InfoExtractor:
+ IE_DESC: str | bool
+ SEARCH_KEY: str
+ def _login_hint(self, method: _StrNoDefaultOrNone, netrc: str | None = None) -> dict[str, str]: ...
+ def __init__(self, downloader: YoutubeDL | None = None) -> None: ...
+ @classmethod
+ def _match_valid_url(cls, url: str) -> re.Match[str] | None: ...
+ @classmethod
+ def suitable(cls, url: str) -> re.Match[str] | None: ...
+ @classmethod
+ def get_temp_id(cls, url: str) -> str | None: ...
+ @classmethod
+ def working(cls) -> bool: ...
+ @classmethod
+ def supports_login(cls) -> bool: ...
+ def initialize(self) -> None: ...
+ def extract(self, url: str) -> Iterator[_InfoDict]: ...
+ def set_downloader(self, downloader: YoutubeDL) -> None: ...
+ @property
+ def cache(self) -> Cache: ...
+ @property
+ def cookiejar(self) -> YoutubeDLCookieJar: ...
+ def _initialize_pre_login(self) -> None: ...
+ def _perform_login(self, username: str, password: str) -> None: ...
+ def _real_initialize(self) -> None: ...
+ @classmethod
+ def ie_key(cls) -> str: ...
+ @property
+ def IE_NAME(cls) -> str: ...
+ def _create_request(
+ self,
+ url_or_request: str | Request,
+ data: _DataType | None = None,
+ headers: Mapping[str, str] | None = None,
+ query: str | Mapping[str, str] | None = None,
+ extensions: Mapping[str, Any] | None = None,
+ ) -> Request: ...
+ def _download_webpage_handle(
+ self,
+ url_or_request: str | Request,
+ video_id: str,
+ note: str | None = None,
+ errnote: str | None = None,
+ fatal: bool = True,
+ encoding: str | None = None,
+ data: _DataType | None = None,
+ headers: Mapping[str, str] | None = None,
+ query: str | Mapping[str, str] | None = None,
+ expected_status: int | None = None,
+ impersonate: ImpersonateTarget | str | bool | Collection[str | ImpersonateTarget] | None = None,
+ require_impersonation: bool = False,
+ ) -> tuple[str, Response] | Literal[False]: ...
+ @staticmethod
+ def _guess_encoding_from_content(content_type: str, webpage_bytes: bytes) -> str: ...
+ def _webpage_read_content(
+ self,
+ urlh: Response,
+ url_or_request: str | Request,
+ video_id: str,
+ note: str | None = None,
+ errnote: str | None = None,
+ fatal: bool = True,
+ prefix: str | None = None,
+ encoding: str | None = None,
+ data: _RequestData | None = None,
+ ) -> str | Literal[False]: ...
+ def _parse_json(
+ self,
+ json_string: str,
+ video_id: str,
+ transform_source: Callable[..., str] | None = None,
+ fatal: bool = True,
+ errnote: str | None = None,
+ *,
+ cls: type[JSONDecoder] | None = None,
+ object_hook: Callable[[dict[Any, Any]], Any] | None = None,
+ parse_float: Callable[[str], Any] | None = None,
+ parse_int: Callable[[str], Any] | None = None,
+ parse_constant: Callable[[str], Any] | None = None,
+ object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None,
+ ) -> Any: ...
+ def _parse_socket_response_as_json(
+ self,
+ data: str,
+ video_id: str,
+ cls: type[JSONDecoder] | None = None,
+ object_hook: Callable[[dict[Any, Any]], Any] | None = None,
+ parse_float: Callable[[str], Any] | None = None,
+ parse_int: Callable[[str], Any] | None = None,
+ parse_constant: Callable[[str], Any] | None = None,
+ object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None,
+ ) -> Any: ...
+ def report_warning(self, msg: str, video_id: str | None = None, only_once: bool = False) -> None: ...
+ def to_screen(
+ self, msg: str, message: str, skip_eol: bool = False, quiet: bool | None = None, only_once: bool = False
+ ) -> None: ...
+ def write_debug(self, msg: str, only_once: bool = False) -> None: ...
+ # *args and **kwargs are passed to .params.get() where params is normally a mapping but is not required to be.
+ def get_param(self, name: str, default: Any = None, *args: Any, **kwargs: Any) -> Any: ...
+ def report_drm(self, video_id: str) -> None: ...
+ def report_extraction(self, id_or_name: str) -> None: ...
+ def report_download_webpage(self, video_id: str) -> None: ...
+ def report_age_confirmation(self) -> None: ...
+ def report_login(self) -> None: ...
+ def raise_login_required(
+ self,
+ msg: str = "This video is only available for registered users",
+ metadata_available: bool = False,
+ method: str | type[NO_DEFAULT] = ...,
+ ) -> None: ...
+ def raise_geo_restricted(
+ self, msg: str = ..., countries: Collection[str] | None = None, metadata_available: bool = False
+ ) -> None: ...
+ def raise_no_formats(self, msg: str, expected: bool = False, video_id: str | None = None) -> None: ...
+ @staticmethod
+ def url_result(
+ url: str,
+ ie: InfoExtractor | None = None,
+ video_id: str | None = None,
+ video_title: str | None = None,
+ *,
+ url_transparent: bool = False,
+ **kwargs: Any, # Added to the dict return value.
+ ) -> dict[str, Any]: ...
+ @classmethod
+ def playlist_from_matches(
+ cls,
+ matches: Sequence[str],
+ playlist_id: str | None = None,
+ playlist_title: str | None = None,
+ getter: Callable[..., Any] = ...,
+ ie: InfoExtractor | None = None,
+ video_kwargs: Mapping[str, Any] | None = None,
+ multi_video: bool = False,
+ **kwargs: Any, # Added to the dict return value.
+ ) -> dict[str, Any]: ...
+ @staticmethod
+ def playlist_result(
+ entries: Iterable[_InfoDict],
+ playlist_id: str | None = None,
+ playlist_title: str | None = None,
+ playlist_description: str | None = None,
+ *,
+ multi_video: bool = False,
+ **kwargs: Any, # Added to the dict return value.
+ ) -> _InfoDict: ...
+ def http_scheme(self) -> str: ...
+ @classmethod
+ def get_testcases(cls, include_onlymatching: bool = False) -> Iterator[dict[str, Any]]: ...
+ @classmethod
+ def get_webpage_testcases(cls) -> Iterator[dict[str, Any]]: ...
+ @property
+ def age_limit(cls) -> int: ...
+ @classmethod
+ def is_single_video(cls, url: str) -> bool: ...
+ @classmethod
+ def is_suitable(cls, age_limit: int) -> bool: ...
+ @classmethod
+ def description(cls, *, markdown: bool = True, search_examples: Sequence[str] | None = None) -> str: ...
+ # Calls _get_subtitles which only raises NotImplementedError here.
+ def extract_subtitles(self, *args: Any, **kwargs: Any) -> list[dict[str, Any]]: ...
+ def _configuration_arg(self, key: str, default: Any = ..., *, ie_key: str | None = None, casesense: bool = False) -> Any: ...
+ # These are dynamically created.
+ def _download_xml_handle(
+ self,
+ url_or_request: str | Request,
+ video_id: str,
+ note: str | None = "Downloading XML",
+ errnote: str | None = "Unable to download XML",
+ transform_source: Callable[..., str] | None = None,
+ fatal: bool = True,
+ encoding: str | None = None,
+ data: _DataType | None = None,
+ headers: Mapping[str, str] = {},
+ query: Mapping[str, str] = {},
+ expected_status: int | None = None,
+ impersonate: str | None = None,
+ require_impersonation: bool = False,
+ ) -> tuple[ET.ElementTree, Response]: ...
+ def _download_xml(
+ self,
+ url_or_request: str | Request,
+ video_id: str,
+ note: str | None = "Downloading XML",
+ errnote: str | None = "Unable to download XML",
+ transform_source: Callable[..., str] | None = None,
+ fatal: bool = True,
+ encoding: str | None = None,
+ data: _DataType | None = None,
+ headers: Mapping[str, str] = {},
+ query: Mapping[str, str] = {},
+ expected_status: int | None = None,
+ impersonate: str | None = None,
+ require_impersonation: bool = False,
+ ) -> ET.ElementTree: ...
+ def _download_socket_json_handle(
+ self,
+ url_or_request: str | Request,
+ video_id: str,
+ note: str | None = "Polling socket",
+ errnote: str | None = "Unable to poll socket",
+ transform_source: Callable[..., str] | None = None,
+ fatal: bool = True,
+ encoding: str | None = None,
+ data: _DataType | None = None,
+ headers: Mapping[str, str] = {},
+ query: Mapping[str, str] = {},
+ expected_status: int | None = None,
+ impersonate: str | None = None,
+ require_impersonation: bool = False,
+ ) -> tuple[dict[str, Any], Response]: ...
+ def _download_socket_json(
+ self,
+ url_or_request: str | Request,
+ video_id: str,
+ note: str | None = "Polling socket",
+ errnote: str | None = "Unable to poll socket",
+ transform_source: Callable[..., str] | None = None,
+ fatal: bool = True,
+ encoding: str | None = None,
+ data: _DataType | None = None,
+ headers: Mapping[str, str] = {},
+ query: Mapping[str, str] = {},
+ expected_status: int | None = None,
+ impersonate: str | None = None,
+ require_impersonation: bool = False,
+ ) -> dict[str, Any]: ...
+ def _download_json_handle(
+ self,
+ url_or_request: str | Request,
+ video_id: str,
+ note: str | None = "Downloading JSON metadata",
+ errnote: str | None = "Unable to download JSON metadata",
+ transform_source: Callable[..., str] | None = None,
+ fatal: bool = True,
+ encoding: str | None = None,
+ data: _DataType | None = None,
+ headers: Mapping[str, str] = {},
+ query: Mapping[str, str] = {},
+ expected_status: int | None = None,
+ impersonate: str | None = None,
+ require_impersonation: bool = False,
+ ) -> tuple[dict[str, Any], Response]: ...
+ def _download_json(
+ self,
+ url_or_request: str | Request,
+ video_id: str,
+ note: str | None = "Downloading JSON metadata",
+ errnote: str | None = "Unable to download JSON metadata",
+ transform_source: Callable[..., str] | None = None,
+ fatal: bool = True,
+ encoding: str | None = None,
+ data: _DataType | None = None,
+ headers: Mapping[str, str] = {},
+ query: Mapping[str, str] = {},
+ expected_status: int | None = None,
+ impersonate: str | None = None,
+ require_impersonation: bool = False,
+ ) -> dict[str, Any]: ...
+ def _download_webpage(
+ self,
+ url_or_request: str | Request,
+ video_id: str,
+ note: str | None = None,
+ errnote: str | None = None,
+ transform_source: Callable[..., str] | None = ...,
+ fatal: bool = True,
+ encoding: str | None = ...,
+ data: _DataType | None = ...,
+ headers: Mapping[str, str] = ...,
+ query: Mapping[str, str] = ...,
+ expected_status: int | None = ...,
+ impersonate: str | None = ...,
+ require_impersonation: bool = ...,
+ ) -> str: ...
+ def _parse_xml(
+ self,
+ xml_string: str,
+ video_id: str,
+ transform_source: Callable[..., str] | None = None,
+ fatal: bool = True,
+ errnote: str | None = None,
+ ) -> ET.Element: ...
+ def _parse_mpd_formats(
+ self, mpd_doc: ET.Element, mpd_id: str | None = ..., mpd_base_url: str = ..., mpd_url: str | None = ...
+ ) -> list[Any]: ...
+ def _real_extract(self, url: str) -> _InfoDict: ...
+ @staticmethod
+ def _availability(
+ is_private: bool | None = None,
+ needs_premium: bool | None = None,
+ needs_subscription: bool | None = None,
+ needs_auth: bool | None = None,
+ is_unlisted: bool | None = None,
+ ) -> Literal["needs_auth", "premium_only", "private", "public", "subscriber_only", "unlisted"] | None: ...
+ def _request_webpage(
+ self,
+ url_or_req: str | Request,
+ video_id: str,
+ note: str | None = None,
+ errnote: str | None = None,
+ fatal: bool = True,
+ data: _DataType | None = None,
+ headers: Mapping[str, str] | None = None,
+ query: Mapping[str, str] | None = None,
+ expected_status: int | None = None,
+ ) -> Response | Literal[False]: ...
+ @classmethod
+ def _match_id(cls, url: str) -> str: ...
+ def _search_regex(
+ self,
+ pattern: str | re.Pattern[str],
+ string: str | None,
+ name: str,
+ default: _StrNoDefaultOrNone = ...,
+ fatal: bool = True,
+ flags: int = 0,
+ group: tuple[int, ...] | list[int] | None = None,
+ ) -> str: ...
+ def _search_json(
+ self,
+ start_pattern: str | re.Pattern[str],
+ string: str | None,
+ name: str,
+ video_id: str,
+ *,
+ end_pattern: str | re.Pattern[str] = "",
+ contains_pattern: str | re.Pattern[str] = r"{(?s:.+)}",
+ fatal: bool = True,
+ default: _StrNoDefaultOrNone = ...,
+ cls: type[JSONDecoder] | None = None,
+ object_hook: Callable[[dict[Any, Any]], Any] | None = None,
+ parse_float: Callable[[str], Any] | None = None,
+ parse_int: Callable[[str], Any] | None = None,
+ parse_constant: Callable[[str], Any] | None = None,
+ object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = None,
+ ) -> Any: ...
+ def _html_search_regex(
+ self,
+ pattern: str | re.Pattern[str],
+ string: str,
+ name: str,
+ default: _StrNoDefaultOrNone = ...,
+ fatal: bool = True,
+ flags: int = 0,
+ group: int | None = None,
+ ) -> str | tuple[str, ...]: ...
+ def _get_netrc_login_info(self, netrc_machine: str | None = None) -> tuple[str | None, str | None]: ...
+ def _get_login_info(
+ self, username_option: str = "username", password_option: str = "password", netrc_machine: str | None = None
+ ) -> tuple[str | None, str | None]: ...
+ def _get_tfa_info(self, note: str = "two-factor verification code") -> str: ...
+ @staticmethod
+ def _og_regexes(prop: str) -> list[str]: ...
+ @staticmethod
+ def _meta_regex(prop: str) -> str: ...
+ def _og_search_property(
+ self, prop: str, html: str, name: str | None = None, *, default: type[NO_DEFAULT] | str = ..., fatal: bool = False
+ ) -> str | None: ...
+ def _og_search_thumbnail(self, html: str, *, default: type[NO_DEFAULT] | str = ...) -> str | None: ...
+ def _og_search_description(self, html: str, *, default: type[NO_DEFAULT] | str = ...) -> str | None: ...
+ def _og_search_title(self, html: str, *, fatal: bool = False, default: type[NO_DEFAULT] | str = ...) -> str | None: ...
+ def _og_search_video_url(
+ self,
+ html: str,
+ name: str = "video url",
+ secure: bool = True,
+ *,
+ default: type[NO_DEFAULT] | str = ...,
+ fatal: bool = False,
+ ) -> str | None: ...
+ def _og_search_url(self, html: str, *, default: type[NO_DEFAULT] | str = ..., fatal: bool = False) -> str | None: ...
+ def _html_extract_title(
+ self,
+ html: str,
+ name: str = "title",
+ *,
+ default: type[NO_DEFAULT] | str = ...,
+ flags: int = 0,
+ group: tuple[int, ...] | list[int] | None = None,
+ fatal: bool = False,
+ ) -> str | None: ...
+ def _html_search_meta(
+ self,
+ name: str,
+ html: str,
+ display_name: str | None = None,
+ fatal: bool = False,
+ flags: int = 0,
+ group: tuple[int, ...] | list[int] | None = None,
+ ) -> str | None: ...
+ def _dc_search_uploader(self, html: str) -> str | None: ...
+ @staticmethod
+ def _rta_search(html: str) -> int: ...
+ def _media_rating_search(self, html: str) -> int: ...
+ def _family_friendly_search(self, html: str) -> int: ...
+ def _twitter_search_player(self, html: str) -> str | None: ...
+ def _yield_json_ld(
+ self, html: str, video_id: str, *, fatal: bool = True, default: type[NO_DEFAULT] | bool = ...
+ ) -> Iterator[dict[str, Any]]: ...
+ def _search_json_ld(
+ self,
+ html: str,
+ video_id: str,
+ expected_type: Iterable[str] | str | None = None,
+ *,
+ fatal: bool = True,
+ default: type[NO_DEFAULT] | bool = ...,
+ ) -> dict[str, Any]: ...
+ # json_ld parameter is passed to json.loads().
+ def _json_ld(
+ self, json_ld: Any, video_id: str, fatal: bool = True, expected_type: Iterable[str] | str | None = None
+ ) -> dict[str, Any]: ...
+ def _search_nextjs_data(
+ self, webpage: str, video_id: str, *, fatal: bool = True, default: type[NO_DEFAULT] | bool = ..., **kw: Any
+ ) -> Any: ...
+ def _search_nuxt_data(
+ self,
+ webpage: str,
+ video_id: str,
+ context_name: str = "__NUXT__",
+ *,
+ fatal: bool = True,
+ traverse: tuple[str, int] = ("data", 0),
+ ) -> Any: ...
+ @staticmethod
+ def _hidden_inputs(html: str) -> dict[str, Any]: ...
+ def _form_hidden_inputs(self, form_id: str, html: str) -> dict[str, Any]: ...
+ def _check_formats(self, formats: list[dict[str, Any]], video_id: str) -> None: ...
+ @staticmethod
+ def _remove_duplicate_formats(formats: list[dict[str, Any]]) -> None: ...
+ def _is_valid_url(self, url: str, video_id: str, item: str = "video", headers: Mapping[str, Any] = {}) -> bool: ...
+ def _proto_relative_url(self, url: str, scheme: str | None = None) -> str: ...
+ def _sleep(self, timeout: float, video_id: str, msg_template: str | None = None) -> None: ...
+ def _extract_f4m_formats(
+ self,
+ manifest_url: str,
+ video_id: str,
+ preference: Any = None,
+ quality: Any = None,
+ f4m_id: str | None = None,
+ transform_source: Callable[..., str] = ...,
+ fatal: bool = True,
+ m3u8_id: str | None = None,
+ data: str | None = None,
+ headers: Mapping[str, Any] = {},
+ query: Mapping[str, Any] = {},
+ ) -> list[dict[str, Any]]: ...
+ def _parse_f4m_formats(
+ self,
+ manifest: str,
+ manifest_url: str,
+ video_id: str,
+ preference: Any = None,
+ quality: Any = None,
+ f4m_id: str | None = None,
+ transform_source: Callable[..., str] = ...,
+ fatal: bool = True,
+ m3u8_id: str | None = None,
+ ) -> list[dict[str, Any]]: ...
+ def _m3u8_meta_format(
+ self, m3u8_url: str, ext: str | None = None, preference: Any = None, quality: Any = None, m3u8_id: str | None = None
+ ) -> dict[str, Any]: ...
+ def _report_ignoring_subs(self, name: str) -> None: ...
+ def _extract_m3u8_formats(
+ self,
+ m3u8_url: str,
+ video_id: str,
+ ext: str | None = None,
+ entry_protocol: str = "m3u8_native",
+ preference: Any = None,
+ quality: Any = None,
+ m3u8_id: str | None = None,
+ note: str | None = None,
+ errnote: str | None = None,
+ fatal: bool = True,
+ live: bool = False,
+ data: Any = None,
+ headers: Mapping[str, Any] = ...,
+ query: Mapping[str, Any] = ...,
+ ) -> list[dict[str, Any]]: ...
+ def _extract_m3u8_formats_and_subtitles(
+ self,
+ m3u8_url: str,
+ video_id: str,
+ ext: str | None = None,
+ entry_protocol: str = "m3u8_native",
+ preference: Any = None,
+ quality: Any = None,
+ m3u8_id: str | None = None,
+ note: str | None = None,
+ errnote: str | None = None,
+ fatal: bool = True,
+ live: bool = False,
+ data: Any = None,
+ headers: Mapping[str, Any] = {},
+ query: Mapping[str, Any] = {},
+ ) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]: ...
+ def _parse_m3u8_formats_and_subtitles(
+ self,
+ m3u8_doc: str,
+ m3u8_url: str | None = None,
+ ext: str | None = None,
+ entry_protocol: str = "m3u8_native",
+ preference: Any = None,
+ quality: Any = None,
+ m3u8_id: str | None = None,
+ live: bool = False,
+ note: str | None = None,
+ errnote: str | None = None,
+ fatal: bool = True,
+ data: Any = None,
+ headers: Mapping[str, Any] = {},
+ query: Mapping[str, Any] = {},
+ video_id: str | None = None,
+ ) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]: ...
+ def _extract_m3u8_vod_duration(
+ self,
+ m3u8_vod_url: str,
+ video_id: str,
+ note: str | None = None,
+ errnote: str | None = None,
+ data: Any = None,
+ headers: Mapping[str, Any] = {},
+ query: Mapping[str, Any] = {},
+ ) -> int | None: ...
+ def _parse_m3u8_vod_duration(self, m3u8_vod: str, video_id: str) -> int: ...
+ def _extract_mpd_vod_duration(
+ self,
+ mpd_url: str,
+ video_id: str,
+ note: str | None = None,
+ errnote: str | None = None,
+ data: Any = None,
+ headers: Mapping[str, Any] = {},
+ query: Mapping[str, Any] = {},
+ ) -> int | None: ...
+ @staticmethod
+ def _xpath_ns(path: str, namespace: str | None = None) -> str: ...
+ def _extract_smil_formats_and_subtitles(
+ self,
+ smil_url: str,
+ video_id: str,
+ fatal: bool = True,
+ f4m_params: Mapping[str, Any] | None = None,
+ transform_source: Callable[..., str] | None = None,
+ ) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]: ...
+ def _extract_smil_formats(
+ self,
+ smil: ET.Element,
+ smil_url: str,
+ video_id: str,
+ namespace: str | None = None,
+ f4m_params: Mapping[str, Any] | None = None,
+ transform_rtmp_url: Callable[[str, str], tuple[str, str]] | None = None,
+ ) -> list[dict[str, Any]]: ...
+ def _extract_smil_info(
+ self, smil_url: str, video_id: str, fatal: bool = True, f4m_params: Mapping[str, Any] | None = None
+ ) -> dict[str, Any]: ...
+ def _download_smil(
+ self, smil_url: str, video_id: str, fatal: bool = True, transform_source: Callable[..., str] | None = None
+ ) -> ET.Element: ...
+ def _parse_smil(
+ self, smil: ET.Element, smil_url: str, video_id: str, f4m_params: Mapping[str, Any] | None = None
+ ) -> dict[str, Any]: ...
+ def _parse_smil_namespace(self, smil: str) -> str | None: ...
+ def _parse_smil_formats(
+ self,
+ smil: ET.Element,
+ smil_url: str,
+ video_id: str,
+ namespace: str | None = None,
+ f4m_params: Mapping[str, Any] | None = None,
+ transform_rtmp_url: Callable[[str, str], tuple[str, str]] | None = None,
+ ) -> list[dict[str, Any]]: ...
+ def _parse_smil_formats_and_subtitles(
+ self,
+ smil: ET.Element,
+ smil_url: str,
+ video_id: str,
+ namespace: str | None = None,
+ f4m_params: Mapping[str, Any] | None = None,
+ transform_rtmp_url: Callable[[str, str], tuple[str, str]] | None = None,
+ ) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]: ...
+ def _parse_smil_subtitles(
+ self, smil: ET.Element, namespace: str | None = None, subtitles_lang: str = "en"
+ ) -> list[dict[str, Any]]: ...
+ def _extract_xspf_playlist(self, xspf_url: str, playlist_id: str, fatal: bool = True) -> list[dict[str, Any]]: ...
+ def _parse_xspf(
+ self, xspf_doc: ET.Element, playlist_id: str, xspf_url: str | None = None, xspf_base_url: str | None = None
+ ) -> list[dict[str, Any]]: ...
+ def _extract_mpd_formats(
+ self,
+ mpd_url: str,
+ video_id: str,
+ mpd_id: str | None = None,
+ note: str | None = None,
+ errnote: str | None = None,
+ fatal: bool = True,
+ data: Any = None,
+ headers: Mapping[str, Any] = ...,
+ query: Mapping[str, Any] = ...,
+ ) -> list[dict[str, Any]]: ...
+ def _extract_mpd_formats_and_subtitles(
+ self,
+ mpd_url: str,
+ video_id: str,
+ mpd_id: str | None = None,
+ note: str | None = None,
+ errnote: str | None = None,
+ fatal: bool = True,
+ data: Any = None,
+ headers: Mapping[str, Any] = ...,
+ query: Mapping[str, Any] = ...,
+ ) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]: ...
+ def _extract_mpd_periods(
+ self,
+ mpd_url: str,
+ video_id: str,
+ mpd_id: str | None = None,
+ note: str | None = None,
+ errnote: str | None = None,
+ fatal: bool = True,
+ data: Any = None,
+ headers: Mapping[str, Any] = {},
+ query: Mapping[str, Any] = {},
+ ) -> tuple[list[Any], dict[str, Any]]: ...
+ def _parse_mpd_formats_and_subtitles(
+ self,
+ mpd_url: str,
+ video_id: str,
+ mpd_id: str | None = None,
+ note: str | None = None,
+ errnote: str | None = None,
+ fatal: bool = True,
+ data: Any = None,
+ headers: Mapping[str, Any] = ...,
+ query: Mapping[str, Any] = ...,
+ ) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]: ...
+ def _merge_mpd_periods(self, periods: Iterable[Mapping[str, Any]]) -> tuple[list[Any], dict[str, Any]]: ...
+ def _parse_mpd_periods(
+ self, mpd_doc: ET.Element, mpd_id: str | None = None, mpd_base_url: str = "", mpd_url: str | None = None
+ ) -> tuple[list[Any], dict[str, Any]]: ...
+ def _extract_ism_formats(
+ self,
+ ism_url: str,
+ video_id: str,
+ ism_id: str | None = None,
+ note: str | None = None,
+ errnote: str | None = None,
+ fatal: bool = True,
+ data: Any = None,
+ headers: Mapping[str, Any] = ...,
+ query: Mapping[str, Any] = ...,
+ ) -> list[dict[str, Any]]: ...
+ def _extract_ism_formats_and_subtitles(
+ self,
+ ism_url: str,
+ video_id: str,
+ ism_id: str | None = None,
+ note: str | None = None,
+ errnote: str | None = None,
+ fatal: bool = True,
+ data: Any = None,
+ headers: Mapping[str, Any] = {},
+ query: Mapping[str, Any] = {},
+ ) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]: ...
+ def _parse_ism_formats_and_subtitles(
+ self, ism_doc: str, ism_url: str, ism_id: str | None = None
+ ) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]: ...
+ def _parse_html5_media_entries(
+ self,
+ base_url: str,
+ webpage: str,
+ video_id: str,
+ m3u8_id: str | None = None,
+ m3u8_entry_protocol: str = "m3u8_native",
+ mpd_id: str | None = None,
+ preference: Any = None,
+ quality: Any = None,
+ _headers: Mapping[str, Any] | None = None,
+ ) -> list[dict[str, Any]]: ...
+ def _extract_akamai_formats(
+ self, manifest_url: str, video_id: str, hosts: Mapping[str, Any] = ...
+ ) -> list[dict[str, Any]]: ...
+ def _extract_akamai_formats_and_subtitles(
+ self, manifest_url: str, video_id: str, hosts: Mapping[str, Any] = {}
+ ) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]: ...
+ def _extract_wowza_formats(
+ self, url: str, video_id: str, m3u8_entry_protocol: str = "m3u8_native", skip_protocols: Collection[str] = []
+ ) -> list[dict[str, Any]]: ...
+ def _find_jwplayer_data(
+ self, webpage: str, video_id: str | None = None, transform_source: Callable[..., str] = ...
+ ) -> Any: ...
+ def _extract_jwplayer_data(
+ self,
+ webpage: str,
+ video_id: str,
+ *args: Any,
+ transform_source: Callable[..., str] = ...,
+ require_title: bool = True,
+ m3u8_id: str | None = None,
+ mpd_id: str | None = None,
+ rtmp_params: Mapping[str, Any] | None = None,
+ base_url: str | None = None,
+ ) -> list[dict[str, Any]]: ...
+ def _parse_jwplayer_data(
+ self,
+ jwplayer_data: Mapping[str, Any],
+ video_id: str | None = None,
+ require_title: bool = True,
+ m3u8_id: str | None = None,
+ mpd_id: str | None = None,
+ rtmp_params: Mapping[str, Any] | None = None,
+ base_url: str | None = None,
+ ) -> list[dict[str, Any]]: ...
+ def _parse_jwplayer_formats(
+ self,
+ jwplayer_sources_data: Iterable[Mapping[str, Any]],
+ video_id: str | None = None,
+ m3u8_id: str | None = None,
+ mpd_id: str | None = None,
+ rtmp_params: Mapping[str, Any] | None = None,
+ base_url: str | None = None,
+ ) -> list[dict[str, Any]]: ...
+ def _int(
+ self,
+ v: Any,
+ name: str,
+ fatal: bool = False,
+ *,
+ scale: int = 1,
+ default: int | None = None,
+ get_attr: str | None = None,
+ invscale: int = 1,
+ base: int | None = None,
+ ) -> int | None: ...
+ def _float(
+ self, v: Any, name: str, fatal: bool = False, *, scale: int = 1, invscale: int = 1, default: float | None = None
+ ) -> float | None: ...
+ def _set_cookie(
+ self,
+ domain: str,
+ name: str,
+ value: str,
+ expire_time: int | None = None,
+ port: int | None = None,
+ path: str = "/",
+ secure: bool = False,
+ discard: bool = False,
+ rest: dict[str, Any] = {},
+ **kwargs: Unused,
+ ) -> None: ...
+ def _live_title(self, name: _T) -> _T: ...
+ def _get_cookies(self, url: str) -> LenientSimpleCookie: ...
+ def _apply_first_set_cookie_header(self, url_handle: Response, cookie: str) -> None: ...
+ @property
+ def _RETURN_TYPE(cls) -> str: ...
+ def _get_subtitles(self, *args: Any, **kwargs: Any) -> list[dict[str, Any]]: ... # Not implemented here.
+ # Passes *args and **kwargs to _get_comments.
+ def extract_comments(self, *args: Any, **kwargs: Any) -> list[dict[str, Any]]: ...
+ def _get_comments(self, *args: Any, **kwargs: Any) -> list[dict[str, Any]]: ... # Not implemented here.
+ @staticmethod
+ def _merge_subtitle_items(
+ subtitle_list1: Iterable[Mapping[str, Any]], subtitle_list2: Iterable[Mapping[str, Any]]
+ ) -> list[dict[str, Any]]: ...
+ @classmethod
+ def _merge_subtitles(cls, *dicts: dict[str, Any], target: Any = None) -> dict[str, Any]: ...
+ # Calls _get_automatic_captions which only raises NotImplementedError here.
+ def extract_automatic_captions(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ...
+ @cached_property
+ def _cookies_passed(self) -> bool: ...
+ def _mark_watched(self, *args: Any, **kwargs: Any) -> Any: ... # Not implemented here.
+ @staticmethod
+ def _generic_id(url: str) -> str: ...
+ def _generic_title(self, url: str = "", webpage: str = "", *, default: str | None = None) -> str | None: ...
+ def _extract_chapters_helper(
+ self,
+ chapter_list: Iterable[Mapping[str, Any]],
+ start_function: Callable[..., Any],
+ title_function: Callable[..., Any],
+ duration: float,
+ strict: bool = True,
+ ) -> list[dict[str, int]] | None: ...
+ def _extract_chapters_from_description(
+ self, description: str | None, duration: str | None
+ ) -> list[dict[str, int]] | None: ...
+ # Passes *args and **kwargs to _mark_watched which only raises NotImplementedError here.
+ def mark_watched(self, *args: Any, **kwargs: Any) -> None: ...
+ def geo_verification_headers(self) -> dict[str, str]: ...
+ # kwargs passed to _error_callback.
+ def RetryManager(self, *, _retries: int | None, _error_callback: Callable[..., Any], **kwargs: Any) -> _RetryManager: ...
+ @classmethod
+ def extract_from_webpage(cls, ydl: YoutubeDL, url: str, webpage: str) -> Iterator[_InfoDict]: ...
+ def _yes_playlist(
+ self,
+ playlist_id: str,
+ video_id: str,
+ smuggled_data: Any = None,
+ *,
+ playlist_label: str = "playlist",
+ video_label: str = "video",
+ ) -> bool: ...
+ def _error_or_warning(self, err: str, _count: int | None = None, _retries: int = 0, *, fatal: bool = True) -> None: ...
+ def _extract_generic_embeds(
+ self,
+ url: str,
+ *args: Unused,
+ info_dict: _InfoDict = {}, # type: ignore[typeddict-item] # pyright: ignore[reportArgumentType]
+ note: str = "Extracting generic embeds",
+ **kwargs: Unused,
+ ) -> list[dict[str, Any]]: ...
+ @classmethod
+ def _extract_from_webpage(cls, url: str, webpage: str) -> Iterator[_InfoDict]: ...
+ @classmethod
+ def _extract_embed_urls(cls, url: str, webpage: str) -> Iterator[str]: ...
+ @classmethod
+ def _extract_url(cls, webpage: str) -> str | None: ...
+ @classmethod
+ def __init_subclass__(cls, *, plugin_name: str | None = None, **kwargs: Any) -> None: ...
+
+ class StopExtraction(Exception): ...
+ class CommentsDisabled(Exception): ...
+
+class SearchInfoExtractor(InfoExtractor):
+ def _real_extract(self, query: str) -> _InfoDict: ...
+ def _get_n_results(self, query: str, n: int) -> list[_InfoDict]: ...
+ def _search_results(self, query: str) -> list[_InfoDict]: ...
+
+class UnsupportedURLIE(InfoExtractor): ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/extractor/commonmistakes.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/extractor/commonmistakes.pyi
new file mode 100644
index 000000000000..0b33ccd54acb
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/extractor/commonmistakes.pyi
@@ -0,0 +1,10 @@
+from .common import InfoExtractor
+
+class CommonMistakesIE(InfoExtractor):
+ IE_DESC: bool
+
+class UnicodeBOMIE(InfoExtractor):
+ IE_DESC: bool
+
+class BlobIE(InfoExtractor):
+ IE_DESC: bool
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/extractor/commonprotocols.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/extractor/commonprotocols.pyi
new file mode 100644
index 000000000000..495cdd49646d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/extractor/commonprotocols.pyi
@@ -0,0 +1,10 @@
+from .common import InfoExtractor
+
+class RtmpIE(InfoExtractor):
+ IE_DESC: bool
+
+class MmsIE(InfoExtractor):
+ IE_DESC: bool
+
+class ViewSourceIE(InfoExtractor):
+ IE_DESC: bool
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/globals.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/globals.pyi
new file mode 100644
index 000000000000..cb97371d901f
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/globals.pyi
@@ -0,0 +1,20 @@
+from collections import defaultdict
+from typing import Any, Generic, Literal, TypeVar
+
+_T = TypeVar("_T")
+
+class Indirect(Generic[_T]):
+ value: _T
+ def __init__(self, initial: _T, /) -> None: ...
+
+postprocessors: Indirect[dict[str, Any]]
+extractors: Indirect[dict[str, Any]]
+all_plugins_loaded: Indirect[bool]
+plugin_specs: Indirect[dict[str, Any]]
+plugin_dirs: Indirect[list[str]]
+plugin_ies: Indirect[dict[str, Any]]
+plugin_pps: Indirect[dict[str, Any]]
+plugin_ies_overrides: Indirect[defaultdict[str, Any]]
+IN_CLI: Indirect[bool]
+LAZY_EXTRACTORS: Indirect[bool | None]
+WINDOWS_VT_MODE: Indirect[Literal[False] | None] # Code takes into account that only False here
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/jsinterp.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/jsinterp.pyi
new file mode 100644
index 000000000000..4fbd25299b5c
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/jsinterp.pyi
@@ -0,0 +1,72 @@
+import collections
+import types
+from collections.abc import Callable, Collection, Iterable, Mapping
+from typing import Any, NoReturn
+from typing_extensions import TypeAlias
+
+from yt_dlp.extractor.common import InfoExtractor
+from yt_dlp.utils._utils import function_with_repr
+
+from .utils import ExtractorError
+
+def js_number_to_string(val: float, radix: int = 10) -> str: ...
+
+class JS_Undefined: ...
+
+class JS_Break(ExtractorError):
+ def __init__(self) -> None: ...
+
+class JS_Continue(ExtractorError):
+ def __init__(self) -> None: ...
+
+class JS_Throw(ExtractorError):
+ error: BaseException
+ def __init__(self, e: BaseException) -> None: ...
+
+class LocalNameSpace(collections.ChainMap[str, Any]):
+ def __setitem__(self, key: str, value: Any) -> None: ...
+ def __delitem__(self, key: str) -> NoReturn: ...
+ def set_local(self, key: str, value: Any) -> None: ...
+ def get_local(self, key: str) -> Any: ...
+
+class Debugger:
+ ENABLED: bool
+ @staticmethod
+ def write(*args: str, level: int = 100) -> None: ...
+ @classmethod
+ # Callable[[Debugger, str, Any, int, ...], tuple[Any, bool]] but it also accepts *args, **kwargs.
+ def wrap_interpreter(cls, f: Callable[..., tuple[Any, bool]]) -> Callable[..., tuple[Any, bool]]: ...
+
+_BuildFunctionReturnType: TypeAlias = Callable[[Collection[Any], Mapping[str, Any], int], Any | None]
+
+class JSInterpreter:
+ def __init__(self, code: str, objects: Mapping[str, Any] | None = None) -> None: ...
+
+ class Exception(ExtractorError):
+ def __init__(
+ self,
+ msg: str,
+ expr: str | None = None,
+ tb: types.TracebackType | None = None,
+ expected: bool = False,
+ cause: Exception | str | None = None,
+ video_id: str | None = None,
+ ie: InfoExtractor | None = None,
+ ) -> None: ...
+
+ # After wrapping, *args and **kwargs are added but do nothing for this method.
+ def interpret_statement(
+ self, stmt: str, local_vars: Mapping[str, Any], allow_recursion: int, *args: Any, **kwargs: Any
+ ) -> tuple[Any, bool]: ...
+ def interpret_expression(self, expr: str, local_vars: Mapping[str, Any], allow_recursion: int) -> Any: ...
+ def extract_object(self, objname: str, *global_stack: Iterable[dict[str, Any]]) -> Any: ...
+ def extract_function_code(self, funcname: str) -> tuple[list[str], tuple[str, str]]: ...
+ def extract_function(self, funcname: str, *global_stack: Iterable[dict[str, Any]]) -> function_with_repr[Any]: ...
+ def extract_function_from_code(
+ self, argnames: Collection[str], code: str, *global_stack: Iterable[dict[str, Any]]
+ ) -> _BuildFunctionReturnType: ...
+ # args are passed to the extracted function.
+ def call_function(self, funcname: str, *args: Any) -> function_with_repr[Any]: ...
+ def build_function(
+ self, argnames: Collection[str], code: str, *global_stack: Iterable[dict[str, Any]]
+ ) -> _BuildFunctionReturnType: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/minicurses.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/minicurses.pyi
new file mode 100644
index 000000000000..d83671b44f31
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/minicurses.pyi
@@ -0,0 +1,23 @@
+from collections.abc import Callable
+from typing import TextIO
+from typing_extensions import Self
+
+CONTROL_SEQUENCES: dict[str, str] = ...
+
+def format_text(text: str, f: str) -> str: ...
+
+class MultilinePrinterBase:
+ def __init__(self, stream: TextIO | None = None, lines: int = 1) -> None: ...
+ def __enter__(self) -> Self: ...
+ def __exit__(self, *args: object) -> None: ...
+ def print_at_line(self, text: str, pos: int) -> None: ...
+ def end(self) -> None: ...
+ def write(self, *text: str) -> None: ...
+
+class QuietMultilinePrinter(MultilinePrinterBase): ...
+class MultilineLogger(MultilinePrinterBase): ...
+class BreaklineStatusPrinter(MultilinePrinterBase): ...
+
+class MultilinePrinter(MultilinePrinterBase):
+ def __init__(self, stream: TextIO | None = None, lines: int = 1, preserve_output: bool = True) -> None: ...
+ def lock(func: Callable[..., object]) -> Callable[..., object]: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/networking/__init__.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/networking/__init__.pyi
new file mode 100644
index 000000000000..274b53643736
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/networking/__init__.pyi
@@ -0,0 +1,9 @@
+from .common import (
+ HEADRequest as HEADRequest,
+ PATCHRequest as PATCHRequest,
+ PUTRequest as PUTRequest,
+ Request as Request,
+ RequestDirector as RequestDirector,
+ RequestHandler as RequestHandler,
+ Response as Response,
+)
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/networking/_helper.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/networking/_helper.pyi
new file mode 100644
index 000000000000..d93a606440ad
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/networking/_helper.pyi
@@ -0,0 +1,47 @@
+import ssl
+from _socket import _Address
+from _typeshed import StrOrBytesPath
+from collections.abc import Callable, Iterable, Mapping
+from socket import AddressFamily, SocketKind
+from typing import Any
+from typing_extensions import TypeAlias
+
+from ..socks import sockssocket
+from ..utils.networking import HTTPHeaderDict
+from .common import Request, RequestHandler, Response
+
+def ssl_load_certs(context: ssl.SSLContext, use_certifi: bool = True) -> None: ...
+def ssl_load_windows_store_certs(ssl_context: ssl.SSLContext, storename: str) -> None: ...
+def make_socks_proxy_opts(socks_proxy: str) -> dict[str, Any]: ...
+def get_redirect_method(method: str, status: int) -> str: ...
+def make_ssl_context(
+ verify: bool = True,
+ client_certificate: StrOrBytesPath | None = None,
+ client_certificate_key: StrOrBytesPath | None = None,
+ client_certificate_password: Callable[[], str | bytes | bytearray] | str | bytes | bytearray | None = None,
+ legacy_support: bool = False,
+ use_certifi: bool = True,
+) -> ssl.SSLContext: ...
+
+class InstanceStoreMixin:
+ def __init__(self, **kwargs: Any) -> None: ... # Passed to non-existent parent so MRO works.
+
+def add_accept_encoding_header(headers: HTTPHeaderDict, supported_encodings: Iterable[str]) -> None: ...
+def wrap_request_errors(
+ func: Callable[[RequestHandler, Request], Response | None],
+) -> Callable[[RequestHandler, Request], None]: ...
+
+_IPAddress: TypeAlias = tuple[
+ AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes]
+]
+
+def create_socks_proxy_socket(
+ dest_addr: _Address, proxy_args: Mapping[str, Any], proxy_ip_addr: _IPAddress, timeout: float | None, source_address: _Address
+) -> sockssocket: ...
+def create_connection(
+ address: tuple[str, int],
+ timeout: int = ...,
+ source_address: _Address | None = None,
+ *,
+ _create_socket_func: Callable[[_IPAddress, int, _Address], sockssocket] = ...,
+) -> sockssocket: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/networking/common.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/networking/common.pyi
new file mode 100644
index 000000000000..9a00e90d08fa
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/networking/common.pyi
@@ -0,0 +1,162 @@
+import abc
+import enum
+import io
+from _typeshed import Unused
+from collections.abc import Callable, Iterable, Mapping
+from email.message import Message
+from logging import Logger
+from typing import IO, Any
+from typing_extensions import Self, TypeAlias
+
+from ..cookies import YoutubeDLCookieJar
+from ..utils._utils import _YDLLogger
+from ..utils.networking import HTTPHeaderDict
+
+DEFAULT_TIMEOUT: int
+_RequestData: TypeAlias = bytes | Iterable[bytes] | IO[Any] | None
+_Preference: TypeAlias = Callable[[RequestHandler, Request], int]
+
+def register_preference(*handlers: type[RequestHandler]) -> Callable[..., object]: ...
+
+class RequestDirector:
+ handlers: dict[str, RequestHandler]
+ preferences: set[_Preference]
+ logger: Logger
+ verbose: bool
+ def __init__(self, logger: Logger, verbose: bool = False) -> None: ...
+ def close(self) -> None: ...
+ def add_handler(self, handler: RequestHandler) -> None: ...
+ def send(self, request: Request) -> Response: ...
+
+def register_rh(handler: RequestHandler) -> RequestHandler: ...
+
+class Features(enum.Enum):
+ ALL_PROXY = 1
+ NO_PROXY = 2
+
+class RequestHandler(abc.ABC, metaclass=abc.ABCMeta):
+ headers: HTTPHeaderDict | dict[str, str]
+ cookiejar: YoutubeDLCookieJar | None
+ timeout: float | int
+ proxies: Mapping[str, Any] | dict[str, Any]
+ source_address: str | None
+ verbose: bool
+ prefer_system_certs: bool
+ verify: bool
+ legacy_ssl_support: bool
+ def __init__(
+ self,
+ *,
+ logger: _YDLLogger,
+ headers: HTTPHeaderDict | Mapping[str, str] | None = None,
+ cookiejar: YoutubeDLCookieJar | None = None,
+ timeout: float | None = None,
+ proxies: Mapping[str, Any] | None = None,
+ source_address: str | None = None,
+ verbose: bool = False,
+ prefer_system_certs: bool = False,
+ client_cert: dict[str, str | None] | None = None,
+ verify: bool = True,
+ legacy_ssl_support: bool = False,
+ **_: Unused,
+ ) -> None: ...
+ def validate(self, request: Request) -> None: ...
+ def send(self, request: Request) -> Response: ...
+ def close(self) -> None: ...
+ @property
+ def RH_NAME(cls) -> str: ...
+ @property
+ def RH_KEY(cls) -> str: ...
+ def __enter__(self) -> Self: ...
+ def __exit__(self, *args: object) -> None: ...
+
+class Request:
+ proxies: Mapping[str, Any] | dict[str, Any]
+ extensions: Mapping[str, Any] | dict[str, Any]
+ def __init__(
+ self,
+ url: str,
+ data: _RequestData | None = None,
+ headers: HTTPHeaderDict | Mapping[str, str] | None = None,
+ proxies: Mapping[str, Any] | None = None,
+ query: Mapping[str, str] | None = None,
+ method: str | None = None,
+ extensions: Mapping[str, Any] | None = None,
+ ) -> None: ...
+ @property
+ def url(self) -> str: ...
+ @url.setter
+ def url(self, url: str) -> None: ...
+ @property
+ def method(self) -> str: ...
+ @method.setter
+ def method(self, method: str) -> None: ...
+ @property
+ def data(self) -> _RequestData | io.IOBase: ...
+ @data.setter
+ def data(self, data: _RequestData) -> None: ...
+ @property
+ def headers(self) -> HTTPHeaderDict | dict[str, str]: ...
+ @headers.setter
+ def headers(self, new_headers: Mapping[str, str] | HTTPHeaderDict) -> None: ...
+ def update(
+ self,
+ url: str | None = None,
+ data: str | None = None,
+ headers: HTTPHeaderDict | Mapping[str, str] | None = None,
+ query: Mapping[str, str] | None = None,
+ extensions: Mapping[str, Any] | None = None,
+ ) -> None: ...
+ def copy(self) -> Self: ...
+
+def HEADRequest(
+ url: str,
+ data: _RequestData | None = None,
+ headers: HTTPHeaderDict | Mapping[str, str] | None = None,
+ proxies: Mapping[str, Any] | None = None,
+ query: Mapping[str, str] | None = None,
+ *,
+ method: str = "HEAD",
+ extensions: Mapping[str, Any] | None = None,
+) -> Request: ...
+def PATCHRequest(
+ url: str,
+ data: _RequestData | None = None,
+ headers: HTTPHeaderDict | Mapping[str, str] | None = None,
+ proxies: Mapping[str, Any] | None = None,
+ query: Mapping[str, str] | None = None,
+ *,
+ method: str = "PATCH",
+ extensions: Mapping[str, Any] | None = None,
+) -> Request: ...
+def PUTRequest(
+ url: str,
+ data: _RequestData | None = None,
+ headers: HTTPHeaderDict | Mapping[str, str] | None = None,
+ proxies: Mapping[str, Any] | None = None,
+ query: Mapping[str, str] | None = None,
+ *,
+ method: str = "PUT",
+ extensions: Mapping[str, Any] | None = None,
+) -> Request: ...
+
+class Response(io.IOBase):
+ fp: io.IOBase
+ headers: Message
+ status: int
+ url: str
+ reason: str | None
+ extensions: Mapping[str, Any] | dict[str, Any]
+ def __init__(
+ self,
+ fp: io.IOBase,
+ url: str,
+ headers: Mapping[str, str],
+ status: int = 200,
+ reason: str | None = None,
+ extensions: Mapping[str, Any] | dict[str, Any] | None = None,
+ ) -> None: ...
+ def readable(self) -> bool: ...
+ def read(self, amt: int | None = None) -> bytes: ...
+ def close(self) -> None: ...
+ def get_header(self, name: str, default: str | None = None) -> str | None: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/networking/exceptions.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/networking/exceptions.pyi
new file mode 100644
index 000000000000..15668162344b
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/networking/exceptions.pyi
@@ -0,0 +1,43 @@
+from ..utils import YoutubeDLError
+from .common import RequestHandler, Response
+
+class RequestError(YoutubeDLError):
+ handler: RequestHandler | None
+ cause: Exception | str | None
+ def __init__(
+ self, msg: str | None = None, cause: Exception | str | None = None, handler: RequestHandler | None = None
+ ) -> None: ...
+
+class UnsupportedRequest(RequestError): ...
+
+class NoSupportingHandlers(RequestError):
+ unsupported_errors: list[UnsupportedRequest]
+ unexpected_errors: list[UnsupportedRequest]
+ def __init__(self, unsupported_errors: list[UnsupportedRequest], unexpected_errors: list[Exception]) -> None: ...
+
+class TransportError(RequestError): ...
+
+class HTTPError(RequestError):
+ response: Response
+ status: int
+ reason: str | None
+ redirect_loop: bool
+
+ def __init__(self, response: Response, redirect_loop: bool = False) -> None: ...
+ def close(self) -> None: ...
+
+class IncompleteRead(TransportError):
+ def __init__(
+ self,
+ partial: int,
+ expected: int | None = None,
+ *,
+ cause: Exception | str | None = None,
+ handler: RequestHandler | None = None,
+ ) -> None: ...
+
+class SSLError(TransportError): ...
+class CertificateVerifyError(SSLError): ...
+class ProxyError(TransportError): ...
+
+network_exceptions: tuple[type[RequestError], ...]
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/networking/impersonate.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/networking/impersonate.pyi
new file mode 100644
index 000000000000..3fdc816bf04b
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/networking/impersonate.pyi
@@ -0,0 +1,35 @@
+from abc import ABC
+from dataclasses import dataclass
+from typing import Any
+from typing_extensions import Self
+
+from .common import Request, RequestHandler
+
+@dataclass(order=True, frozen=True)
+class ImpersonateTarget:
+ client: str | None = ...
+ version: str | None = ...
+ os: str | None = ...
+ os_version: str | None = ...
+
+ def __post_init__(self) -> None: ...
+ def __contains__(self, target: Self) -> bool: ...
+ @classmethod
+ def from_str(cls, target: str) -> Self: ...
+
+class ImpersonateRequestHandler(RequestHandler, ABC):
+ _SUPPORTED_IMPERSONATE_TARGET_MAP: dict[ImpersonateTarget, Any] = ... # Copied from source.
+
+ def __init__(
+ self,
+ *,
+ impersonate: ImpersonateTarget | None = None,
+ # All keyword arguments are ignored (passed to RequestHandler as **kwargs but RequestHandler.__init__() has **_ and does
+ # not use it).
+ **kwargs: Any,
+ ) -> None: ...
+ @property
+ def supported_targets(cls) -> tuple[ImpersonateTarget, ...]: ...
+ def is_supported_target(self, target: ImpersonateTarget) -> bool: ...
+
+def impersonate_preference(rh: RequestHandler, request: Request) -> int: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/networking/websocket.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/networking/websocket.pyi
new file mode 100644
index 000000000000..f842d6a72adf
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/networking/websocket.pyi
@@ -0,0 +1,11 @@
+import abc
+from typing import Any
+
+from .common import RequestHandler, Response
+
+class WebSocketResponse(Response):
+ # Both raise NotImplementedError.
+ def send(self, message: bytes | str) -> Any: ...
+ def recv(self) -> Any: ...
+
+class WebSocketRequestHandler(RequestHandler, abc.ABC, metaclass=abc.ABCMeta): ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/options.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/options.pyi
new file mode 100644
index 000000000000..cce470c8cbdb
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/options.pyi
@@ -0,0 +1,16 @@
+import optparse
+from collections.abc import Sequence
+
+def parseOpts(
+ overrideArguments: Sequence[str] | None = None, ignore_config_files: str = "if_override"
+) -> tuple[_YoutubeDLOptionParser, optparse.Values, list[str]]: ...
+
+class _YoutubeDLOptionParser(optparse.OptionParser):
+ ALIAS_DEST: str
+ ALIAS_TRIGGER_LIMIT: int
+ def __init__(self) -> None: ...
+ def parse_known_args(
+ self, args: Sequence[str] | None = None, values: optparse.Values | None = None, strict: bool = True
+ ) -> tuple[optparse.Values, list[str]]: ...
+
+def create_parser() -> _YoutubeDLOptionParser: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/plugins.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/plugins.pyi
new file mode 100644
index 000000000000..6394f6fd036d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/plugins.pyi
@@ -0,0 +1,45 @@
+import dataclasses
+import importlib.abc
+from _typeshed import Unused
+from collections.abc import Iterator
+from importlib.machinery import ModuleSpec
+from pathlib import Path
+from types import ModuleType
+from typing import Any
+
+from .globals import Indirect
+
+__all__ = [
+ "COMPAT_PACKAGE_NAME",
+ "PACKAGE_NAME",
+ "PluginSpec",
+ "directories",
+ "load_all_plugins",
+ "load_plugins",
+ "register_plugin_spec",
+]
+
+PACKAGE_NAME: str = "yt_dlp_plugins"
+COMPAT_PACKAGE_NAME: str = "ytdlp_plugins"
+
+@dataclasses.dataclass
+class PluginSpec:
+ module_name: str
+ suffix: str
+ destination: Indirect[dict[str, Any]]
+ plugin_destination: Indirect[dict[str, Any]]
+
+class PluginLoader(importlib.abc.Loader):
+ def exec_module(self, module: ModuleType) -> None: ...
+
+class PluginFinder(importlib.abc.MetaPathFinder):
+ packages: set[str]
+ def __init__(self, *packages: str) -> None: ...
+ def search_locations(self, fullname: str) -> Iterator[Path]: ...
+ def find_spec(self, fullname: str, path: Unused | None = None, target: Unused | None = None) -> ModuleSpec | None: ...
+ def invalidate_caches(self) -> None: ...
+
+def directories() -> list[str]: ...
+def load_plugins(plugin_spec: PluginSpec) -> dict[str, Any]: ...
+def load_all_plugins() -> None: ...
+def register_plugin_spec(plugin_spec: PluginSpec) -> None: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/postprocessor/__init__.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/postprocessor/__init__.pyi
new file mode 100644
index 000000000000..a94f3c35484f
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/postprocessor/__init__.pyi
@@ -0,0 +1,7 @@
+from collections.abc import Mapping
+
+from .common import PostProcessor
+
+_default_pps: Mapping[str, type[PostProcessor]]
+
+def get_postprocessor(key: str) -> type[PostProcessor]: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/postprocessor/common.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/postprocessor/common.pyi
new file mode 100644
index 000000000000..bb02ab145873
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/postprocessor/common.pyi
@@ -0,0 +1,38 @@
+from _typeshed import StrPath
+from collections.abc import Callable
+from typing import Any
+
+from ..extractor.common import _InfoDict
+from ..YoutubeDL import YoutubeDL
+
+class PostProcessorMetaClass(type):
+ @staticmethod
+ def run_wrapper(func: Callable[..., object]) -> Callable[..., object]: ...
+ def __new__(cls, name: str, bases: tuple[type[Any], ...], attrs: dict[str, Any]) -> type[Any]: ...
+
+class PostProcessor(metaclass=PostProcessorMetaClass):
+ PP_NAME: str
+ def __init__(self, downloader: YoutubeDL | None = None) -> None: ...
+ @classmethod
+ def pp_key(cls) -> str: ...
+ def to_screen(
+ self,
+ text: str,
+ prefix: bool = True,
+ *,
+ message: str,
+ skip_eol: bool = False,
+ quiet: bool | None = None,
+ only_once: bool = False,
+ ) -> None: ...
+ def report_warning(self, text: str, only_once: bool = False) -> None: ...
+ def deprecation_warning(self, msg: str) -> None: ...
+ def deprecated_feature(self, msg: str) -> None: ...
+ def write_debug(self, text: str, *, only_once: bool = False) -> None: ...
+ # *args and **kwargs are passed to .param.get() where param is normally a dict but does not have to be.
+ def get_param(self, name: str, default: Any = None, *args: Any, **kwargs: Any) -> Any: ...
+ def set_downloader(self, downloader: YoutubeDL) -> None: ...
+ def run(self, information: _InfoDict) -> tuple[list[str], _InfoDict]: ...
+ def try_utime(self, path: StrPath, atime: int, mtime: int, errnote: str = "Cannot update utime of file") -> None: ...
+ def add_progress_hook(self, ph: Callable[[str], object]) -> None: ...
+ def report_progress(self, s: str) -> None: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/socks.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/socks.pyi
new file mode 100644
index 000000000000..c4c908519ac1
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/socks.pyi
@@ -0,0 +1,74 @@
+import socket
+from _socket import _Address
+from collections.abc import Mapping
+from typing import NamedTuple, SupportsIndex
+
+SOCKS4_VERSION: int
+SOCKS4_REPLY_VERSION: int
+SOCKS4_DEFAULT_DSTIP: bytes
+SOCKS5_VERSION: int
+SOCKS5_USER_AUTH_VERSION: int
+SOCKS5_USER_AUTH_SUCCESS: int
+
+class Socks4Command:
+ CMD_CONNECT: int
+ CMD_BIND: int
+
+class Socks5Command(Socks4Command):
+ CMD_UDP_ASSOCIATE: int
+
+class Socks5Auth:
+ AUTH_NONE: int
+ AUTH_GSSAPI: int
+ AUTH_USER_PASS: int
+ AUTH_NO_ACCEPTABLE: int
+
+class Socks5AddressType:
+ ATYP_IPV4: int
+ ATYP_DOMAINNAME: int
+ ATYP_IPV6: int
+
+class ProxyError(OSError):
+ ERR_SUCCESS: int
+ def __init__(self, code: int | None = None, msg: str | None = None) -> None: ...
+
+class InvalidVersionError(ProxyError):
+ def __init__(self, expected_version: int, got_version: int) -> None: ...
+
+class Socks4Error(ProxyError):
+ ERR_SUCCESS: int
+ CODES: Mapping[int, str]
+
+class Socks5Error(ProxyError):
+ ERR_GENERAL_FAILURE: int
+ CODES: Mapping[int, str]
+
+class ProxyType:
+ SOCKS4: int
+ SOCKS4A: int
+ SOCKS5: int
+
+class Proxy(NamedTuple):
+ type: ProxyType
+ host: str
+ port: int
+ username: str
+ password: str
+ remote_dns: bool
+
+class sockssocket(socket.socket):
+ def __init__(
+ self, family: int = -1, type: int = -1, proto: int = -1, fileno: SupportsIndex | bytes | None = None
+ ) -> None: ...
+ def setproxy(
+ self,
+ proxytype: ProxyType,
+ addr: str,
+ port: int,
+ rdns: bool = True,
+ username: str | None = None,
+ password: str | None = None,
+ ) -> None: ...
+ def recvall(self, cnt: int) -> bytes: ...
+ def connect(self, address: _Address) -> None: ...
+ def connect_ex(self, address: _Address) -> int: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/update.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/update.pyi
new file mode 100644
index 000000000000..bd287ac6212e
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/update.pyi
@@ -0,0 +1,34 @@
+import functools
+from dataclasses import dataclass
+
+from yt_dlp.utils._utils import NO_DEFAULT
+from yt_dlp.YoutubeDL import YoutubeDL
+
+__all__ = ["Updater"]
+
+@dataclass
+class UpdateInfo:
+ tag: str
+ version: str | None = ...
+ requested_version: str | None = ...
+ commit: str | None = ...
+ binary_name: str | None = ...
+ checksum: str | None = ...
+
+class Updater:
+ ydl: YoutubeDL
+ requested_channel: str
+ requested_tag: str | None
+ requested_repo: str | None
+ def __init__(self, ydl: YoutubeDL, target: str | None = None) -> None: ...
+ @property
+ def current_version(self) -> str: ...
+ @property
+ def current_commit(self) -> str: ...
+ def query_update(self, *, _output: bool = False) -> UpdateInfo | None: ...
+ def update(self, update_info: type[NO_DEFAULT] | None | UpdateInfo = ...) -> bool | None: ...
+ @functools.cached_property
+ def filename(self) -> str: ...
+ @functools.cached_property
+ def cmd(self) -> list[str]: ...
+ def restart(self) -> int: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/__init__.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/__init__.pyi
new file mode 100644
index 000000000000..f4fea0224c81
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/__init__.pyi
@@ -0,0 +1,269 @@
+from ._deprecated import (
+ bytes_to_intlist as bytes_to_intlist,
+ compiled_regex_type as compiled_regex_type,
+ intlist_to_bytes as intlist_to_bytes,
+ jwt_encode_hs256 as jwt_encode_hs256,
+)
+from ._utils import (
+ ACCENT_CHARS as ACCENT_CHARS,
+ BOMS as BOMS,
+ DATE_FORMATS as DATE_FORMATS,
+ DATE_FORMATS_DAY_FIRST as DATE_FORMATS_DAY_FIRST,
+ DATE_FORMATS_MONTH_FIRST as DATE_FORMATS_MONTH_FIRST,
+ DEFAULT_OUTTMPL as DEFAULT_OUTTMPL,
+ DOT_DESKTOP_LINK_TEMPLATE as DOT_DESKTOP_LINK_TEMPLATE,
+ DOT_URL_LINK_TEMPLATE as DOT_URL_LINK_TEMPLATE,
+ DOT_WEBLOC_LINK_TEMPLATE as DOT_WEBLOC_LINK_TEMPLATE,
+ ENGLISH_MONTH_NAMES as ENGLISH_MONTH_NAMES,
+ IDENTITY as IDENTITY,
+ JSON_LD_RE as JSON_LD_RE,
+ KNOWN_EXTENSIONS as KNOWN_EXTENSIONS,
+ LINK_TEMPLATES as LINK_TEMPLATES,
+ MEDIA_EXTENSIONS as MEDIA_EXTENSIONS,
+ MONTH_NAMES as MONTH_NAMES,
+ NO_DEFAULT as NO_DEFAULT,
+ NUMBER_RE as NUMBER_RE,
+ OUTTMPL_TYPES as OUTTMPL_TYPES,
+ PACKED_CODES_RE as PACKED_CODES_RE,
+ POSTPROCESS_WHEN as POSTPROCESS_WHEN,
+ STR_FORMAT_RE_TMPL as STR_FORMAT_RE_TMPL,
+ STR_FORMAT_TYPES as STR_FORMAT_TYPES,
+ TIMEZONE_NAMES as TIMEZONE_NAMES,
+ TV_PARENTAL_GUIDELINES as TV_PARENTAL_GUIDELINES,
+ US_RATINGS as US_RATINGS,
+ WINDOWS_VT_MODE as WINDOWS_VT_MODE,
+ Config as Config,
+ ContentTooShortError as ContentTooShortError,
+ DateRange as DateRange,
+ DownloadCancelled as DownloadCancelled,
+ DownloadError as DownloadError,
+ EntryNotInPlaylist as EntryNotInPlaylist,
+ ExistingVideoReached as ExistingVideoReached,
+ ExtractorError as ExtractorError,
+ FormatSorter as FormatSorter,
+ GeoRestrictedError as GeoRestrictedError,
+ GeoUtils as GeoUtils,
+ HTMLAttributeParser as HTMLAttributeParser,
+ HTMLBreakOnClosingTagParser as HTMLBreakOnClosingTagParser,
+ HTMLListAttrsParser as HTMLListAttrsParser,
+ InAdvancePagedList as InAdvancePagedList,
+ ISO639Utils as ISO639Utils,
+ ISO3166Utils as ISO3166Utils,
+ LazyList as LazyList,
+ LenientJSONDecoder as LenientJSONDecoder,
+ LockingUnsupportedError as LockingUnsupportedError,
+ MaxDownloadsReached as MaxDownloadsReached,
+ Namespace as Namespace,
+ OnDemandPagedList as OnDemandPagedList,
+ PagedList as PagedList,
+ PlaylistEntries as PlaylistEntries,
+ Popen as Popen,
+ PostProcessingError as PostProcessingError,
+ ReExtractInfo as ReExtractInfo,
+ RegexNotFoundError as RegexNotFoundError,
+ RejectedVideoReached as RejectedVideoReached,
+ RetryManager as RetryManager,
+ SameFileError as SameFileError,
+ ThrottledDownload as ThrottledDownload,
+ UnavailableVideoError as UnavailableVideoError,
+ UnsupportedError as UnsupportedError,
+ UserNotLive as UserNotLive,
+ XAttrMetadataError as XAttrMetadataError,
+ XAttrUnavailableError as XAttrUnavailableError,
+ YoutubeDLError as YoutubeDLError,
+ age_restricted as age_restricted,
+ args_to_str as args_to_str,
+ ass_subtitles_timecode as ass_subtitles_timecode,
+ base_url as base_url,
+ bool_or_none as bool_or_none,
+ bug_reports_message as bug_reports_message,
+ bytes_to_long as bytes_to_long,
+ cached_method as cached_method,
+ caesar as caesar,
+ check_executable as check_executable,
+ classproperty as classproperty,
+ clean_html as clean_html,
+ clean_podcast_url as clean_podcast_url,
+ cli_bool_option as cli_bool_option,
+ cli_configuration_args as cli_configuration_args,
+ cli_option as cli_option,
+ cli_valueless_option as cli_valueless_option,
+ date_formats as date_formats,
+ date_from_str as date_from_str,
+ datetime_add_months as datetime_add_months,
+ datetime_from_str as datetime_from_str,
+ datetime_round as datetime_round,
+ decode_base_n as decode_base_n,
+ decode_packed_codes as decode_packed_codes,
+ deprecation_warning as deprecation_warning,
+ detect_exe_version as detect_exe_version,
+ determine_ext as determine_ext,
+ determine_file_encoding as determine_file_encoding,
+ determine_protocol as determine_protocol,
+ dfxp2srt as dfxp2srt,
+ download_range_func as download_range_func,
+ encode_base_n as encode_base_n,
+ encode_compat_str as encode_compat_str,
+ encode_data_uri as encode_data_uri,
+ encodeArgument as encodeArgument,
+ error_to_str as error_to_str,
+ escapeHTML as escapeHTML,
+ expand_path as expand_path,
+ ext2mimetype as ext2mimetype,
+ extract_attributes as extract_attributes,
+ extract_basic_auth as extract_basic_auth,
+ extract_timezone as extract_timezone,
+ filesize_from_tbr as filesize_from_tbr,
+ filter_dict as filter_dict,
+ find_available_port as find_available_port,
+ find_xpath_attr as find_xpath_attr,
+ fix_xml_ampersands as fix_xml_ampersands,
+ float_or_none as float_or_none,
+ format_bytes as format_bytes,
+ format_decimal_suffix as format_decimal_suffix,
+ format_field as format_field,
+ formatSeconds as formatSeconds,
+ frange as frange,
+ function_with_repr as function_with_repr,
+ get_compatible_ext as get_compatible_ext,
+ get_domain as get_domain,
+ get_element_by_attribute as get_element_by_attribute,
+ get_element_by_class as get_element_by_class,
+ get_element_by_id as get_element_by_id,
+ get_element_html_by_attribute as get_element_html_by_attribute,
+ get_element_html_by_class as get_element_html_by_class,
+ get_element_html_by_id as get_element_html_by_id,
+ get_element_text_and_html_by_tag as get_element_text_and_html_by_tag,
+ get_elements_by_attribute as get_elements_by_attribute,
+ get_elements_by_class as get_elements_by_class,
+ get_elements_html_by_attribute as get_elements_html_by_attribute,
+ get_elements_html_by_class as get_elements_html_by_class,
+ get_elements_text_and_html_by_attribute as get_elements_text_and_html_by_attribute,
+ get_exe_version as get_exe_version,
+ get_executable_path as get_executable_path,
+ get_filesystem_encoding as get_filesystem_encoding,
+ get_system_config_dirs as get_system_config_dirs,
+ get_user_config_dirs as get_user_config_dirs,
+ get_windows_version as get_windows_version,
+ hyphenate_date as hyphenate_date,
+ int_or_none as int_or_none,
+ iri_to_uri as iri_to_uri,
+ is_html as is_html,
+ is_iterable_like as is_iterable_like,
+ is_outdated_version as is_outdated_version,
+ is_path_like as is_path_like,
+ join_nonempty as join_nonempty,
+ js_to_json as js_to_json,
+ jwt_decode_hs256 as jwt_decode_hs256,
+ jwt_encode as jwt_encode,
+ limit_length as limit_length,
+ locked_file as locked_file,
+ long_to_bytes as long_to_bytes,
+ lookup_unit_table as lookup_unit_table,
+ lowercase_escape as lowercase_escape,
+ make_archive_id as make_archive_id,
+ make_dir as make_dir,
+ match_filter_func as match_filter_func,
+ match_str as match_str,
+ merge_dicts as merge_dicts,
+ merge_headers as merge_headers,
+ mimetype2ext as mimetype2ext,
+ month_by_abbreviation as month_by_abbreviation,
+ month_by_name as month_by_name,
+ multipart_encode as multipart_encode,
+ netrc_from_content as netrc_from_content,
+ number_of_digits as number_of_digits,
+ ohdave_rsa_encrypt as ohdave_rsa_encrypt,
+ orderedSet as orderedSet,
+ orderedSet_from_options as orderedSet_from_options,
+ parse_age_limit as parse_age_limit,
+ parse_bitrate as parse_bitrate,
+ parse_bytes as parse_bytes,
+ parse_codecs as parse_codecs,
+ parse_count as parse_count,
+ parse_dfxp_time_expr as parse_dfxp_time_expr,
+ parse_duration as parse_duration,
+ parse_filesize as parse_filesize,
+ parse_http_range as parse_http_range,
+ parse_iso8601 as parse_iso8601,
+ parse_list as parse_list,
+ parse_m3u8_attributes as parse_m3u8_attributes,
+ parse_qs as parse_qs,
+ parse_resolution as parse_resolution,
+ partial_application as partial_application,
+ pkcs1pad as pkcs1pad,
+ preferredencoding as preferredencoding,
+ prepend_extension as prepend_extension,
+ qualities as qualities,
+ random_birthday as random_birthday,
+ random_uuidv4 as random_uuidv4,
+ read_batch_urls as read_batch_urls,
+ read_stdin as read_stdin,
+ remove_end as remove_end,
+ remove_quotes as remove_quotes,
+ remove_start as remove_start,
+ remove_terminal_sequences as remove_terminal_sequences,
+ render_table as render_table,
+ replace_extension as replace_extension,
+ rot47 as rot47,
+ sanitize_filename as sanitize_filename,
+ sanitize_open as sanitize_open,
+ sanitize_path as sanitize_path,
+ sanitize_url as sanitize_url,
+ scale_thumbnails_to_max_format_width as scale_thumbnails_to_max_format_width,
+ setproctitle as setproctitle,
+ shell_quote as shell_quote,
+ smuggle_url as smuggle_url,
+ srt_subtitles_timecode as srt_subtitles_timecode,
+ str_or_none as str_or_none,
+ str_to_int as str_to_int,
+ strftime_or_none as strftime_or_none,
+ strip_jsonp as strip_jsonp,
+ strip_or_none as strip_or_none,
+ subtitles_filename as subtitles_filename,
+ supports_terminal_sequences as supports_terminal_sequences,
+ system_identifier as system_identifier,
+ time_seconds as time_seconds,
+ timeconvert as timeconvert,
+ timetuple_from_msec as timetuple_from_msec,
+ to_high_limit_path as to_high_limit_path,
+ truncate_string as truncate_string,
+ try_call as try_call,
+ try_get as try_get,
+ unescapeHTML as unescapeHTML,
+ unified_strdate as unified_strdate,
+ unified_timestamp as unified_timestamp,
+ unsmuggle_url as unsmuggle_url,
+ update_url as update_url,
+ update_url_query as update_url_query,
+ uppercase_escape as uppercase_escape,
+ url_basename as url_basename,
+ url_or_none as url_or_none,
+ urlencode_postdata as urlencode_postdata,
+ urlhandle_detect_ext as urlhandle_detect_ext,
+ urljoin as urljoin,
+ urshift as urshift,
+ variadic as variadic,
+ version_tuple as version_tuple,
+ windows_enable_vt_mode as windows_enable_vt_mode,
+ write_json_file as write_json_file,
+ write_string as write_string,
+ write_xattr as write_xattr,
+ xpath_attr as xpath_attr,
+ xpath_element as xpath_element,
+ xpath_text as xpath_text,
+ xpath_with_ns as xpath_with_ns,
+ ytdl_is_updateable as ytdl_is_updateable,
+)
+from .traversal import (
+ dict_get as dict_get,
+ find_element as find_element,
+ find_elements as find_elements,
+ get_first as get_first,
+ require as require,
+ subs_list_to_dict as subs_list_to_dict,
+ traverse_obj as traverse_obj,
+ trim_str as trim_str,
+ unpack as unpack,
+ value as value,
+)
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/_deprecated.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/_deprecated.pyi
new file mode 100644
index 000000000000..9d872396fb01
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/_deprecated.pyi
@@ -0,0 +1,13 @@
+import re
+from collections.abc import Mapping
+from typing import Any
+from typing_extensions import deprecated
+
+@deprecated("Use `list` instead.")
+def bytes_to_intlist(bs: bytes) -> list[int]: ...
+@deprecated("Use `bytes` instead.")
+def intlist_to_bytes(xs: list[int]) -> bytes: ...
+@deprecated("Use `yt_dlp.utils.jwt_encode` instead.")
+def jwt_encode_hs256(payload_data: Any, key: str, headers: Mapping[str, Any] = {}) -> bytes: ... # Passed to json.dumps().
+
+compiled_regex_type: type[re.Pattern[Any]]
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/_legacy.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/_legacy.pyi
new file mode 100644
index 000000000000..838771c834a9
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/_legacy.pyi
@@ -0,0 +1,125 @@
+import ssl
+import types
+import urllib.request
+from _socket import _Address
+from _typeshed import ReadableBuffer, SupportsRead, Unused
+from asyncio.events import AbstractEventLoop
+from collections.abc import AsyncIterable, Awaitable, Callable, Collection, Iterable, Mapping, MutableMapping, Sequence
+from http.client import HTTPResponse
+from http.cookiejar import CookieJar
+from socket import socket
+from subprocess import Popen
+from typing import Any, AnyStr, Generic, Literal, TypeVar, overload
+from typing_extensions import Self
+
+from websockets import ClientConnection, HeadersLike, LoggerLike, Origin, Subprotocol
+from websockets.asyncio.client import connect
+from websockets.extensions import ClientExtensionFactory
+
+has_certifi: bool
+has_websockets: bool
+_T = TypeVar("_T")
+
+class WebSocketsWrapper(Generic[_T]):
+ pool: _T | None
+ loop: AbstractEventLoop
+ conn: connect
+ def __init__(
+ self,
+ url: str,
+ headers: Mapping[str, str] | None = None,
+ connect: bool = True,
+ *,
+ # Passed to websockets.connect()
+ origin: Origin | None = None,
+ extensions: Sequence[ClientExtensionFactory] | None = None,
+ subprotocols: Sequence[Subprotocol] | None = None,
+ compression: str | None = "deflate",
+ additional_headers: HeadersLike | None = None,
+ user_agent_header: str | None = ...,
+ proxy: str | Literal[True] | None = True,
+ process_exception: Callable[[Exception], Exception | None] = ...,
+ open_timeout: float | None = 10,
+ ping_interval: float | None = 20,
+ ping_timeout: float | None = 20,
+ close_timeout: float | None = 10,
+ max_size: int | None = 1048576,
+ max_queue: int | None | tuple[int | None, int | None] = 16,
+ write_limit: int | tuple[int, int | None] = 32768,
+ logger: LoggerLike | None = None,
+ create_connection: type[ClientConnection] | None = None,
+ # Passed to AbstractEventLoop.connect() by websockets
+ ssl: bool | None | ssl.SSLContext = None,
+ family: int = 0,
+ proto: int = 0,
+ flags: int = 0,
+ sock: socket | None = None,
+ 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,
+ ) -> None: ...
+ def __enter__(self) -> Self: ...
+ def send(
+ self, message: str | bytes | Iterable[str | bytes] | AsyncIterable[str | bytes], text: bool | None = None
+ ) -> None: ...
+ @overload
+ def recv(self, decode: Literal[True]) -> str: ...
+ @overload
+ def recv(self, decode: Literal[False]) -> bytes: ...
+ @overload
+ def recv(self, decode: bool | None = None) -> str | bytes: ...
+ def __exit__(
+ self, type: type[BaseException] | None, value: BaseException | None, traceback: types.TracebackType | None
+ ) -> None: ...
+ @staticmethod
+ def run_with_loop(main: Awaitable[_T], loop: AbstractEventLoop) -> _T: ...
+
+def load_plugins(name: str, suffix: str, namespace: dict[str, Any]) -> dict[str, type[Any]]: ...
+def traverse_dict(dictn: Mapping[str, Any], keys: Collection[str], casesense: bool = True) -> Any: ...
+def decode_base(value: str, digits: str) -> int: ...
+def platform_name() -> str: ...
+def get_subprocess_encoding() -> str: ...
+def register_socks_protocols() -> None: ...
+def handle_youtubedl_headers(headers: dict[str, Any]) -> dict[str, Any]: ...
+def request_to_url(req: urllib.request.Request | str) -> str: ...
+def sanitized_Request(
+ url: str,
+ data: ReadableBuffer | SupportsRead[bytes] | Iterable[bytes] | None = None,
+ headers: MutableMapping[str, str] = {},
+ origin_req_host: str | None = None,
+ unverifiable: bool = False,
+ method: str | None = None,
+) -> urllib.request.Request: ...
+
+class YoutubeDLHandler(urllib.request.AbstractHTTPHandler):
+ def __init__(
+ self,
+ params: Mapping[str, Any],
+ *args: Any, # args passed to urllib.request.AbstractHTTPHandler.__init__().
+ context: Any = None,
+ source_address: _Address | None = None,
+ debuglevel: int | None = None,
+ ) -> None: ...
+
+YoutubeDLHTTPSHandler = YoutubeDLHandler
+
+class YoutubeDLCookieProcessor(urllib.request.HTTPCookieProcessor):
+ def __init__(self, cookiejar: CookieJar | None = None) -> None: ...
+ def http_response(self, request: urllib.request.Request, response: HTTPResponse) -> HTTPResponse: ...
+ https_request: Callable[[urllib.request.HTTPCookieProcessor, urllib.request.Request], HTTPResponse] # type: ignore[assignment]
+ https_response = http_response
+
+def make_HTTPS_handler(
+ params: Mapping[str, Any], *, debuglevel: int | None = None, source_address: _Address | None = None
+) -> YoutubeDLHTTPSHandler: ...
+def process_communicate_or_kill(
+ p: Popen[Any], *args: Any, **kwargs: Any # args/kwargs passed to Popen.__init__().
+) -> tuple[AnyStr, AnyStr]: ...
+def encodeFilename(s: str, for_subprocess: Unused = False) -> bytes: ...
+def decodeFilename(b: bytes, for_subprocess: Unused = False) -> str: ...
+def decodeArgument(b: _T) -> _T: ...
+def decodeOption(optval: AnyStr) -> str: ...
+def error_to_compat_str(err: Any) -> str: ... # Calls str(err).
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/_utils.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/_utils.pyi
new file mode 100644
index 000000000000..b29dcb6f519c
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/_utils.pyi
@@ -0,0 +1,730 @@
+import enum
+import html.parser
+import json
+import netrc
+import optparse
+import subprocess
+import sys
+import types
+from _typeshed import (
+ ExcInfo,
+ FileDescriptorLike,
+ FileDescriptorOrPath,
+ OpenBinaryMode,
+ OpenTextMode,
+ ReadableBuffer,
+ StrOrBytesPath,
+ Unused,
+)
+from collections import deque
+from collections.abc import Callable, Collection, Hashable, Iterable, Iterator, Mapping, Sequence
+from datetime import date, datetime, timedelta
+from functools import cache
+from optparse import Values
+from os import PathLike
+from re import Pattern
+from typing import IO, Any, AnyStr, BinaryIO, Generic, Literal, NamedTuple, TextIO, TypeVar, overload
+from typing_extensions import Self, TypeAlias
+from urllib.parse import _QueryType, _QuoteVia
+from xml.etree import ElementTree as ET
+
+from yt_dlp.networking import Response
+
+from .. import _Params
+from ..extractor.common import InfoExtractor, _InfoDict
+from ..globals import WINDOWS_VT_MODE as WINDOWS_VT_MODE
+from ..options import _YoutubeDLOptionParser
+from ..YoutubeDL import YoutubeDL
+
+_T = TypeVar("_T")
+
+class NO_DEFAULT: ...
+
+def IDENTITY(x: _T) -> _T: ...
+
+ENGLISH_MONTH_NAMES: Sequence[str]
+MONTH_NAMES: Mapping[str, Sequence[str]]
+TIMEZONE_NAMES: Mapping[str, str]
+ACCENT_CHARS: Mapping[str, str]
+DATE_FORMATS: Sequence[str]
+DATE_FORMATS_DAY_FIRST: Sequence[str]
+DATE_FORMATS_MONTH_FIRST: Sequence[str]
+PACKED_CODES_RE: str
+JSON_LD_RE: str
+NUMBER_RE: str
+
+@cache
+def preferredencoding() -> str: ...
+def write_json_file(obj: Any, fn: str) -> None: ... # obj passed to json.dump().
+def partial_application(func: Callable[..., Any]) -> Callable[..., Any]: ...
+def find_xpath_attr(node: ET.ElementTree, xpath: str, key: str, val: str | None = None) -> ET.Element | None: ...
+def xpath_with_ns(path: str, ns_map: Mapping[str, str]) -> str: ...
+def xpath_element(
+ node: ET.ElementTree, xpath: str, name: str | None = None, fatal: bool = False, default: ET.Element | type[NO_DEFAULT] = ...
+) -> ET.Element | None: ...
+def xpath_text(
+ node: ET.ElementTree, xpath: str, name: str | None = None, fatal: bool = False, default: str | type[NO_DEFAULT] = ...
+) -> str | None: ...
+def xpath_attr(
+ node: ET.ElementTree,
+ xpath: str,
+ key: str,
+ name: str | None = None,
+ fatal: bool = False,
+ default: str | type[NO_DEFAULT] = ...,
+) -> str | None: ...
+def get_element_by_id(id: str, html: str, *, tag: str, escape_value: bool = True) -> str | None: ...
+def get_element_html_by_id(id: str, html: str, *, tag: str, escape_value: bool = True) -> str | None: ...
+def get_element_by_class(class_name: str, html: str) -> str: ...
+def get_element_html_by_class(class_name: str, html: str) -> str: ...
+def get_element_by_attribute(attribute: str, value: str, html: str, *, tag: str, escape_value: bool = True) -> str: ...
+def get_element_html_by_attribute(attribute: str, value: str, html: str, *, tag: str, escape_value: bool = True) -> list[str]: ...
+def get_elements_by_class(class_name: str, html: str, **kargs: Unused) -> list[str]: ...
+def get_elements_html_by_class(class_name: str, html: str) -> list[str]: ...
+def get_elements_by_attribute(attribute: str, value: str, html: str, *, tag: str, escape_value: bool = True) -> list[str]: ...
+def get_elements_html_by_attribute(
+ attribute: str, value: str, html: str, *, tag: str = "[\\w:.-]+", escape_value: bool = True
+) -> list[str]: ...
+def get_elements_text_and_html_by_attribute(
+ attribute: str, value: str, html: str, *, tag: str = "[\\w:.-]+", escape_value: bool = True
+) -> Iterator[str]: ...
+
+class HTMLBreakOnClosingTagParser(html.parser.HTMLParser):
+ class HTMLBreakOnClosingTagException(Exception): ...
+ tagstack: deque[Any]
+ def __init__(self) -> None: ...
+ def __enter__(self) -> Self: ...
+ def __exit__(self, *_: Unused) -> None: ...
+ def close(self) -> None: ...
+ def handle_starttag(self, tag: str, _: Unused) -> None: ...
+ def handle_endtag(self, tag: str) -> None: ...
+
+def get_element_text_and_html_by_tag(tag: str, html: str) -> str: ...
+
+class HTMLAttributeParser(html.parser.HTMLParser):
+ attrs: dict[str, str | None]
+ def __init__(self) -> None: ...
+ def handle_starttag(self, tag: str, attrs: list[tuple[str, str | None]]) -> None: ...
+
+class HTMLListAttrsParser(html.parser.HTMLParser):
+ items: list[dict[str, str | None]]
+ def __init__(self) -> None: ...
+ def handle_starttag(self, tag: str, attrs: list[tuple[str, str | None]]) -> None: ...
+ def handle_endtag(self, tag: str) -> None: ...
+
+def extract_attributes(html_element: str) -> dict[str, str]: ...
+def parse_list(webpage: str) -> list[dict[str, str | None]]: ...
+def clean_html(html: str | None) -> str | None: ...
+
+class LenientJSONDecoder(json.JSONDecoder):
+ def __init__(
+ self,
+ *args: Unused,
+ transform_source: Callable[[str], str] | None = None,
+ ignore_extra: bool = False,
+ close_objects: int = 0,
+ object_hook: Callable[[dict[str, Any]], Any] | None = None,
+ parse_float: Callable[[str], Any] | None = None,
+ parse_int: Callable[[str], Any] | None = None,
+ parse_constant: Callable[[str], Any] | None = None,
+ strict: bool = True,
+ object_pairs_hook: Callable[[list[tuple[str, Any]]], Any] | None = None,
+ ) -> None: ...
+ def decode(self, s: str) -> Any: ... # type: ignore[override]
+
+@overload
+def sanitize_open(filename: FileDescriptorOrPath, open_mode: OpenBinaryMode) -> BinaryIO: ...
+@overload
+def sanitize_open(filename: FileDescriptorOrPath, open_mode: OpenTextMode) -> TextIO: ...
+def timeconvert(timestr: str) -> str: ...
+def sanitize_filename(s: str, restricted: bool = False, is_id: bool | type[NO_DEFAULT] = ...) -> str: ...
+def sanitize_path(s: str, force: bool = False) -> str: ...
+def sanitize_url(url: str, *, scheme: str = "http") -> str: ...
+def extract_basic_auth(url: str) -> tuple[str, str | None]: ...
+def expand_path(s: str) -> str: ...
+def orderedSet(iterable: Iterable[_T], *, lazy: bool = False) -> Iterator[_T]: ...
+def unescapeHTML(s: str | None) -> str | None: ...
+def escapeHTML(text: str) -> str: ...
+
+class netrc_from_content(netrc.netrc):
+ def __init__(self, content: str) -> None: ...
+
+def encodeArgument(s: str) -> str: ...
+
+class _timetuple(NamedTuple):
+ hours: tuple[int, int]
+ minutes: tuple[int, int]
+ seconds: tuple[int, int]
+ milliseconds: tuple[int, int]
+
+def timetuple_from_msec(msec: int) -> _timetuple: ...
+def formatSeconds(secs: int, delim: str = ":", msec: bool = False) -> str: ...
+def bug_reports_message(before: str = ";") -> None: ...
+
+class YoutubeDLError(Exception):
+ msg: str | None
+ def __init__(self, msg: str | None = None) -> None: ...
+
+class ExtractorError(YoutubeDLError):
+ orig_msg: Any
+ traceback: types.TracebackType | None
+ expected: Any
+ cause: Exception | str | None
+ video_id: str
+ ie: InfoExtractor
+ exc_info: ExcInfo
+ def __init__(
+ self,
+ msg: str,
+ tb: types.TracebackType | None = None,
+ expected: bool = False,
+ cause: Exception | str | None = None,
+ video_id: str | None = None,
+ ie: InfoExtractor | None = None,
+ ) -> None: ...
+ def format_traceback(self) -> str: ...
+ msg: str | None
+ args: tuple[Any, ...]
+ def __setattr__(self, name: str, value: Any) -> None: ...
+
+class UnsupportedError(ExtractorError):
+ url: str
+ def __init__(self, url: str) -> None: ...
+
+class RegexNotFoundError(ExtractorError): ...
+
+class GeoRestrictedError(ExtractorError):
+ countries: str | None
+ def __init__(
+ self,
+ msg: str,
+ countries: str | None = None,
+ *,
+ tb: types.TracebackType | None = None,
+ expected: bool = False,
+ cause: Exception | str | None = None,
+ video_id: str | None = None,
+ ie: InfoExtractor | None = None,
+ ) -> None: ...
+
+class UserNotLive(ExtractorError):
+ def __init__(
+ self,
+ msg: str | None = None,
+ *,
+ tb: types.TracebackType | None = None,
+ expected: bool = False,
+ cause: Exception | str | None = None,
+ video_id: str | None = None,
+ ie: InfoExtractor | None = None,
+ ) -> None: ...
+
+class DownloadError(YoutubeDLError):
+ exc_info: ExcInfo
+ def __init__(self, msg: str, exc_info: ExcInfo | None = None) -> None: ...
+
+class EntryNotInPlaylist(YoutubeDLError):
+ msg: str
+
+class SameFileError(YoutubeDLError):
+ msg: str
+ def __init__(self, filename: str | None = None) -> None: ...
+
+class PostProcessingError(YoutubeDLError): ...
+
+class DownloadCancelled(YoutubeDLError):
+ msg: str
+
+class ExistingVideoReached(DownloadCancelled):
+ msg: str
+
+class RejectedVideoReached(DownloadCancelled):
+ msg: str
+
+class MaxDownloadsReached(DownloadCancelled):
+ msg: str
+
+class ReExtractInfo(YoutubeDLError):
+ expected: bool
+ def __init__(self, msg: str, expected: bool = False) -> None: ...
+
+class ThrottledDownload(ReExtractInfo):
+ msg: str
+ def __init__(self) -> None: ...
+
+class UnavailableVideoError(YoutubeDLError):
+ msg: str
+ def __init__(self, err: str | None = None) -> None: ...
+
+class ContentTooShortError(YoutubeDLError):
+ downloaded: int
+ expected: int
+ def __init__(self, downloaded: int, expected: int) -> None: ...
+
+class XAttrMetadataError(YoutubeDLError):
+ code: str | None
+ msg: str | None
+ reason: str
+ def __init__(self, code: str | None = None, msg: str = "Unknown error") -> None: ...
+
+class XAttrUnavailableError(YoutubeDLError): ...
+
+def is_path_like(f: Any) -> bool: ... # Type checker.
+def extract_timezone(date_str: str, default: Any = None) -> tuple[timedelta, str]: ... # Any or type[NO_DEFAULT]
+def parse_iso8601(date_str: str, delimiter: str = "T", timezone: type[NO_DEFAULT] | Any | None = None) -> int: ...
+def date_formats(day_first: bool = True) -> list[str]: ...
+def unified_strdate(date_str: str, day_first: bool = True) -> str: ...
+def unified_timestamp(date_str: str, day_first: bool = True) -> int: ...
+def determine_ext(url: str, default_ext: str = "unknown_video") -> str: ...
+def subtitles_filename(filename: str, sub_lang: str, sub_format: str, expected_real_ext: str | None = None) -> str: ...
+def datetime_from_str(date_str: str, precision: str = "auto", format: str = "%Y%m%d") -> datetime: ...
+def date_from_str(date_str: str, format: str = "%Y%m%d", strict: bool = False) -> date: ...
+def datetime_add_months(dt_: datetime, months: int) -> datetime: ...
+def datetime_round(dt_: datetime, precision: str = "day") -> datetime: ...
+def hyphenate_date(date_str: str) -> str: ...
+
+class DateRange:
+ start: date
+ end: date
+ def __init__(self, start: date | None = None, end: date | None = None) -> None: ...
+ @classmethod
+ def day(cls, day: date) -> Self: ...
+ def __contains__(self, date: date) -> bool: ...
+ def __eq__(self, other: object) -> bool: ...
+
+def system_identifier() -> str: ...
+def get_windows_version() -> tuple[str, ...]: ...
+def write_string(s: str, out: TextIO | None = None, encoding: str | None = None) -> None: ...
+def deprecation_warning(
+ msg: str, *, printer: Callable[..., Any] | None = None, stacklevel: int = 0, **kwargs: Any # kwargs are passed to printer.
+) -> None: ...
+
+class LockingUnsupportedError(OSError):
+ msg: str
+ def __init__(self) -> None: ...
+
+class locked_file:
+ locked: bool
+ f: TextIO
+ def __init__(
+ self, filename: AnyStr, mode: OpenTextMode | OpenBinaryMode, block: bool = True, encoding: str | None = None
+ ) -> None: ...
+ def __enter__(self) -> Self: ...
+ def unlock(self) -> None: ...
+ def __exit__(self, *_: Unused) -> None: ...
+ open = __enter__
+ close = __exit__
+ def __getattr__(self, attr: str) -> Any: ...
+ def __iter__(self) -> str: ...
+
+def get_filesystem_encoding() -> str: ...
+def shell_quote(args: str | Collection[str], *, shell: bool = False) -> str: ...
+def smuggle_url(url: str, data: Any) -> str: ... # data may be anything JSON serializable.
+
+# default is simply returned if #__youtubedl_smuggle is present.
+def unsmuggle_url(smug_url: str, default: Any | None = None) -> tuple[str, Any]: ...
+def format_decimal_suffix(num: float, fmt: str = "%d%s", *, factor: int = 1000) -> str: ...
+def format_bytes(bytes: int) -> str: ...
+def lookup_unit_table(unit_table: Mapping[str, int], s: str, strict: bool = False) -> float: ...
+def parse_bytes(s: str) -> int: ...
+def parse_filesize(s: str | None) -> int | None: ...
+def parse_count(s: str | None) -> str | None: ...
+def parse_resolution(s: str, *, lenient: bool = False) -> dict[str, int]: ...
+def parse_bitrate(s: str) -> int: ...
+def month_by_name(name: str, lang: str = "en") -> str | None: ...
+def month_by_abbreviation(abbrev: str) -> str | None: ...
+def fix_xml_ampersands(xml_str: str) -> str: ...
+def setproctitle(title: str) -> None: ...
+def remove_start(s: str, start: str) -> str: ...
+def remove_end(s: str, end: str) -> str: ...
+def remove_quotes(s: str) -> str: ...
+def get_domain(url: str) -> str | None: ...
+def url_basename(url: str) -> str: ...
+def base_url(url: str) -> str: ...
+def urljoin(base: str, path: str) -> str: ...
+def int_or_none(
+ v: Any, scale: int = 1, default: int | None = None, get_attr: str | None = None, invscale: int = 1, base: int | None = None
+) -> int | None: ...
+def str_or_none(v: Any, default: str | None = None) -> str: ...
+def str_to_int(int_str: str) -> int: ...
+def float_or_none(v: Any, scale: int = 1, invscale: int = 1, default: float | None = None) -> float | None: ...
+def bool_or_none(v: Any, default: bool | None = None) -> bool | None: ...
+def strip_or_none(v: Any, default: str | None = None) -> str | None: ...
+def url_or_none(url: Any) -> str | None: ...
+def strftime_or_none(timestamp: int, date_format: str = "%Y%m%d", default: str | None = None) -> str | None: ...
+def parse_duration(s: str | None) -> float: ...
+def prepend_extension(filename: str, ext: str, expected_real_ext: str | None = None) -> str: ...
+def replace_extension(filename: str, ext: str, expected_real_ext: str | None = None) -> str: ...
+def check_executable(exe: str, args: Iterable[str] = []) -> str | None: ...
+def detect_exe_version(output: str, version_re: str | Pattern[str] | None = None, unrecognized: str = "present") -> str: ...
+def get_exe_version(
+ exe: str,
+ args: Iterable[str] = ["--version"],
+ version_re: str | None = None,
+ unrecognized: Iterable[str] = ("present", "broken"),
+) -> str: ...
+def frange(start: int = 0, stop: int | None = None, step: int = 1) -> Iterator[float]: ...
+
+class LazyList(Sequence[_T]):
+ def __init__(self, iterable: Iterable[_T], *, reverse: bool = False, _cache: list[Any] | None = None) -> None: ...
+ def __iter__(self) -> Iterator[_T]: ...
+ def exhaust(self) -> list[_T]: ...
+ @overload
+ def __getitem__(self, idx: int, /) -> _T: ...
+ @overload
+ def __getitem__(self, idx: slice, /) -> list[_T]: ...
+ def __bool__(self) -> bool: ...
+ def __len__(self) -> int: ...
+ def __reversed__(self) -> Iterator[_T]: ...
+ def __copy__(self) -> Self: ...
+
+class PagedList:
+ def __len__(self) -> int: ...
+ def __init__(self, pagefunc: Callable[[int], Iterator[Any]], pagesize: int, use_cache: bool = True) -> None: ...
+ def getpage(self, pagenum: int) -> list[Any]: ...
+ def getslice(self, start: int = 0, end: int | None = None) -> list[Any]: ...
+ @overload
+ def __getitem__(self, idx: int, /) -> Any: ...
+ @overload
+ def __getitem__(self, idx: slice, /) -> list[Any]: ...
+ def __bool__(self) -> bool: ...
+
+class OnDemandPagedList(PagedList): ...
+
+class InAdvancePagedList(PagedList):
+ def __init__(self, pagefunc: Callable[[int], Iterator[Any]], pagecount: int, pagesize: int) -> None: ...
+
+class PlaylistEntries:
+ MissingEntry: Any
+ is_exhausted: bool
+ ydl: YoutubeDL
+ is_incomplete: bool
+ def __init__(self, ydl: YoutubeDL, info_dict: _InfoDict) -> None: ...
+ PLAYLIST_ITEMS_RE: Pattern[str]
+ @classmethod
+ def parse_playlist_items(cls, string: str) -> slice | int: ...
+ def get_requested_items(self) -> Iterator[tuple[int, Any]]: ...
+ def get_full_count(self) -> int | None: ...
+ def __getitem__(self, idx: int) -> Iterator[tuple[int, Any]]: ...
+ def __len__(self) -> int: ...
+
+_K = TypeVar("_K")
+_V = TypeVar("_V")
+
+def uppercase_escape(s: str) -> str: ...
+def lowercase_escape(s: str) -> str: ...
+def parse_qs(
+ url: str,
+ *,
+ keep_blank_values: bool = False,
+ strict_parsing: bool = False,
+ encoding: str = "utf-8",
+ errors: str = "replace",
+ max_num_fields: int | None = None,
+ separator: str = "&",
+) -> dict[AnyStr, list[AnyStr]]: ...
+def read_batch_urls(batch_fd: FileDescriptorLike) -> list[str]: ...
+def urlencode_postdata(
+ query: _QueryType,
+ doseq: bool = False,
+ safe: str | bytes = "",
+ encoding: str | None = None,
+ errors: str | None = None,
+ quote_via: _QuoteVia = ...,
+) -> bytes: ...
+
+# Passes kwargs to NamedTuple._replace().
+def update_url(url: str, *, query_update: Mapping[str, str] | None = None, **kwargs: Any) -> str: ...
+def update_url_query(url: str, query: Mapping[str, str]) -> str: ...
+def multipart_encode(data: Mapping[AnyStr, AnyStr], boundary: str | None = None) -> tuple[bytes, str]: ...
+def is_iterable_like(
+ x: Any, allowed_types: Collection[type[Any]] = ..., blocked_types: Collection[type[Any]] | type[NO_DEFAULT] = ...
+) -> bool: ...
+def variadic(x: _T, allowed_types: Collection[type[Any]] | type[NO_DEFAULT] = ...) -> _T | tuple[_T]: ...
+def try_call(
+ *funcs: Callable[..., _T],
+ expected_type: type[_T] | None = None,
+ args: Iterable[Any] = [],
+ kwargs: Mapping[Hashable, Any] = {},
+) -> _T | None: ...
+def try_get(src: Any, getter: Callable[..., _T] | Collection[Callable[..., _T]], expected_type: type[_T] | None = None) -> _T: ...
+def filter_dict(dct: Mapping[_K, _V], cndn: Callable[[_K, _V], bool] = ...) -> dict[_K, _V]: ...
+def merge_dicts(*dicts: Mapping[Hashable, Any]) -> dict[Hashable, Any]: ...
+def encode_compat_str(string: str, encoding: str = ..., errors: str = "strict") -> str: ...
+
+US_RATINGS: Mapping[str, int]
+TV_PARENTAL_GUIDELINES: Mapping[str, int]
+
+def parse_age_limit(s: int) -> int | None: ...
+def strip_jsonp(code: str) -> str: ...
+def js_to_json(code: str, vars: Mapping[str, Any] = {}, *, strict: bool = False) -> str: ...
+def qualities(quality_ids: Sequence[int]) -> Callable[[int], int]: ...
+
+POSTPROCESS_WHEN: tuple[str, ...]
+DEFAULT_OUTTMPL: Mapping[str, str]
+OUTTMPL_TYPES: Mapping[str, str | None]
+STR_FORMAT_RE_TMPL: str
+STR_FORMAT_TYPES: str
+
+def limit_length(s: str, length: int) -> str: ...
+def version_tuple(v: str) -> tuple[int, ...]: ...
+def is_outdated_version(version: str, limit: str, assume_new: bool = True) -> bool: ...
+def ytdl_is_updateable() -> bool: ...
+def args_to_str(args: str | Collection[str]) -> str: ...
+def error_to_str(err: BaseException) -> str: ...
+def mimetype2ext(mt: str, default: str | type[NO_DEFAULT] = ...) -> str: ...
+def ext2mimetype(ext_or_url: str | None) -> str: ...
+def parse_codecs(codecs_str: str) -> dict[str, str]: ...
+def get_compatible_ext(
+ *,
+ vcodecs: Collection[str],
+ acodecs: Collection[str],
+ vexts: Collection[str],
+ aexts: Collection[str],
+ preferences: Sequence[str] | None = None,
+) -> str: ...
+def urlhandle_detect_ext(url_handle: Response, default: str | type[NO_DEFAULT] = ...) -> str | None: ...
+def encode_data_uri(data: ReadableBuffer, mime_type: str) -> str: ...
+def age_restricted(content_limit: int | None, age_limit: int | None) -> bool: ...
+
+BOMS: Collection[tuple[bytes, str]]
+
+def is_html(first_bytes: bytes) -> bool: ...
+def determine_protocol(info_dict: _InfoDict) -> str: ...
+def render_table(
+ header_row: Iterable[str], data: Iterable[str], delim: bool = False, extra_gap: int = 0, hide_empty: bool = False
+) -> str: ...
+def match_str(filter_str: str, dct: Mapping[str, Any], incomplete: bool = False) -> bool: ...
+def match_filter_func(
+ filters: Collection[str] | str, breaking_filters: Collection[str] | str | None = None
+) -> Callable[..., str | type[NO_DEFAULT] | None]: ...
+
+class download_range_func:
+ def __init__(
+ self, chapters: Iterable[str | Pattern[str]], ranges: Iterable[tuple[int, int]], from_info: bool = False
+ ) -> None: ...
+ def __call__(self, info_dict: _InfoDict, ydl: YoutubeDL) -> Iterator[dict[str, Any]]: ...
+ def __eq__(self, other: object) -> bool: ...
+
+def parse_dfxp_time_expr(time_expr: str | None) -> int | None: ...
+def srt_subtitles_timecode(seconds: float) -> str: ...
+def ass_subtitles_timecode(seconds: float) -> str: ...
+def dfxp2srt(dfxp_data: bytes) -> str: ...
+def cli_option(params: _Params, command_option: str, param: str, separator: str | None = None) -> Any: ...
+def cli_bool_option(
+ params: _Params,
+ command_option: str,
+ param: bool | None,
+ true_value: str = "true",
+ false_value: str = "false",
+ separator: str | None = None,
+) -> Any: ...
+def cli_valueless_option(params: _Params, command_option: str, param: str, expected_value: bool = True) -> Any: ...
+def cli_configuration_args(argdict: dict[str, Any], keys: Iterable[str], default: Any = [], use_compat: bool = True) -> Any: ...
+
+class ISO639Utils:
+ @classmethod
+ def short2long(cls, code: str) -> str | None: ...
+ @classmethod
+ def long2short(cls, code: str) -> str | None: ...
+
+class ISO3166Utils:
+ @classmethod
+ def short2full(cls, code: str) -> str | None: ...
+
+class GeoUtils:
+ @classmethod
+ def random_ipv4(cls, code_or_block: str) -> str | None: ...
+
+def long_to_bytes(n: int, blocksize: int = 0) -> bytes: ...
+def bytes_to_long(s: bytes) -> int: ...
+def ohdave_rsa_encrypt(data: ReadableBuffer, exponent: float, modulus: float | None) -> str: ...
+def pkcs1pad(data: Sequence[int], length: int) -> list[int]: ...
+def encode_base_n(num: int, n: int | None = None, table: str | None = None) -> str: ...
+def decode_base_n(string: str, n: int | None = None, table: str | None = None) -> int: ...
+def decode_packed_codes(code: str) -> str: ...
+def caesar(s: str, alphabet: str, shift: int) -> str: ...
+def rot47(s: str) -> str: ...
+def parse_m3u8_attributes(attrib: str) -> dict[str, str]: ...
+def urshift(val: int, n: int) -> int: ...
+def write_xattr(path: FileDescriptorOrPath, key: str, value: str) -> None: ...
+def random_birthday(year_field: Hashable, month_field: Hashable, day_field: Hashable) -> dict[Hashable, str]: ...
+def find_available_port(interface: str = "") -> Any | None: ...
+
+DOT_URL_LINK_TEMPLATE: str
+DOT_WEBLOC_LINK_TEMPLATE: str
+DOT_DESKTOP_LINK_TEMPLATE: str
+LINK_TEMPLATES: Mapping[str, str]
+
+def iri_to_uri(iri: str) -> str: ...
+def to_high_limit_path(path: PathLike[AnyStr]) -> str: ...
+def format_field(
+ obj: Mapping[str, Any] | Sequence[Any],
+ field: str | Collection[str] | None = None,
+ template: str = "%s",
+ ignore: type[NO_DEFAULT] | str | Collection[str] = ...,
+ default: str = "",
+ func: Callable[[Any], Any] = ...,
+) -> str: ...
+def clean_podcast_url(url: str) -> str: ...
+def random_uuidv4() -> str: ...
+def make_dir(path: PathLike[AnyStr], to_screen: Callable[[str], Any] | None = None) -> bool: ...
+def get_executable_path() -> str: ...
+def get_user_config_dirs(package_name: str) -> Iterator[str]: ...
+def get_system_config_dirs(package_name: str) -> Iterator[str]: ...
+def time_seconds(**kwargs: float) -> int: ...
+def jwt_encode(
+ payload_data: Any, key: str, *, alg: Literal["HS256"] = "HS256", headers: Mapping[str, Any] | None = None
+) -> str: ... # payload_data and headers are passed to json.dumps().
+def jwt_decode_hs256(jwt: str) -> Any: ... # Returns json.loads() output.
+def supports_terminal_sequences(stream: IO[Any]) -> bool: ...
+def windows_enable_vt_mode() -> None: ...
+def remove_terminal_sequences(string: str) -> str: ...
+def number_of_digits(number: int) -> int: ...
+def join_nonempty(*values: str, delim: str = "-", from_dict: Mapping[str, Any] | None = None) -> str: ...
+def scale_thumbnails_to_max_format_width(
+ formats: Iterable[Mapping[str, Any]], thumbnails: Iterable[Mapping[str, Any]], url_width_re: str | Pattern[str]
+) -> list[dict[str, Any]]: ...
+def parse_http_range(range: str | None) -> tuple[int | None, int | None, int | None]: ...
+def read_stdin(what: str) -> TextIO | Any: ...
+def determine_file_encoding(data: bytes) -> tuple[str | None, int]: ...
+
+class Config:
+ own_args: Sequence[str] | None
+ parsed_args: tuple[Values, list[str]] | None
+ filename: str | None
+ def __init__(self, parser: _YoutubeDLOptionParser, label: str | None = None) -> None: ...
+ def init(self, args: Sequence[str] | None = None, filename: str | None = None) -> bool: ...
+ def load_configs(self) -> bool: ...
+ @staticmethod
+ def read_file(filename: FileDescriptorOrPath, default: list[str] = []) -> list[str]: ...
+ @staticmethod
+ def hide_login_info(opts: Iterable[str]) -> list[str]: ...
+ def append_config(self, args: Sequence[str] | None, filename: str | None, *, label: str | None = None) -> None: ...
+ @property
+ def all_args(self) -> Iterator[str]: ...
+ def parse_known_args(self, *, values: optparse.Values | None = None, strict: bool = True) -> tuple[Values, list[str]]: ...
+ def parse_args(self) -> tuple[Values, list[str]]: ...
+
+def merge_headers(*dicts: dict[str, Any]) -> dict[str, Any]: ...
+def cached_method(f: Callable[..., Any]) -> Callable[..., Any]: ...
+
+class function_with_repr(Generic[_T]):
+ def __init__(self, func: Callable[..., _T], repr_: str | None = None) -> None: ...
+ def __call__(self, *args: Any, **kwargs: Any) -> _T: ... # Arbitrary arguments.
+ @classmethod
+ def set_repr(cls, repr_: str) -> Callable[..., Any]: ...
+
+class Namespace(types.SimpleNamespace):
+ def __iter__(self) -> Iterator[Any]: ...
+ @property
+ def items_(self) -> dict[str, Any]: ...
+
+MEDIA_EXTENSIONS: Namespace
+KNOWN_EXTENSIONS: tuple[str, ...]
+
+class _UnsafeExtensionError(Exception):
+ ALLOWED_EXTENSIONS: frozenset[str]
+ extension: str
+ def __init__(self, extension: str, /) -> None: ...
+ @classmethod
+ def sanitize_extension(cls, extension: str, /, *, prepend: bool = False) -> str: ...
+
+class RetryManager:
+ attempt: int
+ retries: int
+ error_callback: Callable[[BaseException, int, int], Any]
+ def __init__(
+ self, _retries: int | None, _error_callback: Callable[..., Any], **kwargs: Any # kwargs passed to _error_callback.
+ ) -> None: ...
+ @property
+ def error(self) -> None: ...
+ @error.setter
+ def error(self, value: type[NO_DEFAULT] | BaseException) -> None: ...
+ def __iter__(self) -> Self: ...
+ @staticmethod
+ def report_retry(
+ e: BaseException,
+ count: int,
+ retries: int,
+ *,
+ sleep_func: Callable[..., float | None],
+ info: Callable[[str], Any],
+ warn: Callable[[str], Any],
+ error: Callable[[str], Any] | None = None,
+ suffix: str | None = None,
+ ) -> None: ...
+
+def make_archive_id(ie: InfoExtractor, video_id: str) -> str: ...
+def truncate_string(s: str, left: int, right: int = 0) -> str: ...
+def orderedSet_from_options(
+ options: Sequence[str], alias_dict: dict[str, Sequence[str]], *, use_regex: bool = False, start: Iterable[Any] | None = None
+) -> Iterator[Any]: ...
+
+class FormatSorter:
+ regex: str
+ default: tuple[str, ...]
+ ytdl_default: tuple[str, ...]
+ settings: dict[str, Any]
+ ydl: YoutubeDL
+ def __init__(self, ydl: YoutubeDL, field_preference: _Params) -> None: ...
+ def evaluate_params(self, params: _Params, sort_extractor: Collection[str]) -> None: ...
+ def print_verbose_info(self, write_debug: Callable[..., None]) -> None: ...
+ def calculate_preference(self, format: dict[str, Any]) -> tuple[int, ...]: ...
+
+@overload
+def filesize_from_tbr(tbr: None, duration: None) -> None: ...
+@overload
+def filesize_from_tbr(tbr: int, duration: None) -> None: ...
+@overload
+def filesize_from_tbr(tbr: None, duration: int) -> None: ...
+@overload
+def filesize_from_tbr(tbr: int | None, duration: int | None) -> int | None: ...
+
+class _YDLLogger:
+ def __init__(self, ydl: YoutubeDL | None = None) -> None: ...
+ def debug(self, message: str) -> None: ...
+ def info(self, message: str) -> None: ...
+ def warning(self, message: str, *, once: bool = False) -> None: ...
+ def error(self, message: str, *, is_error: bool = True) -> None: ...
+ def stdout(self, message: str) -> None: ...
+ def stderr(self, message: str) -> None: ...
+
+class _ProgressState(enum.Enum):
+ HIDDEN = 0
+ INDETERMINATE = 3
+ VISIBLE = 1
+ WARNING = 4
+ ERROR = 2
+ @classmethod
+ def from_dict(cls, s: dict[str, Any], /) -> _ProgressState: ...
+ def get_ansi_escape(self, /, percent: int | None = None) -> str: ...
+
+if sys.platform == "win32":
+ _ENV: TypeAlias = Mapping[str, str]
+else:
+ _ENV: TypeAlias = Mapping[bytes, StrOrBytesPath] | Mapping[str, StrOrBytesPath]
+
+class Popen(subprocess.Popen[AnyStr]):
+ def __init__(
+ self,
+ args: StrOrBytesPath | Sequence[StrOrBytesPath],
+ *remaining: Any, # Passed to subprocess.Popen.__init__().
+ env: _ENV | None = None,
+ text: bool = False,
+ shell: bool = False,
+ **kwargs: Any, # Passed to subprocess.Popen.__init__().
+ ) -> None: ...
+ def communicate_or_kill(self, input: AnyStr | None = None, timeout: float | None = None) -> tuple[AnyStr, AnyStr]: ...
+ def kill(self, *, timeout: int = 0) -> None: ...
+ # kwargs passed to cls.__init__().
+ @classmethod
+ def run(cls, *args: Any, timeout: int | None = None, **kwargs: Any) -> tuple[AnyStr, AnyStr]: ...
+
+class classproperty:
+ # args passed to func().
+ def __new__(cls, func: Callable[..., Any] | None = None, *args: Any, cache: bool = False) -> Self: ...
+ def __init__( # pyright: ignore[reportInconsistentConstructor]
+ self, func: Callable[..., Any], *, cache: bool = False
+ ) -> None: ...
+ def __get__(self, _: Unused, cls: type[Any]) -> Any: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/jslib/__init__.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/jslib/__init__.pyi
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/jslib/devalue.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/jslib/devalue.pyi
new file mode 100644
index 000000000000..5ca1e8a6d36d
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/jslib/devalue.pyi
@@ -0,0 +1,9 @@
+from collections.abc import Callable, Generator
+from typing import Any
+
+def parse_iter(
+ parsed: Any, /, *, revivers: dict[str, Callable[[list[Any]], Any]] | None = None # parsed: Any from the signature.
+) -> Generator[TypeError | IndexError | ValueError, Any, float | None]: ...
+def parse(
+ parsed: Any, /, *, revivers: dict[str, Callable[[Any], Any]] | None = None # parsed: Any from the signature.
+) -> Any: ... # returns StopIteration.value if it is raised.
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/networking.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/networking.pyi
new file mode 100644
index 000000000000..1d3d18310dd3
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/networking.pyi
@@ -0,0 +1,44 @@
+from collections.abc import Mapping
+from typing import Any, TypeVar, overload
+from typing_extensions import Self
+
+from ._utils import NO_DEFAULT
+
+def random_user_agent() -> str: ...
+
+_T = TypeVar("_T")
+
+class HTTPHeaderDict(dict[str, str]):
+ # *args and **kwargs are passed to dict.__init__().
+ def __new__(cls, *args: Any, **kwargs: Any) -> Self: ...
+ # *args is passed to filter: filter(None, args)
+ def __init__(self, /, *args: Any, **kwargs: str) -> None: ...
+ def sensitive(self, /) -> dict[str, str]: ...
+ @overload # type: ignore[override]
+ def get(self, key: str, /) -> str | None: ...
+ @overload
+ def get(self, key: str, /, default: _T) -> str | _T: ...
+ @overload
+ def get(self, key: str, /, default: type[NO_DEFAULT] | _T = ...) -> str | _T | type[NO_DEFAULT]: ...
+ @overload
+ def pop(self, key: str, /) -> str: ...
+ @overload
+ def pop(self, key: str, /, default: _T) -> str | _T: ...
+ @overload
+ def pop(self, key: str, /, default: type[NO_DEFAULT] | _T | str = ...) -> str | _T | type[NO_DEFAULT]: ...
+ @overload
+ def setdefault(self, key: str, /) -> str: ...
+ @overload
+ def setdefault(self, key: str, /, default: str) -> str: ...
+ @overload
+ def setdefault(self, key: str, /, default: str | None = None) -> str: ...
+ def update(self, other: Mapping[str, str], /, **kwargs: str) -> None: ... # type: ignore[override]
+
+std_headers: HTTPHeaderDict
+
+def clean_proxies(proxies: dict[str, Any], headers: HTTPHeaderDict) -> None: ...
+def clean_headers(headers: HTTPHeaderDict) -> None: ...
+def remove_dot_segments(path: str) -> str: ...
+def escape_rfc3986(s: str) -> str: ...
+def normalize_url(url: str) -> str: ...
+def select_proxy(url: str, proxies: Mapping[str, Any]) -> str: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/progress.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/progress.pyi
new file mode 100644
index 000000000000..bb213136def3
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/progress.pyi
@@ -0,0 +1,22 @@
+class ProgressCalculator:
+ SAMPLING_WINDOW: int
+ SAMPLING_RATE: float
+ GRACE_PERIOD: int
+ downloaded: int
+ elapsed: float
+ speed: SmoothValue
+ eta: SmoothValue
+ def __init__(self, initial: int) -> None: ...
+ @property
+ def total(self) -> int | None: ...
+ @total.setter
+ def total(self, value: int | None) -> None: ...
+ def thread_reset(self) -> None: ...
+ def update(self, size: int | None) -> None: ...
+
+class SmoothValue:
+ value: float | None
+ def __init__(self, initial: float | None, smoothing: float) -> None: ...
+ smooth: float | None
+ def set(self, value: float) -> None: ...
+ def reset(self) -> None: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/traversal.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/traversal.pyi
new file mode 100644
index 000000000000..a59073a2b380
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/utils/traversal.pyi
@@ -0,0 +1,88 @@
+from collections.abc import Callable, Collection, Iterable, Mapping
+from typing import Any, TypeVar, overload
+from typing_extensions import TypeAlias
+
+from ._utils import NO_DEFAULT, ExtractorError
+
+_Traversable: TypeAlias = Mapping[str, Any] | Iterable[Any]
+_PathArg: TypeAlias = str | int
+
+def traverse_obj(
+ obj: _Traversable,
+ *paths: _PathArg,
+ default: Any = ..., # Anything or type[NO_DEFAULT]
+ expected_type: type[Any] | None = None,
+ get_all: bool = True,
+ casesense: bool = True,
+ is_user_input: bool | type[NO_DEFAULT] = ...,
+ traverse_string: bool = False,
+) -> Any: ... # Unknown return type
+
+_T = TypeVar("_T")
+
+def value(value: _T, /) -> _T: ...
+def require(name: str, /, *, expected: bool = False) -> Callable[[_T], _T]: ...
+
+class _RequiredError(ExtractorError): ...
+
+@overload
+def subs_list_to_dict(
+ *, lang: str | None = "und", ext: str | None = None
+) -> Callable[[list[dict[str, Any]]], dict[str, list[dict[str, Any]]]]: ...
+@overload
+def subs_list_to_dict(
+ subs: list[dict[str, Any]] | None, /, *, lang: str | None = "und", ext: str | None = None
+) -> dict[str, list[dict[str, Any]]]: ...
+@overload
+def find_element(*, attr: str, value: str, tag: str | None = None, html: bool = False, regex: bool = False) -> str: ...
+@overload
+def find_element(*, cls: str, html: bool = False) -> str: ...
+@overload
+def find_element(*, id: str, tag: str | None = None, html: bool = False, regex: bool = False) -> str: ...
+@overload
+def find_element(*, tag: str, html: bool = False, regex: bool = False) -> str: ...
+@overload
+def find_element(
+ *,
+ tag: str | None = None,
+ id: str | None = None,
+ cls: str | None = None,
+ attr: str | None = None,
+ value: str | None = None,
+ html: bool = False,
+ regex: bool = False,
+) -> str: ...
+@overload
+def find_elements(*, cls: str, html: bool = False) -> list[str]: ...
+@overload
+def find_elements(*, attr: str, value: str, tag: str | None = None, html: bool = False, regex: bool = False) -> list[str]: ...
+@overload
+def find_elements(
+ *,
+ tag: str | None = None,
+ cls: str | None = None,
+ attr: str | None = None,
+ value: str | None = None,
+ html: bool = False,
+ regex: bool = False,
+) -> list[str]: ...
+def trim_str(*, start: str | None = None, end: str | None = None) -> Callable[[str], str]: ...
+
+# Returns a callable f(items) which calls func(*items, **kwargs).
+def unpack(func: Callable[..., Any], **kwargs: Any) -> Callable[..., Any]: ...
+def get_first(
+ obj: _Traversable,
+ *paths: _PathArg,
+ default: Any = ..., # Anything or type[NO_DEFAULT]
+ expected_type: type[Any] | None = None,
+ get_all: bool = True,
+ casesense: bool = True,
+ is_user_input: bool | type[NO_DEFAULT] = ...,
+ traverse_string: bool = False,
+) -> Any: ...
+@overload
+def dict_get(d: str, key_or_keys: str | Collection[str]) -> Any | None: ...
+@overload
+def dict_get(
+ d: str, key_or_keys: str | Collection[str], default: Any | None = None, skip_false_values: bool = True
+) -> Any | None: ...
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/version.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/version.pyi
new file mode 100644
index 000000000000..e4e6cf246ae1
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/version.pyi
@@ -0,0 +1,6 @@
+__version__: str
+RELEASE_GIT_HEAD: str
+VARIANT: str
+UPDATE_HINT: str
+CHANNEL: str
+ORIGIN: str
diff --git a/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/webvtt.pyi b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/webvtt.pyi
new file mode 100644
index 000000000000..0a3b87f03980
--- /dev/null
+++ b/python/helpers/typeshed/stubs/yt-dlp/yt_dlp/webvtt.pyi
@@ -0,0 +1,49 @@
+import re
+from collections.abc import Generator, Mapping
+from typing import Any, TextIO, TypeVar
+
+_AT = TypeVar("_AT", int, str, re.Match[str], None)
+
+class _MatchParser:
+ def __init__(self, string: str) -> None: ...
+ def match(self, r: re.Pattern[str]) -> re.Match[str] | int | None: ...
+ def advance(self, by: _AT) -> _AT: ...
+ def consume(self, r: re.Pattern[str]) -> re.Match[str]: ...
+ def child(self) -> _MatchChildParser: ...
+
+class _MatchChildParser(_MatchParser):
+ def __init__(self, parent: _MatchParser) -> None: ...
+ def commit(self) -> _MatchParser: ...
+
+class ParseError(Exception):
+ def __init__(self, parser: _MatchParser) -> None: ...
+
+class Block:
+ def __init__(self, **kwargs: Any) -> None: ... # Abstract. Accepts arbitrary keyword arguments.
+ @classmethod
+ def parse(cls, parser: _MatchParser) -> Block: ...
+ def write_into(self, stream: TextIO) -> None: ...
+
+class HeaderBlock(Block): ...
+
+class Magic(HeaderBlock):
+ @classmethod
+ def parse(cls, parser: _MatchParser) -> Magic: ...
+ def write_into(self, stream: TextIO) -> None: ...
+
+class StyleBlock(HeaderBlock): ...
+class RegionBlock(HeaderBlock): ...
+class CommentBlock(Block): ...
+
+class CueBlock(Block):
+ @classmethod
+ def parse(cls, parser: _MatchParser) -> CueBlock: ...
+ def write_into(self, stream: TextIO) -> None: ...
+ @property
+ def as_json(self) -> dict[str, Any]: ...
+ def __eq__(self, other: object) -> bool: ...
+ @classmethod
+ def from_json(cls, json: Mapping[str, Any]) -> CueBlock: ...
+ def hinges(self, other: Block) -> bool: ...
+
+def parse_fragment(frag_content: bytes) -> Generator[Block]: ...
diff --git a/python/helpers/typeshed/stubs/zstd/METADATA.toml b/python/helpers/typeshed/stubs/zstd/METADATA.toml
index 37447439d079..540aecc58454 100644
--- a/python/helpers/typeshed/stubs/zstd/METADATA.toml
+++ b/python/helpers/typeshed/stubs/zstd/METADATA.toml
@@ -1,2 +1,2 @@
-version = "1.5.7.0"
+version = "~=1.5.7.1"
upstream_repository = "https://github.com/sergey-dryabzhinsky/python-zstd"
diff --git a/python/helpers/typeshed/stubs/zstd/zstd.pyi b/python/helpers/typeshed/stubs/zstd/zstd.pyi
index 5ff13bd83d2d..ad09e87ea22c 100644
--- a/python/helpers/typeshed/stubs/zstd/zstd.pyi
+++ b/python/helpers/typeshed/stubs/zstd/zstd.pyi
@@ -5,6 +5,7 @@ class Error(Exception): ...
def ZSTD_compress(data: ReadableBuffer, level: int = ..., threads: int = ..., /) -> bytes: ...
compress = ZSTD_compress
+compress_real_mt = ZSTD_compress
dumps = ZSTD_compress
encode = ZSTD_compress
@@ -30,4 +31,9 @@ def ZSTD_with_threads() -> int: ...
def ZSTD_legacy_support() -> int: ...
def ZSTD_max_compression_level() -> int: ...
def ZSTD_min_compression_level() -> int: ...
+def ZSTD_default_compression_level() -> int: ...
+def ZSTD_is_debug_enabled() -> int: ...
+def ZSTD_is_debug_error_enabled() -> int: ...
+def ZSTD_is_debug_info_enabled() -> int: ...
+def ZSTD_is_debug_notice_enabled() -> int: ...
def version() -> str: ...
diff --git a/python/helpers/typeshed/stubs/zxcvbn/zxcvbn/__init__.pyi b/python/helpers/typeshed/stubs/zxcvbn/zxcvbn/__init__.pyi
index e327270125ce..668d12a9b250 100644
--- a/python/helpers/typeshed/stubs/zxcvbn/zxcvbn/__init__.pyi
+++ b/python/helpers/typeshed/stubs/zxcvbn/zxcvbn/__init__.pyi
@@ -1,12 +1,13 @@
import datetime
from collections.abc import Iterable
from decimal import Decimal
-from typing import TypedDict
+from typing import TypedDict, type_check_only
from .feedback import _Feedback
from .matching import _Match
from .time_estimates import _TimeEstimate
+@type_check_only
class _Result(_TimeEstimate, TypedDict):
password: str
guesses: Decimal
diff --git a/python/helpers/typeshed/stubs/zxcvbn/zxcvbn/feedback.pyi b/python/helpers/typeshed/stubs/zxcvbn/zxcvbn/feedback.pyi
index 1258af31330c..17b348a0bd7d 100644
--- a/python/helpers/typeshed/stubs/zxcvbn/zxcvbn/feedback.pyi
+++ b/python/helpers/typeshed/stubs/zxcvbn/zxcvbn/feedback.pyi
@@ -1,8 +1,9 @@
from collections.abc import Sequence
-from typing import Literal, TypedDict
+from typing import Literal, TypedDict, type_check_only
from .matching import _Match
+@type_check_only
class _Feedback(TypedDict):
warning: str
suggestions: list[str]
diff --git a/python/helpers/typeshed/stubs/zxcvbn/zxcvbn/matching.pyi b/python/helpers/typeshed/stubs/zxcvbn/zxcvbn/matching.pyi
index 7aba63bad5d5..7f8bfb28af20 100644
--- a/python/helpers/typeshed/stubs/zxcvbn/zxcvbn/matching.pyi
+++ b/python/helpers/typeshed/stubs/zxcvbn/zxcvbn/matching.pyi
@@ -1,11 +1,12 @@
from collections.abc import Iterable, Mapping
from decimal import Decimal
from re import Pattern
-from typing import Any, Literal, TypedDict
+from typing import Any, Literal, TypedDict, type_check_only
from typing_extensions import NotRequired
from .adjacency_graphs import _Graph
+@type_check_only
class _Match(TypedDict):
pattern: Literal["dictionary", "spatial", "repeat", "sequence", "regex", "date"]
token: str
@@ -80,11 +81,12 @@ def regex_match(
password: str, _regexen: dict[str, Pattern[str]] = ..., _ranked_dictionaries: dict[str, dict[str, int]] = ...
) -> list[_Match]: ...
def date_match(password: str, _ranked_dictionaries: dict[str, dict[str, int]] = ...) -> list[_Match]: ...
-
+@type_check_only
class _DM(TypedDict):
month: int
day: int
+@type_check_only
class _DMY(TypedDict):
year: int
month: int
diff --git a/python/helpers/typeshed/stubs/zxcvbn/zxcvbn/scoring.pyi b/python/helpers/typeshed/stubs/zxcvbn/zxcvbn/scoring.pyi
index 9aafe968a3b1..a553977c42e2 100644
--- a/python/helpers/typeshed/stubs/zxcvbn/zxcvbn/scoring.pyi
+++ b/python/helpers/typeshed/stubs/zxcvbn/zxcvbn/scoring.pyi
@@ -1,7 +1,7 @@
from collections.abc import Iterable
from decimal import Decimal
from re import Pattern
-from typing import TypedDict
+from typing import TypedDict, type_check_only
from .adjacency_graphs import _Graph
from .matching import _Match
@@ -15,6 +15,7 @@ MIN_SUBMATCH_GUESSES_MULTI_CHAR: int
MIN_YEAR_SPACE: int
REFERENCE_YEAR: int
+@type_check_only
class _GuessesResult(TypedDict):
password: str
guesses: int
diff --git a/python/helpers/typeshed/stubs/zxcvbn/zxcvbn/time_estimates.pyi b/python/helpers/typeshed/stubs/zxcvbn/zxcvbn/time_estimates.pyi
index 71e2b3671850..f18ec53268c7 100644
--- a/python/helpers/typeshed/stubs/zxcvbn/zxcvbn/time_estimates.pyi
+++ b/python/helpers/typeshed/stubs/zxcvbn/zxcvbn/time_estimates.pyi
@@ -1,17 +1,20 @@
from decimal import Decimal
-from typing import Literal, TypedDict
+from typing import Literal, TypedDict, type_check_only
+@type_check_only
class _TimeEstimate(TypedDict):
crack_times_seconds: _CrackTimeSeconds
crack_times_display: _CrackTimesDisplay
score: Literal[0, 1, 2, 3, 4]
+@type_check_only
class _CrackTimeSeconds(TypedDict):
online_throttling_100_per_hour: Decimal
online_no_throttling_10_per_second: Decimal
offline_slow_hashing_1e4_per_second: Decimal
offline_fast_hashing_1e10_per_second: Decimal
+@type_check_only
class _CrackTimesDisplay(TypedDict):
online_throttling_100_per_hour: str
online_no_throttling_10_per_second: str
diff --git a/python/helpers/typeshed/tests/README.md b/python/helpers/typeshed/tests/README.md
index e2fd81fb7362..a8f2c5e9a944 100644
--- a/python/helpers/typeshed/tests/README.md
+++ b/python/helpers/typeshed/tests/README.md
@@ -1,8 +1,6 @@
This directory contains several tests:
- `tests/mypy_test.py`
tests the stubs with [mypy](https://github.com/python/mypy/)
-- `tests/pytype_test.py` tests the stubs with
-[pytype](https://github.com/google/pytype/).
- `tests/pyright_test.py` tests the stubs with
[pyright](https://github.com/microsoft/pyright).
- `tests/regr_test.py` runs mypy against the test cases for typeshed's
@@ -19,7 +17,7 @@ in the `tests` and `scripts` directories.
To run the tests, follow the [setup instructions](../CONTRIBUTING.md#preparing-the-environment)
in the `CONTRIBUTING.md` document. In particular, you have to run with Python 3.9+.
-In order for `pytype_test` and `pyright_test` to work correctly, some third-party stubs
+In order for `pyright_test` to work correctly, some third-party stubs
may require extra dependencies external to typeshed to be installed in your virtual environment
prior to running the test.
You can list or install all of a stubs package's external dependencies using the following script:
@@ -67,18 +65,6 @@ imported but doesn't check whether stubs match their implementation
Run `python tests/mypy_test.py --help` for information on the various configuration options
for this script.
-## pytype\_test.py
-
-Note: This test cannot be run on Python version < 3.13 as pytype does not yet support
-Python 3.13 and above.
-
-Run using:
-```bash
-(.venv3)$ python3 tests/pytype_test.py
-```
-
-This test works similarly to `mypy_test.py`, except it uses `pytype`.
-
## pyright\_test.py
This test requires [Node.js](https://nodejs.org) to be installed. Although
diff --git a/python/helpers/typeshed/tests/check_typeshed_structure.py b/python/helpers/typeshed/tests/check_typeshed_structure.py
old mode 100755
new mode 100644
index 191173b4256b..a0e905b9974b
--- a/python/helpers/typeshed/tests/check_typeshed_structure.py
+++ b/python/helpers/typeshed/tests/check_typeshed_structure.py
@@ -25,7 +25,7 @@ extension_descriptions = {".pyi": "stub", ".py": ".py"}
# These type checkers and linters must have exact versions in the requirements file to ensure
# consistent CI runs.
-linters = {"mypy", "pyright", "pytype", "ruff"}
+linters = {"mypy", "pyright", "ruff"}
ALLOWED_PY_FILES_IN_TESTS_DIR = {
"django_settings.py" # This file contains Django settings used by the mypy_django_plugin during stubtest execution.
diff --git a/python/helpers/typeshed/tests/get_external_apt_dependencies.py b/python/helpers/typeshed/tests/get_external_apt_dependencies.py
deleted file mode 100755
index 8e3f4ddfdeb1..000000000000
--- a/python/helpers/typeshed/tests/get_external_apt_dependencies.py
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env python3
-
-import itertools
-import os
-import sys
-
-from ts_utils.metadata import read_metadata
-from ts_utils.paths import STUBS_PATH
-
-if __name__ == "__main__":
- distributions = sys.argv[1:]
- if not distributions:
- distributions = os.listdir(STUBS_PATH)
- dependencies = set(
- itertools.chain.from_iterable(
- read_metadata(distribution).stubtest_settings.apt_dependencies for distribution in distributions
- )
- )
- for dependency in sorted(dependencies):
- print(dependency)
diff --git a/python/helpers/typeshed/tests/get_external_stub_requirements.py b/python/helpers/typeshed/tests/get_external_stub_requirements.py
old mode 100755
new mode 100644
diff --git a/python/helpers/typeshed/tests/get_stubtest_system_requirements.py b/python/helpers/typeshed/tests/get_stubtest_system_requirements.py
old mode 100755
new mode 100644
index 1e01ceb4f02f..6c67bf425c38
--- a/python/helpers/typeshed/tests/get_stubtest_system_requirements.py
+++ b/python/helpers/typeshed/tests/get_stubtest_system_requirements.py
@@ -5,5 +5,5 @@ from ts_utils.requirements import get_stubtest_system_requirements
if __name__ == "__main__":
distributions = sys.argv[1:]
- for requirement in get_stubtest_system_requirements(distributions):
+ for requirement in sorted(get_stubtest_system_requirements(distributions)):
print(requirement)
diff --git a/python/helpers/typeshed/tests/mypy_test.py b/python/helpers/typeshed/tests/mypy_test.py
old mode 100755
new mode 100644
diff --git a/python/helpers/typeshed/tests/pyright_test.py b/python/helpers/typeshed/tests/pyright_test.py
old mode 100755
new mode 100644
index 04b3df6fa99e..c97ca44feb47
--- a/python/helpers/typeshed/tests/pyright_test.py
+++ b/python/helpers/typeshed/tests/pyright_test.py
@@ -37,7 +37,7 @@ def main() -> None:
# version installed into the virtual environment, due to failures on some
# platforms. https://github.com/python/typeshed/issues/11614
os.environ["PYRIGHT_PYTHON_FORCE_VERSION"] = pyright_version
- command = [npx, f"pyright@{pyright_version}"] + sys.argv[1:]
+ command = [npx, f"pyright@{pyright_version}", *sys.argv[1:]]
print_command(command)
ret = subprocess.run(command, check=False).returncode
diff --git a/python/helpers/typeshed/tests/pytype_exclude_list.txt b/python/helpers/typeshed/tests/pytype_exclude_list.txt
deleted file mode 100644
index bad4109bf3c7..000000000000
--- a/python/helpers/typeshed/tests/pytype_exclude_list.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-# Pytype exclude list. Files will not be tested with pytype.
-
-# pytype has its own version of these files, and thus doesn't mind if it
-# can't parse the typeshed version:
-stdlib/builtins.pyi
-stdlib/typing.pyi
-
-# can't subscript memoryview for some reason
-stdlib/asyncio/sslproto.pyi
-stdlib/asyncio/transports.pyi
-
-# errors about import statements
-stubs/mysqlclient/MySQLdb/__init__.pyi
-stubs/mysqlclient/MySQLdb/connections.pyi
-stubs/mysqlclient/MySQLdb/cursors.pyi
-
-# twisted not installed during tests
-stubs/pika/pika/adapters/twisted_connection.pyi
-
-# pytype.pytd.visitors.ContainerError: Conflicting values for TypeVar
-stubs/openpyxl/openpyxl/descriptors/nested.pyi
-
-# matplotlib not installed during tests
-stubs/shapely/shapely/plotting.pyi
-
-# matplotlib et al not installed during tests
-stubs/geopandas/geopandas/plotting.pyi
-stubs/geopandas/geopandas/explore.pyi
diff --git a/python/helpers/typeshed/tests/pytype_test.py b/python/helpers/typeshed/tests/pytype_test.py
deleted file mode 100755
index 1c5fce2c12f4..000000000000
--- a/python/helpers/typeshed/tests/pytype_test.py
+++ /dev/null
@@ -1,249 +0,0 @@
-#!/usr/bin/env python3
-# Lack of pytype typing
-# pyright: reportUnknownVariableType=false, reportUnknownMemberType=false, reportUnknownArgumentType=false, reportMissingTypeStubs=false
-"""Test runner for typeshed.
-
-Depends on pytype being installed.
-
-If pytype is installed:
- 1. For every pyi, do nothing if it is in pytype_exclude_list.txt.
- 2. Otherwise, call 'pytype.io.parse_pyi'.
-Option two will load the file and all the builtins, typeshed dependencies. This
-will also discover incorrect usage of imported modules.
-"""
-
-from __future__ import annotations
-
-import sys
-from typing import TYPE_CHECKING
-
-if TYPE_CHECKING:
- assert sys.platform != "win32", "pytype isn't yet installed in CI, but wheels can be built on Windows"
- from _typeshed import StrPath
-if sys.version_info >= (3, 13):
- print("pytype does not support Python 3.13+ yet.", file=sys.stderr)
- sys.exit(1)
-
-import argparse
-import importlib.metadata
-import inspect
-import os
-import traceback
-from collections.abc import Iterable, Sequence
-from pathlib import Path
-
-# pytype is not py.typed https://github.com/google/pytype/issues/1325
-from pytype import config as pytype_config, load_pytd # type: ignore[import]
-from pytype.imports import typeshed # type: ignore[import]
-
-from ts_utils.metadata import read_dependencies
-from ts_utils.paths import STDLIB_PATH, STUBS_PATH, TS_BASE_PATH
-from ts_utils.utils import SupportedVersionsDict, parse_stdlib_versions_file, supported_versions_for_module
-
-TYPESHED_SUBDIRS = [STDLIB_PATH.absolute(), STUBS_PATH.absolute()]
-TYPESHED_HOME = "TYPESHED_HOME"
-EXCLUDE_LIST = TS_BASE_PATH / "tests" / "pytype_exclude_list.txt"
-_LOADERS: dict[str, tuple[pytype_config.Options, load_pytd.Loader]] = {}
-
-
-def main() -> None:
- args = create_parser().parse_args()
- typeshed_location = Path(args.typeshed_location) or Path.cwd()
- check_subdirs_discoverable(TYPESHED_SUBDIRS)
- old_typeshed_home = os.environ.get(TYPESHED_HOME)
- os.environ[TYPESHED_HOME] = str(typeshed_location)
- files_to_test = determine_files_to_test(paths=[Path(file) for file in args.files] or TYPESHED_SUBDIRS)
- run_all_tests(files_to_test=files_to_test, print_stderr=args.print_stderr, dry_run=args.dry_run)
- if old_typeshed_home is None:
- del os.environ[TYPESHED_HOME]
- else:
- os.environ[TYPESHED_HOME] = old_typeshed_home
-
-
-def create_parser() -> argparse.ArgumentParser:
- parser = argparse.ArgumentParser(description="Pytype/typeshed tests.")
- parser.add_argument("-n", "--dry-run", action="store_true", default=False, help="Don't actually run tests")
- # Default to '' so that symlinking typeshed subdirs in cwd will work.
- parser.add_argument("--typeshed-location", type=str, default="", help="Path to typeshed installation.")
- # Set to true to print a stack trace every time an exception is thrown.
- parser.add_argument(
- "--print-stderr", action="store_true", default=False, help="Print stderr every time an error is encountered."
- )
- parser.add_argument(
- "files", metavar="FILE", type=str, nargs="*", help="Files or directories to check. (Default: Check all files.)"
- )
- return parser
-
-
-def run_pytype(*, filename: StrPath, python_version: str, missing_modules: Iterable[str]) -> str | None:
- """Run pytype, returning the stderr if any."""
- if python_version not in _LOADERS:
- options = pytype_config.Options.create("", parse_pyi=True, python_version=python_version)
- # For simplicity, pretends missing modules are part of the stdlib.
- missing_modules = tuple(str(STDLIB_PATH / m) for m in missing_modules)
- loader = load_pytd.create_loader(options, missing_modules)
- _LOADERS[python_version] = (options, loader)
- options, loader = _LOADERS[python_version]
- stderr: str | None
- try:
- with pytype_config.verbosity_from(options):
- ast = loader.load_file(_get_module_name(filename), filename)
- loader.finish_and_verify_ast(ast)
- except Exception:
- stderr = traceback.format_exc()
- else:
- stderr = None
- return stderr
-
-
-def _get_relative(filename: StrPath) -> Path:
- filepath = Path(filename)
- for d in TYPESHED_SUBDIRS:
- try:
- return filepath.absolute().relative_to(d.parent)
- except ValueError:
- continue
- raise ValueError(f"{filepath} not relative to {TYPESHED_SUBDIRS}")
-
-
-def _get_module_name(filename: StrPath) -> str:
- """Convert a filename {subdir}/m.n/module/foo to module.foo."""
- parts = _get_relative(filename).parts
- if parts[0] == "stdlib":
- module_parts = parts[1:]
- else:
- assert parts[0] == "stubs"
- module_parts = parts[2:]
- return ".".join(module_parts).replace(".pyi", "").replace(".__init__", "")
-
-
-def check_subdirs_discoverable(subdir_paths: Iterable[Path]) -> None:
- for p in subdir_paths:
- if not p.is_dir():
- raise SystemExit(f"Cannot find typeshed subdir at {p} (specify parent dir via --typeshed-location)")
-
-
-def determine_files_to_test(*, paths: Iterable[Path]) -> list[Path]:
- """Determine all files to test.
-
- Checks for files in the pytype exclude list and for the stdlib VERSIONS file.
- """
- filenames = find_stubs_in_paths(paths)
- ts = typeshed.Typeshed()
- exclude_list = set(ts.read_blacklist())
- stdlib_module_versions = parse_stdlib_versions_file()
- return [
- f
- for f in sorted(filenames)
- if _get_relative(f).as_posix() not in exclude_list and _is_supported_stdlib_version(stdlib_module_versions, f)
- ]
-
-
-def find_stubs_in_paths(paths: Iterable[Path]) -> list[Path]:
- filenames: list[Path] = []
- for path in paths:
- if path.is_dir():
- for root, _, fns in os.walk(path):
- filenames.extend(Path(root, fn) for fn in fns if fn.endswith(".pyi"))
- else:
- filenames.append(path)
- return filenames
-
-
-def _is_supported_stdlib_version(module_versions: SupportedVersionsDict, filename: StrPath) -> bool:
- parts = _get_relative(filename).parts
- if parts[0] != "stdlib":
- return True
- module_name = _get_module_name(filename)
- min_version, max_version = supported_versions_for_module(module_versions, module_name)
- return min_version <= sys.version_info <= max_version
-
-
-def _get_pkgs_associated_with_requirement(req_name: str) -> list[str]:
- try:
- dist = importlib.metadata.distribution(req_name)
- except importlib.metadata.PackageNotFoundError:
- # The package wasn't installed, probably because an environment
- # marker excluded it.
- return []
- toplevel_txt_contents = dist.read_text("top_level.txt")
- if toplevel_txt_contents is None:
- if dist.files is None:
- raise RuntimeError(f"Can't read find the packages associated with requirement {req_name!r}")
- maybe_modules = [f.parts[0] if len(f.parts) > 1 else inspect.getmodulename(f) for f in dist.files]
- packages = [name for name in maybe_modules if name is not None and "." not in name]
- else:
- packages = toplevel_txt_contents.split()
- # https://peps.python.org/pep-0561/#stub-only-packages
- return sorted({package.removesuffix("-stubs") for package in packages})
-
-
-def get_missing_modules(files_to_test: Iterable[Path]) -> Iterable[str]:
- """Get names of modules that should be treated as missing.
-
- Some typeshed stubs depend on dependencies outside of typeshed. Since pytype
- isn't able to read such dependencies, we instead declare them as "missing"
- modules, so that no errors are reported for them.
-
- Similarly, pytype cannot parse files on its exclude list, so we also treat
- those as missing.
- """
- stub_distributions = set[str]()
- for fi in files_to_test:
- parts = fi.parts
- try:
- idx = parts.index("stubs")
- except ValueError:
- continue
- stub_distributions.add(parts[idx + 1])
-
- missing_modules = {
- associated_package
- for distribution in stub_distributions
- for external_req in read_dependencies(distribution).external_pkgs
- for associated_package in _get_pkgs_associated_with_requirement(external_req.name)
- }
-
- with EXCLUDE_LIST.open() as f:
- for line in f:
- if not line.startswith("stubs/"):
- # Skips comments, empty lines, and stdlib files, which are in
- # the exclude list because pytype has its own version.
- continue
- _ts_subdir, _distribution, module_path = line.strip().split("/", 2)
- missing_modules.add(module_path.removesuffix(".pyi"))
- return missing_modules
-
-
-def run_all_tests(*, files_to_test: Sequence[Path], print_stderr: bool, dry_run: bool) -> None:
- bad: list[tuple[StrPath, str, str]] = []
- errors = 0
- total_tests = len(files_to_test)
- missing_modules = get_missing_modules(files_to_test)
- python_version = f"{sys.version_info.major}.{sys.version_info.minor}"
- print("Testing files with pytype...")
- for i, file_to_test in enumerate(files_to_test):
- if dry_run:
- stderr = None
- else:
- stderr = run_pytype(filename=file_to_test, python_version=python_version, missing_modules=missing_modules)
- if stderr:
- if print_stderr:
- print(f"\n{stderr}")
- errors += 1
- stacktrace_final_line = stderr.rstrip().rsplit("\n", 1)[-1]
- bad.append((_get_relative(file_to_test), python_version, stacktrace_final_line))
-
- runs = i + 1
- if runs % 25 == 0:
- print(f" {runs:3d}/{total_tests:d} with {errors:3d} errors")
-
- print(f"Ran pytype with {total_tests:d} pyis, got {errors:d} errors.")
- for f, v, err in bad:
- print(f"\n{f} ({v}): {err}")
- if errors:
- raise SystemExit("\nRun again with --print-stderr to get the full stacktrace.")
-
-
-if __name__ == "__main__":
- main()
diff --git a/python/helpers/typeshed/tests/regr_test.py b/python/helpers/typeshed/tests/regr_test.py
old mode 100755
new mode 100644
diff --git a/python/helpers/typeshed/tests/runtests.py b/python/helpers/typeshed/tests/runtests.py
old mode 100755
new mode 100644
index efffc84df747..296cb8ccd068
--- a/python/helpers/typeshed/tests/runtests.py
+++ b/python/helpers/typeshed/tests/runtests.py
@@ -6,7 +6,6 @@ import json
import re
import subprocess
import sys
-from importlib.util import find_spec
from pathlib import Path
from ts_utils.metadata import get_oldest_supported_python, read_metadata
@@ -77,7 +76,6 @@ def main() -> None:
python_version = get_oldest_supported_python()
stubtest_result: subprocess.CompletedProcess[bytes] | None = None
- pytype_result: subprocess.CompletedProcess[bytes] | None = None
print("\nRunning pre-commit...")
pre_commit_result = subprocess.run(["pre-commit", "run", "--files", *path.rglob("*")], check=False)
@@ -125,17 +123,6 @@ def main() -> None:
else:
print(colored("\nSkipping stubtest since mypy failed.", "yellow"))
- if find_spec("pytype"):
- print("\nRunning pytype...")
- pytype_result = subprocess.run([sys.executable, "tests/pytype_test.py", path], check=False)
- else:
- print(
- colored(
- f"\nSkipping pytype on Windows. You need to install it first: `{sys.executable} -m pip install pytype` .",
- "yellow",
- )
- )
-
cases_path = test_cases_path(stub if folder == "stubs" else "stdlib")
if not cases_path.exists():
# No test means they all ran successfully (0 out of 0). Not all 3rd-party stubs have regression tests.
@@ -186,7 +173,6 @@ def main() -> None:
pyright_returncode,
mypy_result.returncode,
getattr(stubtest_result, "returncode", 0),
- getattr(pytype_result, "returncode", 0),
pyright_testcases_returncode,
regr_test_returncode,
]
@@ -218,10 +204,6 @@ def main() -> None:
print("stubtest:", _SKIPPED)
else:
print("stubtest:", _SUCCESS if stubtest_result.returncode == 0 else _FAILED)
- if not pytype_result:
- print("pytype:", _SKIPPED)
- else:
- print("pytype:", _SUCCESS if pytype_result.returncode == 0 else _FAILED)
if pyright_testcases_skipped:
print("Pyright regression tests:", _SKIPPED)
else:
diff --git a/python/helpers/typeshed/tests/stubtest_stdlib.py b/python/helpers/typeshed/tests/stubtest_stdlib.py
old mode 100755
new mode 100644
diff --git a/python/helpers/typeshed/tests/stubtest_third_party.py b/python/helpers/typeshed/tests/stubtest_third_party.py
old mode 100755
new mode 100644
index f477fb8e2c55..d2ea4190bc77
--- a/python/helpers/typeshed/tests/stubtest_third_party.py
+++ b/python/helpers/typeshed/tests/stubtest_third_party.py
@@ -28,12 +28,11 @@ from ts_utils.utils import (
print_info,
print_success_msg,
print_time,
+ print_warning,
)
-def run_stubtest(
- dist: Path, *, verbose: bool = False, specified_platforms_only: bool = False, keep_tmp_dir: bool = False
-) -> bool:
+def run_stubtest(dist: Path, *, verbose: bool = False, ci_platforms_only: bool = False, keep_tmp_dir: bool = False) -> bool:
"""Run stubtest for a single distribution."""
dist_name = dist.name
@@ -44,14 +43,16 @@ def run_stubtest(
stubtest_settings = metadata.stubtest_settings
if stubtest_settings.skip:
- print(colored("skipping", "yellow"))
+ print(colored("skipping (skip = true)", "yellow"))
return True
- if sys.platform not in stubtest_settings.platforms:
- if specified_platforms_only:
- print(colored("skipping (platform not specified in METADATA.toml)", "yellow"))
- return True
- print(colored(f"Note: {dist_name} is not currently tested on {sys.platform} in typeshed's CI.", "yellow"))
+ if stubtest_settings.supported_platforms is not None and sys.platform not in stubtest_settings.supported_platforms:
+ print(colored("skipping (platform not supported)", "yellow"))
+ return True
+
+ if ci_platforms_only and sys.platform not in stubtest_settings.ci_platforms:
+ print(colored("skipping (platform skipped in CI)", "yellow"))
+ return True
if not metadata.requires_python.contains(PYTHON_VERSION):
print(colored(f"skipping (requires Python {metadata.requires_python})", "yellow"))
@@ -107,6 +108,7 @@ def run_stubtest(
"mypy.stubtest",
"--mypy-config-file",
temp.name,
+ "--show-traceback",
# Use --custom-typeshed-dir in case we make linked changes to stdlib or _typeshed
"--custom-typeshed-dir",
str(dist.parent.parent),
@@ -189,8 +191,13 @@ def run_stubtest(
else:
print_time(time() - t)
print_success_msg()
+
+ if sys.platform not in stubtest_settings.ci_platforms:
+ print_warning(f"Note: {dist_name} is not currently tested on {sys.platform} in typeshed's CI")
+
if keep_tmp_dir:
print_info(f"Virtual environment kept at: {venv_dir}")
+
finally:
if not keep_tmp_dir:
rmtree(venv_dir)
@@ -398,9 +405,9 @@ def main() -> NoReturn:
parser.add_argument("--num-shards", type=int, default=1)
parser.add_argument("--shard-index", type=int, default=0)
parser.add_argument(
- "--specified-platforms-only",
+ "--ci-platforms-only",
action="store_true",
- help="skip the test if the current platform is not specified in METADATA.toml/tool.stubtest.platforms",
+ help="skip the test if the current platform is not specified in METADATA.toml/tool.stubtest.ci-platforms",
)
parser.add_argument("--keep-tmp-dir", action="store_true", help="keep the temporary virtualenv")
parser.add_argument("dists", metavar="DISTRIBUTION", type=str, nargs=argparse.ZERO_OR_MORE)
@@ -417,7 +424,7 @@ def main() -> NoReturn:
continue
try:
if not run_stubtest(
- dist, verbose=args.verbose, specified_platforms_only=args.specified_platforms_only, keep_tmp_dir=args.keep_tmp_dir
+ dist, verbose=args.verbose, ci_platforms_only=args.ci_platforms_only, keep_tmp_dir=args.keep_tmp_dir
):
result = 1
except NoSuchStubError as e:
diff --git a/python/helpers/typeshed/tests/typecheck_typeshed.py b/python/helpers/typeshed/tests/typecheck_typeshed.py
old mode 100755
new mode 100644