Commit eb26d525 authored by Igor Gnatenko's avatar Igor Gnatenko
Browse files

[backends/python] check via pylint
parent 051b058a
......@@ -185,6 +185,7 @@ Dependencies : python, python-dbus, python-simplejson
### Python
Dependencies : python, python-dbus
Optional dependencies : pylint (enabled only if you will pass "pylint" in "options" to dbus service)
### Ruby
Dependencies : ruby, ruby-dbus
# gnome code assistance python backend
# Copyright (C) 2013 Jesse van den Kieboom <>
# Copyright (C) 2014 Elad Alfassa <>
# Copyright (C) 2015 Igor Gnatenko <>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -20,8 +21,50 @@ import ast
import subprocess
import re
from pylint import lint
from pylint.reporters.text import TextReporter
except ImportError:
from gnome.codeassistance import transport, types
class PyLint(object):
def __init__(self, data_path):
self.diagnostics = []
self.data_path = data_path
def write(self, st):
if st != "\n" and not st.startswith("*"):
result = st.split(":")
col = int(result[1]) + 1
loc = types.SourceLocation(line=result[0], column=col)
* (C) convention, for programming standard violation
* (R) refactor, for bad code smell
* (W) warning, for python specific problems
* (E) error, for much probably bugs in the code
* (F) fatal, if an error occurred which prevented pylint from doing
further processing.
if result[2] == "C" or result[2] == "R" or result[2] == "W":
severity = types.Diagnostic.Severity.INFO
severity = types.Diagnostic.Severity.ERROR
def run(self):
args = [self.data_path, "-r", "n",
"--msg-template='{line}:{column}:{C}:{msg_id} {msg}'"]
lint.Run(args, reporter=TextReporter(self), exit=False)
return self.diagnostics
class Service(transport.Service):
language = 'python'
......@@ -54,6 +97,14 @@ class Service(transport.Service):
# PEP8 is not installed. Do nothing.
if "pylint" in options and options["pylint"]:
pylint = PyLint(doc.data_path)
diagnostics =
for diag in diagnostics:
class Document(transport.Document, transport.Diagnostics):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment