cunla / fakeredis-py

Implementation of Redis in python without having a Redis server running. Fully compatible with using redis-py.
https://fakeredis.moransoftware.ca/
BSD 3-Clause "New" or "Revised" License
299 stars 49 forks source link

2.25.0: TypeError: FakeBaseConnectionMixin.__init__() missing 2 required keyword-only arguments: 'version' and 'server_type' #334

Closed 9128305 closed 1 month ago

9128305 commented 1 month ago

Describe the bug Hi, this combination of dependencies is working:

django-redis                  5.4.0
fakeredis                     2.24.1
hiredis                       3.0.0
redis                         5.1.0

fakeredis 2.25.0 breaks my django tests with the following error:

TypeError: FakeBaseConnectionMixin.__init__() missing 2 required keyword-only arguments: 'version' and 'server_type'

To Reproduce

from django.core.cache import caches
caches['default'].get('key')

Traceback:

.venv/lib/python3.11/site-packages/django_redis/cache.py:92: in get
    value = self._get(key, default, version, client)
.venv/lib/python3.11/site-packages/django_redis/cache.py:29: in _decorator
    return method(self, *args, **kwargs)
.venv/lib/python3.11/site-packages/django_redis/cache.py:99: in _get
    return self.client.get(key, default=default, version=version, client=client)
.venv/lib/python3.11/site-packages/django_redis/client/default.py:258: in get
    value = client.get(key)
.venv/lib/python3.11/site-packages/redis/commands/core.py:1822: in get
    return self.execute_command("GET", name, keys=[name])
.venv/lib/python3.11/site-packages/redis/client.py:559: in execute_command
    return self._execute_command(*args, **options)
.venv/lib/python3.11/site-packages/redis/client.py:565: in _execute_command
    conn = self.connection or pool.get_connection(command_name, **options)
.venv/lib/python3.11/site-packages/redis/connection.py:1418: in get_connection
    connection = self.make_connection()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <[TypeError("FakeBaseConnectionMixin.__init__() missing 2 required keyword-only arguments: 'version' and 'server_type'") raised in repr()] ConnectionPool object at 0x7ebef80ed9d0>

    def make_connection(self) -> "ConnectionInterface":
        "Create a new connection"
        if self._created_connections >= self.max_connections:
            raise ConnectionError("Too many connections")
        self._created_connections += 1

        if self.cache is not None:
            return CacheProxyConnection(
                self.connection_class(**self.connection_kwargs), self.cache, self._lock
            )

>       return self.connection_class(**self.connection_kwargs)
E       TypeError: FakeBaseConnectionMixin.__init__() missing 2 required keyword-only arguments: 'version' and 'server_type'

.venv/lib/python3.11/site-packages/redis/connection.py:1464: TypeError

Minimal reproducer:

import redis
from fakeredis import FakeConnection

client = redis.Redis(connection_pool=redis.ConnectionPool(connection_class=FakeConnection))

client.get('key')

Expected behavior No errors

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

Upvote & Fund

Fund with Polar

cunla commented 1 month ago

Thanks for reporting this. I'll address this shortly