From 7794b41fe6fec289ab874e0b9c1227f99b92bae0 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Tue, 14 Jan 2025 22:03:00 +0100 Subject: [PATCH] Run `ruff format`` --- .maint/update_authors.py | 6 +++--- .maint/update_zenodo.py | 2 +- fmriprep/_warnings.py | 2 +- fmriprep/cli/parser.py | 10 ++++------ fmriprep/cli/workflow.py | 6 +++--- fmriprep/config.py | 2 +- fmriprep/interfaces/workbench.py | 3 +-- fmriprep/reports/tests/test_reports.py | 12 ++++++------ fmriprep/utils/bids.py | 2 +- fmriprep/workflows/base.py | 8 ++++---- fmriprep/workflows/bold/stc.py | 2 +- 11 files changed, 26 insertions(+), 29 deletions(-) diff --git a/.maint/update_authors.py b/.maint/update_authors.py index b439db179..269a8b05b 100755 --- a/.maint/update_authors.py +++ b/.maint/update_authors.py @@ -132,7 +132,7 @@ def get_git_lines(fname='line-contributors.txt'): def _namelast(inlist): retval = [] for i in inlist: - i['name'] = (f"{i.pop('name', '')} {i.pop('lastname', '')}").strip() + i['name'] = (f'{i.pop("name", "")} {i.pop("lastname", "")}').strip() retval.append(i) return retval @@ -187,7 +187,7 @@ def zenodo( misses = set(miss_creators).intersection(miss_contributors) if misses: print( - f"Some people made commits, but are missing in .maint/ files: {', '.join(misses)}", + f'Some people made commits, but are missing in .maint/ files: {", ".join(misses)}', file=sys.stderr, ) @@ -268,7 +268,7 @@ def _aslist(value): if misses: print( - f"Some people made commits, but are missing in .maint/ files: {', '.join(misses)}", + f'Some people made commits, but are missing in .maint/ files: {", ".join(misses)}', file=sys.stderr, ) diff --git a/.maint/update_zenodo.py b/.maint/update_zenodo.py index a31f535c4..29e46ec7f 100755 --- a/.maint/update_zenodo.py +++ b/.maint/update_zenodo.py @@ -73,7 +73,7 @@ def get_git_lines(fname='line-contributors.txt'): if cmd == [None]: cmd = [shutil.which('git-summary'), '--line'] if not lines and cmd[0]: - print(f"Running {' '.join(cmd)!r} on repo") + print(f'Running {" ".join(cmd)!r} on repo') lines = sp.check_output(cmd).decode().splitlines() lines = [line for line in lines if 'Not Committed Yet' not in line] contrib_file.write_text('\n'.join(lines)) diff --git a/fmriprep/_warnings.py b/fmriprep/_warnings.py index 60b3c2c92..151b6ca0c 100644 --- a/fmriprep/_warnings.py +++ b/fmriprep/_warnings.py @@ -35,7 +35,7 @@ def _warn(message, category=None, stacklevel=1, source=None): category = type(category).__name__ category = category.replace('type', 'WARNING') - logging.getLogger('py.warnings').warning(f"{category or 'WARNING'}: {message}") + logging.getLogger('py.warnings').warning(f'{category or "WARNING"}: {message}') def _showwarning(message, category, filename, lineno, file=None, line=None): diff --git a/fmriprep/cli/parser.py b/fmriprep/cli/parser.py index b230a89c0..d98ed7994 100644 --- a/fmriprep/cli/parser.py +++ b/fmriprep/cli/parser.py @@ -54,8 +54,8 @@ class DeprecatedAction(Action): def __call__(self, parser, namespace, values, option_string=None): new_opt, rem_vers = deprecations.get(self.dest, (None, None)) msg = ( - f"{self.option_strings} has been deprecated and will be removed in " - f"{rem_vers or 'a later version'}." + f'{self.option_strings} has been deprecated and will be removed in ' + f'{rem_vers or "a later version"}.' ) if new_opt: msg += f' Please use `{new_opt}` instead.' @@ -557,8 +557,7 @@ def _slice_time_ref(value, parser): action='store', default=0.5, type=float, - help='Threshold for flagging a frame as an outlier on the basis of framewise ' - 'displacement', + help='Threshold for flagging a frame as an outlier on the basis of framewise displacement', ) g_confounds.add_argument( '--dvars-spike-threshold', @@ -900,8 +899,7 @@ def parse_args(args=None, namespace=None): from ..utils.bids import validate_input_dir build_log.info( - 'Making sure the input data is BIDS compliant (warnings can be ignored in most ' - 'cases).' + 'Making sure the input data is BIDS compliant (warnings can be ignored in most cases).' ) validate_input_dir( config.environment.exec_env, diff --git a/fmriprep/cli/workflow.py b/fmriprep/cli/workflow.py index 35140221a..29f2bfdaf 100644 --- a/fmriprep/cli/workflow.py +++ b/fmriprep/cli/workflow.py @@ -58,11 +58,11 @@ def build_workflow(config_file, retval): notice_path = data.load.readable('NOTICE') if notice_path.exists(): banner[0] += '\n' - banner += [f"License NOTICE {'#' * 50}"] + banner += [f'License NOTICE {"#" * 50}'] banner += [f'fMRIPrep {version}'] banner += notice_path.read_text().splitlines(keepends=False)[1:] banner += ['#' * len(banner[1])] - build_log.log(25, f"\n{' ' * 9}".join(banner)) + build_log.log(25, f'\n{" " * 9}'.join(banner)) # warn if older results exist: check for dataset_description.json in output folder msg = check_pipeline_version('fMRIPrep', version, fmriprep_dir / 'dataset_description.json') @@ -121,7 +121,7 @@ def build_workflow(config_file, retval): if config.execution.fs_subjects_dir: init_msg += [f"Pre-run FreeSurfer's SUBJECTS_DIR: {config.execution.fs_subjects_dir}."] - build_log.log(25, f"\n{' ' * 11}* ".join(init_msg)) + build_log.log(25, f'\n{" " * 11}* '.join(init_msg)) retval['workflow'] = init_fmriprep_wf() diff --git a/fmriprep/config.py b/fmriprep/config.py index b89e9ad3d..3ecd4de67 100644 --- a/fmriprep/config.py +++ b/fmriprep/config.py @@ -432,7 +432,7 @@ class execution(_Config): the command line) as spatial references for outputs.""" reports_only = False """Only build the reports, based on the reportlets found in a cached working directory.""" - run_uuid = f"{strftime('%Y%m%d-%H%M%S')}_{uuid4()}" + run_uuid = f'{strftime("%Y%m%d-%H%M%S")}_{uuid4()}' """Unique identifier of this particular run.""" participant_label = None """List of participant identifiers that are to be preprocessed.""" diff --git a/fmriprep/interfaces/workbench.py b/fmriprep/interfaces/workbench.py index 6c3330a61..e666830c1 100644 --- a/fmriprep/interfaces/workbench.py +++ b/fmriprep/interfaces/workbench.py @@ -114,8 +114,7 @@ class MetricDilateInputSpec(OpenMPTraitedSpec): argstr='-exponent %f ', position=9, default=6.0, - desc='exponent n to use in (area / (distance ^ n)) as the ' - 'weighting function (default 6)', + desc='exponent n to use in (area / (distance ^ n)) as the weighting function (default 6)', ) corrected_areas = File( diff --git a/fmriprep/reports/tests/test_reports.py b/fmriprep/reports/tests/test_reports.py index 5d46d1fa1..8489c2881 100644 --- a/fmriprep/reports/tests/test_reports.py +++ b/fmriprep/reports/tests/test_reports.py @@ -101,11 +101,11 @@ def mock_session_list(*args, **kwargs): html_content = Path.read_text(tmp_path / expected_files[0]) if boilerplate: - assert ( - 'The boilerplate text was automatically generated' in html_content - ), f'The file {expected_files[0]} did not contain the reported error.' + assert 'The boilerplate text was automatically generated' in html_content, ( + f'The file {expected_files[0]} did not contain the reported error.' + ) if error: - assert ( - 'One or more execution steps failed' in html_content - ), f'The file {expected_files[0]} did not contain the reported error.' + assert 'One or more execution steps failed' in html_content, ( + f'The file {expected_files[0]} did not contain the reported error.' + ) diff --git a/fmriprep/utils/bids.py b/fmriprep/utils/bids.py index f700ed062..db18d8c01 100644 --- a/fmriprep/utils/bids.py +++ b/fmriprep/utils/bids.py @@ -131,7 +131,7 @@ def write_derivative_description(bids_dir, deriv_dir, dataset_links=None): if 'FMRIPREP_DOCKER_TAG' in os.environ: desc['GeneratedBy'][0]['Container'] = { 'Type': 'docker', - 'Tag': f"nipreps/fmriprep:{os.environ['FMRIPREP_DOCKER_TAG']}", + 'Tag': f'nipreps/fmriprep:{os.environ["FMRIPREP_DOCKER_TAG"]}', } if 'FMRIPREP_SINGULARITY_URL' in os.environ: desc['GeneratedBy'][0]['Container'] = { diff --git a/fmriprep/workflows/base.py b/fmriprep/workflows/base.py index 7ffa8b32e..c8a2fb8a7 100644 --- a/fmriprep/workflows/base.py +++ b/fmriprep/workflows/base.py @@ -232,9 +232,9 @@ def init_single_subject_wf(subject_id: str): if subject_data['roi']: warnings.warn( - f"Lesion mask {subject_data['roi']} found. " - "Future versions of fMRIPrep will use alternative conventions. " - "Please refer to the documentation before upgrading.", + f'Lesion mask {subject_data["roi"]} found. ' + 'Future versions of fMRIPrep will use alternative conventions. ' + 'Please refer to the documentation before upgrading.', FutureWarning, stacklevel=1, ) @@ -828,7 +828,7 @@ def map_fieldmap_estimation( for bold_file, estimator_key in all_estimators.items(): if len(estimator_key) > 1: config.loggers.workflow.warning( - f"Several fieldmaps <{', '.join(estimator_key)}> are " + f'Several fieldmaps <{", ".join(estimator_key)}> are ' f"'IntendedFor' <{bold_file}>, using {estimator_key[0]}" ) estimator_key[1:] = [] diff --git a/fmriprep/workflows/bold/stc.py b/fmriprep/workflows/bold/stc.py index 90c9593cb..65e9e6fe9 100644 --- a/fmriprep/workflows/bold/stc.py +++ b/fmriprep/workflows/bold/stc.py @@ -121,7 +121,7 @@ def init_bold_stc_wf( slice_timing_correction = pe.Node( TShift( outputtype='NIFTI_GZ', - tr=f"{metadata['RepetitionTime']}s", + tr=f'{metadata["RepetitionTime"]}s', slice_timing=metadata['SliceTiming'], slice_encoding_direction=metadata.get('SliceEncodingDirection', 'k'), tzero=tzero,