From 1298256cdad9442139678719fbcd6c13bb79dcaa Mon Sep 17 00:00:00 2001 From: Rodrigo Roque Date: Fri, 7 Aug 2026 08:05:52 -0300 Subject: [PATCH] chore: repair scripts/setup and align local tooling with the uv workflow scripts/setup still ran pip against a requirements.txt that no longer exists since the migration to uv, which also broke the devcontainer's postCreateCommand. It now runs uv sync with the dev and lint groups, and the devcontainer installs uv and drops the template's leftover name. The pre-commit hooks move to local uv run commands so they always use the exact ruff pinned in pyproject.toml instead of a drifting mirror rev, and a mypy hook now runs the same strict check as CI. --- .devcontainer.json | 3 ++- .pre-commit-config.yaml | 26 +++++++++++++++++++++----- scripts/setup | 8 +------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/.devcontainer.json b/.devcontainer.json index 120bfc3..1c0abe8 100644 --- a/.devcontainer.json +++ b/.devcontainer.json @@ -1,5 +1,5 @@ { - "name": "ludeeus/ttlock_ble", + "name": "roquerodrigo/ha-ttlock-ble", "image": "mcr.microsoft.com/devcontainers/base:debian", "postCreateCommand": "scripts/setup", "forwardPorts": [ @@ -40,6 +40,7 @@ "ghcr.io/devcontainers/features/python:1": { "version": "3.14" }, + "ghcr.io/va-h/devcontainers-features/uv:1": {}, "ghcr.io/devcontainers-extra/features/apt-packages:1": { "packages": "ffmpeg,libturbojpeg0,libpcap-dev" } diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ad551d7..fbe162f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,12 +1,28 @@ # Run with: pre-commit install (after scripts/setup) -# CI mirrors these checks via .github/workflows/lint.yml +# CI mirrors these checks via .github/workflows/ci.yml repos: - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.12 + - repo: local hooks: - - id: ruff-check - args: [--fix] - id: ruff-format + name: ruff format + entry: uv run ruff format + language: system + types_or: [python, pyi] + require_serial: true + + - id: ruff-check + name: ruff check + entry: uv run ruff check --fix + language: system + types_or: [python, pyi] + require_serial: true + + - id: mypy + name: mypy + entry: uv run mypy custom_components/ttlock_ble + language: system + pass_filenames: false + types: [python] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 diff --git a/scripts/setup b/scripts/setup index bee3d47..188cc82 100755 --- a/scripts/setup +++ b/scripts/setup @@ -4,10 +4,4 @@ set -e cd "$(dirname "$0")/.." -# Auto-use ./.venv if present so callers don't need to `source activate`. -if [ -d "${PWD}/.venv" ]; then - export PATH="${PWD}/.venv/bin:${PATH}" - export VIRTUAL_ENV="${PWD}/.venv" -fi - -python3 -m pip install --requirement requirements.txt +uv sync --group dev --group lint