]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
👷 Add pre-commit to check typos (#15482)
authorSebastián Ramírez <tiangolo@gmail.com>
Tue, 5 May 2026 09:44:36 +0000 (11:44 +0200)
committerGitHub <noreply@github.com>
Tue, 5 May 2026 09:44:36 +0000 (09:44 +0000)
.pre-commit-config.yaml
pyproject.toml
tests/test_response_set_response_code_empty.py [moved from tests/test_reponse_set_reponse_code_empty.py with 100% similarity]
tests/test_tutorial/test_body_multiple_params/test_tutorial002.py
tests/test_tutorial/test_body_multiple_params/test_tutorial005.py
tests/test_ws_router.py

index 7913c813acc4ec26aa681bb3a23906be0c90fdb3..d304b78e8c417c6db74b191c9c1e541ecd9df32f 100644 (file)
@@ -14,6 +14,12 @@ repos:
       - id: end-of-file-fixer
       - id: trailing-whitespace
 
+  - repo: https://github.com/crate-ci/typos
+    rev: bbaefadf97b0ec5fdc942684b647f1a6ab250274 # v1.46.0
+    hooks:
+      - id: typos
+        args: [--force-exclude]
+
   - repo: local
     hooks:
       - id: local-ruff-check
index 8d8c4978d8d0c6af3723f9127027539558c24385..7abb9a33c431d41c7eb1de515641d7ec22e68b1a 100644 (file)
@@ -335,3 +335,40 @@ keep-runtime-typing = true
 [tool.inline-snapshot]
 # default-flags=["fix"]
 # default-flags=["create"]
+
+[tool.typos.files]
+extend-exclude = [
+    "coverage/",
+    "dist/",
+    "docs/de/",
+    "docs/en/data/",
+    "docs/en/docs/img/",
+    "docs/en/docs/release-notes.md",
+    "docs/es/",
+    "docs/fr/",
+    "docs/ja/",
+    "docs/ko/",
+    "docs/language_names.yml",
+    "docs/pt/",
+    "docs/ru/",
+    "docs/tr/",
+    "docs/uk/",
+    "docs/zh/",
+    "docs/zh-hant/",
+    "htmlcov/",
+    "scripts/general-llm-prompt.md",
+    "scripts/tests/test_translation_fixer/test_complex_doc/",
+    "site/",
+    "site_build/",
+    "uv.lock",
+]
+
+[tool.typos.default.extend-identifiers]
+alls = "alls"
+
+[tool.typos.default.extend-words]
+ba = "ba"
+fo = "fo"
+havin = "havin"
+Ines = "Ines"
+ser = "ser"
index b23402c3cbe53a0b3bc0e741620cdd06f4a3c031..b9b9928ba57642872505b776631e63cb30bf214e 100644 (file)
@@ -154,13 +154,16 @@ def test_post_missing_required_field_in_item(client: TestClient):
 def test_post_missing_required_field_in_user(client: TestClient):
     response = client.put(
         "/items/5",
-        json={"item": {"name": "Foo", "price": 50.5}, "user": {"ful_name": "John Doe"}},
+        json={
+            "item": {"name": "Foo", "price": 50.5},
+            "user": {"full_name": "John Doe"},
+        },
     )
     assert response.status_code == 422
     assert response.json() == {
         "detail": [
             {
-                "input": {"ful_name": "John Doe"},
+                "input": {"full_name": "John Doe"},
                 "loc": [
                     "body",
                     "user",
index b8fc98cd7e092cd8618009af7b820f34970b43dc..6186380c966ef71951a75c8e6228bb385500cff5 100644 (file)
@@ -82,7 +82,7 @@ def test_post_no_body(client: TestClient):
     }
 
 
-def test_post_like_not_embeded(client: TestClient):
+def test_post_like_not_embedded(client: TestClient):
     response = client.put(
         "/items/5",
         json={
index 240a42bb0c97e6c4c545410d3c965867251eb1e4..d8bcf17588361f2b5f757241bb388c9fdb561255 100644 (file)
@@ -176,7 +176,7 @@ def test_router_with_params():
 
 def test_wrong_uri():
     """
-    Verify that a websocket connection to a non-existent endpoing returns in a shutdown
+    Verify that a websocket connection to a non-existent endpoint returns in a shutdown
     """
     client = TestClient(app)
     with pytest.raises(WebSocketDisconnect) as e: