Does not work with latest isort
danpalmer opened this issue · 7 comments
When running with the latest isort (4.2.15) I get the following exception.
I'm using flake8-isort 2.2.1.
flake8 --jobs=auto
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/usr/local/Cellar/python35/3.5.3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/multiprocessing/pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "/usr/local/Cellar/python35/3.5.3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/multiprocessing/pool.py", line 44, in mapstar
return list(map(*args))
File "/venvs/lib/python3.5/site-packages/flake8/checker.py", line 642, in _run_checks
return checker.run_checks()
File "/venvs/lib/python3.5/site-packages/flake8/checker.py", line 573, in run_checks
self.run_ast_checks()
File "/venvs/lib/python3.5/site-packages/flake8/checker.py", line 487, in run_ast_checks
for (line_number, offset, text, check) in runner:
File "/venvs/lib/python3.5/site-packages/flake8_isort.py", line 72, in run
for line_num, message in self.sortimports_linenum_msg(sort_result):
File "/venvs/lib/python3.5/site-packages/flake8_isort.py", line 139, in sortimports_linenum_msg
self._fixup_sortimports_wrapped(sort_result)
File "/venvs/lib/python3.5/site-packages/flake8_isort.py", line 195, in _fixup_sortimports_wrapped
for idx, line in enumerate(sort_imports.out_lines):
AttributeError: 'SortImports' object has no attribute 'out_lines'
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/venvs/bin/flake8", line 11, in <module>
sys.exit(main())
File "/venvs/lib/python3.5/site-packages/flake8/main/cli.py", line 16, in main
app.run(argv)
File "/venvs/lib/python3.5/site-packages/flake8/main/application.py", line 328, in run
self._run(argv)
File "/venvs/lib/python3.5/site-packages/flake8/main/application.py", line 316, in _run
self.run_checks()
File "/venvs/lib/python3.5/site-packages/flake8/main/application.py", line 246, in run_checks
self.file_checker_manager.run()
File "/venvs/lib/python3.5/site-packages/flake8/checker.py", line 317, in run
self.run_parallel()
File "/venvs/lib/python3.5/site-packages/flake8/checker.py", line 286, in run_parallel
for ret in pool_map:
File "/usr/local/Cellar/python35/3.5.3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/multiprocessing/pool.py", line 314, in <genexpr>
return (item for chunk in result for item in chunk)
File "/usr/local/Cellar/python35/3.5.3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/multiprocessing/pool.py", line 695, in next
raise value
AttributeError: 'SortImports' object has no attribute 'out_lines'
@danpalmer thanks for using flake8-isort and reporting issues you find with it!
I can not reproduce the error though:
git clone git@github.com:collective/collective.cover
cd collective.cover
virutalenv-2.7 .
pip install flake8-isort
flake8 --jobs=auto src
I've investigated this, and the issue is that the file contains:
"""
isort:skip_file
"""
This causes isort
to skip the file as expected, but does not set the skipped
flag on the SortImports
object, which is used here to check whether to process the isort
output or not.
I've submitted a PR to isort
to fix this: PyCQA/isort#588
In the mean time, should sortimports_linenum_msg
be resilient to a non-existent in_lines
or out_lines
? I'm not sure it's worth doing, or it might be good to error loudly with a better error message? I'm happy to implement this if you think it's a good idea, but also happy to leave if you don't think it would be useful.
@danpalmer thanks for the investigation and the pull request to isort!
If you still have time to make a pull request here, I would gladly accept & merge & release as soon as I'm able to (I'm on parental leave).
This way we will be able to still work with versions of isort lower than the next release that contains your fix.
FYI your upstream changes on isort have been merged, but so far there has been no release :-/
I forgot to close this when releasing 2.2.2.
@danpalmer reopen if you still think it should be kept open.