stubtest-complete grpcio plugins (#13932)

This commit is contained in:
Avasam
2025-05-05 15:21:48 +02:00
committed by GitHub
parent 8d4cafdc15
commit 2b2ea7185b
29 changed files with 1321 additions and 221 deletions
+77 -85
View File
@@ -79,21 +79,21 @@ class Future(abc.ABC, Generic[_TFutureValue]):
@abc.abstractmethod
def done(self) -> bool: ...
@abc.abstractmethod
def exception(self, timeout: float | None = ...) -> Exception | None: ...
def exception(self, timeout: float | None = None) -> Exception | None: ...
@abc.abstractmethod
def result(self, timeout: float | None = ...) -> _TFutureValue: ...
def result(self, timeout: float | None = None) -> _TFutureValue: ...
@abc.abstractmethod
def running(self) -> bool: ...
# FIXME: unsure of the exact return type here. Is it a traceback.StackSummary?
@abc.abstractmethod
def traceback(self, timeout: float | None = ...) -> Any: ...
def traceback(self, timeout: float | None = None): ...
# Create Client:
def insecure_channel(target: str, options: _Options | None = ..., compression: Compression | None = ...) -> Channel: ...
def insecure_channel(target: str, options: _Options | None = None, compression: Compression | None = None) -> Channel: ...
def secure_channel(
target: str, credentials: ChannelCredentials, options: _Options | None = ..., compression: Compression | None = ...
target: str, credentials: ChannelCredentials, options: _Options | None = None, compression: Compression | None = None
) -> Channel: ...
_Interceptor: TypeAlias = (
@@ -108,14 +108,14 @@ def intercept_channel(channel: Channel, *interceptors: _Interceptor[_TRequest, _
# Create Client Credentials:
def ssl_channel_credentials(
root_certificates: bytes | None = ..., private_key: bytes | None = ..., certificate_chain: bytes | None = ...
root_certificates: bytes | None = None, private_key: bytes | None = None, certificate_chain: bytes | None = None
) -> ChannelCredentials: ...
def local_channel_credentials(local_connect_type: LocalConnectionType = ...) -> ChannelCredentials: ...
def metadata_call_credentials(metadata_plugin: AuthMetadataPlugin, name: str | None = ...) -> CallCredentials: ...
def metadata_call_credentials(metadata_plugin: AuthMetadataPlugin, name: str | None = None) -> CallCredentials: ...
def access_token_call_credentials(access_token: str) -> CallCredentials: ...
def alts_channel_credentials(service_accounts: Sequence[str] | None = ...) -> ChannelCredentials: ...
def alts_channel_credentials(service_accounts: Sequence[str] | None = None) -> ChannelCredentials: ...
def compute_engine_channel_credentials(call_credentials: CallCredentials) -> ChannelCredentials: ...
def xds_channel_credentials(fallback_credentials: ChannelCredentials | None = ...) -> ChannelCredentials: ...
def xds_channel_credentials(fallback_credentials: ChannelCredentials | None = None) -> ChannelCredentials: ...
# GRPC docs say there should be at least two:
def composite_call_credentials(creds1: CallCredentials, creds2: CallCredentials, *rest: CallCredentials) -> CallCredentials: ...
@@ -129,12 +129,12 @@ def composite_channel_credentials(
def server(
thread_pool: futures.ThreadPoolExecutor,
handlers: list[GenericRpcHandler[Any, Any]] | None = ...,
interceptors: list[ServerInterceptor[Any, Any]] | None = ...,
options: _Options | None = ...,
maximum_concurrent_rpcs: int | None = ...,
compression: Compression | None = ...,
xds: bool = ...,
handlers: list[GenericRpcHandler[Any, Any]] | None = None,
interceptors: list[ServerInterceptor[Any, Any]] | None = None,
options: _Options | None = None,
maximum_concurrent_rpcs: int | None = None,
compression: Compression | None = None,
xds: bool = False,
) -> Server: ...
# Create Server Credentials:
@@ -143,17 +143,17 @@ _CertificateChainPair: TypeAlias = tuple[bytes, bytes]
def ssl_server_credentials(
private_key_certificate_chain_pairs: list[_CertificateChainPair],
root_certificates: bytes | None = ...,
require_client_auth: bool = ...,
root_certificates: bytes | None = None,
require_client_auth: bool = False,
) -> ServerCredentials: ...
def local_server_credentials(local_connect_type: LocalConnectionType = ...) -> ServerCredentials: ...
def ssl_server_certificate_configuration(
private_key_certificate_chain_pairs: list[_CertificateChainPair], root_certificates: bytes | None = ...
private_key_certificate_chain_pairs: list[_CertificateChainPair], root_certificates: bytes | None = None
) -> ServerCertificateConfiguration: ...
def dynamic_ssl_server_credentials(
initial_certificate_configuration: ServerCertificateConfiguration,
certificate_configuration_fetcher: Callable[[], ServerCertificateConfiguration],
require_client_authentication: bool = ...,
require_client_authentication: bool = False,
) -> ServerCredentials: ...
def alts_server_credentials() -> ServerCredentials: ...
def insecure_server_credentials() -> ServerCredentials: ...
@@ -174,23 +174,23 @@ class _Behaviour(Protocol):
def unary_unary_rpc_method_handler(
behavior: _Behaviour,
request_deserializer: _RequestDeserializer | None = ...,
response_serializer: _ResponseSerializer | None = ...,
request_deserializer: _RequestDeserializer | None = None,
response_serializer: _ResponseSerializer | None = None,
) -> RpcMethodHandler[Any, Any]: ...
def unary_stream_rpc_method_handler(
behavior: _Behaviour,
request_deserializer: _RequestDeserializer | None = ...,
response_serializer: _ResponseSerializer | None = ...,
request_deserializer: _RequestDeserializer | None = None,
response_serializer: _ResponseSerializer | None = None,
) -> RpcMethodHandler[Any, Any]: ...
def stream_unary_rpc_method_handler(
behavior: _Behaviour,
request_deserializer: _RequestDeserializer | None = ...,
response_serializer: _ResponseSerializer | None = ...,
request_deserializer: _RequestDeserializer | None = None,
response_serializer: _ResponseSerializer | None = None,
) -> RpcMethodHandler[Any, Any]: ...
def stream_stream_rpc_method_handler(
behavior: _Behaviour,
request_deserializer: _RequestDeserializer | None = ...,
response_serializer: _ResponseSerializer | None = ...,
request_deserializer: _RequestDeserializer | None = None,
response_serializer: _ResponseSerializer | None = None,
) -> RpcMethodHandler[Any, Any]: ...
def method_handlers_generic_handler(
service: str, method_handlers: dict[str, RpcMethodHandler[Any, Any]]
@@ -248,31 +248,31 @@ class Channel(abc.ABC):
def stream_stream(
self,
method: str,
request_serializer: _RequestSerializer | None = ...,
response_deserializer: _ResponseDeserializer | None = ...,
request_serializer: _RequestSerializer | None = None,
response_deserializer: _ResponseDeserializer | None = None,
) -> StreamStreamMultiCallable[Any, Any]: ...
@abc.abstractmethod
def stream_unary(
self,
method: str,
request_serializer: _RequestSerializer | None = ...,
response_deserializer: _ResponseDeserializer | None = ...,
request_serializer: _RequestSerializer | None = None,
response_deserializer: _ResponseDeserializer | None = None,
) -> StreamUnaryMultiCallable[Any, Any]: ...
@abc.abstractmethod
def subscribe(self, callback: Callable[[ChannelConnectivity], None], try_to_connect: bool = ...) -> None: ...
def subscribe(self, callback: Callable[[ChannelConnectivity], None], try_to_connect: bool = False) -> None: ...
@abc.abstractmethod
def unary_stream(
self,
method: str,
request_serializer: _RequestSerializer | None = ...,
response_deserializer: _ResponseDeserializer | None = ...,
request_serializer: _RequestSerializer | None = None,
response_deserializer: _ResponseDeserializer | None = None,
) -> UnaryStreamMultiCallable[Any, Any]: ...
@abc.abstractmethod
def unary_unary(
self,
method: str,
request_serializer: _RequestSerializer | None = ...,
response_deserializer: _ResponseDeserializer | None = ...,
request_serializer: _RequestSerializer | None = None,
response_deserializer: _ResponseDeserializer | None = None,
) -> UnaryUnaryMultiCallable[Any, Any]: ...
@abc.abstractmethod
def unsubscribe(self, callback: Callable[[ChannelConnectivity], None]) -> None: ...
@@ -303,7 +303,7 @@ 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 wait_for_termination(self, timeout: float | None = None) -> bool: ...
# Authentication & Authorization Objects:
@@ -538,34 +538,31 @@ class UnaryUnaryMultiCallable(abc.ABC, Generic[_TRequest, _TResponse]):
def __call__(
self,
request: _TRequest,
timeout: float | None = ...,
metadata: _Metadata | None = ...,
credentials: CallCredentials | None = ...,
# FIXME: optional bool seems weird, but that's what the docs suggest
wait_for_ready: bool | None = ...,
compression: Compression | None = ...,
timeout: float | None = None,
metadata: _Metadata | None = None,
credentials: CallCredentials | None = None,
wait_for_ready: bool | None = None,
compression: Compression | None = None,
) -> _TResponse: ...
@abc.abstractmethod
def future(
self,
request: _TRequest,
timeout: float | None = ...,
metadata: _Metadata | None = ...,
credentials: CallCredentials | None = ...,
# FIXME: optional bool seems weird, but that's what the docs suggest
wait_for_ready: bool | None = ...,
compression: Compression | None = ...,
timeout: float | None = None,
metadata: _Metadata | None = None,
credentials: CallCredentials | None = None,
wait_for_ready: bool | None = None,
compression: Compression | None = None,
) -> _CallFuture[_TResponse]: ...
@abc.abstractmethod
def with_call(
self,
request: _TRequest,
timeout: float | None = ...,
metadata: _Metadata | None = ...,
credentials: CallCredentials | None = ...,
# FIXME: optional bool seems weird, but that's what the docs suggest
wait_for_ready: bool | None = ...,
compression: Compression | None = ...,
timeout: float | None = None,
metadata: _Metadata | None = None,
credentials: CallCredentials | None = None,
wait_for_ready: bool | None = None,
compression: Compression | None = None,
# FIXME: Return value is documented as "The response value for the RPC and a Call value for the RPC";
# this is slightly unclear so this return type is a best-effort guess.
) -> tuple[_TResponse, Call]: ...
@@ -575,12 +572,11 @@ class UnaryStreamMultiCallable(abc.ABC, Generic[_TRequest, _TResponse]):
def __call__(
self,
request: _TRequest,
timeout: float | None = ...,
metadata: _Metadata | None = ...,
credentials: CallCredentials | None = ...,
# FIXME: optional bool seems weird, but that's what the docs suggest
wait_for_ready: bool | None = ...,
compression: Compression | None = ...,
timeout: float | None = None,
metadata: _Metadata | None = None,
credentials: CallCredentials | None = None,
wait_for_ready: bool | None = None,
compression: Compression | None = None,
) -> _CallIterator[_TResponse]: ...
class StreamUnaryMultiCallable(abc.ABC, Generic[_TRequest, _TResponse]):
@@ -588,34 +584,31 @@ class StreamUnaryMultiCallable(abc.ABC, Generic[_TRequest, _TResponse]):
def __call__(
self,
request_iterator: Iterator[_TRequest],
timeout: float | None = ...,
metadata: _Metadata | None = ...,
credentials: CallCredentials | None = ...,
# FIXME: optional bool seems weird, but that's what the docs suggest
wait_for_ready: bool | None = ...,
compression: Compression | None = ...,
timeout: float | None = None,
metadata: _Metadata | None = None,
credentials: CallCredentials | None = None,
wait_for_ready: bool | None = None,
compression: Compression | None = None,
) -> _TResponse: ...
@abc.abstractmethod
def future(
self,
request_iterator: Iterator[_TRequest],
timeout: float | None = ...,
metadata: _Metadata | None = ...,
credentials: CallCredentials | None = ...,
# FIXME: optional bool seems weird, but that's what the docs suggest
wait_for_ready: bool | None = ...,
compression: Compression | None = ...,
timeout: float | None = None,
metadata: _Metadata | None = None,
credentials: CallCredentials | None = None,
wait_for_ready: bool | None = None,
compression: Compression | None = None,
) -> _CallFuture[_TResponse]: ...
@abc.abstractmethod
def with_call(
self,
request_iterator: Iterator[_TRequest],
timeout: float | None = ...,
metadata: _Metadata | None = ...,
credentials: CallCredentials | None = ...,
# FIXME: optional bool seems weird, but that's what the docs suggest
wait_for_ready: bool | None = ...,
compression: Compression | None = ...,
timeout: float | None = None,
metadata: _Metadata | None = None,
credentials: CallCredentials | None = None,
wait_for_ready: bool | None = None,
compression: Compression | None = None,
# FIXME: Return value is documented as "The response value for the RPC and a Call value for the RPC";
# this is slightly unclear so this return type is a best-effort guess.
) -> tuple[_TResponse, Call]: ...
@@ -625,12 +618,11 @@ class StreamStreamMultiCallable(abc.ABC, Generic[_TRequest, _TResponse]):
def __call__(
self,
request_iterator: Iterator[_TRequest],
timeout: float | None = ...,
metadata: _Metadata | None = ...,
credentials: CallCredentials | None = ...,
# FIXME: optional bool seems weird, but that's what the docs suggest
wait_for_ready: bool | None = ...,
compression: Compression | None = ...,
timeout: float | None = None,
metadata: _Metadata | None = None,
credentials: CallCredentials | None = None,
wait_for_ready: bool | None = None,
compression: Compression | None = None,
) -> _CallIterator[_TResponse]: ...
# Runtime Protobuf Parsing:
+46 -53
View File
@@ -37,12 +37,9 @@ class AioRpcError(RpcError):
code: StatusCode,
initial_metadata: Metadata,
trailing_metadata: Metadata,
details: str | None = ...,
debug_error_string: str | None = ...,
details: str | None = None,
debug_error_string: str | None = None,
) -> None: ...
# FIXME: confirm if these are present in the parent type. The remaining
# methods already exist.
def debug_error_string(self) -> str: ...
def initial_metadata(self) -> Metadata: ...
@@ -52,27 +49,27 @@ class ClientInterceptor(metaclass=abc.ABCMeta): ...
def insecure_channel(
target: str,
options: _Options | None = ...,
compression: Compression | None = ...,
interceptors: Sequence[ClientInterceptor] | None = ...,
options: _Options | None = None,
compression: Compression | None = None,
interceptors: Sequence[ClientInterceptor] | None = None,
) -> Channel: ...
def secure_channel(
target: str,
credentials: ChannelCredentials,
options: _Options | None = ...,
compression: Compression | None = ...,
interceptors: Sequence[ClientInterceptor] | None = ...,
options: _Options | None = None,
compression: Compression | None = None,
interceptors: Sequence[ClientInterceptor] | None = None,
) -> Channel: ...
# Create Server:
def server(
migration_thread_pool: futures.Executor | None = ...,
handlers: Sequence[GenericRpcHandler[Any, Any]] | None = ...,
interceptors: Sequence[ServerInterceptor[Any, Any]] | None = ...,
options: _Options | None = ...,
maximum_concurrent_rpcs: int | None = ...,
compression: Compression | None = ...,
migration_thread_pool: futures.Executor | None = None,
handlers: Sequence[GenericRpcHandler[Any, Any]] | None = None,
interceptors: Sequence[ServerInterceptor[Any, Any]] | None = None,
options: _Options | None = None,
maximum_concurrent_rpcs: int | None = None,
compression: Compression | None = None,
) -> Server: ...
# Channel Object:
@@ -85,38 +82,38 @@ _ResponseDeserializer: TypeAlias = Callable[[bytes], Any]
class Channel(abc.ABC):
@abc.abstractmethod
async def close(self, grace: float | None = ...) -> None: ...
async def close(self, grace: float | None = None) -> None: ...
@abc.abstractmethod
def get_state(self, try_to_connect: bool = ...) -> ChannelConnectivity: ...
def get_state(self, try_to_connect: bool = False) -> ChannelConnectivity: ...
@abc.abstractmethod
async def wait_for_state_change(self, last_observed_state: ChannelConnectivity) -> None: ...
@abc.abstractmethod
def stream_stream(
self,
method: str,
request_serializer: _RequestSerializer | None = ...,
response_deserializer: _ResponseDeserializer | None = ...,
request_serializer: _RequestSerializer | None = None,
response_deserializer: _ResponseDeserializer | None = None,
) -> StreamStreamMultiCallable[Any, Any]: ...
@abc.abstractmethod
def stream_unary(
self,
method: str,
request_serializer: _RequestSerializer | None = ...,
response_deserializer: _ResponseDeserializer | None = ...,
request_serializer: _RequestSerializer | None = None,
response_deserializer: _ResponseDeserializer | None = None,
) -> StreamUnaryMultiCallable[Any, Any]: ...
@abc.abstractmethod
def unary_stream(
self,
method: str,
request_serializer: _RequestSerializer | None = ...,
response_deserializer: _ResponseDeserializer | None = ...,
request_serializer: _RequestSerializer | None = None,
response_deserializer: _ResponseDeserializer | None = None,
) -> UnaryStreamMultiCallable[Any, Any]: ...
@abc.abstractmethod
def unary_unary(
self,
method: str,
request_serializer: _RequestSerializer | None = ...,
response_deserializer: _ResponseDeserializer | None = ...,
request_serializer: _RequestSerializer | None = None,
response_deserializer: _ResponseDeserializer | None = None,
) -> UnaryUnaryMultiCallable[Any, Any]: ...
@abc.abstractmethod
async def __aenter__(self) -> Self: ...
@@ -149,7 +146,7 @@ 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: ...
async def wait_for_termination(self, timeout: float | None = None) -> bool: ...
# Client-Side Context:
@@ -216,7 +213,7 @@ class _DoneCallback(Generic[_TRequest, _TResponse]):
class ServicerContext(Generic[_TRequest, _TResponse], metaclass=abc.ABCMeta):
@abc.abstractmethod
async def abort(self, code: StatusCode, details: str = ..., trailing_metadata: _MetadataType = ...) -> NoReturn: ...
async def abort(self, code: StatusCode, details: str = "", trailing_metadata: _MetadataType = ()) -> NoReturn: ...
@abc.abstractmethod
async def read(self) -> _TRequest: ...
@abc.abstractmethod
@@ -377,12 +374,11 @@ class UnaryUnaryMultiCallable(Generic[_TRequest, _TResponse], metaclass=abc.ABCM
self,
request: _TRequest,
*,
timeout: float | None = ...,
metadata: _MetadataType | None = ...,
credentials: CallCredentials | None = ...,
# FIXME: optional bool seems weird, but that's what the docs suggest
wait_for_ready: bool | None = ...,
compression: Compression | None = ...,
timeout: float | None = None,
metadata: _MetadataType | None = None,
credentials: CallCredentials | None = None,
wait_for_ready: bool | None = None,
compression: Compression | None = None,
) -> UnaryUnaryCall[_TRequest, _TResponse]: ...
class UnaryStreamMultiCallable(Generic[_TRequest, _TResponse], metaclass=abc.ABCMeta):
@@ -391,12 +387,11 @@ class UnaryStreamMultiCallable(Generic[_TRequest, _TResponse], metaclass=abc.ABC
self,
request: _TRequest,
*,
timeout: float | None = ...,
metadata: _MetadataType | None = ...,
credentials: CallCredentials | None = ...,
# FIXME: optional bool seems weird, but that's what the docs suggest
wait_for_ready: bool | None = ...,
compression: Compression | None = ...,
timeout: float | None = None,
metadata: _MetadataType | None = None,
credentials: CallCredentials | None = None,
wait_for_ready: bool | None = None,
compression: Compression | None = None,
) -> UnaryStreamCall[_TRequest, _TResponse]: ...
class StreamUnaryMultiCallable(Generic[_TRequest, _TResponse], metaclass=abc.ABCMeta):
@@ -404,12 +399,11 @@ class StreamUnaryMultiCallable(Generic[_TRequest, _TResponse], metaclass=abc.ABC
def __call__(
self,
request_iterator: AsyncIterator[_TRequest] | Iterator[_TRequest] | None = None,
timeout: float | None = ...,
metadata: _MetadataType | None = ...,
credentials: CallCredentials | None = ...,
# FIXME: optional bool seems weird, but that's what the docs suggest
wait_for_ready: bool | None = ...,
compression: Compression | None = ...,
timeout: float | None = None,
metadata: _MetadataType | None = None,
credentials: CallCredentials | None = None,
wait_for_ready: bool | None = None,
compression: Compression | None = None,
) -> StreamUnaryCall[_TRequest, _TResponse]: ...
class StreamStreamMultiCallable(Generic[_TRequest, _TResponse], metaclass=abc.ABCMeta):
@@ -417,12 +411,11 @@ class StreamStreamMultiCallable(Generic[_TRequest, _TResponse], metaclass=abc.AB
def __call__(
self,
request_iterator: AsyncIterator[_TRequest] | Iterator[_TRequest] | None = None,
timeout: float | None = ...,
metadata: _MetadataType | None = ...,
credentials: CallCredentials | None = ...,
# FIXME: optional bool seems weird, but that's what the docs suggest
wait_for_ready: bool | None = ...,
compression: Compression | None = ...,
timeout: float | None = None,
metadata: _MetadataType | None = None,
credentials: CallCredentials | None = None,
wait_for_ready: bool | None = None,
compression: Compression | None = None,
) -> StreamStreamCall[_TRequest, _TResponse]: ...
# Metadata: