I'm using Pylint with Sublime Text 3 on Windows 8.1
. It is configured to run on save with Ctrl+S
:
// Set to true to automatically run Pylint on save
"run_on_save": true,
and I like this.
The problem arises when I hit a shortcut for the 'Build' command - Ctrl+B
or F7
without the file being saved: the Python script and Pylint start simultaneously and the script output (I see in 'Build result' pane below) often becomes broken (much of the printout disappears), or that causes Pylint error message boxes or crashes of my Sublime Text.
But nothing is wrong when I first save the file with Ctrl+S
and then run it.
The question is can I configure Pylint for the delayed start (say, 1 second) after Ctrl+S
so it will not affect the script run?
P.S. A brief search over Pylint settings of Sublime-linter settings did not yield useful results.
The resources I checked: Running Pylint, Pylint FAQ, Sublime Linter Settings. I did not find anything interesting about modifying pylintrc
file (pylintrc example).
Any ideas? Thanks in advance.
You could write a plugin that inherits the ViewEventListener
class and implement the on_post_save_async()
callback method to sleep for a second (is that really enough, will it always be enough!?) and then use self.view.run_command()
to launch Pylint. Ensure run_on_save
is false if you do so. Here's the relevant bit of the API.
BUT doing that is NOT a good idea — you're asking for further problems with the output panels, error messages, and Sublime crashes.
I suggest you take full control of manually launching the linter. Set the Pylint run_on_save
setting to false
. Assign convenient keys to launch the linter when you want it and get out of the habit of running it automatically every time you save a file. Linters are like spell checkers, it is much more efficient to run them from time to time and make all the necessary changes in one go, rather than having the linter run over and over again, repeatedly validating the same code, just to check the most recent few lines.
If you try and write larger and larger amounts of code without building or linting then in time the accuracy and speed of your coding will improve.