summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavanum Srinivas <davanum@gmail.com>2015-07-21 15:31:58 -0500
committerDavanum Srinivas (dims) <davanum@gmail.com>2015-07-23 11:01:19 +0000
commit83d6548bbe3b1570a11099a9aae689a2dc1b93f7 (patch)
tree77bca0ac140bba1252ef8083a5bc7d59663817e9
parent8a7665b6ba34235c246b1564cc2518d31050b3bd (diff)
downloadnova-83d6548bbe3b1570a11099a9aae689a2dc1b93f7.tar.gz
Remove unnecessary oslo namespace import checks
Latest oslo libraries do not support the old oslo namespace based imports, so the import check in our hacking rules are redundant as CI jobs will fail for sure if someone tries to use oslo namespace based imports. Change-Id: I49c74ade374582f53a3678a1bc7df194c24e892e
-rw-r--r--HACKING.rst1
-rw-r--r--nova/hacking/checks.py34
-rw-r--r--nova/tests/unit/test_hacking.py21
3 files changed, 0 insertions, 56 deletions
diff --git a/HACKING.rst b/HACKING.rst
index 8329e97663..1076469ddc 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -41,7 +41,6 @@ Nova Specific Commandments
- [N329] Validate that LOG.exception messages use _LE.
- [N330] Validate that LOG.warning and LOG.warn messages use _LW.
- [N332] Check that the api_version decorator is the first decorator on a method
-- [N333] Check for oslo library imports use the non-namespaced packages
- [N334] Change assertTrue/False(A in/not in B, message) to the more specific
assertIn/NotIn(A, B, message)
- [N335] Check for usage of deprecated assertRaisesRegexp
diff --git a/nova/hacking/checks.py b/nova/hacking/checks.py
index 36a41eb52e..5696ab8ccf 100644
--- a/nova/hacking/checks.py
+++ b/nova/hacking/checks.py
@@ -97,21 +97,6 @@ dict_constructor_with_list_copy_re = re.compile(r".*\bdict\((\[)?(\(|\[)")
decorator_re = re.compile(r"@.*")
http_not_implemented_re = re.compile(r"raise .*HTTPNotImplemented\(")
-# TODO(dims): When other oslo libraries switch over non-namespace'd
-# imports, we need to add them to the regexp below.
-oslo_namespace_imports = re.compile(r"from[\s]*oslo[.]"
- r"(concurrency|config|context|db|i18n|"
- r"log|messaging|middleware|rootwrap|"
- r"serialization|utils|vmware)")
-oslo_namespace_imports_2 = re.compile(r"from[\s]*oslo[\s]*import[\s]*"
- r"(concurrency|config|context|db|i18n|"
- r"log|messaging|middleware|rootwrap|"
- r"serialization|utils|vmware)")
-oslo_namespace_imports_3 = re.compile(r"import[\s]*oslo\."
- r"(concurrency|config|context|db|i18n|"
- r"log|messaging|middleware|rootwrap|"
- r"serialization|utils|vmware)")
-
class BaseASTChecker(ast.NodeVisitor):
"""Provides a simple framework for writing AST-based checks.
@@ -475,24 +460,6 @@ class CheckForTransAdd(BaseASTChecker):
super(CheckForTransAdd, self).generic_visit(node)
-def check_oslo_namespace_imports(logical_line, blank_before, filename):
- if re.match(oslo_namespace_imports, logical_line):
- msg = ("N333: '%s' must be used instead of '%s'.") % (
- logical_line.replace('oslo.', 'oslo_'),
- logical_line)
- yield(0, msg)
- match = re.match(oslo_namespace_imports_2, logical_line)
- if match:
- msg = ("N333: 'module %s should not be imported "
- "from oslo namespace.") % match.group(1)
- yield(0, msg)
- match = re.match(oslo_namespace_imports_3, logical_line)
- if match:
- msg = ("N333: 'module %s should not be imported "
- "from oslo namespace.") % match.group(1)
- yield(0, msg)
-
-
def assert_true_or_false_with_in(logical_line):
"""Check for assertTrue/False(A in B), assertTrue/False(A not in B),
assertTrue/False(A in B, message) or assertTrue/False(A not in B, message)
@@ -574,7 +541,6 @@ def factory(register):
register(check_api_version_decorator)
register(CheckForStrUnicodeExc)
register(CheckForTransAdd)
- register(check_oslo_namespace_imports)
register(assert_true_or_false_with_in)
register(dict_constructor_with_list_copy)
register(assert_equal_in)
diff --git a/nova/tests/unit/test_hacking.py b/nova/tests/unit/test_hacking.py
index 7dbdf827ce..800b3647bc 100644
--- a/nova/tests/unit/test_hacking.py
+++ b/nova/tests/unit/test_hacking.py
@@ -431,27 +431,6 @@ class HackingTestCase(test.NoDBTestCase):
self._assert_has_errors(code, checks.check_api_version_decorator,
expected_errors=[(2, 0, "N332")])
- def test_oslo_namespace_imports_check(self):
- code = """
- from oslo.concurrency import processutils
- """
- self._assert_has_errors(code, checks.check_oslo_namespace_imports,
- expected_errors=[(1, 0, "N333")])
-
- def test_oslo_namespace_imports_check_2(self):
- code = """
- from oslo import i18n
- """
- self._assert_has_errors(code, checks.check_oslo_namespace_imports,
- expected_errors=[(1, 0, "N333")])
-
- def test_oslo_namespace_imports_check_3(self):
- code = """
- import oslo.messaging
- """
- self._assert_has_errors(code, checks.check_oslo_namespace_imports,
- expected_errors=[(1, 0, "N333")])
-
def test_oslo_assert_raises_regexp(self):
code = """
self.assertRaisesRegexp(ValueError,