PyCQA / flake8-import-order

Flake8 plugin that checks import order against various Python Style Guides
GNU Lesser General Public License v3.0
278 stars 72 forks source link

Using #noqa and still get: I100 Import statements are in the wrong order. #136

Open JohnVillalovos opened 6 years ago

JohnVillalovos commented 6 years ago

Trying to use latest version of flake8-import-order from PyPi and got the error:

ironic_inspector/test/functional.py:17:1: I100 Import statements are in the wrong order. import contextlib should be before import eventlet

Code here: https://github.com/openstack/ironic-inspector/blob/b81c14282477266a1302014357da99b565149a09/ironic_inspector/test/functional.py#L14-L17

The eventlet import needs to be first. We have a '#noqa' on that line but getting the error. Any ideas?

Thanks for the plugin! :)

pgjones commented 6 years ago

The issue here is that the error is reported on line 17 and hence the # noqa should be silenced there (rather than on line 14). We had a discussion about this in #120 as 0.14.3 onwards changed the behaviour and I thought this (accepting noqa only on the lines reporting the error) would be clearer. With this in mind, do you think it is clear?

JohnVillalovos commented 6 years ago

Thanks for the work-around/solution. That did fix the issue.

I guess I was thinking I should put it on line 17.

Plus I would think if a line has "# noqa" it would be ignored. As in right now the eventlet line has "# noqa" on it but the check is still paying attention to the fact that there is an "import eventlet" line.

To me the real culprit here is the "import eventlet" line. So maybe it could accept it on both?

After reading the other bug I agree with the other people that the "# noqa" should be on the line that is actually the culprit, which in this case is "import eventlet" in my opinion.

Dreamsorcerer commented 3 years ago

Ignoring errors on another line from where the #noqa is located is no longer possible in flake8. So, this issue can no longer be solved in this project, probably best to close it. https://gitlab.com/pycqa/flake8/-/issues/638#note_340556082