Skip to content

Commit 286606c

Browse files
MAINT: apply ruff/flake8-simplify rule SIM103
SIM103 Return the condition `...` directly
1 parent 549e3d6 commit 286606c

File tree

4 files changed

+5
-13
lines changed

4 files changed

+5
-13
lines changed

numpy/_core/_dtype.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,7 @@ def _is_packed(dtype):
277277
if align:
278278
total_offset = _aligned_offset(total_offset, max_alignment)
279279

280-
if total_offset != dtype.itemsize:
281-
return False
282-
return True
280+
return total_offset == dtype.itemsize
283281

284282

285283
def _struct_list_str(dtype):

numpy/_core/numerictypes.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,10 @@ def issctype(rep):
223223
return False
224224
try:
225225
res = obj2sctype(rep)
226-
if res and res != object_:
227-
return True
228-
return False
229226
except Exception:
230227
return False
231-
228+
else:
229+
return res and res != object_
232230

233231
@set_module('numpy')
234232
def obj2sctype(rep, default=None):

numpy/f2py/tests/util.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,7 @@ def check_language(lang, code_snippet=None):
221221
stdout=subprocess.PIPE,
222222
stderr=subprocess.PIPE,
223223
)
224-
if runmeson.returncode == 0:
225-
return True
226-
else:
227-
return False
224+
return runmeson.returncode == 0
228225
finally:
229226
shutil.rmtree(tmpdir)
230227
return False

numpy/tests/test_public_api.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,7 @@ def test_functions_single_location():
614614
# else check if we got a function-like object
615615
elif (
616616
inspect.isfunction(member) or
617-
isinstance(member, dispatched_function) or
618-
isinstance(member, np.ufunc)
617+
isinstance(member, (dispatched_function, np.ufunc))
619618
):
620619
if member in visited_functions:
621620

0 commit comments

Comments
 (0)