Coverage for class_generator/formatters/file_writer.py: 100%
7 statements
« prev ^ index » next coverage.py v7.10.1, created at 2025-07-29 12:31 +0300
« prev ^ index » next coverage.py v7.10.1, created at 2025-07-29 12:31 +0300
1"""File writing and formatting utilities for generated code."""
3import shlex
5from pyhelper_utils.shell import run_command
8def write_and_format_rendered(filepath: str, output: str) -> None:
9 """
10 Write rendered content to file and format it with ruff.
12 Args:
13 filepath: Path to write the file to
14 output: Content to write
15 """
16 with open(filepath, "w") as fd:
17 fd.write(output)
19 for op in ("format", "check"):
20 run_command(
21 command=shlex.split(f"uvx ruff {op} {filepath}"),
22 verify_stderr=False,
23 check=False,
24 )