Drop redundant hacking check for xrange

xrange no longer exists in Python 3 and it is caught by the core check
(as an undefined method).

Also remove a few unused regex patterns.

Change-Id: I6b7cb5fc67b84fa95ef7180d7b16e77105c22522
Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
Takashi Kajinami
2026-01-06 01:21:27 +09:00
parent 31d7a45233
commit cc1d2b2f1b
4 changed files with 0 additions and 21 deletions

View File

@@ -16,7 +16,6 @@ Cloudkitty Specific Commandments
included in translated message.
- [C318] Must use a dict comprehension instead of a dict constructor
with a sequence of key-value pairs.
- [C319] Ensure to not use xrange().
- [C320] Do not use LOG.warn as it's deprecated.
- [C321] Ensure that the _() function is explicitly imported to ensure
proper translations.

View File

@@ -47,11 +47,7 @@ underscore_import_check_multi = re.compile(r"(.)*import (.)*_, (.)*")
# We need this for cases where they have created their own _ function.
custom_underscore_check = re.compile(r"(.)*_\s*=\s*(.)*")
dict_constructor_with_list_copy_re = re.compile(r".*\bdict\((\[)?(\(|\[)")
assert_no_xrange_re = re.compile(r"\s*xrange\s*\(")
assert_True = re.compile(r".*assertEqual\(True, .*\)")
assert_None = re.compile(r".*assertEqual\(None, .*\)")
no_log_warn = re.compile(r".*LOG.warn\(.*\)")
asse_raises_regexp = re.compile(r"assertRaisesRegexp\(")
class BaseASTChecker(ast.NodeVisitor):
@@ -294,16 +290,6 @@ def dict_constructor_with_list_copy(logical_line):
yield (0, msg)
@core.flake8ext
def no_xrange(logical_line):
"""Ensure to not use xrange()
C319
"""
if assert_no_xrange_re.match(logical_line):
yield (0, "C319: Do not use xrange().")
@core.flake8ext
def no_log_warn_check(logical_line):
"""Disallow 'LOG.warn'

View File

@@ -280,11 +280,6 @@ class HackingTestCase(tests.TestCase):
self.assertEqual(0, len(list(checks.dict_constructor_with_list_copy(
" self._render_dict(xml, data_el, data.__dict__)"))))
def test_no_xrange(self):
self.assertEqual(1, len(list(checks.no_xrange("xrange(45)"))))
self.assertEqual(0, len(list(checks.no_xrange("range(45)"))))
def test_no_log_warn_check(self):
self.assertEqual(0, len(list(checks.no_log_warn_check(
"LOG.warning('This should not trigger LOG.warn"

View File

@@ -99,7 +99,6 @@ extension =
C314 = checks:CheckForStrUnicodeExc
C315 = checks:CheckForTransAdd
C318 = checks:dict_constructor_with_list_copy
C319 = checks:no_xrange
C320 = checks:no_log_warn_check
C321 = checks:check_explicit_underscore_import
paths = ./cloudkitty/hacking