Skip to content

Commit a291e16

Browse files
committed
STYLE: Fix style warnings raised by latest ruff release
Fix style warnings raised by latest `ruff` release (v0.9.0, released Jan 9, 2025). Fixes style warnings raised for example in: https://github.com/nipreps/mriqc/actions/runs/12700111857/job/35402136045?pr=1369#step:4:134 `ruff` v0.9.0 release blog post: https://astral.sh/blog/ruff-v0.9.0
1 parent a3bdc5d commit a291e16

File tree

7 files changed

+15
-16
lines changed

7 files changed

+15
-16
lines changed

mriqc/bin/labeler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def main():
5454
finished[j - 1] = finished[j - 1] + 1
5555
hold[j - 1, i - 1] = int(file[i][j])
5656
finished = np.divide(np.round(np.divide(finished, total) * 1000), 10)
57-
print(f"Completed: {' '.join(['%g%%' % f for f in finished])}")
57+
print(f'Completed: {" ".join(["%g%%" % f for f in finished])}')
5858
print(f'Total: {np.round(np.divide(np.sum(finished), 3))}%')
5959
input('Waiting: [enter]')
6060

mriqc/cli/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,8 @@ def parse_args(args=None, namespace=None):
603603
selected_label = set(config.execution.participant_label)
604604
if missing_subjects := selected_label - set(participant_label):
605605
parser.error(
606-
"One or more participant labels were not found in the BIDS directory: "
607-
f"{', '.join(missing_subjects)}."
606+
'One or more participant labels were not found in the BIDS directory: '
607+
f'{", ".join(missing_subjects)}.'
608608
)
609609
participant_label = selected_label
610610

mriqc/instrumentation/resources.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ def run(self, *args, **kwargs):
175175

176176
# Write headers (comment trace + header row)
177177
_header = [
178-
f"# MRIQC Resource recorder started tracking PID {self._pid} "
179-
f"{datetime.now(tz=UTC).strftime('(%Y/%m/%d; %H:%M:%S)')}",
178+
f'# MRIQC Resource recorder started tracking PID {self._pid} '
179+
f'{datetime.now(tz=UTC).strftime("(%Y/%m/%d; %H:%M:%S)")}',
180180
'\t'.join(('timestamp', *SAMPLE_ATTRS)).replace(
181181
'memory_info', 'mem_rss_mb\tmem_vsm_mb'
182182
),
@@ -198,8 +198,8 @@ def run(self, *args, **kwargs):
198198
sample2file(self._pid, fd=_logfile, timestamp=wait_til)
199199
except psutil.NoSuchProcess:
200200
print(
201-
f"# MRIQC Resource recorder killed "
202-
f"{datetime.now(tz=UTC).strftime('(%Y/%m/%d; %H:%M:%S)')}",
201+
f'# MRIQC Resource recorder finished '
202+
f'{datetime.now(tz=UTC).strftime("(%Y/%m/%d; %H:%M:%S)")}',
203203
file=_logfile,
204204
)
205205
_logfile.flush()
@@ -216,6 +216,6 @@ def stop(self, *args):
216216
self._done.set()
217217
with Path(self._logfile).open('a') as f:
218218
f.write(
219-
f"# MRIQC Resource recorder finished "
220-
f"{datetime.now(tz=UTC).strftime('(%Y/%m/%d; %H:%M:%S)')}",
219+
f'# MRIQC Resource recorder finished '
220+
f'{datetime.now(tz=UTC).strftime("(%Y/%m/%d; %H:%M:%S)")}',
221221
)

mriqc/instrumentation/viz.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def plot(filename, param='mem_vsm_mb', mask_processes=(), out_file=None):
4545
for pid in pids:
4646
pid_info = data[data['pid'] == pid]
4747
try:
48-
label = f"{pid_info['name'].values[0]}"
48+
label = f'{pid_info["name"].values[0]}'
4949
except KeyError:
5050
label = f'{pid}'
5151

mriqc/interfaces/anatomical.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ def _run_interface(self, runtime): # pylint: disable=R0914,E1101
124124

125125
if np.sum(segdata > 0) < 1e3:
126126
raise RuntimeError(
127-
'Input segmentation data is likely corrupt. '
128-
'MRIQC failed to process this dataset.'
127+
'Input segmentation data is likely corrupt. MRIQC failed to process this dataset.'
129128
)
130129

131130
# Load air, artifacts and head masks

mriqc/utils/bids.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def write_derivative_description(bids_dir, deriv_dir):
6868
if 'MRIQC_DOCKER_TAG' in os.environ:
6969
desc['GeneratedBy'][0]['Container'] = {
7070
'Type': 'docker',
71-
'Tag': f"nipreps/mriqc:{os.environ['MRIQC_DOCKER_TAG']}",
71+
'Tag': f'nipreps/mriqc:{os.environ["MRIQC_DOCKER_TAG"]}',
7272
}
7373
if 'MRIQC_SINGULARITY_URL' in os.environ:
7474
desc['GeneratedBy'][0]['Container'] = {
@@ -83,7 +83,7 @@ def write_derivative_description(bids_dir, deriv_dir):
8383
orig_desc = json.loads(fname.read_text())
8484

8585
if 'Name' in orig_desc:
86-
desc['Name'] = f"MRIQC - {orig_desc['Name']}"
86+
desc['Name'] = f'MRIQC - {orig_desc["Name"]}'
8787
else:
8888
desc['Name'] = 'MRIQC - MRI Quality Control'
8989

@@ -191,6 +191,6 @@ def derive_bids_fname(
191191
else:
192192
bidts.insert(position, entity.strip('_'))
193193

194-
retval = newpath / f"{'_'.join(bidts)}_{newsuffix}.{newext.strip('.')}"
194+
retval = newpath / f'{"_".join(bidts)}_{newsuffix}.{newext.strip(".")}'
195195

196196
return retval.absolute() if absolute else retval

mriqc/utils/misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ def initialize_meta_and_data(
501501

502502
config.loggers.cli.log(
503503
25,
504-
f"File size ('{mod}'): {_max_size:.2f}|{np.mean(size):.2f} " 'GB [maximum|average].',
504+
f"File size ('{mod}'): {_max_size:.2f}|{np.mean(size):.2f} GB [maximum|average].",
505505
)
506506

507507

0 commit comments

Comments
 (0)