Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT: apply pyupgrade suggestions #348

Merged
merged 3 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
Expand Down
1 change: 0 additions & 1 deletion get_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
# @Author: oesteban
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from setuptools import setup
import versioneer
Expand Down
6 changes: 3 additions & 3 deletions smriprep/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def get_parser():

# optional arguments
parser.add_argument(
"--version", action="version", version="smriprep v{}".format(__version__)
"--version", action="version", version=f"smriprep v{__version__}"
)

g_bids = parser.add_argument_group("Options for filtering BIDS queries")
Expand Down Expand Up @@ -380,7 +380,7 @@ def _warn_redirect(message, category, filename, lineno, file=None, line=None):
if missing:
print("Cannot run sMRIPrep. Missing dependencies:")
for iface, cmd in missing:
print("\t{} (Interface: {})".format(cmd, iface))
print(f"\t{cmd} (Interface: {iface})")
sys.exit(2)

# Clean up master process before running workflow, which may create forks
Expand Down Expand Up @@ -453,7 +453,7 @@ def build_workflow(opts, retval):
""".format

# Set up some instrumental utilities
run_uuid = "%s_%s" % (strftime("%Y%m%d-%H%M%S"), uuid.uuid4())
run_uuid = "{}_{}".format(strftime("%Y%m%d-%H%M%S"), uuid.uuid4())

# First check that bids_dir looks like a BIDS folder
bids_dir = opts.bids_dir.resolve()
Expand Down
4 changes: 2 additions & 2 deletions smriprep/interfaces/freesurfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ def cmdline(self):
no_run = True
flags = []
for step, outfiles, infiles in steps:
flag = "-{}".format(step)
noflag = "-no{}".format(step)
flag = f"-{step}"
noflag = f"-no{step}"
if noflag in cmd:
continue
elif flag in cmd:
Expand Down
4 changes: 2 additions & 2 deletions smriprep/interfaces/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class SubjectSummary(SummaryInterface):
def _run_interface(self, runtime):
if isdefined(self.inputs.subject_id):
self._results["subject_id"] = self.inputs.subject_id
return super(SubjectSummary, self)._run_interface(runtime)
return super()._run_interface(runtime)

def _generate_segment(self):
if not isdefined(self.inputs.subjects_dir):
Expand All @@ -122,7 +122,7 @@ def _generate_segment(self):

t2w_seg = ""
if self.inputs.t2w:
t2w_seg = "(+ {:d} T2-weighted)".format(len(self.inputs.t2w))
t2w_seg = f"(+ {len(self.inputs.t2w):d} T2-weighted)"

output_spaces = self.inputs.output_spaces
if not isdefined(output_spaces):
Expand Down
4 changes: 2 additions & 2 deletions smriprep/workflows/surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def _dedup(in_list):
vals = set(in_list)
if len(vals) > 1:
raise ValueError(
"Non-identical values can't be deduplicated:\n{!r}".format(in_list)
f"Non-identical values can't be deduplicated:\n{in_list!r}"
)
return vals.pop()

Expand Down Expand Up @@ -694,7 +694,7 @@ def init_segs_to_native_wf(*, name="segs_to_native", segmentation="aseg"):
The selected segmentation, after resampling in native space

"""
workflow = Workflow(name="%s_%s" % (name, segmentation))
workflow = Workflow(name=f"{name}_{segmentation}")
inputnode = pe.Node(
niu.IdentityInterface(
["in_file", "subjects_dir", "subject_id", "fsnative2t1w_xfm"]
Expand Down