Update hacking
This patch updates the version of hacking to be consistent with octavia.
It is also 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 removes O349 check for importing mock since flake8 has
added H216 which does the same check.
Change-Id: I8e49fc19faff59b2811a7ee09b7ccaa286f73d82
diff --git a/octavia_tempest_plugin/hacking/checks.py b/octavia_tempest_plugin/hacking/checks.py
index eec7476..7008994 100644
--- a/octavia_tempest_plugin/hacking/checks.py
+++ b/octavia_tempest_plugin/hacking/checks.py
@@ -66,8 +66,6 @@
no_eventlet_re = re.compile(r'(import|from)\s+[(]?eventlet')
no_line_continuation_backslash_re = re.compile(r'.*(\\)\n')
no_logging_re = re.compile(r'(import|from)\s+[(]?logging')
-import_mock_re = re.compile(r"\bimport[\s]+mock\b")
-import_from_mock_re = re.compile(r"\bfrom[\s]+mock[\s]+import\b")
def _translation_checks_not_enforced(filename):
@@ -147,7 +145,7 @@
O339
"""
if logical_line.startswith('LOG.warn('):
- yield(0, "O339:Use LOG.warning() rather than LOG.warn()")
+ yield (0, "O339:Use LOG.warning() rather than LOG.warn()")
@core.flake8ext
@@ -260,18 +258,3 @@
if no_logging_re.match(logical_line):
msg = 'O348 Usage of Python logging module not allowed, use oslo_log'
yield logical_line.index('logging'), msg
-
-
-@core.flake8ext
-def check_no_import_mock(logical_line):
- """O349 - Test code must not import mock library.
-
- :param logical_line: The logical line to check.
- :returns: None if the logical line passes the check, otherwise a tuple
- is yielded that contains the offending index in logical line
- and a message describe the check validation failure.
- """
- if (import_mock_re.match(logical_line) or
- import_from_mock_re.match(logical_line)):
- msg = 'O349 Test code must not import mock library, use unittest.mock'
- yield 0, msg