|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
| 3 | +import subprocess |
3 | 4 | from collections.abc import Iterable |
4 | 5 | from pathlib import Path |
5 | 6 |
|
@@ -27,22 +28,25 @@ def command(*args: str) -> Iterable[str]: |
27 | 28 | session.run(*command("black"), directory) |
28 | 29 |
|
29 | 30 |
|
30 | | -def _pyupgrade(session: Session, config: Config, files: Iterable[str]) -> None: |
| 31 | +def _pyupgrade(session: Session, config: Config) -> None: |
| 32 | + py_files = python_files(config.root) |
31 | 33 | pyupgrade_args = getattr(config, "pyupgrade_args", _PYUPGRADE_ARGS) |
32 | | - session.run( |
33 | | - "pyupgrade", |
34 | | - *pyupgrade_args, |
35 | | - "--exit-zero-even-if-changed", |
36 | | - *files, |
| 34 | + |
| 35 | + command = ["pyupgrade", *pyupgrade_args, "--exit-zero-even-if-changed"] |
| 36 | + result = subprocess.run( |
| 37 | + command + [*py_files], capture_output=True, text=True, check=True |
37 | 38 | ) |
38 | 39 |
|
| 40 | + session.run("echo", " ".join(command) + f" *py_files({config.root})") |
| 41 | + if result.stderr: |
| 42 | + print(result.stderr.strip()) |
| 43 | + |
39 | 44 |
|
40 | 45 | @nox.session(name="project:fix", python=False) |
41 | 46 | def fix(session: Session) -> None: |
42 | 47 | """Runs all automated fixes on the code base""" |
43 | | - py_files = python_files(PROJECT_CONFIG.root) |
44 | 48 | _version(session, Mode.Fix) |
45 | | - _pyupgrade(session, config=PROJECT_CONFIG, files=py_files) |
| 49 | + _pyupgrade(session, config=PROJECT_CONFIG) |
46 | 50 | _code_format(session, Mode.Fix, PROJECT_CONFIG.root) |
47 | 51 |
|
48 | 52 |
|
|
0 commit comments