@@ -3792,71 +3792,77 @@ class HashCommands:
3792
3792
see: https://redis.io/topics/data-types-intro#redis-hashes
3793
3793
"""
3794
3794
3795
- def hdel (self , name , * keys ) :
3795
+ def hdel (self , name : str , * keys : List ) -> int :
3796
3796
"""
3797
3797
Delete ``keys`` from hash ``name``
3798
3798
3799
3799
For more information check https://redis.io/commands/hdel
3800
3800
"""
3801
3801
return self .execute_command ("HDEL" , name , * keys )
3802
3802
3803
- def hexists (self , name , key ) :
3803
+ def hexists (self , name : str , key : str ) -> bool :
3804
3804
"""
3805
3805
Returns a boolean indicating if ``key`` exists within hash ``name``
3806
3806
3807
3807
For more information check https://redis.io/commands/hexists
3808
3808
"""
3809
3809
return self .execute_command ("HEXISTS" , name , key )
3810
3810
3811
- def hget (self , name , key ) :
3811
+ def hget (self , name : str , key : str ) -> Optional [ str ] :
3812
3812
"""
3813
3813
Return the value of ``key`` within the hash ``name``
3814
3814
3815
3815
For more information check https://redis.io/commands/hget
3816
3816
"""
3817
3817
return self .execute_command ("HGET" , name , key )
3818
3818
3819
- def hgetall (self , name ) :
3819
+ def hgetall (self , name : str ) -> dict :
3820
3820
"""
3821
3821
Return a Python dict of the hash's name/value pairs
3822
3822
3823
3823
For more information check https://redis.io/commands/hgetall
3824
3824
"""
3825
3825
return self .execute_command ("HGETALL" , name )
3826
3826
3827
- def hincrby (self , name , key , amount = 1 ) :
3827
+ def hincrby (self , name : str , key : str , amount : int = 1 ) -> int :
3828
3828
"""
3829
3829
Increment the value of ``key`` in hash ``name`` by ``amount``
3830
3830
3831
3831
For more information check https://redis.io/commands/hincrby
3832
3832
"""
3833
3833
return self .execute_command ("HINCRBY" , name , key , amount )
3834
3834
3835
- def hincrbyfloat (self , name , key , amount = 1.0 ):
3835
+ def hincrbyfloat (self , name : str , key : str , amount : float = 1.0 ) -> float :
3836
3836
"""
3837
3837
Increment the value of ``key`` in hash ``name`` by floating ``amount``
3838
3838
3839
3839
For more information check https://redis.io/commands/hincrbyfloat
3840
3840
"""
3841
3841
return self .execute_command ("HINCRBYFLOAT" , name , key , amount )
3842
3842
3843
- def hkeys (self , name ) :
3843
+ def hkeys (self , name : str ) -> List :
3844
3844
"""
3845
3845
Return the list of keys within hash ``name``
3846
3846
3847
3847
For more information check https://redis.io/commands/hkeys
3848
3848
"""
3849
3849
return self .execute_command ("HKEYS" , name )
3850
3850
3851
- def hlen (self , name ) :
3851
+ def hlen (self , name : str ) -> int :
3852
3852
"""
3853
3853
Return the number of elements in hash ``name``
3854
3854
3855
3855
For more information check https://redis.io/commands/hlen
3856
3856
"""
3857
3857
return self .execute_command ("HLEN" , name )
3858
3858
3859
- def hset (self , name , key = None , value = None , mapping = None ):
3859
+ def hset (
3860
+ self ,
3861
+ name : str ,
3862
+ key : Optional [str ] = None ,
3863
+ value : Optional [str ] = None ,
3864
+ mapping : Optional [dict ] = None ,
3865
+ ) -> int :
3860
3866
"""
3861
3867
Set ``key`` to ``value`` within hash ``name``,
3862
3868
``mapping`` accepts a dict of key/value pairs that will be
@@ -3876,7 +3882,7 @@ def hset(self, name, key=None, value=None, mapping=None):
3876
3882
3877
3883
return self .execute_command ("HSET" , name , * items )
3878
3884
3879
- def hsetnx (self , name , key , value ) :
3885
+ def hsetnx (self , name : str , key : str , value : str ) -> bool :
3880
3886
"""
3881
3887
Set ``key`` to ``value`` within hash ``name`` if ``key`` does not
3882
3888
exist. Returns 1 if HSETNX created a field, otherwise 0.
@@ -3885,7 +3891,7 @@ def hsetnx(self, name, key, value):
3885
3891
"""
3886
3892
return self .execute_command ("HSETNX" , name , key , value )
3887
3893
3888
- def hmset (self , name , mapping ) :
3894
+ def hmset (self , name : str , mapping : dict ) -> str :
3889
3895
"""
3890
3896
Set key to value within hash ``name`` for each corresponding
3891
3897
key and value from the ``mapping`` dict.
@@ -3905,7 +3911,7 @@ def hmset(self, name, mapping):
3905
3911
items .extend (pair )
3906
3912
return self .execute_command ("HMSET" , name , * items )
3907
3913
3908
- def hmget (self , name , keys , * args ) :
3914
+ def hmget (self , name : str , keys : List , * args : List ) -> List :
3909
3915
"""
3910
3916
Returns a list of values ordered identically to ``keys``
3911
3917
@@ -3914,15 +3920,15 @@ def hmget(self, name, keys, *args):
3914
3920
args = list_or_args (keys , args )
3915
3921
return self .execute_command ("HMGET" , name , * args )
3916
3922
3917
- def hvals (self , name ) :
3923
+ def hvals (self , name : str ) -> List :
3918
3924
"""
3919
3925
Return the list of values within hash ``name``
3920
3926
3921
3927
For more information check https://redis.io/commands/hvals
3922
3928
"""
3923
3929
return self .execute_command ("HVALS" , name )
3924
3930
3925
- def hstrlen (self , name , key ) :
3931
+ def hstrlen (self , name : str , key : str ) -> int :
3926
3932
"""
3927
3933
Return the number of bytes stored in the value of ``key``
3928
3934
within hash ``name``
0 commit comments