Skip to content

Commit

Permalink
fix: FakeRedisMixin.from_url() return type is really Self. (#305)
Browse files Browse the repository at this point in the history
This fixes issues when you have strongly typed client code using that method.
  • Loading branch information
ben-xo authored Apr 19, 2024
1 parent 87ab329 commit 1ec2939
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fakeredis/_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import weakref
from collections import defaultdict
from typing import Dict, Tuple, Any, List, Optional, Union, Set
from typing_extensions import Self

import redis

Expand Down Expand Up @@ -139,7 +140,7 @@ def __init__(
self, *args: Any,
server: Optional[FakeServer] = None,
version: VersionType = (7,),
lua_modules: Set[str] = None,
lua_modules: Optional[Set[str]] = None,
**kwargs: Any) -> None:
# Interpret the positional and keyword arguments according to the
# version of redis in use.
Expand Down Expand Up @@ -204,7 +205,7 @@ def __init__(
super().__init__(**kwds)

@classmethod
def from_url(cls, *args: Any, **kwargs: Any) -> "FakeRedisMixin":
def from_url(cls, *args: Any, **kwargs: Any) -> Self:
pool = redis.ConnectionPool.from_url(*args, **kwargs)
# Now override how it creates connections
pool.connection_class = FakeConnection
Expand Down

0 comments on commit 1ec2939

Please sign in to comment.