Closed remcohaszing closed 7 years ago
I can reproduce this, but interestingly it depends on using flake8 > 3.0, I'll try and track it down.
Ah, so Flake8 3.0 doesn't monkey-patch anyone's stdin. Let me check on something quickly. You can assign this to me if you want @pgjones
@remcohaszing can you also confirm that #83 fixes this?
Have merged #83, confirmation would be good.
It works. Thanks :smile:
This error does still occur in flake8 2, see https://github.com/PyCQA/flake8-import-order/pull/83#pullrequestreview-51643493
@dandavison I can't reproduce this, could you give me an example of something you think I can reproduce?
Sure,
venv=/tmp/flake8-import-order-venv
virtualenv $venv
. $venv/bin/activate
pip install flake8==2.5.4 flake8-import-order==0.12
cat > bad.py <<EOF
import b
import a
EOF
flake8 - < bad.py
Traceback (most recent call last):
File "/tmp/flake8-import-order-venv/bin/flake8", line 11, in <module>
sys.exit(main())
File "/tmp/flake8-import-order-venv/lib/python2.7/site-packages/flake8/main.py", line 33, in main
report = flake8_style.check_files()
File "/tmp/flake8-import-order-venv/lib/python2.7/site-packages/flake8/engine.py", line 181, in check_files
return self._retry_serial(self._styleguide.check_files, paths=paths)
File "/tmp/flake8-import-order-venv/lib/python2.7/site-packages/flake8/engine.py", line 172, in _retry_serial
return func(*args, **kwargs)
File "/tmp/flake8-import-order-venv/lib/python2.7/site-packages/pep8.py", line 1842, in check_files
runner(path)
File "/tmp/flake8-import-order-venv/lib/python2.7/site-packages/flake8/engine.py", line 126, in input_file
return fchecker.check_all(expected=expected, line_offset=line_offset)
File "/tmp/flake8-import-order-venv/lib/python2.7/site-packages/pep8.py", line 1574, in check_all
self.check_ast()
File "/tmp/flake8-import-order-venv/lib/python2.7/site-packages/pep8.py", line 1521, in check_ast
for lineno, offset, text, check in checker.run():
File "/tmp/flake8-import-order-venv/lib/python2.7/site-packages/flake8_import_order/flake8_linter.py", line 91, in run
for error in self.check_order():
File "/tmp/flake8-import-order-venv/lib/python2.7/site-packages/flake8_import_order/checker.py", line 58, in check_order
if not pycodestyle.noqa(self.lines[import_.lineno - 1]):
IndexError: list index out of range
@dandavison Can you upgrade to flake8 >=2.6.0 and try again? I can't reproduce the above with any 2.6 patch but I can with 2.5.4.
Oh, I suspect that 2.6.0 is when we introduced the monkey-patch to cache pycodestyle.get_stdin_value
. Alternatively, it's also when we switched our dependency from pep8
to pycodestyle
.
When linting a file from stdin, this plugin raises an error.
This does work when just linting a file instead.
I've installed the following packages in my environment (simply a virtualenv using the latest
flake8
andflake8-import-order
).This bug does not yet exist when using the following requirements:
I didn't try this using
flake8 ~= 2.6.0
, because this was causing errors related to other plugins.