Update hacking
This patch updates the version of hacking to be consistent with
designate.
It is required for flake8 to understand f-strings correctly.
Along with this version update, the patch fixes issues in the code found
by the new versions.
This patch also disables two flake8 plugins from tempest T110 and T111
as they are not compatible with the newer version of flake8.
They can be re-enabled once tempest updates to a newer hacking version
and fixes these issues.
Change-Id: Ia8153724e28cd0ce032d77ff08b4c35f75a1dfc8
diff --git a/designate_tempest_plugin/hacking/checks.py b/designate_tempest_plugin/hacking/checks.py
index 53de95c..bce63ef 100644
--- a/designate_tempest_plugin/hacking/checks.py
+++ b/designate_tempest_plugin/hacking/checks.py
@@ -15,7 +15,6 @@
import re
from hacking import core
-import pycodestyle
# D701: Default parameter value is a mutable type
# D702: Log messages require translation
@@ -49,8 +48,8 @@
@core.flake8ext
-def mutable_default_arguments(physical_line, logical_line, filename):
- if pycodestyle.noqa(physical_line):
+def mutable_default_arguments(logical_line, filename, noqa):
+ if noqa:
return
if mutable_default_argument_check.match(logical_line):
@@ -69,7 +68,7 @@
N319
"""
if logical_line.startswith("LOG.debug(_("):
- yield(0, "D706: Don't translate debug level logs")
+ yield (0, "D706: Don't translate debug level logs")
@core.flake8ext
@@ -90,7 +89,7 @@
UNDERSCORE_IMPORT_FILES.append(filename)
elif (translated_log.match(logical_line) or
string_translation.match(logical_line)):
- yield(0, "D703: Found use of _() without explicit import of _!")
+ yield (0, "D703: Found use of _() without explicit import of _!")
@core.flake8ext
@@ -109,8 +108,8 @@
matches = graduated_oslo_libraries_import_re.match(logical_line)
if matches:
- yield(0, "D704: Found import of %s. This oslo library has been "
- "graduated!" % matches.group(1))
+ yield (0, "D704: Found import of %s. This oslo library has been "
+ "graduated!" % matches.group(1))
@core.flake8ext
@@ -133,14 +132,13 @@
if re.search(r"\bbasestring\b", logical_line):
msg = ("D707: basestring is not Python3-compatible, use "
"str instead.")
- yield(0, msg)
+ yield (0, msg)
@core.flake8ext
def check_python3_xrange(logical_line):
if re.search(r"\bxrange\s*\(", logical_line):
- yield(0, "D708: Do not use xrange. Use range for "
- "large loops.")
+ yield (0, "D708: Do not use xrange. Use range for large loops.")
@core.flake8ext
@@ -152,7 +150,7 @@
for OpenStack we can enforce not using it.
"""
if "LOG.audit(" in logical_line:
- yield(0, "D709: LOG.audit is deprecated, please use LOG.info!")
+ yield (0, "D709: LOG.audit is deprecated, please use LOG.info!")
@core.flake8ext
@@ -162,7 +160,7 @@
D710
"""
if logical_line.startswith('LOG.warn('):
- yield(0, "D710:Use LOG.warning() rather than LOG.warn()")
+ yield (0, "D710:Use LOG.warning() rather than LOG.warn()")
@core.flake8ext