hacking: remove oslo.* import check

Oslo libraries don't ship oslo.* namespace anymore (since Liberty). Time
to clean those up.

Change-Id: I86f571c576141d3574a0b5efd0f62670ed6e2dcd
This commit is contained in:
Ihar Hrachyshka 2016-03-03 10:58:42 +01:00
parent ad305919e6
commit 8a03a20726
3 changed files with 0 additions and 31 deletions

View File

@ -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.

View File

@ -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)

View File

@ -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)')