From 9e7b75bb0f6f6649fb00f2dc97059e90b7d52875 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Sat, 19 Sep 2026 14:39:38 +0200 Subject: style: the 98 ruff could not fix, so the linter is a signal again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pass before this applied ruff's own fixes. These are the ones needing a decision, and the point of doing them is that `ruff check .` now passes: a linter reporting 98 known-acceptable findings reports nothing, because the next real one arrives invisible. **Lines over 100 (70).** Mostly wrapped where they stood. Two exceptions: the aligned trailing comments in `protocol.py`'s message table were shortened rather than wrapped, because wrapping one row of a table breaks the table; and in `models.py` the column comments moved above their columns for the same reason. **Imports below the first statement (14).** `csam.py` kept its FastAPI imports under a section header halfway down the file; two node tests had a constant and a `pytestmark` wedged between two import blocks. Moved, not suppressed. **Bindings nothing reads (4).** Three in tests, where the call stays and only the name goes — `_user(client, "listener")` is there to create the user, not to return one. The fourth was in `revocation.py` and was not a lint finding at all: `_connect_and_listen` opened an httpx stream to the WebSocket URL, did `pass`, and then opened the real connection through the `websockets` library. One pointless request per connect, left over from before that library was used directly. Removed, and `httpx` with it. **`l` as a name (4)**, **semicolons (6)** in the POC spikes, and the rest. 2893 passed, the same count as the two commits before it. `meshbay_node/revocation.py` is worth a decision separately: 154 lines that nothing imports, superseded by `hub_client.maintain_ws`'s `on_revocation`. This commit only stopped it failing the linter. Co-Authored-By: Claude Opus 5 --- packages/meshbay-node/src/meshbay_node/daemon.py | 3 ++- .../src/meshbay_node/indexer/title_parse.py | 3 ++- .../meshbay-node/src/meshbay_node/revocation.py | 11 +++-------- .../meshbay-node/src/meshbay_node/transfers.py | 2 +- .../src/meshbay_node/transport/webrtc_server.py | 22 +++++++++++++++------- 5 files changed, 23 insertions(+), 18 deletions(-) (limited to 'packages/meshbay-node/src/meshbay_node') diff --git a/packages/meshbay-node/src/meshbay_node/daemon.py b/packages/meshbay-node/src/meshbay_node/daemon.py index a0ce211..bb50bcf 100644 --- a/packages/meshbay-node/src/meshbay_node/daemon.py +++ b/packages/meshbay-node/src/meshbay_node/daemon.py @@ -2243,7 +2243,8 @@ def main() -> None: _GUIDANCE = { "node_key_link": ( "Link node key", - f"Copy the node key above and paste it in Settings → Link Node on {cfg.hub.url}"), + f"Copy the node key above and paste it in " + f"Settings → Link Node on {cfg.hub.url}"), "group_add": ( "Add a group", "meshbay-node group add --dir /path/to/files"), diff --git a/packages/meshbay-node/src/meshbay_node/indexer/title_parse.py b/packages/meshbay-node/src/meshbay_node/indexer/title_parse.py index 5df70c4..91bf2bd 100644 --- a/packages/meshbay-node/src/meshbay_node/indexer/title_parse.py +++ b/packages/meshbay-node/src/meshbay_node/indexer/title_parse.py @@ -218,7 +218,8 @@ class ParsedName: year: int | None = None season: int | None = None episode: int | None = None - confidence: bool = False # True only when display_title is set and structurally corroborated + # True only when display_title is set and structurally corroborated + confidence: bool = False def parse_movie_filename(filename: str) -> ParsedName: diff --git a/packages/meshbay-node/src/meshbay_node/revocation.py b/packages/meshbay-node/src/meshbay_node/revocation.py index 1e8caee..dede5d0 100644 --- a/packages/meshbay-node/src/meshbay_node/revocation.py +++ b/packages/meshbay-node/src/meshbay_node/revocation.py @@ -19,7 +19,6 @@ import json import logging from typing import Literal -import httpx import jwt log = logging.getLogger(__name__) @@ -108,13 +107,9 @@ class RevocationSubscriber: ws_url = self._hub_url.replace("http://", "ws://").replace("https://", "wss://") ws_url += "/v1/nodes/ws" - async with httpx.AsyncClient() as client: - async with client.stream("GET", ws_url, - headers={"Upgrade": "websocket"}) as resp: - # Use websockets library for proper WS protocol - pass - - # Use websockets library directly + # An httpx stream was opened to this URL here and immediately dropped — + # one pointless request per connect, left over from before the websockets + # library was used directly. import websockets async with websockets.connect(ws_url) as ws: # Authenticate diff --git a/packages/meshbay-node/src/meshbay_node/transfers.py b/packages/meshbay-node/src/meshbay_node/transfers.py index 86c8d14..3345cb9 100644 --- a/packages/meshbay-node/src/meshbay_node/transfers.py +++ b/packages/meshbay-node/src/meshbay_node/transfers.py @@ -393,7 +393,7 @@ class TransferSlots: # the one place it would be tempting to add one for a prettier # log line. for x in sorted(self.leases.values(), - key=lambda l: (l.kind, l.state, l.created_at)) + key=lambda ls: (ls.kind, ls.state, ls.created_at)) ], } diff --git a/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py b/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py index 2bd1419..e92ec13 100644 --- a/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py +++ b/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py @@ -3930,7 +3930,8 @@ class WebRTCPeerSession: if not entry: thumb = await self._try_serve_thumbnail(file_id, chunk_index, ctx.get("gek")) if thumb is not None: - log.debug("file_req file_id=%s chunk=%s: served as thumbnail", file_id[:16], chunk_index) + log.debug("file_req file_id=%s chunk=%s: served as thumbnail", + file_id[:16], chunk_index) self._send(thumb) return log.warning("File not found: %s", file_id[:16]) @@ -3998,7 +3999,8 @@ class WebRTCPeerSession: self._leaseless.finish(str(file_id)) @staticmethod - async def _fetch_and_cache_poster(media_cache, tmdb_client, poster_path: str | None) -> str | None: + async def _fetch_and_cache_poster(media_cache, tmdb_client, + poster_path: str | None) -> str | None: """ Downloads a TMDB poster/backdrop once, caches it under its own blake3 like a video thumbnail (docs/MESHBAY_DESIGN.md §9.7), and @@ -4026,7 +4028,8 @@ class WebRTCPeerSession: return thumb_hash @staticmethod - async def _fetch_and_cache_cover(media_cache, musicbrainz_client, mbid: str | None) -> str | None: + async def _fetch_and_cache_cover(media_cache, musicbrainz_client, + mbid: str | None) -> str | None: """ Music app equivalent of `_fetch_and_cache_poster` — a release's Cover Art Archive image, fetched once per mbid and cached under its @@ -4510,7 +4513,9 @@ class WebRTCPeerSession: # itself. if not fetched.get("overview"): fallback = await tmdb_client.tv_season(tmdb_id, season, language="en-US") or {} - fetched = {**fallback, **{k: v for k, v in fetched.items() if v not in (None, "", [])}} + fetched = {**fallback, + **{k: v for k, v in fetched.items() + if v not in (None, "", [])}} await media_cache.set_season_meta(tmdb_id, season, fetched) details = fetched @@ -4839,8 +4844,10 @@ class WebRTCPeerSession: # back to English per field rather than discarding an otherwise-good # localized response over one empty one — mirrored here the same # way, at field granularity, not by abandoning the whole response. - if not details.get("overview") or not details.get("poster_path") or not details.get("genres"): - fallback = (await tmdb_client.tv_details(tmdb_id, language="en-US") if media_type == "tv" + if (not details.get("overview") or not details.get("poster_path") + or not details.get("genres")): + fallback = (await tmdb_client.tv_details(tmdb_id, language="en-US") + if media_type == "tv" else await tmdb_client.movie_details(tmdb_id, language="en-US")) or {} details = {**fallback, **{k: v for k, v in details.items() if v not in (None, "", [])}} credits = (await tmdb_client.tv_credits(tmdb_id) if media_type == "tv" @@ -5915,7 +5922,8 @@ class WebRTCPeerSession: transcript = admin_transcript( op=pending["op"], node_pk_b64=self._node_pk_b64(), - group_id=pending["group_id"] if pending.get("group_id") is not None else (self._group_id or ""), + group_id=(pending["group_id"] if pending.get("group_id") is not None + else (self._group_id or "")), subject=pending["subject"], nonce=pending["nonce"], ts=pending["ts"], -- cgit v1.2.3