Skip to content

Commit 7472f51

Browse files
committed
Bump hacking
hacking 3.0.x is too old. This also removes the note about old behavior of pip which has been changed in recent versions. Notes: - A few errors newly detected are also fixed. - This also fixes the compatibility with flake8 >= 3.0 because flake8 is also bumped when we bump hacking. - pretty_flake8 tool is removed because it's not commonly used but needs maintenance effort to keep it in sync with newer releases Change-Id: I8e91b06199bfbed1d6e9f8d62ddf52fafd60b7f9
1 parent 21b266b commit 7472f51

File tree

8 files changed

+20
-122
lines changed

8 files changed

+20
-122
lines changed

contrib/zoneextractor.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# under the License.
1616

1717
import argparse
18+
import io
1819
import logging
1920
import os
2021
import re
@@ -39,7 +40,7 @@ def to_stdout(self):
3940
self.to_file(sys.stdout)
4041

4142
def to_file(self, f):
42-
if type(f) == 'file':
43+
if isinstance(f, io.IOBase):
4344
fd = f
4445
elif type(f) is str:
4546
if os.path.isdir(f):

designate/hacking/checks.py

+11-12
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import re
1616

1717
from hacking import core
18-
import pycodestyle
1918

2019
# D701: Default parameter value is a mutable type
2120
# D702: Log messages require translation
@@ -49,8 +48,8 @@
4948

5049

5150
@core.flake8ext
52-
def mutable_default_arguments(physical_line, logical_line, filename):
53-
if pycodestyle.noqa(physical_line):
51+
def mutable_default_arguments(logical_line, filename, noqa):
52+
if noqa:
5453
return
5554

5655
if mutable_default_argument_check.match(logical_line):
@@ -69,7 +68,7 @@ def no_translate_debug_logs(logical_line, filename):
6968
N319
7069
"""
7170
if logical_line.startswith("LOG.debug(_("):
72-
yield(0, "D706: Don't translate debug level logs")
71+
yield (0, "D706: Don't translate debug level logs")
7372

7473

7574
@core.flake8ext
@@ -90,7 +89,7 @@ def check_explicit_underscore_import(logical_line, filename):
9089
UNDERSCORE_IMPORT_FILES.append(filename)
9190
elif (translated_log.match(logical_line) or
9291
string_translation.match(logical_line)):
93-
yield(0, "D703: Found use of _() without explicit import of _!")
92+
yield (0, "D703: Found use of _() without explicit import of _!")
9493

9594

9695
@core.flake8ext
@@ -109,8 +108,8 @@ def no_import_graduated_oslo_libraries(logical_line, filename):
109108

110109
matches = graduated_oslo_libraries_import_re.match(logical_line)
111110
if matches:
112-
yield(0, "D704: Found import of %s. This oslo library has been "
113-
"graduated!" % matches.group(1))
111+
yield (0, "D704: Found import of %s. This oslo library has been "
112+
"graduated!" % matches.group(1))
114113

115114

116115
@core.flake8ext
@@ -133,14 +132,14 @@ def check_no_basestring(logical_line):
133132
if re.search(r"\bbasestring\b", logical_line):
134133
msg = ("D707: basestring is not Python3-compatible, use "
135134
"str instead.")
136-
yield(0, msg)
135+
yield (0, msg)
137136

138137

139138
@core.flake8ext
140139
def check_python3_xrange(logical_line):
141140
if re.search(r"\bxrange\s*\(", logical_line):
142-
yield(0, "D708: Do not use xrange. Use range for "
143-
"large loops.")
141+
yield (0, "D708: Do not use xrange. Use range for "
142+
"large loops.")
144143

145144

146145
@core.flake8ext
@@ -152,7 +151,7 @@ def check_no_log_audit(logical_line):
152151
for OpenStack we can enforce not using it.
153152
"""
154153
if "LOG.audit(" in logical_line:
155-
yield(0, "D709: LOG.audit is deprecated, please use LOG.info!")
154+
yield (0, "D709: LOG.audit is deprecated, please use LOG.info!")
156155

157156

158157
@core.flake8ext
@@ -162,7 +161,7 @@ def check_no_log_warn(logical_line):
162161
D710
163162
"""
164163
if logical_line.startswith('LOG.warn('):
165-
yield(0, "D710:Use LOG.warning() rather than LOG.warn()")
164+
yield (0, "D710:Use LOG.warning() rather than LOG.warn()")
166165

167166

168167
@core.flake8ext

designate/storage/sqlalchemy/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def sort_query(query, table, sort_keys, sort_dir=None, sort_dirs=None):
8888
# the actual primary key, rather than assuming its id
8989
LOG.warning('Id not in sort_keys; is sort_keys unique?')
9090

91-
assert(not (sort_dir and sort_dirs))
91+
assert (not (sort_dir and sort_dirs))
9292

9393
# Default the sort direction to ascending
9494
if sort_dirs is None and sort_dir is None:
@@ -98,7 +98,7 @@ def sort_query(query, table, sort_keys, sort_dir=None, sort_dirs=None):
9898
if sort_dirs is None:
9999
sort_dirs = [sort_dir for _sort_key in sort_keys]
100100

101-
assert(len(sort_dirs) == len(sort_keys))
101+
assert (len(sort_dirs) == len(sort_keys))
102102

103103
for current_sort_key, current_sort_dir in zip(sort_keys, sort_dirs):
104104
try:

requirements.txt

-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Requirements lower bounds listed here are our best effort to keep them up to
22
# date but we do not test them so no guarantee of having them all correct. If
33
# you find any incorrect lower bounds, let us know or propose a fix.
4-
5-
# The order of packages is significant, because pip processes them in the order
6-
# of appearance. Changing the order has an impact on the overall integration
7-
# process, which may cause wedges in the gate later.
84
alembic>=1.8.0 # MIT
95
eventlet>=0.26.1 # MIT
106
Flask!=0.11,>=0.10 # BSD

test-requirements.txt

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
# The order of packages is significant, because pip processes them in the order
2-
# of appearance. Changing the order has an impact on the overall integration
3-
# process, which may cause wedges in the gate later.
4-
51
# Hacking already pins down pep8, pyflakes and flake8
6-
hacking>=4.1.0,<4.2.0 # Apache-2.0
2+
hacking>=6.1.0,<6.2.0 # Apache-2.0
73
coverage!=4.4,>=4.0 # Apache-2.0
84
fixtures>=3.0.0 # Apache-2.0/BSD
95
stestr>=2.0.0 # Apache-2.0

tools/pretty_flake8.py

-90
This file was deleted.

tools/pretty_flake8.sh

-6
This file was deleted.

tox.ini

+4-2
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,14 @@ commands = oslo_debug_helper -t designate/tests {posargs}
8282

8383
[testenv:flake8]
8484
deps = -r{toxinidir}/test-requirements.txt
85-
commands = sh tools/pretty_flake8.sh
85+
commands =
86+
flake8
8687
{[testenv:bandit]commands}
8788

8889
[testenv:pep8]
8990
deps = -r{toxinidir}/test-requirements.txt
90-
commands = sh tools/pretty_flake8.sh
91+
commands =
92+
flake8
9193
{[testenv:bandit]commands}
9294
doc8 {posargs}
9395

0 commit comments

Comments
 (0)