forked from Mirrors/itch-dl
Add Ruff linting configs, fix reported warnings
This commit is contained in:
6
.idea/ruff.xml
generated
Normal file
6
.idea/ruff.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RuffConfigService">
|
||||||
|
<option name="globalRuffLspExecutablePath" value="/usr/bin/ruff" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -203,7 +203,7 @@ class GameDownloader:
|
|||||||
|
|
||||||
return r.url
|
return r.url
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
raise ItchDownloadError(f"Unrecoverable download error: {e}")
|
raise ItchDownloadError(f"Unrecoverable download error: {e}") from e
|
||||||
|
|
||||||
def download_file_by_upload_id(self, upload_id: int, download_path: Optional[str], credentials: dict) -> str:
|
def download_file_by_upload_id(self, upload_id: int, download_path: Optional[str], credentials: dict) -> str:
|
||||||
"""Performs a request to download a given upload by its ID."""
|
"""Performs a request to download a given upload by its ID."""
|
||||||
@@ -225,7 +225,7 @@ class GameDownloader:
|
|||||||
# As metadata is the final file we write, all the files
|
# As metadata is the final file we write, all the files
|
||||||
# should already be downloaded at this point.
|
# should already be downloaded at this point.
|
||||||
logging.info("Skipping already-downloaded game for URL: %s", url)
|
logging.info("Skipping already-downloaded game for URL: %s", url)
|
||||||
return DownloadResult(url, True, [f"Game already downloaded."], [])
|
return DownloadResult(url, True, ["Game already downloaded."], [])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logging.info("Downloading %s", url)
|
logging.info("Downloading %s", url)
|
||||||
@@ -258,7 +258,7 @@ class GameDownloader:
|
|||||||
try:
|
try:
|
||||||
os.makedirs(paths['files'], exist_ok=True)
|
os.makedirs(paths['files'], exist_ok=True)
|
||||||
for upload in game_uploads:
|
for upload in game_uploads:
|
||||||
if any([key not in upload for key in ('id', 'filename', 'storage')]):
|
if any(key not in upload for key in ('id', 'filename', 'storage')):
|
||||||
errors.append(f"Upload metadata incomplete: {upload}")
|
errors.append(f"Upload metadata incomplete: {upload}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ def get_jobs_for_browse_url(url: str, client: ItchApiClient) -> List[str]:
|
|||||||
"""
|
"""
|
||||||
page = 1
|
page = 1
|
||||||
found_urls: Set[str] = set()
|
found_urls: Set[str] = set()
|
||||||
logging.info(f"Scraping game URLs from RSS feeds for %s", url)
|
logging.info("Scraping game URLs from RSS feeds for %s", url)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
logging.info(f"Downloading page {page} (found {len(found_urls)} URLs total)")
|
logging.info(f"Downloading page {page} (found {len(found_urls)} URLs total)")
|
||||||
@@ -214,7 +214,7 @@ def get_jobs_for_path(path: str) -> List[str]:
|
|||||||
logging.info("Parsing provided file as a list of URLs to fetch...")
|
logging.info("Parsing provided file as a list of URLs to fetch...")
|
||||||
return url_list
|
return url_list
|
||||||
|
|
||||||
raise ValueError(f"File format is unknown - cannot read URLs to download.")
|
raise ValueError("File format is unknown - cannot read URLs to download.")
|
||||||
|
|
||||||
|
|
||||||
def get_jobs_for_url_or_path(path_or_url: str, settings: Settings) -> List[str]:
|
def get_jobs_for_url_or_path(path_or_url: str, settings: Settings) -> List[str]:
|
||||||
|
|||||||
@@ -37,3 +37,10 @@ itch-dl = "itch_dl.cli:run"
|
|||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core>=1.0.0"]
|
requires = ["poetry-core>=1.0.0"]
|
||||||
build-backend = "poetry.core.masonry.api"
|
build-backend = "poetry.core.masonry.api"
|
||||||
|
|
||||||
|
[tool.ruff]
|
||||||
|
line-length = 120
|
||||||
|
target-version = "py38"
|
||||||
|
|
||||||
|
[tool.ruff.lint]
|
||||||
|
select = ["E4", "E7", "E9", "F", "B", "C4", "T10", "N", "UP", "S"]
|
||||||
|
|||||||
Reference in New Issue
Block a user