@@ -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,20 @@ 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 (
5091+ keepttl and _check_for_multiple (ex , px , exat , pxat ) > 0
5092+ ):
5093+ raise DataError (
5094+ "Only one of 'ex', 'px', 'exat', 'pxat', or 'keepttl' can be specified."
5095+ )
5096+ if nx and xx :
5097+ raise DataError ("Only one of 'nx' or 'xx' can be specified." )
5098+ if fnx and fxx :
5099+ raise DataError ("Only one of 'fnx' or 'fxx' can be specified." )
50855100 pieces = []
50865101 if ex is not None :
50875102 pieces .extend (["EX" , ex ])
@@ -5107,6 +5122,8 @@ def hsetex(
51075122 if mapping :
51085123 pieces .append (len (mapping ))
51095124 for key , value in mapping .items ():
5125+ if key is None or value is None :
5126+ raise DataError ("'hsetex' mapping contains None key or value" )
51105127 pieces .append (key )
51115128 pieces .append (value )
51125129 if items :
0 commit comments