diff --git a/heat/hacking/checks.py b/heat/hacking/checks.py index dade30bb25..4c39435383 100644 --- a/heat/hacking/checks.py +++ b/heat/hacking/checks.py @@ -15,6 +15,8 @@ import re +from hacking import core + """ Guidelines for writing new hacking checks @@ -31,6 +33,7 @@ Guidelines for writing new hacking checks """ +@core.flake8ext def no_log_warn(logical_line): """Disallow 'LOG.warn(' @@ -42,6 +45,7 @@ def no_log_warn(logical_line): yield(0, 'Heat301 Use LOG.warning() rather than LOG.warn()') +@core.flake8ext def check_python3_no_iteritems(logical_line): msg = ("Heat302: Use dict.items() instead of dict.iteritems().") @@ -49,6 +53,7 @@ def check_python3_no_iteritems(logical_line): yield(0, msg) +@core.flake8ext def check_python3_no_iterkeys(logical_line): msg = ("Heat303: Use dict.keys() instead of dict.iterkeys().") @@ -56,15 +61,9 @@ def check_python3_no_iterkeys(logical_line): yield(0, msg) +@core.flake8ext def check_python3_no_itervalues(logical_line): msg = ("Heat304: Use dict.values() instead of dict.itervalues().") if re.search(r".*\.itervalues\(\)", logical_line): yield(0, msg) - - -def factory(register): - register(no_log_warn) - register(check_python3_no_iteritems) - register(check_python3_no_iterkeys) - register(check_python3_no_itervalues) diff --git a/lower-constraints.txt b/lower-constraints.txt index e859aba3a6..35874684d6 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -28,13 +28,11 @@ eventlet==0.18.2 extras==1.0.0 fasteners==0.14.1 fixtures==3.0.0 -flake8==2.5.5 future==0.16.0 futurist==1.6.0 gitdb2==2.0.3 GitPython==2.1.8 greenlet==0.4.13 -hacking==0.12.0 idna==2.6 iso8601==0.1.12 Jinja2==2.10 @@ -84,7 +82,6 @@ paramiko==2.4.1 Paste==2.0.3 PasteDeploy==1.5.0 pbr==2.0.0 -pep8==1.5.7 pika-pool==0.1.3 pika==0.10.0 ply==3.11 @@ -94,7 +91,6 @@ psycopg2==2.7 pyasn1==0.4.2 pycadf==2.7.0 pycparser==2.18 -pyflakes==0.8.1 Pygments==2.2.0 pyinotify==0.9.6 PyMySQL==0.7.6 diff --git a/test-requirements.txt b/test-requirements.txt index d7bd8f6f8a..9e9a488a4c 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -3,7 +3,7 @@ # process, which may cause wedges in the gate later. # Hacking already pins down pep8, pyflakes and flake8 -hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 +hacking>=3.0,<3.1.0 # Apache-2.0 bandit!=1.6.0,>=1.1.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD diff --git a/tox.ini b/tox.ini index 736297877a..62df7fa829 100644 --- a/tox.ini +++ b/tox.ini @@ -108,8 +108,21 @@ commands = bandit -r heat -x tests --skip B101,B104,B107,B110,B310,B311,B404,B41 [flake8] show-source = true +# E117 over-indented +# E123 closing bracket does not match indentation of opening bracket's line +# E226 missing whitespace around arithmetic operator +# E241 multiple spaces after ',' +# E305 expected 2 blank lines after class or function definition, found 1 +# E402 module level import not at top of file +# E731 do not assign a lambda expression, use a def +# E741 ambiguous variable name 'l' +# F841 local variable 'ex' is assigned to but never used +# W503 line break before binary operator +# W504 line break after binary operator +# W605 invalid escape sequence '\ ' +ignore = E117,E123,E226,E241,E305,E402,E731,E741,F841,W503,W504,W605 exclude=.*,dist,*lib/python*,*egg,build,*convergence/scenarios/* -max-complexity=20 +max-complexity=23 [doc8] ignore = D001 @@ -117,7 +130,14 @@ ignore-path = .venv,.git,.tox,.tmp,*heat/locale*,*lib/python*,openstack_heat.egg [hacking] import_exceptions = heat.common.i18n -local-check-factory = heat.hacking.checks.factory + +[flake8:local-plugins] +extension = + Heat301 = checks:no_log_warn + Heat302 = checks:check_python3_no_iteritems + Heat303 = checks:check_python3_no_iterkeys + Heat304 = checks:check_python3_no_itervalues +paths = ./heat/hacking [testenv:debug] commands = oslo_debug_helper {posargs}