Skip to content

Commit

Permalink
STYLE: Fix style warnings raised by latest ruff release
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jhlegarreta committed Jan 12, 2025
1 parent a3bdc5d commit a291e16
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion mriqc/bin/labeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def main():
finished[j - 1] = finished[j - 1] + 1
hold[j - 1, i - 1] = int(file[i][j])
finished = np.divide(np.round(np.divide(finished, total) * 1000), 10)
print(f"Completed: {' '.join(['%g%%' % f for f in finished])}")
print(f'Completed: {" ".join(["%g%%" % f for f in finished])}')
print(f'Total: {np.round(np.divide(np.sum(finished), 3))}%')
input('Waiting: [enter]')

Expand Down
4 changes: 2 additions & 2 deletions mriqc/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,8 @@ def parse_args(args=None, namespace=None):
selected_label = set(config.execution.participant_label)
if missing_subjects := selected_label - set(participant_label):
parser.error(
"One or more participant labels were not found in the BIDS directory: "
f"{', '.join(missing_subjects)}."
'One or more participant labels were not found in the BIDS directory: '
f'{", ".join(missing_subjects)}.'
)
participant_label = selected_label

Expand Down
12 changes: 6 additions & 6 deletions mriqc/instrumentation/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ def run(self, *args, **kwargs):

# Write headers (comment trace + header row)
_header = [
f"# MRIQC Resource recorder started tracking PID {self._pid} "
f"{datetime.now(tz=UTC).strftime('(%Y/%m/%d; %H:%M:%S)')}",
f'# MRIQC Resource recorder started tracking PID {self._pid} '
f'{datetime.now(tz=UTC).strftime("(%Y/%m/%d; %H:%M:%S)")}',
'\t'.join(('timestamp', *SAMPLE_ATTRS)).replace(
'memory_info', 'mem_rss_mb\tmem_vsm_mb'
),
Expand All @@ -198,8 +198,8 @@ def run(self, *args, **kwargs):
sample2file(self._pid, fd=_logfile, timestamp=wait_til)
except psutil.NoSuchProcess:
print(
f"# MRIQC Resource recorder killed "
f"{datetime.now(tz=UTC).strftime('(%Y/%m/%d; %H:%M:%S)')}",
f'# MRIQC Resource recorder finished '
f'{datetime.now(tz=UTC).strftime("(%Y/%m/%d; %H:%M:%S)")}',
file=_logfile,
)
_logfile.flush()
Expand All @@ -216,6 +216,6 @@ def stop(self, *args):
self._done.set()
with Path(self._logfile).open('a') as f:
f.write(
f"# MRIQC Resource recorder finished "
f"{datetime.now(tz=UTC).strftime('(%Y/%m/%d; %H:%M:%S)')}",
f'# MRIQC Resource recorder finished '
f'{datetime.now(tz=UTC).strftime("(%Y/%m/%d; %H:%M:%S)")}',
)
2 changes: 1 addition & 1 deletion mriqc/instrumentation/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def plot(filename, param='mem_vsm_mb', mask_processes=(), out_file=None):
for pid in pids:
pid_info = data[data['pid'] == pid]
try:
label = f"{pid_info['name'].values[0]}"
label = f'{pid_info["name"].values[0]}'
except KeyError:
label = f'{pid}'

Expand Down
3 changes: 1 addition & 2 deletions mriqc/interfaces/anatomical.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ def _run_interface(self, runtime): # pylint: disable=R0914,E1101

if np.sum(segdata > 0) < 1e3:
raise RuntimeError(
'Input segmentation data is likely corrupt. '
'MRIQC failed to process this dataset.'
'Input segmentation data is likely corrupt. MRIQC failed to process this dataset.'
)

# Load air, artifacts and head masks
Expand Down
6 changes: 3 additions & 3 deletions mriqc/utils/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def write_derivative_description(bids_dir, deriv_dir):
if 'MRIQC_DOCKER_TAG' in os.environ:
desc['GeneratedBy'][0]['Container'] = {
'Type': 'docker',
'Tag': f"nipreps/mriqc:{os.environ['MRIQC_DOCKER_TAG']}",
'Tag': f'nipreps/mriqc:{os.environ["MRIQC_DOCKER_TAG"]}',
}
if 'MRIQC_SINGULARITY_URL' in os.environ:
desc['GeneratedBy'][0]['Container'] = {
Expand All @@ -83,7 +83,7 @@ def write_derivative_description(bids_dir, deriv_dir):
orig_desc = json.loads(fname.read_text())

if 'Name' in orig_desc:
desc['Name'] = f"MRIQC - {orig_desc['Name']}"
desc['Name'] = f'MRIQC - {orig_desc["Name"]}'
else:
desc['Name'] = 'MRIQC - MRI Quality Control'

Expand Down Expand Up @@ -191,6 +191,6 @@ def derive_bids_fname(
else:
bidts.insert(position, entity.strip('_'))

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

return retval.absolute() if absolute else retval
2 changes: 1 addition & 1 deletion mriqc/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def initialize_meta_and_data(

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


Expand Down

0 comments on commit a291e16

Please sign in to comment.