Closed dhermes closed 6 years ago
I think this may be due to
Correct the flake8 entrypoint to report all I errors, this may result in I2XX errors being reported that were absent previously.
rather than a regression.
I this case it is a limitation of this checker that it doesn't pick up the try-except lines (nor the imports within) and hence just sees:
...
import numpy as np
import six
and therefore sees an extra line(s). I would write your imports as:
# repro.py
try:
import matplotlib.pyplot as plt
except ImportError:
plt = None
try:
import seaborn # pylint: disable=unused-import
except ImportError:
seaborn = None
import numpy as np
import six
to work around this. Although I think a # noqa: I202
is equally sensible.
@pgjones Thanks for the quick reply!
try/except
are not considered to be imports in any way? Is that bug/"feature request"-worthy?I think the noqa
is maybe the best I can offer for 1. :), as for 2. I think it could be a feature request but I am unsure how best to implement it - feel free to suggest a PR. I'll close this, as I think we agree this isn't a bug (although reopen if you disagree).
Hi, Got the same trouble with a group of imports separated by a block of comments (also see the travis job)
I think the current master branch fixes the block of comments issue, I'll release it soon.
For a given file
repro.py
, there is a regression:I don't have any preference for how I do my imports, so I'm happy to change the imports to "conform" to what is expected. Are there equivalent docs? My logic was "keep them in alphabetical order and catch the potential
ImportError
-s as they come".I have "fixed" this issue for now in a real code base just by ignoring the error.