Skip to content

Commit 371ac00

Browse files
committed
pyupgrade is not stable (tries to format .cache, etc., so we need files defined, but we can suppress inputs
1 parent e167d36 commit 371ac00

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

exasol/toolbox/nox/_format.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import subprocess
34
from collections.abc import Iterable
45
from pathlib import Path
56

@@ -27,22 +28,25 @@ def command(*args: str) -> Iterable[str]:
2728
session.run(*command("black"), directory)
2829

2930

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)
3133
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
3738
)
3839

40+
session.run("echo", " ".join(command) + f" *py_files({config.root})")
41+
if result.stderr:
42+
print(result.stderr.strip())
43+
3944

4045
@nox.session(name="project:fix", python=False)
4146
def fix(session: Session) -> None:
4247
"""Runs all automated fixes on the code base"""
43-
py_files = python_files(PROJECT_CONFIG.root)
4448
_version(session, Mode.Fix)
45-
_pyupgrade(session, config=PROJECT_CONFIG, files=py_files)
49+
_pyupgrade(session, config=PROJECT_CONFIG)
4650
_code_format(session, Mode.Fix, PROJECT_CONFIG.root)
4751

4852

0 commit comments

Comments
 (0)