-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
50 lines (47 loc) · 2.51 KB
/
.pre-commit-config.yaml
File metadata and controls
50 lines (47 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
#
# This configuration uses local hooks that rely on packages
# installed in the virtual environment (via requirements.txt).
#
# The hooks use the currently activated virtual environment or fall back
# to the standard location at $HOME/.local/ha-venv.
#
repos:
- repo: local
hooks:
# Run the Ruff linter with auto-fix
- id: ruff
name: ruff
entry: bash -c 'VENV_PATHS=("$HOME/.local/ha-venv" ".local/ha-venv"); for venv in "${VENV_PATHS[@]}"; do if [[ -f "$venv/bin/ruff" ]]; then source "$venv/bin/activate" 2>/dev/null || true; ruff check --fix --exit-non-zero-on-fix "$@"; exit $?; fi; done; echo "⚠️ Skipping ruff (venv not ready)"; exit 0' --
language: system
types: [python]
require_serial: true
pass_filenames: true
# Run the Ruff formatter
- id: ruff-format
name: ruff format
entry: bash -c 'VENV_PATHS=("$HOME/.local/ha-venv" ".local/ha-venv"); for venv in "${VENV_PATHS[@]}"; do if [[ -f "$venv/bin/ruff" ]]; then source "$venv/bin/activate" 2>/dev/null || true; ruff format "$@"; exit $?; fi; done; echo "⚠️ Skipping ruff format (venv not ready)"; exit 0' --
language: system
types: [python]
require_serial: true
pass_filenames: true
# Spell checking
- id: codespell
name: codespell
entry: bash -c 'VENV_PATHS=("$HOME/.local/ha-venv" ".local/ha-venv"); for venv in "${VENV_PATHS[@]}"; do if [[ -f "$venv/bin/codespell" ]]; then source "$venv/bin/activate" 2>/dev/null || true; codespell --ignore-words-list=aiport,astroid,checkin,currenty,hass,iif,incomfort,lookin,nam,NotIn --skip="./.*,*.csv,*.json,*.ambr,uv.lock" --quiet-level=2 "$@"; exit $?; fi; done; echo "⚠️ Skipping codespell (venv not ready)"; exit 0' --
language: system
types_or: [python, markdown, rst]
exclude_types: [csv, json, html]
files: ^(custom_components/|tests/|script/|README\.md|CONTRIBUTING\.md|DEPENDENCIES\.md)
pass_filenames: true
# Type checking with Pyright (optional, can be slow)
# Uncomment to enable in pre-commit (recommended to use in IDE instead)
# - id: pyright
# name: pyright
# entry: bash -c '"$HOME/.local/ha-venv/bin/pyright" "$@"' --
# language: system
# types: [python]
# pass_filenames: true
# # Run manually with: pre-commit run pyright --all-files
# stages: [manual]