personal memory agent
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: reformat link modules to satisfy ruff format-check

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

+50 -20
+9 -3
apps/link/call.py
··· 79 79 80 80 @app.command() 81 81 def pair( 82 - device_label: str = typer.Option(..., "--device-label", help="Label for the phone being paired"), 82 + device_label: str = typer.Option( 83 + ..., "--device-label", help="Label for the phone being paired" 84 + ), 83 85 convey_host: str = typer.Option( 84 86 "", 85 87 "--convey-host", ··· 133 135 # the pair route fired but we missed the device (rare). 134 136 nonce_entry = _nonces().peek(value) 135 137 if nonce_entry and nonce_entry.used: 136 - typer.echo("Pair request completed; device should appear in `sol call link list`.") 138 + typer.echo( 139 + "Pair request completed; device should appear in `sol call link list`." 140 + ) 137 141 raise typer.Exit(0) 138 142 typer.echo("Timed out. Pair code expired.") 139 143 raise typer.Exit(2) ··· 158 162 159 163 @app.command() 160 164 def unpair( 161 - target: str = typer.Argument(..., help="Device label or fingerprint (sha256:<hex>)"), 165 + target: str = typer.Argument( 166 + ..., help="Device label or fingerprint (sha256:<hex>)" 167 + ), 162 168 ) -> None: 163 169 """Revoke a paired device. Next reconnect from that device fails at TLS handshake.""" 164 170 authorized = _authorized()
+6 -1
apps/link/routes.py
··· 34 34 from flask import Blueprint, jsonify, request 35 35 36 36 from think.link.auth import AuthorizedClients, ClientEntry 37 - from think.link.ca import generate_nonce, load_or_generate_ca, mint_attestation, sign_csr 37 + from think.link.ca import ( 38 + generate_nonce, 39 + load_or_generate_ca, 40 + mint_attestation, 41 + sign_csr, 42 + ) 38 43 from think.link.nonces import NonceStore 39 44 from think.link.paths import ( 40 45 LinkState,
+3 -1
think/link/auth.py
··· 111 111 self._entries = current 112 112 return True 113 113 114 - def touch_last_seen(self, fingerprint: str, *, now: dt.datetime | None = None) -> bool: 114 + def touch_last_seen( 115 + self, fingerprint: str, *, now: dt.datetime | None = None 116 + ) -> bool: 115 117 """Update last_seen_at for a paired device. Returns False if not paired.""" 116 118 ts = (now or dt.datetime.now(dt.UTC)).strftime("%Y-%m-%dT%H:%M:%SZ") 117 119 with self._lock:
+3 -1
think/link/ca.py
··· 136 136 now = dt.datetime.now(dt.UTC) 137 137 cert = ( 138 138 x509.CertificateBuilder() 139 - .subject_name(x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, device_label)])) 139 + .subject_name( 140 + x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, device_label)]) 141 + ) 140 142 .issuer_name(ca.cert.subject) 141 143 .public_key(pub) 142 144 .serial_number(x509.random_serial_number())
+3 -1
think/link/framing.py
··· 145 145 def build_window(stream_id: int, credit: int) -> Frame: 146 146 if not 0 <= credit <= 0xFFFFFFFF: 147 147 raise ProtocolError(f"window credit out of range: {credit}") 148 - return Frame(stream_id=stream_id, flags=FLAG_WINDOW, payload=credit.to_bytes(4, "big")) 148 + return Frame( 149 + stream_id=stream_id, flags=FLAG_WINDOW, payload=credit.to_bytes(4, "big") 150 + ) 149 151 150 152 151 153 def validate_flags(flags: int) -> None:
+3 -1
think/link/mux.py
··· 157 157 await self._emit(build_reset(frame.stream_id, RESET_PROTOCOL_ERROR)) 158 158 return 159 159 if len(self._streams) >= MAX_CONCURRENT_STREAMS: 160 - await self._emit(build_reset(frame.stream_id, RESET_STREAM_LIMIT_EXCEEDED)) 160 + await self._emit( 161 + build_reset(frame.stream_id, RESET_STREAM_LIMIT_EXCEEDED) 162 + ) 161 163 return 162 164 state = self._open_stream(frame.stream_id) 163 165 if frame.payload:
+10 -7
think/link/relay_client.py
··· 156 156 task.cancel() 157 157 if self._tunnels: 158 158 await asyncio.gather( 159 - *( 160 - asyncio.shield(t) 161 - for t in self._tunnels.values() 162 - ), 159 + *(asyncio.shield(t) for t in self._tunnels.values()), 163 160 return_exceptions=True, 164 161 ) 165 162 self._tunnels.clear() ··· 193 190 name=f"link-tunnel-{tunnel_id}", 194 191 ) 195 192 self._tunnels[tunnel_id] = task 196 - task.add_done_callback(lambda _t, tid=tunnel_id: self._tunnels.pop(tid, None)) 193 + task.add_done_callback( 194 + lambda _t, tid=tunnel_id: self._tunnels.pop(tid, None) 195 + ) 197 196 198 197 async def _handle_tunnel(self, tunnel_id: str) -> None: 199 198 assert self._account_token is not None ··· 207 206 ) as ws: 208 207 await self._pump_tunnel(ws, tunnel_id) 209 208 except ConnectionClosed as exc: 210 - log.info("tunnel %s closed: code=%s reason=%s", tunnel_id, exc.code, exc.reason) 209 + log.info( 210 + "tunnel %s closed: code=%s reason=%s", tunnel_id, exc.code, exc.reason 211 + ) 211 212 except TlsError as exc: 212 213 log.info("tunnel %s TLS rejected: %s", tunnel_id, exc) 213 214 except Exception as exc: # noqa: BLE001 ··· 251 252 nonlocal fingerprint_touched 252 253 try: 253 254 async for frame in ws: 254 - inbound = frame if isinstance(frame, bytes) else frame.encode("utf-8") 255 + inbound = ( 256 + frame if isinstance(frame, bytes) else frame.encode("utf-8") 257 + ) 255 258 outbound, plaintext = drive_tls(tls, inbound=inbound) 256 259 if outbound: 257 260 await ws.send(outbound)
+13 -5
think/link/wsgi_bridge.py
··· 92 92 ) -> Callable[[bytes], None]: 93 93 response_state.status_line = status 94 94 response_state.headers = list(headers) 95 + 95 96 # WSGI returns a write() callable, but we use the iterable instead. 96 97 def write(_data: bytes) -> None: 97 98 raise RuntimeError("write() callable not supported; return iterable") ··· 105 106 None, lambda: wsgi_app(environ, start_response) 106 107 ) 107 108 except Exception: 108 - log.exception( 109 - "tunnel %s stream %s: wsgi app raised", tunnel_id, stream_id 109 + log.exception("tunnel %s stream %s: wsgi app raised", tunnel_id, stream_id) 110 + await _write_simple( 111 + writer, 500, "internal server error", b"internal server error\n" 110 112 ) 111 - await _write_simple(writer, 500, "internal server error", b"internal server error\n") 112 113 meta.status = 500 113 114 meta.response_bytes = _byte_count_for_simple(b"internal server error\n") 114 115 return meta ··· 141 142 meta.response_bytes += sent 142 143 143 144 # Stream body. Iterate in a thread (WSGI iterables can block). 144 - iterator = iter(result) if not isinstance(result, (bytes, bytearray)) else iter([bytes(result)]) 145 + iterator = ( 146 + iter(result) 147 + if not isinstance(result, (bytes, bytearray)) 148 + else iter([bytes(result)]) 149 + ) 145 150 146 151 async def next_chunk() -> bytes | None: 147 152 def _pull() -> bytes | None: ··· 226 231 227 232 headers_map = {k.lower(): v for k, v in headers} 228 233 body = b"" 229 - if "transfer-encoding" in headers_map and headers_map["transfer-encoding"].lower() == "chunked": 234 + if ( 235 + "transfer-encoding" in headers_map 236 + and headers_map["transfer-encoding"].lower() == "chunked" 237 + ): 230 238 body = await _read_chunked(reader) 231 239 else: 232 240 cl_raw = headers_map.get("content-length", "0")