zephyr/scripts/ruff/gen_format_exclude.py
Pieter De Gendt 4db97b5bb6 scripts: Add helper scripts for ruff baseline excludes
Add simple scripts to convert ruff check and ruff format output to
toml exclude sections.

These sections can be used to ignore baseline violations for an existing
codebase.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-19 18:36:54 -05:00

18 lines
529 B
Python
Executable file

#!/usr/bin/env python3
# Copyright (c) 2024 Basalte bv
# SPDX-License-Identifier: Apache-2.0
import sys
# A very simple script to convert ruff format output to toml
# For example:
# ruff format --check | ./scripts/ruff/gen_format_exclude.py >> .ruff-excludes.toml
if __name__ == "__main__":
sys.stdout.write("[format]\n")
sys.stdout.write("exclude = [\n")
for line in sys.stdin:
if line.startswith("Would reformat: "):
sys.stdout.write(f' "./{line[16:-1]}",\n')
sys.stdout.write("]\n")