From 75136b2bb86426c22609449b3f48579ee9c2e4f5 Mon Sep 17 00:00:00 2001 From: Mathias Goncalves <goncalves.mathias@gmail.com> Date: Thu, 9 Jan 2025 15:09:16 -0500 Subject: [PATCH 1/2] STY: Ruff format [git-blame-ignore-rev] --- niworkflows/interfaces/bids.py | 8 ++++---- niworkflows/interfaces/confounds.py | 3 +-- niworkflows/interfaces/images.py | 3 +-- niworkflows/interfaces/itk.py | 3 +-- niworkflows/interfaces/nibabel.py | 2 +- niworkflows/interfaces/surf.py | 2 +- niworkflows/interfaces/workbench.py | 3 +-- niworkflows/tests/test_utils.py | 3 +-- niworkflows/tests/test_viz.py | 12 ++++++------ niworkflows/utils/testing.py | 2 +- niworkflows/utils/tests/test_spaces.py | 6 +++--- 11 files changed, 21 insertions(+), 26 deletions(-) diff --git a/niworkflows/interfaces/bids.py b/niworkflows/interfaces/bids.py index ec7131dff3a..53cefc3aead 100644 --- a/niworkflows/interfaces/bids.py +++ b/niworkflows/interfaces/bids.py @@ -773,7 +773,7 @@ def _run_interface(self, runtime): _copy_any(in_file, out_file) if self.inputs.metadata: - sidecar = out_file.parent / f"{out_file.name.split('.', 1)[0]}.json" + sidecar = out_file.parent / f'{out_file.name.split(".", 1)[0]}.json' sidecar.unlink(missing_ok=True) sidecar.write_text(dumps(self.inputs.metadata, indent=2)) self._results['out_meta'].append(str(sidecar)) @@ -1236,7 +1236,7 @@ def _run_interface(self, runtime): {k: getattr(self.inputs, k) for k in meta_fields if k not in self._static_traits} ) if self._metadata: - sidecar = out_file.parent / f"{out_file.name.split('.', 1)[0]}.json" + sidecar = out_file.parent / f'{out_file.name.split(".", 1)[0]}.json' unlink(sidecar, missing_ok=True) sidecar.write_text(dumps(self._metadata, sort_keys=True, indent=2)) self._results['out_meta'] = str(sidecar) @@ -1482,6 +1482,6 @@ def _fmt_xyz(coords: list) -> str: return f'{xyz} mm^3' return ( - f"Template {space} ({_fmt_xyz(res_meta['zooms'])})," - f" curated by TemplateFlow {tf.__version__}" + f'Template {space} ({_fmt_xyz(res_meta["zooms"])}),' + f' curated by TemplateFlow {tf.__version__}' ) diff --git a/niworkflows/interfaces/confounds.py b/niworkflows/interfaces/confounds.py index 08ed16c63e7..6c14d68f483 100644 --- a/niworkflows/interfaces/confounds.py +++ b/niworkflows/interfaces/confounds.py @@ -176,8 +176,7 @@ class _SpikeRegressorsInputSpec(BaseInterfaceInputSpec): concatenate = traits.Bool( True, usedefault=True, - desc='Indicates whether to concatenate spikes to existing confounds ' - 'or return spikes only', + desc='Indicates whether to concatenate spikes to existing confounds or return spikes only', ) output_format = traits.Enum( 'spikes', 'mask', usedefault=True, desc='Format of output (spikes or mask)' diff --git a/niworkflows/interfaces/images.py b/niworkflows/interfaces/images.py index bb04c82ec21..388dbea9bbb 100644 --- a/niworkflows/interfaces/images.py +++ b/niworkflows/interfaces/images.py @@ -702,8 +702,7 @@ def _run_interface(self, runtime): # This check assumes all input masks have same dimensions if img.shape[:3] != mask_imgs[0].shape[:3]: raise NotImplementedError( - 'Input image and mask should be of ' - 'same dimensions before running SignalExtraction' + 'Input image and mask should be of same dimensions before running SignalExtraction' ) # Load the mask. # If mask is a list, each mask is treated as its own ROI/parcel diff --git a/niworkflows/interfaces/itk.py b/niworkflows/interfaces/itk.py index ae9b0274f52..1c8e2c7c156 100644 --- a/niworkflows/interfaces/itk.py +++ b/niworkflows/interfaces/itk.py @@ -91,8 +91,7 @@ class _MultiApplyTransformsInputSpec(_FixTraitApplyTransformsInputSpec): input_image = InputMultiObject( File(exists=True), mandatory=True, - desc='input time-series as a list of volumes after splitting' - ' through the fourth dimension', + desc='input time-series as a list of volumes after splitting through the fourth dimension', ) num_threads = traits.Int(1, usedefault=True, nohash=True, desc='number of parallel processes') save_cmd = traits.Bool( diff --git a/niworkflows/interfaces/nibabel.py b/niworkflows/interfaces/nibabel.py index d041164a692..172adfdb508 100644 --- a/niworkflows/interfaces/nibabel.py +++ b/niworkflows/interfaces/nibabel.py @@ -182,7 +182,7 @@ def _run_interface(self, runtime): img = nb.load(in_file) extra_dims = tuple(dim for dim in img.shape[3:] if dim > 1) or (1,) if len(extra_dims) != 1: - raise ValueError(f"Invalid shape {'x'.join(str(s) for s in img.shape)}") + raise ValueError(f'Invalid shape {"x".join(str(s) for s in img.shape)}') img = img.__class__( img.dataobj.reshape(img.shape[:3] + extra_dims), img.affine, img.header ) diff --git a/niworkflows/interfaces/surf.py b/niworkflows/interfaces/surf.py index 2a1fd76da21..0e75a501516 100644 --- a/niworkflows/interfaces/surf.py +++ b/niworkflows/interfaces/surf.py @@ -192,7 +192,7 @@ def _run_interface(self, runtime): in_file = Path(self.inputs.in_file) extension = ''.join(in_file.suffixes[-((in_file.suffixes[-1] == '.gz') + 1) :]) info = self._pattern.match(in_file.name[: -len(extension)]).groupdict() - self._results['extension'] = f"{info.pop('extprefix', None) or ''}{extension}" + self._results['extension'] = f'{info.pop("extprefix", None) or ""}{extension}' self._results.update(info) if 'hemi' in self._results: self._results['hemi'] = self._results['hemi'].upper() diff --git a/niworkflows/interfaces/workbench.py b/niworkflows/interfaces/workbench.py index 9ad60cf5a30..975f24f19f0 100644 --- a/niworkflows/interfaces/workbench.py +++ b/niworkflows/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/niworkflows/tests/test_utils.py b/niworkflows/tests/test_utils.py index 278ddaee892..dbfff2d59ef 100644 --- a/niworkflows/tests/test_utils.py +++ b/niworkflows/tests/test_utils.py @@ -89,6 +89,5 @@ def test_compression(tmp_path): size = int(os.stat(uncompressed).st_size) size_compress = int(os.stat(compressed).st_size) assert size >= size_compress, ( - f'The uncompressed report is smaller ({size})' - f'than the compressed report ({size_compress})' + f'The uncompressed report is smaller ({size})than the compressed report ({size_compress})' ) diff --git a/niworkflows/tests/test_viz.py b/niworkflows/tests/test_viz.py index fe9d6a796c3..82b65d3a99d 100644 --- a/niworkflows/tests/test_viz.py +++ b/niworkflows/tests/test_viz.py @@ -54,8 +54,8 @@ def test_carpetplot(tr, sorting): output_file=( os.path.join( save_artifacts, - f"carpet_nosegs_{'index' if tr is None else 'time'}_" - f"{'nosort' if sorting is None else sorting}.svg", + f'carpet_nosegs_{"index" if tr is None else "time"}_' + f'{"nosort" if sorting is None else sorting}.svg', ) if save_artifacts else None @@ -87,8 +87,8 @@ def test_carpetplot(tr, sorting): output_file=( os.path.join( save_artifacts, - f"carpet_random_{'index' if tr is None else 'seg'}_" - f"{'nosort' if sorting is None else sorting}.svg", + f'carpet_random_{"index" if tr is None else "seg"}_' + f'{"nosort" if sorting is None else sorting}.svg', ) if save_artifacts else None @@ -114,8 +114,8 @@ def test_carpetplot(tr, sorting): output_file=( os.path.join( save_artifacts, - f"carpet_const_{'index' if tr is None else 'time'}_" - f"{'nosort' if sorting is None else sorting}.svg", + f'carpet_const_{"index" if tr is None else "time"}_' + f'{"nosort" if sorting is None else sorting}.svg', ) if save_artifacts else None diff --git a/niworkflows/utils/testing.py b/niworkflows/utils/testing.py index cf0a271c800..ba6f7ed004a 100644 --- a/niworkflows/utils/testing.py +++ b/niworkflows/utils/testing.py @@ -96,4 +96,4 @@ def to_json(filename, data): def combine_entities(**entities): - return f"_{'_'.join([f'{lab}-{val}' for lab, val in entities.items()])}" if entities else '' + return f'_{"_".join([f"{lab}-{val}" for lab, val in entities.items()])}' if entities else '' diff --git a/niworkflows/utils/tests/test_spaces.py b/niworkflows/utils/tests/test_spaces.py index bf5cfca5b35..8b6e35f6d93 100644 --- a/niworkflows/utils/tests/test_spaces.py +++ b/niworkflows/utils/tests/test_spaces.py @@ -91,9 +91,9 @@ def test_space_action(parser, spaces, expected): pargs = parser.parse_known_args(args=('--spaces',) + spaces)[0] parsed_spaces = pargs.spaces assert isinstance(parsed_spaces, SpatialReferences) - assert all( - isinstance(sp, Reference) for sp in parsed_spaces.references - ), 'Every element must be a `Reference`' + assert all(isinstance(sp, Reference) for sp in parsed_spaces.references), ( + 'Every element must be a `Reference`' + ) assert len(parsed_spaces.references) == len(expected) for ref, expected_ref in zip(parsed_spaces.references, expected): assert str(ref) == expected_ref From 5536e4f6bd05eda10b794f3a9dce9742b18e770a Mon Sep 17 00:00:00 2001 From: Mathias Goncalves <goncalves.mathias@gmail.com> Date: Thu, 9 Jan 2025 15:10:56 -0500 Subject: [PATCH 2/2] MAINT: Add git blame ignore file --- .git-blame-ignore-revs | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000000..e1c9cff3819 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# 2025-01-09 - goncalves.mathias@gmail.com - STY: Ruff format [git-blame-ignore-rev] +75136b2bb86426c22609449b3f48579ee9c2e4f5