|
7 | 7 | import re
|
8 | 8 | import sys
|
9 | 9 | import warnings
|
10 |
| -from distutils.version import LooseVersion |
11 | 10 |
|
12 | 11 | from nipype.interfaces.base import BaseInterface
|
13 | 12 |
|
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 |
19 | 14 |
|
20 | 15 |
|
21 | 16 | # Functions and classes
|
@@ -248,12 +243,7 @@ def test_specs(self, uri):
|
248 | 243 | assert getattr(inputs.traits()[key], metakey) == value"""
|
249 | 244 | ]
|
250 | 245 |
|
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()) |
257 | 247 | with open(testfile, 'wt') as fp:
|
258 | 248 | fp.writelines(fmt_cmd)
|
259 | 249 | else:
|
@@ -317,14 +307,9 @@ def test_specs(self, uri):
|
317 | 307 | for metakey, value in list(metadata.items()):
|
318 | 308 | assert getattr(outputs.traits()[key], metakey) == value"""
|
319 | 309 | ]
|
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()) |
326 | 311 | with open(testfile, 'at') as fp:
|
327 |
| - fp.writelines(fmt_cmd) |
| 312 | + fp.writelines("\n\n" + fmt_cmd) |
328 | 313 |
|
329 | 314 | for traitname, trait in sorted(
|
330 | 315 | classinst.output_spec().traits(transient=None).items()):
|
|
0 commit comments