|
14 | 14 | import sys |
15 | 15 | import tempfile |
16 | 16 |
|
17 | | -from llnl.util.filesystem import working_dir, mkdirp |
| 17 | +from llnl.util.filesystem import mkdirp, working_dir |
| 18 | +from spack.util.executable import ProcessError, which |
18 | 19 |
|
19 | 20 | import ramble.paths |
20 | | -from spack.util.executable import which, ProcessError |
21 | | - |
22 | 21 |
|
23 | 22 | description = "runs source code style checks on Ramble." |
24 | 23 | section = "developer" |
@@ -119,7 +118,7 @@ def is_object(f): |
119 | 118 | } |
120 | 119 |
|
121 | 120 | # Tools run in the given order, with flake8 as the last check. |
122 | | -tool_names = ["black", "flake8"] |
| 121 | +tool_names = ["isort", "black", "flake8"] |
123 | 122 |
|
124 | 123 | tools = {} |
125 | 124 |
|
@@ -473,6 +472,20 @@ def run_black(black_cmd, file_list, args): |
473 | 472 | return returncode |
474 | 473 |
|
475 | 474 |
|
| 475 | +@tool("isort") |
| 476 | +def run_isort(isort_cmd, file_list, args): |
| 477 | + isort_args = ("--sp", os.path.join(ramble.paths.prefix, "pyproject.toml")) |
| 478 | + if not args.fix: |
| 479 | + isort_args += ("--check", "--diff") |
| 480 | + output = isort_cmd( |
| 481 | + *(isort_args + tuple(file_list)), fail_on_error=False, output=str, error=str |
| 482 | + ) |
| 483 | + returncode = isort_cmd.returncode |
| 484 | + print_output(output, args) |
| 485 | + print_tool_result("isort", returncode) |
| 486 | + return returncode |
| 487 | + |
| 488 | + |
476 | 489 | def validate_toolset(arg_value): |
477 | 490 | """Validate --tool and --skip arguments (sets of optionally comma-separated tools).""" |
478 | 491 | tools = set(",".join(arg_value).split(",")) # allow args like 'black,flake8' |
|
0 commit comments