Use pycodestyle in place of pep8

The lower version of pycodestyle lib (aliased to pep8) doesn't work
for py36 env. This commit unblocks the py36 gate by adding a
dependency on pycodestyle and using that for style checks.

Bump the "hacking" lib version to v1.1.0 which depends
on a higher verion of pycodestyle.

Change-Id: I3fc591e09c1e25a3bd2a3922880772ea9617f1e3
This commit is contained in:
wangxiyuan 2018-11-20 15:21:54 +08:00 committed by Lance Bragstad
parent b7c8738822
commit 090886902c
5 changed files with 16 additions and 17 deletions

View File

@ -19,8 +19,8 @@ so that core devs don't have to.
There are two types of pep8 extensions. One is a function that takes either
a physical or logical line. The physical or logical line is the first param
in the function definition and can be followed by other parameters supported
by pep8. The second type is a class that parses AST trees. For more info
please see pep8.py.
by pycodestyle. The second type is a class that parses AST trees. For more info
please see pycodestyle.py.
"""
import ast

View File

@ -12,13 +12,7 @@
import textwrap
try:
import pep8
except ImportError:
# NTOE(stevemar): pycodestyle is not yet in global-requirements, but
# packagers have begun pycodestyle (the renamed version of pep8)
# See: https://github.com/PyCQA/pycodestyle/issues/466
import pycodestyle as pep8
import pycodestyle
from keystone.tests.hacking import checks
from keystone.tests import unit
@ -41,14 +35,14 @@ class BaseStyleCheck(unit.BaseTestCase):
return hacking_fixtures.HackingCode()
def run_check(self, code):
pep8.register_check(self.get_checker())
pycodestyle.register_check(self.get_checker())
lines = textwrap.dedent(code).strip().splitlines(True)
# Load all keystone hacking checks, they are of the form Kddd,
# where ddd can from range from 000-999
guide = pep8.StyleGuide(select='K')
checker = pep8.Checker(lines=lines, options=guide.options)
guide = pycodestyle.StyleGuide(select='K')
checker = pycodestyle.Checker(lines=lines, options=guide.options)
checker.check_all()
checker.report._deferred_print.sort()
return checker.report._deferred_print

View File

@ -12,7 +12,7 @@ flake8==2.5.5
Flask===1.0.2
Flask-RESTful===0.3.5
freezegun==0.3.6
hacking==0.12.0
hacking==1.1.0
iso8601==0.1.12
jsonschema==2.6.0
keystoneauth1==3.4.0
@ -43,9 +43,9 @@ osprofiler==1.4.0
passlib==1.7.0
pbr==2.0.0
pep257==0.7.0
pep8==1.5.7
pika==0.10.0
pycadf==1.1.0
pycodestyle==2.0.0
python-ldap===3.0.0
pymongo===3.0.2
pysaml2==4.5.0

View File

@ -2,8 +2,9 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
hacking>=1.1.0,<1.2.0 # Apache-2.0
pep257==0.7.0 # MIT License
pycodestyle>=2.0.0 # MIT License
flake8-docstrings==0.2.1.post1 # MIT
bashate>=0.5.1 # Apache-2.0
os-testr>=1.0.0 # Apache-2.0

View File

@ -32,7 +32,7 @@ deps =
.[bandit]
{[testenv]deps}
commands =
flake8
flake8 --ignore=D100,D101,D102,D103,D104,E305,E402,E501,W503,W504,W605,E731
# Run bash8 during pep8 runs to ensure violations are caught by
# the check and gate queues
bashate devstack/plugin.sh
@ -117,7 +117,11 @@ enable-extensions = H203,H904
# D103: Missing docstring in public function
# D104: Missing docstring in public package
# D203: 1 blank line required before class docstring (deprecated in pep257)
ignore = D100,D101,D102,D103,D104,D203
# TODO(wxy): Fix the pep8 issue.
# E402: module level import not at top of file
# W503: line break before binary operator
# E731: do not assign a lambda expression, use a def
ignore = D100,D101,D102,D103,D104,D203,E402,W503,E731
exclude=.venv,.git,.tox,build,dist,*lib/python*,*egg,tools,vendor,.update-venv,*.ini,*.po,*.pot
max-complexity=24