peterjc / flake8-black

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

Read config from pyproject.toml for black #4

Closed ADKosm closed 5 years ago

ADKosm commented 5 years ago

This PR adds reading file mode configuration from black section in pyproject.toml (see https://black.readthedocs.io/en/stable/pyproject_toml.html).

Main motivation is support for skip-string-normalization option. Without this flag flake8 will always fails on large and other specific projects, which disable string normalization ( see this section in offitial black README - https://github.com/python/black#strings).

peterjc commented 5 years ago

Rather than tests/test_cases/with_black_configuration/ could you use tests/with_pyproject_toml/ instead (not a nested folder).

My naming suggestion here is to then be able to add tests/with_dot_flake8/ and tests/with_dot_flake8/.flake8 with the configuration (e.g. could try varying the line length here).

Does it make sense to support skip_string_normalization via flake8's configuration file(s), .flake8 etc?

ADKosm commented 5 years ago

Rather than tests/test_cases/with_black_configuration/ could you use tests/with_pyproject_toml/ instead (not a nested folder).

My naming suggestion here is to then be able to add tests/with_dot_flake8/ and tests/with_dot_flake8/.flake8 with the configuration (e.g. could try varying the line length here).

Does it make sense to support skip_string_normalization via flake8's configuration file(s), .flake8 etc?

  1. Of course - I will move this test to with_pyproject_toml :) (unfortunately, there is no file like CONTRIBUTIONS with some convetions about project)
  2. Quote from official flake8 documentation (see https://flake8.pycqa.org/en/latest/user/configuration.html):

Not every Flake8 command-line option can be specified in the configuration file. See our list of options to determine which options will be parsed from the configuration files.

This means, that there is predefined options, which we can use in .flake8 - https://flake8.pycqa.org/en/latest/user/options.html#options-list .

Moreover, if user uses black with skip_string_normalization, he must define this property in pyproject.toml because original black tool use only this config file. This means, that using skip_string_normalization in .flake8 is useless dublication.

peterjc commented 5 years ago

My understanding is plugins can add their own settings to .flake8, setup.cfg, or tox.ini - but agree given the very clear expectation of black settings being in pyproject.toml we should prioritise that.

peterjc commented 5 years ago

Are you happy to be thanked by name in the release notes etc, something like here: https://github.com/peterjc/flake8-rst-docstrings

peterjc commented 5 years ago

I'm going to tweak the message wording, update the README, and bump the version for a new release. I would like to acknowledge you by name if that's OK?

ADKosm commented 5 years ago

@peterjc yes, of course :)