mirror of
https://github.com/kuhyx/steam-backlog-enforcer.git
synced 2026-07-04 13:43:45 +02:00
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:
parent
ccc1900adf
commit
4527879c9f
@ -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"
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 []
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user