Skip to content
Snippets Groups Projects
Commit 28d96e27 authored by Bienchen's avatar Bienchen
Browse files

Extended pylint

parent 9f56485f
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,7 @@ class FileCheck(object): ...@@ -24,6 +24,7 @@ class FileCheck(object):
""" """
def __init__(self, filepath): def __init__(self, filepath):
self.filepath = filepath self.filepath = filepath
self.absfilepath = os.path.abspath(filepath)
self.current_line = None self.current_line = None
def Check(self, ignore_line_width=False): def Check(self, ignore_line_width=False):
......
...@@ -26,7 +26,9 @@ class Python(base.FileCheck): ...@@ -26,7 +26,9 @@ class Python(base.FileCheck):
pm3_csc.FailMsg("ERROR in parsing pylint output, message seems to"+ pm3_csc.FailMsg("ERROR in parsing pylint output, message seems to"+
"contain more than one ':': '%s'" % outline, 15) "contain more than one ':': '%s'" % outline, 15)
# for the message translation, we provide tags %(line)s and %(file)s, # for the message translation, we provide tags %(line)s and %(file)s,
# they will be filled if a message gets invoked. # they will be filled if a message gets invoked. The original pylint
# command runs with '--msg-template="{line}:{symbol}"' to reveal the
# first bit of an entry.
msg_dict = { msg_dict = {
'missing-docstring': 'missing-docstring':
"Line %(line)s: Documentation is missing. We want "+ "Line %(line)s: Documentation is missing. We want "+
...@@ -49,15 +51,25 @@ class Python(base.FileCheck): ...@@ -49,15 +51,25 @@ class Python(base.FileCheck):
'unused-import': 'unused-import':
"Line %(line)s: A module is imported but never used in the code. "+ "Line %(line)s: A module is imported but never used in the code. "+
"This increases execution time and may create an unnecessary "+ "This increases execution time and may create an unnecessary "+
"dependency. Please remove the import." "dependency. Please remove the import.",
'bad-continuation':
"Line %(line)s: A multi-line command is not aligned like Python "+
"wants it. Usually things should all align along opening "+
"parenthesis or similar landmarks. Sometimes this means to "+
"introduce an awkward looking '=\\' in a function call."
} }
if msg[1] not in msg_dict.keys(): if msg[1] not in msg_dict.keys():
this_path = os.path.dirname(__file__)
pm3_csc.FailMsg("Found a pylint message for the first time: "+ pm3_csc.FailMsg("Found a pylint message for the first time: "+
"'%s'. You can get more information on " % outline + "'%s'. You can get more information on " % outline +
"the kind of issue by running 'pylint "+ "the kind of issue by running 'pylint "+
"--help-msg=%s'. Once this is resolved, " % msg[1] + "--help-msg=%s'. Once this is resolved, " % msg[1] +
"you could extend '%s' with more " % __file__ + "you could extend '%s' with more " % __file__ +
"meaningful information.", 16) "meaningful information. You can run pylint on "+
"this file by 'pylint "+
"--rcfile=%s " % os.path.join(this_path,
'pylintrc')+
"-r n %s'." % self.absfilepath, 16)
subst_dict = {'line' : msg[0], 'file' : self.filepath} subst_dict = {'line' : msg[0], 'file' : self.filepath}
return msg_dict[msg[1]] % subst_dict return msg_dict[msg[1]] % subst_dict
...@@ -103,3 +115,5 @@ class Python(base.FileCheck): ...@@ -103,3 +115,5 @@ class Python(base.FileCheck):
os.linesep.join(msg_stack), 17) os.linesep.join(msg_stack), 17)
__all__ = ('Python', ) __all__ = ('Python', )
# LocalWords: multi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment