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

ResponseT shouldn't be async when using sync Redis class #3497

Open
patrick91 opened this issue Feb 3, 2025 · 1 comment
Open

ResponseT shouldn't be async when using sync Redis class #3497

patrick91 opened this issue Feb 3, 2025 · 1 comment

Comments

@patrick91
Copy link
Contributor

This code here:

from typing import reveal_type

from redis import Redis

redis = Redis(host="localhost", port=6379, db=0)

redis.set("test", "Hello, World!")

reveal_type(redis.get("test"))

Shows:

Revealed type is "Union[typing.Awaitable[Any], Any]"

Which I think is wrong, since the return type should be Any instead[1], right?

I think we might separate ResponseT for Redis and async Redis, what do you think?

I haven't sent a PR for this, because it will touch quite a few files, so I wanted to double check with you all first 😊

[1] We should allow using generics for return types, but that's another issue 😊

@vladvildanov
Copy link
Collaborator

@patrick91 Hey, thanks for reaching out! The problem is that both of clients sync and async uses the same RedisCommands class that define an API of commands itself, that's why it generic to satisfy both

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants