Skip to content

Commit 8c271ac

Browse files
committed
Small fixes for modern mypy and pylint.
Signed-off-by: Chris Lalancette <clalancette@gmail.com>
1 parent 97a540b commit 8c271ac

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

pycdlib/eltorito.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,10 @@ def _checksum(data):
163163
Returns:
164164
The checksum of the data.
165165
"""
166-
def identity(x):
167-
# type: (int) -> int
168-
"""
169-
The identity function so we can use a function for python2/3
170-
compatibility.
171-
"""
172-
return x
173-
174-
if isinstance(data, str):
166+
if isinstance(data, bytes):
167+
myord = int
168+
else:
175169
myord = ord
176-
elif isinstance(data, bytes):
177-
myord = identity
178170
csum = 0
179171
for i, val in enumerate(data):
180172
short = (myord(val) << (8 * (i % 2))) & 0xffff

pycdlib/isohybrid.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,8 @@ def parse(self, instr):
700700
if unused2 != 0:
701701
raise pycdlibexception.PyCdlibInvalidISO('Invalid IsoHybrid unused2')
702702

703+
psize = 0
704+
ecyle = 0
703705
offset = 32 + struct.calcsize(self.FMT)
704706
for i in range(1, 5):
705707
if bytes(bytearray([instr[offset]])) == b'\x80':

pycdlib/pycdlib.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3107,6 +3107,9 @@ def _add_hard_link_to_inode(self, data_ino, length, file_mode,
31073107
# we know for certain that this is Joliet.
31083108
if self.joliet_vd is None:
31093109
raise pycdlibexception.PyCdlibInternalError('Tried to link to Joliet record on non-Joliet ISO')
3110+
if joliet_new_path is None:
3111+
# This can really never happen, but here to make mypy happy
3112+
raise pycdlibexception.PyCdlibInternalError('Invalid joliet_new_path')
31103113
# ... to a file on the Joliet filesystem.
31113114
(new_name, new_parent) = self._joliet_name_and_parent_from_path(joliet_new_path)
31123115
vd = self.joliet_vd
@@ -4504,6 +4507,9 @@ def modify_file_in_place(self, fp, length, iso_path, rr_name=None, # pylint: di
45044507
abs_offset = abs_extent_loc * self.logical_block_size + offset
45054508
elif isinstance(record, udfmod.UDFFileEntry):
45064509
abs_offset = record.extent_location() * self.logical_block_size
4510+
else:
4511+
# This should never happen
4512+
raise pycdlibexception.PyCdlibInternalError('Invalid record type')
45074513

45084514
record.set_data_length(length)
45094515
self._cdfp.seek(abs_offset)
@@ -5743,6 +5749,8 @@ def set_hidden(self, iso_path=None, rr_path=None, joliet_path=None):
57435749
elif joliet_path is not None:
57445750
joliet_path_bytes = self._normalize_joliet_path(joliet_path)
57455751
rec = self._find_joliet_record(joliet_path_bytes)
5752+
else:
5753+
raise pycdlibexception.PyCdlibInvalidInput('Must provide exactly one of iso_path, rr_path, or joliet_path')
57465754

57475755
rec.change_existence(True)
57485756

@@ -5773,6 +5781,8 @@ def clear_hidden(self, iso_path=None, rr_path=None, joliet_path=None):
57735781
elif joliet_path is not None:
57745782
joliet_path_bytes = self._normalize_joliet_path(joliet_path)
57755783
rec = self._find_joliet_record(joliet_path_bytes)
5784+
else:
5785+
raise pycdlibexception.PyCdlibInvalidInput('Must provide exactly one of iso_path, rr_path, or joliet_path')
57765786

57775787
rec.change_existence(False)
57785788

0 commit comments

Comments
 (0)