Skip to content

Commit 96ef836

Browse files
DimitriPapadopoulosFrancescAlted
authored andcommitted
Apply ruff/pyupgrade rule
UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
1 parent fd958c9 commit 96ef836

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

blosc2/lazyexpr.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ def __init__(self, new_op):
9191
self.operands = {"o0": value1, "o1": value2}
9292
self.expression = f"{op}(o0, o1)"
9393
return
94-
if isinstance(value1, (int, float)) and isinstance(value2, (int, float)):
94+
if isinstance(value1, int | float) and isinstance(value2, int | float):
9595
self.expression = f"({value1} {op} {value2})"
96-
elif isinstance(value2, (int, float)):
96+
elif isinstance(value2, int | float):
9797
self.operands = {"o0": value1}
9898
self.expression = f"(o0 {op} {value2})"
99-
elif isinstance(value1, (int, float)):
99+
elif isinstance(value1, int | float):
100100
self.operands = {"o0": value2}
101101
self.expression = f"({value1} {op} o0)"
102102
else:
@@ -133,7 +133,7 @@ def update_expr(self, new_op):
133133
elif isinstance(value1, LazyExpr):
134134
if op == "not":
135135
self.expression = f"({op}{self.expression})"
136-
elif isinstance(value2, (int, float)):
136+
elif isinstance(value2, int | float):
137137
self.expression = f"({self.expression} {op} {value2})"
138138
else:
139139
try:
@@ -143,7 +143,7 @@ def update_expr(self, new_op):
143143
self.operands[op_name] = value2
144144
self.expression = f"({self.expression} {op} {op_name})"
145145
else:
146-
if isinstance(value1, (int, float)):
146+
if isinstance(value1, int | float):
147147
self.expression = f"({value1} {op} {self.expression})"
148148
else:
149149
try:

blosc2/ndarray.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def __setitem__(self, key, value):
163163
start, stop, _ = get_ndarray_start_stop(self.ndim, key, self.shape)
164164
key = (start, stop)
165165

166-
if isinstance(value, (int, float, bool)):
166+
if isinstance(value, int | float | bool):
167167
shape = [sp - st for sp, st in zip(stop, start, strict=False)]
168168
value = np.full(shape, value, dtype=self.dtype)
169169
elif isinstance(value, NDArray):
@@ -379,7 +379,7 @@ def squeeze(self):
379379
super().squeeze()
380380

381381
def _check_allowed_dtypes(self, value: bool | int | float | NDArray, dtype_category: str, op: str):
382-
if not isinstance(value, (int, float, bool, blosc2.LazyExpr, NDArray)):
382+
if not isinstance(value, int | float | bool | blosc2.LazyExpr | NDArray):
383383
raise RuntimeError("Expected bool, int, float, LazyExpr or NDArray instance")
384384

385385
def __and__(self, value: int | float | NDArray, /):
@@ -960,7 +960,7 @@ def contains(ndarr: NDArray, value: str | NDArray, /):
960960
out: :ref:`LazyExpr`
961961
A lazy expression that can be evaluated.
962962
"""
963-
if not isinstance(value, (str, NDArray)):
963+
if not isinstance(value, str | NDArray):
964964
raise ValueError("value should be a string or a NDArray!")
965965
return blosc2.LazyExpr(new_op=(ndarr, "contains", value))
966966

@@ -989,7 +989,7 @@ def abs(ndarr: NDArray, /):
989989
def _check_shape(shape):
990990
if isinstance(shape, int):
991991
shape = (shape,)
992-
elif not isinstance(shape, (tuple, list)):
992+
elif not isinstance(shape, tuple | list):
993993
raise ValueError("shape should be a tuple or a list!")
994994
return shape
995995

0 commit comments

Comments
 (0)