From 08f0ac7eb706840ed385008f1016e2cb9bf949f9 Mon Sep 17 00:00:00 2001 From: Chloe Yip Date: Fri, 6 Sep 2024 10:14:05 -0700 Subject: [PATCH 1/7] current progress Signed-off-by: Chloe Yip --- python/python/glide/async_commands/core.py | 127 +++++++----------- .../glide/async_commands/transaction.py | 47 +------ 2 files changed, 48 insertions(+), 126 deletions(-) diff --git a/python/python/glide/async_commands/core.py b/python/python/glide/async_commands/core.py index 7acb44ca60..a091980428 100644 --- a/python/python/glide/async_commands/core.py +++ b/python/python/glide/async_commands/core.py @@ -5592,89 +5592,52 @@ async def getbit(self, key: TEncodable, offset: int) -> int: await self._execute_command(RequestType.GetBit, [key, str(offset)]), ) - async def bitpos( - self, key: TEncodable, bit: int, start: Optional[int] = None - ) -> int: - """ - Returns the position of the first bit matching the given `bit` value. The optional starting offset - `start` is a zero-based index, with `0` being the first byte of the list, `1` being the next byte and so on. - The offset can also be a negative number indicating an offset starting at the end of the list, with `-1` being - the last byte of the list, `-2` being the penultimate, and so on. - - See https://valkey.io/commands/bitpos for more details. - - Args: - key (TEncodable): The key of the string. - bit (int): The bit value to match. Must be `0` or `1`. - start (Optional[int]): The starting offset. - - Returns: - int: The position of the first occurrence of `bit` in the binary value of the string held at `key`. - If `start` was provided, the search begins at the offset indicated by `start`. - - Examples: - >>> await client.set("key1", "A1") # "A1" has binary value 01000001 00110001 - >>> await client.bitpos("key1", 1) - 1 # The first occurrence of bit value 1 in the string stored at "key1" is at the second position. - >>> await client.bitpos("key1", 1, -1) - 10 # The first occurrence of bit value 1, starting at the last byte in the string stored at "key1", is at the eleventh position. - """ - args = [key, str(bit)] if start is None else [key, str(bit), str(start)] - return cast( - int, - await self._execute_command(RequestType.BitPos, args), - ) - - async def bitpos_interval( - self, - key: TEncodable, - bit: int, - start: int, - end: int, - index_type: Optional[BitmapIndexType] = None, + async def bitcount( + self, key: TEncodable, bit: int, options: Optional[OffsetOptions] = None ) -> int: - """ - Returns the position of the first bit matching the given `bit` value. The offsets are zero-based indexes, with - `0` being the first element of the list, `1` being the next, and so on. These offsets can also be negative - numbers indicating offsets starting at the end of the list, with `-1` being the last element of the list, `-2` - being the penultimate, and so on. - - If you are using Valkey 7.0.0 or above, the optional `index_type` can also be provided to specify whether the - `start` and `end` offsets specify BIT or BYTE offsets. If `index_type` is not provided, BYTE offsets - are assumed. If BIT is specified, `start=0` and `end=2` means to look at the first three bits. If BYTE is - specified, `start=0` and `end=2` means to look at the first three bytes. - - See https://valkey.io/commands/bitpos for more details. - - Args: - key (TEncodable): The key of the string. - bit (int): The bit value to match. Must be `0` or `1`. - start (int): The starting offset. - end (int): The ending offset. - index_type (Optional[BitmapIndexType]): The index offset type. This option can only be specified if you are - using Valkey version 7.0.0 or above. Could be either `BitmapIndexType.BYTE` or `BitmapIndexType.BIT`. - If no index type is provided, the indexes will be assumed to be byte indexes. - - Returns: - int: The position of the first occurrence from the `start` to the `end` offsets of the `bit` in the binary - value of the string held at `key`. - - Examples: - >>> await client.set("key1", "A12") # "A12" has binary value 01000001 00110001 00110010 - >>> await client.bitpos_interval("key1", 1, 1, -1) - 10 # The first occurrence of bit value 1 in the second byte to the last byte of the string stored at "key1" is at the eleventh position. - >>> await client.bitpos_interval("key1", 1, 2, 9, BitmapIndexType.BIT) - 7 # The first occurrence of bit value 1 in the third to tenth bits of the string stored at "key1" is at the eighth position. - """ - if index_type is not None: - args = [key, str(bit), str(start), str(end), index_type.value] - else: - args = [key, str(bit), str(start), str(end)] - - return cast( - int, - await self._execute_command(RequestType.BitPos, args), - ) + """ + Returns the position of the first bit matching the given `bit` value. The optional starting offset + `start` is a zero-based index, with `0` being the first byte of the list, `1` being the next byte and so on. + The offset can also be a negative number indicating an offset starting at the end of the list, with `-1` being + the last byte of the list, `-2` being the penultimate, and so on. + + If you are using Valkey 7.0.0 or above, the optional `index_type` can also be provided to specify whether the + `start` and `end` offsets specify BIT or BYTE offsets. If `index_type` is not provided, BYTE offsets + are assumed. If BIT is specified, `start=0` and `end=2` means to look at the first three bits. If BYTE is + specified, `start=0` and `end=2` means to look at the first three bytes. + + See https://valkey.io/commands/bitpos for more details. + + Args: + key (TEncodable): The key of the string. + bit (int): The bit value to match. Must be `0` or `1`. + options (Optional[OffsetOptions]): The offset options. + + Returns: + int: The position of the first occurrence of `bit` in the binary value of the string held at `key`. + If `start` was provided, the search begins at the offset indicated by `start`. + + Examples: + >>> await client.set("key1", "A1") # "A1" has binary value 01000001 00110001 + >>> await client.bitpos("key1", 1) + 1 # The first occurrence of bit value 1 in the string stored at "key1" is at the second position. + >>> await client.bitpos("key1", 1, -1) + 10 # The first occurrence of bit value 1, starting at the last byte in the string stored at "key1", is at the eleventh position. + + >>> await client.set("key2", "A12") # "A12" has binary value 01000001 00110001 00110010 + >>> await client.bitpos("key2", 1, OffsetOptions(1, -1)) + 10 # The first occurrence of bit value 1 in the second byte to the last byte of the string stored at "key1" is at the eleventh position. + >>> await client.bitpos("key2", 1, OffsetOptions(2, 9, BitmapIndexType.BIT)) + 7 # The first occurrence of bit value 1 in the third to tenth bits of the string stored at "key1" is at the eighth position. + """ + args: List[TEncodable] = [key, bit] + if options is not None: + args.extend(options.to_args()) + + return cast( + int, + await self._execute_command(RequestType.BitPos, args), + ) async def bitop( self, diff --git a/python/python/glide/async_commands/transaction.py b/python/python/glide/async_commands/transaction.py index 9bb72770e3..e3fc1292ae 100644 --- a/python/python/glide/async_commands/transaction.py +++ b/python/python/glide/async_commands/transaction.py @@ -4087,7 +4087,7 @@ def bitpos( self: TTransaction, key: TEncodable, bit: int, - start: Optional[int] = None, + options: Optional[OffsetOptions] = None, ) -> TTransaction: """ Returns the position of the first bit matching the given `bit` value. The optional starting offset @@ -4100,54 +4100,13 @@ def bitpos( Args: key (TEncodable): The key of the string. bit (int): The bit value to match. Must be `0` or `1`. - start (Optional[int]): The starting offset. + options (Optional[OffsetOptions]): The offset options. Command response: int: The position of the first occurrence of `bit` in the binary value of the string held at `key`. If `start` was provided, the search begins at the offset indicated by `start`. """ - args = [key, str(bit)] if start is None else [key, str(bit), str(start)] - return self.append_command(RequestType.BitPos, args) - - def bitpos_interval( - self: TTransaction, - key: TEncodable, - bit: int, - start: int, - end: int, - index_type: Optional[BitmapIndexType] = None, - ) -> TTransaction: - """ - Returns the position of the first bit matching the given `bit` value. The offsets are zero-based indexes, with - `0` being the first element of the list, `1` being the next, and so on. These offsets can also be negative - numbers indicating offsets starting at the end of the list, with `-1` being the last element of the list, `-2` - being the penultimate, and so on. - - If you are using Valkey 7.0.0 or above, the optional `index_type` can also be provided to specify whether the - `start` and `end` offsets specify BIT or BYTE offsets. If `index_type` is not provided, BYTE offsets - are assumed. If BIT is specified, `start=0` and `end=2` means to look at the first three bits. If BYTE is - specified, `start=0` and `end=2` means to look at the first three bytes. - - See https://valkey.io/commands/bitpos for more details. - - Args: - key (TEncodable): The key of the string. - bit (int): The bit value to match. Must be `0` or `1`. - start (int): The starting offset. - end (int): The ending offset. - index_type (Optional[BitmapIndexType]): The index offset type. This option can only be specified if you are - using Valkey version 7.0.0 or above. Could be either `BitmapIndexType.BYTE` or `BitmapIndexType.BIT`. - If no index type is provided, the indexes will be assumed to be byte indexes. - - Command response: - int: The position of the first occurrence from the `start` to the `end` offsets of the `bit` in the binary - value of the string held at `key`. - """ - if index_type is not None: - args = [key, str(bit), str(start), str(end), index_type.value] - else: - args = [key, str(bit), str(start), str(end)] - + args = [key, str(bit)] if options is not None: args.extend(options.to_args()) return self.append_command(RequestType.BitPos, args) def bitop( From 1dfa464c0686a4d7e62b26ce6ffc05d128e17d1f Mon Sep 17 00:00:00 2001 From: Chloe Yip Date: Fri, 6 Sep 2024 14:51:25 -0700 Subject: [PATCH 2/7] fix core Signed-off-by: Chloe Yip --- python/python/glide/async_commands/core.py | 88 +++++++++---------- .../glide/async_commands/transaction.py | 5 +- python/python/tests/test_async_client.py | 38 ++++---- python/python/tests/test_transaction.py | 2 +- 4 files changed, 72 insertions(+), 61 deletions(-) diff --git a/python/python/glide/async_commands/core.py b/python/python/glide/async_commands/core.py index a091980428..b8acc4c18a 100644 --- a/python/python/glide/async_commands/core.py +++ b/python/python/glide/async_commands/core.py @@ -5592,52 +5592,52 @@ async def getbit(self, key: TEncodable, offset: int) -> int: await self._execute_command(RequestType.GetBit, [key, str(offset)]), ) - async def bitcount( + async def bitpos( self, key: TEncodable, bit: int, options: Optional[OffsetOptions] = None ) -> int: - """ - Returns the position of the first bit matching the given `bit` value. The optional starting offset - `start` is a zero-based index, with `0` being the first byte of the list, `1` being the next byte and so on. - The offset can also be a negative number indicating an offset starting at the end of the list, with `-1` being - the last byte of the list, `-2` being the penultimate, and so on. - - If you are using Valkey 7.0.0 or above, the optional `index_type` can also be provided to specify whether the - `start` and `end` offsets specify BIT or BYTE offsets. If `index_type` is not provided, BYTE offsets - are assumed. If BIT is specified, `start=0` and `end=2` means to look at the first three bits. If BYTE is - specified, `start=0` and `end=2` means to look at the first three bytes. - - See https://valkey.io/commands/bitpos for more details. - - Args: - key (TEncodable): The key of the string. - bit (int): The bit value to match. Must be `0` or `1`. - options (Optional[OffsetOptions]): The offset options. - - Returns: - int: The position of the first occurrence of `bit` in the binary value of the string held at `key`. - If `start` was provided, the search begins at the offset indicated by `start`. - - Examples: - >>> await client.set("key1", "A1") # "A1" has binary value 01000001 00110001 - >>> await client.bitpos("key1", 1) - 1 # The first occurrence of bit value 1 in the string stored at "key1" is at the second position. - >>> await client.bitpos("key1", 1, -1) - 10 # The first occurrence of bit value 1, starting at the last byte in the string stored at "key1", is at the eleventh position. - - >>> await client.set("key2", "A12") # "A12" has binary value 01000001 00110001 00110010 - >>> await client.bitpos("key2", 1, OffsetOptions(1, -1)) - 10 # The first occurrence of bit value 1 in the second byte to the last byte of the string stored at "key1" is at the eleventh position. - >>> await client.bitpos("key2", 1, OffsetOptions(2, 9, BitmapIndexType.BIT)) - 7 # The first occurrence of bit value 1 in the third to tenth bits of the string stored at "key1" is at the eighth position. - """ - args: List[TEncodable] = [key, bit] - if options is not None: - args.extend(options.to_args()) - - return cast( - int, - await self._execute_command(RequestType.BitPos, args), - ) + """ + Returns the position of the first bit matching the given `bit` value. The optional starting offset + `start` is a zero-based index, with `0` being the first byte of the list, `1` being the next byte and so on. + The offset can also be a negative number indicating an offset starting at the end of the list, with `-1` being + the last byte of the list, `-2` being the penultimate, and so on. + + If you are using Valkey 7.0.0 or above, the optional `index_type` can also be provided to specify whether the + `start` and `end` offsets specify BIT or BYTE offsets. If `index_type` is not provided, BYTE offsets + are assumed. If BIT is specified, `start=0` and `end=2` means to look at the first three bits. If BYTE is + specified, `start=0` and `end=2` means to look at the first three bytes. + + See https://valkey.io/commands/bitpos for more details. + + Args: + key (TEncodable): The key of the string. + bit (int): The bit value to match. Must be `0` or `1`. + options (Optional[OffsetOptions]): The offset options. + + Returns: + int: The position of the first occurrence of `bit` in the binary value of the string held at `key`. + If `start` was provided, the search begins at the offset indicated by `start`. + + Examples: + >>> await client.set("key1", "A1") # "A1" has binary value 01000001 00110001 + >>> await client.bitpos("key1", 1) + 1 # The first occurrence of bit value 1 in the string stored at "key1" is at the second position. + >>> await client.bitpos("key1", 1, -1) + 10 # The first occurrence of bit value 1, starting at the last byte in the string stored at "key1", is at the eleventh position. + + >>> await client.set("key2", "A12") # "A12" has binary value 01000001 00110001 00110010 + >>> await client.bitpos("key2", 1, OffsetOptions(1, -1)) + 10 # The first occurrence of bit value 1 in the second byte to the last byte of the string stored at "key1" is at the eleventh position. + >>> await client.bitpos("key2", 1, OffsetOptions(2, 9, BitmapIndexType.BIT)) + 7 # The first occurrence of bit value 1 in the third to tenth bits of the string stored at "key1" is at the eighth position. + """ + args: List[TEncodable] = [key, bit] + if options is not None: + args.extend(options.to_args()) + + return cast( + int, + await self._execute_command(RequestType.BitPos, args), + ) async def bitop( self, diff --git a/python/python/glide/async_commands/transaction.py b/python/python/glide/async_commands/transaction.py index e3fc1292ae..9bc7879c65 100644 --- a/python/python/glide/async_commands/transaction.py +++ b/python/python/glide/async_commands/transaction.py @@ -4106,7 +4106,10 @@ def bitpos( int: The position of the first occurrence of `bit` in the binary value of the string held at `key`. If `start` was provided, the search begins at the offset indicated by `start`. """ - args = [key, str(bit)] if options is not None: args.extend(options.to_args()) + args: List[TEncodable] = [key, str(bit)] + if options is not None: + args.extend(options.to_args()) + return self.append_command(RequestType.BitPos, args) def bitop( diff --git a/python/python/tests/test_async_client.py b/python/python/tests/test_async_client.py index 7566194dcc..c33bfb0c78 100644 --- a/python/python/tests/test_async_client.py +++ b/python/python/tests/test_async_client.py @@ -7226,7 +7226,7 @@ async def test_getbit(self, glide_client: TGlideClient): @pytest.mark.parametrize("cluster_mode", [True, False]) @pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3]) - async def test_bitpos_and_bitpos_interval(self, glide_client: TGlideClient): + async def test_bitpos(self, glide_client: TGlideClient): key = get_random_string(10) non_existing_key = get_random_string(10) set_key = get_random_string(10) @@ -7238,57 +7238,65 @@ async def test_bitpos_and_bitpos_interval(self, glide_client: TGlideClient): assert await glide_client.bitpos(key, 0) == 0 assert await glide_client.bitpos(key, 1) == 2 assert await glide_client.bitpos(key, 1, 1) == 9 - assert await glide_client.bitpos_interval(key, 0, 3, 5) == 24 + assert await glide_client.bitpos(key, 0, OffsetOptions(3, 5)) == 24 # `BITPOS` returns -1 for non-existing strings assert await glide_client.bitpos(non_existing_key, 1) == -1 - assert await glide_client.bitpos_interval(non_existing_key, 1, 3, 5) == -1 + assert await glide_client.bitpos(non_existing_key, 1, OffsetOptions(3, 5)) == -1 # invalid argument - bit value must be 0 or 1 with pytest.raises(RequestError): await glide_client.bitpos(key, 2) with pytest.raises(RequestError): - await glide_client.bitpos_interval(key, 2, 3, 5) + await glide_client.bitpos(key, 2, OffsetOptions(3, 5)) # key exists, but it is not a string assert await glide_client.sadd(set_key, [value]) == 1 with pytest.raises(RequestError): await glide_client.bitpos(set_key, 1) with pytest.raises(RequestError): - await glide_client.bitpos_interval(set_key, 1, 1, -1) + await glide_client.bitpos(set_key, 1, OffsetOptions(1, -1)) if await check_if_server_version_lt(glide_client, "7.0.0"): # error thrown because BIT and BYTE options were implemented after 7.0.0 with pytest.raises(RequestError): - await glide_client.bitpos_interval(key, 1, 1, -1, BitmapIndexType.BYTE) + await glide_client.bitpos( + key, 1, OffsetOptions(1, -1, BitmapIndexType.BYTE) + ) with pytest.raises(RequestError): - await glide_client.bitpos_interval(key, 1, 1, -1, BitmapIndexType.BIT) + await glide_client.bitpos( + key, 1, OffsetOptions(1, -1, BitmapIndexType.BIT) + ) else: assert ( - await glide_client.bitpos_interval(key, 0, 3, 5, BitmapIndexType.BYTE) + await glide_client.bitpos( + key, 0, OffsetOptions(3, 5, BitmapIndexType.BYTE) + ) == 24 ) assert ( - await glide_client.bitpos_interval(key, 1, 43, -2, BitmapIndexType.BIT) + await glide_client.bitpos( + key, 1, OffsetOptions(43, -2, BitmapIndexType.BIT) + ) == 47 ) assert ( - await glide_client.bitpos_interval( - non_existing_key, 1, 3, 5, BitmapIndexType.BYTE + await glide_client.bitpos( + non_existing_key, 1, OffsetOptions(3, 5, BitmapIndexType.BYTE) ) == -1 ) assert ( - await glide_client.bitpos_interval( - non_existing_key, 1, 3, 5, BitmapIndexType.BIT + await glide_client.bitpos( + non_existing_key, 1, OffsetOptions(3, 5, BitmapIndexType.BIT) ) == -1 ) # key exists, but it is not a string with pytest.raises(RequestError): - await glide_client.bitpos_interval( - set_key, 1, 1, -1, BitmapIndexType.BIT + await glide_client.bitpos( + set_key, 1, OffsetOptions(1, -1, BitmapIndexType.BIT) ) @pytest.mark.parametrize("cluster_mode", [True, False]) diff --git a/python/python/tests/test_transaction.py b/python/python/tests/test_transaction.py index dadef84200..8ff5ddbe4e 100644 --- a/python/python/tests/test_transaction.py +++ b/python/python/tests/test_transaction.py @@ -558,7 +558,7 @@ async def transaction_test( args.append(OK) transaction.bitcount(key20, OffsetOptions(5, 30, BitmapIndexType.BIT)) args.append(17) - transaction.bitpos_interval(key20, 1, 44, 50, BitmapIndexType.BIT) + transaction.bitpos(key20, 1, OffsetOptions(44, 50, BitmapIndexType.BIT)) args.append(46) if not await check_if_server_version_lt(glide_client, "8.0.0"): From 06e504583d3d4641bfe3c11bdadd8f26d9c92efb Mon Sep 17 00:00:00 2001 From: Chloe Yip Date: Mon, 9 Sep 2024 09:22:17 -0700 Subject: [PATCH 3/7] implement python bitpos Signed-off-by: Chloe Yip --- python/python/glide/async_commands/bitmap.py | 4 ++-- python/python/glide/async_commands/core.py | 4 ++-- python/python/tests/test_async_client.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/python/python/glide/async_commands/bitmap.py b/python/python/glide/async_commands/bitmap.py index 87e501dfb5..ac2f369288 100644 --- a/python/python/glide/async_commands/bitmap.py +++ b/python/python/glide/async_commands/bitmap.py @@ -260,8 +260,8 @@ class BitOverflowControl(Enum): WRAP = "WRAP" """ - Performs modulo when overflows occur with unsigned encoding. When overflows occur with signed encoding, the value - restarts at the most negative value. When underflows occur with signed encoding, the value restarts at the most + Performs modulo when overflows occur with unsigned encoding. When overflows occur with signed encoding, the value + restarts at the most negative value. When underflows occur with signed encoding, the value restarts at the most positive value. """ SAT = "SAT" diff --git a/python/python/glide/async_commands/core.py b/python/python/glide/async_commands/core.py index b8acc4c18a..f6cd6be97a 100644 --- a/python/python/glide/async_commands/core.py +++ b/python/python/glide/async_commands/core.py @@ -5621,7 +5621,7 @@ async def bitpos( >>> await client.set("key1", "A1") # "A1" has binary value 01000001 00110001 >>> await client.bitpos("key1", 1) 1 # The first occurrence of bit value 1 in the string stored at "key1" is at the second position. - >>> await client.bitpos("key1", 1, -1) + >>> await client.bitpos("key1", 1, OffsetOptions(-1)) 10 # The first occurrence of bit value 1, starting at the last byte in the string stored at "key1", is at the eleventh position. >>> await client.set("key2", "A12") # "A12" has binary value 01000001 00110001 00110010 @@ -5630,7 +5630,7 @@ async def bitpos( >>> await client.bitpos("key2", 1, OffsetOptions(2, 9, BitmapIndexType.BIT)) 7 # The first occurrence of bit value 1 in the third to tenth bits of the string stored at "key1" is at the eighth position. """ - args: List[TEncodable] = [key, bit] + args: List[TEncodable] = [key, str(bit)] if options is not None: args.extend(options.to_args()) diff --git a/python/python/tests/test_async_client.py b/python/python/tests/test_async_client.py index c33bfb0c78..cb821980a8 100644 --- a/python/python/tests/test_async_client.py +++ b/python/python/tests/test_async_client.py @@ -7237,7 +7237,7 @@ async def test_bitpos(self, glide_client: TGlideClient): assert await glide_client.set(key, value) == OK assert await glide_client.bitpos(key, 0) == 0 assert await glide_client.bitpos(key, 1) == 2 - assert await glide_client.bitpos(key, 1, 1) == 9 + assert await glide_client.bitpos(key, 1, OffsetOptions(1)) == 9 assert await glide_client.bitpos(key, 0, OffsetOptions(3, 5)) == 24 # `BITPOS` returns -1 for non-existing strings From 981277b6669faf7c065a9f1a1b263d35caebca32 Mon Sep 17 00:00:00 2001 From: Chloe Yip Date: Mon, 9 Sep 2024 09:27:54 -0700 Subject: [PATCH 4/7] add changelog Signed-off-by: Chloe Yip --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ee5dda24f..13d285202b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ * Node: Renamed `ReturnType` to `GlideReturnType` ([#2241](https://github.com/valkey-io/valkey-glide/pull/2241)) * Node, Python: Rename `stop` to `end` in sorted set queries ([#2214](https://github.com/valkey-io/valkey-glide/pull/2214)) * Node: Added binary variant to sorted set commands - part 1 ([#2190](https://github.com/valkey-io/valkey-glide/pull/2190)) +* Python: Fix BITPOS for Valkey8 ([#2256](https://github.com/valkey-io/valkey-glide/pull/2256)) * Node: Added binary variant to HSCAN command ([#2240](https://github.com/valkey-io/valkey-glide/pull/2240)) * Node: replace decoder by DecoderOption and route by RouteOption in API([#2234](https://github.com/valkey-io/valkey-glide/pull/2234/)) * Node: Added binary variant to sorted set commands ([#2190](https://github.com/valkey-io/valkey-glide/pull/2190), [#2210](https://github.com/valkey-io/valkey-glide/pull/2210)) From 7c4800a502f82fdfcc14af41727ba8287a236a0b Mon Sep 17 00:00:00 2001 From: Chloe Yip Date: Mon, 9 Sep 2024 09:54:37 -0700 Subject: [PATCH 5/7] ran linter Signed-off-by: Chloe Yip --- python/python/tests/test_async_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/python/tests/test_async_client.py b/python/python/tests/test_async_client.py index cb821980a8..8fa21e0808 100644 --- a/python/python/tests/test_async_client.py +++ b/python/python/tests/test_async_client.py @@ -7237,7 +7237,7 @@ async def test_bitpos(self, glide_client: TGlideClient): assert await glide_client.set(key, value) == OK assert await glide_client.bitpos(key, 0) == 0 assert await glide_client.bitpos(key, 1) == 2 - assert await glide_client.bitpos(key, 1, OffsetOptions(1)) == 9 + assert await glide_client.bitpos(key, 1, OffsetOptions(1)) == 9 assert await glide_client.bitpos(key, 0, OffsetOptions(3, 5)) == 24 # `BITPOS` returns -1 for non-existing strings From e86260be4063403c2bf67a83a25fc63a3d4130c0 Mon Sep 17 00:00:00 2001 From: James Xin Date: Wed, 25 Sep 2024 12:14:12 -0700 Subject: [PATCH 6/7] address comment Signed-off-by: James Xin --- python/python/glide/async_commands/bitmap.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/python/glide/async_commands/bitmap.py b/python/python/glide/async_commands/bitmap.py index ac2f369288..4e98697996 100644 --- a/python/python/glide/async_commands/bitmap.py +++ b/python/python/glide/async_commands/bitmap.py @@ -37,7 +37,8 @@ def __init__( Args: start (int): The starting offset index. - end (int): The ending offset index. Optional since Valkey version 8.0.0 and above. If not provided, it will default to the end of the string. + end (Optional[int]): The ending offset index. Optional since Valkey version 8.0.0 and above. If not provided, + it will default to the end of the string. index_type (Optional[BitmapIndexType]): The index offset type. This option can only be specified if you are using Valkey version 7.0.0 or above. Could be either `BitmapIndexType.BYTE` or `BitmapIndexType.BIT`. If no index type is provided, the indexes will be assumed to be byte indexes. From b1b50af987440c2aa8f8c31eb9839331a68399b8 Mon Sep 17 00:00:00 2001 From: James Xin Date: Thu, 26 Sep 2024 09:50:21 -0700 Subject: [PATCH 7/7] fix doc for OffsetOptions Signed-off-by: James Xin --- python/python/glide/async_commands/bitmap.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/python/glide/async_commands/bitmap.py b/python/python/glide/async_commands/bitmap.py index 4e98697996..d7e2415057 100644 --- a/python/python/glide/async_commands/bitmap.py +++ b/python/python/glide/async_commands/bitmap.py @@ -37,8 +37,8 @@ def __init__( Args: start (int): The starting offset index. - end (Optional[int]): The ending offset index. Optional since Valkey version 8.0.0 and above. If not provided, - it will default to the end of the string. + end (Optional[int]): The ending offset index. Optional since Valkey version 8.0.0 and above for the BITCOUNT + command. If not provided, it will default to the end of the string. index_type (Optional[BitmapIndexType]): The index offset type. This option can only be specified if you are using Valkey version 7.0.0 or above. Could be either `BitmapIndexType.BYTE` or `BitmapIndexType.BIT`. If no index type is provided, the indexes will be assumed to be byte indexes.