peterjc / flake8-black

flake8 plugin to run black for checking Python coding style
MIT License
165 stars 10 forks source link

Rework TOML loading; BLK907 for invalid pyproject.toml #16

Closed peterjc closed 5 years ago

peterjc commented 5 years ago

A reworking of PR #15.

Builds on #11, makes the caching of parsed pyproject.toml files more explicit (run flake8 -v ... | grep black to see this in the logs).

Adds new BLK997 if a pyproject.toml file is invalid, allows using flake8 --black-config '' ... (or any other bash syntax to pass an empty string) to mean ignore any pyproject.toml files.

What do you think @098799 ?

098799 commented 5 years ago

Have to say I'm completely lost in the logic of override and the if/elif/return madness, but don't have much time now to try to simplify it. Still, I strongly feel like you're overengineering stuff: there should be one if (is the black config supplied in the config? is it a correct file?) which checks from which file the config should be loaded (project or global).

peterjc commented 5 years ago

If you're completely lost, then it is too complicated.

One simplification would be if we could offload the path normalisation to flake8 (my issue #13), but that seems to me to be broken: https://gitlab.com/pycqa/flake8/issues/562

peterjc commented 5 years ago

Note also that using flake8 to do the path normalisation would currently prevent using None (or any non-string) as a default value in order to tell apart no value set, and the empty string being used. PR proposed: https://gitlab.com/pycqa/flake8/merge_requests/337

peterjc commented 5 years ago

Closing for a third attempt...