-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--check
option, mirroring black --check
#36
Conversation
(only for regions we touched in this branch)
I rebased on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
A couple of aesthetic nitpicks of questionable usefulness:
- the call
format_edited_parts(but_dont_really_edit_the_files=True)
is a little wonky IMO. - the fact that the parameter
print_diff
impliescheck_only
is a little weird to me as well.
I would refactor the code so there is a function
that returns the proposed changes
and another function that actually applies those,
so the high-level control remains high in the call stack and the "do_the_actual_change" flag does not have to travel far in the function calls.
`format_edited_parts()` now yields the proposed changes for each file, and two separate functions display diffs or modify files. This way high-level control remains high in the call stack and the `--diff`/`--check` flags don't have to travel far in the function calls. Thanks for review @samoylovfp!
@samoylovfp, both |
I did that, could you make a another quick check on the code? Quite some test changes were required as a result. |
@akaihola I think it looks excellent! |
--check
skips writing changes to files, and returns a return value of 1 from thedarker
process in case any modified lines in any of the given files are not already properly formatted.The return value will allow using
darker
with more different tools. It for example opens the possibility for apytest-darker
plugin.