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
298 stars 48 forks source link

scan_iter() with type filter asserts when there is a stream key #233

Closed mjessome closed 1 year ago

mjessome commented 1 year ago

Describe the bug I'm on fakeredis-py 2.18.0

When a stream exists, and using scan_iter(_type='XXX'), we hit the following assert:

key = <fakeredis._commands.Item object at 0x10feaad40>

    def key_value_type(key):
        if key.value is None:
            return SimpleString(b'none')
        elif isinstance(key.value, bytes):
            return SimpleString(b'string')
        elif isinstance(key.value, list):
            return SimpleString(b'list')
        elif isinstance(key.value, set):
            return SimpleString(b'set')
        elif isinstance(key.value, ZSet):
            return SimpleString(b'zset')
        elif isinstance(key.value, dict):
            return SimpleString(b'hash')
        else:
>           assert False  # pragma: nocover
E           AssertionError

To Reproduce

from fakeredis import FakeRedis

r = FakeRedis()

r.xadd("mystream", { "test": "value" })
for s in r.scan_iter(_type="STRING"):
    print(s)

Expected behavior

Doesn't assert, Stream keys are enumerated (or filtered out) just like any other key.

Desktop (please complete the following information):

Additional context

Thank you!