PyCQA / isort

A Python utility / library to sort imports.
https://pycqa.github.io/isort/
MIT License
6.49k stars 580 forks source link

Isort is disregarding the multiply line import #2128

Open Cheukting opened 1 year ago

Cheukting commented 1 year ago

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 commented 1 year ago

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

Zac-HD commented 1 year ago

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

MrMino commented 8 months ago

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.