level12 / keg-app-cookiecutter

0 stars 0 forks source link

Add config for black #174

Closed bchopson closed 1 year ago

bchopson commented 2 years ago

Also add black-friendly config for flake8 and isort

Fixes GH-159, Fixes GH-161

rsyring commented 2 years ago

Also add Black and isort to requirements/dev.in?

Otherwise looks ok to me, although I haven't used any of it yet, so my :+1: might not mean much. :)

bchopson commented 2 years ago

Also add Black and isort to requirements/dev.in?

For H2R, we use pre-commit, which takes care of installing black in an isolated virtualenv. We can add an example pre-commit config if we want to be all in on pre-commit. Also, isort is more of an editor concern; some IDEs may have their own import sorting function. The goal with including isort config is that isort will do the right thing if it is in use. If we want to enforce import sorting with isort, then we could add isort via pre-commit.

rsyring commented 2 years ago

IMO, we should include the pre-commit config. Ditto for including isort. If we are going to go all in with automated formatting, then sorting imports and enforcing black should also be standard IMO.

Although, maybe the enforcement should happen in CI and not necessarily by hijacking and individual dev's workflow?

Happy to dialogue on what direction we should take here. Thanks.

bchopson commented 2 years ago

@rsyring Added pre-commit support with black, isort, flake8, and our custom alembic count-heads hook. I disabled pre-commit checks in CI for the cookiecutter (but not the generated project) since formatting is bound to change after the cookiecutter template is filled in.

rsyring commented 2 years ago

Some interesting discussion here on black including isort vs usort link: https://news.ycombinator.com/item?id=30130315