Skip to content

Commit 4b1c508

Browse files
willfreygerzse
authored andcommitted
Update ResponseT type alias (#3227)
Pyright treats explicit and implicit `Any` differently, with implicit `Any` being treated as `Unknown`. Pyright raised a warning indicating an unknown member type for 'Awaitable' when used in 'ResponseT'. Using the `incr` method as an example, the warning is: ``` "warning: Type of 'incr' is partially unknown Type of 'incr' is '(name: bytes | str | memoryview, amount: int = 1) -> (Awaitable[Unknown] | Any)' (reportUnknownMemberType)" ``` By explicitly specifying 'Awaitable[Any]' in the union for 'ResponseT', this resolves the ambiguity about the member type.
1 parent c35eb96 commit 4b1c508

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

CHANGES

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* Update `ResponseT` type hint
12
* Allow to control the minimum SSL version
23
* Add an optional lock_name attribute to LockError.
34
* Fix return types for `get`, `set_path` and `strappend` in JSONCommands

redis/commands/core.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import warnings
66
from typing import (
77
TYPE_CHECKING,
8-
Any,
98
AsyncIterator,
109
Awaitable,
1110
Callable,
@@ -37,6 +36,7 @@
3736
KeysT,
3837
KeyT,
3938
PatternT,
39+
ResponseT,
4040
ScriptTextT,
4141
StreamIdT,
4242
TimeoutSecT,
@@ -49,8 +49,6 @@
4949
from redis.asyncio.client import Redis as AsyncRedis
5050
from redis.client import Redis
5151

52-
ResponseT = Union[Awaitable, Any]
53-
5452

5553
class ACLCommands(CommandsProtocol):
5654
"""

redis/typing.py

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
PatternT = _StringLikeT # Patterns matched against keys, fields etc
3434
FieldT = EncodableT # Fields within hash tables, streams and geo commands
3535
KeysT = Union[KeyT, Iterable[KeyT]]
36+
ResponseT = Union[Awaitable[Any], Any]
3637
ChannelT = _StringLikeT
3738
GroupT = _StringLikeT # Consumer group
3839
ConsumerT = _StringLikeT # Consumer name

0 commit comments

Comments
 (0)