test(util/service): use Protocol cast instead of type: ignore

Address CodeRabbit feedback on the new GraphValidationError round-trip
tests: the file already has a ``_SupportsGetReturn`` Protocol pattern
and coding guidelines forbid ``# type: ignore`` suppressors.

Add ``_SupportsHandleCallMethodResponse`` Protocol alongside the
existing one, cast the test client to it, and drop the two
``# type: ignore[attr-defined]`` suppressions added for the new tests.
Pre-existing suppressions on older tests are left untouched (separate
concern, out of scope for this PR).
This commit is contained in:
majdyz
2026-04-10 23:59:36 +00:00
parent 24e1e37ebe
commit 6f9f2c72db

View File

@@ -30,6 +30,12 @@ class _SupportsGetReturn(Protocol):
def _get_return(self, expected_return: TypeAdapter | None, result: Any) -> Any: ...
class _SupportsHandleCallMethodResponse(Protocol):
def _handle_call_method_response(
self, *, response: Any, method_name: str
) -> Any: ...
class ServiceTest(AppService):
def __init__(self):
super().__init__()
@@ -516,10 +522,13 @@ class TestHTTPErrorRetryBehavior:
"400 Bad Request", request=Mock(), response=mock_response
)
client = get_service_client(ServiceTestClient)
client = cast(
_SupportsHandleCallMethodResponse,
get_service_client(ServiceTestClient),
)
with pytest.raises(GraphValidationError) as exc_info:
client._handle_call_method_response( # type: ignore[attr-defined]
client._handle_call_method_response(
response=mock_response, method_name="test_method"
)
@@ -540,10 +549,13 @@ class TestHTTPErrorRetryBehavior:
"400 Bad Request", request=Mock(), response=mock_response
)
client = get_service_client(ServiceTestClient)
client = cast(
_SupportsHandleCallMethodResponse,
get_service_client(ServiceTestClient),
)
with pytest.raises(GraphValidationError) as exc_info:
client._handle_call_method_response( # type: ignore[attr-defined]
client._handle_call_method_response(
response=mock_response, method_name="test_method"
)