Given .isort.cfg containing:
[settings]
multi_line_output=3
Applying isort to a file containing:
from some_module.or_other.somewhere import (
submodule_named_a,
submodule_named_b,
submodule_named_c,
submodule_named_d,
submodule_named_e
)
Does nothing, as expected.
But, if one of the imports is renamed:
from some_module.or_other.somewhere import (
submodule_named_a,
submodule_named_b,
submodule_named_c as renamed_c,
submodule_named_d,
submodule_named_e
)
isort transforms it into:
from some_module.or_other.somewhere import submodule_named_a, submodule_named_b
from some_module.or_other.somewhere import submodule_named_c as renamed_c
from some_module.or_other.somewhere import submodule_named_d, submodule_named_e
Which is pretty ugly.
It would be preferable to keep the group the same, or to sort the renamed import separately so as the rest of the imports could still be grouped.
I think that is a bug. But what if you add:
combine_as_imports = 1
Sorry it's taken me so long to respond. Adding combine_as_imports=1 makes no difference to the behaviour.
combine_as_imports=1 in the settings actually fixed the issue for me. I have version 4.3.4.
I realise this yesterday, the setting combine_as_imports resolved for me.
I liked to know why this setting is not by default and know what are the pep way to make this imports
combine_as_imports is the correct action to take if you do not want as imports to appear on their own line. The only stipulation is that a new enough version of isort must be installed that supports it.
Thanks everyone!
~Timothy
Most helpful comment
I think that is a bug. But what if you add:
combine_as_imports = 1