From 0b9bd6d2ba3b42708857b35f820ac6a3adcdc497 Mon Sep 17 00:00:00 2001 From: Tsvika Shapira Date: Sat, 23 May 2026 17:03:51 +0300 Subject: [PATCH] Sync blacken-docs additional_dependencies from uv.lock Add a `_sync-blacken-docs` just recipe that reads the `black` version from `uv.lock` and rewrites `blacken-docs`' `additional_dependencies` in-place, preserving file formatting. Wire it into `deps-update` before the existing `sync-pre-commit-deps` step (kept as a safety net for other hooks that may have `additional_dependencies`). Replace the literal `black==26.5.1` pin in the template's `.pre-commit-config.yaml.jinja` with a `` marker, consistent with the rev placeholders used elsewhere; the new recipe resolves it on first `deps-update`. Co-Authored-By: Claude Opus 4.7 (1M context) --- project_name/.pre-commit-config.yaml.jinja | 2 +- project_name/justfile.jinja | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/project_name/.pre-commit-config.yaml.jinja b/project_name/.pre-commit-config.yaml.jinja index ef5686d..2c42bd4 100644 --- a/project_name/.pre-commit-config.yaml.jinja +++ b/project_name/.pre-commit-config.yaml.jinja @@ -156,7 +156,7 @@ repos: rev: hooks: - id: blacken-docs - additional_dependencies: [black==26.5.1] + additional_dependencies: [black==] - repo: https://github.com/astral-sh/ruff-pre-commit rev: hooks: diff --git a/project_name/justfile.jinja b/project_name/justfile.jinja index 2476e9d..e4a183d 100644 --- a/project_name/justfile.jinja +++ b/project_name/justfile.jinja @@ -39,6 +39,7 @@ deps-update: && deps-list-outdated uv sync --upgrade uv run prek auto-update uvx sync-with-uv + just _sync-blacken-docs uvx sync-pre-commit-deps --yaml-mapping 2 --yaml-sequence 4 --yaml-offset 2 .pre-commit-config.yaml || { \ echo "Note: '.pre-commit-config.yaml' changed, and might lost its formatting." \ && exit 1; \ @@ -48,6 +49,13 @@ deps-update: && deps-list-outdated deps-audit: uv audit --locked +# Sync blacken-docs' black additional_dependency with the version in uv.lock +_sync-blacken-docs: + @black_ver=$(awk -F'"' '/^\[\[package\]\]/{p=0} /^name = "black"$/{p=1} p && /^version =/{print $2; exit}' uv.lock); \ + if [ -n "$black_ver" ] && grep -q 'id: blacken-docs' .pre-commit-config.yaml; then \ + sed -i -E "/id: blacken-docs/,/^ - repo:/ s/(black==)(<[^>]*>|[0-9][0-9a-z.+-]*)/\1$black_ver/" .pre-commit-config.yaml; \ + fi + ### code quality ### _assert_clean_repo: