flake8 error E901
Asked Answered
S

2

5
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.

Semiotic answered 5/4, 2014 at 11:6 Comment(0)
J
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.

Jester answered 5/4, 2014 at 11:30 Comment(1)
cool, glad my guess was helpful. I did run across this once before, but couldn't really figure out what the rules were -- what interpreter version / what build / what os didn't like foreign newlines. most accept all kinds.Jester
P
5

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

Psychologism answered 4/3, 2015 at 16:16 Comment(0)
J
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.

Jester answered 5/4, 2014 at 11:30 Comment(1)
cool, glad my guess was helpful. I did run across this once before, but couldn't really figure out what the rules were -- what interpreter version / what build / what os didn't like foreign newlines. most accept all kinds.Jester

© 2022 - 2024 — McMap. All rights reserved.