If file does not exist flake8 crashes

Alfredo Deza avatarAlfredo Deza created an issue

When a new file is edited (and not yet saved) you cannot run flake8 on it because it crashes. This diverts from dealing with an invalid/non-existent path with pyflakes for example.

Shown below is what would happen with a non-existent foo.py file and what happens with pyflakes and what does with flake8

#  pyflakes foo.py
foo.py: No such file or directory

#  flake8 foo.py
Traceback (most recent call last):
  File "/usr/local/bin/flake8", line 8, in <module>
    load_entry_point('flake8==1.5', 'console_scripts', 'flake8')()
  File "/Library/Python/2.7/site-packages/flake8/run.py", line 68, in main
    for path in _get_python_files(pep8style.paths):
  File "/Library/Python/2.7/site-packages/flake8/run.py", line 51, in _get_python_files
    if not skip_file(path):
  File "/Library/Python/2.7/site-packages/flake8/util.py", line 30, in skip_file
    f = open(path)
IOError: [Errno 2] No such file or directory: 'foo.py'

I wrote a Vim plugin that checks your code on the fly and this particular issue is very painful to deal with as I need to see if there was a traceback thrown to stderr

Comments (6)

  1. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.