Closed no2chem closed 3 years ago
well, it seems to really not want to run automatically on the test directory, not sure why...
Hi there—although I'm not a frequent Black user, I'm OK with adding it if users are excited about automatic formatting. (TBH, I find gentle feedback from flake8 enough to ensure consistency, although I know some folks really get a lot of value out of automatic reformatters.)
If we're going to do this, however, I think it would be best to enforce its use "server-side" rather than relying on folks to use the pre-commit hook. That would mean reconfiguring our GitHub actions to run something like black --check
or black-primer
in addition to flake8 and mypy. Would anybody be interested in taking care of that?
This PR introduces the black formatter as a pre-commit hook.
When you run
git commit
, black automatically re-formats the code before passing it to flake8.example:
There are some differences in how black and flake8 interpret pep. I'm not really opinionated here as I am not a python expert, but it seems that the black authors think they are right in interpreting the PEP, and black fixes the formatting in a consistent way that an explicit rule shouldn't be required. The exceptions are defined in the
.flake8
file.This change should make it easier to compare changes, as small style differences should be make consistent by the tool. For example, #132 has a lot of changes because I ran
black
just to correct theflake8
errors. This eliminates formatting differences from pull requests.You can always skip the precommit hooks by running