isort icon indicating copy to clipboard operation
isort copied to clipboard

Isort is disregarding the multiply line import

Open Cheukting opened this issue 2 years ago • 3 comments

Found in version 5.12.0 of isort from solving https://github.com/Zac-HD/shed/pull/94

Multiline import will automatically be put in one line.

Here is an example:

from os import (
    waitpid,
    waitstatus_to_exitcode,
    walk,
    write,
    writev,
)

print(
    waitpid,
    waitstatus_to_exitcode,
    walk,
    write,
    write,
)

Becomes

from os import waitpid, waitstatus_to_exitcode, walk, write, writev

print(
    waitpid,
    waitstatus_to_exitcode,
    walk,
    write,
    write,
)

CC @Zac-HD

Cheukting avatar Apr 30 '23 17:04 Cheukting

This is starting to give me some pain. I am happy to look into a possible solution and attempt a PR.

Cheukting avatar Aug 17 '23 07:08 Cheukting

More specifically, the problem is that isort doesn't respect the "magic trailing comma" which Black uses, even when using profile=black.

Zac-HD avatar Aug 17 '23 08:08 Zac-HD

~~It doesn't do that even when given --split-on-trailing-comma option. Looks like a regression of the feature introduced in #1876?~~

Edit: the --split-on-trailing-comma option works fine, my bad. Looks like this option is not enabled by default with --profile=black. IMO it should, since this is black's current behavior.

MrMino avatar Feb 16 '24 10:02 MrMino