You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The type hint for the scan method in the Redis Python library appears to be incorrect or overly broad. While the method is used in sync mode, the type hint suggests that it can return an Awaitable[Any] | Any, causing issues when using type-checking tools like mypy.
In practice, when using the sync mode, the scan method reliably returns a tuple[int, list[str]] as per the Redis documentation and behavior. However, the current type hint does not accurately reflect this.
Environment
Redis Python Version: 5.2.0
Python Version: 3.12.1
Operating System: Mac
Steps to Reproduce
Use the scan method in sync mode with a Redis client.
Assign the result to a variable with the expected type tuple[int, list[str]].
Description
The type hint for the
scan
method in the Redis Python library appears to be incorrect or overly broad. While the method is used in sync mode, the type hint suggests that it can return anAwaitable[Any] | Any
, causing issues when using type-checking tools likemypy
.In practice, when using the sync mode, the
scan
method reliably returns atuple[int, list[str]]
as per the Redis documentation and behavior. However, the current type hint does not accurately reflect this.Environment
5.2.0
3.12.1
Mac
Steps to Reproduce
scan
method in sync mode with a Redis client.tuple[int, list[str]]
.mypy
type-checking on the code.mypy
error.Example Code
Expected Behavior
When using the
scan
method in sync mode, the type should be annotated as:This aligns with the Redis documentation and avoids unnecessary type-checking errors when using tools like
mypy
.Current Behavior
The current type hint in the Redis Python library annotates the return value as:
This causes
mypy
to raise errors when thescan
method is used in a synchronous context. For example:The above snippet results in the following error from
mypy
:The text was updated successfully, but these errors were encountered: