From 63f6f7d4ee0ecd5f4848ece78f7868d49d2ad434 Mon Sep 17 00:00:00 2001 From: Angraybill <102320032+Angraybill@users.noreply.github.com> Date: Sun, 19 Jan 2025 22:48:59 -0800 Subject: [PATCH] Ran Linter and Black, fixed export error --- python/python/glide/__init__.py | 3 ++- python/python/glide/async_commands/core.py | 8 +++++--- python/python/tests/test_async_client.py | 10 +++++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/python/python/glide/__init__.py b/python/python/glide/__init__.py index d5b950211a..9e3d808a8c 100644 --- a/python/python/glide/__init__.py +++ b/python/python/glide/__init__.py @@ -20,7 +20,6 @@ from glide.async_commands.command_args import Limit, ListDirection, ObjectType, OrderBy from glide.async_commands.core import ( ConditionalChange, - OnlyIfEqual, CoreCommands, ExpireOptions, ExpiryGetEx, @@ -31,6 +30,7 @@ FunctionRestorePolicy, InfoSection, InsertPosition, + OnlyIfEqual, UpdateOptions, ) from glide.async_commands.server_modules import ft, glide_json, json_transaction @@ -226,6 +226,7 @@ "Script", "ScoreBoundary", "ConditionalChange", + "OnlyIfEqual", "ExpireOptions", "ExpiryGetEx", "ExpirySet", diff --git a/python/python/glide/async_commands/core.py b/python/python/glide/async_commands/core.py index 86e088c991..efa8310200 100644 --- a/python/python/glide/async_commands/core.py +++ b/python/python/glide/async_commands/core.py @@ -78,15 +78,17 @@ class ConditionalChange(Enum): ONLY_IF_EXISTS = "XX" ONLY_IF_DOES_NOT_EXIST = "NX" + @dataclass -class OnlyIfEqual(): +class OnlyIfEqual: """ Change condition to the `SET` command, For additional conditonal options see ConditionalChange - - comparison_value - value to compare to the current value of a key. + - comparison_value - value to compare to the current value of a key. If comparison_value is equal to the key, it will overwrite the value of key to the new provided value - Equivalent to the IFEQ comparison-value in the Valkey API + Equivalent to the IFEQ comparison-value in the Valkey API """ + comparison_value: TEncodable diff --git a/python/python/tests/test_async_client.py b/python/python/tests/test_async_client.py index 022b0b3412..c17cf90a47 100644 --- a/python/python/tests/test_async_client.py +++ b/python/python/tests/test_async_client.py @@ -29,7 +29,6 @@ from glide.async_commands.command_args import Limit, ListDirection, OrderBy from glide.async_commands.core import ( ConditionalChange, - OnlyIfEqual, ExpireOptions, ExpiryGetEx, ExpirySet, @@ -40,6 +39,7 @@ InfBound, InfoSection, InsertPosition, + OnlyIfEqual, UpdateOptions, ) from glide.async_commands.sorted_set import ( @@ -484,12 +484,16 @@ async def test_set_only_if_equal(self, glide_client: TGlideClient): await glide_client.set(key, value) res = await glide_client.set( - key, "foobar", conditional_set=OnlyIfEqual(wrong_comparison_value), + key, + "foobar", + conditional_set=OnlyIfEqual(wrong_comparison_value), ) assert res is None assert await glide_client.get(key) == value.encode() res = await glide_client.set( - key, value2, conditional_set=OnlyIfEqual(value), + key, + value2, + conditional_set=OnlyIfEqual(value), ) assert res == OK assert await glide_client.get(key) == value2.encode()