Skip to content

Commit 5083109

Browse files
authored
Merge pull request #3681 from DimitriPapadopoulos/F
STY: Apply ruff/Pyflakes rules (F)
2 parents b93b08e + cb889bf commit 5083109

File tree

117 files changed

+44
-405
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+44
-405
lines changed

nipype/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import faulthandler
2626

2727
faulthandler.enable()
28-
except (ImportError, OSError) as e:
28+
except (ImportError, OSError):
2929
pass
3030

3131
config = NipypeConfig()

nipype/algorithms/misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,7 @@ def split_rois(in_file, mask=None, roishape=None):
13451345
"""
13461346
import nibabel as nb
13471347
import numpy as np
1348-
from math import sqrt, ceil
1348+
from math import ceil
13491349
import os.path as op
13501350

13511351
if roishape is None:

nipype/algorithms/tests/test_ErrorMap.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
#!/usr/bin/env python
22

3-
import pytest
4-
from nipype.testing import example_data
53
from nipype.algorithms.metrics import ErrorMap
64
import nibabel as nb
75
import numpy as np
8-
import os
96

107

118
def test_errormap(tmpdir):

nipype/algorithms/tests/test_Overlap.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
33
# vi: set ft=python sts=4 ts=4 sw=4 et:
44

5-
import os
65

76
from nipype.testing import example_data
87

nipype/algorithms/tests/test_confounds.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
import os
32

43
import pytest
54
from nipype.testing import example_data

nipype/algorithms/tests/test_mesh_ops.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
33

4-
import os
54

65
import pytest
7-
import nipype.testing as npt
86
from nipype.testing import example_data
97
import numpy as np
108
from nipype.algorithms import mesh as m

nipype/algorithms/tests/test_modelgen.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
33

44
from copy import deepcopy
5-
import os
65

76
from nibabel import Nifti1Image
87
import numpy as np

nipype/algorithms/tests/test_normalize_tpms.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
33

4-
import os
54

6-
import pytest
75
from nipype.testing import example_data
86

97
import numpy as np
108
import nibabel as nb
11-
import nipype.testing as nit
129

1310
from nipype.algorithms.misc import normalize_tpms
1411

nipype/algorithms/tests/test_splitmerge.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
def test_split_and_merge(tmpdir):
77
import numpy as np
88
import nibabel as nb
9-
import os.path as op
10-
import os
119

1210
from nipype.algorithms.misc import split_rois, merge_rois
1311

nipype/interfaces/afni/model.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,19 @@
1212
import os
1313

1414
from ..base import (
15-
CommandLineInputSpec,
16-
CommandLine,
17-
Directory,
1815
TraitedSpec,
1916
traits,
2017
isdefined,
2118
File,
2219
InputMultiPath,
23-
Undefined,
2420
Str,
2521
Tuple,
2622
)
27-
from ...external.due import BibTeX
2823

2924
from .base import (
30-
AFNICommandBase,
3125
AFNICommand,
3226
AFNICommandInputSpec,
3327
AFNICommandOutputSpec,
34-
Info,
3528
)
3629

3730

nipype/interfaces/ants/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
33
"""The ants module provides basic functions for interfacing with ANTS tools."""
44
import os
5-
from packaging.version import Version, parse
5+
from packaging.version import parse
66

77
# Local imports
88
from ... import logging

nipype/interfaces/ants/resampling.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def _format_arg(self, opt, spec, val):
122122
if isdefined(self.inputs.invert_affine):
123123
diff_inv = set(self.inputs.invert_affine) - set(affine_invert)
124124
if diff_inv:
125-
raise Exceptions(
125+
raise Exception(
126126
"Review invert_affine, not all indexes from invert_affine were used, "
127127
"check the description for the full definition"
128128
)
@@ -275,7 +275,7 @@ def _format_arg(self, opt, spec, val):
275275
if isdefined(self.inputs.invert_affine):
276276
diff_inv = set(self.inputs.invert_affine) - set(affine_invert)
277277
if diff_inv:
278-
raise Exceptions(
278+
raise Exception(
279279
"Review invert_affine, not all indexes from invert_affine were used, "
280280
"check the description for the full definition"
281281
)

nipype/interfaces/cat12/preprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ def _list_outputs(self):
576576
]
577577

578578
outputs["report"] = fname_presuffix(
579-
f, prefix=os.path.join("report", f"cat_"), suffix=".xml", use_ext=False
579+
f, prefix=os.path.join("report", "cat_"), suffix=".xml", use_ext=False
580580
)
581581

582582
outputs["label_files"] = [

nipype/interfaces/cmtk/convert.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import os.path as op
33
import datetime
44
import string
5-
import networkx as nx
65

76
from ...utils.filemanip import split_filename
87
from ..base import (
@@ -13,7 +12,7 @@
1312
InputMultiPath,
1413
isdefined,
1514
)
16-
from .base import CFFBaseInterface, have_cfflib
15+
from .base import CFFBaseInterface
1716

1817

1918
def _read_pickle(fname):

nipype/interfaces/cmtk/nbs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
OutputMultiPath,
1919
isdefined,
2020
)
21-
from .base import have_cv
2221

2322
iflogger = logging.getLogger("nipype.interface")
2423

nipype/interfaces/cmtk/nx.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
OutputMultiPath,
1919
isdefined,
2020
)
21-
from .base import have_cmp
2221

2322
iflogger = logging.getLogger("nipype.interface")
2423

nipype/interfaces/cmtk/parcellation.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
from ... import logging
1212
from ..base import (
13-
BaseInterface,
1413
LibraryBaseInterface,
1514
BaseInterfaceInputSpec,
1615
traits,
@@ -19,21 +18,20 @@
1918
Directory,
2019
isdefined,
2120
)
22-
from .base import have_cmp
2321

2422
iflogger = logging.getLogger("nipype.interface")
2523

2624

2725
def create_annot_label(subject_id, subjects_dir, fs_dir, parcellation_name):
28-
import cmp
26+
from cmp.configuration import PipelineConfiguration
2927
from cmp.util import runCmd
3028

3129
iflogger.info("Create the cortical labels necessary for our ROIs")
3230
iflogger.info("=================================================")
3331
fs_label_dir = op.join(op.join(subjects_dir, subject_id), "label")
3432
output_dir = op.abspath(op.curdir)
3533
paths = []
36-
cmp_config = cmp.configuration.PipelineConfiguration()
34+
cmp_config = PipelineConfiguration()
3735
cmp_config.parcellation_scheme = "Lausanne2008"
3836
for hemi in ["lh", "rh"]:
3937
spath = (
@@ -334,13 +332,13 @@ def create_annot_label(subject_id, subjects_dir, fs_dir, parcellation_name):
334332
def create_roi(subject_id, subjects_dir, fs_dir, parcellation_name, dilation):
335333
"""Creates the ROI_%s.nii.gz files using the given parcellation information
336334
from networks. Iteratively create volume."""
337-
import cmp
335+
from cmp.configuration import PipelineConfiguration
338336
from cmp.util import runCmd
339337

340338
iflogger.info("Create the ROIs:")
341339
output_dir = op.abspath(op.curdir)
342340
fs_dir = op.join(subjects_dir, subject_id)
343-
cmp_config = cmp.configuration.PipelineConfiguration()
341+
cmp_config = PipelineConfiguration()
344342
cmp_config.parcellation_scheme = "Lausanne2008"
345343
log = cmp_config.get_logger()
346344
parval = cmp_config._get_lausanne_parcellation("Lausanne2008")[parcellation_name]
@@ -469,12 +467,12 @@ def create_roi(subject_id, subjects_dir, fs_dir, parcellation_name, dilation):
469467

470468

471469
def create_wm_mask(subject_id, subjects_dir, fs_dir, parcellation_name):
472-
import cmp
470+
from cmp.configuration import PipelineConfiguration
473471
import scipy.ndimage.morphology as nd
474472

475473
iflogger.info("Create white matter mask")
476474
fs_dir = op.join(subjects_dir, subject_id)
477-
cmp_config = cmp.configuration.PipelineConfiguration()
475+
cmp_config = PipelineConfiguration()
478476
cmp_config.parcellation_scheme = "Lausanne2008"
479477
pgpath = cmp_config._get_lausanne_parcellation("Lausanne2008")[parcellation_name][
480478
"node_information_graphml"
@@ -620,10 +618,11 @@ def create_wm_mask(subject_id, subjects_dir, fs_dir, parcellation_name):
620618
def crop_and_move_datasets(
621619
subject_id, subjects_dir, fs_dir, parcellation_name, out_roi_file, dilation
622620
):
621+
from cmp.configuration import PipelineConfiguration
623622
from cmp.util import runCmd
624623

625624
fs_dir = op.join(subjects_dir, subject_id)
626-
cmp_config = cmp.configuration.PipelineConfiguration()
625+
cmp_config = PipelineConfiguration()
627626
cmp_config.parcellation_scheme = "Lausanne2008"
628627
log = cmp_config.get_logger()
629628
output_dir = op.abspath(op.curdir)

nipype/interfaces/cmtk/tests/test_nbs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
have_cv = True
99
try:
1010
package_check("cviewer")
11-
except Exception as e:
11+
except Exception:
1212
have_cv = False
1313

1414

@@ -39,7 +39,7 @@ def test_importerror(creating_graphs, tmpdir):
3939
nbs.inputs.in_group2 = group2
4040
nbs.inputs.edge_key = "weight"
4141

42-
with pytest.raises(ImportError) as e:
42+
with pytest.raises(ImportError):
4343
nbs.run()
4444

4545

nipype/interfaces/dipy/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os.path as op
44
import inspect
55
import numpy as np
6-
from ... import logging
76
from ..base import (
87
traits,
98
File,

nipype/interfaces/dipy/reconstruction.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ class RESTORE(DipyDiffusionInterface):
8585
def _run_interface(self, runtime):
8686
from scipy.special import gamma
8787
from dipy.reconst.dti import TensorModel
88-
import gc
8988

9089
img = nb.load(self.inputs.in_file)
9190
hdr = img.header.copy()
@@ -222,7 +221,6 @@ class EstimateResponseSH(DipyDiffusionInterface):
222221
output_spec = EstimateResponseSHOutputSpec
223222

224223
def _run_interface(self, runtime):
225-
from dipy.core.gradients import GradientTable
226224
from dipy.reconst.dti import fractional_anisotropy, mean_diffusivity
227225
from dipy.reconst.csdeconv import recursive_response, auto_response
228226

nipype/interfaces/dipy/simulate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def _generate_gradients(ndirs=64, values=[1000, 3000], nb0s=1):
324324
325325
"""
326326
import numpy as np
327-
from dipy.core.sphere import disperse_charges, Sphere, HemiSphere
327+
from dipy.core.sphere import disperse_charges, HemiSphere
328328
from dipy.core.gradients import gradient_table
329329

330330
theta = np.pi * np.random.rand(ndirs)

nipype/interfaces/freesurfer/longitudinal.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,13 @@
1313
InputMultiPath,
1414
OutputMultiPath,
1515
isdefined,
16-
InputMultiObject,
17-
Directory,
1816
)
1917
from .base import (
2018
FSCommand,
2119
FSTraitedSpec,
2220
FSCommandOpenMP,
2321
FSTraitedSpecOpenMP,
24-
CommandLine,
2522
)
26-
from .preprocess import ReconAllInputSpec
27-
from ..io import FreeSurferSource
2823

2924
__docformat__ = "restructuredtext"
3025
iflogger = logging.getLogger("nipype.interface")

nipype/interfaces/freesurfer/tests/test_model.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
33

4-
import os
54
import numpy as np
65
import nibabel as nb
76

nipype/interfaces/fsl/aroma.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
File,
1212
Directory,
1313
traits,
14-
isdefined,
1514
)
1615
import os
1716

nipype/interfaces/fsl/tests/test_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import nipype.interfaces.fsl as fsl
66
from nipype.interfaces.base import InterfaceResult
7-
from nipype.interfaces.fsl import check_fsl, no_fsl
7+
from nipype.interfaces.fsl import no_fsl
88

99
import pytest
1010

nipype/interfaces/fsl/tests/test_epi.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
3-
import os
43

54
import pytest
65
from nipype.testing.fixtures import create_files_in_directory

nipype/interfaces/fsl/tests/test_model.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
3-
import os
43

54
import pytest
65
import nipype.interfaces.fsl.model as fsl

nipype/interfaces/fsl/tests/test_preprocess.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from copy import deepcopy
55

66
import pytest
7-
import pdb
87
from nipype.utils.filemanip import split_filename, ensure_list
98
from .. import preprocess as fsl
109
from nipype.interfaces.fsl import Info
@@ -579,7 +578,6 @@ def test_applywarp(setup_flirt):
579578
def setup_fugue(tmpdir):
580579
import nibabel as nb
581580
import numpy as np
582-
import os.path as op
583581

584582
d = np.ones((80, 80, 80))
585583
infile = tmpdir.join("dumbfile.nii.gz").strpath

nipype/interfaces/fsl/tests/test_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55

66
import numpy as np
77

8-
import nibabel as nb
98
import pytest
109
import nipype.interfaces.fsl.utils as fsl
11-
from nipype.interfaces.fsl import no_fsl, Info
10+
from nipype.interfaces.fsl import no_fsl
1211

1312
from nipype.testing.fixtures import create_files_in_directory_plus_output_type
1413

0 commit comments

Comments
 (0)