]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
⬆️ Upgrade Starlette supported version range to >=0.40.0,<0.49.0 (#14077)
authorBen Beasley <code@musicinmybrain.net>
Tue, 16 Sep 2025 17:21:48 +0000 (18:21 +0100)
committerGitHub <noreply@github.com>
Tue, 16 Sep 2025 17:21:48 +0000 (19:21 +0200)
Co-authored-by: svlandeg <svlandeg@github.com>
docs_src/handling_errors/tutorial005.py
fastapi/exception_handlers.py
fastapi/openapi/utils.py
pyproject.toml
tests/test_enforce_once_required_parameter.py

index 6e0b81d313fdc6e07755cd88ddffd32e45e211ff..0e04fa086405056103e5f696a0ae7862c23551a1 100644 (file)
@@ -1,4 +1,4 @@
-from fastapi import FastAPI, Request, status
+from fastapi import FastAPI, Request
 from fastapi.encoders import jsonable_encoder
 from fastapi.exceptions import RequestValidationError
 from fastapi.responses import JSONResponse
@@ -10,7 +10,7 @@ app = FastAPI()
 @app.exception_handler(RequestValidationError)
 async def validation_exception_handler(request: Request, exc: RequestValidationError):
     return JSONResponse(
-        status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
+        status_code=422,
         content=jsonable_encoder({"detail": exc.errors(), "body": exc.body}),
     )
 
index 6c2ba7fedf9337260824b62987e65301e4fed129..475dd7bdd9891a7595b6df5db97cd3840179c8fa 100644 (file)
@@ -5,7 +5,7 @@ from fastapi.websockets import WebSocket
 from starlette.exceptions import HTTPException
 from starlette.requests import Request
 from starlette.responses import JSONResponse, Response
-from starlette.status import HTTP_422_UNPROCESSABLE_ENTITY, WS_1008_POLICY_VIOLATION
+from starlette.status import WS_1008_POLICY_VIOLATION
 
 
 async def http_exception_handler(request: Request, exc: HTTPException) -> Response:
@@ -21,7 +21,7 @@ async def request_validation_exception_handler(
     request: Request, exc: RequestValidationError
 ) -> JSONResponse:
     return JSONResponse(
-        status_code=HTTP_422_UNPROCESSABLE_ENTITY,
+        status_code=422,
         content={"detail": jsonable_encoder(exc.errors())},
     )
 
index 808646cc27216c3423681041ee9923372a2a9d03..eda64a9994ccfc1463db0cc31b76ca3f9026cff1 100644 (file)
@@ -35,7 +35,6 @@ from fastapi.utils import (
 from pydantic import BaseModel
 from starlette.responses import JSONResponse
 from starlette.routing import BaseRoute
-from starlette.status import HTTP_422_UNPROCESSABLE_ENTITY
 from typing_extensions import Literal
 
 validation_error_definition = {
@@ -416,7 +415,7 @@ def get_openapi_path(
                     )
                     deep_dict_update(openapi_response, process_response)
                     openapi_response["description"] = description
-            http422 = str(HTTP_422_UNPROCESSABLE_ENTITY)
+            http422 = "422"
             all_route_params = get_flat_params(route.dependant)
             if (all_route_params or route.body_field) and not any(
                 status in operation["responses"]
index 7709451ffccf9023151cf399c8796a85ec6adb2b..4d86b21fb8c3533c7fd8e6824bc95904726076db 100644 (file)
@@ -43,7 +43,7 @@ classifiers = [
     "Topic :: Internet :: WWW/HTTP",
 ]
 dependencies = [
-    "starlette>=0.40.0,<0.48.0",
+    "starlette>=0.40.0,<0.49.0",
     "pydantic>=1.7.4,!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,!=2.1.0,<3.0.0",
     "typing-extensions>=4.8.0",
 ]
index 30329282f2b2dbf8a10a1d5c4e036148d4cc21ec..2e5ac6c0628b13d1c4b2f316623f5d631723f383 100644 (file)
@@ -102,7 +102,7 @@ def test_schema():
 
 def test_get_invalid():
     response = client.get("/foo")
-    assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY
+    assert response.status_code == 422
 
 
 def test_get_valid():