aio-libs-abandoned/aioredis-py

TypeError: duplicate base class TimeoutError

farahats9 opened this issue · 2 comments

Describe the bug

When trying to import aioredis in Python 3.11 an error is raised

To Reproduce

1- use python 3.11
2- try to import aioredis
3- this error is raised:

>>> import aioredis
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".venv/lib64/python3.11/site-packages/aioredis/__init__.py", line 1, in <module>
    from aioredis.client import Redis, StrictRedis
  File ".venv/lib64/python3.11/site-packages/aioredis/client.py", line 32, in <module>
    from aioredis.connection import (
  File ".venv/lib64/python3.11/site-packages/aioredis/connection.py", line 33, in <module>
    from .exceptions import (
  File ".venv/lib64/python3.11/site-packages/aioredis/exceptions.py", line 14, in <module>
    class TimeoutError(asyncio.TimeoutError, builtins.TimeoutError, RedisError):
TypeError: duplicate base class TimeoutError

Expected behavior

it should import correctly without errors. I think the problem is in aioredis/exceptions.py#L14

class TimeoutError(asyncio.TimeoutError, builtins.TimeoutError, RedisError):
    pass

The asyncio.TimeoutError is inheriting from builtins.TimeoutError and they are both used as base classes which python doesn't like.

Logs/tracebacks

already added above

Python Version

$ python --version
3.11.0

aioredis Version

$ python -m pip show aioredis
Name: aioredis
Version: 2.0.1
Summary: asyncio (PEP 3156) Redis support
Home-page: https://github.com/aio-libs/aioredis-py
Author: 
Author-email: 
License: MIT
Location: /mnt/d/dev/python/smsarko/smsarko-fastapi/.venvl/lib64/python3.11/site-packages
Requires: async-timeout, typing-extensions
Required-by:

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct

Aioredis is now in redis-py 4.2.0rc1+

To install, just do pip install redis>=4.2.0rc1. The code is almost the exact same. You will just need to import like so:
from redis import asyncio as aioredis

This way you don't have to change all your code, just the imports.

Aioredis is now in redis-py 4.2.0rc1+

To install, just do pip install redis>=4.2.0rc1. The code is almost the exact same. You will just need to import like so: from redis import asyncio as aioredis

This way you don't have to change all your code, just the imports.

Thanks, that worked!

Had the described problem because of fastapi-mail dependency.

Added redis>=4.2.0rc1 to requirements.txt.

Also, created aioredis.py in app's root folder containing
from redis.asyncio import *