Create a test.py file with the following contents:
def fail((a, b, c)):
pass
Run flake8 test.py (with flake8-print installed).
Expected: flake8 run passes without raising any issues.
Actual: flake8 fails with the following traceback:
(venv) [test_flake8_print] flake8 test.py
Traceback (most recent call last):
File "/Users/wojcikstefan/Repos/test_flake8_print/venv/bin/flake8", line 11, in <module>
sys.exit(main())
File "/Users/wojcikstefan/Repos/test_flake8_print/venv/lib/python2.7/site-packages/flake8/main/cli.py", line 16, in main
app.run(argv)
File "/Users/wojcikstefan/Repos/test_flake8_print/venv/lib/python2.7/site-packages/flake8/main/application.py", line 396, in run
self._run(argv)
File "/Users/wojcikstefan/Repos/test_flake8_print/venv/lib/python2.7/site-packages/flake8/main/application.py", line 384, in _run
self.run_checks()
File "/Users/wojcikstefan/Repos/test_flake8_print/venv/lib/python2.7/site-packages/flake8/main/application.py", line 310, in run_checks
self.file_checker_manager.run()
File "/Users/wojcikstefan/Repos/test_flake8_print/venv/lib/python2.7/site-packages/flake8/checker.py", line 319, in run
self.run_parallel()
File "/Users/wojcikstefan/Repos/test_flake8_print/venv/lib/python2.7/site-packages/flake8/checker.py", line 288, in run_parallel
for ret in pool_map:
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 668, in next
raise value
AttributeError: 'Tuple' object has no attribute 'id'
When the function definition contains a tuple parameter one of the args is an _ast.Tuple object, not the expected _ast.Name. _ast.Tuple doesn't have the id attribute, hence arg.id raises the AttributeError seen in the traceback.
Note that tuple parameter unpacking has been removed in Python 3 via PEP 3113, so this is only a bug in handling Python 2 files.
Steps to reproduce
test.py
file with the following contents:flake8 test.py
(withflake8-print
installed).Expected: flake8 run passes without raising any issues. Actual: flake8 fails with the following traceback:
Reason
I traced the problem back to this line: https://github.com/JBKahn/flake8-print/blob/e5d3812c4c93628ed804e9ecf74c2d31780627e5/flake8_print.py#L50
When the function definition contains a tuple parameter one of the
arg
s is an_ast.Tuple
object, not the expected_ast.Name
._ast.Tuple
doesn't have theid
attribute, hencearg.id
raises theAttributeError
seen in the traceback.Note that tuple parameter unpacking has been removed in Python 3 via PEP 3113, so this is only a bug in handling Python 2 files.