Skip to content

Commit f7e97e5

Browse files
committed
Add pre-commit configuration file and update dependencies.
Use pre-commit hooks for static checks and version updates on check-in/check-out.
1 parent 42e6c22 commit f7e97e5

File tree

3 files changed

+929
-1551
lines changed

3 files changed

+929
-1551
lines changed

.pre-commit-config.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
default_install_hook_types: [
2+
pre-commit, pre-merge-commit, pre-push,
3+
post-checkout, post-commit]
4+
default_stages: [pre-commit, pre-merge-commit, pre-push, manual]
5+
exclude: (^tests/.*/.*$)
6+
repos:
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v4.6.0
9+
hooks:
10+
- id: check-yaml
11+
- id: end-of-file-fixer
12+
- id: trailing-whitespace
13+
14+
- repo: https://github.com/astral-sh/uv-pre-commit
15+
rev: 0.7.10
16+
hooks:
17+
- id: uv-lock
18+
- id: uv-export
19+
20+
- repo: local
21+
hooks:
22+
- id: static-checks
23+
name: static-checks
24+
description: >-
25+
This hook runs all static checks, including mypy, and ruff.
26+
It is recommended to run this on pre-commit and pre-push.
27+
always_run: true
28+
language: python
29+
entry: uv run tox -m static
30+
31+
- id: update-version
32+
name: update-version
33+
description: >-
34+
This hook uses the hatch-vcs module to update the `_version.py` file.
35+
Call this on post-commit and post-checkout.
36+
stages: [post-commit, post-checkout, manual]
37+
always_run: true
38+
language: python
39+
pass_filenames: false
40+
entry: uv run --frozen hatch build --hooks-only

pyproject.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ classifiers = [
2020
"Topic :: Software Development :: Libraries",
2121
"Typing :: Typed",
2222
]
23-
requires-python = ">=3.8"
23+
requires-python = ">=3.9"
2424
dynamic = ["version"]
2525
dependencies = [
2626
"esptool>=4.6.2",
@@ -46,8 +46,8 @@ test = [
4646
]
4747
dev = [
4848
{include-group = "test"},
49-
# For building and updating _version.py
50-
"hatch>=1.12.0", "hatch-vcs>=0.3.0", "pip>=25.0.1",
49+
"pre-commit>=2.9", "pre-commit-uv>=4.0.0", "pip>=23.0", # pre-commit hooks
50+
"hatch>=1.12.0", "hatch-vcs>=0.3.0", # For building and updating _version.py
5151
]
5252

5353
[build-system]
@@ -86,14 +86,14 @@ lint.extend-select = ["I"] # Enable ruffs isort rules (for compat with vscode r
8686
[tool.coverage]
8787
run.source = ["src", "tests"]
8888
run.omit = ["_version.py"]
89-
report.skip_covered = true
89+
report.skip_covered = false
9090
append = true
9191

9292
# https://tox.wiki/en/latest/config.html#pyproject-toml-native
9393
[tool.tox]
9494
env_list = [
9595
"clean", "typing", "lint", "format",
96-
"3.8", "3.9", "3.10", "3.11", "3.12", "3.13"
96+
"3.9", "3.10", "3.11", "3.12", "3.13"
9797
]
9898
labels.static = ["clean", "typing", "lint", "format"]
9999
env.clean.commands = [["coverage", "erase"]] # Cleanup coverage data
@@ -108,6 +108,7 @@ env_run_base.dependency_groups = ["test"] # Ensure test dependencies are instal
108108
env_run_base.extras = ["littlefs"] # Include optional dependencies
109109
env_run_base.package = "editable" # Use the editable install mode
110110
env_run_base.runner = "uv-venv-runner" # We love uv
111+
env_run_base.skip_install = true
111112

112113
# Overrides for the latest python version
113114
env.3.13.commands = [["pytest", "--cov", {replace = "posargs", extend = true}]]

0 commit comments

Comments
 (0)