Skip to content

Commit 258586f

Browse files
committed
Update pylint to work with python 3
The pylint job was switched over to run under python 3, but the job is not voting and it was apparently missed that the conversion was causing it to fail. This updates the version of pylint to one that is actually supported by python 3 and makes tweaks to our script to for the minor changes between versions. Single character change to get rid of the more strict py3 regex string escape character format. Change-Id: I93124b62c5ee177815457b32f55f5453fc3d387e Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
1 parent 4536b2f commit 258586f

4 files changed

Lines changed: 16 additions & 8 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ build
1616
dist
1717
cinderclient/versioninfo
1818
python_cinderclient.egg-info
19+
20+
# pylint files
21+
tools/lintstack.head.py
22+
tools/pylint_exceptions

cinderclient/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
# tell keystoneclient that we can ignore the /v1|v2/{project_id} component of
7070
# the service catalog when doing discovery lookups
7171
for svc in ('volume', 'volumev2', 'volumev3'):
72-
discover.add_catalog_discover_hack(svc, re.compile('/v[12]/\w+/?$'), '/')
72+
discover.add_catalog_discover_hack(svc, re.compile(r'/v[12]/\w+/?$'), '/')
7373

7474

7575
def get_server_version(url):

tools/lintstack.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
"""pylint error checking."""
1818

19-
from __future__ import print_function
20-
2119
import json
2220
import re
2321
import sys
@@ -70,6 +68,8 @@ def __init__(self, filename, lineno, line_content, code, message,
7068
@classmethod
7169
def from_line(cls, line):
7270
m = re.search(r"(\S+):(\d+): \[(\S+)(, \S+)?] (.*)", line)
71+
if m is None:
72+
return None
7373
matched = m.groups()
7474
filename, lineno, code, message = (matched[0], int(matched[1]),
7575
matched[2], matched[-1])
@@ -83,13 +83,15 @@ def from_line(cls, line):
8383

8484
@classmethod
8585
def from_msg_to_dict(cls, msg):
86-
"""From the output of pylint msg, to a dict, where each key
86+
"""Convert pylint output to a dict.
87+
88+
From the output of pylint msg, to a dict, where each key
8789
is a unique error identifier, value is a list of LintOutput
8890
"""
8991
result = {}
9092
for line in msg.splitlines():
9193
obj = cls.from_line(line)
92-
if obj.is_ignored():
94+
if obj is None or obj.is_ignored():
9395
continue
9496
key = obj.key()
9597
if key not in result:
@@ -147,8 +149,10 @@ def from_file(cls, filename):
147149

148150
def run_pylint():
149151
buff = StringIO()
150-
reporter = text.ParseableTextReporter(output=buff)
151-
args = ["--include-ids=y", "-E", "cinderclient"]
152+
reporter = text.TextReporter(output=buff)
153+
args = [
154+
"--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'",
155+
"-E", "cinderclient"]
152156
lint.Run(args, reporter=reporter, exit=False)
153157
val = buff.getvalue()
154158
buff.close()

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ basepython = python3
3333
deps =
3434
-c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}
3535
-r{toxinidir}/requirements.txt
36-
pylint==0.26.0
36+
pylint==1.9.1
3737
commands = bash tools/lintstack.sh
3838
whitelist_externals = bash
3939

0 commit comments

Comments
 (0)