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

Upgrade Redis stubs to 4.2.x #7597

Closed
Ankhas opened this issue Apr 6, 2022 · 5 comments · Fixed by #7675 or #7676
Closed

Upgrade Redis stubs to 4.2.x #7597

Ankhas opened this issue Apr 6, 2022 · 5 comments · Fixed by #7675 or #7676

Comments

@Ankhas
Copy link

Ankhas commented Apr 6, 2022

The redis-py package has been updated to 4.2.2 : https://github.com/redis/redis-py/releases/tag/v4.2.2 and currently stubs are in version 4.1.*

@kovalevvlad
Copy link

A big change here and the reason why I upvoted is the addition of asyncio

@AlexWaygood
Copy link
Member

AlexWaygood commented Apr 8, 2022

Thanks — PR welcome!

@srittau
Copy link
Collaborator

srittau commented Apr 24, 2022

#7675 didn't add async support. Reopening.

@squaresmile
Copy link

Thank you for the updated redis typing. 2 things I noticed with the new types:

from redis.asyncio import Redis 

async def func(redis: Redis, redis_key: str): # 1
    return await redis.get(redis_key)         # 2
  • 1 leads to mypy error Missing type parameters for generic type while TypeError: <class 'redis.asyncio.client.Redis'> is not a generic class.
  • 2 leads to Incompatible types in "await" (actual type "Optional[Any]", expected type "Awaitable[Any]").

@srittau
Copy link
Collaborator

srittau commented May 4, 2022

(1) is a general problem with types that are generic for type checking purposes, but not at runtime. Use:

async def func(redis: "Redis[Any]", redis_key: str):  # or even better Redis[str] or Redis[bytes]

Alternatively, if you want to leave out the quotes, use from __future__ import annotations.

python/typing#307 would also help with that.

(2) I think we will need to override all Redis commands in the corresponding classes accordingly. This is quite a big task, but all PRs are welcome.

sileht added a commit to sileht/typeshed that referenced this issue May 10, 2022
redis-py has introduced an asyncio module since 4.2 and almost all
commands should be async if the redis.asyncio.Redis is used instead of
redis.Redis.

This changes adds the types for all core commands.

Related to python#7597
sileht added a commit to sileht/typeshed that referenced this issue May 10, 2022
redis-py has introduced an asyncio module since 4.2 and almost all
commands should be async if the redis.asyncio.Redis is used instead of
redis.Redis.

This changes adds the types for all core commands.

Related to python#7597
JelleZijlstra pushed a commit that referenced this issue May 19, 2022
redis-py has introduced an asyncio module since 4.2 and almost all
commands should be async if the redis.asyncio.Redis is used instead of
redis.Redis.

This changes adds the types for all core commands.

Related to #7597
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants