Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5a3b6c7

Browse files
authored
Fix redis stub hset() to allow only providing mapping (#5168)
* Fix redis stub hset() to allow only providing mapping * Fix redis stub hset() and hmset() mapping type
1 parent ef9b37e commit 5a3b6c7

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

stubs/redis/redis/client.pyi

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -729,11 +729,14 @@ class Redis(Generic[_StrType]):
729729
def hincrbyfloat(self, name: _Key, key: _Key, amount: float = ...) -> float: ...
730730
def hkeys(self, name: _Key) -> List[_StrType]: ...
731731
def hlen(self, name: _Key) -> int: ...
732-
def hset(
733-
self, name: _Key, key: Optional[_Key], value: Optional[_Value], mapping: Optional[Mapping[_Value, _Value]] = ...
734-
) -> int: ...
732+
@overload
733+
def hset(self, name: _Key, key: _Key, value: _Value, mapping: Optional[Mapping[_Key, _Value]] = ...) -> int: ...
734+
@overload
735+
def hset(self, name: _Key, key: None, value: None, mapping: Mapping[_Key, _Value]) -> int: ...
736+
@overload
737+
def hset(self, name: _Key, *, mapping: Mapping[_Key, _Value]) -> int: ...
735738
def hsetnx(self, name: _Key, key: _Key, value: _Value) -> int: ...
736-
def hmset(self, name: _Key, mapping: Mapping[_Value, _Value]) -> bool: ...
739+
def hmset(self, name: _Key, mapping: Mapping[_Key, _Value]) -> bool: ...
737740
def hmget(self, name: _Key, keys: Union[_Key, Iterable[_Key]], *args: _Key) -> List[Optional[_StrType]]: ...
738741
def hvals(self, name: _Key) -> List[_StrType]: ...
739742
def publish(self, channel: _Key, message: _Key) -> int: ...
@@ -1093,11 +1096,14 @@ class Pipeline(Redis):
10931096
def hincrbyfloat(self, name: _Key, key: _Key, amount: float = ...) -> Pipeline: ... # type: ignore [override]
10941097
def hkeys(self, name: _Key) -> Pipeline: ... # type: ignore [override]
10951098
def hlen(self, name: _Key) -> Pipeline: ... # type: ignore [override]
1096-
def hset( # type: ignore [override]
1097-
self, name: _Key, key: Optional[_Key], value: Optional[_Value], mapping: Optional[Mapping[_Value, _Value]] = ...
1098-
) -> Pipeline: ...
1099+
@overload # type: ignore [override]
1100+
def hset(self, name: _Key, key: _Key, value: _Value, mapping: Optional[Mapping[_Key, _Value]] = ...) -> Pipeline: ...
1101+
@overload # type: ignore [override]
1102+
def hset(self, name: _Key, key: None, value: None, mapping: Mapping[_Key, _Value]) -> int: ...
1103+
@overload # type: ignore [override]
1104+
def hset(self, name: _Key, *, mapping: Mapping[_Key, _Value]) -> Pipeline: ...
10991105
def hsetnx(self, name: _Key, key: _Key, value: _Value) -> Pipeline: ... # type: ignore [override]
1100-
def hmset(self, name: _Key, mapping: Mapping[_Value, _Value]) -> Pipeline: ... # type: ignore [override]
1106+
def hmset(self, name: _Key, mapping: Mapping[_Key, _Value]) -> Pipeline: ... # type: ignore [override]
11011107
def hmget(self, name: _Key, keys: Union[_Key, Iterable[_Key]], *args: _Key) -> Pipeline: ... # type: ignore [override]
11021108
def hvals(self, name: _Key) -> Pipeline: ... # type: ignore [override]
11031109
def publish(self, channel: _Key, message: _Key) -> Pipeline: ... # type: ignore [override]

0 commit comments

Comments
 (0)