Python 3 Print Flake8 Problems

10 thoughts
last posted July 16, 2014, 9:11 p.m.
0
get stream as: markdown or atom
0

A line like

print("foo", end=" ")

is reported as E901 SyntaxError: invalid syntax invalid syntax by flake8.

0

pep8 doesn't complain but flake8 does even though flake8 uses pep8.

I wonder if that means the problem is with pyflakes (which flake8 also uses).

0

Note that the line is a SyntaxError in Python 2.

0

python3 -m flake8 test.py

works whereas

python2 -m flake8 test.py

doesn't. So the problem just seems to be that the flake8 I'm running on command line (and in Atom Editor) is hard-coded to be the Python 2 one.

0

pyflakes gives the error, so flake8 is almost certainly getting it from there not pep8.

0

Maybe the solution is to get rid of pyflakes (and the rest of flake8) from the global site-packages.

0

It appears Atom Editor will use the right Python version to run flake8 if it is started up in the virtualenv (otherwise, after you remove flake8 from the global site-packages, Atom will complain that flake8 doesn't exist.

0

One thing I haven't tested yet is starting up two Atom windows, one from a Python 2 virtualenv and one from a Python 3 virtualenv.

0

Okay, so I've tested that now. It appears multiple Atom windows will use the flake8 in the virtualenv where Atom was first started up.

It also means that if you start up Atom from somewhere other than atom on the command line (in a virtualenv) flake8 won't be available.

0

In summary, if you develop with both Python 2 and Python 3 and want to use flake8:

  • don't install flake8 at global site-packages level
  • always use virtual environments
  • if you use Atom Editor with flake8 support, always start up atom from within the virtual environment