From bf096ed145b66c26d29dc0c25bb477604c291461 Mon Sep 17 00:00:00 2001 From: Islam Alibekov Date: Wed, 14 May 2025 23:09:31 +0300 Subject: [PATCH] feat(CLOUDAPI-1046): Improve client method typing with TypeVar --- yandexcloud/_sdk.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/yandexcloud/_sdk.py b/yandexcloud/_sdk.py index 6e507953..8f5feda8 100644 --- a/yandexcloud/_sdk.py +++ b/yandexcloud/_sdk.py @@ -1,11 +1,13 @@ import inspect -from typing import TYPE_CHECKING, Any, Dict, Optional, Type, Union +from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Type, TypeVar, Union import grpc from yandexcloud import _channels, _helpers, _operation_waiter, _retry_policy from yandexcloud._wrappers import Wrappers +Client = TypeVar("Client") + if TYPE_CHECKING: import logging @@ -70,7 +72,7 @@ def __init__( def client( self, - stub_ctor: Type, + stub_ctor: Callable[[Any], Client], interceptor: Union[ grpc.UnaryUnaryClientInterceptor, grpc.UnaryStreamClientInterceptor, @@ -80,7 +82,7 @@ def client( ] = None, endpoint: Optional[str] = None, insecure: bool = False, - ) -> Any: + ) -> Client: service = _service_for_ctor(stub_ctor) channel = self._channels.channel(service, endpoint, insecure) if interceptor is not None: