Question

flake8 xxx --ignore=E501,E128,E701,E261,E301,E126,E127,E131

xxx.py:1:40: E901 SyntaxError: invalid syntax

Any one has any idea where is the syntax error?

Python==2.6, first line of the file is, no byte order marking :

from __future__ import absolute_import

Works fine in Python 2.7 and 3+ though.

Was it helpful?

Solution 2

A bit hard to guess without complete file, ideally in some format that preserves bytes exactly.

:1:40 refers to first line, char position 40. The line is 38 characters long.

Thus suspicion falls on newline marker.

Most likely newline (single char) is not recognised and Python (not flake8 btw) treats this line and the next and one long line. Thus error is in column 40.

Alternatively your newline is a sequence of 2 chars and 2nd char is not understood correctly.

There could theoretically also be an encoding problem, but I find that quite unlikely.

OTHER TIPS

If you add --show-source to the flake8 command it'll point out the error in the output.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top