Skip to content

Some functions have wrong return types #3091

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

Closed
ykun91 opened this issue Dec 25, 2023 · 4 comments
Closed

Some functions have wrong return types #3091

ykun91 opened this issue Dec 25, 2023 · 4 comments

Comments

@ykun91
Copy link

ykun91 commented Dec 25, 2023

Thanks for wanting to report an issue you've found in redis-py. Please delete this text and fill in the template below.
It is of course not always possible to reduce your code to a small test case, but it's highly appreciated to have as much data as possible. Thank you!

Version: What redis-py and what redis version is the issue happening on?
redis-py: 5.0.1
redis: 7.2.3

Platform: What platform / version? (For example Python 3.5.1 on Windows 7 / Ubuntu 15.10 / Azure)
Python 3.11 on Ubuntu

Description:
Some functions have wrong return types.
like hget in here, it was typed as Union[Awaitable[Optional[str]], Optional[str]]
but I don't think it is Awaitable as it isn't a async function, and it return bytes actually, not str.
Same issue may found in other functions.

@aryaniyaps
Copy link

any updates on this issue?

@ykun91
Copy link
Author

ykun91 commented Jan 22, 2024

FYI

Install types-redis (https://pypi.org/project/types-redis/) can be a workaround, as types in it is more accurate.

also there is a note in the description

Note: Redis-py 5.0.0 added a py.typed file, but the inline annotations are incomplete. Continuing to use types-redis for the time being may lead to superior results.

So it seems that the redis team already know that the embedded type hints are incomplete :D

@ykun91
Copy link
Author

ykun91 commented May 30, 2024

#2399

@MaffooBristol
Copy link

I've noticed that since upgrading py-redis from v4 to v5, it now enforces that we pass a string into a hash rather than bytes or anything else. However types-redis with v5 seems to undo this somewhat, saying the output of hget() is Unknown | None. I can't work out which option is the better of two evils...

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

3 participants