From 8a03a207262d3a0b4855374e7eead25136483a83 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Thu, 3 Mar 2016 10:58:42 +0100 Subject: [PATCH] hacking: remove oslo.* import check Oslo libraries don't ship oslo.* namespace anymore (since Liberty). Time to clean those up. Change-Id: I86f571c576141d3574a0b5efd0f62670ed6e2dcd --- HACKING.rst | 1 - neutron/hacking/checks.py | 22 ---------------------- neutron/tests/unit/hacking/test_checks.py | 8 -------- 3 files changed, 31 deletions(-) diff --git a/HACKING.rst b/HACKING.rst index 89c1bbe1701..a6cfbc136a8 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -12,7 +12,6 @@ Neutron Specific Commandments - [N320] Validate that LOG messages, except debug ones, have translations - [N321] Validate that jsonutils module is used instead of json - [N322] Detect common errors with assert_called_once_with -- [N323] Enforce namespace-less imports for oslo libraries - [N324] Prevent use of deprecated contextlib.nested. - [N325] Python 3: Do not use xrange. - [N326] Python 3: do not use basestring. diff --git a/neutron/hacking/checks.py b/neutron/hacking/checks.py index af72744f5ab..d6048599829 100644 --- a/neutron/hacking/checks.py +++ b/neutron/hacking/checks.py @@ -55,9 +55,6 @@ log_translation_hint = re.compile( '|'.join('(?:%s)' % _regex_for_level(level, hint) for level, hint in six.iteritems(_all_log_levels))) -oslo_namespace_imports_dot = re.compile(r"import[\s]+oslo[.][^\s]+") -oslo_namespace_imports_from_dot = re.compile(r"from[\s]+oslo[.]") -oslo_namespace_imports_from_root = re.compile(r"from[\s]+oslo[\s]+import[\s]+") contextlib_nested = re.compile(r"^with (contextlib\.)?nested\(") @@ -133,24 +130,6 @@ def check_assert_called_once_with(logical_line, filename): yield (0, msg) -def check_oslo_namespace_imports(logical_line): - if re.match(oslo_namespace_imports_from_dot, logical_line): - msg = ("N323: '%s' must be used instead of '%s'.") % ( - logical_line.replace('oslo.', 'oslo_'), - logical_line) - yield(0, msg) - elif re.match(oslo_namespace_imports_from_root, logical_line): - msg = ("N323: '%s' must be used instead of '%s'.") % ( - logical_line.replace('from oslo import ', 'import oslo_'), - logical_line) - yield(0, msg) - elif re.match(oslo_namespace_imports_dot, logical_line): - msg = ("N323: '%s' must be used instead of '%s'.") % ( - logical_line.replace('import', 'from').replace('.', ' import '), - logical_line) - yield(0, msg) - - def check_no_contextlib_nested(logical_line, filename): msg = ("N324: contextlib.nested is deprecated. With Python 2.7 and later " "the with-statement supports multiple nested objects. See https://" @@ -244,7 +223,6 @@ def factory(register): register(use_jsonutils) register(check_assert_called_once_with) register(no_translate_debug_logs) - register(check_oslo_namespace_imports) register(check_no_contextlib_nested) register(check_python3_xrange) register(check_no_basestring) diff --git a/neutron/tests/unit/hacking/test_checks.py b/neutron/tests/unit/hacking/test_checks.py index fffbd955e26..be1b114e745 100644 --- a/neutron/tests/unit/hacking/test_checks.py +++ b/neutron/tests/unit/hacking/test_checks.py @@ -141,14 +141,6 @@ class HackingTestCase(base.BaseTestCase): 0, len(list(checks.check_assert_called_once_with(pass_code2, "neutron/tests/test_assert.py")))) - def test_check_oslo_namespace_imports(self): - f = checks.check_oslo_namespace_imports - self.assertLinePasses(f, 'from oslo_utils import importutils') - self.assertLinePasses(f, 'import oslo_messaging') - self.assertLineFails(f, 'from oslo.utils import importutils') - self.assertLineFails(f, 'from oslo import messaging') - self.assertLineFails(f, 'import oslo.messaging') - def test_check_python3_xrange(self): f = checks.check_python3_xrange self.assertLineFails(f, 'a = xrange(1000)')