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

broken flake8 noqa on multi-line imports #1415

Closed
ndevenish opened this issue Aug 26, 2020 · 2 comments
Closed

broken flake8 noqa on multi-line imports #1415

ndevenish opened this issue Aug 26, 2020 · 2 comments
Labels
enhancement New feature or request integration

Comments

@ndevenish
Copy link
Contributor

Our code:

from dials.test.algorithms.spot_prediction.test_scan_static_reflection_predictor import ( # noqa: F401
    data as static_test,
)

And flake8 --select F401 test_noqa.py gives no error. When isort is run in --profile=black mode it moves the comment somewhere that flake8 no longer recognises:

from dials.test.algorithms.spot_prediction.test_scan_static_reflection_predictor import (
    data as static_test,  # noqa: F401
)

Now, flake8 counts this as an unused import, because flake8 only handles first-line or continuations. There was a ticket (https://gitlab.com/pycqa/flake8/-/issues/385) documenting this but this was closed as a duplicate of a ticket adding continuation handling, so this is still a problem.

This... sounds pretty similar to #1004 except there's no splitting involved. The pre-isort noqa example there doesn't seem to work in flake8 in my tests anyway, so I'm not sure if the intentions overlap.

Can be worked around with isort:skip on the noqa line.

flake8: 3.8.3 (mccabe: 0.6.1, pycodestyle: 2.6.0, pyflakes: 2.2.0) CPython 3.6.10`
isort: 5.4.2 (though running off develop because I needed the fix from 19221a3)

@timothycrosley timothycrosley added the enhancement New feature or request label Aug 26, 2020
@timothycrosley
Copy link
Member

Hi @ndevenish,

Thanks for reporting! I think this combined with the other (2?) issues around noqa comments shows some work is required in this area. isort is now part of the same organization as flake8, so maybe this is an area where the two projects can coordinate on a solution that helps our users achieve the result they want as seamlessly as possible.

Thanks!

~Timothy

@timothycrosley
Copy link
Member

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

Thanks!

~Timothy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request integration
Projects
None yet
Development

No branches or pull requests

2 participants