Skip to content

Commit d967046

Browse files
STY: Apply ruff/flake8-simplify rule SIM103
SIM103 Return the condition directly
1 parent 78712fb commit d967046

File tree

7 files changed

+10
-32
lines changed

7 files changed

+10
-32
lines changed

nipype/interfaces/afni/base.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,4 @@ def _cmd_prefix(self):
326326

327327
def no_afni():
328328
"""Check whether AFNI is not available."""
329-
if Info.version() is None:
330-
return True
331-
return False
329+
return Info.version() is None

nipype/interfaces/freesurfer/base.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,4 @@ def no_freesurfer():
269269
used with skipif to skip tests that will
270270
fail if FreeSurfer is not installed"""
271271

272-
if Info.version() is None:
273-
return True
274-
else:
275-
return False
272+
return Info.version() is None

nipype/interfaces/fsl/base.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,7 @@ def no_fsl():
262262
used with skipif to skip tests that will
263263
fail if FSL is not installed"""
264264

265-
if Info.version() is None:
266-
return True
267-
else:
268-
return False
265+
return Info.version() is None
269266

270267

271268
def no_fsl_course_data():

nipype/interfaces/spm/base.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ def func_is_3d(in_file):
5252
else:
5353
img = load(in_file)
5454
shape = img.shape
55-
if len(shape) == 3 or (len(shape) == 4 and shape[3] == 1):
56-
return True
57-
else:
58-
return False
55+
return len(shape) == 3 or len(shape) == 4 and shape[3] == 1
5956

6057

6158
def get_first_3dfile(in_files):
@@ -254,10 +251,7 @@ def no_spm():
254251
used with pytest.mark.skipif decorator to skip tests
255252
that will fail if spm is not installed"""
256253

257-
if "NIPYPE_NO_MATLAB" in os.environ or Info.version() is None:
258-
return True
259-
else:
260-
return False
254+
return "NIPYPE_NO_MATLAB" in os.environ or Info.version() is None
261255

262256

263257
class SPMCommandInputSpec(BaseInterfaceInputSpec):

nipype/pipeline/plugins/condor.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ def _is_pending(self, taskid):
5555
iflogger.setLevel(logging.getLevelName("CRITICAL"))
5656
result = cmd.run(ignore_exception=True)
5757
iflogger.setLevel(oldlevel)
58-
if result.runtime.stdout.count("\n%d" % taskid):
59-
return True
60-
return False
58+
return bool(result.runtime.stdout.count("\n%d" % taskid))
6159

6260
def _submit_batchtask(self, scriptfile, node):
6361
cmd = CommandLine(

nipype/pipeline/plugins/lsf.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ def _is_pending(self, taskid):
5454
result = cmd.run(ignore_exception=True)
5555
iflogger.setLevel(oldlevel)
5656
# logger.debug(result.runtime.stdout)
57-
if "DONE" in result.runtime.stdout or "EXIT" in result.runtime.stdout:
58-
return False
59-
else:
60-
return True
57+
return (
58+
"DONE" not in result.runtime.stdout and "EXIT" not in result.runtime.stdout
59+
)
6160

6261
def _submit_batchtask(self, scriptfile, node):
6362
cmd = CommandLine(

nipype/utils/misc.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,7 @@ def is_container(item):
8787
True if container
8888
False if not (eg string)
8989
"""
90-
if isinstance(item, str):
91-
return False
92-
elif hasattr(item, "__iter__"):
93-
return True
94-
else:
95-
return False
90+
return not isinstance(item, str) and hasattr(item, "__iter__")
9691

9792

9893
def container_to_string(cont):

0 commit comments

Comments
 (0)