I'm using Sublime Text 3 With Pylinter to run pylint
on my files.
However, on the same machine, I work on files for both python 2, and python 3 projects (the code is executed on one of several remote test-VMs, via SSH. I'm modifying the files by opening them over SMB. This is my home test-lab, and I'm finally sitting down to learn py3k).
Can I easily override the mechanism pylint uses to determine the python version it should lint for? Ideally, there would be an inline directive, but I have not had much luck finding anything.
I'm (editing) on Windows (the remote VMs are linux, but that' irrelevant here), for what it's worth.
You can override on a per-project level in Sublime Text by changing the pylint executable setting in Project->Edit Project to include:
substituting 3.4 for your preferred flavour
You can try
python2 -m pylint ...
andpython3 -m pylint ...
. That ensures that you use the right version.This is good, but I think the simplest thing is just to use virtualenv, and install pylint in each virtualenv. The correct pylint and python interpreter will be used.
You should have two pylint installations, say pylint2 and pylint3, then write a wrapper script that will subprocess the desired one.
You can install pylint3 which will evaluate for python 3.0, and pylint which will evaluate the code as python 2.7 by default.
Expanding on @sthenault's answer and borrowing heavily from @simon's to a very similar question on askubuntu, the solution is to write a wrapper script around
pylint
that executes it with the appropriate version of the Python interpreter. Drop the following into a script calledmypylint
(or whatever) somewhere in your$PATH
:Then, execute it like so:
mypylint 2|3 PYLINT_ARGS
. For instance:I'm not sure how you can tie that into sublime-text, but it more generally answers the question of parallel versions of
pylint
. I also bundled the above solution into a gist.