From c436c4bc981bbd696904e8b081020baabe74a939 Mon Sep 17 00:00:00 2001 From: Nikhil Badyal Date: Wed, 25 Jun 2025 09:27:00 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20Lint=20Fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- src/app.py | 8 ++++---- src/downloader/apkpure.py | 6 ++---- src/downloader/download.py | 2 +- src/patches_gen.py | 2 +- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8f80d3d..d8a4951 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.ruff] line-length = 120 -target-version = "py311" +target-version = "py313" fix = true show-fixes = true [tool.ruff.lint] diff --git a/src/app.py b/src/app.py index 293524a..74c3596 100644 --- a/src/app.py +++ b/src/app.py @@ -63,8 +63,8 @@ class APP(object): download_cache: dict[tuple[str, str], tuple[str, str]], ) -> None: """Download apk to be patched, skipping if already downloaded (matching source and version).""" - from src.downloader.download import Downloader - from src.downloader.factory import DownloaderFactory + from src.downloader.download import Downloader # noqa: PLC0415 + from src.downloader.factory import DownloaderFactory # noqa: PLC0415 if self.download_dl: logger.info("Downloading apk to be patched using provided dl") @@ -137,12 +137,12 @@ class APP(object): ------- tuple of strings, which is the tag,file name of the downloaded file. """ - from src.downloader.download import Downloader + from src.downloader.download import Downloader # noqa: PLC0415 url = url.strip() tag = "latest" if url.startswith("https://github"): - from src.downloader.github import Github + from src.downloader.github import Github # noqa: PLC0415 tag, url = Github.patch_resource(url, assets_filter, config) if tag.startswith("tags/"): diff --git a/src/downloader/apkpure.py b/src/downloader/apkpure.py index 8102200..ed66ced 100644 --- a/src/downloader/apkpure.py +++ b/src/downloader/apkpure.py @@ -1,6 +1,8 @@ """APK Pure Downloader Class.""" +from functools import cmp_to_key from typing import Any, Self +from urllib.parse import parse_qs, urlparse import requests from bs4 import BeautifulSoup @@ -35,8 +37,6 @@ class ApkPure(Downloader): def _compare_dls(self: Self, dl1: str, dl2: str) -> int: """Compare two dls of same type (apk or xapk) to prioritise the archs on lower indices.""" - from urllib.parse import parse_qs, urlparse - apk_type1 = parse_qs(urlparse(dl1).query).get("nc") apk_type2 = parse_qs(urlparse(dl2).query).get("nc") if apk_type1 and apk_type2: @@ -67,8 +67,6 @@ class ApkPure(Downloader): :param app: Name of the app :return: Tuple of filename and app direct download link """ - from functools import cmp_to_key - logger.debug(f"Extracting download link from\n{page}") r = requests.get(page, headers=request_header, timeout=request_timeout) handle_request_response(r, page) diff --git a/src/downloader/download.py b/src/downloader/download.py index 3ca52c1..4d12021 100644 --- a/src/downloader/download.py +++ b/src/downloader/download.py @@ -67,7 +67,7 @@ class Downloader(object): """Extract download link from web page.""" raise NotImplementedError(implement_method) - def specific_version(self: Self, app: APP, version: str) -> tuple[str, str]: + def specific_version(self: Self, app: "APP", version: str) -> tuple[str, str]: """Function to download the specified version of app.. :param app: Name of the application diff --git a/src/patches_gen.py b/src/patches_gen.py index aedaec1..d20a07a 100644 --- a/src/patches_gen.py +++ b/src/patches_gen.py @@ -1,5 +1,6 @@ """Generate patches using cli.""" +import json import re import subprocess from pathlib import Path @@ -97,7 +98,6 @@ def convert_command_output_to_json( parsed_data.sort(key=lambda x: x["name"]) with Path("patches.json").open("w") as file: - import json json.dump(parsed_data, file, indent=2)