Skip to content

Commit

Permalink
Ran Linter and Black, fixed export error
Browse files Browse the repository at this point in the history
  • Loading branch information
Angraybill committed Jan 20, 2025
1 parent 75384a1 commit 63f6f7d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion python/python/glide/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -31,6 +30,7 @@
FunctionRestorePolicy,
InfoSection,
InsertPosition,
OnlyIfEqual,
UpdateOptions,
)
from glide.async_commands.server_modules import ft, glide_json, json_transaction
Expand Down Expand Up @@ -226,6 +226,7 @@
"Script",
"ScoreBoundary",
"ConditionalChange",
"OnlyIfEqual",
"ExpireOptions",
"ExpiryGetEx",
"ExpirySet",
Expand Down
8 changes: 5 additions & 3 deletions python/python/glide/async_commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
10 changes: 7 additions & 3 deletions python/python/tests/test_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -40,6 +39,7 @@
InfBound,
InfoSection,
InsertPosition,
OnlyIfEqual,
UpdateOptions,
)
from glide.async_commands.sorted_set import (
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 63f6f7d

Please sign in to comment.