Skip to content

Commit aa7dc34

Browse files
STY: Apply ruff/flynt rule FLY002
FLY002 Consider f-string instead of string join
1 parent 4d1352a commit aa7dc34

File tree

30 files changed

+51
-52
lines changed

30 files changed

+51
-52
lines changed

nipype/algorithms/rapidart.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -398,18 +398,18 @@ def _get_output_filenames(self, motionfile, output_dir):
398398
raise Exception("Unknown type of file")
399399
_, filename, ext = split_filename(infile)
400400
artifactfile = os.path.join(
401-
output_dir, "".join(("art.", filename, "_outliers.txt"))
401+
output_dir, f"art.{filename}_outliers.txt"
402402
)
403403
intensityfile = os.path.join(
404-
output_dir, "".join(("global_intensity.", filename, ".txt"))
404+
output_dir, f"global_intensity.{filename}.txt"
405405
)
406-
statsfile = os.path.join(output_dir, "".join(("stats.", filename, ".txt")))
407-
normfile = os.path.join(output_dir, "".join(("norm.", filename, ".txt")))
406+
statsfile = os.path.join(output_dir, f"stats.{filename}.txt")
407+
normfile = os.path.join(output_dir, f"norm.{filename}.txt")
408408
plotfile = os.path.join(
409-
output_dir, "".join(("plot.", filename, ".", self.inputs.plot_type))
409+
output_dir, f"plot.{filename}.{self.inputs.plot_type}"
410410
)
411-
displacementfile = os.path.join(output_dir, "".join(("disp.", filename, ext)))
412-
maskfile = os.path.join(output_dir, "".join(("mask.", filename, ext)))
411+
displacementfile = os.path.join(output_dir, f"disp.{filename}{ext}")
412+
maskfile = os.path.join(output_dir, f"mask.{filename}{ext}")
413413
return (
414414
artifactfile,
415415
intensityfile,
@@ -760,7 +760,7 @@ def _get_output_filenames(self, motionfile, output_dir):
760760
"""
761761
(_, filename) = os.path.split(motionfile)
762762
(filename, _) = os.path.splitext(filename)
763-
corrfile = os.path.join(output_dir, "".join(("qa.", filename, "_stimcorr.txt")))
763+
corrfile = os.path.join(output_dir, f"qa.{filename}_stimcorr.txt")
764764
return corrfile
765765

766766
def _stimcorr_core(self, motionfile, intensityfile, designmatrix, cwd=None):

nipype/interfaces/afni/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def _gen_fname(self, basename, cwd=None, suffix=None, change_ext=True, ext=None)
292292
if ext is None:
293293
ext = Info.output_type_to_ext(self.inputs.outputtype)
294294
if change_ext:
295-
suffix = "".join((suffix, ext)) if suffix else ext
295+
suffix = f"{suffix}{ext}" if suffix else ext
296296

297297
if suffix is None:
298298
suffix = ""

nipype/interfaces/ants/resampling.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def _list_outputs(self):
134134
outputs = self._outputs().get()
135135
_, name, ext = split_filename(os.path.abspath(self.inputs.input_image))
136136
outputs["output_image"] = os.path.join(
137-
os.getcwd(), "".join((name, self.inputs.out_postfix, ext))
137+
os.getcwd(), f"{name}{self.inputs.out_postfix}{ext}"
138138
)
139139
return outputs
140140

@@ -254,7 +254,7 @@ class WarpImageMultiTransform(ANTSCommand):
254254
def _gen_filename(self, name):
255255
if name == "output_image":
256256
_, name, ext = split_filename(os.path.abspath(self.inputs.input_image))
257-
return "".join((name, self.inputs.out_postfix, ext))
257+
return f"{name}{self.inputs.out_postfix}{ext}"
258258
return None
259259

260260
def _format_arg(self, opt, spec, val):

nipype/interfaces/base/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ def version_from_command(self, flag="-v", cmd=None):
709709
out_environ = self._get_environ()
710710
env.update(out_environ)
711711
proc = sp.Popen(
712-
" ".join((cmd, flag)),
712+
f"{cmd} {flag}",
713713
shell=True,
714714
env=canonicalize_env(env),
715715
stdout=sp.PIPE,

nipype/interfaces/base/specs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def _deprecated_warn(self, obj, name, old, new):
136136
msg3 = "It has been replaced by %s." % trait_spec.new_name
137137
else:
138138
msg3 = ""
139-
msg = " ".join((msg1, msg2, msg3))
139+
msg = f"{msg1} {msg2} {msg3}"
140140
if Version(str(trait_spec.deprecated)) < self.package_version:
141141
raise TraitError(msg)
142142
else:

nipype/interfaces/brainsuite/brainsuite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@ def getFileName(inputName, suffix):
18011801
dotRegex = regex.compile("[^.]+")
18021802
# extract between last slash and first period
18031803
inputNoExtension = dotRegex.findall(fullInput)[0]
1804-
return os.path.abspath("".join((inputNoExtension, suffix)))
1804+
return os.path.abspath(f"{inputNoExtension}{suffix}")
18051805

18061806

18071807
def l_outputs(self):

nipype/interfaces/cat12/surface.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,7 @@ def _list_outputs(self):
145145
outputs[name_hemisphere] = []
146146
if not isdefined(outputs[all_files_hemisphere]):
147147
outputs[all_files_hemisphere] = []
148-
generated_filename = ".".join(
149-
[hemisphere, parameter_name, original_filename]
150-
)
148+
generated_filename = f"{hemisphere}.{parameter_name}.{original_filename}"
151149
outputs[name_hemisphere].append(
152150
os.path.join(pth, generated_filename)
153151
)

nipype/interfaces/dtitk/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def _gen_fname(self, basename, cwd=None, suffix=None, change_ext=True, ext=None)
8989
ext = Info.output_type_to_ext(self.inputs.output_type)
9090
if change_ext:
9191
if suffix:
92-
suffix = "".join((suffix, ext))
92+
suffix = f"{suffix}{ext}"
9393
else:
9494
suffix = ext
9595
if suffix is None:

nipype/interfaces/freesurfer/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ def _list_outputs(self):
673673
outfile = fname_presuffix(
674674
self.inputs.in_file,
675675
newpath=os.getcwd(),
676-
suffix=".".join(("_thresh", self.inputs.out_type)),
676+
suffix=f"_thresh.{self.inputs.out_type}",
677677
use_ext=False,
678678
)
679679
else:

nipype/interfaces/freesurfer/preprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2540,7 +2540,7 @@ def _format_arg(self, name, spec, value):
25402540
cmd = " ".join((cmd, "-fa %.1f" % self.inputs.flip_list[i]))
25412541
if isdefined(self.inputs.xfm_list):
25422542
cmd = " ".join((cmd, "-at %s" % self.inputs.xfm_list[i]))
2543-
cmd = " ".join((cmd, file))
2543+
cmd = f"{cmd} {file}"
25442544
return cmd
25452545
return super()._format_arg(name, spec, value)
25462546

0 commit comments

Comments
 (0)