@@ -108,8 +108,8 @@ def get_client(
108108
109109 if show_index :
110110 return self ._clients [index ], index
111- else :
112- return self ._clients [index ]
111+
112+ return self ._clients [index ]
113113
114114 def connect (self , index : int = 0 ) -> Redis :
115115 """
@@ -166,13 +166,13 @@ def set( # noqa: A003
166166 # not expire (in our case delete) the value if it exists.
167167 # Obviously expire not existent value is noop.
168168 return not self .has_key (key , version = version , client = client )
169- else :
170- # redis doesn't support negative timeouts in ex flags
171- # so it seems that it's better to just delete the key
172- # than to set it and than expire in a pipeline
173- return bool (
174- self .delete (key , client = client , version = version )
175- )
169+
170+ # redis doesn't support negative timeouts in ex flags
171+ # so it seems that it's better to just delete the key
172+ # than to set it and than expire in a pipeline
173+ return bool (
174+ self .delete (key , client = client , version = version )
175+ )
176176
177177 return bool (client .set (nkey , nvalue , nx = nx , px = timeout , xx = xx ))
178178 except _main_exceptions as e :
@@ -419,7 +419,7 @@ def delete_many(
419419 keys = [self .make_key (k , version = version ) for k in keys ]
420420
421421 if not keys :
422- return
422+ return None
423423
424424 try :
425425 return client .delete (* keys )
@@ -459,8 +459,7 @@ def encode(self, value: Any) -> Union[bytes, Any]:
459459
460460 if isinstance (value , bool ) or not isinstance (value , int ):
461461 value = self ._serializer .dumps (value )
462- value = self ._compressor .compress (value )
463- return value
462+ return self ._compressor .compress (value )
464463
465464 return value
466465
@@ -623,13 +622,13 @@ def ttl(
623622
624623 if t >= 0 :
625624 return t
626- elif t == - 1 :
625+ if t == - 1 :
627626 return None
628- elif t == - 2 :
627+ if t == - 2 :
629628 return 0
630- else :
631- # Should never reach here
632- return None
629+
630+ # Should never reach here
631+ return None
633632
634633 def pttl (self , key , version = None , client = None ):
635634 """
@@ -647,13 +646,13 @@ def pttl(self, key, version=None, client=None):
647646
648647 if t >= 0 :
649648 return t
650- elif t == - 1 :
649+ if t == - 1 :
651650 return None
652- elif t == - 2 :
651+ if t == - 2 :
653652 return 0
654- else :
655- # Should never reach here
656- return None
653+
654+ # Should never reach here
655+ return None
657656
658657 def has_key (
659658 self , key : Any , version : Optional [int ] = None , client : Optional [Redis ] = None
@@ -739,7 +738,7 @@ def make_pattern(
739738
740739 return CacheKey (self ._backend .key_func (pattern , prefix , version_str ))
741740
742- def close (self , ** kwargs ):
741+ def close (self ):
743742 close_flag = self ._options .get (
744743 "CLOSE_CONNECTION" ,
745744 getattr (settings , "DJANGO_REDIS_CLOSE_CONNECTION" , False ),
@@ -774,7 +773,7 @@ def touch(
774773 key = self .make_key (key , version = version )
775774 if timeout is None :
776775 return bool (client .persist (key ))
777- else :
778- # Convert to milliseconds
779- timeout = int (timeout * 1000 )
780- return bool (client .pexpire (key , timeout ))
776+
777+ # Convert to milliseconds
778+ timeout = int (timeout * 1000 )
779+ return bool (client .pexpire (key , timeout ))
0 commit comments