Skip to content

Commit 3181e9b

Browse files
authored
Merge branch 'main' into removing-setuptools._distutils
2 parents 293f2fe + 76cd40e commit 3181e9b

File tree

323 files changed

+4556
-4133
lines changed

Some content is hidden

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

323 files changed

+4556
-4133
lines changed

.github/renovate.json5

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,26 @@
77
"semanticCommits": "disabled",
88
"separateMajorMinor": false,
99
"prHourlyLimit": 10,
10+
// This package rule disables updates for `actions/setup-python` Python versions:
11+
// it's better to do these manually as there's often a reason why we can't use
12+
// the latest Python version in CI for a specific job
13+
ignoreDeps: ["python"],
1014
"pre-commit": {
1115
"enabled": true
1216
},
1317
"packageRules": [
1418
{
15-
"groupName": "GitHub Actions",
16-
"matchManagers": ["github-actions"],
17-
"description": "Quarterly update of GitHub Action dependencies",
18-
"schedule": ["every 3 months on the first day of the month"]
19-
},
20-
{
21-
// This package rule disables updates for `actions/setup-python` Python versions:
22-
// it's better to do these manually as there's often a reason why we can't use
23-
// the latest Python version in CI for a specific job
24-
groupName: "Python versions",
19+
groupName: "GitHub Actions",
2520
matchManagers: ["github-actions"],
26-
matchPackageNames: ["python"],
27-
description: "Disable PRs updating Python versions",
28-
enabled: false,
21+
description: "Quarterly update of GitHub Action dependencies",
22+
schedule: ["every 3 months on the first day of the month"]
2923
},
3024
{
31-
"groupName": "most test/lint dependencies",
32-
"matchManagers": ["pip_requirements", "pre-commit"],
33-
"excludePackageNames": ["pytype", "pyright"],
34-
"description": "Quarterly update of most test dependencies",
35-
"schedule": ["every 3 months on the first day of the month"]
25+
groupName: "most test/lint dependencies",
26+
matchManagers: ["pip_requirements", "pre-commit"],
27+
matchPackageNames: ["!pytype", "!pyright"],
28+
description: "Quarterly update of most test dependencies",
29+
schedule: ["every 3 months on the first day of the month"]
3630
},
3731
{
3832
"groupName": "pytype and pyright",

.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/astral-sh/ruff-pre-commit
14-
rev: v0.11.2 # must match requirements-tests.txt
14+
rev: v0.11.4 # must match requirements-tests.txt
1515
hooks:
1616
- id: ruff
1717
name: Run ruff on stubs, tests and scripts

lib/ts_utils/metadata.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55

66
from __future__ import annotations
77

8+
import functools
89
import re
910
import urllib.parse
1011
from collections.abc import Mapping
1112
from dataclasses import dataclass
1213
from pathlib import Path
13-
from typing import Final, NamedTuple, final
14-
from typing_extensions import Annotated, TypeGuard
14+
from typing import Annotated, Final, NamedTuple, final
15+
from typing_extensions import TypeGuard
1516

1617
import tomli
1718
import tomlkit
1819
from packaging.requirements import Requirement
1920
from packaging.specifiers import Specifier
2021

2122
from .paths import PYPROJECT_PATH, STUBS_PATH, distribution_path
22-
from .utils import cache
2323

2424
__all__ = [
2525
"NoSuchStubError",
@@ -42,7 +42,7 @@ def _is_list_of_strings(obj: object) -> TypeGuard[list[str]]:
4242
return isinstance(obj, list) and all(isinstance(item, str) for item in obj)
4343

4444

45-
@cache
45+
@functools.cache
4646
def _get_oldest_supported_python() -> str:
4747
with PYPROJECT_PATH.open("rb") as config:
4848
val = tomli.load(config)["tool"]["typeshed"]["oldest_supported_python"]
@@ -79,7 +79,7 @@ def system_requirements_for_platform(self, platform: str) -> list[str]:
7979
return ret
8080

8181

82-
@cache
82+
@functools.cache
8383
def read_stubtest_settings(distribution: str) -> StubtestSettings:
8484
"""Return an object describing the stubtest settings for a single stubs distribution."""
8585
with metadata_path(distribution).open("rb") as f:
@@ -188,7 +188,7 @@ class NoSuchStubError(ValueError):
188188
"""Raise NoSuchStubError to indicate that a stubs/{distribution} directory doesn't exist."""
189189

190190

191-
@cache
191+
@functools.cache
192192
def read_metadata(distribution: str) -> StubMetadata:
193193
"""Return an object describing the metadata of a stub as given in the METADATA.toml file.
194194
@@ -329,12 +329,12 @@ class PackageDependencies(NamedTuple):
329329
external_pkgs: tuple[Requirement, ...]
330330

331331

332-
@cache
332+
@functools.cache
333333
def get_pypi_name_to_typeshed_name_mapping() -> Mapping[str, str]:
334334
return {read_metadata(stub_dir.name).stub_distribution: stub_dir.name for stub_dir in STUBS_PATH.iterdir()}
335335

336336

337-
@cache
337+
@functools.cache
338338
def read_dependencies(distribution: str) -> PackageDependencies:
339339
"""Read the dependencies listed in a METADATA.toml file for a stubs package.
340340
@@ -361,7 +361,7 @@ def read_dependencies(distribution: str) -> PackageDependencies:
361361
return PackageDependencies(tuple(typeshed), tuple(external))
362362

363363

364-
@cache
364+
@functools.cache
365365
def get_recursive_requirements(package_name: str) -> PackageDependencies:
366366
"""Recursively gather dependencies for a single stubs package.
367367

lib/ts_utils/utils.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
from __future__ import annotations
44

5+
import functools
56
import re
67
import sys
78
from collections.abc import Iterable, Mapping
8-
from functools import lru_cache
99
from pathlib import Path
10-
from typing import Any, Dict, Final, NamedTuple, Tuple
10+
from typing import Any, Final, NamedTuple
1111
from typing_extensions import TypeAlias
1212

1313
import pathspec
@@ -26,11 +26,6 @@ def colored(text: str, color: str | None = None, **kwargs: Any) -> str: # type:
2626
PYTHON_VERSION: Final = f"{sys.version_info.major}.{sys.version_info.minor}"
2727

2828

29-
# A backport of functools.cache for Python <3.9
30-
# This module is imported by mypy_test.py, which needs to run on 3.8 in CI
31-
cache = lru_cache(None)
32-
33-
3429
def strip_comments(text: str) -> str:
3530
return text.split("#")[0].strip()
3631

@@ -81,7 +76,7 @@ def print_time(t: float) -> None:
8176
# ====================================================================
8277

8378

84-
@cache
79+
@functools.cache
8580
def venv_python(venv_dir: Path) -> Path:
8681
if sys.platform == "win32":
8782
return venv_dir / "Scripts" / "python.exe"
@@ -93,7 +88,7 @@ def venv_python(venv_dir: Path) -> Path:
9388
# ====================================================================
9489

9590

96-
@cache
91+
@functools.cache
9792
def parse_requirements() -> Mapping[str, Requirement]:
9893
"""Return a dictionary of requirements from the requirements file."""
9994
with REQUIREMENTS_PATH.open(encoding="UTF-8") as requirements_file:
@@ -111,8 +106,8 @@ def get_mypy_req() -> str:
111106
# Parsing the stdlib/VERSIONS file
112107
# ====================================================================
113108

114-
VersionTuple: TypeAlias = Tuple[int, int]
115-
SupportedVersionsDict: TypeAlias = Dict[str, Tuple[VersionTuple, VersionTuple]]
109+
VersionTuple: TypeAlias = tuple[int, int]
110+
SupportedVersionsDict: TypeAlias = dict[str, tuple[VersionTuple, VersionTuple]]
116111

117112
VERSIONS_PATH = STDLIB_PATH / "VERSIONS"
118113
VERSION_LINE_RE = re.compile(r"^([a-zA-Z_][a-zA-Z0-9_.]*): ([23]\.\d{1,2})-([23]\.\d{1,2})?$")
@@ -206,10 +201,10 @@ def allowlists(distribution_name: str) -> list[str]:
206201
# ====================================================================
207202

208203

209-
@cache
204+
@functools.cache
210205
def get_gitignore_spec() -> pathspec.PathSpec:
211206
with open(".gitignore", encoding="UTF-8") as f:
212-
return pathspec.PathSpec.from_lines("gitwildmatch", f.readlines())
207+
return pathspec.GitIgnoreSpec.from_lines(f)
213208

214209

215210
def spec_matches_path(spec: pathspec.PathSpec, path: Path) -> bool:

pyproject.toml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ force-exclude = ".*_pb2.pyi"
1818
[tool.ruff]
1919
line-length = 130
2020
# Oldest supported Python version
21-
target-version = "py38"
21+
target-version = "py39"
2222
fix = true
2323
exclude = [
2424
# virtual environment
@@ -47,14 +47,23 @@ select = [
4747
"A", # flake8-builtins
4848
"ARG", # flake8-unused-arguments
4949
"B", # flake8-bugbear
50+
"C4", # flake8-comprehensions
5051
"D", # pydocstyle
52+
"DTZ", # flake8-datetimez
5153
"EXE", # flake8-executable
5254
"FA", # flake8-future-annotations
55+
"FBT", # flake8-boolean-trap
56+
"FLY", # flynt
5357
"I", # isort
5458
"N", # pep8-naming
5559
"PGH", # pygrep-hooks
60+
"PIE", # flake8-pie
5661
"PL", # Pylint
62+
"RSE", # flake8-raise
5763
"RUF", # Ruff-specific and unused-noqa
64+
"SLOT", # flake8-slots
65+
"T10", # flake8-debugger
66+
"TD", # flake8-todos
5867
"TRY", # tryceratops
5968
"UP", # pyupgrade
6069
"YTT", # flake8-2020
@@ -159,6 +168,11 @@ ignore = [
159168
"PLR2004", # Magic value used in comparison, consider replacing `{value}` with a constant variable
160169
# Keep codeflow path separation explicit
161170
"PLR5501", # Use `elif` instead of `else` then `if`, to reduce indentation
171+
# Allow FIXME
172+
"TD001", # Invalid TODO tag: `{tag}`
173+
# Git blame is sufficient
174+
"TD002", # Missing author in TODO;
175+
"TD003", # Missing issue link for this TODO
162176
# Mostly from scripts and tests, it's ok to have messages passed directly to exceptions
163177
"TRY003", # Avoid specifying long messages outside the exception class
164178
# Slower and more verbose https://github.com/astral-sh/ruff/issues/7871

pyrightconfig.stricter.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"stdlib/tkinter/ttk.pyi",
2525
"stubs/aiofiles/aiofiles/tempfile/temptypes.pyi",
2626
"stubs/antlr4-python3-runtime",
27+
"stubs/auth0-python",
2728
"stubs/Authlib",
2829
"stubs/aws-xray-sdk",
2930
"stubs/beautifulsoup4",

requirements-tests.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Type checkers that we test our stubs against. These should always
22
# be pinned to a specific version to make failure reproducible.
33
mypy==1.15.0
4-
pyright==1.1.398
4+
pyright==1.1.399
55
# pytype can be installed on Windows, but requires building wheels, let's not do that on the CI
66
pytype==2024.10.11; platform_system != "Windows" and python_version >= "3.10" and python_version < "3.13"
77

@@ -13,7 +13,7 @@ packaging==24.2
1313
pathspec>=0.11.1
1414
pre-commit
1515
# Required by create_baseline_stubs.py. Must match .pre-commit-config.yaml.
16-
ruff==0.11.2
16+
ruff==0.11.4
1717
stubdefaulter==0.1.0
1818
termcolor>=2.3
1919
tomli==2.2.1

scripts/stubsabot.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,6 @@ async def suggest_typeshed_obsolete(obsolete: Obsolete, session: aiohttp.ClientS
730730

731731

732732
async def main() -> None:
733-
assert sys.version_info >= (3, 9)
734-
735733
parser = argparse.ArgumentParser()
736734
parser.add_argument(
737735
"--action-level",

scripts/sync_protobuf/_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
import subprocess
44
import sys
5+
from collections.abc import Iterable
56
from http.client import HTTPResponse
6-
from typing import TYPE_CHECKING, Iterable
7+
from typing import TYPE_CHECKING
78
from urllib.request import urlopen
89
from zipfile import ZipFile
910

stdlib/@tests/stubtest_allowlists/darwin-py313.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,4 @@
22
# >= 3.13
33
# =======
44

5-
# Depends on HAVE_NCURSESW and how we install CPython,
6-
# should be removed when 3.13 will be officially released:
7-
_?curses.unget_wch
8-
_?curses.window.get_wch
9-
105
(mmap.MAP_32BIT)? # Exists locally on MacOS but not on GitHub

0 commit comments

Comments
 (0)