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

Bug: Isort dropping # noqa comment with star import #1744

Closed
Lothiraldan opened this issue Jun 10, 2021 · 3 comments
Closed

Bug: Isort dropping # noqa comment with star import #1744

Lothiraldan opened this issue Jun 10, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@Lothiraldan
Copy link

Version: 5.8.0
Python 3.7.5 (running through pre-commit but not sure)
Description
Isort drops # noqa comment while sorting, when two imports from the same file/module exists, and one of them is a star import. I think it might be related to #1594 but I preferred opening a new bug if that's not the case.

Steps to reproduce
Create one file with content as below. Sort test.py with isort

test.py

from typing import *  # noqa
from typing import IO, BinaryIO, Union # noqa

Actual result:

from typing import *  # noqa
from typing import IO, BinaryIO, Union

As you can see, #noqa comment was dropped from the second line, resulting in linter failling.

Expected result:
Imports should be kept as is, both # noqa comments should be kept as well.

Thank you for your amazing work!

@anirudnits
Copy link
Collaborator

anirudnits commented Jun 12, 2021

Hello @Lothiraldan, you could enforce skipping of the import statements by using the honor-noqa option, https://github.com/PyCQA/isort/blob/main/docs/configuration/options.md#honor-noqa. I tested it out locally and it worked for me on the example you shared.

Hope this helps.

@timothycrosley
Copy link
Member

@anirudnits's advice is good for fixing this on the current latest version of isort on PyPI, and the bug itself is now fixed in develop and will be pushed to PyPI some time this month.

@timothycrosley timothycrosley added the bug Something isn't working label Jun 13, 2021
@Lothiraldan
Copy link
Author

Thanks @anirudnits and @timothycrosley for the prompt workaround and prompt fix, you rocks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants