[patch] Unify dev tooling via uv so pre-commit, CI, and the update bot stay aligned #48

Merged
brian merged 1 commits from chore/align-dev-tooling-via-uv into main 2026-07-10 14:36:46 +02:00
21 changed files with 94 additions and 42 deletions
@@ -14,12 +14,38 @@ jobs:
with: with:
token: ${{ secrets.CI_RUNNER_TOKEN }} token: ${{ secrets.CI_RUNNER_TOKEN }}
- name: Sync dependencies
env:
UV_LINK_MODE: copy
UV_INDEX_GITEA_USERNAME: ci-bot
UV_INDEX_GITEA_PASSWORD: ${{ secrets.CI_RUNNER_TOKEN }}
run: uv sync --all-extras
- name: Upgrade dependencies - name: Upgrade dependencies
env: env:
UV_INDEX_GITEA_USERNAME: ci-bot UV_INDEX_GITEA_USERNAME: ci-bot
UV_INDEX_GITEA_PASSWORD: ${{ secrets.CI_RUNNER_TOKEN }} UV_INDEX_GITEA_PASSWORD: ${{ secrets.CI_RUNNER_TOKEN }}
run: uv lock --upgrade run: uv lock --upgrade
- name: Update pre-commit hook revs
env:
UV_INDEX_GITEA_USERNAME: ci-bot
UV_INDEX_GITEA_PASSWORD: ${{ secrets.CI_RUNNER_TOKEN }}
run: uv run pre-commit autoupdate
- name: Sync upgraded dependencies
env:
UV_LINK_MODE: copy
UV_INDEX_GITEA_USERNAME: ci-bot
UV_INDEX_GITEA_PASSWORD: ${{ secrets.CI_RUNNER_TOKEN }}
run: uv sync --all-extras
- name: Smoke check
run: |
uv run ruff check .
uv run ruff format --check .
uv run mypy .
- name: Commit and push changes - name: Commit and push changes
env: env:
API_URL: ${{ vars.API_URL }} API_URL: ${{ vars.API_URL }}
+19 -17
View File
@@ -11,28 +11,30 @@ repos:
- id: name-tests-test - id: name-tests-test
- id: check-merge-conflict - id: check-merge-conflict
# Python linting and formatting with Ruff # Python tooling via uv (versions pinned in uv.lock)
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: local
rev: v0.12.8
hooks: hooks:
- id: ruff-check - id: ruff-check
args: [--fix] name: ruff check
entry: uv run ruff check --fix
language: system
types: [python]
- id: ruff-format - id: ruff-format
name: ruff format
# Static type checking with mypy entry: uv run ruff format
- repo: https://github.com/pre-commit/mirrors-mypy language: system
rev: v1.8.0 types: [python]
hooks:
- id: mypy - id: mypy
additional_dependencies: name: mypy
- types-redis entry: uv run mypy .
language: system
# Python syntax modernization with pyupgrade types: [python]
- repo: https://github.com/asottile/pyupgrade pass_filenames: false
rev: v3.20.0
hooks:
- id: pyupgrade - id: pyupgrade
args: ["--py312-plus"] name: pyupgrade
entry: uv run pyupgrade --py312-plus
language: system
types: [python]
# Formatting for Markdown, JSON, and YAML with Prettier # Formatting for Markdown, JSON, and YAML with Prettier
- repo: https://github.com/pre-commit/mirrors-prettier - repo: https://github.com/pre-commit/mirrors-prettier
+16 -4
View File
@@ -60,6 +60,18 @@ name = "gitea"
url = "https://gitea.lille-vemmelund.dk/api/packages/brian/pypi/simple/" url = "https://gitea.lille-vemmelund.dk/api/packages/brian/pypi/simple/"
explicit = true explicit = true
[tool.ruff]
line-length = 88
target-version = "py312"
[tool.ruff.lint]
extend-select = ["I"]
[tool.ruff.lint.isort]
known-first-party = ["python_repositories", "tests"]
combine-as-imports = true
force-sort-within-sections = true
[tool.mypy] [tool.mypy]
python_version = "3.12" python_version = "3.12"
warn_return_any = true # nudge to use stricter types warn_return_any = true # nudge to use stricter types
@@ -87,12 +99,12 @@ ignore_missing_imports = true
[dependency-groups] [dependency-groups]
dev = [ dev = [
"mypy>=1.17.1", "mypy>=2.1.0",
"pre-commit>=4.3.0", "pre-commit>=4.6.0",
"pytest>=8.4.1", "pytest>=8.4.1",
"pytest-cov>=7.0.0", "pytest-cov>=7.0.0",
"pyupgrade>=3.20.0", "pyupgrade>=3.21.2",
"ruff>=0.12.11", "ruff>=0.15.20",
"safety>=3.6.0", "safety>=3.6.0",
"testcontainers>=4.13.0", "testcontainers>=4.13.0",
"types-redis>=4.6.0.20241004", "types-redis>=4.6.0.20241004",
@@ -2,8 +2,8 @@
from __future__ import annotations from __future__ import annotations
import time
from abc import abstractmethod from abc import abstractmethod
import time
from typing import Self from typing import Self
import structlog import structlog
@@ -1,6 +1,7 @@
"""Definition of MinioAdapter class.""" """Definition of MinioAdapter class."""
from __future__ import annotations from __future__ import annotations
from io import BytesIO from io import BytesIO
from python_repositories.adapters.connection_aware_adapter import ( from python_repositories.adapters.connection_aware_adapter import (
@@ -1,6 +1,7 @@
"""Definition of RedisAdapter class.""" """Definition of RedisAdapter class."""
from __future__ import annotations from __future__ import annotations
from collections.abc import Iterator from collections.abc import Iterator
from typing import Any, cast from typing import Any, cast
+1 -1
View File
@@ -2,8 +2,8 @@
from __future__ import annotations from __future__ import annotations
import os
from dataclasses import dataclass from dataclasses import dataclass
import os
from python_utils import check_env from python_utils import check_env
+1 -1
View File
@@ -2,8 +2,8 @@
from __future__ import annotations from __future__ import annotations
import os
from dataclasses import dataclass from dataclasses import dataclass
import os
from python_utils import check_env from python_utils import check_env
@@ -1,7 +1,7 @@
"""Definition of JsonRepositoryInterface abstract base class.""" """Definition of JsonRepositoryInterface abstract base class."""
from collections.abc import Iterator
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from collections.abc import Iterator
from typing import Any from typing import Any
+9 -3
View File
@@ -11,15 +11,16 @@ set -euo pipefail
BRANCH="${BRANCH:-renovate/auto-deps-update}" BRANCH="${BRANCH:-renovate/auto-deps-update}"
BASE_BRANCH="${BASE_BRANCH:-main}" BASE_BRANCH="${BASE_BRANCH:-main}"
LOCKFILE="${LOCKFILE:-uv.lock}" LOCKFILE="${LOCKFILE:-uv.lock}"
PRE_COMMIT_CONFIG="${PRE_COMMIT_CONFIG:-.pre-commit-config.yaml}"
if git diff --quiet "$LOCKFILE"; then if git diff --quiet "$LOCKFILE" && git diff --quiet "$PRE_COMMIT_CONFIG"; then
echo "No dependency updates available." echo "No dependency updates available."
exit 0 exit 0
fi fi
git config user.name "CI Bot" git config user.name "CI Bot"
git config user.email "[email protected]" git config user.email "[email protected]"
git add "$LOCKFILE" git add "$LOCKFILE" "$PRE_COMMIT_CONFIG"
git commit -m "chore(deps): update dependencies [automated]" git commit -m "chore(deps): update dependencies [automated]"
git remote set-url origin "https://x-access-token:${CI_RUNNER_TOKEN}@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git" git remote set-url origin "https://x-access-token:${CI_RUNNER_TOKEN}@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git"
@@ -48,7 +49,12 @@ print(
json.dumps( json.dumps(
{ {
"title": "chore(deps): update dependencies", "title": "chore(deps): update dependencies",
"body": "This PR was created automatically to update dependencies.", "body": (
"This PR was created automatically to update dependencies.\n\n"
"- `uv.lock`: upgraded Python dependencies\n"
"- `.pre-commit-config.yaml`: updated remote hook revs via "
"`pre-commit autoupdate`"
),
"head": os.environ["BRANCH"], "head": os.environ["BRANCH"],
"base": os.environ["BASE_BRANCH"], "base": os.environ["BASE_BRANCH"],
} }
+2 -2
View File
@@ -1,13 +1,13 @@
"""Integration tests configuration.""" """Integration tests configuration."""
import logging
from collections.abc import Generator from collections.abc import Generator
import logging
from typing import Any, cast from typing import Any, cast
from minio import Minio
import pytest import pytest
import redis import redis
import structlog import structlog
from minio import Minio
from testcontainers.core.container import DockerContainer from testcontainers.core.container import DockerContainer
from testcontainers.core.waiting_utils import WaitStrategy, WaitStrategyTarget from testcontainers.core.waiting_utils import WaitStrategy, WaitStrategyTarget
from testcontainers.minio import MinioContainer from testcontainers.minio import MinioContainer
+1 -1
View File
@@ -5,8 +5,8 @@ from io import BytesIO
import os import os
import random import random
import pytest
from minio import Minio from minio import Minio
import pytest
from python_repositories.examples.artifact_object_repository import ( from python_repositories.examples.artifact_object_repository import (
ArtifactObjectRepository, ArtifactObjectRepository,
+2 -2
View File
@@ -2,13 +2,13 @@
from collections.abc import Generator from collections.abc import Generator
from dataclasses import replace from dataclasses import replace
from io import BytesIO
import logging import logging
import random import random
from io import BytesIO
from unittest.mock import MagicMock from unittest.mock import MagicMock
import pytest
from minio import Minio, S3Error from minio import Minio, S3Error
import pytest
from urllib3.response import BaseHTTPResponse from urllib3.response import BaseHTTPResponse
from python_repositories.adapters.minio_adapter import MinioAdapter from python_repositories.adapters.minio_adapter import MinioAdapter
+2 -2
View File
@@ -3,12 +3,12 @@
from __future__ import annotations from __future__ import annotations
import builtins import builtins
from collections.abc import Callable, Mapping, Sequence
import importlib import importlib
import os import os
from pathlib import Path
import subprocess import subprocess
import sys import sys
from collections.abc import Callable, Mapping, Sequence
from pathlib import Path
from types import ModuleType from types import ModuleType
from unittest.mock import patch from unittest.mock import patch
+1 -1
View File
@@ -4,9 +4,9 @@ from __future__ import annotations
from unittest.mock import MagicMock from unittest.mock import MagicMock
from minio import Minio
import pytest import pytest
import redis import redis
from minio import Minio
from python_repositories.adapters.minio_adapter import MinioAdapter from python_repositories.adapters.minio_adapter import MinioAdapter
from python_repositories.adapters.redis_adapter import RedisAdapter from python_repositories.adapters.redis_adapter import RedisAdapter
@@ -1,6 +1,7 @@
"""Unit tests for ConnectionAwareInterface.""" """Unit tests for ConnectionAwareInterface."""
import pytest import pytest
from python_repositories.interfaces.connection_aware_interface import ( from python_repositories.interfaces.connection_aware_interface import (
ConnectionAwareInterface, ConnectionAwareInterface,
) )
@@ -3,6 +3,7 @@
from __future__ import annotations from __future__ import annotations
import pytest import pytest
from python_repositories.interfaces.context_aware_interface import ContextAwareInterface from python_repositories.interfaces.context_aware_interface import ContextAwareInterface
@@ -3,6 +3,7 @@
from typing import Any from typing import Any
import pytest import pytest
from python_repositories.interfaces.json_repository_interface import ( from python_repositories.interfaces.json_repository_interface import (
JsonRepositoryInterface, JsonRepositoryInterface,
) )
+1 -1
View File
@@ -5,8 +5,8 @@ from __future__ import annotations
from dataclasses import replace from dataclasses import replace
from unittest.mock import MagicMock from unittest.mock import MagicMock
import pytest
from minio import Minio, S3Error from minio import Minio, S3Error
import pytest
from urllib3.response import BaseHTTPResponse from urllib3.response import BaseHTTPResponse
from python_repositories.adapters.minio_adapter import MinioAdapter from python_repositories.adapters.minio_adapter import MinioAdapter
@@ -3,6 +3,7 @@
from io import BytesIO from io import BytesIO
import pytest import pytest
from python_repositories.interfaces.object_repository_interface import ( from python_repositories.interfaces.object_repository_interface import (
ObjectRepositoryInterface, ObjectRepositoryInterface,
) )
Generated
+5 -5
View File
@@ -1,5 +1,5 @@
version = 1 version = 1
revision = 2 revision = 3
requires-python = ">=3.12" requires-python = ">=3.12"
resolution-markers = [ resolution-markers = [
"python_full_version >= '3.15'", "python_full_version >= '3.15'",
@@ -1097,12 +1097,12 @@ provides-extras = ["redis", "minio"]
[package.metadata.requires-dev] [package.metadata.requires-dev]
dev = [ dev = [
{ name = "mypy", specifier = ">=1.17.1" }, { name = "mypy", specifier = ">=2.1.0" },
{ name = "pre-commit", specifier = ">=4.3.0" }, { name = "pre-commit", specifier = ">=4.6.0" },
{ name = "pytest", specifier = ">=8.4.1" }, { name = "pytest", specifier = ">=8.4.1" },
{ name = "pytest-cov", specifier = ">=7.0.0" }, { name = "pytest-cov", specifier = ">=7.0.0" },
{ name = "pyupgrade", specifier = ">=3.20.0" }, { name = "pyupgrade", specifier = ">=3.21.2" },
{ name = "ruff", specifier = ">=0.12.11" }, { name = "ruff", specifier = ">=0.15.20" },
{ name = "safety", specifier = ">=3.6.0" }, { name = "safety", specifier = ">=3.6.0" },
{ name = "testcontainers", specifier = ">=4.13.0" }, { name = "testcontainers", specifier = ">=4.13.0" },
{ name = "types-redis", specifier = ">=4.6.0.20241004" }, { name = "types-redis", specifier = ">=4.6.0.20241004" },