Conversation
Adds `./b format`, a port of NUbots' tools/format.py, plus the .clang-format and
.cmake-format.py configs it drives. Formatter versions are pinned in pyproject.toml
to the ones NUbots uses (clang-format 14.0.6 — the same LLVM release NUbots builds
into its image — cmakelang 0.6.13, isort 5.13.2, black 24.10.0), so a given file
formats identically in either repo.
The port differs from the original only where NUSim's plumbing forces it:
* the formatters run on the host out of the uv project environment rather than
inside the docker image, since ./b here is a stdlib-only host-side dispatcher
* --check diffs with difflib instead of shelling out to colordiff
* files are formatted on a thread pool, not a process pool: b.py loads tool
modules under a name absent from sys.modules, so a forked child cannot unpickle
the work function. The work is all subprocess calls, so threads lose nothing
* no licence-header formatter (commented out upstream) and therefore no pygit2
* no eslint/prettier, as there is no JavaScript in this repo
.cmake-format.py drops NUbots' custom-command declarations and wraps k1sim_role()
instead of nuclear_role(). mujoco/idl_gen/ is excluded from clang-format: it is
fastddsgen output that the build regenerates.
Aligning black/isort with NUbots also lifts the requires-python <3.13 cap, which
only existed to accommodate black 20.8b1.
This commit adds the tooling only; the reformat is the commit that follows.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Pure mechanical output of `./b format --all` using the configs added in the previous commit. No behavioural change: the sim builds and all six unit tests pass, and `./b format --check --all` is clean. Most of the diff is NamespaceIndentation: All, which NUbots' .clang-format sets and this codebase was not written with. mujoco/idl_gen/ is untouched — it is generated, and excluded in tools/format.py. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.