Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redis: "RedisCluster[Any]" has no attribute "zadd"|"zrem"| any other command #9810

Closed
juanamari94 opened this issue Feb 24, 2023 · 1 comment
Labels
topic: redis Issues related to the redis third-party stubs

Comments

@juanamari94
Copy link
Contributor

juanamari94 commented Feb 24, 2023

The latest releases of the async version of RedisCluster for the redis library (i.e: redis.asyncio.cluster) are failing on mypy due to undefined attributes (which do exist in reality):

Steps to reproduce:

  • Install mypy
  • Install types-redis
  • Paste the following code into a file (e.g: main.py):
import asyncio
import string
import random
from redis.asyncio.cluster import RedisCluster


async def future(rc: RedisCluster):
    key = ''.join([random.choice(string.ascii_uppercase) for _ in range(6)])
    field = ''.join([random.choice(string.ascii_uppercase) for _ in range(4)])
    value = random.randint(0, 10)
    await rc.zadd(key, {field: value}, ch=True)
    await rc.zrem(key, field)
    print("Ran for %s -> %s: %s" % (key, field, value))


async def main():
    async with RedisCluster("localhost", 6379) as rc:
        futures = [future(rc) for _ in range(100000)]
        await asyncio.gather(*futures)

asyncio.run(main())
  • Evaluate the code with mypy: mypy main.py
  • Output will be:
$ mypy redis_test.py                                                                                                                                                                                                
redis_test.py:11: error: "RedisCluster[Any]" has no attribute "zadd"  [attr-defined]
redis_test.py:12: error: "RedisCluster[Any]" has no attribute "zrem"  [attr-defined]
Found 2 errors in 1 file (checked 1 source file)
@AlexWaygood AlexWaygood added the topic: redis Issues related to the redis third-party stubs label Jul 8, 2023
@srittau
Copy link
Collaborator

srittau commented Aug 1, 2024

The redis stubs are scheduled for removal (see #10592) and only support redis 4. While we still accept contributions, I'm closing this issue now for housekeeping purposes. Improvements to the types of redis 5 should be directed to the redis-py repository.

@srittau srittau closed this as not planned Won't fix, can't repro, duplicate, stale Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: redis Issues related to the redis third-party stubs
Projects
None yet
Development

No branches or pull requests

3 participants