ruff icon indicating copy to clipboard operation
ruff copied to clipboard

lint isort I001: forbid multiple imports on single line?

Open fschulze opened this issue 1 year ago • 2 comments

I tried to configure lint.isort to block multiple imports on single lines without enforcing the way multiple imports are split.

This should be reported as I001:

from typing import Any, Callable, ContextManager

Both of these variants should not be reported:

from typing import Any
from typing import Callable
from typing import ContextManager
from typing import (
    Any,
    Callable,
    ContextManager,
)

The only setting which comes close is force-single-line=true, but then only the first variant is allowed and the last variant is reported.

fschulze avatar Jul 08 '24 08:07 fschulze

This is interesting. Could you explain why you want to allow both variants?

The goal of isort is to have consistent import formatting. That's why it only allows exactly one variant.

MichaReiser avatar Jul 08 '24 09:07 MichaReiser

For longer import lists the bracketed version is more readable, for a few imports the non-bracketed version is more concise without preventing nice diffs like the multiple imports on one line would.

fschulze avatar Jul 08 '24 09:07 fschulze