Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
Signed-off-by: Yevgen Polyak <yevgen.polyak@gmail.com>
  • Loading branch information
evhen14 committed Jun 25, 2024
1 parent ece0d3d commit 8fe881d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions ext/dapr-ext-grpc/dapr/ext/grpc/_health_servicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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')

Check warning on line 21 in ext/dapr-ext-grpc/dapr/ext/grpc/_health_servicer.py

View check run for this annotation

Codecov / codecov/patch

ext/dapr-ext-grpc/dapr/ext/grpc/_health_servicer.py#L21

Added line #L21 was not covered by tests
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()
Expand Down
2 changes: 1 addition & 1 deletion ext/dapr-ext-grpc/dapr/ext/grpc/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion ext/dapr-ext-grpc/tests/test_servicier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8fe881d

Please sign in to comment.