Skip to content

Commit f513b63

Browse files
Add mypy (#3958)
1 parent 6a9d200 commit f513b63

File tree

4 files changed

+64
-3
lines changed

4 files changed

+64
-3
lines changed

.github/workflows/lint.yaml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ on:
77
paths:
88
- '**.py' # Run if pushed commits include a change to a Python (.py) file.
99
- '.github/workflows/lint.yaml' # Run if pushed commits include a change to a github actions workflow file.
10-
- '.pyproject.toml' # Run if project configuration file changes.
10+
- 'pyproject.toml' # Run if project configuration file changes.
1111
pull_request:
1212
branches:
1313
- "main"
1414
paths:
1515
- '**.py' # Run if pushed commits include a change to a Python (.py) file.
1616
- '.github/workflows/lint.yaml' # Run if pushed commits include a change to a github actions workflow file.
17-
- '.pyproject.toml' # Run if project configuration file changes.
17+
- 'pyproject.toml' # Run if project configuration file changes.
1818
workflow_dispatch:
1919

2020
jobs:
@@ -34,3 +34,24 @@ jobs:
3434
uses: astral-sh/ruff-action@v3
3535
with:
3636
args: format --check --diff
37+
38+
mypy:
39+
runs-on: ubuntu-latest
40+
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v5
44+
45+
- name: Install uv
46+
uses: astral-sh/setup-uv@v4
47+
with:
48+
enable-cache: true
49+
50+
- name: Set up Python
51+
run: uv python install
52+
53+
- name: Install dependencies
54+
run: uv sync
55+
56+
- name: Run mypy
57+
run: uv run mypy custom_components/battery_notes/ --check-untyped-defs

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Changelog = "https://github.com/andrew-codechimp/HA-Battery-Notes/releases"
2929
dev = [
3030
"colorlog",
3131
"homeassistant==2025.9.0",
32+
"mypy",
3233
"ruff",
3334
]
3435

@@ -156,7 +157,7 @@ follow_imports = "normal"
156157
ignore_missing_imports = true
157158

158159
# be strict
159-
# check_untyped_defs = true
160+
check_untyped_defs = true
160161
# disallow_any_generics = true
161162
# disallow_incomplete_defs = true
162163
# disallow_subclassing_any = true

scripts/lint

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@ set -euo pipefail
44
# Move to project root
55
cd "$(dirname "$0")/.."
66

7+
echo "Running ruff check..."
78
uv run ruff check . --fix
9+
10+
echo "Running mypy type checking..."
11+
uv run mypy custom_components/battery_notes/ --check-untyped-defs
12+
13+
echo "Lint completed successfully!"

uv.lock

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)