diff --git a/tests/test_commands.py b/tests/test_commands.py index 31db8c51..085f74c4 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -1330,6 +1330,8 @@ def test_getdel(self, r): @skip_if_server_version_lt("6.2.0") def test_getex(self, r): r.set("a", 1) + with pytest.raises(valkey.DataError): + r.getex("a", ex=10, px=10) assert r.getex("a") == b"1" assert r.ttl("a") == -1 assert r.getex("a", ex=60) == b"1" diff --git a/valkey/commands/core.py b/valkey/commands/core.py index 35af510c..93160f9b 100644 --- a/valkey/commands/core.py +++ b/valkey/commands/core.py @@ -1859,8 +1859,8 @@ def getex( For more information see https://valkey.io/commands/getex """ - opset = {ex, px, exat, pxat} - if len(opset) > 2 or len(opset) > 1 and persist: + opvs = sum(op is not None for op in [ex, px, exat, pxat]) + if opvs > 1 or (opvs and persist): raise DataError( "``ex``, ``px``, ``exat``, ``pxat``, " "and ``persist`` are mutually exclusive."