Three spots had the same shape: a field starts None, a later method populates it, a read site later reads it. Pyright can't track the cross-method invariant. Rather than spray assertions at the read sites, fix each site at the structural level: - `FastAPIWebsocketInputTransport._monitor_websocket` now takes the session timeout as an argument. The task-creation site already guards on truthiness, so the call can pass the non-None value directly and the method's signature tells the truth. - `FrameProcessorMetrics.task_manager` raises `RuntimeError` instead of asserting. Asserts are stripped under `python -O`; a real raise keeps the runtime safety net and still narrows the type for pyright. - `SOXRStreamAudioResampler._maybe_initialize_sox_stream` returns the initialized stream. Callers use the return value and never touch the Optional `_soxr_stream` attribute, so narrowing stays inside the init method where the invariant is established.
6.1 KiB
6.1 KiB