From de936e54e107dae7138a23a5148cbbc1d9fd2cc8 Mon Sep 17 00:00:00 2001 From: Artur Shiriev Date: Tue, 10 Nov 2026 22:13:04 +0300 Subject: [PATCH] Update ty ignore codes for 0.0.100 Refs #58 --- examples/app.py | 6 +++--- modern_di_grpc/main.py | 12 ++++++------ tests/test_aio.py | 4 ++-- tests/test_example.py | 2 +- tests/test_smoke.py | 2 +- tests/test_sync.py | 10 +++++----- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/examples/app.py b/examples/app.py index 05f8b11..f981083 100644 --- a/examples/app.py +++ b/examples/app.py @@ -32,11 +32,11 @@ class GreeterService(greeter_pb2_grpc.GreeterServicer): @inject def SayHello( # noqa: N802 self, - request: greeter_pb2.HelloRequest, # ty: ignore[unresolved-attribute] + request: greeter_pb2.HelloRequest, # ty: ignore[missing-attribute] _context: grpc.ServicerContext, greeter: typing.Annotated[Greeter, FromDI(Greeter)], - ) -> greeter_pb2.HelloReply: # ty: ignore[unresolved-attribute] - return greeter_pb2.HelloReply(message=greeter.greet(request.name)) # ty: ignore[unresolved-attribute] + ) -> greeter_pb2.HelloReply: # ty: ignore[missing-attribute] + return greeter_pb2.HelloReply(message=greeter.greet(request.name)) # ty: ignore[missing-attribute] def build_server(port: str = "127.0.0.1:0") -> tuple[grpc.Server, int, Container]: diff --git a/modern_di_grpc/main.py b/modern_di_grpc/main.py index 9b7a8a8..05e51f2 100644 --- a/modern_di_grpc/main.py +++ b/modern_di_grpc/main.py @@ -99,15 +99,15 @@ def _rewrap( ) -> grpc.RpcMethodHandler: # grpc.RpcMethodHandler is an abc.ABC documenting these attributes only in its docstring (no annotated # fields), so ty cannot resolve them on the concrete instances the runtime actually hands back. - deserializer = handler.request_deserializer # ty: ignore[unresolved-attribute] - serializer = handler.response_serializer # ty: ignore[unresolved-attribute] - if unary_unary := handler.unary_unary: # ty: ignore[unresolved-attribute] + deserializer = handler.request_deserializer # ty: ignore[missing-attribute] + serializer = handler.response_serializer # ty: ignore[missing-attribute] + if unary_unary := handler.unary_unary: # ty: ignore[missing-attribute] return grpc.unary_unary_rpc_method_handler(unary_builder(unary_unary), deserializer, serializer) - if unary_stream := handler.unary_stream: # ty: ignore[unresolved-attribute] + if unary_stream := handler.unary_stream: # ty: ignore[missing-attribute] return grpc.unary_stream_rpc_method_handler(stream_builder(unary_stream), deserializer, serializer) - if stream_unary := handler.stream_unary: # ty: ignore[unresolved-attribute] + if stream_unary := handler.stream_unary: # ty: ignore[missing-attribute] return grpc.stream_unary_rpc_method_handler(unary_builder(stream_unary), deserializer, serializer) - if stream_stream := handler.stream_stream: # ty: ignore[unresolved-attribute] + if stream_stream := handler.stream_stream: # ty: ignore[missing-attribute] return grpc.stream_stream_rpc_method_handler(stream_builder(stream_stream), deserializer, serializer) return handler # pragma: no cover (every RpcMethodHandler sets exactly one behavior) diff --git a/tests/test_aio.py b/tests/test_aio.py index 7b8895c..0d0dbbf 100644 --- a/tests/test_aio.py +++ b/tests/test_aio.py @@ -18,8 +18,8 @@ # greeter_pb2 is generated by protoc; ty (like most static checkers) can't see its dynamically # built message attributes, so alias them once here instead of an ignore comment on every use below. -HelloRequest = greeter_pb2.HelloRequest # ty: ignore[unresolved-attribute] -HelloReply = greeter_pb2.HelloReply # ty: ignore[unresolved-attribute] +HelloRequest = greeter_pb2.HelloRequest # ty: ignore[missing-attribute] +HelloReply = greeter_pb2.HelloReply # ty: ignore[missing-attribute] class AioServicer(greeter_pb2_grpc.GreeterServicer): diff --git a/tests/test_example.py b/tests/test_example.py index b28f8b6..5cfeeed 100644 --- a/tests/test_example.py +++ b/tests/test_example.py @@ -4,7 +4,7 @@ from tests.protos import greeter_pb2, greeter_pb2_grpc -HelloRequest = greeter_pb2.HelloRequest # ty: ignore[unresolved-attribute] +HelloRequest = greeter_pb2.HelloRequest # ty: ignore[missing-attribute] def test_example_resolves_and_greets() -> None: diff --git a/tests/test_smoke.py b/tests/test_smoke.py index 9b5601b..4dce7c5 100644 --- a/tests/test_smoke.py +++ b/tests/test_smoke.py @@ -32,5 +32,5 @@ def test_public_surface_is_exactly_the_six_documented_symbols() -> None: def test_proto_stubs_importable() -> None: - assert greeter_pb2.HelloRequest is not None # ty: ignore[unresolved-attribute] + assert greeter_pb2.HelloRequest is not None # ty: ignore[missing-attribute] assert greeter_pb2_grpc.GreeterServicer is not None diff --git a/tests/test_sync.py b/tests/test_sync.py index 027187f..d16c340 100644 --- a/tests/test_sync.py +++ b/tests/test_sync.py @@ -24,8 +24,8 @@ # greeter_pb2 is generated by protoc; ty (like most static checkers) can't see its dynamically # built message attributes, so alias them once here instead of an ignore comment on every use below. -HelloRequest = greeter_pb2.HelloRequest # ty: ignore[unresolved-attribute] -HelloReply = greeter_pb2.HelloReply # ty: ignore[unresolved-attribute] +HelloRequest = greeter_pb2.HelloRequest # ty: ignore[missing-attribute] +HelloReply = greeter_pb2.HelloReply # ty: ignore[missing-attribute] class Servicer(greeter_pb2_grpc.GreeterServicer): @@ -125,7 +125,7 @@ def test_unknown_method_returns_unimplemented(sync_channel: grpc.Channel) -> Non sync_channel.unary_unary("/greeter.Greeter/DoesNotExist")(b"") # grpc.RpcError is an empty marker class; the actual raised instance is also a grpc.Call # (code(), details(), ...), which ty can't see from the RpcError annotation alone. - assert excinfo.value.code() == grpc.StatusCode.UNIMPLEMENTED # ty: ignore[unresolved-attribute] + assert excinfo.value.code() == grpc.StatusCode.UNIMPLEMENTED # ty: ignore[missing-attribute] def test_inject_without_interceptor_reports_missing_interceptor() -> None: @@ -138,8 +138,8 @@ def test_inject_without_interceptor_reports_missing_interceptor() -> None: greeter_pb2_grpc.GreeterStub(channel).SayHello(HelloRequest(name="a")) finally: server.stop(0) - assert excinfo.value.code() == grpc.StatusCode.UNKNOWN # ty: ignore[unresolved-attribute] - assert "DIInterceptor" in excinfo.value.details() # ty: ignore[unresolved-attribute] + assert excinfo.value.code() == grpc.StatusCode.UNKNOWN # ty: ignore[missing-attribute] + assert "DIInterceptor" in excinfo.value.details() # ty: ignore[missing-attribute] async def test_app_finalizer_runs_on_root_close() -> None: