From 8fe881d15cf23a62af4d7388d511f8afb78292d5 Mon Sep 17 00:00:00 2001 From: Yevgen Polyak Date: Tue, 25 Jun 2024 14:15:51 +1200 Subject: [PATCH] Fix types Signed-off-by: Yevgen Polyak --- ext/dapr-ext-grpc/dapr/ext/grpc/_health_servicer.py | 10 +++++----- ext/dapr-ext-grpc/dapr/ext/grpc/app.py | 2 +- ext/dapr-ext-grpc/tests/test_servicier.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ext/dapr-ext-grpc/dapr/ext/grpc/_health_servicer.py b/ext/dapr-ext-grpc/dapr/ext/grpc/_health_servicer.py index 305d0f12..029dff74 100644 --- a/ext/dapr-ext-grpc/dapr/ext/grpc/_health_servicer.py +++ b/ext/dapr-ext-grpc/dapr/ext/grpc/_health_servicer.py @@ -4,7 +4,7 @@ from dapr.proto import appcallback_service_v1 from dapr.proto.runtime.v1.appcallback_pb2 import HealthCheckResponse -HealthCheckCallable = Callable[[], None] +HealthCheckCallable = Optional[Callable[[], None]] class _HealthCheckServicer(appcallback_service_v1.AppCallbackHealthCheckServicer): @@ -13,19 +13,19 @@ class _HealthCheckServicer(appcallback_service_v1.AppCallbackHealthCheckServicer :class:`App` provides useful decorators to register method, topic, input bindings. """ + def __init__(self): + self._health_check_cb: Optional[HealthCheckCallable] = None + def register_health_check(self, cb: HealthCheckCallable) -> None: if not cb: raise ValueError('health check callback must be defined') self._health_check_cb = cb - def __init__(self): - self._health_check_cb: Optional[HealthCheckCallable] = None - def HealthCheck(self, request, context): """Health check.""" if not self._health_check_cb: - context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_code(grpc.StatusCode.UNIMPLEMENTED) # type: ignore context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') self._health_check_cb() diff --git a/ext/dapr-ext-grpc/dapr/ext/grpc/app.py b/ext/dapr-ext-grpc/dapr/ext/grpc/app.py index e6012f4d..13a0bec6 100644 --- a/ext/dapr-ext-grpc/dapr/ext/grpc/app.py +++ b/ext/dapr-ext-grpc/dapr/ext/grpc/app.py @@ -20,7 +20,7 @@ from dapr.conf import settings from dapr.ext.grpc._servicer import _CallbackServicer, Rule # type: ignore -from dapr.ext.grpc._health_servicer import _HealthCheckServicer +from dapr.ext.grpc._health_servicer import _HealthCheckServicer # type: ignore from dapr.proto import appcallback_service_v1 diff --git a/ext/dapr-ext-grpc/tests/test_servicier.py b/ext/dapr-ext-grpc/tests/test_servicier.py index 4be179c7..1c59581c 100644 --- a/ext/dapr-ext-grpc/tests/test_servicier.py +++ b/ext/dapr-ext-grpc/tests/test_servicier.py @@ -19,7 +19,7 @@ from dapr.clients.grpc._request import InvokeMethodRequest from dapr.clients.grpc._response import InvokeMethodResponse, TopicEventResponse -from dapr.ext.grpc._servicier import _CallbackServicer +from dapr.ext.grpc._servicer import _CallbackServicer from dapr.proto import common_v1, appcallback_v1 from google.protobuf.any_pb2 import Any as GrpcAny