Skip to content

Commit 13e1227

Browse files
authored
Merge pull request numpy#27297 from DimitriPapadopoulos/RSE
MAINT: Apply ruff/flake8-raise rules (RSE)
2 parents 6a3f10f + 477d9d1 commit 13e1227

File tree

14 files changed

+23
-23
lines changed

14 files changed

+23
-23
lines changed

benchmarks/benchmarks/bench_ufunc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def setup(self, ufuncname):
5050
try:
5151
self.afdn = getattr(np, ufuncname)
5252
except AttributeError:
53-
raise NotImplementedError()
53+
raise NotImplementedError
5454
self.args = []
5555
for _, aarg in get_squares_().items():
5656
arg = (aarg,) * 1 # no nin
@@ -97,7 +97,7 @@ def setup(self, ufuncname):
9797
try:
9898
self.ufn = getattr(np, ufuncname)
9999
except AttributeError:
100-
raise NotImplementedError()
100+
raise NotImplementedError
101101
self.args = []
102102
for _, aarg in get_squares_().items():
103103
arg = (aarg,) * self.ufn.nin
@@ -332,7 +332,7 @@ def setup(self, ufuncname):
332332
try:
333333
self.f = getattr(np, ufuncname)
334334
except AttributeError:
335-
raise NotImplementedError()
335+
raise NotImplementedError
336336
self.array_5 = np.array([1., 2., 10., 3., 4.])
337337
self.array_int_3 = np.array([1, 2, 3])
338338
self.float64 = np.float64(1.1)

numpy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def _sanity_check():
443443
try:
444444
x = ones(2, dtype=float32)
445445
if not abs(x.dot(x) - float32(2.0)) < 1e-5:
446-
raise AssertionError()
446+
raise AssertionError
447447
except AssertionError:
448448
msg = ("The current Numpy installation ({!r}) fails to "
449449
"pass simple sanity checks. This can be caused for example "

numpy/_core/numerictypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ def _preprocess_dtype(dtype):
374374
if isinstance(dtype, ma.dtype):
375375
dtype = dtype.type
376376
if isinstance(dtype, ndarray) or dtype not in allTypes.values():
377-
raise _PreprocessDTypeError()
377+
raise _PreprocessDTypeError
378378
return dtype
379379

380380

numpy/_core/tests/test_mem_overlap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def iter_random_view_pairs(x, same_steps=True, equal_size=False):
235235
rng = np.random.RandomState(1234)
236236

237237
if equal_size and same_steps:
238-
raise ValueError()
238+
raise ValueError
239239

240240
def random_slice(n, step):
241241
start = rng.randint(0, n+1, dtype=np.intp)

numpy/_core/tests/test_multiarray.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,14 +1097,14 @@ def __len__(self):
10971097
return 1
10981098

10991099
def __getitem__(self, index):
1100-
raise ValueError()
1100+
raise ValueError
11011101

11021102
class Map:
11031103
def __len__(self):
11041104
return 1
11051105

11061106
def __getitem__(self, index):
1107-
raise KeyError()
1107+
raise KeyError
11081108

11091109
a = np.array([Map()])
11101110
assert_(a.shape == (1,))
@@ -1121,7 +1121,7 @@ def __getitem__(self, ind):
11211121
if ind in [0, 1]:
11221122
return ind
11231123
else:
1124-
raise IndexError()
1124+
raise IndexError
11251125
d = np.array([Point2(), Point2(), Point2()])
11261126
assert_equal(d.dtype, np.dtype(object))
11271127

@@ -8592,7 +8592,7 @@ def __array__(self, dtype=None, copy=None):
85928592
def test__array__reference_leak(self):
85938593
class NotAnArray:
85948594
def __array__(self, dtype=None, copy=None):
8595-
raise NotImplementedError()
8595+
raise NotImplementedError
85968596

85978597
x = NotAnArray()
85988598

@@ -9993,7 +9993,7 @@ def check(self, shape, dtype, order, align):
99939993
elif order is None:
99949994
assert_(x.flags.c_contiguous, err_msg)
99959995
else:
9996-
raise ValueError()
9996+
raise ValueError
99979997

99989998
def test_various_alignments(self):
99999999
for align in [1, 2, 3, 4, 8, 12, 16, 32, 64, None]:

numpy/_core/tests/test_regression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2178,7 +2178,7 @@ class Foo:
21782178
__array_priority__ = 1002
21792179

21802180
def __array__(self, *args, **kwargs):
2181-
raise Exception()
2181+
raise Exception
21822182

21832183
rhs = Foo()
21842184
lhs = np.array(1)

numpy/fft/tests/test_pocketfft.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ def test_fft_with_order(dtype, order, fft):
494494
Y_res = fft(Y, axes=ax)
495495
assert_allclose(X_res, Y_res, atol=_tol, rtol=_tol)
496496
else:
497-
raise ValueError()
497+
raise ValueError
498498

499499

500500
@pytest.mark.parametrize("order", ["F", "C"])

numpy/lib/tests/test_function_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,7 @@ def test_keywords_no_func_code(self):
15631563
try:
15641564
vectorize(random.randrange) # Should succeed
15651565
except Exception:
1566-
raise AssertionError()
1566+
raise AssertionError
15671567

15681568
def test_keywords2_ticket_2100(self):
15691569
# Test kwarg support: enhancement ticket 2100

numpy/lib/tests/test_regression.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def test_append_fields_dtype_list(self):
180180
try:
181181
append_fields(base, names, data, dlist)
182182
except Exception:
183-
raise AssertionError()
183+
raise AssertionError
184184

185185
def test_loadtxt_fields_subarrays(self):
186186
# For ticket #1936
@@ -209,7 +209,7 @@ def test_nansum_with_boolean(self):
209209
try:
210210
np.nansum(a)
211211
except Exception:
212-
raise AssertionError()
212+
raise AssertionError
213213

214214
def test_py3_compat(self):
215215
# gh-2561
@@ -222,6 +222,6 @@ class C:
222222
try:
223223
np.info(C(), output=out)
224224
except AttributeError:
225-
raise AssertionError()
225+
raise AssertionError
226226
finally:
227227
out.close()

numpy/polynomial/chebyshev.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ def chebdiv(c1, c2):
800800
# c1, c2 are trimmed copies
801801
[c1, c2] = pu.as_series([c1, c2])
802802
if c2[-1] == 0:
803-
raise ZeroDivisionError()
803+
raise ZeroDivisionError # FIXME: add message with details to exception
804804

805805
# note: this is more efficient than `pu._div(chebmul, c1, c2)`
806806
lc1 = len(c1)

0 commit comments

Comments
 (0)