Skip to content

Commit

Permalink
fix:flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
cunla committed Oct 10, 2024
1 parent 6e0eea9 commit 22f390a
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions fakeredis/commands_mixins/bitmap_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,15 @@ def bitpos(self, key: CommandItem, bit: int, *args: bytes) -> int:
return -1 if bit == 1 else 0

start = 0 if len(args) == 0 else Int.decode(args[0])
bit_chr = str(bit)

if bit_mode:
value = self._bytes_as_bin_string(key.value)
end = len(value) if len(args) <= 1 else Int.decode(args[1])
length = len(value)
start, end = fix_range(start, end, length)
value = value[start:end]
else:
end = len(key.value) if len(args) <= 1 else Int.decode(args[1])
length = len(key.value)
start, end = fix_range(start, end, length)
value = self._bytes_as_bin_string(key.value[start:end])

source_value = self._bytes_as_bin_string(key.value) if bit_mode else key.value
end = len(source_value) if len(args) <= 1 else Int.decode(args[1])
length = len(source_value)
start, end = fix_range(start, end, length)
if start == end == -1:
return -1
source_value = source_value[start:end] if bit_mode else self._bytes_as_bin_string(source_value[start:end])

result = value.find(bit_chr)
result = source_value.find(str(bit))
if result != -1:
result += start if bit_mode else (start * 8)
elif bit == 0 and len(args) <= 1:
Expand Down

0 comments on commit 22f390a

Please sign in to comment.