flake8pyflakes

Flake8 failing to detect syntax issues that can be detect by pyflakes


I am trying to get Emacs' flycheck to work nicely with python syntax error checking. By default it uses flake8, but I noticed that recently flake8 is only reporting style issues, when it supposed to produce the same kind of results as pyflakes.

As an example, I have a simple python script with a wrong module name.

$ cat so.py

import os

print(os.path)

op.path()

output of $ flake8 so.py is empty, while pyflakes' output is

 $ pyflakes so.py

 so.py:5: undefined name 'op'

My flake8 configuration, if it matters:

[flake8]
max-line-length = 96
ignore = E123,E701,E126,F821

I am using Linux, if that matters.

Flake8 version: version 3.3.0 mccabe: 0.6.1, pycodestyle: 2.3.1, pyflakes: 1.5.0

Pyflakes version: 1.5.0


Solution

  • When you're wondering why Flake8 isn't reporting something you think it should, the best path forward is to utilize the --isolated flag.

    With the file contents above in ex.py if I do:

    ❯❯❯ flake8 --isolated ex.py
    ex.py:5:1: F821 undefined name 'op'
    

    With that in mind, it does appear that your configuration is the problem here.