File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,8 @@ def run(cli_args: Sequence[str], cache_toml: bool = True) -> int: # noqa: C901
178178 return 1
179179 if path :
180180 if formatted_str != original_str :
181+ if opts ["exit_non_zero_on_format" ]:
182+ format_errors_found = True
181183 path .write_bytes (formatted_str .encode ())
182184 else :
183185 sys .stdout .buffer .write (formatted_str .encode ())
@@ -210,6 +212,11 @@ def make_arg_parser(
210212 parser .add_argument (
211213 "--check" , action = "store_true" , help = "do not apply changes to files"
212214 )
215+ parser .add_argument (
216+ "--exit-non-zero-on-format" ,
217+ action = "store_true" ,
218+ help = "return non-zero if files are modified" ,
219+ )
213220 parser .add_argument (
214221 "--no-validate" ,
215222 action = "store_const" ,
You can’t perform that action at this time.
0 commit comments