Skip to content

Commit f234217

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Drop redundant check of xrange"
2 parents a2c9db1 + 347b229 commit f234217

4 files changed

Lines changed: 0 additions & 24 deletions

File tree

HACKING.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Magnum Specific Commandments
1818
- [M336] Must use a dict comprehension instead of a dict constructor
1919
with a sequence of key-value pairs.
2020
- [M338] Use assertIn/NotIn(A, B) rather than assertEqual(A in B, True/False).
21-
- [M339] Don't use xrange()
2221
- [M340] Check for explicit import of the _ function.
2322
- [M352] LOG.warn is deprecated. Enforce use of LOG.warning.
2423
- [M353] String interpolation should be delayed at logging calls.

magnum/hacking/checks.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
r"(.)*assertTrue\(isinstance\((\w|\.|\'|\"|\[|\])+, "
4545
r"(\w|\.|\'|\"|\[|\])+\)\)")
4646
dict_constructor_with_list_copy_re = re.compile(r".*\bdict\((\[)?(\(|\[)")
47-
assert_xrange_re = re.compile(
48-
r"\s*xrange\s*\(")
4947
log_translation = re.compile(
5048
r"(.)*LOG\.(audit|error|critical)\(\s*('|\")")
5149
log_translation_info = re.compile(
@@ -102,16 +100,6 @@ def assert_equal_in(logical_line):
102100
"contents.")
103101

104102

105-
@core.flake8ext
106-
def no_xrange(logical_line):
107-
"""Disallow 'xrange()'
108-
109-
M339
110-
"""
111-
if assert_xrange_re.match(logical_line):
112-
yield (0, "M339: Do not use xrange().")
113-
114-
115103
@core.flake8ext
116104
def use_timeutils_utcnow(logical_line, filename):
117105
# tools are OK to use the standard datetime module

magnum/tests/unit/test_hacking.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,6 @@ def test_assert_true_isinstance(self):
150150
code = "self.assertTrue()"
151151
self._assert_has_no_errors(code, check)
152152

153-
def test_no_xrange(self):
154-
errors = [(1, 0, "M339")]
155-
check = checks.no_xrange
156-
157-
code = "xrange(45)"
158-
self._assert_has_errors(code, check, errors)
159-
160-
code = "range(45)"
161-
self._assert_has_no_errors(code, check)
162-
163153
def test_no_log_warn(self):
164154
errors = [(1, 0, "M352")]
165155
check = checks.no_log_warn

tox.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ extension =
116116
M322 = checks:no_mutable_default_args
117117
M336 = checks:dict_constructor_with_list_copy
118118
M338 = checks:assert_equal_in
119-
M339 = checks:no_xrange
120119
M340 = checks:check_explicit_underscore_import
121120
M352 = checks:no_log_warn
122121
paths = ./magnum/hacking

0 commit comments

Comments
 (0)