Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 31 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
ci:
autofix_commit_msg: "Apply pre-commit auto fixes"
autoupdate_commit_msg: "Auto-update pre-commit hooks"
skip: [mypy]
Comment thread
TheJulianJES marked this conversation as resolved.

repos:
- repo: https://github.com/codespell-project/codespell
rev: v2.4.2
- repo: local
hooks:
- id: codespell
additional_dependencies: [tomli]
args: ["--toml", "pyproject.toml"]
name: codespell
entry: uv run --frozen codespell --toml pyproject.toml
language: system
types: [text]

- id: ruff-check
name: ruff check
entry: uv run --frozen ruff check --force-exclude --fix
language: system
types_or: [python, pyi]
require_serial: true

- id: ruff-format
name: ruff format
entry: uv run --frozen ruff format --force-exclude
language: system
types_or: [python, pyi]
require_serial: true

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v2.1.0
hooks:
- id: mypy

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.14
name: mypy
entry: uv run --frozen mypy
language: system
types_or: [python, pyi]
require_serial: true
files: ^zha/

- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.11.16
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
- id: uv-lock
args: ["--check"]
239 changes: 235 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,34 @@ testing = [
"python-slugify"
]

[dependency-groups]
testing = [
"codespell==2.4.2",
"coloredlogs",
"colorlog",
"coverage[toml]",
"freezegun",
"looptime>=0.7",
"mypy==2.1.0",
"pre-commit==4.6.0",
"pytest",
"pytest-asyncio<1.0",
"pytest-cov",
"pytest-sugar",
"pytest-timeout",
"python-slugify",
"ruff==0.15.15",
"uv>=0.11.16",
]
ci = [
{include-group = "testing"},
"pytest-github-actions-annotate-failures",
"pytest-xdist",
]

[tool.uv]
default-groups = ["testing"]

[tool.setuptools-git-versioning]
enabled = true

Expand Down Expand Up @@ -63,12 +91,215 @@ error_summary = true
install_types = true
non_interactive = true

# Per-module error-code suppressions below are regenerated by
# `python -m tools.regenerate_mypy_ignores`. They are sorted easiest-to-fix
# first; clean up a module's errors and re-run the tool to shrink the list.
# Autogenerated mypy overrides: start
[[tool.mypy.overrides]]
module = "zha.application.discovery"
disable_error_code = [
"no-untyped-def",
"no-any-return",
"no-untyped-call",
"arg-type",
"no-any-return", # 3
]

[[tool.mypy.overrides]]
module = "zha.application.platforms.update"
disable_error_code = [
"arg-type", # 3
]

[[tool.mypy.overrides]]
module = "zha.async_"
disable_error_code = [
"arg-type", # 2
"no-untyped-def", # 1
]

[[tool.mypy.overrides]]
module = "zha.zigbee.cluster_config"
disable_error_code = [
"arg-type", # 2
"no-untyped-call", # 1
]

[[tool.mypy.overrides]]
module = "zha.application.platforms.lock"
disable_error_code = [
"arg-type", # 3
"no-untyped-def", # 1
]

[[tool.mypy.overrides]]
module = "zha.application.platforms.siren"
disable_error_code = [
"arg-type", # 2
"assignment", # 2
]

[[tool.mypy.overrides]]
module = "zha.event"
disable_error_code = [
"no-untyped-def", # 4
]

[[tool.mypy.overrides]]
module = "zha.application.platforms.device_tracker"
disable_error_code = [
"arg-type", # 2
"no-untyped-def", # 3
]

[[tool.mypy.overrides]]
module = "zha.zigbee.group"
disable_error_code = [
"no-untyped-def", # 3
"return-value", # 2
]

[[tool.mypy.overrides]]
module = "zha.application.platforms"
disable_error_code = [
"arg-type", # 1
"assignment", # 1
"attr-defined", # 2
"no-any-return", # 2
]

[[tool.mypy.overrides]]
module = "zha.application.platforms.button"
disable_error_code = [
"arg-type", # 5
"assignment", # 2
"override", # 2
]

[[tool.mypy.overrides]]
module = "zha.application.gateway"
disable_error_code = [
"arg-type", # 3
"assignment", # 2
"no-untyped-call", # 4
"return-value", # 1
]

[[tool.mypy.overrides]]
module = "zha.application.platforms.fan"
disable_error_code = [
"arg-type", # 5
"index", # 1
"no-any-return", # 3
"no-untyped-def", # 1
]

[[tool.mypy.overrides]]
module = "zha.application.platforms.alarm_control_panel"
disable_error_code = [
"arg-type", # 1
"no-untyped-call", # 1
"no-untyped-def", # 11
]

[[tool.mypy.overrides]]
module = "zha.application.helpers"
disable_error_code = [
"arg-type", # 2
"no-untyped-call", # 4
"no-untyped-def", # 10
]

[[tool.mypy.overrides]]
module = "zha.application.platforms.cover"
disable_error_code = [
"arg-type", # 3
"no-any-return", # 3
"no-untyped-call", # 6
"no-untyped-def", # 5
]

[[tool.mypy.overrides]]
module = "zha.application.platforms.binary_sensor"
disable_error_code = [
"arg-type", # 22
"no-any-return", # 1
"no-untyped-call", # 1
"no-untyped-def", # 1
"override", # 1
]

[[tool.mypy.overrides]]
module = "zha.application.platforms.light"
disable_error_code = [
"arg-type", # 9
"no-any-return", # 4
"no-untyped-call", # 11
"no-untyped-def", # 8
"type-var", # 2
]

[[tool.mypy.overrides]]
module = "zha.application.platforms.select"
disable_error_code = [
"arg-type", # 33
"override", # 1
]

[[tool.mypy.overrides]]
module = "zha.application.platforms.virtual"
disable_error_code = [
"arg-type", # 40
"no-any-return", # 1
]

[[tool.mypy.overrides]]
module = "zha.application.platforms.climate"
disable_error_code = [
"arg-type", # 9
"call-overload", # 4
"no-any-return", # 23
"no-untyped-def", # 8
]

[[tool.mypy.overrides]]
module = "zha.application.platforms.switch"
disable_error_code = [
"arg-type", # 41
"no-any-return", # 1
"no-untyped-call", # 2
"override", # 1
]

[[tool.mypy.overrides]]
module = "zha.zigbee.device"
disable_error_code = [
"arg-type", # 12
"assignment", # 2
"no-any-return", # 4
"no-untyped-call", # 4
"no-untyped-def", # 10
"return-value", # 1
"union-attr", # 18
]

[[tool.mypy.overrides]]
module = "zha.application.platforms.number"
disable_error_code = [
"arg-type", # 56
"no-any-return", # 2
"override", # 1
]

[[tool.mypy.overrides]]
module = "zha.application.platforms.sensor"
disable_error_code = [
"arg-type", # 88
"assignment", # 1
"attr-defined", # 5
"no-any-return", # 9
"no-untyped-call", # 4
"no-untyped-def", # 3
"operator", # 4
"override", # 3
]
# Autogenerated mypy overrides: end

[[tool.mypy.overrides]]
module = [
Expand Down
17 changes: 0 additions & 17 deletions requirements_test.txt

This file was deleted.

10 changes: 4 additions & 6 deletions script/setup
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@ fi

if [ ! -n "$VIRTUAL_ENV" ]; then
if [ -x "$(command -v uv)" ]; then
uv venv venv
uv venv
else
python3 -m venv venv
python3 -m venv .venv
fi
source venv/bin/activate
source .venv/bin/activate
fi

if ! [ -x "$(command -v uv)" ]; then
python3 -m pip install uv
fi

uv pip install -U pip setuptools pre-commit
uv pip install -r requirements_test.txt
uv pip install -e .
uv sync

pre-commit install
Loading
Loading