From dd104e77500c0e1959a6625eca8c26e9969fa956 Mon Sep 17 00:00:00 2001 From: Alexandr Artemyev Date: Mon, 19 Oct 2026 18:17:00 +0500 Subject: [PATCH] Add asynchronous grpc health checking stubs and serving status types --- .../grpc_health/v1/_async.pyi | 17 +++++++++++++++++ .../grpc_health/v1/health.pyi | 6 ++++-- .../grpc_health/v1/health_pb2.pyi | 18 +++++++++--------- .../grpc_health/v1/health_pb2_grpc.pyi | 15 ++++++++++----- 4 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 stubs/grpcio-health-checking/grpc_health/v1/_async.pyi diff --git a/stubs/grpcio-health-checking/grpc_health/v1/_async.pyi b/stubs/grpcio-health-checking/grpc_health/v1/_async.pyi new file mode 100644 index 000000000000..6f781a406bbd --- /dev/null +++ b/stubs/grpcio-health-checking/grpc_health/v1/_async.pyi @@ -0,0 +1,17 @@ +from grpc.aio import ServicerContext +from grpc_health.v1 import health_pb2, health_pb2_grpc + +class HealthServicer(health_pb2_grpc.HealthServicer): + def __init__(self) -> None: ... + async def Check( + self, + request: health_pb2.HealthCheckRequest, + context: ServicerContext[health_pb2.HealthCheckRequest, health_pb2.HealthCheckResponse], + ) -> health_pb2.HealthCheckResponse: ... + async def Watch( + self, + request: health_pb2.HealthCheckRequest, + context: ServicerContext[health_pb2.HealthCheckRequest, health_pb2.HealthCheckResponse], + ) -> None: ... + async def set(self, service: str, status: int) -> None: ... + async def enter_graceful_shutdown(self) -> None: ... diff --git a/stubs/grpcio-health-checking/grpc_health/v1/health.pyi b/stubs/grpcio-health-checking/grpc_health/v1/health.pyi index e98ffdbcd980..275a50670761 100644 --- a/stubs/grpcio-health-checking/grpc_health/v1/health.pyi +++ b/stubs/grpcio-health-checking/grpc_health/v1/health.pyi @@ -5,7 +5,9 @@ from typing import Final, overload from typing_extensions import Self from grpc import ServicerContext -from grpc_health.v1 import health_pb2, health_pb2_grpc +from grpc_health.v1 import _async, health_pb2, health_pb2_grpc + +aio = _async SERVICE_NAME: Final[str] OVERALL_HEALTH: Final[str] @@ -33,5 +35,5 @@ class HealthServicer(health_pb2_grpc.HealthServicer): self, request: health_pb2.HealthCheckRequest, context: ServicerContext, send_response_callback: Callable[..., Incomplete] ) -> None: ... - def set(self, service: str, status: health_pb2.HealthCheckResponse.ServingStatus) -> None: ... + def set(self, service: str, status: int) -> None: ... def enter_graceful_shutdown(self) -> None: ... diff --git a/stubs/grpcio-health-checking/grpc_health/v1/health_pb2.pyi b/stubs/grpcio-health-checking/grpc_health/v1/health_pb2.pyi index 82191f79b659..ca12270816b6 100644 --- a/stubs/grpcio-health-checking/grpc_health/v1/health_pb2.pyi +++ b/stubs/grpcio-health-checking/grpc_health/v1/health_pb2.pyi @@ -1,8 +1,8 @@ -from _typeshed import Incomplete -from typing import ClassVar, final +from typing import ClassVar, Literal, final from google._upb._message import Descriptor, FileDescriptor, MessageMeta from google.protobuf import message +from google.protobuf.internal.enum_type_wrapper import EnumTypeWrapper DESCRIPTOR: FileDescriptor @@ -15,12 +15,12 @@ class HealthCheckRequest(message.Message, metaclass=MessageMeta): @final class HealthCheckResponse(message.Message, metaclass=MessageMeta): - ServingStatus: Incomplete - UNKNOWN: Incomplete - SERVING: Incomplete - NOT_SERVING: Incomplete - SERVICE_UNKNOWN: Incomplete + ServingStatus: ClassVar[EnumTypeWrapper] + UNKNOWN: ClassVar[Literal[0]] + SERVING: ClassVar[Literal[1]] + NOT_SERVING: ClassVar[Literal[2]] + SERVICE_UNKNOWN: ClassVar[Literal[3]] STATUS_FIELD_NUMBER: ClassVar[int] - status: Incomplete - def __init__(self, status: Incomplete | str | None = ...) -> None: ... + status: int + def __init__(self, status: int | str | None = ...) -> None: ... DESCRIPTOR: Descriptor diff --git a/stubs/grpcio-health-checking/grpc_health/v1/health_pb2_grpc.pyi b/stubs/grpcio-health-checking/grpc_health/v1/health_pb2_grpc.pyi index 8170664f0cb1..5c8552573f9f 100644 --- a/stubs/grpcio-health-checking/grpc_health/v1/health_pb2_grpc.pyi +++ b/stubs/grpcio-health-checking/grpc_health/v1/health_pb2_grpc.pyi @@ -1,16 +1,21 @@ -from typing import Final +from typing import Any, Final + +import grpc +from grpc import aio +from grpc_health.v1 import health_pb2 GRPC_GENERATED_VERSION: Final[str] GRPC_VERSION: Final[str] class HealthStub: - def __init__(self, channel) -> None: ... + def __init__(self, channel: grpc.Channel | aio.Channel) -> None: ... class HealthServicer: - def Check(self, request, context): ... - def Watch(self, request, context): ... + # Generated methods are overridden by both synchronous and asynchronous servicers. + def Check(self, request: health_pb2.HealthCheckRequest, context: Any) -> Any: ... + def Watch(self, request: health_pb2.HealthCheckRequest, context: Any) -> Any: ... -def add_HealthServicer_to_server(servicer, server) -> None: ... +def add_HealthServicer_to_server(servicer: HealthServicer, server: grpc.Server | aio.Server) -> None: ... class Health: @staticmethod