Skip to content

Commit 7ed8c5b

Browse files
Fix: type hints on from_url
1 parent c620503 commit 7ed8c5b

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

redis/asyncio/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def from_url(
131131
single_connection_client: bool = False,
132132
auto_close_connection_pool: Optional[bool] = None,
133133
**kwargs,
134-
):
134+
) -> "Redis":
135135
"""
136136
Return a Redis client object configured from the given URL
137137

redis/asyncio/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from typing import TYPE_CHECKING
1+
from typing import TYPE_CHECKING, Any
22

33
if TYPE_CHECKING:
44
from redis.asyncio.client import Pipeline, Redis
55

66

7-
def from_url(url, **kwargs):
7+
def from_url(url: str, **kwargs: Any) -> "Redis":
88
"""
99
Returns an active Redis client generated from the given database URL.
1010

redis/cluster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ def replace_default_node(self, target_node: "ClusterNode" = None) -> None:
460460

461461
class RedisCluster(AbstractRedisCluster, RedisClusterCommands):
462462
@classmethod
463-
def from_url(cls, url, **kwargs):
463+
def from_url(cls, url: str, **kwargs: Any) -> "RedisCluster":
464464
"""
465465
Return a Redis client object configured from the given URL
466466

redis/utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
from collections.abc import Callable
66
from contextlib import contextmanager
77
from functools import wraps
8-
from typing import Any, Dict, List, Mapping, Optional, TypeVar, Union
8+
from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, TypeVar, Union
99

1010
from redis.exceptions import DataError
1111
from redis.typing import AbsExpiryT, EncodableT, ExpiryT
1212

13+
if TYPE_CHECKING:
14+
from redis.client import Redis
15+
1316
try:
1417
import hiredis # noqa
1518

@@ -40,7 +43,7 @@
4043
from importlib import metadata
4144

4245

43-
def from_url(url, **kwargs):
46+
def from_url(url: str, **kwargs: Any) -> "Redis":
4447
"""
4548
Returns an active Redis client generated from the given database URL.
4649

0 commit comments

Comments
 (0)