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
This commit is contained in:
Krzysztof kuhy Rudnicki 2026-03-13 20:48:40 +01:00
parent ccc1900adf
commit 4527879c9f
4 changed files with 11 additions and 7 deletions

View File

@ -103,7 +103,7 @@ def _get_hltb_search_url() -> str:
if search_info and search_info.search_url: if search_info and search_info.search_url:
url: str = HTMLRequests.BASE_URL + search_info.search_url url: str = HTMLRequests.BASE_URL + search_info.search_url
return url return url
except Exception: # noqa: BLE001 except (OSError, RuntimeError, ValueError, TypeError):
logger.debug("Failed to discover HLTB search URL, using default") logger.debug("Failed to discover HLTB search URL, using default")
return "https://howlongtobeat.com/api/finder" return "https://howlongtobeat.com/api/finder"

View File

@ -44,7 +44,9 @@ def _get_shared_js_ws_url() -> str | None:
"""Query the CDP HTTP endpoint and return the SharedJSContext WS URL.""" """Query the CDP HTTP endpoint and return the SharedJSContext WS URL."""
url = f"http://127.0.0.1:{_CDP_PORT}/json" url = f"http://127.0.0.1:{_CDP_PORT}/json"
try: 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()) targets = json.loads(resp.read())
except (OSError, ValueError): except (OSError, ValueError):
return None return None

View File

@ -135,7 +135,7 @@ def _ensure_steam_running() -> None:
# Check if any steam process is running (main client, not just helpers). # Check if any steam process is running (main client, not just helpers).
try: try:
result = subprocess.run( result = subprocess.run(
["pgrep", "-f", "steam.sh"], # noqa: S607 ["/usr/bin/pgrep", "-f", "steam.sh"],
capture_output=True, capture_output=True,
text=True, text=True,
check=False, check=False,
@ -937,7 +937,7 @@ def cmd_reset(config: Config, state: State) -> None:
count = unhide_all_games(owned) count = unhide_all_games(owned)
if count: if count:
_echo(f"Unhidden {count} games.") _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}") _echo(f"Warning: could not unhide games: {exc}")
state.current_app_id = None 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) client = SteamAPIClient(config.steam_api_key, config.steam_id)
owned = client.get_owned_games() owned = client.get_owned_games()
return [g["appid"] for g in owned] 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.") logger.warning("Could not fetch owned game list for hiding.")
return [] return []

View File

@ -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" _PROTONDB_API = "https://www.protondb.com/api/v1/reports/summaries/{app_id}.json"
MAX_CONCURRENT = 30 # parallel requests - be polite to the CDN MAX_CONCURRENT = 30 # parallel requests - be polite to the CDN
HTTP_NOT_FOUND = 404
# Tier ordering from best to worst. # Tier ordering from best to worst.
TIER_ORDER: dict[str, int] = { TIER_ORDER: dict[str, int] = {
"native": 0, "native": 0,
@ -101,7 +103,7 @@ async def _fetch_one(
async with sem: async with sem:
try: try:
async with session.get(url, timeout=aiohttp.ClientTimeout(total=15)) as r: 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) return ProtonDBRating(app_id=app_id)
r.raise_for_status() r.raise_for_status()
data = await r.json(content_type=None) data = await r.json(content_type=None)
@ -113,7 +115,7 @@ async def _fetch_one(
confidence=data.get("confidence", ""), confidence=data.get("confidence", ""),
total_reports=data.get("total", 0), 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) logger.warning("ProtonDB fetch failed for AppID=%d", app_id)
return ProtonDBRating(app_id=app_id) return ProtonDBRating(app_id=app_id)