Use black code formatter
b2m opened this issue · 4 comments
Joking aside, I think I'll just use the black code formatter in the future, reasonable results and no more arguing about bike sheds... eh code formatting.
Originally posted by @mikegerber in #37 (comment)
Note: black requires Python >= 3.6!
Todo:
- list black in developer requirements
- Update setup.cfg und .editorconfig according to https://black.readthedocs.io/en/stable/compatible_configs.html
- Maybe: Add pre-commit Hook https://black.readthedocs.io/en/stable/version_control_integration.html
- [-] Maybe: Add GitHub Action: https://black.readthedocs.io/en/stable/github_actions.html
- Maybe: Inform contributors about the code formatting choice and give a hint about editor integrations: https://black.readthedocs.io/en/stable/editor_integration.html
- Reformat codebase without compromising git blame: https://black.readthedocs.io/en/stable/installation_and_usage.html#migrating-your-code-style-without-ruining-git-blame
I'm contemplating to not reformat the code base but just require it for new changes. Mainly because GitHub does not allow to ignore a pure reformat commit.
I'm contemplating to not reformat the code base but just require it for new changes. Mainly because GitHub does not allow to ignore a pure reformat commit.
As the most code is written by you this should be a non issue and I would guess the other contributors will aggree =)
Reviewng this to close the issue. Only small inconsistency now that I use pre-commit:
sys.argv[1:] = (
args # XXX Hack to satisfy ocrd_cli_wrap_processor() check for arguments
)
This gets formatted differently by pre-commit's black vs. black. Didn't bother to check the configuration and just moved the comment outside the parens - it was bad style anyway.
- Maybe: Inform contributors about the code formatting choice and give a hint about editor integrations: https://black.readthedocs.io/en/stable/editor_integration.html
README-DEV.md has info about pre-commit, and .editorconfig
is in place. That should do it IMO, as I don't want to make it mandatory.