Skip to content

Commit 9db0862

Browse files
committed
Add flake8 checks
1 parent e929b6b commit 9db0862

5 files changed

Lines changed: 16 additions & 12 deletions

File tree

cdblib/cdblib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def putstring(self, key, value, encoding='utf-8'):
215215
def putstrings(self, key, values, encoding='utf-8'):
216216
'''Write zero or more unicode strings to the output file. Equivalent to
217217
calling putstring() in a loop.'''
218-
self.puts(key, (six.text_type.encode(value, encoding) for value in values))
218+
self.puts(key, (six.text_type.encode(v, encoding) for v in values))
219219

220220
def finalize(self):
221221
'''Write the final hash tables to the output file, and write out its
@@ -238,7 +238,7 @@ def finalize(self):
238238
self.fp.seek(0)
239239
for pair in index:
240240
self.fp.write(self.write_pair(*pair))
241-
self.fp = None # prevent double finalize()
241+
self.fp = None # prevent double finalize()
242242

243243

244244
class Writer64(Writer):

cdblib/cdbmake.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(self, stdin, stdout, stderr):
3535
def parse_args(self, args):
3636
try:
3737
opts, args = getopt.gnu_getopt(args, 'p8')
38-
except getopt.error as e:
38+
except getopt.error as e:
3939
self.usage(str(e))
4040

4141
for opt, arg in opts:
@@ -67,11 +67,10 @@ def parse_input(self):
6767
elif plus != '+':
6868
self.die('bad or missing plus, line/record #%d', rec_nr)
6969

70-
bad = False
7170
try:
7271
klen = int(''.join(iter(partial(read, 1), ',')), 10)
7372
dlen = int(''.join(iter(partial(read, 1), ':')), 10)
74-
except ValueError as e:
73+
except ValueError:
7574
self.die('bad or missing length, line/record #%d', rec_nr)
7675

7776
key = read(klen)
@@ -118,4 +117,4 @@ def main(args=None, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr):
118117

119118

120119
if __name__ == '__main__':
121-
main(sys.argv[1:])
120+
main(sys.argv[1:])

cdblib/djb_hash.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@
77
# iterating over byte strings differently.
88
if six.PY2:
99
def djb_hash(s):
10-
'''Return the value of DJB's hash function for the given byte string.'''
10+
'''Return the value of DJB's hash function for byte string *s*'''
1111
h = 5381
1212
for c in s:
1313
h = (((h << 5) + h) ^ ord(c)) & 0xffffffff
1414
return h
1515
else:
16-
def djb_hash(s):
17-
'''Return the value of DJB's hash function for the given byte string.'''
16+
def djb_hash(s): # noqa
17+
'''Return the value of DJB's hash function for byte string *s*'''
1818
h = 5381
1919
for c in s:
2020
h = (((h << 5) + h) ^ c) & 0xffffffff
2121
return h
2222

2323
# If the C Extensions is available (Python 2 only), use it
2424
try:
25-
from ._djb_hash import djb_hash
25+
from ._djb_hash import djb_hash # noqa
2626
except ImportError:
2727
pass

setup.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
filename =
3+
./cdblib/*.py
4+
./setup.py

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@
2121
keywords='cdb file format appengine database db',
2222
license='MIT',
2323
name='pure-cdb',
24+
version='2.1.0',
2425
packages=find_packages(include=['cdblib']),
2526
ext_modules=ext_modules,
2627
install_requires=['six>=1.0.0,<2.0.0'],
2728
test_suite='tests',
28-
version='2.1.0',
29-
entry_points = {
29+
tests_require=['flake8']
30+
entry_points={
3031
'console_scripts': ['python-pure-cdbmake=cdblib.cdbmake:main'],
3132
}
3233
)

0 commit comments

Comments
 (0)