add: option to return non-zero if files are changed#532
Open
chadrik wants to merge 2 commits intohukkin:masterfrom
Open
add: option to return non-zero if files are changed#532chadrik wants to merge 2 commits intohukkin:masterfrom
chadrik wants to merge 2 commits intohukkin:masterfrom
Conversation
for more information, see https://pre-commit.ci
|
It would be great if someone could look at this! |
|
I'd be very interested in this feature as well. |
KyleKing
reviewed
Feb 15, 2026
Contributor
KyleKing
left a comment
There was a problem hiding this comment.
I could see this being useful in similar scenarios as to why ruff adopted it, but I can't think of other tools that implement this pattern.
Also, I'm not sure if hukkin will have time to review or would approve, so take my feedback with a grain of salt!
| file_path_1.write_text(UNFORMATTED_MARKDOWN) | ||
| file_path_2.write_text(UNFORMATTED_MARKDOWN) | ||
| file_path_3.write_text(UNFORMATTED_MARKDOWN) | ||
| assert run((str(tmp_path),), "--exit-non-zero-on-format") == 1 |
Contributor
There was a problem hiding this comment.
I think there might be an error in this test if I understand it correctly:
Suggested change
| assert run((str(tmp_path),), "--exit-non-zero-on-format") == 1 | |
| assert run((str(tmp_path), "--exit-non-zero-on-format")) == 0 |
| "--exit-non-zero-on-format", | ||
| action="store_true", | ||
| help="return non-zero if files are modified", | ||
| ) |
Contributor
There was a problem hiding this comment.
This new option should be mutually exclusive with --check (and maybe better document that both are CLI only because it doesn't make sense to configure these permanently in toml)
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.
Fixes #531