Skip to content

Commit 82df2ec

Browse files
committed
setup: Switch to pycodestyle and pylint imports
Which seamlessly let's us run pylint/pycodestyle depending on the invoking python version, 2 or 3
1 parent 9aad8aa commit 82df2ec

4 files changed

Lines changed: 31 additions & 19 deletions

File tree

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,19 @@ To test all supported python versions, run tox using any of the following.
3939
tox -- --rw-functional
4040

4141

42-
# pylint and pep8
42+
# pylint and pycodestyle
4343

44-
To test for pylint or pep8 violations, you can run:
44+
To test for pylint or pycodestyle violations, you can run:
4545

4646
python setup.py pylint
4747

48-
Note: This expects that you already have pylint and pep8 installed.
48+
Note: This expects that you already have pylint and pycodestyle installed.
4949

5050

5151
# Patch Submission
5252

5353
If you are submitting a patch, ensure the following:
54-
[REQ] verify that no new pylint or pep8 violations
54+
[REQ] verify that no new pylint or pycodestyle violations
5555
[REQ] run basic unit test suite across all python versions as described
5656
above.
5757

setup.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,21 +144,32 @@ def finalize_options(self):
144144
pass
145145

146146
def _run(self):
147-
files = ["bugzilla/", "bin-bugzilla", "examples/*.py", "tests/*.py"]
147+
import pylint.lint
148+
import pycodestyle
149+
150+
files = (["bugzilla/", "bin-bugzilla"] +
151+
glob.glob("examples/*.py") +
152+
glob.glob("tests/*.py"))
148153
output_format = sys.stdout.isatty() and "colorized" or "text"
149154

150-
if os.path.exists("/usr/bin/pylint-2"):
151-
cmd = "pylint-2 "
152-
else:
153-
cmd = "pylint "
154-
cmd += "--output-format=%s " % output_format
155-
cmd += " ".join(files)
156-
os.system(cmd + " --rcfile tests/pylint.cfg")
157-
158-
print("running pep8")
159-
cmd = "pep8 "
160-
cmd += " ".join(files)
161-
os.system(cmd + " --config tests/pep8.cfg --exclude oldclasses.py")
155+
print("running pycodestyle")
156+
style_guide = pycodestyle.StyleGuide(
157+
config_file='tests/pycodestyle.cfg',
158+
paths=files,
159+
)
160+
style_guide.options.exclude = pycodestyle.normalize_paths(
161+
"bugzilla/oldclasses.py",
162+
)
163+
report = style_guide.check_files()
164+
if style_guide.options.count:
165+
sys.stderr.write(str(report.total_errors) + '\n')
166+
167+
print("running pylint")
168+
pylint_opts = [
169+
"--rcfile", "tests/pylint.cfg",
170+
"--output-format=%s" % output_format,
171+
]
172+
pylint.lint.Run(files + pylint_opts)
162173

163174
def run(self):
164175
os.link("bin/bugzilla", "bin-bugzilla")

test-requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# additional packages needed for testing
22
coverage
3-
pep8
3+
pycodestyle
4+
pylint

tests/pep8.cfg renamed to tests/pycodestyle.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[pep8]
1+
[pycodestyle]
22

33
format = pylint
44

0 commit comments

Comments
 (0)