Skip to content

Commit

Permalink
fix type of mget
Browse files Browse the repository at this point in the history
Signed-off-by: BoazBD <boazbd@amazon.com>
  • Loading branch information
BoazBD committed Oct 23, 2024
1 parent 5a9e9ac commit 5c14340
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 2 additions & 3 deletions python/python/glide/async_commands/server_modules/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ async def mget(
keys: List[TEncodable],
paths: Optional[Union[TEncodable, List[TEncodable]]] = None,
options: Optional[JsonGetOptions] = None,
) -> Optional[List[bytes]]:
) -> List[Optional[bytes]]:
"""
Retrieves the JSON values at the specified `paths` stored at multiple `keys`.
Expand Down Expand Up @@ -179,8 +179,7 @@ async def mget(
paths = [paths]
args.extend(paths)

results = await client.custom_command(args)
return [result if result is not None else None for result in results]
return cast(List[Optional[bytes]], await client.custom_command(args))


async def arrlen(
Expand Down
6 changes: 2 additions & 4 deletions python/python/tests/tests_server_modules/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ async def test_json_mget(self, glide_client: TGlideClient):
["{non_existing_key}1", "{non_existing_key}2"],
["$a"],
)
expected_result = [None, None]
assert result == expected_result
assert result == [None, None]

# Test with only one key
result = await json.mget(
Expand All @@ -255,8 +254,7 @@ async def test_json_mget(self, glide_client: TGlideClient):
glide_client,
[key1, key2],
)
expected_result = [None]
assert result == expected_result
assert result == [None]

@pytest.mark.parametrize("cluster_mode", [True, False])
@pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3])
Expand Down

0 comments on commit 5c14340

Please sign in to comment.