You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature Request] Add non-mutating mojo format --check mode #6885
Please expose a non-mutating --check mode on mojo format for CI and pre-commit use.
This is the still-unresolved use case from #1249. That issue was closed with an explicit invitation to open a new issue if detecting formatting changes remained important.
Reproduction
Verified on both:
Mojo 1.0.0 (ed45d567)
Mojo 1.1.0.dev2026081105 (e929a99e)
mojo format --help exposes only --line-length and --quiet. Running mojo format rewrites files and returns exit code 0 when formatting changes were required, so CI cannot distinguish an already-formatted tree without modifying the workspace and adding shell/script logic.
Requested behavior
mojo format --check <sources...>
do not modify source files;
exit 0 when every source is already formatted;
exit 1 when formatting changes would be required;
use a distinct nonzero status for parse/internal formatter failures;
report which files require formatting.
An optional future --diff mode would also be useful, but is not required for the core request.
Motivation
This enables a direct, race-free CI task such as:
format-check = "mojo format --check src tests examples"
The public repository already invokes the underlying mblack formatter with --check --diff in bazel/lint/mblack-wrapper.py, so this appears to be an existing formatter capability that is not exposed by the mojo format CLI.
Activity
[mojo] Add mojo-format-check.py: working --check mode via mblack
AmrDeveloper commentedon Aug 20, 2026
I created a draft PR to introduce the check subcommand, but I can't create valid and invalid lit tests with the pinned Mojo version
#6938
Once it changes, I will convert the draft to active
Note: Not sure if there is currently a workaround to test it. What I did locally was intercepting and printing the args and using them with mblack
Thanks