Skip to content

Commit

Permalink
Add ruff linting configuration and fix lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitryder committed Feb 1, 2025
1 parent 2b59c09 commit 54aff23
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
1 change: 0 additions & 1 deletion cdtb/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
parse_storage_component,
storage_conf_from_path,
)
from cdtb.patcher import PatcherStorage
from cdtb.wad import Wad
from cdtb.export import CdragonRawPatchExporter
from cdtb.binfile import BinFile
Expand Down
2 changes: 1 addition & 1 deletion cdtb/hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def progress_iterate(sequence, formatter=None):
"""Iterate over sequence, display progress on SIGINT"""

if formatter is None:
formatter = lambda v: v
formatter = lambda v: v # noqa

interrupted = False
def handler():
Expand Down
4 changes: 2 additions & 2 deletions cdtb/rads.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ class RadsProjectVersion:
The data in these ProjectVersions are contained in Bin files, which are extracted.
"""

def __init__(self, project: RadsProject, version: 'Version'):
def __init__(self, project: RadsProject, version: RadsVersion):
self.path = f"{project.path}/{version}"
self.project = project
self.version = version
Expand Down Expand Up @@ -629,7 +629,7 @@ def parse_rads_component(storage: RadsStorage, component: str):
return RadsSolutionVersion(solution, RadsVersion(version))
elif typ == 'patch':
if version is None:
raise ValueError(f"patch requires a version")
raise ValueError("patch requires a version")
elif version == '':
return storage.patch(None)
else:
Expand Down
4 changes: 2 additions & 2 deletions cdtb/wad.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def read_data(self, f, subchunk_toc=None):
# No subchunk TOC, try to decompress
try:
return zstd_decompress(data)
except:
except Exception:
raise MalformedSubchunkError(data)
raise ValueError(f"unsupported file type: {self.type}")

Expand Down Expand Up @@ -331,5 +331,5 @@ def read_file_data(self, fwad, wadfile):
try:
return wadfile.read_data(fwad, self.subchunk_toc)
except MalformedSubchunkError:
logger.warning(f"failed to read subchunked wad entry " + (wadfile.path if wadfile.path is not None else f"{wadfile.path_hash:016x}"))
logger.warning("failed to read subchunked wad entry " + (wadfile.path if wadfile.path is not None else f"{wadfile.path_hash:016x}"))
return None
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ include = ["/cdtb/*.py"]

[tool.hatch.build.targets.wheel]
packages = ["cdtb"]

[tool.ruff.lint]
ignore = ["E741"]

0 comments on commit 54aff23

Please sign in to comment.