Skip to content

Commit 526b43b

Browse files
authored
Merge branch 'main' into abstractcontextmanger
2 parents 5599391 + 4ab04d2 commit 526b43b

File tree

312 files changed

+1302
-1431
lines changed

Some content is hidden

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

312 files changed

+1302
-1431
lines changed

.github/workflows/meta_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
version-file: "requirements-tests.txt"
6262
- run: uv pip install -r requirements-tests.txt --system
6363
- name: Run pyright on typeshed
64-
uses: jakebailey/pyright-action@v2
64+
uses: jakebailey/pyright-action@v3
6565
with:
6666
version: PATH
6767
python-platform: ${{ matrix.python-platform }}

.github/workflows/mypy_primer.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ jobs:
6262
run: |
6363
echo ${{ github.event.pull_request.number }} | tee pr_number.txt
6464
- name: Upload mypy_primer diff + PR number
65-
uses: actions/upload-artifact@v6
65+
uses: actions/upload-artifact@v7
6666
if: ${{ matrix.shard-index == 0 }}
6767
with:
6868
name: mypy_primer_diffs-${{ matrix.shard-index }}
6969
path: |
7070
diff_${{ matrix.shard-index }}.txt
7171
pr_number.txt
7272
- name: Upload mypy_primer diff
73-
uses: actions/upload-artifact@v6
73+
uses: actions/upload-artifact@v7
7474
if: ${{ matrix.shard-index != 0 }}
7575
with:
7676
name: mypy_primer_diffs-${{ matrix.shard-index }}
@@ -84,7 +84,7 @@ jobs:
8484
contents: read
8585
steps:
8686
- name: Merge artifacts
87-
uses: actions/upload-artifact/merge@v6
87+
uses: actions/upload-artifact/merge@v7
8888
with:
8989
name: mypy_primer_diffs
9090
pattern: mypy_primer_diffs-*

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,22 +118,22 @@ jobs:
118118
- name: List 3rd-party stub dependencies installed
119119
run: uv pip freeze
120120
- name: Run pyright with basic settings on all the stubs
121-
uses: jakebailey/pyright-action@v2
121+
uses: jakebailey/pyright-action@v3
122122
with:
123123
version: PATH
124124
python-platform: ${{ matrix.python-platform }}
125125
python-version: ${{ matrix.python-version }}
126126
annotate: ${{ matrix.python-version == '3.13' && matrix.python-platform == 'Linux' }} # Having each job create the same comment is too noisy.
127127
- name: Run pyright with stricter settings on some of the stubs
128-
uses: jakebailey/pyright-action@v2
128+
uses: jakebailey/pyright-action@v3
129129
with:
130130
version: PATH
131131
python-platform: ${{ matrix.python-platform }}
132132
python-version: ${{ matrix.python-version }}
133133
annotate: ${{ matrix.python-version == '3.13' && matrix.python-platform == 'Linux' }} # Having each job create the same comment is too noisy.
134134
project: ./pyrightconfig.stricter.json
135135
- name: Run pyright on the test cases
136-
uses: jakebailey/pyright-action@v2
136+
uses: jakebailey/pyright-action@v3
137137
with:
138138
version: PATH
139139
python-platform: ${{ matrix.python-platform }}

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
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/astral-sh/ruff-pre-commit
14-
rev: v0.14.10 # must match requirements-tests.txt
14+
rev: v0.15.8 # must match requirements-tests.txt
1515
hooks:
1616
- id: ruff
1717
name: Run ruff on stubs, tests and scripts
@@ -27,7 +27,7 @@ repos:
2727
- "--unsafe-fixes"
2828
files: '.*test_cases/.+\.py$'
2929
- repo: https://github.com/psf/black-pre-commit-mirror
30-
rev: 25.12.0
30+
rev: 26.3.1
3131
hooks:
3232
- id: black
3333
- repo: https://github.com/pycqa/flake8

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ supported:
163163
When the stubs are updated to a newer version
164164
of the library, the version of the stub should be bumped (note that
165165
previous versions are still available on PyPI).
166-
* `requires` (optional): A list of other stub packages or packages with type
166+
* `dependencies` (optional): A list of other stub packages or packages with type
167167
information that are imported by the stubs in this package. Only packages
168168
generated by typeshed or required by the upstream package are allowed to
169169
be listed here, for security reasons. See
@@ -202,9 +202,9 @@ This has the following keys:
202202
`--ignore_missing_stub` option to the stubtest call. See
203203
[tests/README.md](./tests/README.md) for more information. In most cases,
204204
this field should be identical to `partial_stub`.
205-
* `stubtest_requirements` (default: `[]`): A list of Python packages that need
205+
* `stubtest_dependencies` (default: `[]`): A list of Python packages that need
206206
to be installed for stubtest to run successfully. These packages are installed
207-
in addition to the requirements in the `requires` field.
207+
in addition to the dependencies in the `dependencies` field.
208208
* `apt_dependencies` (default: `[]`): A list of Ubuntu APT packages
209209
that need to be installed for stubtest to run successfully.
210210
* `brew_dependencies` (default: `[]`): A list of MacOS Homebrew packages

lib/ts_utils/metadata.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class StubtestSettings:
8484
ignore_missing_stub: bool
8585
supported_platforms: list[str] | None # None means all platforms
8686
ci_platforms: list[str]
87-
stubtest_requirements: list[str]
87+
stubtest_dependencies: list[str]
8888
mypy_plugins: list[str]
8989
mypy_plugins_config: dict[str, dict[str, Any]]
9090

@@ -109,7 +109,7 @@ def read_stubtest_settings(distribution: str) -> StubtestSettings:
109109
ignore_missing_stub: object = data.get("ignore_missing_stub", False)
110110
supported_platforms: object = data.get("supported_platforms")
111111
ci_platforms: object = data.get("ci_platforms", DEFAULT_STUBTEST_PLATFORMS)
112-
stubtest_requirements: object = data.get("stubtest_requirements", [])
112+
stubtest_dependencies: object = data.get("stubtest_dependencies", [])
113113
mypy_plugins: object = data.get("mypy_plugins", [])
114114
mypy_plugins_config: object = data.get("mypy_plugins_config", {})
115115

@@ -123,7 +123,7 @@ def read_stubtest_settings(distribution: str) -> StubtestSettings:
123123
assert _is_list_of_strings(brew_dependencies)
124124
assert _is_list_of_strings(choco_dependencies)
125125
assert _is_list_of_strings(extras)
126-
assert _is_list_of_strings(stubtest_requirements)
126+
assert _is_list_of_strings(stubtest_dependencies)
127127
assert _is_list_of_strings(mypy_plugins)
128128
assert _is_nested_dict(mypy_plugins_config)
129129

@@ -151,7 +151,7 @@ def read_stubtest_settings(distribution: str) -> StubtestSettings:
151151
ignore_missing_stub=ignore_missing_stub,
152152
supported_platforms=supported_platforms,
153153
ci_platforms=ci_platforms,
154-
stubtest_requirements=stubtest_requirements,
154+
stubtest_dependencies=stubtest_dependencies,
155155
mypy_plugins=mypy_plugins,
156156
mypy_plugins_config=mypy_plugins_config,
157157
)
@@ -174,7 +174,7 @@ class StubMetadata:
174174

175175
distribution: Annotated[str, "The name of the distribution on PyPI"]
176176
version_spec: Annotated[Specifier, "Upstream versions that the stubs are compatible with"]
177-
requires: Annotated[list[Requirement], "The parsed requirements as listed in METADATA.toml"]
177+
dependencies: Annotated[list[Requirement], "The parsed dependencies as listed in METADATA.toml"]
178178
extra_description: str | None
179179
stub_distribution: Annotated[str, "The name under which the distribution is uploaded to PyPI"]
180180
upstream_repository: Annotated[str, "The URL of the upstream repository"] | None
@@ -193,7 +193,7 @@ def is_obsolete(self) -> bool:
193193
_KNOWN_METADATA_FIELDS: Final = frozenset(
194194
{
195195
"version",
196-
"requires",
196+
"dependencies",
197197
"extra_description",
198198
"stub_distribution",
199199
"upstream_repository",
@@ -216,7 +216,7 @@ def is_obsolete(self) -> bool:
216216
"ignore_missing_stub",
217217
"supported_platforms",
218218
"ci_platforms",
219-
"stubtest_requirements",
219+
"stubtest_dependencies",
220220
"mypy_plugins",
221221
"mypy_plugins_config",
222222
}
@@ -235,7 +235,7 @@ def read_metadata(distribution: str) -> StubMetadata:
235235
This function does some basic validation,
236236
but does no parsing, transforming or normalization of the metadata.
237237
Use `read_dependencies` if you need to parse the dependencies
238-
given in the `requires` field, for example.
238+
given in the `dependencies` field, for example.
239239
"""
240240
try:
241241
with metadata_path(distribution).open("rb") as f:
@@ -255,9 +255,9 @@ def read_metadata(distribution: str) -> StubMetadata:
255255
version_spec = Specifier(version)
256256
assert version_spec.operator in {"==", "~="}, f"Invalid 'version' field in METADATA.toml for {distribution!r}"
257257

258-
requires_s: object = data.get("requires", []) # pyright: ignore[reportUnknownMemberType]
259-
assert isinstance(requires_s, list)
260-
requires = [parse_requires(distribution, req) for req in requires_s]
258+
dependencies_s: object = data.get("dependencies", []) # pyright: ignore[reportUnknownMemberType]
259+
assert isinstance(dependencies_s, list)
260+
dependencies = [parse_dependencies(distribution, dep) for dep in dependencies_s]
261261

262262
extra_description: object = data.get("extra_description") # pyright: ignore[reportUnknownMemberType]
263263
assert isinstance(extra_description, (str, type(None)))
@@ -336,7 +336,7 @@ def read_metadata(distribution: str) -> StubMetadata:
336336
return StubMetadata(
337337
distribution=distribution,
338338
version_spec=version_spec,
339-
requires=requires,
339+
dependencies=dependencies,
340340
extra_description=extra_description,
341341
stub_distribution=stub_distribution,
342342
upstream_repository=upstream_repository,
@@ -366,7 +366,7 @@ def update_metadata(distribution: str, **new_values: object) -> tomlkit.TOMLDocu
366366
return data
367367

368368

369-
def parse_requires(distribution: str, req: object) -> Requirement:
369+
def parse_dependencies(distribution: str, req: object) -> Requirement:
370370
assert isinstance(req, str), f"Invalid requirement {req!r} for {distribution!r}"
371371
return Requirement(req)
372372

@@ -398,7 +398,7 @@ def read_dependencies(distribution: str) -> PackageDependencies:
398398
pypi_name_to_typeshed_name_mapping = get_pypi_name_to_typeshed_name_mapping()
399399
typeshed: list[Requirement] = []
400400
external: list[Requirement] = []
401-
for dependency in read_metadata(distribution).requires:
401+
for dependency in read_metadata(distribution).dependencies:
402402
if dependency.name in pypi_name_to_typeshed_name_mapping:
403403
req = Requirement(str(dependency)) # copy the requirement
404404
req.name = pypi_name_to_typeshed_name_mapping[dependency.name]

lib/ts_utils/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def colored(text: str, color: str | None = None, **kwargs: Any) -> str: # type:
5050

5151

5252
def strip_comments(text: str) -> str:
53-
return text.split("#")[0].strip()
53+
return text.split("#", maxsplit=1)[0].strip()
5454

5555

5656
def jsonc_to_json(text: str) -> str:

requirements-tests.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
# Type checkers that we test our stubs against. These should always
22
# be pinned to a specific version to make failure reproducible.
3-
mypy==1.19.1
3+
mypy==1.20.0
44
pyright==1.1.408
55

66
# Libraries used by our various scripts.
7-
aiohttp==3.13.3
7+
aiohttp==3.13.5
88
grpcio-tools>=1.76.0 # For grpc_tools.protoc
9-
mypy-protobuf==4.0.0
10-
packaging==25.0
9+
mypy-protobuf==5.0.0
10+
packaging==26.0
1111
pathspec>=1.0.3
1212
pre-commit
1313
# Required by create_baseline_stubs.py. Must match .pre-commit-config.yaml.
14-
ruff==0.14.10
14+
ruff==0.15.8
1515
stubdefaulter==0.1.0
1616
termcolor>=2.3
17-
tomli==2.3.0; python_version < "3.11"
18-
tomlkit==0.13.3
17+
tomli==2.4.1; python_version < "3.11"
18+
tomlkit==0.14.0
1919
typing_extensions>=4.15.0rc1
20-
uv==0.9.22
20+
uv==0.11.2
2121

2222
# Utilities for typeshed infrastructure scripts.
2323
ts_utils @ file:lib

scripts/create_baseline_stubs.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,10 @@ def add_pyright_exclusion(stub_dir: Path) -> None:
188188

189189

190190
def main() -> None:
191-
parser = argparse.ArgumentParser(
192-
description="""Generate baseline stubs automatically for an installed pip package
191+
parser = argparse.ArgumentParser(description="""Generate baseline stubs automatically for an installed pip package
193192
using stubgen. Also run Black and Ruff. If the name of
194193
the project is different from the runtime Python package name, you may
195-
need to use --package (example: --package yaml PyYAML)."""
196-
)
194+
need to use --package (example: --package yaml PyYAML).""")
197195
parser.add_argument("project", help="name of PyPI project for which to generate stubs under stubs/")
198196
parser.add_argument("--package", help="generate stubs for this Python package (default is autodetected)")
199197
args = parser.parse_args()

scripts/stubsabot.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -844,24 +844,20 @@ def get_update_pr_body(update: Update, metadata: Mapping[str, Any]) -> str:
844844
stubtest_settings: dict[str, Any] = metadata.get("tool", {}).get("stubtest", {})
845845
stubtest_will_run = not stubtest_settings.get("skip", False)
846846
if stubtest_will_run:
847-
body += textwrap.dedent(
848-
"""
847+
body += textwrap.dedent("""
849848
850849
If stubtest fails for this PR:
851850
- Leave this PR open (as a reminder, and to prevent stubsabot from opening another PR)
852851
- Fix stubtest failures in another PR, then close this PR
853852
854853
Note that you will need to close and re-open the PR in order to trigger CI
855-
"""
856-
)
854+
""")
857855
else:
858-
body += textwrap.dedent(
859-
f"""
856+
body += textwrap.dedent(f"""
860857
861858
:warning: Review this PR manually, as stubtest is skipped in CI for {update.distribution}!
862859
Also check whether stubtest can be reenabled. :warning:
863-
"""
864-
)
860+
""")
865861
return body
866862

867863

0 commit comments

Comments
 (0)