Break long lines of python code programmatically

93 Views Asked by At

What is a/the way to auto-format an existing (potentially large) Python codebase to conform to a given max line length?

Autoformatters like black, yapf and autopep8 do change too much as they also change other things.

1

There are 1 best solutions below

2
Jovan V On

This seems like a thing that can be easily solved using an .editorconfig file. I don't know what IDE/Code editor you use, but from my experience, pyCharm supports it very well. The config should look something like this:

root = true

[*.py]
max_line_length = 88

For more info, check https://editorconfig.org/.