Skip to content

Commit

Permalink
Apply ruff/flake8-raise rule RSE102
Browse files Browse the repository at this point in the history
RSE102 Unnecessary parentheses on raised exception
  • Loading branch information
DimitriPapadopoulos committed May 17, 2024
1 parent cc6b1ad commit fb30670
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
12 changes: 6 additions & 6 deletions src/zarr/v2/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,7 @@ def set_basic_selection(self, selection, value, fields=None):

# guard conditions
if self._read_only:
raise ReadOnlyError()
raise ReadOnlyError

# refresh metadata
if not self._cache_metadata:
Expand Down Expand Up @@ -1557,7 +1557,7 @@ def set_orthogonal_selection(self, selection, value, fields=None):

# guard conditions
if self._read_only:
raise ReadOnlyError()
raise ReadOnlyError

# refresh metadata
if not self._cache_metadata:
Expand Down Expand Up @@ -1630,7 +1630,7 @@ def set_coordinate_selection(self, selection, value, fields=None):

# guard conditions
if self._read_only:
raise ReadOnlyError()
raise ReadOnlyError

# refresh metadata
if not self._cache_metadata:
Expand Down Expand Up @@ -1723,7 +1723,7 @@ def set_block_selection(self, selection, value, fields=None):
"""
# guard conditions
if self._read_only:
raise ReadOnlyError()
raise ReadOnlyError

# refresh metadata
if not self._cache_metadata:
Expand Down Expand Up @@ -1799,7 +1799,7 @@ def set_mask_selection(self, selection, value, fields=None):

# guard conditions
if self._read_only:
raise ReadOnlyError()
raise ReadOnlyError

# refresh metadata
if not self._cache_metadata:
Expand Down Expand Up @@ -2489,7 +2489,7 @@ def _synchronized_op(self, f, *args, **kwargs):
def _write_op(self, f, *args, **kwargs):
# guard condition
if self._read_only:
raise ReadOnlyError()
raise ReadOnlyError

return self._synchronized_op(f, *args, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion src/zarr/v2/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ def tree(self, expand=False, level=None):
def _write_op(self, f, *args, **kwargs):
# guard condition
if self._read_only:
raise ReadOnlyError()
raise ReadOnlyError

if self._synchronizer is None:
# no synchronization
Expand Down
4 changes: 2 additions & 2 deletions src/zarr/v2/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def __init__(self, dim_sel, dim_len, dim_chunk_len):
# normalize
self.start, self.stop, self.step = dim_sel.indices(dim_len)
if self.step < 1:
raise NegativeStepError()
raise NegativeStepError

# store attributes
self.dim_len = dim_len
Expand Down Expand Up @@ -978,7 +978,7 @@ def make_slice_selection(selection):
if len(dim_selection) == 1:
ls.append(slice(int(dim_selection[0]), int(dim_selection[0]) + 1, 1))
else:
raise ArrayIndexError()
raise ArrayIndexError
else:
ls.append(dim_selection)
return ls
Expand Down
20 changes: 10 additions & 10 deletions src/zarr/v2/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ def __getitem__(self, key):

def setitems(self, values):
if self.mode == "r":
raise ReadOnlyError()
raise ReadOnlyError

# Normalize keys and make sure the values are bytes
values = {
Expand All @@ -1286,7 +1286,7 @@ def setitems(self, values):

def __setitem__(self, key, value):
if self.mode == "r":
raise ReadOnlyError()
raise ReadOnlyError
key = self._normalize_key(key)
value = ensure_contiguous_ndarray_or_bytes(value)
path = self.dir_path(key)
Expand All @@ -1300,7 +1300,7 @@ def __setitem__(self, key, value):

def __delitem__(self, key):
if self.mode == "r":
raise ReadOnlyError()
raise ReadOnlyError
key = self._normalize_key(key)
path = self.dir_path(key)
if self.fs.isdir(path):
Expand All @@ -1310,7 +1310,7 @@ def __delitem__(self, key):

def delitems(self, keys):
if self.mode == "r":
raise ReadOnlyError()
raise ReadOnlyError
# only remove the keys that exist in the store
nkeys = [self._normalize_key(key) for key in keys if key in self]
# rm errors if you pass an empty collection
Expand Down Expand Up @@ -1369,7 +1369,7 @@ def listdir(self, path=None):

def rmdir(self, path=None):
if self.mode == "r":
raise ReadOnlyError()
raise ReadOnlyError
store_path = self.dir_path(path)
if self.fs.isdir(store_path):
self.fs.rm(store_path, recursive=True)
Expand All @@ -1380,7 +1380,7 @@ def getsize(self, path=None):

def clear(self):
if self.mode == "r":
raise ReadOnlyError()
raise ReadOnlyError
self.map.clear()

@classmethod
Expand Down Expand Up @@ -1670,7 +1670,7 @@ def __getitem__(self, key):

def __setitem__(self, key, value):
if self.mode == "r":
raise ReadOnlyError()
raise ReadOnlyError
value = ensure_contiguous_ndarray_like(value).view("u1")
with self.mutex:
# writestr(key, value) writes with default permissions from
Expand Down Expand Up @@ -1752,7 +1752,7 @@ def getsize(self, path=None):

def clear(self):
if self.mode == "r":
raise ReadOnlyError()
raise ReadOnlyError
with self.mutex:
self.close()
os.remove(self.path)
Expand Down Expand Up @@ -2810,10 +2810,10 @@ def __len__(self):
return len(self.meta_store)

def __delitem__(self, key):
raise ReadOnlyError()
raise ReadOnlyError

def __setitem__(self, key, value):
raise ReadOnlyError()
raise ReadOnlyError

def getsize(self, path):
return getsize(self.meta_store, path)
Expand Down
2 changes: 1 addition & 1 deletion tests/v2/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def __init__(self, pass_on=1):
def __call__(self):
self.c += 1
if self.c != self.pass_on:
raise PermissionError()
raise PermissionError

for x in range(1, 11):
# Any number of failures less than 10 will be accepted.
Expand Down

0 comments on commit fb30670

Please sign in to comment.