forked from Mirrors/itch-dl
Fix/disable all linter warnings
This commit is contained in:
@@ -51,9 +51,9 @@ def parse_args() -> argparse.Namespace:
|
|||||||
parser.add_argument("--parallel", metavar="parallel", type=int, default=None,
|
parser.add_argument("--parallel", metavar="parallel", type=int, default=None,
|
||||||
help="how many threads to use for downloading games (default: 1)")
|
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)")
|
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)")
|
help="filter downloaded files by type (see wiki for valid values)")
|
||||||
parser.add_argument("--filter-files-glob", metavar="glob", default=None,
|
parser.add_argument("--filter-files-glob", metavar="glob", default=None,
|
||||||
help="filter downloaded files with a shell-style glob/fnmatch (unmatched files are skipped)")
|
help="filter downloaded files with a shell-style glob/fnmatch (unmatched files are skipped)")
|
||||||
|
|||||||
@@ -52,13 +52,13 @@ def process_platform_traits(platforms: list[str]) -> list[str] | None:
|
|||||||
traits = set()
|
traits = set()
|
||||||
for p in platforms:
|
for p in platforms:
|
||||||
platform_trait = None
|
platform_trait = None
|
||||||
p = p.strip().lower().removeprefix("p_")
|
p = p.strip().lower().removeprefix("p_") # noqa: PLW2901
|
||||||
|
|
||||||
if p.startswith("native"):
|
if p.startswith("native"):
|
||||||
p = platform.system().lower()
|
p = platform.system().lower() # noqa: PLW2901
|
||||||
if p.endswith("bsd"):
|
if p.endswith("bsd"):
|
||||||
logging.warning("Note: Native downloads for *BSDs are not available - Linux binaries will be used.")
|
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():
|
for key, trait in trait_mapping.items():
|
||||||
if p.startswith(key):
|
if p.startswith(key):
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import fnmatch
|
|
||||||
import logging
|
import logging
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|||||||
@@ -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]:
|
def preprocess_job_urls(jobs: list[str], settings: Settings) -> list[str]:
|
||||||
cleaned_jobs = set()
|
cleaned_jobs = set()
|
||||||
for job in jobs:
|
for base_job in jobs:
|
||||||
job = job.strip()
|
job = base_job.strip()
|
||||||
|
|
||||||
if should_skip_item_by_glob("URL", job, settings.filter_urls_glob):
|
if should_skip_item_by_glob("URL", job, settings.filter_urls_glob):
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ def get_int_after_marker_in_json(text: str, marker: str, key: str) -> int | None
|
|||||||
return int(found_ints[0])
|
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):
|
if glob and not fnmatch(item, glob):
|
||||||
logging.info("%s '%s' does not match the glob filter '%s', skipping", kind, item, glob)
|
logging.info("%s '%s' does not match the glob filter '%s', skipping", kind, item, glob)
|
||||||
return True
|
return True
|
||||||
@@ -45,7 +45,7 @@ def should_skip_item_by_glob(kind: Literal['File'] | Literal['URL'], item: str,
|
|||||||
return False
|
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):
|
if regex and not re.fullmatch(regex, item):
|
||||||
logging.info("%s '%s' does not match the regex filter '%s', skipping", kind, item, regex)
|
logging.info("%s '%s' does not match the regex filter '%s', skipping", kind, item, regex)
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -51,4 +51,4 @@ target-version = "py310"
|
|||||||
[tool.ruff.lint]
|
[tool.ruff.lint]
|
||||||
# https://docs.astral.sh/ruff/rules/
|
# 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"]
|
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"]
|
||||||
|
|||||||
Reference in New Issue
Block a user