build: use yamlfix for yaml formatting

This commit is contained in:
sebthom
2025-04-28 01:35:36 +02:00
parent bda0acf943
commit 3e8072973a
6 changed files with 287 additions and 35 deletions

View File

@@ -52,10 +52,12 @@ dev = [
"pytest-rerunfailures",
"pytest-cov>=6.0.0",
# linting:
"autopep8",
"ruff",
"mypy",
"basedpyright",
# formatting
"autopep8",
"yamlfix",
# packaging:
"pyinstaller",
"platformdirs", # required by pyinstaller
@@ -78,13 +80,22 @@ write_to = "kleinanzeigen_bot/_version.py"
write_template = "__version__ = '{}'\n"
[tool.pdm.scripts] # https://pdm-project.org/latest/usage/scripts/
app = "python -m kleinanzeigen_bot"
app = "python -m kleinanzeigen_bot"
debug = "python -m pdb -m kleinanzeigen_bot"
compile.cmd = "python -O -m PyInstaller pyinstaller.spec --clean"
compile.env = {PYTHONHASHSEED = "1", SOURCE_DATE_EPOCH = "0"} # https://pyinstaller.org/en/stable/advanced-topics.html#creating-a-reproducible-build
debug = "python -m pdb -m kleinanzeigen_bot"
format = {shell = "autopep8 --recursive --in-place scripts src tests --verbose && python scripts/post_autopep8.py scripts src tests" }
lint = {shell = "ruff check --preview && mypy && basedpyright" }
fix = {shell = "ruff check --preview --fix" }
format = { composite = ["format:py", "format:yaml"] }
"format:py" = { shell = "autopep8 --recursive --in-place scripts src tests --verbose && python scripts/post_autopep8.py scripts src tests" }
"format:yaml" = "yamlfix scripts/ src/ tests/"
lint = { composite = ["lint:ruff", "lint:mypy", "lint:pyright"] }
"lint:ruff" = "ruff check --preview"
"lint:mypy" = "mypy"
"lint:pyright" = "basedpyright"
"lint:fix" = {shell = "ruff check --preview --fix" }
test = "python -m pytest --capture=tee-sys -v"
utest = "python -m pytest --capture=tee-sys -v -m 'not itest'"
itest = "python -m pytest --capture=tee-sys -v -m 'itest'"
@@ -228,6 +239,10 @@ ignore = [
notice-rgx = "SPDX-FileCopyrightText: .*"
min-file-size = 256
[tool.ruff.lint.isort]
# combine-straight-imports = true # not (yet) supported by ruff
[tool.ruff.lint.pylint]
# https://pylint.pycqa.org/en/latest/user_guide/configuration/all-options.html#design-checker
# https://pylint.pycqa.org/en/latest/user_guide/checkers/features.html#design-checker-messages
@@ -299,3 +314,23 @@ filterwarnings = [
"ignore:Exception ignored in:pytest.PytestUnraisableExceptionWarning",
"ignore::DeprecationWarning"
]
#####################
# yamlfix
# https://lyz-code.github.io/yamlfix/
#####################
[tool.yamlfix]
allow_duplicate_keys = true
comments_min_spaces_from_content = 2
comments_require_starting_space = false # FIXME should be true but rule is buggy
comments_whitelines = 1
section_whitelines = 1
explicit_start = false
indentation = 2
line_length = 1024
preserve_quotes = true
quote_basic_values = false
quote_keys_and_basic_values = false
quote_representation = '"'
whitelines = 1