diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9e66823..cc7f998 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -55,10 +55,8 @@ repos: rev: cb8c523fd4835aba42af70f4cad5568db4df0b6c # frozen: v0.16.0 hooks: - id: ruff - files: ^(scripts|tests|custom_components)/.+\.py$ args: [--fix, --exit-non-zero-on-fix] - id: ruff-format - files: ^(scripts|tests|custom_components)/.+\.py$ - repo: https://github.com/pre-commit/mirrors-mypy rev: 41e691678310dfd3833f7ab4e180ddb014310356 # frozen: v2.3.0 diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 0000000..e8050e3 --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2026 The Linux Foundation + +# Ruff configuration for repositories created from this template. +# +# The `select` list is pinned deliberately. Without it ruff applies its +# *default* rule set, and that default is not stable across releases: +# +# ruff 0.15.22 -> 59 rules across 2 categories (E, F) +# ruff 0.16.0 -> 413 rules across 38 categories +# +# A routine pre-commit autoupdate therefore changed which rules run and +# broke fifteen repositories in this organisation simultaneously, on code +# that had not been touched. +# +# Pinning does not decline the unselected rules. It makes adopting them a +# deliberate, reviewed change instead of a side effect of a version bump. +# +# `line-length` and `target-version` are intentionally left unset so that +# ruff's own defaults -- and its inference from `requires-python` where a +# `pyproject.toml` exists -- continue to apply unchanged. + +[lint] +# The de-facto standard across this organisation: present as a superset in +# 13 of the 16 repositories that already pin their rules. +select = ["E", "W", "F", "I", "B", "C4", "UP"] + +ignore = [ + "E501", # line-too-long: the formatter owns line length + "B008", # function call in argument default: typer/click idiom +] + +[lint.per-file-ignores] +# Test suites legitimately break rules that matter in library code. +# Listed even though some are not currently selected, so that widening +# `select` later does not immediately flag every test module. +# +# PLR0917 in particular cannot be satisfied in tests that stack +# `@patch` decorators: unittest.mock injects its mocks positionally, so a +# keyword-only signature is impossible, not merely inconvenient. +"tests/**/*.py" = ["S101", "ARG", "PLR0913", "PLR0917", "PLR2004"]