Skip to content

Commit

Permalink
Fix new MyPy issues
Browse files Browse the repository at this point in the history
Left operand of "or" is always false  [redundant-expr]
  • Loading branch information
DimitriPapadopoulos committed Mar 12, 2024
1 parent 95d0cff commit 15612ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion zarr/_storage/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def _valid_key(self, key: str) -> bool:
0-9, or in the set /.-_ it will return True if that's the case, False
otherwise.
"""
if not isinstance(key, str) or not key.isascii():
if not isinstance(key, str) or not key.isascii(): # type: ignore[redundant-expr]
return False
if set(key) - self._valid_key_characters:
return False
Expand Down
4 changes: 3 additions & 1 deletion zarr/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2497,11 +2497,13 @@ def _accommodate_value(self, value_size):
self._current_size -= buffer_size(v)

def _cache_value(self, key: Path, value):
if self._max_size is None:
return
# cache a value
value_size = buffer_size(value)
# check size of the value against max size, as if the value itself exceeds max
# size then we are never going to cache it
if self._max_size is None or value_size <= self._max_size:
if value_size <= self._max_size:
self._accommodate_value(value_size)
self._values_cache[key] = value
self._current_size += value_size
Expand Down

0 comments on commit 15612ed

Please sign in to comment.