Skip to content

testing~ #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
20 changes: 20 additions & 0 deletions stubs/grpcio/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,23 @@ grpc.RpcError.trailing_metadata
# =============================
# Stub class is incomplete.
grpc_reflection.v1alpha._base.BaseReflectionServicer.__init__

# Error: is not present in stub
# =============================
# Missing stubs
grpc.aio._typing.*
grpc_channelz.v1.*
grpc_health.v1.*
grpc_reflection.v1alpha.*
grpc_status.rpc_status.__all__
grpc_status.rpc_status.aio

# Error: failed to find stubs
# =============================
# Missing stubs
grpc._cython.cygrpc
grpc.beta.*
grpc.experimental.*
grpc.framework.*
grpc_reflection.v1alpha.proto_reflection_descriptor_database
grpc_reflection.v1alpha.reflection_pb2_grpc
1 change: 0 additions & 1 deletion stubs/grpcio/METADATA.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ requires = [
]

[tool.stubtest]
ignore_missing_stub = true
stubtest_requirements = [
"grpcio-channelz",
"grpcio-health-checking",
Expand Down
74 changes: 73 additions & 1 deletion stubs/grpcio/grpc/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ class Server(abc.ABC):
# Block current thread until the server stops. Returns a bool
# indicates if the operation times out. Timeout is in seconds.
def wait_for_termination(self, timeout: float | None = ...) -> bool: ...
def add_registered_method_handlers(
self, service_name: str, method_handlers: dict[str, RpcMethodHandler[Any, Any]]
) -> None: ...

# Authentication & Authorization Objects:

Expand Down Expand Up @@ -483,11 +486,13 @@ class ServicerContext(RpcContext, metaclass=abc.ABCMeta):
def set_compression(self, compression: Compression) -> None: ...
@abc.abstractmethod
def set_trailing_metadata(self, trailing_metadata: _Metadata) -> None: ...
def trailing_metadata(self) -> _Metadata: ...

# misnamed function 'details', does not align with status.proto, where it is called 'message':
@abc.abstractmethod
def set_details(self, details: str) -> None: ...
def trailing_metadata(self) -> _Metadata: ...
def code(self) -> StatusCode: ...
def details(self) -> str: ...

# Service-Side Handler:

Expand Down Expand Up @@ -638,3 +643,70 @@ class StreamStreamMultiCallable(abc.ABC, Generic[_TRequest, _TResponse]):
def protos(protobuf_path: str) -> ModuleType: ...
def services(protobuf_path: str) -> ModuleType: ...
def protos_and_services(protobuf_path: str) -> tuple[ModuleType, ModuleType]: ...

__all__ = (
"FutureTimeoutError",
"FutureCancelledError",
"Future",
"ChannelConnectivity",
"StatusCode",
"Status",
"RpcError",
"RpcContext",
"Call",
"ChannelCredentials",
"CallCredentials",
"AuthMetadataContext",
"AuthMetadataPluginCallback",
"AuthMetadataPlugin",
"Compression",
"ClientCallDetails",
"ServerCertificateConfiguration",
"ServerCredentials",
"LocalConnectionType",
"UnaryUnaryMultiCallable",
"UnaryStreamMultiCallable",
"StreamUnaryMultiCallable",
"StreamStreamMultiCallable",
"UnaryUnaryClientInterceptor",
"UnaryStreamClientInterceptor",
"StreamUnaryClientInterceptor",
"StreamStreamClientInterceptor",
"Channel",
"ServicerContext",
"RpcMethodHandler",
"HandlerCallDetails",
"GenericRpcHandler",
"ServiceRpcHandler",
"Server",
"ServerInterceptor",
"unary_unary_rpc_method_handler",
"unary_stream_rpc_method_handler",
"stream_unary_rpc_method_handler",
"stream_stream_rpc_method_handler",
"method_handlers_generic_handler",
"ssl_channel_credentials",
"metadata_call_credentials",
"access_token_call_credentials",
"composite_call_credentials",
"composite_channel_credentials",
"compute_engine_channel_credentials",
"local_channel_credentials",
"local_server_credentials",
"alts_channel_credentials",
"alts_server_credentials",
"ssl_server_credentials",
"ssl_server_certificate_configuration",
"dynamic_ssl_server_credentials",
"channel_ready_future",
"insecure_channel",
"secure_channel",
"intercept_channel",
"server",
"protos",
"services",
"protos_and_services",
"xds_channel_credentials",
"xds_server_credentials",
"insecure_server_credentials",
)
49 changes: 46 additions & 3 deletions stubs/grpcio/grpc/aio/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ from grpc import (
StatusCode,
_Options,
)
from grpc.aio._typing import EOFType

_TRequest = TypeVar("_TRequest")
_TResponse = TypeVar("_TResponse")
EOF = EOFType()

# Exceptions:

Expand All @@ -46,6 +48,9 @@ class AioRpcError(RpcError):
def debug_error_string(self) -> str: ...
def initial_metadata(self) -> Metadata: ...

def init_grpc_aio() -> None: ...
def shutdown_grpc_aio() -> None: ...

# Create Client:

class ClientInterceptor(metaclass=abc.ABCMeta): ...
Expand Down Expand Up @@ -150,11 +155,13 @@ class Server(metaclass=abc.ABCMeta):
# Returns a bool indicates if the operation times out. Timeout is in seconds.
@abc.abstractmethod
async def wait_for_termination(self, timeout: float | None = ...) -> bool: ...
def add_registered_method_handlers(
self, service_name: str, method_handlers: dict[str, RpcMethodHandler[Any, Any]]
) -> None: ...

# Client-Side Context:

_DoneCallbackType: TypeAlias = Callable[[Any], None]
_EOFType: TypeAlias = object

class RpcContext(metaclass=abc.ABCMeta):
@abc.abstractmethod
Expand Down Expand Up @@ -188,7 +195,7 @@ class UnaryStreamCall(Call, Generic[_TRequest, _TResponse], metaclass=abc.ABCMet
@abc.abstractmethod
def __aiter__(self) -> AsyncIterator[_TResponse]: ...
@abc.abstractmethod
async def read(self) -> _EOFType | _TResponse: ...
async def read(self) -> EOFType | _TResponse: ...

class StreamUnaryCall(Call, Generic[_TRequest, _TResponse], metaclass=abc.ABCMeta):
@abc.abstractmethod
Expand All @@ -202,7 +209,7 @@ class StreamStreamCall(Call, Generic[_TRequest, _TResponse], metaclass=abc.ABCMe
@abc.abstractmethod
def __aiter__(self) -> AsyncIterator[_TResponse]: ...
@abc.abstractmethod
async def read(self) -> _EOFType | _TResponse: ...
async def read(self) -> EOFType | _TResponse: ...
@abc.abstractmethod
async def write(self, request: _TRequest) -> None: ...
@abc.abstractmethod
Expand Down Expand Up @@ -453,3 +460,39 @@ class Metadata(Mapping[_MetadataKey, _MetadataValue]):
def __contains__(self, key: object) -> bool: ...
def __eq__(self, other: object) -> bool: ...
def __add__(self, other: Any) -> Metadata: ...

__all__ = (
"init_grpc_aio",
"shutdown_grpc_aio",
"AioRpcError",
"RpcContext",
"Call",
"UnaryUnaryCall",
"UnaryStreamCall",
"StreamUnaryCall",
"StreamStreamCall",
"Channel",
"UnaryUnaryMultiCallable",
"UnaryStreamMultiCallable",
"StreamUnaryMultiCallable",
"StreamStreamMultiCallable",
"ClientCallDetails",
"ClientInterceptor",
"UnaryStreamClientInterceptor",
"UnaryUnaryClientInterceptor",
"StreamUnaryClientInterceptor",
"StreamStreamClientInterceptor",
"InterceptedUnaryUnaryCall",
"ServerInterceptor",
"insecure_channel",
"server",
"Server",
"ServicerContext",
"EOF",
"secure_channel",
"AbortError",
"BaseError",
"UsageError",
"InternalError",
"Metadata",
)
8 changes: 8 additions & 0 deletions stubs/grpcio/grpc/aio/_typing.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from typing import Literal

class EOFType:
def __bool__(self) -> Literal[False]: ...
def __len__(self) -> Literal[0]: ...
def _repr(self) -> Literal["<grpc.aio.EOF>"]: ...
def __repr__(self) -> Literal["<grpc.aio.EOF>"]: ...
def __str__(self) -> Literal["<grpc.aio.EOF>"]: ...