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

No module named 'redis.commands' #121

Closed diman82 closed 1 year ago

diman82 commented 1 year ago

Describe the bug Using latest version of the package 2.7.1, I get the following error:

`ERROR: tests.test_custom_xcom (nose2.loader.ModuleImportFailure)

ImportError: Failed to import test module: tests.test_custom_xcom Traceback (most recent call last): File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/nose2/plugins/loader/discovery.py", line 204, in _find_tests_in_file module = util.module_from_name(module_name) File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/nose2/util.py", line 76, in module_from_name import(name) File "/home/runner/work/data-management-airflow-2/data-management-airflow-2/tests/test_custom_xcom.py", line 7, in import fakeredis File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/fakeredis/init.py", line 1, in from ._server import FakeServer, FakeRedis, FakeStrictRedis, FakeConnection, FakeRedisConnSingleton File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/fakeredis/_server.py", line 12, in from fakeredis._fakesocket import FakeSocket File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/fakeredis/_fakesocket.py", line 1, in from fakeredis.stack import JSONCommandsMixin File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/fakeredis/stack/init.py", line 7, in raise e File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/fakeredis/stack/init.py", line 3, in from redis.commands.json.path import Path # noqa: F401 ModuleNotFoundError: No module named 'redis.commands'`

To Reproduce Steps to reproduce the behavior:

  1. import fakeredis module

Expected behavior sub-dependency module is correctly imported

Desktop (please complete the following information):

Additional context having latest apache-airflow-providers-redis package, which installs redis==3.5.3

cunla commented 1 year ago

Are you using json module?

cunla commented 1 year ago

Hi, In version 2.0.0 support for redis-py < 4 was removed.

However, you are using redis-py version: 2.7.1 while the apache-airflow-providers-redis package requires redis-py ~3.2.

I can update fakeredis so you won't get this exception, but you won't be able to use JSON commands.

diman82 commented 1 year ago

@cunla Yes, please update fakeredis library, IMHO the best would be to convert this exception to warning

cunla commented 1 year ago

Fixed, will be in next version

diman82 commented 1 year ago

@cunla When approximately should we expect the new version?

hyeongguen-song commented 1 year ago

@diman82 , cunla just released a new version

diman82 commented 1 year ago

@cunla @hyeongguen-song Confriming issue has been resolved