Fix requirements, update hacking
hacking already pins flake8, so do not add it, especially in conflict with the hacking version. hacking also pins pycodestyle, so remove that as well. The repo is Python 3 now, so update hacking for a python3 version. Blacklist new failures or fix them. Convert own hacking checks to new flake8 API, update lower-constraints for this. Change-Id: I2928b9d764f61a53a549a9eb850c7809bdbb6f74
This commit is contained in:
parent
d3bd9ef3f3
commit
30e5a90552
|
@ -25,13 +25,13 @@ eventlet==0.18.2
|
|||
extras==1.0.0
|
||||
fasteners==0.14.1
|
||||
fixtures==3.0.0
|
||||
flake8==2.5.4
|
||||
flake8==3.7.9
|
||||
future==0.16.0
|
||||
futurist==1.6.0
|
||||
gitdb2==2.0.3
|
||||
GitPython==2.1.8
|
||||
greenlet==0.4.13
|
||||
hacking==0.12.0
|
||||
hacking==2.0.0
|
||||
idna==2.6
|
||||
iso8601==0.1.12
|
||||
Jinja2==2.10
|
||||
|
@ -81,7 +81,6 @@ paramiko==2.4.1
|
|||
Paste==2.0.3
|
||||
PasteDeploy==1.5.0
|
||||
pbr==2.0.0
|
||||
pep8==1.7.1
|
||||
pika-pool==0.1.3
|
||||
pika==0.10.0
|
||||
ply==3.11
|
||||
|
@ -89,6 +88,7 @@ prettytable==0.7.2
|
|||
pyasn1==0.4.2
|
||||
pycadf==2.7.0
|
||||
pycparser==2.18
|
||||
pycodestyle==2.5.0
|
||||
pyflakes==1.0.0
|
||||
pyinotify==0.9.6
|
||||
PyMySQL==0.7.6
|
||||
|
|
|
@ -88,7 +88,7 @@ def setup(url=None, optional=False):
|
|||
try:
|
||||
NOTIFICATION_TRANSPORT = messaging.get_notification_transport(
|
||||
cfg.CONF, allowed_remote_exmods=exmods)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
serializer = RequestContextSerializer(JsonPayloadSerializer())
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
import re
|
||||
|
||||
from hacking import core
|
||||
|
||||
asse_equal_end_with_none_re = re.compile(r"assertEqual\(.*?,\s+None\)$")
|
||||
asse_equal_start_with_none_re = re.compile(r"assertEqual\(None,")
|
||||
asse_equal_start_with_true_re = re.compile(r"assertEqual\(True,")
|
||||
|
@ -21,6 +23,7 @@ api_version_dec = re.compile(r"@.*api_version")
|
|||
decorator_re = re.compile(r"@.*")
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def assert_equal_none(logical_line):
|
||||
"""Check for assertEqual(A, None) or assertEqual(None, A) sentences
|
||||
|
||||
|
@ -33,6 +36,7 @@ def assert_equal_none(logical_line):
|
|||
"sentences not allowed")
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def use_jsonutils(logical_line, filename):
|
||||
msg = "S319: jsonutils.%(fun)s must be used instead of json.%(fun)s"
|
||||
|
||||
|
@ -44,12 +48,14 @@ def use_jsonutils(logical_line, filename):
|
|||
yield (pos, msg % {'fun': f[:-1]})
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def no_mutable_default_args(logical_line):
|
||||
msg = "S320: Method's default argument shouldn't be mutable!"
|
||||
if mutable_default_args.match(logical_line):
|
||||
yield (0, msg)
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def no_log_warn(logical_line):
|
||||
"""Disallow 'LOG.warn('
|
||||
|
||||
|
@ -64,6 +70,7 @@ def no_log_warn(logical_line):
|
|||
yield (0, msg)
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def assert_equal_true(logical_line):
|
||||
"""Check for assertEqual(A, True) or assertEqual(True, A) sentences
|
||||
|
||||
|
@ -76,6 +83,7 @@ def assert_equal_true(logical_line):
|
|||
"sentences not allowed")
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def check_api_version_decorator(logical_line, previous_logical, blank_before,
|
||||
filename):
|
||||
msg = ("S321: The api_version decorator must be the first decorator on "
|
||||
|
@ -83,12 +91,3 @@ def check_api_version_decorator(logical_line, previous_logical, blank_before,
|
|||
if (blank_before == 0 and re.match(api_version_dec, logical_line) and
|
||||
re.match(decorator_re, previous_logical)):
|
||||
yield(0, msg)
|
||||
|
||||
|
||||
def factory(register):
|
||||
register(assert_equal_none)
|
||||
register(use_jsonutils)
|
||||
register(no_mutable_default_args)
|
||||
register(no_log_warn)
|
||||
register(check_api_version_decorator)
|
||||
register(assert_equal_true)
|
||||
|
|
|
@ -143,8 +143,8 @@ class TestConstraintsSchema(testtools.TestCase):
|
|||
c = constraints.AllowedValues(['foo', 'bar'])
|
||||
s = schema.String('A string', default='wibble', required=True,
|
||||
constraints=[c])
|
||||
l = schema.List('A list', schema=s)
|
||||
self.assertEqual(d, dict(l))
|
||||
li = schema.List('A list', schema=s)
|
||||
self.assertEqual(d, dict(li))
|
||||
|
||||
def test_schema_map_schema(self):
|
||||
d = {
|
||||
|
@ -204,8 +204,8 @@ class TestConstraintsSchema(testtools.TestCase):
|
|||
s = schema.String('A string', default='wibble', required=True,
|
||||
constraints=[c])
|
||||
m = schema.Map('A map', schema={'Foo': s})
|
||||
l = schema.List('A list', schema=m)
|
||||
self.assertEqual(d, dict(l))
|
||||
li = schema.List('A list', schema=m)
|
||||
self.assertEqual(d, dict(li))
|
||||
|
||||
def test_schema_validate_good(self):
|
||||
c = constraints.AllowedValues(['foo', 'bar'])
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
import pep8
|
||||
import pycodestyle
|
||||
import textwrap
|
||||
|
||||
from senlin.hacking import checks
|
||||
|
@ -19,14 +19,14 @@ from senlin.tests.unit.common import base
|
|||
|
||||
|
||||
class HackingTestCase(base.SenlinTestCase):
|
||||
@mock.patch('pep8._checks',
|
||||
@mock.patch('pycodestyle._checks',
|
||||
{'physical_line': {}, 'logical_line': {}, 'tree': {}})
|
||||
def _run_check(self, code, checker, filename=None):
|
||||
pep8.register_check(checker)
|
||||
pycodestyle.register_check(checker)
|
||||
|
||||
lines = textwrap.dedent(code).strip().splitlines(True)
|
||||
|
||||
checker = pep8.Checker(filename=filename, lines=lines)
|
||||
checker = pycodestyle.Checker(filename=filename, lines=lines)
|
||||
checker.check_all()
|
||||
checker.report._deferred_print.sort()
|
||||
return checker.report._deferred_print
|
||||
|
|
|
@ -3,13 +3,11 @@
|
|||
# process, which may cause wedges in the gate later.
|
||||
|
||||
# Hacking already pins down pep8, pyflakes and flake8
|
||||
hacking>=3.0,<4.0.0 # Apache-2.0
|
||||
coverage!=4.4,>=4.0 # Apache-2.0
|
||||
flake8<2.6.0,>=2.5.4 # MIT
|
||||
hacking>=1.1.0,<1.2.0 # Apache-2.0
|
||||
mock>=2.0.0 # BSD
|
||||
oslotest>=3.2.0 # Apache-2.0
|
||||
stestr>=2.0.0 # Apache-2.0
|
||||
pycodestyle==2.0.0
|
||||
PyMySQL>=0.7.6 # MIT License
|
||||
tempest>=17.1.0 # Apache-2.0
|
||||
testscenarios>=0.4 # Apache-2.0/BSD
|
||||
|
|
13
tox.ini
13
tox.ini
|
@ -74,16 +74,25 @@ commands =
|
|||
# Temporarily disable complaints about docstring for public module/class/method
|
||||
# H106 Don't put vim configuration in source files
|
||||
# H203 Use assertIs(Not)None to check for None
|
||||
ignore = D100,D101,D102,D103,D104,D105,D200,D201,D202,D204,D205,D300,D301,D400,D401,I100,I201
|
||||
ignore = D100,D101,D102,D103,D104,D105,D200,D201,D202,D204,D205,D300,D301,D400,D401,I100,I201,W504,W605
|
||||
enable-extensions=H106,H203,H204,H205
|
||||
show-source = true
|
||||
exclude=.venv,.git,.tox,cover,dist,*lib/python*,*egg,tools,build,releasenotes
|
||||
max-complexity=20
|
||||
|
||||
[hacking]
|
||||
local-check-factory = senlin.hacking.checks.factory
|
||||
import_exceptions = senlin.common.i18n
|
||||
|
||||
[flake8:local-plugins]
|
||||
extension =
|
||||
S318 = checks:assert_equal_none
|
||||
S319 = checks:use_jsonutils
|
||||
S320 = checks:no_mutable_default_args
|
||||
S321 = checks:check_api_version_decorator
|
||||
S322 = checks:no_log_warn
|
||||
S323 = checks:assert_equal_true
|
||||
paths = ./senlin/hacking
|
||||
|
||||
[testenv:bandit]
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = bandit -r senlin -x tests -s B101,B104,B110,B310,B311,B506
|
||||
|
|
Loading…
Reference in New Issue