{"id":6286,"library":"types-grpcio-health-checking","title":"Typing Stubs for grpcio-health-checking","description":"This package provides static type checking stubs for the `grpcio-health-checking` library, enabling tools like MyPy to validate usage of `grpc_health.v1` modules. It is part of the `typeshed` project, which supplies type hints for many popular Python packages. The current version is 1.0.0.20260408, with releases tied to updates of the underlying runtime library.","status":"active","version":"1.0.0.20260408","language":"en","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["typing","stubs","grpc","health-checking","typeshed","mypy"],"install":[{"cmd":"pip install types-grpcio-health-checking","lang":"bash","label":"Install typing stubs"},{"cmd":"pip install grpcio grpcio-health-checking mypy","lang":"bash","label":"Install runtime dependencies and type checker (recommended)"}],"dependencies":[],"imports":[{"note":"Typing stubs augment the existing runtime modules; you import directly from the original library path, not the stub package itself.","wrong":"from types_grpcio_health_checking import HealthServicer","symbol":"HealthServicer","correct":"from grpc_health.v1.health import HealthServicer"},{"note":"Messages like HealthCheckRequest are typically accessed via the _pb2 generated module.","symbol":"HealthCheckRequest","correct":"from grpc_health.v1 import health_pb2"}],"quickstart":{"code":"import grpc\nfrom grpc_health.v1 import health_pb2\nfrom grpc_health.v1.health import HealthServicer\n\n# This example demonstrates using type hints provided by types-grpcio-health-checking.\n# For this code to run, 'grpcio' and 'grpcio-health-checking' must also be installed.\n# The 'types-' package primarily assists static analysis tools like MyPy.\n\nclass MyHealthServicer(HealthServicer):\n    \"\"\"\n    An example gRPC Health Servicer implementation. The type hints for\n    `request` and the return value are validated by type checkers (like mypy)\n    thanks to the 'types-grpcio-health-checking' package providing stubs\n    for 'grpcio-health-checking'.\n    \"\"\"\n    def Check(self,\n              request: health_pb2.HealthCheckRequest,\n              context: grpc.ServicerContext) -> health_pb2.HealthCheckResponse:\n        \"\"\"\n        Implements the Check method of the gRPC Health Service.\n        \"\"\"\n        print(f\"Received health check for service: {request.service}\")\n        # In a real application, you'd check actual service status here.\n        if request.service == \"myservice\":\n            return health_pb2.HealthCheckResponse(status=health_pb2.HealthCheckResponse.ServingStatus.SERVING)\n        return health_pb2.HealthCheckResponse(status=health_pb2.HealthCheckResponse.ServingStatus.NOT_SERVING)\n\n    def Watch(self,\n              request: health_pb2.HealthCheckRequest,\n              context: grpc.ServicerContext) -> health_pb2.HealthCheckResponse:\n        \"\"\"\n        Implements the Watch method (streaming). For simplicity,\n        this example just yields a single response.\n        \"\"\"\n        yield health_pb2.HealthCheckResponse(status=health_pb2.HealthCheckResponse.ServingStatus.SERVING)\n\n# To verify type-checking with MyPy:\n# 1. Ensure you have 'grpcio', 'grpcio-health-checking', 'types-grpcio-health-checking', and 'mypy' installed.\n# 2. Save this code as 'health_types_example.py'.\n# 3. Run: mypy health_types_example.py\n# If 'types-grpcio-health-checking' were missing, mypy would report errors for `HealthServicer` and other type hints.","lang":"python","description":"This quickstart demonstrates how to use the type hints provided by `types-grpcio-health-checking` in a `grpcio-health-checking` service implementation. It highlights the correct import paths and how type annotations enhance code clarity and enable static analysis. Note that the `types-` package is for type checking, not for runtime execution; the actual runtime code requires `grpcio` and `grpcio-health-checking`."},"warnings":[{"fix":"Install `grpcio` and `grpcio-health-checking` for runtime functionality. Install `types-grpcio-health-checking` only for type checking purposes.","message":"This package provides only type stubs and does not contain any runtime code. Its sole purpose is to provide type information for static analysis tools like MyPy.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always use standard `from grpc_health.v1 import ...` import statements. The `types-` package is picked up automatically by type checkers.","message":"Do not attempt to import symbols directly from `types_grpcio_health_checking`. The stub package augments the original `grpcio-health-checking` library. All imports should be made from `grpc_health.v1` modules as if the stubs were not present.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always keep your `types-grpcio-health-checking` version in sync with your `grpcio-health-checking` version. Refer to the `typeshed` repository for specific version compatibility information.","message":"Type stubs are tightly coupled to the API of the runtime library they type. If you upgrade `grpcio-health-checking` to a new major version, the corresponding `types-grpcio-health-checking` stubs might become outdated or incorrect, potentially leading to type errors or undetected runtime issues.","severity":"breaking","affected_versions":"All versions (when underlying library changes)"},{"fix":"Understand that the date suffix signifies the freshness of the stub, not a direct API version. Always consult `typeshed` or `grpcio-health-checking` documentation for specific compatibility.","message":"The version numbering for `types-` packages from `typeshed` (e.g., `1.0.0.20260408`) indicates the upstream package version (1.0.0) and the date the stub was generated/updated (20260408). It does not necessarily match the exact versioning scheme of the runtime `grpcio-health-checking` package.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}