Skip to content

add: option to return non-zero if files are changed#532

Open
chadrik wants to merge 2 commits intohukkin:masterfrom
chadrik:error-on-fix
Open

add: option to return non-zero if files are changed#532
chadrik wants to merge 2 commits intohukkin:masterfrom
chadrik:error-on-fix

Conversation

@chadrik
Copy link
Copy Markdown

@chadrik chadrik commented Aug 16, 2025

Fixes #531

@cdombrova-scanlinevfx
Copy link
Copy Markdown

It would be great if someone could look at this!

@nrusch
Copy link
Copy Markdown

nrusch commented Feb 9, 2026

I'd be very interested in this feature as well.

Copy link
Copy Markdown
Contributor

@KyleKing KyleKing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide an option to apply changes and exit non-zero if changes were made

4 participants