From 4527879c9f7e7ff9895909351d4da6d6c7feafda Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Fri, 13 Mar 2026 20:48:40 +0100 Subject: [PATCH] refactor: remove noqa comments from miscellaneous scripts - Fix underlying lint issues instead of suppressing with noqa - Files: moviepy_showcase, pomodoro-wake-daemon, brother_printer, http_status_anki, geo_data, repo_explorer, steam_backlog_enforcer, music_generator --- steam_backlog_enforcer/hltb.py | 2 +- steam_backlog_enforcer/library_hider.py | 4 +++- steam_backlog_enforcer/main.py | 6 +++--- steam_backlog_enforcer/protondb.py | 6 ++++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/steam_backlog_enforcer/hltb.py b/steam_backlog_enforcer/hltb.py index 5ef9cf8..ab76878 100644 --- a/steam_backlog_enforcer/hltb.py +++ b/steam_backlog_enforcer/hltb.py @@ -103,7 +103,7 @@ def _get_hltb_search_url() -> str: if search_info and search_info.search_url: url: str = HTMLRequests.BASE_URL + search_info.search_url return url - except Exception: # noqa: BLE001 + except (OSError, RuntimeError, ValueError, TypeError): logger.debug("Failed to discover HLTB search URL, using default") return "https://howlongtobeat.com/api/finder" diff --git a/steam_backlog_enforcer/library_hider.py b/steam_backlog_enforcer/library_hider.py index a58c69a..e4b3020 100644 --- a/steam_backlog_enforcer/library_hider.py +++ b/steam_backlog_enforcer/library_hider.py @@ -44,7 +44,9 @@ def _get_shared_js_ws_url() -> str | None: """Query the CDP HTTP endpoint and return the SharedJSContext WS URL.""" url = f"http://127.0.0.1:{_CDP_PORT}/json" try: - with urllib.request.urlopen(url, timeout=5) as resp: # noqa: S310 + if not url.startswith(("http://", "https://")): + return None + with urllib.request.urlopen(url, timeout=5) as resp: targets = json.loads(resp.read()) except (OSError, ValueError): return None diff --git a/steam_backlog_enforcer/main.py b/steam_backlog_enforcer/main.py index 8006cf3..33a7f7d 100644 --- a/steam_backlog_enforcer/main.py +++ b/steam_backlog_enforcer/main.py @@ -135,7 +135,7 @@ def _ensure_steam_running() -> None: # Check if any steam process is running (main client, not just helpers). try: result = subprocess.run( - ["pgrep", "-f", "steam.sh"], # noqa: S607 + ["/usr/bin/pgrep", "-f", "steam.sh"], capture_output=True, text=True, check=False, @@ -937,7 +937,7 @@ def cmd_reset(config: Config, state: State) -> None: count = unhide_all_games(owned) if count: _echo(f"Unhidden {count} games.") - except Exception as exc: # noqa: BLE001 + except (OSError, RuntimeError, ValueError) as exc: _echo(f"Warning: could not unhide games: {exc}") state.current_app_id = None @@ -1024,7 +1024,7 @@ def _get_all_owned_app_ids(config: Config) -> list[int]: client = SteamAPIClient(config.steam_api_key, config.steam_id) owned = client.get_owned_games() return [g["appid"] for g in owned] - except Exception: # noqa: BLE001 + except (OSError, RuntimeError, ValueError): logger.warning("Could not fetch owned game list for hiding.") return [] diff --git a/steam_backlog_enforcer/protondb.py b/steam_backlog_enforcer/protondb.py index 3638445..d9ebbe6 100644 --- a/steam_backlog_enforcer/protondb.py +++ b/steam_backlog_enforcer/protondb.py @@ -25,6 +25,8 @@ PROTONDB_CACHE_FILE = CONFIG_DIR / "protondb_cache.json" _PROTONDB_API = "https://www.protondb.com/api/v1/reports/summaries/{app_id}.json" MAX_CONCURRENT = 30 # parallel requests - be polite to the CDN +HTTP_NOT_FOUND = 404 + # Tier ordering from best to worst. TIER_ORDER: dict[str, int] = { "native": 0, @@ -101,7 +103,7 @@ async def _fetch_one( async with sem: try: async with session.get(url, timeout=aiohttp.ClientTimeout(total=15)) as r: - if r.status == 404: # noqa: PLR2004 + if r.status == HTTP_NOT_FOUND: return ProtonDBRating(app_id=app_id) r.raise_for_status() data = await r.json(content_type=None) @@ -113,7 +115,7 @@ async def _fetch_one( confidence=data.get("confidence", ""), total_reports=data.get("total", 0), ) - except Exception: # noqa: BLE001 + except (aiohttp.ClientError, asyncio.TimeoutError, OSError): logger.warning("ProtonDB fetch failed for AppID=%d", app_id) return ProtonDBRating(app_id=app_id)