diff --git a/stubs/grpcio/@tests/test_cases/check_handler_inheritance.py b/stubs/grpcio/@tests/test_cases/check_handler_inheritance.py index 21826a18b18f..ce74855fa76d 100644 --- a/stubs/grpcio/@tests/test_cases/check_handler_inheritance.py +++ b/stubs/grpcio/@tests/test_cases/check_handler_inheritance.py @@ -30,7 +30,8 @@ def service(self, handler_call_details: grpc.HandlerCallDetails) -> grpc.RpcMeth h = ServiceHandler() +hcd = cast(grpc.HandlerCallDetails, None) ctx = cast(grpc.ServicerContext, None) -svc = h.service(grpc.HandlerCallDetails()) +svc = h.service(hcd) if svc is not None and svc.unary_unary is not None: svc.unary_unary(Request(), ctx) diff --git a/stubs/grpcio/METADATA.toml b/stubs/grpcio/METADATA.toml index 29fdcfc493d8..f3cfbb32e927 100644 --- a/stubs/grpcio/METADATA.toml +++ b/stubs/grpcio/METADATA.toml @@ -1,4 +1,4 @@ -version = "1.*" +version = "~= 1.82.1" upstream-repository = "https://github.com/grpc/grpc" partial-stub = true diff --git a/stubs/grpcio/grpc/__init__.pyi b/stubs/grpcio/grpc/__init__.pyi index b4e585b08c9b..85f1af44e5a8 100644 --- a/stubs/grpcio/grpc/__init__.pyi +++ b/stubs/grpcio/grpc/__init__.pyi @@ -4,7 +4,7 @@ import threading from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from concurrent import futures from types import ModuleType, TracebackType -from typing import Any, Generic, NoReturn, Protocol, TypeAlias, TypeVar, type_check_only +from typing import Any, Generic, NoReturn, Protocol, TypeAlias, TypeVar, runtime_checkable, type_check_only from typing_extensions import Self from . import aio as aio @@ -483,7 +483,8 @@ class RpcMethodHandler(abc.ABC, Generic[_TRequest, _TResponse]): stream_stream: Callable[[Iterator[_TRequest], ServicerContext], Iterator[_TResponse]] | None -class HandlerCallDetails(abc.ABC): +@runtime_checkable +class HandlerCallDetails(Protocol): method: str invocation_metadata: _Metadata diff --git a/stubs/grpcio/grpc/aio/__init__.pyi b/stubs/grpcio/grpc/aio/__init__.pyi index 290ef936427a..cb3c27ebaa58 100644 --- a/stubs/grpcio/grpc/aio/__init__.pyi +++ b/stubs/grpcio/grpc/aio/__init__.pyi @@ -15,7 +15,7 @@ from collections.abc import ( ) from concurrent import futures from types import TracebackType -from typing import Any, Generic, NoReturn, TypeAlias, TypeVar, overload, type_check_only +from typing import Any, Final, Generic, Literal, NoReturn, TypeAlias, TypeVar, overload, type_check_only from typing_extensions import Self from grpc import ( @@ -32,9 +32,55 @@ from grpc import ( _Options, ) +__all__ = ( + "EOF", + "AbortError", + "AioRpcError", + "BaseError", + "Call", + "Channel", + "ClientCallDetails", + "ClientInterceptor", + "InterceptedUnaryUnaryCall", + "InternalError", + "Metadata", + "RpcContext", + "Server", + "ServerInterceptor", + "ServicerContext", + "StreamStreamCall", + "StreamStreamClientInterceptor", + "StreamStreamMultiCallable", + "StreamUnaryCall", + "StreamUnaryClientInterceptor", + "StreamUnaryMultiCallable", + "UnaryStreamCall", + "UnaryStreamClientInterceptor", + "UnaryStreamMultiCallable", + "UnaryUnaryCall", + "UnaryUnaryClientInterceptor", + "UnaryUnaryMultiCallable", + "UsageError", + "init_grpc_aio", + "insecure_channel", + "secure_channel", + "server", + "shutdown_grpc_aio", +) + _TRequest = TypeVar("_TRequest") _TResponse = TypeVar("_TResponse") +@type_check_only +class _EOF: + def __bool__(self) -> Literal[False]: ... + def __len__(self) -> Literal[0]: ... + +EOF: Final[_EOF] + +def init_grpc_aio() -> None: ... +def shutdown_grpc_aio() -> None: ... + # Exceptions: class BaseError(Exception): ... @@ -46,16 +92,18 @@ class AioRpcError(RpcError): def __init__( self, code: StatusCode, - initial_metadata: Metadata, - trailing_metadata: Metadata, + initial_metadata: Metadata | None = None, + trailing_metadata: Metadata | None = None, details: str | None = None, debug_error_string: str | None = None, ) -> None: ... - def debug_error_string(self) -> str: ... + def code(self) -> StatusCode: ... + def details(self) -> str | None: ... def initial_metadata(self) -> Metadata | MaybeNone: ... # AioRpcError returns the async Metadata, overriding the synchronous # grpc.RpcError.trailing_metadata() -> tuple[_Metadatum, ...]. def trailing_metadata(self) -> Metadata | MaybeNone: ... # type: ignore[override] + def debug_error_string(self) -> str | None: ... # Create Client: