@@ -5066,6 +5066,7 @@ def hsetex(
50665066 px : Union [ExpiryT , None ] = None ,
50675067 exat : Union [AbsExpiryT , None ] = None ,
50685068 pxat : Union [AbsExpiryT , None ] = None ,
5069+ keepttl : bool = False ,
50695070 nx : bool = False ,
50705071 xx : bool = False ,
50715072 fnx : bool = False ,
@@ -5082,6 +5083,18 @@ def hsetex(
50825083
50835084 if key is None and not mapping and not items :
50845085 raise DataError ("'hsetex' with no key value pairs" )
5086+
5087+ def _check_for_multiple (* args ):
5088+ return sum (arg is not None for arg in args )
5089+
5090+ if _check_for_multiple (ex , px , exat , pxat ) > 1 or (keepttl and _check_for_multiple (ex , px , exat , pxat ) > 0 ):
5091+ raise DataError (
5092+ "Only one of 'ex', 'px', 'exat', 'pxat', or 'keepttl' can be specified."
5093+ )
5094+ if nx and xx :
5095+ raise DataError ("Only one of 'nx' or 'xx' can be specified." )
5096+ if fnx and fxx :
5097+ raise DataError ("Only one of 'fnx' or 'fxx' can be specified." )
50855098 pieces = []
50865099 if ex is not None :
50875100 pieces .extend (["EX" , ex ])
@@ -5107,6 +5120,8 @@ def hsetex(
51075120 if mapping :
51085121 pieces .append (len (mapping ))
51095122 for key , value in mapping .items ():
5123+ if key is None or value is None :
5124+ raise DataError ("'hsetex' mapping contains None key or value" )
51105125 pieces .append (key )
51115126 pieces .append (value )
51125127 if items :
0 commit comments