From d675de18dea7391ee54ad15a3a1cb418f60bcfd3 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Tue, 5 Jun 2018 14:50:38 -0500 Subject: [PATCH] Run pylint job under py3 This switches the pylint target to run under python3. In order to work right, it also raises the version of pylint used to a newer version. Related-bug: #1761800 Change-Id: I0bc68a5aee24a53b9d3a08c20549b89d08989678 --- tools/lintstack.py | 16 ++++++++++------ tox.ini | 3 +-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tools/lintstack.py b/tools/lintstack.py index 6bf31b0bf3b..1199ad510d9 100755 --- a/tools/lintstack.py +++ b/tools/lintstack.py @@ -16,8 +16,6 @@ """pylint error checking.""" -from __future__ import print_function - import json import re import sys @@ -112,6 +110,8 @@ class LintOutput(object): @classmethod def from_line(cls, line): m = re.search(r"(\S+):(\d+): \[(\S+)(, \S+)?] (.*)", line) + if m is None: + return None matched = m.groups() filename, lineno, code, message = (matched[0], int(matched[1]), matched[2], matched[-1]) @@ -125,13 +125,15 @@ class LintOutput(object): @classmethod def from_msg_to_dict(cls, msg): - """From the output of pylint msg, to a dict, where each key + """Convert pylint output to a dict + + From the output of pylint msg, to a dict, where each key is a unique error identifier, value is a list of LintOutput """ result = {} for line in msg.splitlines(): obj = cls.from_line(line) - if obj.is_ignored(): + if obj is None or obj.is_ignored(): continue key = obj.key() if key not in result: @@ -199,8 +201,10 @@ class ErrorKeys(object): def run_pylint(): buff = StringIO() - reporter = text.ParseableTextReporter(output=buff) - args = ["--include-ids=y", "-E", "cinder"] + reporter = text.TextReporter(output=buff) + args = [ + "--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'", + "-E", "cinder"] lint.Run(args, reporter=reporter, exit=False) val = buff.getvalue() buff.close() diff --git a/tox.ini b/tox.ini index ec57a39da73..76d544137c3 100644 --- a/tox.ini +++ b/tox.ini @@ -77,9 +77,8 @@ commands = {toxinidir}/tools/fast8.sh [testenv:pylint] -basepython = python2.7 deps = -r{toxinidir}/requirements.txt - pylint==0.26.0 + pylint==1.9.1 commands = bash tools/lintstack.sh [testenv:cover]