Skip to content

Commit d79bdc9

Browse files
authored
Merge branch 'main' into Enable-Ruff-flake8-pie-(PIE)
2 parents 280f776 + bf8d2a9 commit d79bdc9

File tree

615 files changed

+1936
-15394
lines changed

Some content is hidden

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

615 files changed

+1936
-15394
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@
1717
"description": "Quarterly update of GitHub Action dependencies",
1818
"schedule": ["every 3 months on the first day of the month"]
1919
},
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",
25+
matchManagers: ["github-actions"],
26+
matchPackageNames: ["python"],
27+
description: "Disable PRs updating Python versions",
28+
enabled: false,
29+
},
2030
{
2131
"groupName": "most test/lint dependencies",
2232
"matchManagers": ["pip_requirements", "pre-commit"],

.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.9.3 # must match requirements-tests.txt
14+
rev: v0.11.2 # must match requirements-tests.txt
1515
hooks:
1616
- id: ruff
1717
name: Run ruff on stubs, tests and scripts
@@ -31,7 +31,7 @@ repos:
3131
hooks:
3232
- id: black
3333
- repo: https://github.com/pycqa/flake8
34-
rev: 7.1.2
34+
rev: 7.2.0
3535
hooks:
3636
- id: flake8
3737
language: python

lib/ts_utils/paths.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# installed into the user's virtual env, so we can't determine the path
66
# to typeshed. Installing ts_utils editable would solve that, see
77
# https://github.com/python/typeshed/pull/12806.
8-
TS_BASE_PATH: Final = Path("")
8+
TS_BASE_PATH: Final = Path()
99
STDLIB_PATH: Final = TS_BASE_PATH / "stdlib"
1010
STUBS_PATH: Final = TS_BASE_PATH / "stubs"
1111

lib/ts_utils/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ def parse_stdlib_versions_file() -> SupportedVersionsDict:
123123
result: dict[str, tuple[VersionTuple, VersionTuple]] = {}
124124
with VERSIONS_PATH.open(encoding="UTF-8") as f:
125125
for line in f:
126-
line = strip_comments(line)
127-
if line == "":
126+
stripped_line = strip_comments(line)
127+
if stripped_line == "":
128128
continue
129-
m = VERSION_LINE_RE.match(line)
130-
assert m, f"invalid VERSIONS line: {line}"
129+
m = VERSION_LINE_RE.match(stripped_line)
130+
assert m, f"invalid VERSIONS line: {stripped_line}"
131131
mod: str = m.group(1)
132132
assert mod not in result, f"Duplicate module {mod} in VERSIONS"
133133
min_version = _parse_version(m.group(2))

pyproject.toml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ select = [
5454
"N", # pep8-naming
5555
"PGH", # pygrep-hooks
5656
"PIE", # flake8-pie
57-
"PLC", # Pylint Convention
58-
"PLE", # Pylint Error
59-
"PLR", # Pylint Refactor
57+
"PL", # Pylint
6058
"RUF", # Ruff-specific and unused-noqa
6159
"TRY", # tryceratops
6260
"UP", # pyupgrade
@@ -77,6 +75,9 @@ select = [
7775
"FURB169", # Compare the identities of `{object}` and None instead of their respective types
7876
"FURB177", # Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups
7977
"FURB187", # Use of assignment of `reversed` on list `{name}`
78+
# Autofixable flake8-use-pathlib only
79+
"PTH201", # Do not pass the current directory explicitly to `Path`
80+
"PTH210", # Invalid suffix passed to `.with_suffix()`
8081
# PYI: only enable rules that have autofixes and that we always want to fix (even manually),
8182
# avoids duplicate # noqa with flake8-pyi
8283
"PYI009", # Empty body should contain `...`, not pass
@@ -184,15 +185,19 @@ ignore = [
184185
# Rules that are out of the control of stub authors:
185186
###
186187
# Names in stubs should match the implementation, even if it's ambiguous.
188+
# https://github.com/astral-sh/ruff/issues/15293
187189
"A", # flake8-builtins
188-
"F403", # `from . import *` used; unable to detect undefined names
189190
# Stubs can sometimes re-export entire modules.
190191
# Issues with using a star-imported name will be caught by type-checkers.
192+
"F403", # `from . import *` used; unable to detect undefined names
191193
"F405", # may be undefined, or defined from star imports
192194
# Most pep8-naming rules don't apply for third-party stubs like typeshed.
193195
# N811 to N814 could apply, but we often use them to disambiguate a name whilst making it look like a more common one
194196
"N8", # pep8-naming
197+
# Stubs are allowed to use private variables (pyright's reportPrivateUsage is also disabled)
195198
"PLC2701", # Private name import from external module
199+
# Names in stubs should match implementation
200+
"PLW0211", # First argument of a static method should not be named `{argument_name}`
196201
]
197202
"lib/ts_utils/**" = [
198203
# Doesn't affect stubs. The only re-exports we have should be in our local lib ts_utils

pyrightconfig.stricter.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
"stubs/httplib2",
5050
"stubs/hvac",
5151
"stubs/icalendar",
52-
"stubs/influxdb-client",
5352
"stubs/jmespath",
5453
"stubs/jsonschema",
5554
"stubs/jwcrypto",

requirements-tests.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ pyright==1.1.398
66
pytype==2024.10.11; platform_system != "Windows" and python_version >= "3.10" and python_version < "3.13"
77

88
# Libraries used by our various scripts.
9-
aiohttp==3.10.11
9+
aiohttp==3.11.15
1010
grpcio-tools>=1.66.2 # For grpc_tools.protoc
1111
mypy-protobuf==3.6.0
1212
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.9.3
16+
ruff==0.11.2
1717
stubdefaulter==0.1.0
1818
termcolor>=2.3
1919
tomli==2.2.1
2020
tomlkit==0.13.2
2121
typing_extensions>=4.13.0rc1
22-
uv==0.5.14
22+
uv==0.6.11
2323

2424
# Utilities for typeshed infrastructure scripts.
2525
ts_utils @ file:lib

scripts/create_baseline_stubs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ def run_stubgen(package: str, output: str) -> None:
5959

6060
def run_stubdefaulter(stub_dir: str) -> None:
6161
print(f"Running stubdefaulter: stubdefaulter --packages {stub_dir}")
62-
subprocess.run(["stubdefaulter", "--packages", stub_dir])
62+
subprocess.run(["stubdefaulter", "--packages", stub_dir], check=False)
6363

6464

6565
def run_black(stub_dir: str) -> None:
6666
print(f"Running Black: black {stub_dir}")
67-
subprocess.run(["pre-commit", "run", "black", "--files", *glob.iglob(f"{stub_dir}/**/*.pyi")])
67+
subprocess.run(["pre-commit", "run", "black", "--files", *glob.iglob(f"{stub_dir}/**/*.pyi")], check=False)
6868

6969

7070
def run_ruff(stub_dir: str) -> None:
7171
print(f"Running Ruff: ruff check {stub_dir} --fix-only")
72-
subprocess.run([sys.executable, "-m", "ruff", "check", stub_dir, "--fix-only"])
72+
subprocess.run([sys.executable, "-m", "ruff", "check", stub_dir, "--fix-only"], check=False)
7373

7474

7575
async def get_project_urls_from_pypi(project: str, session: aiohttp.ClientSession) -> dict[str, str]:
@@ -102,9 +102,9 @@ async def get_upstream_repo_url(project: str) -> str | None:
102102
url for url_name, url in project_urls.items() if url_name not in url_names_probably_pointing_to_source
103103
)
104104

105-
for url in urls_to_check:
105+
for url_to_check in urls_to_check:
106106
# Remove `www.`; replace `http://` with `https://`
107-
url = re.sub(r"^(https?://)?(www\.)?", "https://", url)
107+
url = re.sub(r"^(https?://)?(www\.)?", "https://", url_to_check)
108108
netloc = urllib.parse.urlparse(url).netloc
109109
if netloc in {"gitlab.com", "github.com", "bitbucket.org", "foss.heptapod.net"}:
110110
# truncate to https://site.com/user/repo

scripts/stubsabot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,8 @@ async def main() -> None:
754754
dists_to_update = [path.name for path in STUBS_PATH.iterdir()]
755755

756756
if args.action_level > ActionLevel.nothing:
757-
subprocess.run(["git", "update-index", "--refresh"], capture_output=True)
758-
diff_result = subprocess.run(["git", "diff-index", "HEAD", "--name-only"], text=True, capture_output=True)
757+
subprocess.run(["git", "update-index", "--refresh"], capture_output=True, check=False)
758+
diff_result = subprocess.run(["git", "diff-index", "HEAD", "--name-only"], text=True, capture_output=True, check=False)
759759
if diff_result.returncode:
760760
print("Unexpected exception!")
761761
print(diff_result.stdout)

scripts/sync_protobuf/_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ def run_protoc(
3535
) -> str:
3636
"""TODO: Describe parameters and return."""
3737
protoc_version = (
38-
subprocess.run([sys.executable, "-m", "grpc_tools.protoc", "--version"], capture_output=True).stdout.decode().strip()
38+
subprocess.run([sys.executable, "-m", "grpc_tools.protoc", "--version"], capture_output=True, check=False)
39+
.stdout.decode()
40+
.strip()
3941
)
4042
print()
4143
print(protoc_version)

0 commit comments

Comments
 (0)