SublimeLinter / SublimeLinter-flake8

SublimeLinter plugin for python, using flake8.
MIT License
184 stars 28 forks source link

Inexistent files cause exceptions with this linter #97

Closed fgimian closed 6 years ago

fgimian commented 6 years ago

Hey there, thanks for all your work on this 😄

I notice a problem which can be reproduced as follows;

First, create a directory containing a Python script

mkdir 1
echo 'import json' > 1/test.py
subl 1/test.py 

Now modify the script in Sublime Text and exit without saving (hot exit).

And now:

# Rename the directory containing the file so that it can no longer be found
mv 1 2

# Open Sublime Text
subl

And you see an exception:

SublimeLinter: #1 flake8 test.py ERROR:
=======================================

  Execution failed

  [Errno 2] No such file or directory: '/Users/fots/1'

  /Users/fots/1  (working dir)
  $ cat test.py | /usr/local/bin/flake8 --format default -

Any help is greatly appreciated 😄 Fotis

kaste commented 6 years ago

Hi 👋

Hm, what do you expect here we should do? If you open subl it reopens test.py as dirty. But e.g. you cannot save that file anymore.

Now, the problem here is that the folder is gone, so we don't have a working working dir anymore. Even if we check that, we would probably still show an error message.

fgimian commented 6 years ago

Hey @kaste, thanks so much for the reply. 😄

Is it possible for the linter to still perform the linting on the buffer it has (similar to unsaved files) or optionally fail without showing the console?

The problem with the current approach is that it's disruptive in cases where for example, I have a directory mounted on my system which becomes unavailable when I'm disconnect from the network .etc.

Kindest Regards Fotis

kaste commented 6 years ago

We probably shouldn't lint orphaned files.

Linting without a working dir doesn't work bc all the config files usually depend on the location of the file. Not failing although we fail is probably not an option.

The question is why should we lint such files? (It's probably comparable to when you switch git branches, and then some views loose their underlying file bc there is no such file in the branch. We probably shouldn't lint these files. You either close the views, or wait until they get alive again to continue editing.)

fgimian commented 6 years ago

You make a really good point @kaste. If you can't think of a more elegant way than to show the console, then I guess we'll have to leave it be. Feel free to close this issue unless you have any other ideas on how to deal with this.

The main thing I find distracting is the Console appearing when I'm resuming a session and don't have my server mounted. Ideally something more subtle would be indicated if that is possible.

Thanks again for your time and help. Have an awesome weekend! Fotis

kaste commented 6 years ago

Tracking in core https://github.com/SublimeLinter/SublimeLinter/issues/1454

fgimian commented 6 years ago

Thank you so much @kaste!! 😄