]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
👷 Add pre-commit config with local script for permalinks (#14398)
authorSebastián Ramírez <tiangolo@gmail.com>
Sun, 23 Nov 2025 17:41:43 +0000 (09:41 -0800)
committerGitHub <noreply@github.com>
Sun, 23 Nov 2025 17:41:43 +0000 (18:41 +0100)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
.github/workflows/pre-commit.yml
.gitignore
.pre-commit-config.yaml
requirements.txt
scripts/docs.py

index 83876405755dc63f982187f55cbfd317b7f049bf..fa0574d7d188b652ce4413a4c61df9f13af72a65 100644 (file)
@@ -7,7 +7,6 @@ on:
       - synchronize
 
 env:
-  UV_SYSTEM_PYTHON: 1
   IS_FORK: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
 
 jobs:
@@ -41,6 +40,10 @@ jobs:
             requirements**.txt
             pyproject.toml
             uv.lock
+      - name: Install Dependencies
+        run: |
+          uv venv
+          uv pip install -r requirements.txt
       - name: Run pre-commit
         id: precommit
         run: |
@@ -69,7 +72,7 @@ jobs:
         run: exit 1
 
   # https://github.com/marketplace/actions/alls-green#why
-  alls-green:  # This job does nothing and is only used for the branch protection
+  pre-commit-alls-green:  # This job does nothing and is only used for the branch protection
     if: always()
     needs:
       - pre-commit
index ef6364a9a7d5328213d9577eb34fcb048475c41b..6016ffa598a565a00842fc309c0dbb9392d7daa9 100644 (file)
@@ -28,3 +28,6 @@ archive.zip
 
 # macOS
 .DS_Store
+
+# Ignore while the setup still depends on requirements.txt files
+uv.lock
index cc3d937796a7db73af90c655527284f4c849bdeb..8e6d93fb7d59a77d2deaf23510d12c7450e42a21 100644 (file)
@@ -1,20 +1,29 @@
 # See https://pre-commit.com for more information
 # See https://pre-commit.com/hooks.html for more hooks
 repos:
--   repo: https://github.com/pre-commit/pre-commit-hooks
+  - repo: https://github.com/pre-commit/pre-commit-hooks
     rev: v6.0.0
     hooks:
-    -   id: check-added-large-files
-    -   id: check-toml
-    -   id: check-yaml
+      - id: check-added-large-files
+      - id: check-toml
+      - id: check-yaml
         args:
-        -   --unsafe
-    -   id: end-of-file-fixer
-    -   id: trailing-whitespace
--   repo: https://github.com/astral-sh/ruff-pre-commit
+        - --unsafe
+      - id: end-of-file-fixer
+      - id: trailing-whitespace
+  - repo: https://github.com/astral-sh/ruff-pre-commit
     rev: v0.14.3
     hooks:
-    -   id: ruff
+      - id: ruff
         args:
         - --fix
-    -   id: ruff-format
+      - id: ruff-format
+  - repo: local
+    hooks:
+      - id: local-script
+        language: unsupported
+        name: local script
+        entry: uv run ./scripts/docs.py add-permalinks-pages
+        args:
+          - --update-existing
+        files: ^docs/en/docs/.*\.md$
index 9180bf1be5d90870144a7f29b8aa33de5a02e885..5d9f97b754454aa7efd75c166f274a04b07f79c5 100644 (file)
@@ -1,6 +1,6 @@
 -e .[all]
 -r requirements-tests.txt
 -r requirements-docs.txt
-pre-commit >=2.17.0,<5.0.0
+pre-commit >=4.5.0,<5.0.0
 # For generating screenshots
 playwright
index d67ab50f77d564f2bba4ddd13bcbac9d7bc0419d..73f60e68c5ed91cf349d4b54d1f6854f57449aa7 100644 (file)
@@ -520,6 +520,15 @@ def add_permalinks_page(path: Path, update_existing: bool = False):
         f.writelines(updated_lines)
 
 
+@app.command()
+def add_permalinks_pages(pages: List[Path], update_existing: bool = False) -> None:
+    """
+    Add or update header permalinks in specific pages of En docs.
+    """
+    for md_file in pages:
+        add_permalinks_page(md_file, update_existing=update_existing)
+
+
 @app.command()
 def add_permalinks(update_existing: bool = False) -> None:
     """