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

Unexpected typecheck failures with redis.asyncio type stubs #7837

Closed
achimnol opened this issue May 15, 2022 · 6 comments
Closed

Unexpected typecheck failures with redis.asyncio type stubs #7837

achimnol opened this issue May 15, 2022 · 6 comments
Labels
stubs: false positive Type checkers report false errors

Comments

@achimnol
Copy link

achimnol commented May 15, 2022

tests/test_redis_storage.py:21: error: Missing type parameters for generic type "Redis"  [type-arg]
tests/test_redis_storage.py:34: error: Missing type parameters for generic type "Redis"  [type-arg]
tests/test_redis_storage.py:39: error: Incompatible types in "await" (actual type "Optional[bool]", expected type "Awaitable[Any]")  [misc]
tests/test_redis_storage.py:43: error: Missing type parameters for generic type "Redis"  [type-arg]
tests/test_redis_storage.py:45: error: Incompatible types in "await" (actual type "Optional[bool]", expected type "Awaitable[Any]")  [misc]
tests/test_redis_storage.py:49: error: Missing type parameters for generic type "Redis"  [type-arg]
tests/test_redis_storage.py:52: error: Incompatible types in "await" (actual type "Optional[Any]", expected type "Awaitable[Any]")  [misc]
...

Happens with:

  • Python 3.10.4
  • mypy 0.950
  • redis 4.3.1
  • types-redis 4.2.2
  • a code that replaced import aioredis with from redis import asyncio as aioredis (ghaction check result)

All the related codes run fine at runtime.

@Akuli
Copy link
Collaborator

Akuli commented May 15, 2022

All of your errors are explained here: #7597 (comment)

@AlexWaygood
Copy link
Member

@achimnol, do you still get false-positive errors with the latest redis stubs now that #7820 has been merged?

@AlexWaygood AlexWaygood added the stubs: false positive Type checkers report false errors label Jun 12, 2022
@achimnol
Copy link
Author

I've updated types-redis to 4.2.3 and running mypy still gives:

$ python -m mypy aiohttp_session
aiohttp_session/redis_storage.py:62: error: Incompatible types in "await" (actual type "Optional[bytes]", expected type "Awaitable[Any]")  [misc]
aiohttp_session/redis_storage.py:87: error: Incompatible types in "await" (actual type "Optional[bool]", expected type "Awaitable[Any]")  [misc]
Found 2 errors in 1 file (checked 6 source files)

@achimnol
Copy link
Author

With types-redis 4.3.1, it says:

$ python -m mypy aiohttp_session
aiohttp_session/redis_storage.py:65: error: Incompatible types in assignment (expression has type "str", variable has type "Optional[bytes]")  [assignment]
aiohttp_session/redis_storage.py:67: error: Argument 1 has incompatible type "bytes"; expected "str"  [arg-type]
aiohttp_session/redis_storage.py:70: error: Argument "data" to "Session" has incompatible type "Optional[bytes]"; expected "Optional[SessionData]"  [arg-type]
Found 3 errors in 1 file (checked 6 source files)

@achimnol
Copy link
Author

Ah, I could fix the above type errors in the aiohttp-session side.
Now it seems that everything is ok!

@AlexWaygood
Copy link
Member

Ah, I could fix the above type errors in the aiohttp-session side.
Now it seems that everything is ok!

Brilliant, thanks for checking!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stubs: false positive Type checkers report false errors
Projects
None yet
Development

No branches or pull requests

3 participants