Skip to content

Commit b35db57

Browse files
committed
RF: Switch from yapf to black for checkspecs
1 parent 75653fe commit b35db57

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

nipype/info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def get_nipype_gitversion():
176176
"nipy": ["nitime", "nilearn<0.5.0", "dipy", "nipy", "matplotlib"],
177177
"profiler": ["psutil>=5.0"],
178178
"pybids": ["pybids>=0.7.0"],
179-
"specs": ["yapf>=0.27"],
179+
"specs": ["black"],
180180
"ssh": ["paramiko"],
181181
"tests": TESTS_REQUIRES,
182182
"xvfbwrapper": ["xvfbwrapper"],

tools/checkspecs.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,10 @@
77
import re
88
import sys
99
import warnings
10-
from distutils.version import LooseVersion
1110

1211
from nipype.interfaces.base import BaseInterface
1312

14-
import yapf
15-
if LooseVersion(yapf.__version__) < '0.27':
16-
raise ImportError("Please upgrade yapf to version 0.27 or newer for stable formatting")
17-
18-
from yapf.yapflib.yapf_api import FormatCode
13+
import black
1914

2015

2116
# Functions and classes
@@ -248,12 +243,7 @@ def test_specs(self, uri):
248243
assert getattr(inputs.traits()[key], metakey) == value"""
249244
]
250245

251-
fmt_cmd, _ = FormatCode(
252-
'\n'.join(cmd) + '\n\n',
253-
style_config={
254-
'based_on_style': 'pep8',
255-
'column_limit': 79
256-
})
246+
fmt_cmd = black.format_str('\n'.join(cmd), mode=black.FileMode())
257247
with open(testfile, 'wt') as fp:
258248
fp.writelines(fmt_cmd)
259249
else:
@@ -317,14 +307,9 @@ def test_specs(self, uri):
317307
for metakey, value in list(metadata.items()):
318308
assert getattr(outputs.traits()[key], metakey) == value"""
319309
]
320-
fmt_cmd, _ = FormatCode(
321-
'\n'.join(cmd) + '\n',
322-
style_config={
323-
'based_on_style': 'pep8',
324-
'column_limit': 79
325-
})
310+
fmt_cmd = black.format_str('\n'.join(cmd), mode=black.FileMode())
326311
with open(testfile, 'at') as fp:
327-
fp.writelines(fmt_cmd)
312+
fp.writelines("\n\n" + fmt_cmd)
328313

329314
for traitname, trait in sorted(
330315
classinst.output_spec().traits(transient=None).items()):

0 commit comments

Comments
 (0)