From 7af53d2aa750fa6ad96f4e343d484638e4ebc58a Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Thu, 29 Feb 2024 22:26:10 +0100 Subject: [PATCH] MNT: Add flake8-logging-format (G) rules to ruff --- fmriprep/_warnings.py | 2 +- fmriprep/interfaces/reports.py | 5 +++-- fmriprep/workflows/bold/stc.py | 2 +- pyproject.toml | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fmriprep/_warnings.py b/fmriprep/_warnings.py index 60b3c2c92..bf7380913 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("%s: %s", category or 'WARNING', message) def _showwarning(message, category, filename, lineno, file=None, line=None): diff --git a/fmriprep/interfaces/reports.py b/fmriprep/interfaces/reports.py index 307a70ee3..68de16d2d 100644 --- a/fmriprep/interfaces/reports.py +++ b/fmriprep/interfaces/reports.py @@ -367,7 +367,8 @@ def get_world_pedir(ornt, pe_direction): if flip[not inv].startswith(axcode): return '-'.join(flip) LOGGER.warning( - 'Cannot determine world direction of phase encoding. ' - f'Orientation: {ornt}; PE dir: {pe_direction}' + 'Cannot determine world direction of phase encoding. Orientation: %s; PE dir: %s', + ornt, + pe_direction, ) return 'Could not be determined - assuming Anterior-Posterior' diff --git a/fmriprep/workflows/bold/stc.py b/fmriprep/workflows/bold/stc.py index 7f024b77e..6d31b357e 100644 --- a/fmriprep/workflows/bold/stc.py +++ b/fmriprep/workflows/bold/stc.py @@ -114,7 +114,7 @@ def init_bold_stc_wf( inputnode = pe.Node(niu.IdentityInterface(fields=['bold_file', 'skip_vols']), name='inputnode') outputnode = pe.Node(niu.IdentityInterface(fields=['stc_file']), name='outputnode') - LOGGER.log(25, f'BOLD series will be slice-timing corrected to an offset of {tzero:.3g}s.') + LOGGER.log(25, 'BOLD series will be slice-timing corrected to an offset of %.3gs.', tzero) # It would be good to fingerprint memory use of afni.TShift slice_timing_correction = pe.Node( diff --git a/pyproject.toml b/pyproject.toml index c65d9d416..25f4390ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -157,6 +157,7 @@ extend-select = [ # "EM", "EXE", "FA", + "G", "ISC", "ICN", "PT",