This bug reminds me a bit of #1427 and I hoped that the release of 5.5.0 would fix this as well but looking at the fix #1430, it makes sense that it wouldn't.
Given:
from my.horribly.long.import.line.that.just.keeps.on.going.and.going.and.going import ( # noqa
my_symbol
)
isort produces:
from my.horribly.long.import.line.that.just.keeps.on.going.and.going.and.going import (
my_symbol # noqa
)
A simple testcase to reproduce this is with all of the settings that I have enabled is:
def test_comments_should_never_be_moved_between_imports_issue_1456():
"""isort should never move comments to a different line of the same import statement.
See: https://github.com/PyCQA/isort/issues/1456
"""
assert isort.check_code(
"""from my.horribly.long.import.line.that.just.keeps.on.going.and.going.and.going import ( # noqa
my_symbol
)
""",
force_single_line=True,
show_diff=True,
multi_line_output=3,
include_trailing_comma=True,
force_grid_wrap=0,
use_parentheses=True,
line_length=79,
)
A more minimal testcase would be:
def test_comments_should_never_be_moved_between_imports_issue_1456():
"""isort should never move comments to different import statement.
See: https://github.com/PyCQA/isort/issues/1456
"""
assert isort.check_code(
"""from my.horribly.long.import.line.that.just.keeps.on.going.and.going.and.going import ( # noqa
my_symbol
)
""",
force_single_line=True,
use_parentheses=True,
multi_line_output=3,
line_length=79,
show_diff=True,
)
Thank you for the steady streams of updates and fixes that you keep providing to all of your users; we owe our beautiful import statements to you.
This bug reminds me a bit of #1427 and I hoped that the release of 5.5.0 would fix this as well but looking at the fix #1430, it makes sense that it wouldn't.
Given:
isort produces:
A simple testcase to reproduce this is with all of the settings that I have enabled is:
A more minimal testcase would be:
Thank you for the steady streams of updates and fixes that you keep providing to all of your users; we owe our beautiful import statements to you.