| 108 | |
| 109 | |
| 110 | def run_black(root: Path) -> None: |
| 111 | targets = [str(root / d) for d in PYTHON_DIRS if (root / d).is_dir()] |
| 112 | if not targets: |
| 113 | return |
| 114 | |
| 115 | print("Running black...") |
| 116 | if shutil.which("black") is not None: |
| 117 | cmd = ["black", "--quiet", *targets] |
| 118 | else: |
| 119 | cmd = [sys.executable, "-m", "black", "--quiet", *targets] |
| 120 | |
| 121 | result = run(cmd) |
| 122 | if result.returncode == 127 or ( |
| 123 | result.returncode != 0 and shutil.which("black") is None |
| 124 | ): |
| 125 | print("black not available -- skipping. Install with: pip install black") |
| 126 | return |
| 127 | if result.returncode != 0: |
| 128 | print("black failed.") |
| 129 | |
| 130 | |
| 131 | def run_python_step(label: str, script: Path, *args: str) -> None: |