Skip to content

Commit 982ac71

Browse files
DimitriPapadopouloseffigies
authored andcommitted
STY: Apply ruff/flake8-bugbear rule B018
B018 Found useless expression. Either assign it to a variable or remove it.
1 parent 5dd99c2 commit 982ac71

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

nipype/interfaces/ants/tests/test_resampling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ def test_WarpTimeSeriesImageMultiTransform_invaffine_wrong(change_dir, create_wt
103103
wtsimt = create_wtsimt
104104
wtsimt.inputs.invert_affine = [0]
105105
with pytest.raises(Exception):
106-
wtsimt.cmdline
106+
wtsimt.cmdline # noqa: B018

nipype/interfaces/ants/tests/test_segmentation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,20 @@ def test_LaplacianThickness_wrongargs(change_dir, create_lt):
4646
with pytest.raises(
4747
ValueError, match=r".* requires a value for input 'sulcus_prior' .*"
4848
):
49-
lt.cmdline
49+
lt.cmdline # noqa: B018
5050
lt.inputs.sulcus_prior = 0.15
5151
with pytest.raises(ValueError, match=r".* requires a value for input 'dT' .*"):
52-
lt.cmdline
52+
lt.cmdline # noqa: B018
5353
lt.inputs.dT = 0.01
5454
with pytest.raises(
5555
ValueError, match=r".* requires a value for input 'prior_thickness' .*"
5656
):
57-
lt.cmdline
57+
lt.cmdline # noqa: B018
5858
lt.inputs.prior_thickness = 5.9
5959
with pytest.raises(
6060
ValueError, match=r".* requires a value for input 'smooth_param' .*"
6161
):
62-
lt.cmdline
62+
lt.cmdline # noqa: B018
6363
lt.inputs.smooth_param = 4.5
6464
assert (
6565
lt.cmdline == "LaplacianThickness functional.nii diffusion_weighted.nii "

nipype/interfaces/base/tests/test_specs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ def test_TraitedSpec_dynamic():
7171
a.foo = 1
7272
assign_a = lambda: setattr(a, "foo", "a")
7373
with pytest.raises(Exception):
74-
assign_a
74+
assign_a()
7575
pkld_a = dumps(a)
7676
unpkld_a = loads(pkld_a)
7777
assign_a_again = lambda: setattr(unpkld_a, "foo", "a")
7878
with pytest.raises(Exception):
79-
assign_a_again
79+
assign_a_again()
8080

8181

8282
def test_DynamicTraitedSpec_tab_completion():
@@ -276,7 +276,7 @@ class TestCycle(nib.CommandLine):
276276
to0 = TestCycle()
277277
not_raised = True
278278
try:
279-
to0.cmdline
279+
to0.cmdline # noqa: B018
280280
except nib.NipypeInterfaceError:
281281
not_raised = False
282282
assert not not_raised

nipype/interfaces/freesurfer/tests/test_preprocess.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def test_mandatory_outvol(create_files_in_directory):
126126

127127
# test raising error with mandatory args absent
128128
with pytest.raises(ValueError):
129-
mni.cmdline
129+
mni.cmdline # noqa: B018
130130

131131
# test with minimal args
132132
mni.inputs.in_file = filelist[0]
@@ -164,7 +164,7 @@ def test_bbregister(create_files_in_directory):
164164

165165
# test raising error with mandatory args absent
166166
with pytest.raises(ValueError):
167-
bbr.cmdline
167+
bbr.cmdline # noqa: B018
168168

169169
bbr.inputs.subject_id = "fsaverage"
170170
bbr.inputs.source_file = filelist[0]
@@ -173,9 +173,9 @@ def test_bbregister(create_files_in_directory):
173173
# Check that 'init' is mandatory in FS < 6, but not in 6+
174174
if Info.looseversion() < LooseVersion("6.0.0"):
175175
with pytest.raises(ValueError):
176-
bbr.cmdline
176+
bbr.cmdline # noqa: B018
177177
else:
178-
bbr.cmdline
178+
bbr.cmdline # noqa: B018
179179

180180
bbr.inputs.init = "fsl"
181181

nipype/interfaces/fsl/tests/test_preprocess.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,11 @@ def test_flirt(setup_flirt):
229229
flirter = fsl.FLIRT()
230230
# infile not specified
231231
with pytest.raises(ValueError):
232-
flirter.cmdline
232+
flirter.cmdline # noqa: B018
233233
flirter.inputs.in_file = infile
234234
# reference not specified
235235
with pytest.raises(ValueError):
236-
flirter.cmdline
236+
flirter.cmdline # noqa: B018
237237
flirter.inputs.reference = reffile
238238

239239
# Generate outfile and outmatrix
@@ -253,7 +253,7 @@ def test_flirt(setup_flirt):
253253
axfm.inputs.apply_xfm = True
254254
# in_matrix_file or uses_qform must be defined
255255
with pytest.raises(RuntimeError):
256-
axfm.cmdline
256+
axfm.cmdline # noqa: B018
257257
axfm2 = deepcopy(axfm)
258258
# test uses_qform
259259
axfm.inputs.uses_qform = True

tools/checkspecs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ def _survives_exclude(self, matchstr, match_type):
418418
matchstr = matchstr[L:]
419419
for pat in patterns:
420420
try:
421-
pat.search
421+
pat.search # noqa: B018
422422
except AttributeError:
423423
pat = re.compile(pat)
424424
if pat.search(matchstr):

0 commit comments

Comments
 (0)