From 38fa63868dc6180641f806a063bfa54d85dcd33e Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 22 Sep 2024 16:07:42 +0200 Subject: [PATCH 1/3] STY: Apply ruff/flynt rule FLY002 FLY002 Consider f-string instead of string join --- nibabel/batteryrunners.py | 2 +- nibabel/gifti/tests/test_gifti.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/nibabel/batteryrunners.py b/nibabel/batteryrunners.py index 30727f3962..860b9b993c 100644 --- a/nibabel/batteryrunners.py +++ b/nibabel/batteryrunners.py @@ -252,7 +252,7 @@ def __str__(self): def message(self): """formatted message string, including fix message if present""" if self.fix_msg: - return '; '.join((self.problem_msg, self.fix_msg)) + return f'{self.problem_msg}; {self.fix_msg}' return self.problem_msg def log_raise(self, logger, error_level=40): diff --git a/nibabel/gifti/tests/test_gifti.py b/nibabel/gifti/tests/test_gifti.py index 1cead0d928..97c929ac4c 100644 --- a/nibabel/gifti/tests/test_gifti.py +++ b/nibabel/gifti/tests/test_gifti.py @@ -423,13 +423,13 @@ def test_gifti_coord(capsys): gcs.xform = None gcs.print_summary() captured = capsys.readouterr() - assert captured.out == '\n'.join( - [ - 'Dataspace: NIFTI_XFORM_UNKNOWN', - 'XFormSpace: NIFTI_XFORM_UNKNOWN', - 'Affine Transformation Matrix: ', - ' None\n', - ] + assert ( + captured.out + == """Dataspace: NIFTI_XFORM_UNKNOWN +XFormSpace: NIFTI_XFORM_UNKNOWN +Affine Transformation Matrix: + None + """ ) gcs.to_xml() From 1c8010bc3d51c031a393558192aa99b30782cc06 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 22 Sep 2024 17:57:58 +0200 Subject: [PATCH 2/3] STY: Enforce ruff/flynt rules (FLY) --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 0dd49c847d..3e2ffa0b43 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -119,6 +119,7 @@ select = [ "B", "C4", "F", + "FLY", "FURB", "I", "PIE", From 27baa683961cdfd42153d368c79ee3ea32ef4ab2 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Mon, 23 Sep 2024 09:34:11 -0400 Subject: [PATCH 3/3] sty: Remove unnecessary trailing whitespace in summary --- nibabel/gifti/gifti.py | 2 +- nibabel/gifti/tests/test_gifti.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/nibabel/gifti/gifti.py b/nibabel/gifti/gifti.py index caee7c3500..c983a14dfd 100644 --- a/nibabel/gifti/gifti.py +++ b/nibabel/gifti/gifti.py @@ -374,7 +374,7 @@ def _to_xml_element(self): def print_summary(self): print('Dataspace: ', xform_codes.niistring[self.dataspace]) print('XFormSpace: ', xform_codes.niistring[self.xformspace]) - print('Affine Transformation Matrix: \n', self.xform) + print('Affine Transformation Matrix:\n', self.xform) def _data_tag_element(dataarray, encoding, dtype, ordering): diff --git a/nibabel/gifti/tests/test_gifti.py b/nibabel/gifti/tests/test_gifti.py index 97c929ac4c..416faf3c84 100644 --- a/nibabel/gifti/tests/test_gifti.py +++ b/nibabel/gifti/tests/test_gifti.py @@ -425,11 +425,12 @@ def test_gifti_coord(capsys): captured = capsys.readouterr() assert ( captured.out - == """Dataspace: NIFTI_XFORM_UNKNOWN + == """\ +Dataspace: NIFTI_XFORM_UNKNOWN XFormSpace: NIFTI_XFORM_UNKNOWN -Affine Transformation Matrix: +Affine Transformation Matrix: None - """ +""" ) gcs.to_xml()