From 6572d1ed92a3d008d983b77ebda139105201b962 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos Orfanos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Fri, 1 Mar 2024 01:30:21 +0100 Subject: [PATCH] CI: Pass ruff tests (#3243) Apply the very simple fixes suggested by ruff. Fixes CI failures, probably related to a recent ruff upgrade. --- .maint/paper_author_list.py | 1 + .maint/update_authors.py | 1 + .maint/update_zenodo.py | 1 + docs/sphinxext/github_link.py | 1 + fmriprep/_warnings.py | 1 + fmriprep/cli/parser.py | 1 + fmriprep/cli/run.py | 1 + fmriprep/cli/tests/test_parser.py | 1 + fmriprep/cli/tests/test_version.py | 1 + fmriprep/config.py | 1 + fmriprep/interfaces/confounds.py | 1 + fmriprep/interfaces/gifti.py | 1 + fmriprep/interfaces/multiecho.py | 1 + fmriprep/interfaces/workbench.py | 1 + fmriprep/tests/test_config.py | 1 + fmriprep/utils/bids.py | 1 + fmriprep/utils/misc.py | 1 + fmriprep/utils/telemetry.py | 1 + fmriprep/workflows/bold/confounds.py | 1 + fmriprep/workflows/bold/outputs.py | 1 + fmriprep/workflows/bold/registration.py | 1 + fmriprep/workflows/bold/resampling.py | 1 + fmriprep/workflows/bold/stc.py | 1 + fmriprep/workflows/bold/t2s.py | 1 + fmriprep/workflows/tests/__init__.py | 1 + wrapper/src/fmriprep_docker/__main__.py | 1 + 26 files changed, 26 insertions(+) diff --git a/.maint/paper_author_list.py b/.maint/paper_author_list.py index 579b61ca0..a6300c635 100755 --- a/.maint/paper_author_list.py +++ b/.maint/paper_author_list.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 """Generate an author list for a new paper or abstract.""" + import json import sys from pathlib import Path diff --git a/.maint/update_authors.py b/.maint/update_authors.py index d2b1b639a..263f88631 100755 --- a/.maint/update_authors.py +++ b/.maint/update_authors.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 """Update and sort the creators list of the zenodo record.""" + import json import sys from pathlib import Path diff --git a/.maint/update_zenodo.py b/.maint/update_zenodo.py index b1d35ef2c..5b30707b8 100755 --- a/.maint/update_zenodo.py +++ b/.maint/update_zenodo.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 """Update and sort the creators list of the zenodo record.""" + import json import sys from pathlib import Path diff --git a/docs/sphinxext/github_link.py b/docs/sphinxext/github_link.py index 2fe41b66b..fabba0ab5 100644 --- a/docs/sphinxext/github_link.py +++ b/docs/sphinxext/github_link.py @@ -2,6 +2,7 @@ This vendored script comes from scikit-learn: https://github.com/scikit-learn/scikit-learn/blob/master/doc/sphinxext/github_link.py """ + import inspect import os import subprocess diff --git a/fmriprep/_warnings.py b/fmriprep/_warnings.py index 70a32cc7e..e4563750b 100644 --- a/fmriprep/_warnings.py +++ b/fmriprep/_warnings.py @@ -21,6 +21,7 @@ # https://www.nipreps.org/community/licensing/ # """Manipulate Python warnings.""" + import logging import warnings diff --git a/fmriprep/cli/parser.py b/fmriprep/cli/parser.py index 822815ffb..f7c8581ed 100644 --- a/fmriprep/cli/parser.py +++ b/fmriprep/cli/parser.py @@ -21,6 +21,7 @@ # https://www.nipreps.org/community/licensing/ # """Parser.""" + import sys from .. import config diff --git a/fmriprep/cli/run.py b/fmriprep/cli/run.py index d095440fe..1ebd14841 100644 --- a/fmriprep/cli/run.py +++ b/fmriprep/cli/run.py @@ -21,6 +21,7 @@ # https://www.nipreps.org/community/licensing/ # """fMRI preprocessing workflow.""" + from .. import config diff --git a/fmriprep/cli/tests/test_parser.py b/fmriprep/cli/tests/test_parser.py index f27d4e14b..0fbca9eee 100644 --- a/fmriprep/cli/tests/test_parser.py +++ b/fmriprep/cli/tests/test_parser.py @@ -21,6 +21,7 @@ # https://www.nipreps.org/community/licensing/ # """Test parser.""" + from argparse import ArgumentError from contextlib import nullcontext diff --git a/fmriprep/cli/tests/test_version.py b/fmriprep/cli/tests/test_version.py index 753dd9ea8..c4eb2d5b6 100644 --- a/fmriprep/cli/tests/test_version.py +++ b/fmriprep/cli/tests/test_version.py @@ -21,6 +21,7 @@ # https://www.nipreps.org/community/licensing/ # """Test version checks.""" + from datetime import datetime, timezone from os import getenv, geteuid from pathlib import Path diff --git a/fmriprep/config.py b/fmriprep/config.py index 96deb1046..337b463ca 100644 --- a/fmriprep/config.py +++ b/fmriprep/config.py @@ -87,6 +87,7 @@ :py:class:`~bids.layout.BIDSLayout`, etc.) """ + import os from multiprocessing import set_start_method diff --git a/fmriprep/interfaces/confounds.py b/fmriprep/interfaces/confounds.py index 299a99286..410b46194 100644 --- a/fmriprep/interfaces/confounds.py +++ b/fmriprep/interfaces/confounds.py @@ -29,6 +29,7 @@ >>> import pandas as pd """ + import os import re diff --git a/fmriprep/interfaces/gifti.py b/fmriprep/interfaces/gifti.py index 54a537acd..517e5c375 100644 --- a/fmriprep/interfaces/gifti.py +++ b/fmriprep/interfaces/gifti.py @@ -1,6 +1,7 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """Interfaces for manipulating GIFTI files.""" + import os import nibabel as nb diff --git a/fmriprep/interfaces/multiecho.py b/fmriprep/interfaces/multiecho.py index ab03ffe25..51ad6a8f0 100644 --- a/fmriprep/interfaces/multiecho.py +++ b/fmriprep/interfaces/multiecho.py @@ -27,6 +27,7 @@ For using multi-echo EPI data. """ + import os from nipype import logging diff --git a/fmriprep/interfaces/workbench.py b/fmriprep/interfaces/workbench.py index 5c20dee51..6c3330a61 100644 --- a/fmriprep/interfaces/workbench.py +++ b/fmriprep/interfaces/workbench.py @@ -1,6 +1,7 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """This module provides interfaces for workbench surface commands.""" + import os from nipype import logging diff --git a/fmriprep/tests/test_config.py b/fmriprep/tests/test_config.py index 2a6b8dadd..c4222280c 100644 --- a/fmriprep/tests/test_config.py +++ b/fmriprep/tests/test_config.py @@ -21,6 +21,7 @@ # https://www.nipreps.org/community/licensing/ # """Check the configuration module and file.""" + import os from unittest.mock import patch diff --git a/fmriprep/utils/bids.py b/fmriprep/utils/bids.py index 700f30def..57bc29269 100644 --- a/fmriprep/utils/bids.py +++ b/fmriprep/utils/bids.py @@ -21,6 +21,7 @@ # https://www.nipreps.org/community/licensing/ # """Utilities to handle BIDS inputs.""" + from __future__ import annotations import json diff --git a/fmriprep/utils/misc.py b/fmriprep/utils/misc.py index 6f7973913..5183f9397 100644 --- a/fmriprep/utils/misc.py +++ b/fmriprep/utils/misc.py @@ -21,6 +21,7 @@ # https://www.nipreps.org/community/licensing/ # """Miscellaneous utilities.""" + from functools import cache diff --git a/fmriprep/utils/telemetry.py b/fmriprep/utils/telemetry.py index c95067a68..35b05b91f 100644 --- a/fmriprep/utils/telemetry.py +++ b/fmriprep/utils/telemetry.py @@ -21,6 +21,7 @@ # https://www.nipreps.org/community/licensing/ # """Stripped out routines for telemetry""" + import os import re diff --git a/fmriprep/workflows/bold/confounds.py b/fmriprep/workflows/bold/confounds.py index f16904633..bdd7c1990 100644 --- a/fmriprep/workflows/bold/confounds.py +++ b/fmriprep/workflows/bold/confounds.py @@ -27,6 +27,7 @@ .. autofunction:: init_bold_confs_wf """ + from nipype.algorithms import confounds as nac from nipype.interfaces import utility as niu from nipype.pipeline import engine as pe diff --git a/fmriprep/workflows/bold/outputs.py b/fmriprep/workflows/bold/outputs.py index 094484156..798e42b69 100644 --- a/fmriprep/workflows/bold/outputs.py +++ b/fmriprep/workflows/bold/outputs.py @@ -21,6 +21,7 @@ # https://www.nipreps.org/community/licensing/ # """Writing out derivative files.""" + from __future__ import annotations import numpy as np diff --git a/fmriprep/workflows/bold/registration.py b/fmriprep/workflows/bold/registration.py index c08a4fa94..6824fc526 100644 --- a/fmriprep/workflows/bold/registration.py +++ b/fmriprep/workflows/bold/registration.py @@ -29,6 +29,7 @@ .. autofunction:: init_fsl_bbr_wf """ + import os import os.path as op import typing as ty diff --git a/fmriprep/workflows/bold/resampling.py b/fmriprep/workflows/bold/resampling.py index b5f13ee0b..e632b7577 100644 --- a/fmriprep/workflows/bold/resampling.py +++ b/fmriprep/workflows/bold/resampling.py @@ -30,6 +30,7 @@ .. autofunction:: init_goodvoxels_bold_mask_wf """ + from __future__ import annotations import typing as ty diff --git a/fmriprep/workflows/bold/stc.py b/fmriprep/workflows/bold/stc.py index 0a820c184..5f5ef7329 100644 --- a/fmriprep/workflows/bold/stc.py +++ b/fmriprep/workflows/bold/stc.py @@ -27,6 +27,7 @@ .. autofunction:: init_bold_stc_wf """ + import nibabel as nb import numpy as np from nipype.interfaces import afni diff --git a/fmriprep/workflows/bold/t2s.py b/fmriprep/workflows/bold/t2s.py index 313593a79..e7a347414 100644 --- a/fmriprep/workflows/bold/t2s.py +++ b/fmriprep/workflows/bold/t2s.py @@ -27,6 +27,7 @@ .. autofunction:: init_bold_t2s_wf """ + import typing as ty from nipype.interfaces import utility as niu diff --git a/fmriprep/workflows/tests/__init__.py b/fmriprep/workflows/tests/__init__.py index e6c33399e..53c1c521f 100644 --- a/fmriprep/workflows/tests/__init__.py +++ b/fmriprep/workflows/tests/__init__.py @@ -21,6 +21,7 @@ # https://www.nipreps.org/community/licensing/ # """Utilities and mocks for testing and documentation building.""" + import os import shutil from contextlib import contextmanager diff --git a/wrapper/src/fmriprep_docker/__main__.py b/wrapper/src/fmriprep_docker/__main__.py index 44d6e1a3b..622f35926 100755 --- a/wrapper/src/fmriprep_docker/__main__.py +++ b/wrapper/src/fmriprep_docker/__main__.py @@ -15,6 +15,7 @@ `NiPreps documentation `__. Please report any feedback to our `GitHub repository `__. """ + import os import re import subprocess