From bf8fdba27148a534ab177680c1aa7311c3c98cb7 Mon Sep 17 00:00:00 2001 From: Tsvika Shapira Date: Tue, 14 Jul 2026 14:50:57 +0300 Subject: [PATCH] Sync blacken-docs' black pin via sync-with-uv pragma Replace the custom `_sync-blacken-docs` justfile recipe with the `# sync-with-uv` pragma comment (sync-with-uv 0.6.0), letting the existing `uvx sync-with-uv` step in `deps-update` keep blacken-docs' `black==` additional_dependency in sync with uv.lock. The pragma parser only matches a block-style list item and needs a parseable version, so the dependency moves from the flow-style `[black==...]` to a block list and seeds `black==0` instead of the `` token (which sync-with-uv cannot rewrite, and which would abort the first `just deps-update`). Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_015vNv6wUpJczEwAbapjWs7p --- project_name/.pre-commit-config.yaml.jinja | 3 ++- project_name/justfile.jinja | 11 ----------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/project_name/.pre-commit-config.yaml.jinja b/project_name/.pre-commit-config.yaml.jinja index 52bd787..2c75e8c 100644 --- a/project_name/.pre-commit-config.yaml.jinja +++ b/project_name/.pre-commit-config.yaml.jinja @@ -150,7 +150,8 @@ repos: rev: hooks: - id: blacken-docs - additional_dependencies: [black==] + additional_dependencies: + - black==0 # sync-with-uv {%- endif %} - repo: https://github.com/astral-sh/ruff-pre-commit rev: diff --git a/project_name/justfile.jinja b/project_name/justfile.jinja index a893b8f..9052dab 100644 --- a/project_name/justfile.jinja +++ b/project_name/justfile.jinja @@ -39,9 +39,6 @@ deps-update: && deps-list-outdated uv sync --upgrade uv run prek auto-update uvx sync-with-uv - {%- if format_tool == "black" %} - just _sync-blacken-docs - {%- endif %} 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; \ @@ -50,14 +47,6 @@ deps-update: && deps-list-outdated # Audit dependencies deps-audit: uv audit --locked -{% if format_tool == "black" %} -# 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 -{%- endif %} ### code quality ###