peterjc / flake8-black

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

feature/GLOBAL_CONFIG: Added global black configuration option #10

Closed 098799 closed 5 years ago

098799 commented 5 years ago

If no pyproject.toml file is found, flake8-black will fallback on the global configuration for black found in $HOME/.config/flake8-black/pyproject.toml. Syntax stays the same.

peterjc commented 5 years ago

What is the motivation? Is the current behaviour not following what black does:

https://black.readthedocs.io/en/stable/pyproject_toml.html#where-black-looks-for-the-file

peterjc commented 5 years ago

See also discussion on #9.

098799 commented 5 years ago

Current configuration is mirroring what black does. The problem is black doesn't allow for global config the way e.g. flake8 or isort do.

Our needs require a unified configuration across several projects. We prefer to configure once in the Dockerfile base instead of including configuration in all repos.

Regarding the discussion, I was on the fence between using .config/flake8 and copying the same approach from pyproject.toml but decided the second is less complex and doesn't require new definitions which wouldn't be used anywhere outside this particular use case.

peterjc commented 5 years ago

Adding yet another tool specific configuration file $HOME/.config/flake8-black/pyproject.toml seems to just make things more confusing.

How about instead adding a .flake8 setting for this plugin, pointing at the black configuration file to use?

This would be like using black --config /mnt/shared/config/black.toml ... at the command line?

As noted on #9, I am keen to see some real world examples using custom black configuration files.

peterjc commented 5 years ago

As an aside, is there an open issue on black to support a global configuration file? I had a little search but couldn't find one.

098799 commented 5 years ago

This would be like using black --config /mnt/shared/config/black.toml ... at the command line?

Probably a better solution, yes.

As noted on #9, I am keen to see some real world examples using custom black configuration files.

No idea, we don't use it yet, but probably will end up disabling string normalization and setting the line length to 120 to minimize the diff in the transition.

As an aside, is there an open issue on black to support a global configuration file? I had a little search but couldn't find one.

Probably https://github.com/psf/black/issues/810 comes the closest. But taking into account the rate of black development since last september, I wouldn't count on that...

peterjc commented 5 years ago

OK, so shall I close this pull request in favour of the that configuration approach?

098799 commented 5 years ago

If you have it ready, that would be great. If not, I'll probably try to hack it together in the nearest future.

peterjc commented 5 years ago

I have no code written for this, and to be honest I am unlikely to work on this myself - at least not any time soon. If you want to work on it, great 👍