Skip to content

Commit

Permalink
Update ResponseT type alias (#3227)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
willfrey authored May 20, 2024
1 parent 6751de2 commit cefc36e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion redis/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cefc36e

Please sign in to comment.