Skip to content

Commit 6e0c86a

Browse files
authored
Fixed pylint warnings (#56)
1 parent d046c2d commit 6e0c86a

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

kaitaistruct.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# runtime is compatible with the generated code.
2121
API_VERSION = (0, 10)
2222

23+
# pylint:disable=bad-indentation,too-many-public-methods,useless-object-inheritance,super-with-arguments
2324

2425
class KaitaiStruct(object):
2526
def __init__(self, stream):
@@ -79,9 +80,9 @@ def is_eof(self):
7980
t = io.read(1)
8081
if t == b'':
8182
return True
82-
else:
83-
io.seek(-1, SEEK_CUR)
84-
return False
83+
84+
io.seek(-1, SEEK_CUR)
85+
return False
8586

8687
def seek(self, n):
8788
self._io.seek(n)
@@ -334,16 +335,17 @@ def read_bytes_term(self, term, include_term, consume_term, eos_error):
334335
"end of stream reached, but no terminator %d found" %
335336
(term,)
336337
)
337-
else:
338-
return r
339-
elif ord(c) == term:
338+
339+
return r
340+
341+
if ord(c) == term:
340342
if include_term:
341343
r += c
342344
if not consume_term:
343345
self._io.seek(-1, SEEK_CUR)
344346
return r
345-
else:
346-
r += c
347+
348+
r += c
347349

348350
def ensure_fixed_contents(self, expected):
349351
actual = self._io.read(len(expected))
@@ -373,15 +375,15 @@ def bytes_terminate(data, term, include_term):
373375
def process_xor_one(data, key):
374376
if PY2:
375377
return bytes(bytearray(v ^ key for v in bytearray(data)))
376-
else:
377-
return bytes(v ^ key for v in data)
378+
379+
return bytes(v ^ key for v in data)
378380

379381
@staticmethod
380382
def process_xor_many(data, key):
381383
if PY2:
382384
return bytes(bytearray(a ^ b for a, b in zip(bytearray(data), itertools.cycle(bytearray(key)))))
383-
else:
384-
return bytes(a ^ b for a, b in zip(data, itertools.cycle(key)))
385+
386+
return bytes(a ^ b for a, b in zip(data, itertools.cycle(key)))
385387

386388
@staticmethod
387389
def process_rotate_left(data, amount, group_size):
@@ -395,7 +397,7 @@ def process_rotate_left(data, amount, group_size):
395397
anti_amount = -amount & mask
396398

397399
r = bytearray(data)
398-
for i in range(len(r)):
400+
for i in range(len(r)): # pylint:disable=consider-using-enumerate
399401
r[i] = (r[i] << amount) & 0xff | (r[i] >> anti_amount)
400402
return bytes(r)
401403

@@ -477,19 +479,19 @@ class ValidationLessThanError(ValidationFailedError):
477479
"""Signals validation failure: we required "actual" value to be
478480
greater than or equal to "min", but it turned out that it's not.
479481
"""
480-
def __init__(self, min, actual, io, src_path):
481-
super(ValidationLessThanError, self).__init__("not in range, min %s, but got %s" % (repr(min), repr(actual)), io, src_path)
482-
self.min = min
482+
def __init__(self, min_bound, actual, io, src_path):
483+
super(ValidationLessThanError, self).__init__("not in range, min %s, but got %s" % (repr(min_bound), repr(actual)), io, src_path)
484+
self.min = min_bound
483485
self.actual = actual
484486

485487

486488
class ValidationGreaterThanError(ValidationFailedError):
487489
"""Signals validation failure: we required "actual" value to be
488490
less than or equal to "max", but it turned out that it's not.
489491
"""
490-
def __init__(self, max, actual, io, src_path):
491-
super(ValidationGreaterThanError, self).__init__("not in range, max %s, but got %s" % (repr(max), repr(actual)), io, src_path)
492-
self.max = max
492+
def __init__(self, max_bound, actual, io, src_path):
493+
super(ValidationGreaterThanError, self).__init__("not in range, max %s, but got %s" % (repr(max_bound), repr(actual)), io, src_path)
494+
self.max = max_bound
493495
self.actual = actual
494496

495497

0 commit comments

Comments
 (0)