I'm currently using isort --profile=black --line-length=79
as a linter in my project for python files.
This produces the Vertical Hanging Indent (mode 3 in isort's documentation kind of output:
from third_party import (
lib1,
lib2,
lib3,
lib4,
)
This multiline mode only applies if the line is longer than 79 characters, though. Is there a mode that cause a multiline output as soon as there are two or more imports on the same line, no matter how long the line is?
I tried hacking it with isort -m=3 --trailing-comma --line-length=1
, but shorter line length will cause multiline output even when there is a single import, which I don't want:
from third_party import (
lib1,
)
You should use the --force-grid-wrap 2
flag in the CLI or set in the settings file like pyproject.toml
option force_grid_wrap = 2
. This would force isort to produce multiline output for 2 or more imports, regardless of line length. More info about this option