peterjc / flake8-black

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

feature/BLACK_CONFIG: Black configuration file configurable #11

Closed 098799 closed 5 years ago

098799 commented 5 years ago

Added flake8-black-config parameter to be set in flake8 configuration file, which points to the .toml file that should be used instead of the default black pyptoject.toml.

peterjc commented 5 years ago

If the black configuration given in the .flake8 (etc) file is a relative path, as a user I would expect this to be interpreted relative to the location of the configuration file (not relative to the current directory which is my guess for what happens with the current code). Does that seem like a good idea?

Or we could just insist on an absolute path?

peterjc commented 5 years ago

This pull request would close issue #9.

098799 commented 5 years ago

If the black configuration given in the .flake8 (etc) file is a relative path, as a user I would expect this to be interpreted relative to the location of the configuration file (not relative to the current directory which is my guess for what happens with the current code). Does that seem like a good idea?

Or we could just insist on an absolute path?

Definitely sounds like an improvement.

098799 commented 5 years ago

I think I covered all the comments, please recheck when you have the time.

peterjc commented 5 years ago

Feel free to bump the version number to v0.1.1 and add a line to the release history in README.rst? Something like:

Option to use a (global) black configuration file, contribution from Tomasz Grining.

Otherwise I'll probably merge this and do that tomorrow. Thanks!

098799 commented 5 years ago

Ok, squashed commits and added the version bump.

peterjc commented 5 years ago

Looks good. Time to try and break it in local testing 😁

peterjc commented 5 years ago

Looks like something isn't quite right in the new configuration option,

$ black -h

This suggests a trivial test to add to tests/run_tests.sh,

flake8 -h 2>&1  | grep "black-config"
peterjc commented 5 years ago

Easy fix - string vs tuple for the help argument

peterjc commented 5 years ago

Merged, thank you 🎉

098799 commented 5 years ago

Ugh, sorry about it, flake8-strict has terrorized me about always adding those silly commas and in some places it changes the meaning. Ready to embrace black's trailing comma handling...

098799 commented 5 years ago

@peterjc Will you release this version on pypi or are we waiting for figuring out the issues with relative paths etc?

peterjc commented 5 years ago

I wanted to include the bad TOML error handling as part of the release, and ideally the path issue too (putting out a release only to change something like how the configuration is interpreted in the next release is a bad idea).