Replace pre commit with prek#133
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request replaces the pre-commit framework with prek, a faster and more compatible alternative. The migration includes updating dependencies, configuration files, documentation, and GitHub Actions workflows. Additionally, Python code has been updated to follow modern Python 3.12+ conventions through Ruff auto-fixes (using UTC instead of timezone.utc and collections.abc instead of typing).
Changes:
- Replaced pre-commit with prek in dependencies (pyproject.toml and uv.lock)
- Updated .pre-commit-config.yaml to use prek's "builtin" repo feature for faster hook execution
- Modified GitHub Actions linting workflow to use
uv run prekcommands - Updated README and devcontainer configuration to reference prek instead of pre-commit
- Applied Ruff auto-fixes for Python 3.12+ conventions (UTC usage, collections.abc imports)
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Removed pre-commit, pre-commit-hooks, and related dependencies (cfgv, distlib, filelock, identify, nodeenv, virtualenv); added prek 0.3.3 |
| pyproject.toml | Replaced pinned pre-commit and pre-commit-hooks versions with unpinned prek dependency |
| .pre-commit-config.yaml | Restructured to use prek's "builtin" repo for common hooks, added remote pre-commit-hooks repository, organized local hooks |
| .github/workflows/linting.yaml | Updated pre-commit-hooks and pylint jobs to use uv run prek commands; added duplicate check-yaml step |
| README.md | Updated documentation to reference uv and prek instead of Poetry and pre-commit |
| .devcontainer/devcontainer.json | Removed pre-commit feature, switched to custom Dockerfile, updated commands to use uv and prek |
| .devcontainer/Containerfile | New file to customize devcontainer with apt cleanup for deprecated yarn repository |
| tests/test_tado.py | Applied Ruff auto-fix: replaced timezone.utc with UTC constant |
| tests/conftest.py | Applied Ruff auto-fix: replaced typing imports with collections.abc |
| src/tadoasync/tadoasync.py | Applied Ruff auto-fix: replaced timezone.utc with UTC constant |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - name: 🚀 Check YAML files | ||
| run: poetry run pre-commit run check-yaml --all-files | ||
| run: uv run prek run check-yaml --all-files |
There was a problem hiding this comment.
Duplicate step: "Check YAML files" is executed twice (lines 77-78 and 79-80). One of these steps should be removed.
| - name: 🏗 Set up Poetry | ||
| run: pipx install poetry | ||
| - name: 🏗 Set up Python ${{ env.DEFAULT_PYTHON }} | ||
| id: python | ||
| uses: actions/setup-python@v5.0.0 | ||
| with: | ||
| python-version: ${{ env.DEFAULT_PYTHON }} | ||
| cache: "poetry" | ||
| - name: 🏗 Install workflow dependencies | ||
| run: | | ||
| poetry config virtualenvs.create true | ||
| poetry config virtualenvs.in-project true | ||
| - name: 🏗 Install Python dependencies | ||
| run: poetry install --no-interaction |
There was a problem hiding this comment.
The workflow is still using Poetry for dependency management (installing poetry, using poetry cache, running poetry install), but then executing prek with "uv run". This is inconsistent with the project's migration to uv. The workflow should be updated to use uv throughout, replacing poetry setup and installation steps with uv installation and "uv sync".
| "mypy==1.9.0", | ||
| "pre-commit==3.6.0", | ||
| "pre-commit-hooks==4.5.0", | ||
| "prek", |
There was a problem hiding this comment.
The prek dependency is not pinned to a specific version, which is inconsistent with most other dev dependencies in this file (e.g., mypy==1.9.0, pylint==3.0.3, pytest==8.1.1). Consider pinning prek to a specific version for reproducibility. However, if the intent is to always use the latest version, this approach is acceptable but should be documented or made consistent across all dev dependencies.
| "prek", | |
| "prek==0.6.5", |
| - name: 🏗 Set up Poetry | ||
| run: pipx install poetry | ||
| - name: 🏗 Set up Python ${{ env.DEFAULT_PYTHON }} | ||
| id: python | ||
| uses: actions/setup-python@v5.0.0 | ||
| with: | ||
| python-version: ${{ env.DEFAULT_PYTHON }} | ||
| cache: "poetry" | ||
| - name: 🏗 Install workflow dependencies | ||
| run: | | ||
| poetry config virtualenvs.create true | ||
| poetry config virtualenvs.in-project true | ||
| - name: 🏗 Install Python dependencies | ||
| run: poetry install --no-interaction |
There was a problem hiding this comment.
The workflow is still using Poetry for dependency management (installing poetry, using poetry cache, running poetry install), but then executing prek commands with "uv run". This is inconsistent and inefficient. Since the project has migrated to uv (as evidenced by uv.lock, pyproject.toml dependency-groups, and the README updates), the workflow should be updated to use uv throughout. Replace poetry setup and installation steps with uv installation and "uv sync".
Proposed Changes
prek is a faster and better supported implementation of the pre-commit framework, mostly compatible with the original framework.
Related Issues
closes #132