From cefc36ef9360fb730025087ef359d676991fd96d Mon Sep 17 00:00:00 2001 From: Will Frey Date: Mon, 20 May 2024 23:44:46 +0900 Subject: [PATCH] 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. --- CHANGES | 1 + redis/typing.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index e0959b0ef3..82c5b6db2a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,4 @@ + * Update `ResponseT` type hint * Allow to control the minimum SSL version * Add an optional lock_name attribute to LockError. * Fix return types for `get`, `set_path` and `strappend` in JSONCommands diff --git a/redis/typing.py b/redis/typing.py index 838219fbb6..ee4296245f 100644 --- a/redis/typing.py +++ b/redis/typing.py @@ -32,7 +32,7 @@ PatternT = _StringLikeT # Patterns matched against keys, fields etc FieldT = EncodableT # Fields within hash tables, streams and geo commands KeysT = Union[KeyT, Iterable[KeyT]] -ResponseT = Union[Awaitable, Any] +ResponseT = Union[Awaitable[Any], Any] ChannelT = _StringLikeT GroupT = _StringLikeT # Consumer group ConsumerT = _StringLikeT # Consumer name