Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion stubs/grpcio/@tests/test_cases/check_handler_inheritance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion stubs/grpcio/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "1.*"
version = "~= 1.82.1"
upstream-repository = "https://github.com/grpc/grpc"
partial-stub = true

Expand Down
5 changes: 3 additions & 2 deletions stubs/grpcio/grpc/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
56 changes: 52 additions & 4 deletions stubs/grpcio/grpc/aio/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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): ...
Expand All @@ -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:

Expand Down
Loading