Skip to content

Commit 432b108

Browse files
committed
Add return type annotations to from_url methods
- Add return type annotation to Redis.from_url() in client.py - Add parameter and return type annotations to utils.from_url() - Improves type safety and IDE autocomplete support - Resolves MyPy no-untyped-call errors for users
1 parent f3806fa commit 432b108

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

redis/asyncio/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ class Redis(
126126

127127
@classmethod
128128
def from_url(
129-
cls,
129+
cls: type[_RedisT],
130130
url: str,
131131
single_connection_client: bool = False,
132132
auto_close_connection_pool: Optional[bool] = None,
133133
**kwargs,
134-
):
134+
) -> _RedisT:
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 Any, TYPE_CHECKING
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

0 commit comments

Comments
 (0)