Skip to content

Commit

Permalink
Added support for Pylint plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinze de Laat committed Dec 28, 2013
1 parent b501217 commit cefa6ba
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Pylinter.sublime-settings
Expand Up @@ -30,5 +30,6 @@
// "F" : Fatal for errors which prevented further processing
"ignore": [],
// a list of strings of individual errors to disable, ex: ["C0301"]
"disable": []
"disable": [],
"plugins": []
}
30 changes: 20 additions & 10 deletions pylinter.py
Expand Up @@ -132,6 +132,7 @@ def read_settings(cls):
pylint_path = cls.get_or('pylint_path', None)
pylint_rc = cls.get_or('pylint_rc', None) or ""
ignore = [t.lower() for t in cls.get_or('ignore', [])]
plugins = cls.get_or('plugins', None)

# Add custom runtime settings
pylint_extra = PylSet.get_or('pylint_extra', None)
Expand All @@ -155,15 +156,16 @@ def read_settings(cls):
pylint_rc,
ignore,
disable_msgs,
pylint_extra)
pylint_extra,
plugins)

@classmethod
def get_lint_version(cls):
""" Return the Pylint version as a (x, y, z) tuple """
pylint_path = cls.get_or('pylint_path', None)
python_bin = cls.get_or('python_bin', 'python')

regex = re.compile(b"[lint.py|pylint]\ ([0-9]+).([0-9]+).([0-9]+)")
regex = re.compile(b"[lint.py|pylint] ([0-9]+).([0-9]+).([0-9]+)")

if pylint_path:
command = [python_bin, pylint_path]
Expand All @@ -176,16 +178,18 @@ def get_lint_version(cls):
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
startupinfo=STARTUPINFO)
output, eoutput = p.communicate()
found = regex.search(output).groups()
output, _ = p.communicate()
found = regex.search(output)

if len(found) == 3:
version = tuple(int(v) for v in found)
print("Pylint version %s found" % str(version))
return version
if found:
found = found.groups()
if len(found) == 3:
version = tuple(int(v) for v in found)
print("Pylint version %s found" % str(version))
return version

speak("Could not determine Pylint version")
return (0, 0, 0)
return (1, 0, 0)


class PylSetException(Exception):
Expand Down Expand Up @@ -354,7 +358,7 @@ def is_enabled(self):
class PylintThread(threading.Thread):
""" This class creates a seperate thread to run Pylint in """
def __init__(self, view, pbin, ppath, cwd, lpath, lrc, ignore,
disable_msgs, extra_pylint_args):
disable_msgs, extra_pylint_args, plugins):
self.view = view
# Grab the file name here, since view cannot be accessed
# from anywhere but the main application thread
Expand All @@ -367,6 +371,7 @@ def __init__(self, view, pbin, ppath, cwd, lpath, lrc, ignore,
self.ignore = ignore
self.disable_msgs = disable_msgs
self.extra_pylint_args = extra_pylint_args
self.plugins = plugins

threading.Thread.__init__(self)

Expand All @@ -384,13 +389,18 @@ def run(self):
options = ['--reports=n',
PYLINT_FORMAT]

if self.plugins:
options.extend(["--load-plugins",
",".join(self.plugins)])

if self.pylint_rc:
options.append('--rcfile=%s' % self.pylint_rc)

if self.disable_msgs:
options.append('--disable=%s' % self.disable_msgs)

options.append(self.file_name)
command.extend(options)

self.set_path()

Expand Down

0 comments on commit cefa6ba

Please sign in to comment.