Skip to content

Commit 702609b

Browse files
savannahostrowskihugovk
authored andcommitted
[3.13] Bump pre-commit hooks (GH-144576)
(cherry picked from commit e682141) Co-authored-by: Savannah Ostrowski <savannah@python.org>
1 parent 57aaee5 commit 702609b

15 files changed

Lines changed: 96 additions & 103 deletions

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.14.10
3+
rev: v0.15.0
44
hooks:
55
- id: ruff-check
66
name: Run Ruff (lint) on Doc/
@@ -36,14 +36,14 @@ repos:
3636
files: ^Tools/wasm/
3737

3838
- repo: https://github.com/psf/black-pre-commit-mirror
39-
rev: 25.12.0
39+
rev: 26.1.0
4040
hooks:
4141
- id: black
4242
name: Run Black on Tools/jit/
4343
files: ^Tools/jit/
4444

4545
- repo: https://github.com/Lucas-C/pre-commit-hooks
46-
rev: v1.5.5
46+
rev: v1.5.6
4747
hooks:
4848
- id: remove-tabs
4949
types: [python]
@@ -68,19 +68,19 @@ repos:
6868
files: '^\.github/CODEOWNERS|\.(gram)$'
6969

7070
- repo: https://github.com/python-jsonschema/check-jsonschema
71-
rev: 0.36.0
71+
rev: 0.36.1
7272
hooks:
7373
- id: check-dependabot
7474
- id: check-github-workflows
7575
- id: check-readthedocs
7676

7777
- repo: https://github.com/rhysd/actionlint
78-
rev: v1.7.9
78+
rev: v1.7.10
7979
hooks:
8080
- id: actionlint
8181

8282
- repo: https://github.com/woodruffw/zizmor-pre-commit
83-
rev: v1.19.0
83+
rev: v1.22.0
8484
hooks:
8585
- id: zizmor
8686

Tools/build/check_extension_modules.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@
3030
import sys
3131
import sysconfig
3232
import warnings
33-
3433
from collections.abc import Iterable
35-
from importlib._bootstrap import _load as bootstrap_load # type: ignore[attr-defined]
36-
from importlib.machinery import BuiltinImporter, ExtensionFileLoader, ModuleSpec
34+
from importlib._bootstrap import ( # type: ignore[attr-defined]
35+
_load as bootstrap_load,
36+
)
37+
from importlib.machinery import (
38+
BuiltinImporter,
39+
ExtensionFileLoader,
40+
ModuleSpec,
41+
)
3742
from importlib.util import spec_from_file_location, spec_from_loader
3843
from typing import NamedTuple
3944

@@ -201,7 +206,7 @@ def print_three_column(modinfos: list[ModuleInfo]) -> None:
201206
# guarantee zip() doesn't drop anything
202207
while len(names) % 3:
203208
names.append("")
204-
for l, m, r in zip(names[::3], names[1::3], names[2::3]):
209+
for l, m, r in zip(names[::3], names[1::3], names[2::3]): # noqa: E741
205210
print("%-*s %-*s %-*s" % (longest, l, longest, m, longest, r))
206211

207212
if verbose and self.builtin_ok:
@@ -433,7 +438,7 @@ def check_module_import(self, modinfo: ModuleInfo) -> None:
433438
except ImportError as e:
434439
logger.error("%s failed to import: %s", modinfo.name, e)
435440
raise
436-
except Exception as e:
441+
except Exception:
437442
if not hasattr(_imp, 'create_dynamic'):
438443
logger.warning("Dynamic extension '%s' ignored", modinfo.name)
439444
return

Tools/build/deepfreeze.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
import re
1717
import time
1818
import types
19+
1920
import umarshal
2021

2122
TYPE_CHECKING = False
2223
if TYPE_CHECKING:
2324
from collections.abc import Iterator
24-
from typing import Any, TextIO, Dict, FrozenSet, TextIO, Tuple
25+
from typing import Any, TextIO
2526

2627
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
2728

@@ -63,8 +64,8 @@ def get_localsplus(code: types.CodeType) -> tuple[tuple[str, ...], bytes]:
6364

6465

6566
def get_localsplus_counts(code: types.CodeType,
66-
names: Tuple[str, ...],
67-
kinds: bytes) -> Tuple[int, int, int]:
67+
names: tuple[str, ...],
68+
kinds: bytes) -> tuple[int, int, int]:
6869
nlocals = 0
6970
ncellvars = 0
7071
nfreevars = 0
@@ -90,7 +91,7 @@ def get_localsplus_counts(code: types.CodeType,
9091
PyUnicode_4BYTE_KIND = 4
9192

9293

93-
def analyze_character_width(s: str) -> Tuple[int, bool]:
94+
def analyze_character_width(s: str) -> tuple[int, bool]:
9495
maxchar = ' '
9596
for c in s:
9697
maxchar = max(maxchar, c)
@@ -115,7 +116,7 @@ class Printer:
115116
def __init__(self, file: TextIO) -> None:
116117
self.level = 0
117118
self.file = file
118-
self.cache: Dict[tuple[type, object, str], str] = {}
119+
self.cache: dict[tuple[type, object, str], str] = {}
119120
self.hits, self.misses = 0, 0
120121
self.finis: list[str] = []
121122
self.inits: list[str] = []
@@ -319,7 +320,7 @@ def generate_code(self, name: str, code: types.CodeType) -> str:
319320
self.inits.append(f"_PyStaticCode_Init({name_as_code})")
320321
return f"& {name}.ob_base.ob_base"
321322

322-
def generate_tuple(self, name: str, t: Tuple[object, ...]) -> str:
323+
def generate_tuple(self, name: str, t: tuple[object, ...]) -> str:
323324
if len(t) == 0:
324325
return f"(PyObject *)& _Py_SINGLETON(tuple_empty)"
325326
items = [self.generate(f"{name}_{i}", it) for i, it in enumerate(t)]
@@ -393,7 +394,7 @@ def generate_complex(self, name: str, z: complex) -> str:
393394
self.write(f".cval = {{ {z.real}, {z.imag} }},")
394395
return f"&{name}.ob_base"
395396

396-
def generate_frozenset(self, name: str, fs: FrozenSet[Any]) -> str:
397+
def generate_frozenset(self, name: str, fs: frozenset[Any]) -> str:
397398
try:
398399
fs_sorted = sorted(fs)
399400
except TypeError:
@@ -479,7 +480,7 @@ def generate(args: list[str], output: TextIO) -> None:
479480
printer = Printer(output)
480481
for arg in args:
481482
file, modname = arg.rsplit(':', 1)
482-
with open(file, "r", encoding="utf8") as fd:
483+
with open(file, encoding="utf8") as fd:
483484
source = fd.read()
484485
if is_frozen_header(source):
485486
code = decode_frozen_data(source)
@@ -527,7 +528,7 @@ def main() -> None:
527528
if args.file:
528529
if verbose:
529530
print(f"Reading targets from {args.file}")
530-
with open(args.file, "rt", encoding="utf-8-sig") as fin:
531+
with open(args.file, encoding="utf-8-sig") as fin:
531532
rules = [x.strip() for x in fin]
532533
else:
533534
rules = args.args

Tools/build/freeze_modules.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
See the notes at the top of Python/frozen.c for more info.
44
"""
55

6-
from collections import namedtuple
76
import hashlib
8-
import os
97
import ntpath
8+
import os
109
import posixpath
11-
import argparse
12-
from update_file import updating_file_with_tmpfile
10+
from collections import namedtuple
1311

12+
from update_file import updating_file_with_tmpfile
1413

1514
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
1615
ROOT_DIR = os.path.abspath(ROOT_DIR)
@@ -485,7 +484,6 @@ def regen_frozen(modules):
485484
header = relpath_for_posix_display(src.frozenfile, parentdir)
486485
headerlines.append(f'#include "{header}"')
487486

488-
externlines = UniqueList()
489487
bootstraplines = []
490488
stdliblines = []
491489
testlines = []
@@ -628,7 +626,6 @@ def regen_makefile(modules):
628626
def regen_pcbuild(modules):
629627
projlines = []
630628
filterlines = []
631-
corelines = []
632629
for src in _iter_sources(modules):
633630
pyfile = relpath_for_windows_display(src.pyfile, ROOT_DIR)
634631
header = relpath_for_windows_display(src.frozenfile, ROOT_DIR)

Tools/build/generate_global_objects.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ def generate_runtime_init(identifiers, strings):
286286
break
287287
else:
288288
raise NotImplementedError
289-
assert nsmallposints and nsmallnegints
289+
assert nsmallposints
290+
assert nsmallnegints
290291

291292
# Then target the runtime initializer.
292293
filename = os.path.join(INTERNAL, 'pycore_runtime_init_generated.h')
@@ -434,7 +435,7 @@ def get_identifiers_and_strings() -> 'tuple[set[str], dict[str, str]]':
434435
# To cover tricky cases (like "\n") we also generate C asserts.
435436
raise ValueError(
436437
'do not use &_PyID or &_Py_STR for one-character latin-1 '
437-
+ f'strings, use _Py_LATIN1_CHR instead: {string!r}')
438+
f'strings, use _Py_LATIN1_CHR instead: {string!r}')
438439
if string not in strings:
439440
strings[string] = name
440441
elif name != strings[string]:

Tools/build/generate_levenshtein_examples.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
"""Generate 10,000 unique examples for the Levenshtein short-circuit tests."""
22

33
import argparse
4-
from functools import lru_cache
54
import json
65
import os.path
6+
from functools import lru_cache
77
from random import choices, randrange
88

9-
109
# This should be in sync with Lib/traceback.py. It's not importing those values
1110
# because this script is being executed by PYTHON_FOR_REGEN and not by the in-tree
1211
# build of Python.

Tools/build/generate_re_casefix.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
def update_file(file, content):
1111
try:
12-
with open(file, 'r', encoding='utf-8') as fobj:
12+
with open(file, encoding='utf-8') as fobj:
1313
if fobj.read() == content:
1414
return False
1515
except (OSError, ValueError):
@@ -50,7 +50,7 @@ def main(outfile='Lib/re/_casefix.py'):
5050
# List of codes of lowercased characters which have the same uppercase.
5151
equivalent_lower_codes = [sorted(t)
5252
for s in equivalent_chars
53-
for t in [set(ord(c.lower()) for c in s)]
53+
for t in [{ord(c.lower()) for c in s}]
5454
if len(t) > 1]
5555

5656
bad_codes = []

Tools/build/generate_sbom.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
"""Tool for generating Software Bill of Materials (SBOM) for Python's dependencies"""
2+
3+
import glob
4+
import hashlib
5+
import json
26
import os
37
import random
48
import re
5-
import hashlib
6-
import json
7-
import glob
8-
from pathlib import Path, PurePosixPath, PureWindowsPath
99
import subprocess
1010
import sys
1111
import time
1212
import typing
1313
import urllib.error
1414
import urllib.request
15-
import typing
15+
from pathlib import Path, PurePosixPath, PureWindowsPath
1616

1717
CPYTHON_ROOT_DIR = Path(__file__).parent.parent.parent
1818

@@ -274,7 +274,7 @@ def check_sbom_packages(sbom_data: dict[str, typing.Any]) -> None:
274274
license_concluded = package["licenseConcluded"]
275275
error_if(
276276
license_concluded != "NOASSERTION",
277-
f"License identifier must be 'NOASSERTION'"
277+
"License identifier must be 'NOASSERTION'"
278278
)
279279

280280

Tools/build/generate_sre_constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
def update_file(file, content):
88
try:
9-
with open(file, 'r') as fobj:
9+
with open(file) as fobj:
1010
if fobj.read() == content:
1111
return False
1212
except (OSError, ValueError):

Tools/build/generate_stdlib_module_names.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
from check_extension_modules import ModuleChecker
1212

13-
1413
SCRIPT_NAME = 'Tools/build/generate_stdlib_module_names.py'
1514

1615
SRC_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))

0 commit comments

Comments
 (0)