`pre-commit` CI fails: cmake-format (cmakelang) crashes on Python 3.15
Maintainers usually reply within 3 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- cmake, github-actions, python
- Domain
- build-system, ci-cd, tooling
Research direction
Start by reading .pre-commit-config.yaml and the pre-commit GitHub workflow to see how the cmake-format hook and Python version are selected. Run pre-commit run --all-files under Python 3.15 to reproduce the failure. Compare the proposed gersemi replacement with pinning Python below 3.15, then confirm the selected approach works across all CMake files and hooks.
Written by the indexing model from the issue text.
Description
Issue applies to:
- PFLOW
- OPFLOW
- TCOPFLOW
- SCOPFLOW
- SOPFLOW
- CMake and build system
- Spack
- Visualization
- Documentation
- Other
Summary
The pre-commit GitHub workflow currently fails on every run because the cmake-format hook executes under Python 3.15.0 on the hosted runner.
The hook is backed by the cmakelang package (v0.6.13, pinned via cheshirekow/cmake-format-precommit). Its lexer builds an re.Scanner from regexes that contain capturing groups. Python 3.15 added a guard that rejects this:
ValueError: Cannot use capturing groups in re.Scanner
The scanner fails to construct before any formatting takes place, so every CMake file in the repository fails with the same traceback (e.g. src/CMakeLists.txt, buildsystem/clang-hip/cache.cmake, interfaces/python/CMakeLists.txt, tests/unit/opflow/objective/CMakeLists.txt). The CMake files themselves are not at fault.
cmakelang has had no release since 2021, so an upstream fix is unlikely. All other hooks (clang-format, check-toml, forbid-new-submodules, end-of-file-fixer, check-yaml) pass.
Description how to reproduce the issue
Observed in the pre-commit workflow on branch suggestion_gridkit_tapfix_precision_eve:
$ pre-commit run --show-diff-on-failure --color=always --all-files
cmake-format.............................................................Failed
- hook id: cmake-format
- exit code: 1
WARNING __main__.py:530: While processing src/CMakeLists.txt
Traceback (most recent call last):
File ".../py_env-python3.15/bin/cmake-format", line 6, in <module>
sys.exit(main())
File ".../cmakelang/format/__main__.py", line 633, in main
return inner_main()
File ".../cmakelang/format/__main__.py", line 616, in inner_main
onefile_main(infile_path, args, argparse_dict)
File ".../cmakelang/format/__main__.py", line 526, in onefile_main
outtext, reflow_valid = process_file(cfg, intext, args.dump)
File ".../cmakelang/format/__main__.py", line 144, in process_file
tokens = lex.tokenize(infile_content)
File ".../cmakelang/lex/__init__.py", line 135, in tokenize
scanner = re.Scanner([
...
], re.DOTALL)
File "/opt/hostedtoolcache/Python/3.15.0/x64/lib/python3.15/re/__init__.py", line 406, in __init__
raise ValueError("Cannot use capturing groups in re.Scanner")
ValueError: Cannot use capturing groups in re.Scanner
The same traceback repeats for every CMake file. Reproducible locally with pre-commit run --all-files under any Python >= 3.15.
ExaGO version
Branch suggestion_gridkit_tapfix_precision_eve (develop-based, untagged)
System and environment details
- GitHub Actions hosted runner,
ubuntu-latest actions/setup-pythonresolving to Python 3.15.0 (/opt/hostedtoolcache/Python/3.15.0/x64)- pre-commit hooks pinned in
.pre-commit-config.yaml:cheshirekow/cmake-format-precommitv0.6.13 (cmakelang 0.6.13)pre-commit/mirrors-clang-formatv10.0.1pre-commit/pre-commit-hooksv4.4.0
- Not hardware/compiler dependent; this is a pure Python tooling failure in CI.
Additional information
Context: re.Scanner is an undocumented stdlib class; Python 3.15 started validating that the lexer patterns passed to it contain no capturing groups. cmakelang relies on capturing groups in its tokenizer patterns and is unmaintained (last release 0.6.13, 2021), so the hook will remain broken on 3.15+ runners.
Also noted in the same log (unrelated, harmless): pre-commit-hooks v4.4.0 uses deprecated stage names; pre-commit autoupdate would clear that warning.
Proposed solution
Preferred: replace the unmaintained hook with gersemi, which is actively maintained and runs on current Python:
- repo: https://github.com/BlankSpruce/gersemi
rev: 0.27.7 # run `pre-commit autoupdate` to pin latest
hooks:
- id: gersemi
Then run pre-commit run --all-files once and commit the resulting CMake reformat as a standalone commit. Style can be tuned via a .gersemirc if the default output differs too much from the current formatting; project-defined functions/macros can be registered via its definitions option.
Short-term alternative: pin the pre-commit interpreter to a Python < 3.15 (e.g. default_language_version: {python: python3.14} plus a matching actions/setup-python version), which keeps cmake-format working but leaves the dead dependency in place.
- Dominant language
- Python
- Stars
- 17
- Forks
- 11
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 2
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ORNL/ExaGO
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 3 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 3 days
-
[E38] a DC line at the reference bus demotes it to PV: `PSSetUp`'s condition is always trueMay be free again @hambrickjc claimed this 50 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
ORNL/ExaGO#109 · 3 comments · 1 assignee ·
Maintainers usually reply within 3 days
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Maintainers usually reply within 3 days
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
Maintainers usually reply within 3 days
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Netcracker/qubership-ai-packages#266 ·
Maintainers usually reply within 1 day
-
PROCESSED_DATA_FOLDER: strip whitespace and treat empty as unsetPossibly taken @TorecLuik claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
NL-BioImaging/BIOMERO.importer#63 ·
Maintainers usually reply within 1 day
-
MLX training-complete chat/merge suggestions omit --backend mlxPossibly taken @vaputa claimed this today. Openneeds-triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
MakazhanAlpamys/Soup#2913 · 1 comment ·
Maintainers usually reply within 1 day
-
area:security effort:S priority:P3 status:needs-triage type:chore
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
randomparity/kdive#3657 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
aws/mcp-proxy-for-aws#476 ·
Maintainers usually reply within 1 day