Drop unicode() hacking check

This hacking check is no longer required now that we have moved to py3.
There probably isn't much need to use unicode() calls, but if the
situation calls for it, it is now better to do that than to direct
people to use six methods.

Some minor cleanup of hacking config included.

Change-Id: I5c97e673223d29b18aad37804d0d7b8c07e501c2
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
Sean McGinnis 2020-03-29 19:11:41 -05:00
parent a144fa3474
commit 6847ba2d6a
3 changed files with 5 additions and 29 deletions

View File

@ -309,20 +309,6 @@ def check_datetime_now(logical_line, noqa):
yield(0, msg) yield(0, msg)
_UNICODE_USAGE_REGEX = re.compile(r'\bunicode *\(')
@core.flake8ext
def check_unicode_usage(logical_line, noqa):
if noqa:
return
msg = "C302: Found unicode() call. Please use six.text_type()."
if _UNICODE_USAGE_REGEX.search(logical_line):
yield(0, msg)
@core.flake8ext @core.flake8ext
def check_no_print_statements(logical_line, filename, noqa): def check_no_print_statements(logical_line, filename, noqa):
# CLI and utils programs do need to use 'print()' so # CLI and utils programs do need to use 'print()' so

View File

@ -219,12 +219,6 @@ class HackingTestCase(test.TestCase):
self.assertEqual(0, len(list(checks.check_timeutils_strtime( self.assertEqual(0, len(list(checks.check_timeutils_strtime(
"strftime")))) "strftime"))))
def test_check_unicode_usage(self):
self.assertEqual(1, len(list(checks.check_unicode_usage(
"unicode(msg)", False))))
self.assertEqual(0, len(list(checks.check_unicode_usage(
"unicode(msg) # noqa", True))))
def test_no_print_statements(self): def test_no_print_statements(self):
self.assertEqual(0, len(list(checks.check_no_print_statements( self.assertEqual(0, len(list(checks.check_no_print_statements(
"a line with no print statement", "a line with no print statement",

14
tox.ini
View File

@ -199,24 +199,20 @@ max-complexity = 30
application-import-names = cinder application-import-names = cinder
import-order-style = pep8 import-order-style = pep8
[hacking]
import_exceptions = cinder.i18n
[flake8:local-plugins] [flake8:local-plugins]
extension = extension =
C312 = checks:no_translate_logs
N322 = checks:no_mutable_default_args N322 = checks:no_mutable_default_args
N323 = checks:check_explicit_underscore_import N323 = checks:check_explicit_underscore_import
C310 = checks:CheckLoggingFormatArgs
C311 = checks:CheckOptRegistrationArgs
C301 = checks:check_datetime_now C301 = checks:check_datetime_now
C303 = checks:check_no_print_statements
C306 = checks:check_timeutils_strtime C306 = checks:check_timeutils_strtime
C308 = checks:check_timeutils_isotime C308 = checks:check_timeutils_isotime
C302 = checks:check_unicode_usage
C303 = checks:check_no_print_statements
C336 = checks:dict_constructor_with_list_copy
C309 = checks:no_test_log C309 = checks:no_test_log
C310 = checks:CheckLoggingFormatArgs
C311 = checks:CheckOptRegistrationArgs
C312 = checks:no_translate_logs
C313 = checks:validate_assertTrue C313 = checks:validate_assertTrue
C336 = checks:dict_constructor_with_list_copy
paths = ./cinder/tests/hacking paths = ./cinder/tests/hacking
[doc8] [doc8]