Skip to content

Commit a605002

Browse files
STY: Apply ruff/flake8-simplify rule SIM103
SIM103 Return the condition directly
1 parent 11ca46a commit a605002

File tree

7 files changed

+8
-32
lines changed

7 files changed

+8
-32
lines changed

nipype/interfaces/afni/base.py

Lines changed: 1 addition & 3 deletions
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

Lines changed: 1 addition & 4 deletions
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

Lines changed: 1 addition & 4 deletions
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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ def func_is_3d(in_file):
5151
else:
5252
img = load(in_file)
5353
shape = img.shape
54-
if len(shape) == 3 or (len(shape) == 4 and shape[3] == 1):
55-
return True
56-
else:
57-
return False
54+
return len(shape) == 3 or len(shape) == 4 and shape[3] == 1
5855

5956

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

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

261255

262256
class SPMCommandInputSpec(BaseInterfaceInputSpec):

nipype/pipeline/plugins/condor.py

Lines changed: 1 addition & 3 deletions
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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ 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 "DONE" not in result.runtime.stdout and "EXIT" not in result.runtime.stdout
6158

6259
def _submit_batchtask(self, scriptfile, node):
6360
cmd = CommandLine(

nipype/utils/misc.py

Lines changed: 1 addition & 6 deletions
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)