diff --git a/src/lg_smtv_mcp/tv_core/protocols.py b/src/lg_smtv_mcp/tv_core/protocols.py index b0d46d2..a288d0f 100644 --- a/src/lg_smtv_mcp/tv_core/protocols.py +++ b/src/lg_smtv_mcp/tv_core/protocols.py @@ -8,11 +8,11 @@ from typing import Any, Literal, Protocol class WebSocketClosedError(Exception): """Raised when a WebSocket transport closes unexpectedly or is already closed.""" - code: int - reason: str - def __init__(self, code: int, reason: str = "") -> None: - raise NotImplementedError + message = f"WebSocket closed ({code}): {reason}" if reason else f"WebSocket closed ({code})" + super().__init__(message) + self.code = code + self.reason = reason class WebSocketTransport(Protocol): @@ -61,9 +61,6 @@ class TvStatus: status: Literal["connected", "already_connected"] elapsed_ms: int - def __post_init__(self) -> None: - raise NotImplementedError - @dataclass(frozen=True, slots=True) class TvStateSnapshot: @@ -77,9 +74,6 @@ class TvStateSnapshot: foreground_app: str | None last_updated: float | None - def __post_init__(self) -> None: - raise NotImplementedError - @dataclass(frozen=True, slots=True) class CaptureResult: @@ -90,9 +84,6 @@ class CaptureResult: changed_since_last: bool size_bytes: int - def __post_init__(self) -> None: - raise NotImplementedError - @dataclass(frozen=True, slots=True) class KeysResult: @@ -105,9 +96,6 @@ class KeysResult: size_bytes: int | None = None capture_error: str | None = None - def __post_init__(self) -> None: - raise NotImplementedError - @dataclass(frozen=True, slots=True) class TextResult: @@ -119,6 +107,3 @@ class TextResult: changed_since_last: bool | None = None size_bytes: int | None = None capture_error: str | None = None - - def __post_init__(self) -> None: - raise NotImplementedError diff --git a/tests/test_protocols.py b/tests/test_protocols.py index a79f4f5..327cb63 100644 --- a/tests/test_protocols.py +++ b/tests/test_protocols.py @@ -12,7 +12,6 @@ from lg_smtv_mcp.tv_core.protocols import ( ) -@pytest.mark.xfail(strict=True, reason="Red phase: protocols") def test_websocket_closed_error_preserves_args_and_str_representation() -> None: err = WebSocketClosedError(1008, "Try Again Later (EWS)") @@ -29,7 +28,6 @@ def test_websocket_closed_error_preserves_args_and_str_representation() -> None: assert "1000" in str(err_no_reason) -@pytest.mark.xfail(strict=True, reason="Red phase: protocols") def test_result_dataclasses_are_frozen_and_expose_expected_fields() -> None: status = TvStatus(status="connected", elapsed_ms=120) snapshot = TvStateSnapshot(