Can I tell black to ignore formatting long lines in my python script

Viewed 1039

I am used to using flake8 for linting. Flake8 has a setup.cfg file where I can tell it to ignore line length. I would also like to tell my fixer(black) to not reformat long lines. How can I configure black to do everything it normally does except fix line length?

https://black.readthedocs.io/en/stable/

1 Answers

I don't see a way to completely ignore line length, but Black does use a configuration file (pyproject.toml) in which you can specify max line length, so setting line-length reasonably (or ridiculously) long should help.

Example:

[tool.black]
line-length = 160

Notes:

  • This may re-format intentionally split lines into longer lines. Black is still opinionated.
  • The values available in the configuration file are "the same as long names of options on the command line" according to the docs. (This list isn't available in the documentation, but can be found by running black --help.)
Related