Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

noqa comment is moved from long import #1456

Closed
jtamagnan opened this issue Sep 3, 2020 · 1 comment · Fixed by #1462
Closed

noqa comment is moved from long import #1456

jtamagnan opened this issue Sep 3, 2020 · 1 comment · Fixed by #1462
Labels
bug Something isn't working duplicate This issue or pull request already exists integration

Comments

@jtamagnan
Copy link

jtamagnan commented Sep 3, 2020

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.

@timothycrosley
Copy link
Member

This should be fixed in the just released 5.5.1 version of isort.

Thanks!

~Timothy

@timothycrosley timothycrosley added bug Something isn't working duplicate This issue or pull request already exists integration labels Sep 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists integration
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants