From 9c9853967dc376a66b5475647b1bd50e060f210f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Fri, 12 Nov 2021 12:23:12 +0100 Subject: [PATCH] Redis Sentinel master_for, slave_for returns a Redis client (#6269) --- stubs/redis/redis/sentinel.pyi | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/stubs/redis/redis/sentinel.pyi b/stubs/redis/redis/sentinel.pyi index 5ca32d666..5b72e2646 100644 --- a/stubs/redis/redis/sentinel.pyi +++ b/stubs/redis/redis/sentinel.pyi @@ -1,8 +1,11 @@ -from typing import Any +from typing import Any, Type, TypeVar, overload +from redis.client import Redis from redis.connection import Connection, ConnectionPool from redis.exceptions import ConnectionError +_Redis = TypeVar("_Redis", bound=Redis[Any]) + class MasterNotFoundError(ConnectionError): ... class SlaveNotFoundError(ConnectionError): ... @@ -39,5 +42,11 @@ class Sentinel(object): def discover_master(self, service_name): ... def filter_slaves(self, slaves): ... def discover_slaves(self, service_name): ... - def master_for(self, service_name, redis_class=..., connection_pool_class=..., **kwargs) -> None: ... - def slave_for(self, service_name, redis_class=..., connection_pool_class=..., **kwargs) -> None: ... + @overload + def master_for(self, service_name: str, *, connection_pool_class=..., **kwargs) -> Redis[Any]: ... + @overload + def master_for(self, service_name: str, redis_class: Type[_Redis] = ..., connection_pool_class=..., **kwargs) -> _Redis: ... + @overload + def slave_for(self, service_name: str, connection_pool_class=..., **kwargs) -> Redis[Any]: ... + @overload + def slave_for(self, service_name: str, redis_class: Type[_Redis] = ..., connection_pool_class=..., **kwargs) -> _Redis: ...