Skip to content

Commit 5079243

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

File tree

30 files changed

+52
-63
lines changed

30 files changed

+52
-63
lines changed

nipype/algorithms/rapidart.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -397,19 +397,13 @@ def _get_output_filenames(self, motionfile, output_dir):
397397
else:
398398
raise Exception("Unknown type of file")
399399
_, filename, ext = split_filename(infile)
400-
artifactfile = os.path.join(
401-
output_dir, "".join(("art.", filename, "_outliers.txt"))
402-
)
403-
intensityfile = os.path.join(
404-
output_dir, "".join(("global_intensity.", filename, ".txt"))
405-
)
406-
statsfile = os.path.join(output_dir, "".join(("stats.", filename, ".txt")))
407-
normfile = os.path.join(output_dir, "".join(("norm.", filename, ".txt")))
408-
plotfile = os.path.join(
409-
output_dir, "".join(("plot.", filename, ".", self.inputs.plot_type))
410-
)
411-
displacementfile = os.path.join(output_dir, "".join(("disp.", filename, ext)))
412-
maskfile = os.path.join(output_dir, "".join(("mask.", filename, ext)))
400+
artifactfile = os.path.join(output_dir, f"art.{filename}_outliers.txt")
401+
intensityfile = os.path.join(output_dir, f"global_intensity.{filename}.txt")
402+
statsfile = os.path.join(output_dir, f"stats.{filename}.txt")
403+
normfile = os.path.join(output_dir, f"norm.{filename}.txt")
404+
plotfile = os.path.join(output_dir, f"plot.{filename}.{self.inputs.plot_type}")
405+
displacementfile = os.path.join(output_dir, f"disp.{filename}{ext}")
406+
maskfile = os.path.join(output_dir, f"mask.{filename}{ext}")
413407
return (
414408
artifactfile,
415409
intensityfile,
@@ -760,7 +754,7 @@ def _get_output_filenames(self, motionfile, output_dir):
760754
"""
761755
(_, filename) = os.path.split(motionfile)
762756
(filename, _) = os.path.splitext(filename)
763-
corrfile = os.path.join(output_dir, "".join(("qa.", filename, "_stimcorr.txt")))
757+
corrfile = os.path.join(output_dir, f"qa.{filename}_stimcorr.txt")
764758
return corrfile
765759

766760
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ 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]
148+
generated_filename = (
149+
f"{hemisphere}.{parameter_name}.{original_filename}"
150150
)
151151
outputs[name_hemisphere].append(
152152
os.path.join(pth, generated_filename)

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
@@ -674,7 +674,7 @@ def _list_outputs(self):
674674
outfile = fname_presuffix(
675675
self.inputs.in_file,
676676
newpath=os.getcwd(),
677-
suffix=".".join(("_thresh", self.inputs.out_type)),
677+
suffix=f"_thresh.{self.inputs.out_type}",
678678
use_ext=False,
679679
)
680680
else:

nipype/interfaces/freesurfer/preprocess.py

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

0 commit comments

Comments
 (0)