From 5f5f61bffb1f6d0e9780c6a67d676a01918bebdb Mon Sep 17 00:00:00 2001 From: Ryszard Knop Date: Thu, 3 Apr 2025 19:03:55 +0200 Subject: [PATCH] Fix/disable all linter warnings --- itch_dl/cli.py | 4 ++-- itch_dl/config.py | 6 +++--- itch_dl/downloader.py | 1 - itch_dl/handlers.py | 4 ++-- itch_dl/utils.py | 4 ++-- pyproject.toml | 2 +- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/itch_dl/cli.py b/itch_dl/cli.py index b28ee66..d06bf45 100644 --- a/itch_dl/cli.py +++ b/itch_dl/cli.py @@ -51,9 +51,9 @@ def parse_args() -> argparse.Namespace: parser.add_argument("--parallel", metavar="parallel", type=int, default=None, help="how many threads to use for downloading games (default: 1)") - parser.add_argument("--filter-files-platform", metavar="platforms", action="extend", nargs='+', + parser.add_argument("--filter-files-platform", metavar="platforms", action="extend", nargs="+", help="filter downloaded files by platform (windows, mac, linux, android, native)") - parser.add_argument("--filter-files-type", metavar="types", action="extend", nargs='+', + parser.add_argument("--filter-files-type", metavar="types", action="extend", nargs="+", help="filter downloaded files by type (see wiki for valid values)") parser.add_argument("--filter-files-glob", metavar="glob", default=None, help="filter downloaded files with a shell-style glob/fnmatch (unmatched files are skipped)") diff --git a/itch_dl/config.py b/itch_dl/config.py index 19aee18..6fdffe5 100644 --- a/itch_dl/config.py +++ b/itch_dl/config.py @@ -52,13 +52,13 @@ def process_platform_traits(platforms: list[str]) -> list[str] | None: traits = set() for p in platforms: platform_trait = None - p = p.strip().lower().removeprefix("p_") + p = p.strip().lower().removeprefix("p_") # noqa: PLW2901 if p.startswith("native"): - p = platform.system().lower() + p = platform.system().lower() # noqa: PLW2901 if p.endswith("bsd"): logging.warning("Note: Native downloads for *BSDs are not available - Linux binaries will be used.") - p = "linux" + p = "linux" # noqa: PLW2901 for key, trait in trait_mapping.items(): if p.startswith(key): diff --git a/itch_dl/downloader.py b/itch_dl/downloader.py index 5faa2d5..94e5dc1 100644 --- a/itch_dl/downloader.py +++ b/itch_dl/downloader.py @@ -1,7 +1,6 @@ import os import json import re -import fnmatch import logging import urllib.parse import zipfile diff --git a/itch_dl/handlers.py b/itch_dl/handlers.py index 8267598..a598c16 100644 --- a/itch_dl/handlers.py +++ b/itch_dl/handlers.py @@ -255,8 +255,8 @@ def get_jobs_for_url_or_path(path_or_url: str, settings: Settings) -> list[str]: def preprocess_job_urls(jobs: list[str], settings: Settings) -> list[str]: cleaned_jobs = set() - for job in jobs: - job = job.strip() + for base_job in jobs: + job = base_job.strip() if should_skip_item_by_glob("URL", job, settings.filter_urls_glob): continue diff --git a/itch_dl/utils.py b/itch_dl/utils.py index 145563a..8e41bf6 100644 --- a/itch_dl/utils.py +++ b/itch_dl/utils.py @@ -37,7 +37,7 @@ def get_int_after_marker_in_json(text: str, marker: str, key: str) -> int | None return int(found_ints[0]) -def should_skip_item_by_glob(kind: Literal['File'] | Literal['URL'], item: str, glob: str): +def should_skip_item_by_glob(kind: Literal["File"] | Literal["URL"], item: str, glob: str) -> bool: if glob and not fnmatch(item, glob): logging.info("%s '%s' does not match the glob filter '%s', skipping", kind, item, glob) return True @@ -45,7 +45,7 @@ def should_skip_item_by_glob(kind: Literal['File'] | Literal['URL'], item: str, return False -def should_skip_item_by_regex(kind: Literal['File'] | Literal['URL'], item: str, regex: str): +def should_skip_item_by_regex(kind: Literal["File"] | Literal["URL"], item: str, regex: str) -> bool: if regex and not re.fullmatch(regex, item): logging.info("%s '%s' does not match the regex filter '%s', skipping", kind, item, regex) return True diff --git a/pyproject.toml b/pyproject.toml index deb6320..52a69b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,4 +51,4 @@ target-version = "py310" [tool.ruff.lint] # https://docs.astral.sh/ruff/rules/ select = ["F", "E", "N", "UP", "ANN", "S", "B", "A", "COM", "C4", "T10", "ISC", "LOG", "Q", "SIM", "TC", "ARG", "PGH", "PLE", "PLW", "RUF", "G"] -ignore = ["COM812"] +ignore = ["COM812", "LOG015"]