From 4b076291c9ffae763c7e3cefaea66405699b14f8 Mon Sep 17 00:00:00 2001 From: Jon Ross-Perkins Date: Mon, 9 Mar 2026 08:49:11 -0700 Subject: [PATCH] pre-commit autoupdate (#6845) Assisted-by: Google Antigravity with Gemini --- .pre-commit-config.yaml | 4 ++-- bazel/version/gen_tmpl.py | 2 +- examples/bazel/update_module_to_nightly.py | 2 +- github_tools/github_helpers_test.py | 1 - github_tools/pr_comments.py | 1 - scripts/bench_runner.py | 2 +- scripts/fix_cc_deps.py | 2 +- scripts/lldbinit.py | 6 ++---- scripts/source_stats.py | 17 ++++++----------- toolchain/diagnostics/check_diagnostics.py | 1 - toolchain/lex/lex.cpp | 2 +- 11 files changed, 15 insertions(+), 25 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1e23e6c067c3..06a2e7ddc699 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -45,7 +45,7 @@ repos: # Formatters should be run late so that they can re-format any prior changes. - repo: https://github.com/psf/black - rev: 8a737e727ac5ab2f1d4cf5876720ed276dc8dc4b # frozen: 25.1.0 + rev: 35ea67920b7f6ac8e09be1c47278752b1e827f76 # frozen: 26.3.0 hooks: - id: black - repo: local @@ -159,7 +159,7 @@ repos: .*_test\.py )$ - repo: https://github.com/codespell-project/codespell - rev: 63c8f8312b7559622c0d82815639671ae42132ac # frozen: v2.4.1 + rev: 2ccb47ff45ad361a21071a7eedda4c37e6ae8c5a # frozen: v2.4.2 hooks: - id: codespell args: ['-I', '.codespell_ignore', '--uri-ignore-words-list', '*'] diff --git a/bazel/version/gen_tmpl.py b/bazel/version/gen_tmpl.py index 5302887a6b53..3252bdad4a4e 100755 --- a/bazel/version/gen_tmpl.py +++ b/bazel/version/gen_tmpl.py @@ -88,7 +88,7 @@ def main() -> None: # Remove line endings. line = line.rstrip("\r\n") # Exactly matches our pattern - (key, value) = line.split(" ", 1) + key, value = line.split(" ", 1) key = key.removeprefix("STABLE_") if key in substitutions: if args.verbose: diff --git a/examples/bazel/update_module_to_nightly.py b/examples/bazel/update_module_to_nightly.py index 71c64a73ca92..f6df8b161f0f 100755 --- a/examples/bazel/update_module_to_nightly.py +++ b/examples/bazel/update_module_to_nightly.py @@ -158,7 +158,7 @@ def main() -> None: version = get_latest_version() new_block = generate_override(version) - (new_content, count) = OVERRIDE_PATTERN.subn(new_block, content) + new_content, count = OVERRIDE_PATTERN.subn(new_block, content) if count > 0: log("Existing override found, replacing with a fresh one") else: diff --git a/github_tools/github_helpers_test.py b/github_tools/github_helpers_test.py index 890f27534405..d0e473bf2780 100644 --- a/github_tools/github_helpers_test.py +++ b/github_tools/github_helpers_test.py @@ -11,7 +11,6 @@ from unittest import mock import github_helpers - _TEST_QUERY = """ query { top(login: "foo") { diff --git a/github_tools/pr_comments.py b/github_tools/pr_comments.py index 21d598418bda..70f948ffc263 100755 --- a/github_tools/pr_comments.py +++ b/github_tools/pr_comments.py @@ -16,7 +16,6 @@ import importlib.util import textwrap from typing import Any, Callable, Optional - # Do some extra work to support direct runs. try: from github_tools import github_helpers diff --git a/scripts/bench_runner.py b/scripts/bench_runner.py index 6f42247d351a..902bb94db550 100755 --- a/scripts/bench_runner.py +++ b/scripts/bench_runner.py @@ -454,7 +454,7 @@ def render_fixed_width_float(x: float) -> str: if math.isinf(x): return f"{x:>4f}{'':<3}" - (frac, whole) = math.modf(x) + frac, whole = math.modf(x) frac_str = f"{math.fabs(frac):<4.3f}"[1:] return f"{int(whole):> 3}{frac_str}" diff --git a/scripts/fix_cc_deps.py b/scripts/fix_cc_deps.py index 2b2b5bd1c2f4..bb09b138158a 100755 --- a/scripts/fix_cc_deps.py +++ b/scripts/fix_cc_deps.py @@ -227,7 +227,7 @@ def get_missing_deps( file_content, re.MULTILINE, ): - (full_include, include_open, header) = header_groups + full_include, include_open, header = header_groups is_system_include = include_open == "<" if header in rule_files: diff --git a/scripts/lldbinit.py b/scripts/lldbinit.py index 87f7c22036dc..6d831f8cfe33 100644 --- a/scripts/lldbinit.py +++ b/scripts/lldbinit.py @@ -39,8 +39,7 @@ dump_re = re.compile(r'\(std::string\) "([\s\S]+)"', re.MULTILINE) # A helper to ease calling the Dump() free functions. def cmd_dump(debugger: Any, command: Any, result: Any, dict: Any) -> None: def print_usage() -> None: - print( - """ + print(""" Dumps the value of an associated ID, using the C++ Dump() functions. Usage: @@ -66,8 +65,7 @@ Example usage: # Dumps the instruction with id 42, with a `context()` method for accessing # the `Check::Context&`. dump context() inst42 -""" - ) +""") args = command.split(" ") if len(args) < 2: diff --git a/scripts/source_stats.py b/scripts/source_stats.py index da024cffd66d..eb8a53b26f1d 100755 --- a/scripts/source_stats.py +++ b/scripts/source_stats.py @@ -11,11 +11,11 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception """ import argparse -from alive_progress import alive_bar # type:ignore +from alive_progress import alive_bar # type: ignore import math from multiprocessing import Pool import re -import termplotlib as tpl # type:ignore +import termplotlib as tpl # type: ignore from pathlib import Path from typing import Optional from dataclasses import dataclass, field, asdict @@ -200,8 +200,7 @@ def main() -> None: stats.accumulate(file_stats) bar() - print( - """ + print(""" ## Stats ## Lines: %(lines)d Blank lines: %(blank_lines)d @@ -215,9 +214,7 @@ Int literals: %(int_literals)d Float literals: %(float_literals)d Symbols: %(symbols)d Keywords: %(keywords)d -IDs: %(identifiers)d""" - % asdict(stats) - ) +IDs: %(identifiers)d""" % asdict(stats)) tokens = ( stats.string_literals @@ -227,8 +224,7 @@ IDs: %(identifiers)d""" + stats.keywords + stats.identifiers ) - print( - f""" + print(f""" Fraction of blank lines: {stats.blank_lines / stats.lines} Fraction of comment lines: {stats.comment_lines / stats.lines} @@ -239,8 +235,7 @@ Fraction float literals: {stats.float_literals / tokens} Fraction symbols: {stats.symbols / tokens} Fraction keywords: {stats.keywords / tokens} Fraction IDs: {stats.identifiers / tokens} - """ - ) + """) def print_histogram( title: str, data: dict[int, int], column_format: str diff --git a/toolchain/diagnostics/check_diagnostics.py b/toolchain/diagnostics/check_diagnostics.py index 9da09756b078..b03d38868ca9 100755 --- a/toolchain/diagnostics/check_diagnostics.py +++ b/toolchain/diagnostics/check_diagnostics.py @@ -21,7 +21,6 @@ import re import sys from typing import Dict, List, NamedTuple, Set - # Example or test diagnostics, ignored because they're expected to not pass. IGNORED = set( [ diff --git a/toolchain/lex/lex.cpp b/toolchain/lex/lex.cpp index bddcacc464d6..4ca61c56b829 100644 --- a/toolchain/lex/lex.cpp +++ b/toolchain/lex/lex.cpp @@ -543,7 +543,7 @@ CARBON_DISPATCH_LEX_TOKEN(LexHash) CARBON_DISPATCH_LEX_TOKEN(LexNumericLiteral) CARBON_DISPATCH_LEX_TOKEN(LexStringLiteral) -// A set of custom dispatch functions that pre-select the symbol token to lex. +// A set of custom dispatch functions that preselect the symbol token to lex. #define CARBON_DISPATCH_LEX_SYMBOL_TOKEN(LexMethod) \ static auto Dispatch##LexMethod##SymbolToken( \ Lexer& lexer, llvm::StringRef source_text, ssize_t position) -> void { \