Skip to content

Commit

Permalink
Fix up newer pylint and mypy warnings.
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette committed Dec 31, 2023
1 parent bc5187a commit 9ac6571
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions pycdlib/pycdlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -4374,7 +4374,7 @@ def add_fp(self, fp, length, iso_path=None, rr_name=None, joliet_path=None,

def add_file(self, filename, iso_path=None, rr_name=None, joliet_path=None,
file_mode=None, udf_path=None):
# type: (str, Optional[str], Optional[str], str, Optional[int], Optional[str]) -> None
# type: (str, Optional[str], Optional[str], Optional[str], Optional[int], Optional[str]) -> None
"""
Add a file to the ISO. If the ISO is a Rock Ridge one, then a Rock
Ridge name must also be provided. If the ISO is a Joliet one, then a
Expand Down Expand Up @@ -4699,7 +4699,7 @@ def rm_hard_link(self, iso_path=None, joliet_path=None, udf_path=None):

def add_directory(self, iso_path=None, rr_name=None, joliet_path=None,
file_mode=None, udf_path=None):
# type: (Optional[str], Optional[str], Optional[str], int, Optional[str]) -> None
# type: (Optional[str], Optional[str], Optional[str], Optional[int], Optional[str]) -> None
"""
Add a directory to the ISO. At least one of an iso_path, joliet_path,
or udf_path must be provided. Providing joliet_path on a non-Joliet
Expand Down Expand Up @@ -5049,7 +5049,7 @@ def add_eltorito(self, bootfile_path, bootcatfile=None,
boot_load_size=None, platform_id=0, boot_info_table=False,
efi=False, media_name='noemul', bootable=True,
boot_load_seg=0, udf_bootcatfile=None):
# type: (str, Optional[str], Optional[str], Optional[str], int, int, bool, bool, str, bool, int, Optional[str]) -> None
# type: (str, Optional[str], Optional[str], Optional[str], Optional[int], int, bool, bool, str, bool, int, Optional[str]) -> None
"""
Add an El Torito Boot Record, and associated files, to the ISO. The
file that will be used as the bootfile must be passed into this function
Expand Down
9 changes: 5 additions & 4 deletions pycdlib/pycdlibio.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@

# For mypy annotations
if False: # pylint: disable=using-constant-test
import ctypes # NOQA
from mmap import mmap # NOQA
import pickle # NOQA
import collections.abc # NOQA pylint: disable=unused-import
import ctypes # NOQA pylint: disable=unused-import
from mmap import mmap # NOQA pylint: disable=unused-import
import pickle # NOQA pylint: disable=unused-import
from typing import Any, Optional, Union # NOQA pylint: disable=unused-import

have_py_3 = True
Expand Down Expand Up @@ -113,7 +114,7 @@ def readall(self):
return data

def readinto(self, b):
# type: (Union[bytearray, memoryview, array.array[Any], mmap, ctypes._CData, pickle.PickleBuffer]) -> int
# type: (collections.abc.Buffer) -> int
if not self._open:
raise pycdlibexception.PyCdlibInvalidInput('I/O operation on closed file.')

Expand Down
6 changes: 3 additions & 3 deletions pycdlib/rockridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,13 +984,13 @@ def factory(name):
A new Component object representing this name.
"""
if name == b'.':
flags = (1 << 1)
flags = 1 << 1
length = 0
elif name == b'..':
flags = (1 << 2)
flags = 1 << 2
length = 0
elif name == b'/':
flags = (1 << 3)
flags = 1 << 3
length = 0
else:
flags = 0
Expand Down
4 changes: 2 additions & 2 deletions pycdlib/udf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3178,7 +3178,7 @@ def new(self):

self.initialized = True

def set_extent_location(self, new_location, tag_location=None):
def set_extent_location(self, new_location, tag_location=-1):
# type: (int, int) -> None
"""
Set the location of this UDF Terminating Descriptor.
Expand All @@ -3193,7 +3193,7 @@ def set_extent_location(self, new_location, tag_location=None):
raise pycdlibexception.PyCdlibInternalError('UDF Terminating Descriptor not initialized')

self.new_extent_loc = new_location
if tag_location is None:
if tag_location < 0:
tag_location = new_location
self.desc_tag.tag_location = tag_location

Expand Down
2 changes: 1 addition & 1 deletion pylint.conf
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ max-bool-expr=10

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception
overgeneral-exceptions=builtins.Exception

[REFACTORING]

Expand Down

0 comments on commit 9ac6571

Please sign in to comment.