|
31 | 31 | Set, |
32 | 32 | Tuple, |
33 | 33 | Union, |
| 34 | + overload, |
34 | 35 | ) |
35 | 36 |
|
36 | 37 | from redis.asyncio.observability.recorder import ( |
|
40 | 41 | from redis.typing import ( |
41 | 42 | AbsExpiryT, |
42 | 43 | AnyKeyT, |
| 44 | + AsyncClientProtocol, |
43 | 45 | BitfieldOffsetT, |
44 | 46 | ChannelT, |
45 | 47 | CommandsProtocol, |
|
55 | 57 | ResponseT, |
56 | 58 | ScriptTextT, |
57 | 59 | StreamIdT, |
| 60 | + SyncClientProtocol, |
58 | 61 | TimeoutSecT, |
59 | 62 | ZScoreBoundT, |
60 | 63 | ) |
@@ -2064,6 +2067,15 @@ def digest(self, name: KeyT) -> Union[str, bytes, None]: |
2064 | 2067 | # Bulk string response is already handled (bytes/str based on decode_responses) |
2065 | 2068 | return self.execute_command("DIGEST", name) |
2066 | 2069 |
|
| 2070 | + # --- @overload pattern for get() --- |
| 2071 | + # Sync client returns bytes | None directly |
| 2072 | + @overload |
| 2073 | + def get(self: SyncClientProtocol, name: KeyT) -> Optional[bytes]: ... |
| 2074 | + |
| 2075 | + # Async client returns Awaitable[bytes | None] |
| 2076 | + @overload |
| 2077 | + def get(self: AsyncClientProtocol, name: KeyT) -> Awaitable[Optional[bytes]]: ... |
| 2078 | + |
2067 | 2079 | def get(self, name: KeyT) -> ResponseT: |
2068 | 2080 | """ |
2069 | 2081 | Return the value at key ``name``, or None if the key doesn't exist |
@@ -2554,6 +2566,47 @@ def restore( |
2554 | 2566 |
|
2555 | 2567 | return self.execute_command("RESTORE", *params) |
2556 | 2568 |
|
| 2569 | + # --- @overload pattern for set() --- |
| 2570 | + # Sync client returns bool | None directly |
| 2571 | + @overload |
| 2572 | + def set( |
| 2573 | + self: SyncClientProtocol, |
| 2574 | + name: KeyT, |
| 2575 | + value: EncodableT, |
| 2576 | + ex: Optional[ExpiryT] = ..., |
| 2577 | + px: Optional[ExpiryT] = ..., |
| 2578 | + nx: bool = ..., |
| 2579 | + xx: bool = ..., |
| 2580 | + keepttl: bool = ..., |
| 2581 | + get: bool = ..., |
| 2582 | + exat: Optional[AbsExpiryT] = ..., |
| 2583 | + pxat: Optional[AbsExpiryT] = ..., |
| 2584 | + ifeq: Optional[Union[bytes, str]] = ..., |
| 2585 | + ifne: Optional[Union[bytes, str]] = ..., |
| 2586 | + ifdeq: Optional[str] = ..., |
| 2587 | + ifdne: Optional[str] = ..., |
| 2588 | + ) -> Optional[bool]: ... |
| 2589 | + |
| 2590 | + # Async client returns Awaitable[bool | None] |
| 2591 | + @overload |
| 2592 | + def set( |
| 2593 | + self: AsyncClientProtocol, |
| 2594 | + name: KeyT, |
| 2595 | + value: EncodableT, |
| 2596 | + ex: Optional[ExpiryT] = ..., |
| 2597 | + px: Optional[ExpiryT] = ..., |
| 2598 | + nx: bool = ..., |
| 2599 | + xx: bool = ..., |
| 2600 | + keepttl: bool = ..., |
| 2601 | + get: bool = ..., |
| 2602 | + exat: Optional[AbsExpiryT] = ..., |
| 2603 | + pxat: Optional[AbsExpiryT] = ..., |
| 2604 | + ifeq: Optional[Union[bytes, str]] = ..., |
| 2605 | + ifne: Optional[Union[bytes, str]] = ..., |
| 2606 | + ifdeq: Optional[str] = ..., |
| 2607 | + ifdne: Optional[str] = ..., |
| 2608 | + ) -> Awaitable[Optional[bool]]: ... |
| 2609 | + |
2557 | 2610 | @experimental_args(["ifeq", "ifne", "ifdeq", "ifdne"]) |
2558 | 2611 | def set( |
2559 | 2612 | self, |
|
0 commit comments