Skip to content

Commit

Permalink
Add types to ConnectionPool.from_url (#3495)
Browse files Browse the repository at this point in the history
Co-authored-by: Vladyslav Vildanov <[email protected]>
  • Loading branch information
patrick91 and vladvildanov authored Feb 4, 2025
1 parent b7d4c48 commit d989bcc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions redis/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from itertools import chain
from queue import Empty, Full, LifoQueue
from time import time
from typing import Any, Callable, Dict, List, Optional, Type, Union
from typing import Any, Callable, Dict, List, Optional, Type, TypeVar, Union
from urllib.parse import parse_qs, unquote, urlparse

from redis.cache import (
Expand Down Expand Up @@ -1263,6 +1263,9 @@ def parse_url(url):
return kwargs


_CP = TypeVar("_CP", bound="ConnectionPool")


class ConnectionPool:
"""
Create a connection pool. ``If max_connections`` is set, then this
Expand All @@ -1278,7 +1281,7 @@ class ConnectionPool:
"""

@classmethod
def from_url(cls, url, **kwargs):
def from_url(cls: Type[_CP], url: str, **kwargs) -> _CP:
"""
Return a connection pool configured from the given URL.
Expand Down

0 comments on commit d989bcc

Please sign in to comment.