Skip to content

Commit c5f3c8a

Browse files
Primeteummclaude
andcommitted
Merge branch 'main' into yt-dlp-parsers-return-none
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 parents ce82b5e + 567e5e3 commit c5f3c8a

736 files changed

Lines changed: 6884 additions & 5777 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.pre-commit-config.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
args: [--fix=lf]
1212
- id: check-case-conflict
1313
- repo: https://github.com/python-jsonschema/check-jsonschema
14-
rev: 4f85d46a92dc17713078e5de73f8a13190edf6fc # frozen: 0.38.2
14+
rev: a76b92851fc9eede9f9bc4073eb55202f34eb0df # frozen: 0.39.0
1515
hooks:
1616
- id: check-github-workflows
1717
- id: check-renovate

‎AGENTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ When opening pull requests, do the following:
5353
documentation if possible.
5454
- Don't include a testing plan.
5555
- Add the name of the agent used to the PR description.
56+
- Never squash commits or force push.

‎CONTRIBUTING.md‎

Lines changed: 6 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -147,106 +147,10 @@ stubbing.
147147

148148
#### The `METADATA.toml` file
149149

150-
The metadata file describes the stubs package using the
151-
[TOML file format](https://toml.io/en/). Currently, the following keys are
152-
supported:
153-
154-
* `version`: The versions of the library that the stubs support. Two
155-
formats are supported:
156-
- A concrete version. This is especially suited for libraries that
157-
use [Calendar Versioning](https://calver.org/).
158-
- A version range ending in `.*`. This is suited for libraries that
159-
reflect API changes in the version number only, where the API-independent
160-
part is represented by the asterisk. In the case
161-
of [Semantic Versioning](https://semver.org/), this version could look
162-
like this: `2.7.*`.
163-
When the stubs are updated to a newer version
164-
of the library, the version of the stub should be bumped (note that
165-
previous versions are still available on PyPI).
166-
* `dependencies` (optional): A list of other stub packages or packages with type
167-
information that are imported by the stubs in this package. Only packages
168-
generated by typeshed or required by the upstream package are allowed to
169-
be listed here, for security reasons. See
170-
[this issue](https://github.com/typeshed-internal/stub_uploader/issues/90)
171-
for more information about what external dependencies are allowed.
172-
* `optional-dependencies` (optional): A list of other stub packages or packages
173-
with type information that are imported by some stubs in this package. This
174-
is often used for packages that provide optional features that require extra
175-
dependencies. The same limitations apply to this field as to `dependencies`.
176-
* `extra-description` (optional): Can be used to add a custom description to
177-
the package's long description. It should be a multi-line string in
178-
Markdown format.
179-
* `stub-distribution` (optional): Distribution name to be uploaded to PyPI.
180-
This defaults to `types-<distribution>` and should only be set in special
181-
cases.
182-
* `upstream-repository` (recommended): The URL of the upstream repository.
183-
* `obsolete-since` (optional): This table is part of our process for
184-
[removing obsolete third-party libraries](#third-party-library-removal-policy).
185-
It contains the first version of the corresponding library that ships
186-
its own `py.typed` file, and the date when that version was released.
187-
* `no-longer-updated` (optional): This field is set to `true` before removing
188-
stubs for other reasons than the upstream library shipping with type
189-
information.
190-
* `upload` (optional): This field is set to `false` to prevent automatic
191-
uploads to PyPI. This should only be used in special cases, e.g. when the stubs
192-
break the upload.
193-
* `partial-stub` (optional): This field marks the type stub package as
194-
[partial](https://typing.python.org/en/latest/spec/distributing.html#partial-stub-packages).
195-
This is for 3rd-party stubs that don't cover the entirety of the package's public API.
196-
* `requires-python` (optional): The minimum version of Python required to install
197-
the type stub package. It must be in the form `>=3.*`. If omitted, the oldest
198-
Python version supported by typeshed is used.
199-
200-
In addition, we specify configuration for stubtest in the `tool.stubtest` table.
201-
This has the following keys:
202-
* `skip` (default: `false`): Whether stubtest should be run against this
203-
package. Please avoid setting this to `true`, and add a comment if you have
204-
to.
205-
* `ignore-missing-stub` (default: `false`): When set to `true`, this will add
206-
the `--ignore-missing-stub` option to the stubtest call. See
207-
[tests/README.md](./tests/README.md) for more information. In most cases,
208-
this field should be identical to `partial-stub`.
209-
* `stubtest-dependencies` (default: `[]`): A list of Python packages that need
210-
to be installed for stubtest to run successfully. These packages are installed
211-
in addition to the dependencies in the `dependencies` and
212-
`optional-dependencies` fields.
213-
* `apt-dependencies` (default: `[]`): A list of Ubuntu APT packages
214-
that need to be installed for stubtest to run successfully.
215-
* `brew-dependencies` (default: `[]`): A list of MacOS Homebrew packages
216-
that need to be installed for stubtest to run successfully
217-
* `choco-dependencies` (default: `[]`): A list of Windows Chocolatey packages
218-
that need to be installed for stubtest to run successfully
219-
* `extras` (default: `[]`): A list of optional dependency groups
220-
([extras](https://packaging.python.org/en/latest/specifications/core-metadata/#provides-extra-multiple-use))
221-
that need to be installed for stubtest to run successfully.
222-
For example, `extras = ["foo"]` installs the package as `<package>[foo]`.
223-
* `supported-platforms` (default: all platforms): A list of OSes on which
224-
stubtest can be run. When a package is not platform-specific, this should
225-
not be set. If the package is platform-specific, this should usually be set
226-
to the supported platforms, unless stubtest is known to fail on a
227-
specific platform.
228-
* `ci-platforms` (default: `["linux"]`): A list of OSes on which to run
229-
stubtest as part of our continuous integration (CI) tests. Can contain
230-
`win32`, `linux`, and `darwin` values. If not specified, stubtest is run
231-
only on `linux`. Only add extra OSes to the test if there are
232-
platform-specific branches in a stubs package.
233-
* `mypy-plugins` (default: `[]`): A list of Python modules to use as mypy plugins
234-
when running stubtest. For example: `mypy-plugins = ["mypy_django_plugin.main"]`
235-
* `mypy-plugins-config` (default: `{}`): A dictionary mapping plugin names to their
236-
configuration dictionaries for use by mypy plugins. For example:
237-
`mypy-plugins-config = {"django-stubs" = {"django_settings_module" = "@tests.django_settings"}}`
238-
* `install-environment` (default: `{}`): A dictionary of environment variables
239-
to set while `pip install`ing the package and its dependencies for stubtest.
240-
Useful for packages that read build-time options from the environment, for
241-
example to disable CPU-specific compiler flags that do not survive CI's
242-
shared wheel cache. For example:
243-
`install-environment = { HNSWLIB_NO_NATIVE = "1" }`
244-
245-
`*-dependencies` are usually packages needed to `pip install` the implementation
246-
distribution.
247-
248-
The format of all `METADATA.toml` files can be checked by running
249-
`python3 ./tests/check_typeshed_structure.py`.
150+
Each third-party stub package must have a metadata file to describe the
151+
package. For example, the metadata for a package `parrot` lives in
152+
`stubs/parrot/METADATA.toml`. See
153+
[docs/metadata-files.md](./docs/metadata-files.md) for a full description.
250154

251155
### Dependencies
252156

@@ -476,7 +380,8 @@ to your PR to fix any minor issues, but this is not always possible.
476380
If a PR lingers with unresolved problems for too long, we may close it
477381
([see below](#closing-stale-prs)).
478382

479-
Also, do not squash your commits or use `git commit --amend` after you have submitted a pull request, as this
383+
Also, do not squash your commits, force push, or use `git commit --amend` after
384+
you have submitted a pull request, as this
480385
erases context during review. We will squash commits when the pull request is merged.
481386
This way, your pull request will appear as a single commit in our git history, even
482387
if it consisted of several smaller commits.

‎docs/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- [CONTRIBUTING.md](../CONTRIBUTING.md) – Contribution Guidelines
77
- [docs/maintainers.md](./maintainers.md) – Active and Former Maintainers
88
- [docs/maintainer-guide.md](./maintainer-guide.md) – Guidelines for Maintainers
9+
- [docs/metadata-files.md](./metadata-files.md) – Description of `METADATA.toml` files
910
- [tests/README.md](../tests/README.md) – Test Suite Overview
1011
- [tests/REGRESSION.md](../tests/REGRESSION.md) – Regression Tests
1112
- [stdlib/_typeshed/README.md](../stdlib/_typeshed/README.md) – Utility Types in `_typeshed`

‎docs/metadata-files.md‎

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Metadata Files
2+
3+
Each third-party stub package must have a metadata file to describe the
4+
package. For example, the metadata for a package `parrot` lives in
5+
`stubs/parrot/METADATA.toml`.
6+
7+
## File Format
8+
9+
Metadata files use the [TOML file format](https://toml.io/en/). Currently, the
10+
following keys are supported:
11+
12+
* `version`: The versions of the library that the stubs support. Two
13+
formats are supported:
14+
- A concrete version. This is especially suited for libraries that
15+
use [Calendar Versioning](https://calver.org/).
16+
- A version range ending in `.*`. This is suited for libraries that
17+
reflect API changes in the version number only, where the API-independent
18+
part is represented by the asterisk. In the case
19+
of [Semantic Versioning](https://semver.org/), this version could look
20+
like this: `2.7.*`.
21+
When the stubs are updated to a newer version
22+
of the library, the version of the stub should be bumped (note that
23+
previous versions are still available on PyPI).
24+
* `dependencies` (optional): A list of other stub packages or packages with type
25+
information that are imported by the stubs in this package. Only packages
26+
generated by typeshed or required by the upstream package are allowed to
27+
be listed here, for security reasons. See
28+
[this issue](https://github.com/typeshed-internal/stub_uploader/issues/90)
29+
for more information about what external dependencies are allowed.
30+
* `optional-dependencies` (optional): A list of other stub packages or packages
31+
with type information that are imported by some stubs in this package. This
32+
is often used for packages that provide optional features that require extra
33+
dependencies. The same limitations apply to this field as to `dependencies`.
34+
* `extra-description` (optional): Can be used to add a custom description to
35+
the package's long description. It should be a multi-line string in
36+
Markdown format.
37+
* `stub-distribution` (optional): Distribution name to be uploaded to PyPI.
38+
This defaults to `types-<distribution>` and should only be set in special
39+
cases.
40+
* `upstream-repository` (recommended): The URL of the upstream repository.
41+
* `obsolete-since` (optional): This table is part of our process for
42+
[removing obsolete third-party libraries](#third-party-library-removal-policy).
43+
It contains the first version of the corresponding library that ships
44+
its own `py.typed` file, and the date when that version was released.
45+
* `no-longer-updated` (optional): This field is set to `true` before removing
46+
stubs for other reasons than the upstream library shipping with type
47+
information.
48+
* `upload` (optional): This field is set to `false` to prevent automatic
49+
uploads to PyPI. This should only be used in special cases, e.g. when the stubs
50+
break the upload.
51+
* `partial-stub` (optional): This field marks the type stub package as
52+
[partial](https://typing.python.org/en/latest/spec/distributing.html#partial-stub-packages).
53+
This is for 3rd-party stubs that don't cover the entirety of the package's public API.
54+
* `requires-python` (optional): The minimum version of Python required to install
55+
the type stub package. It must be in the form `>=3.*`. If omitted, the oldest
56+
Python version supported by typeshed is used.
57+
58+
In addition, we specify configuration for stubtest in the `tool.stubtest` table.
59+
This has the following keys:
60+
* `skip` (default: `false`): Whether stubtest should be run against this
61+
package. Please avoid setting this to `true`, and add a comment if you have
62+
to.
63+
* `ignore-missing-stub` (default: `false`): When set to `true`, this will add
64+
the `--ignore-missing-stub` option to the stubtest call. See
65+
[tests/README.md](./tests/README.md) for more information. In most cases,
66+
this field should be identical to `partial-stub`.
67+
* `stubtest-dependencies` (default: `[]`): A list of Python packages that need
68+
to be installed for stubtest to run successfully. These packages are installed
69+
in addition to the dependencies in the `dependencies` and
70+
`optional-dependencies` fields.
71+
* `apt-dependencies` (default: `[]`): A list of Ubuntu APT packages
72+
that need to be installed for stubtest to run successfully.
73+
* `brew-dependencies` (default: `[]`): A list of MacOS Homebrew packages
74+
that need to be installed for stubtest to run successfully
75+
* `choco-dependencies` (default: `[]`): A list of Windows Chocolatey packages
76+
that need to be installed for stubtest to run successfully
77+
* `extras` (default: `[]`): A list of optional dependency groups
78+
([extras](https://packaging.python.org/en/latest/specifications/core-metadata/#provides-extra-multiple-use))
79+
that need to be installed for stubtest to run successfully.
80+
For example, `extras = ["foo"]` installs the package as `<package>[foo]`.
81+
* `supported-platforms` (default: all platforms): A list of OSes on which
82+
stubtest can be run. When a package is not platform-specific, this should
83+
not be set. If the package is platform-specific, this should usually be set
84+
to the supported platforms, unless stubtest is known to fail on a
85+
specific platform.
86+
* `ci-platforms` (default: `["linux"]`): A list of OSes on which to run
87+
stubtest as part of our continuous integration (CI) tests. Can contain
88+
`win32`, `linux`, and `darwin` values. If not specified, stubtest is run
89+
only on `linux`. Only add extra OSes to the test if there are
90+
platform-specific branches in a stubs package.
91+
* `mypy-plugins` (default: `[]`): A list of Python modules to use as mypy plugins
92+
when running stubtest. For example: `mypy-plugins = ["mypy_django_plugin.main"]`
93+
* `mypy-plugins-config` (default: `{}`): A dictionary mapping plugin names to their
94+
configuration dictionaries for use by mypy plugins. For example:
95+
`mypy-plugins-config = {"django-stubs" = {"django_settings_module" = "@tests.django_settings"}}`
96+
* `install-environment` (default: `{}`): A dictionary of environment variables
97+
to set while `pip install`ing the package and its dependencies for stubtest.
98+
Useful for packages that read build-time options from the environment, for
99+
example to disable CPU-specific compiler flags that do not survive CI's
100+
shared wheel cache. For example:
101+
`install-environment = { HNSWLIB_NO_NATIVE = "1" }`
102+
103+
`*-dependencies` are usually packages needed to `pip install` the implementation
104+
distribution.
105+
106+
## Validation
107+
108+
The format of all `METADATA.toml` files can be checked by running
109+
`python3 ./tests/check_typeshed_structure.py`.

‎requirements-tests.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
mypy==2.4.1
44
pyrefly==1.4.1
55
pyright==1.1.414
6-
ty==0.0.99
6+
ty==0.0.104
77

88
# Libraries used by our various scripts.
99
aiohttp==3.14.4

‎scripts/stubsabot.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,15 +875,16 @@ def get_update_pr_body(update: Update, settings: StubtestSettings) -> str:
875875

876876
def remove_stubs(distribution: str) -> None:
877877
stub_path = distribution_path(distribution)
878-
target_path_prefix = f'"stubs/{distribution}'
878+
target_path = f'"stubs/{distribution}"'
879+
target_path_prefix = f'"stubs/{distribution}/'
879880

880881
if stub_path.exists() and stub_path.is_dir():
881882
shutil.rmtree(stub_path)
882883

883884
with PYRIGHT_CONFIG.open("r", encoding="UTF-8") as f:
884885
lines = f.readlines()
885886

886-
lines = [line for line in lines if not line.lstrip().startswith(target_path_prefix)]
887+
lines = [line for line in lines if line.strip() != target_path and not line.lstrip().startswith(target_path_prefix)]
887888

888889
with PYRIGHT_CONFIG.open("w", encoding="UTF-8") as f:
889890
f.writelines(lines)

‎stdlib/@tests/stubtest_allowlists/common.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ logging.LogRecord.__setattr__ # doesn't exist, but makes things easy if we pret
300300
# These would ideally be special-cased by type checkers; see https://github.com/python/mypy/issues/2220
301301
mmap.mmap.__iter__
302302
mmap.mmap.__contains__
303+
multiprocessing.shared_memory.ShareableList.__iter__
303304

304305
# These multiprocessing proxy methods have *args, **kwargs signatures at runtime,
305306
# But have more precise (accurate) signatures in the stub
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import operator
2+
from typing import overload
3+
4+
5+
class Result: ...
6+
7+
8+
class Operand: ...
9+
10+
11+
class LessThan(Operand):
12+
def __lt__(self, other: Operand, /) -> Result:
13+
return Result()
14+
15+
16+
class GreaterEqual:
17+
def __ge__(self, other: Operand, /) -> Result:
18+
return Result()
19+
20+
21+
def check_comparisons(lt: LessThan, ge: GreaterEqual) -> None:
22+
operator.lt(lt, lt)
23+
operator.gt(lt, lt)
24+
operator.ge(ge, lt)
25+
operator.le(lt, ge)
26+
27+
28+
def check_one_sided_comparisons(lt: LessThan, ge: GreaterEqual, other: Operand) -> None:
29+
operator.lt(lt, other)
30+
operator.gt(other, lt)
31+
operator.ge(ge, other)
32+
operator.le(other, ge)
33+
operator.lt(1, other) # type: ignore[misc]
34+
35+
operators = {"<": operator.lt, "<=": operator.le, ">": operator.gt, ">=": operator.ge, "==": operator.eq, "!=": operator.ne}
36+
operators["<"](lt, other)
37+
38+
39+
class Overloaded:
40+
@overload
41+
def __lt__(self, other: int, /) -> int: ...
42+
@overload
43+
def __lt__(self, other: str, /) -> str: ...
44+
def __lt__(self, other: int | str, /) -> int | str:
45+
return other
46+
47+
48+
def check_overloaded(value: Overloaded, other: int | str) -> None:
49+
operator.lt(value, other)

‎stdlib/_interpchannels.pyi‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from _typeshed import structseq
1+
from _typeshed import FloatInt, structseq
22
from typing import Any, Final, Literal, SupportsIndex, final
33
from typing_extensions import Buffer, Self
44

@@ -76,8 +76,8 @@ def create(unboundop: Literal[1, 2, 3]) -> ChannelID: ...
7676
def destroy(cid: SupportsIndex) -> None: ...
7777
def list_all() -> list[ChannelID]: ...
7878
def list_interpreters(cid: SupportsIndex, *, send: bool) -> list[int]: ...
79-
def send(cid: SupportsIndex, obj: object, *, blocking: bool = True, timeout: float | None = None) -> None: ...
80-
def send_buffer(cid: SupportsIndex, obj: Buffer, *, blocking: bool = True, timeout: float | None = None) -> None: ...
79+
def send(cid: SupportsIndex, obj: object, *, blocking: bool = True, timeout: FloatInt | None = None) -> None: ...
80+
def send_buffer(cid: SupportsIndex, obj: Buffer, *, blocking: bool = True, timeout: FloatInt | None = None) -> None: ...
8181
def recv(cid: SupportsIndex, default: object = ...) -> tuple[Any, Literal[1, 2, 3]]: ...
8282
def close(cid: SupportsIndex, *, send: bool = False, recv: bool = False) -> None: ...
8383
def get_count(cid: SupportsIndex) -> int: ...

0 commit comments

Comments
 (0)