From 54aff232c87a70f24a3c0bb4d0ff756e37e71566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Ryder?= Date: Sun, 1 Sep 2024 16:21:27 +0200 Subject: [PATCH] Add ruff linting configuration and fix lint warnings --- cdtb/__main__.py | 1 - cdtb/hashes.py | 2 +- cdtb/rads.py | 4 ++-- cdtb/wad.py | 4 ++-- pyproject.toml | 3 +++ 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cdtb/__main__.py b/cdtb/__main__.py index b55a35e..5fae95e 100644 --- a/cdtb/__main__.py +++ b/cdtb/__main__.py @@ -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 diff --git a/cdtb/hashes.py b/cdtb/hashes.py index 5ad4803..c5c4719 100644 --- a/cdtb/hashes.py +++ b/cdtb/hashes.py @@ -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(): diff --git a/cdtb/rads.py b/cdtb/rads.py index f47ebc8..3cdce6d 100644 --- a/cdtb/rads.py +++ b/cdtb/rads.py @@ -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 @@ -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: diff --git a/cdtb/wad.py b/cdtb/wad.py index 54f4385..b3443f6 100644 --- a/cdtb/wad.py +++ b/cdtb/wad.py @@ -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}") @@ -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 diff --git a/pyproject.toml b/pyproject.toml index eae4f30..5da6928 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,3 +42,6 @@ include = ["/cdtb/*.py"] [tool.hatch.build.targets.wheel] packages = ["cdtb"] + +[tool.ruff.lint] +ignore = ["E741"]