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>
18 lines
529 B
Python
Executable file
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")
|