As @jonrsharpe says, and I agree, this is because the code is being run in Python 2, but linted in Python 3.
From the flake8 documentation on error codes:
We report E999 when we fail to compile a file into an Abstract Syntax Tree for the plugins that require it.
So to prove this is correct, using a file called bad_syntax.py
and using the same print
syntax as above:
print "test answer", len([])
When I run this with Python 2, everything is happy:
james@codebox:/tmp/lint$ python --version
Python 2.7.12
james@codebox:/tmp/lint$ python bad_syntax.py
test answer 0
Linting with flake8
invoked with a Python 2 environment also passes.
But when I lint with Python 3 (this is running in a virtualenv venv
with Python 3 installed), the E999
is returned:
(venv) james@codebox:/tmp/lint$ flake8 --version
3.5.0 (mccabe: 0.6.1, pycodestyle: 2.3.1, pyflakes: 1.6.0) CPython 3.5.2 on Linux
(venv) james@codebox:/tmp/lint$ flake8 bad_syntax.py
bad_syntax.py:1:19: E999 SyntaxError: invalid syntax
I do not think that this is a setting that needs changing inside linter-flake8
because Flake8 will use the version of Python that it is run through. My guess would be that Flake8 is being run on Python 3 because it has been installed inside a Python 3 environment, even though the code is being run on Python 2.