From 1ec2939c83625209fbadc963dc72e97bee2bb47a Mon Sep 17 00:00:00 2001 From: Ben XO <75862+ben-xo@users.noreply.github.com> Date: Fri, 19 Apr 2024 21:08:00 +0100 Subject: [PATCH] fix: FakeRedisMixin.from_url() return type is really Self. (#305) This fixes issues when you have strongly typed client code using that method. --- fakeredis/_server.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fakeredis/_server.py b/fakeredis/_server.py index 46216a27..f084711d 100644 --- a/fakeredis/_server.py +++ b/fakeredis/_server.py @@ -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 @@ -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. @@ -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