From cdd560f2e0eb4a5fe8c7215f64e3019eb36492f8 Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Mon, 3 Oct 2016 10:53:10 -0400 Subject: [PATCH] Hacking: Remove C305 contextlib.nested check contextlib.nested no longer exists in Python 3, so this check is not needed. Any use of contextlib.nested will fail py3 unit tests. Change-Id: Ibc3bac5caa6e2ab76a4288150ae0f7a30bd1d37c --- cinder/hacking/checks.py | 10 ---------- cinder/tests/unit/test_hacking.py | 10 ---------- 2 files changed, 20 deletions(-) diff --git a/cinder/hacking/checks.py b/cinder/hacking/checks.py index 176d4e2fd4c..b7eb589a0ec 100644 --- a/cinder/hacking/checks.py +++ b/cinder/hacking/checks.py @@ -443,15 +443,6 @@ def check_no_log_audit(logical_line): yield(0, "C304: Found LOG.audit. Use LOG.info instead.") -def check_no_contextlib_nested(logical_line): - msg = ("C305: contextlib.nested is deprecated. With Python 2.7 and later " - "the with-statement supports multiple nested objects. See https://" - "docs.python.org/2/library/contextlib.html#contextlib.nested " - "for more information.") - if no_contextlib_nested.match(logical_line): - yield(0, msg) - - def check_timeutils_strtime(logical_line): msg = ("C306: Found timeutils.strtime(). " "Please use datetime.datetime.isoformat() or datetime.strftime()") @@ -520,7 +511,6 @@ def factory(register): register(check_unicode_usage) register(check_no_print_statements) register(check_no_log_audit) - register(check_no_contextlib_nested) register(no_log_warn) register(dict_constructor_with_list_copy) register(no_test_log) diff --git a/cinder/tests/unit/test_hacking.py b/cinder/tests/unit/test_hacking.py index b4393f1c2c7..e00677189f6 100644 --- a/cinder/tests/unit/test_hacking.py +++ b/cinder/tests/unit/test_hacking.py @@ -320,16 +320,6 @@ class HackingTestCase(test.TestCase): self.assertEqual(0, len(list(checks.check_oslo_namespace_imports( "from oslo_log import bar")))) - def test_no_contextlib_nested(self): - self.assertEqual(1, len(list(checks.check_no_contextlib_nested( - "with contextlib.nested(")))) - self.assertEqual(1, len(list(checks.check_no_contextlib_nested( - " with nested(")))) - self.assertEqual(0, len(list(checks.check_no_contextlib_nested( - "with my.nested(")))) - self.assertEqual(0, len(list(checks.check_no_contextlib_nested( - "with foo as bar")))) - def test_check_datetime_now(self): self.assertEqual(1, len(list(checks.check_datetime_now( "datetime.now", False))))