black
black copied to clipboard
vim-black to respect project's pyproject.toml settings
Is your feature request related to a problem? Please describe.
Background: With vim-black it is possible to customize the maximum line-length using let g:black_linelength = 79
or such.
Context: I do not want to re-open the discussion about which line length is correct, but the simple fact is that different projects have addressed the inconsistency between black and pycodestyle on this issue in different ways. Some projects set flake8 max line length to conform to black in setup.cfg, some projects do the reverse by setting black line length to conform to flake8 in pyproject.toml, while others (as I have seen suggested in other open issues on this project) disable pycodestyle in flake8 entirely.
Problem: Regardless of which solution is "correct", when editing a PR in someone else's project I want to conform to their style guidelines. For example, this becomes a problem if I am working on a PR to a project that has set a different maximum line length in pyproject.toml, because vim-black does not respect this setting. I must set g:black_linelength = 79
somewhere, such as in an ftplugin for python. But if I do that, vim-black will begin to misbehave in other code bases that use black's default settings. I am tempted to use black
on the command line in these situations, or rely on pre-commit
, but this defeats the purpose of an editor integration.
Describe the solution you'd like
vim-black should be maintained to read configuration options such as max line length from pyproject.toml, and anywhere else black
might read them on the command line, now and in the future.
Describe alternatives you've considered
- Tell everyone who has this problem to set up their own
blackd
server for the project. This seems cumbersome and requires more knowledge and investment than the average python project thatblack
would like to reach might want to require.
According to https://github.com/psf/black/issues/667 blackd
doesn't even read the project.toml
file...