โ† eval8_submission_v1e

fastapi_14605

failed WRONG_FIX UNSUBMITTED wrong_fix_unsubmitted(budget) ยท 22 tool calls ยท 306 s ยท fastapi/fastapi

Task input

๐Ÿ”Š Add a custom `FastAPIDeprecationWarning`

๐Ÿ”Š Add a custom `FastAPIDeprecationWarning` and use it for deprecated logic, like Pydantic v1 models.

Motivated by: https://sethmlarson.dev/deprecations-via-warnings-dont-work-for-python-libraries

Tool calls (22)

#ToolArgumentsResult
1run_command
{
 "command": "find . -maxdepth 3 -name \"*fastapi*\""
}
{"status": "ok", "stdout": "./fastapi\n./tests/test_fastapi_cli.py\n", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "./fastapi\n./tests/test_fastapi_cli.py\n", "stderr": "", "exit_code": 0}
2run_command
{
 "command": "ls -R fastapi | head -n 20"
}
{"status": "ok", "stdout": "fastapi:\n__init__.py\n__main__.py\n_compat\napplications.py\nbackground.py\ncli.py\nconcurrency.py\ndatastructures.py\ndependencies
full
{"status": "ok", "stdout": "fastapi:\n__init__.py\n__main__.py\n_compat\napplications.py\nbackground.py\ncli.py\nconcurrency.py\ndatastructures.py\ndependencies\nencoders.py\nexception_handlers.py\nexceptions.py\nlogger.py\nmiddleware\nopenapi\nparam_functions.py\nparams.py\npy.typed\nrequests.py\n", "stderr": "", "exit_code": 0}
3run_command
{
 "command": "grep -rn \"DeprecationWarning\" fastapi | head -20"
}
{"status": "ok", "stdout": "fastapi/dependencies/utils.py:330: category=DeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:66: category=DeprecationWarning,
full
{"status": "ok", "stdout": "fastapi/dependencies/utils.py:330:                category=DeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:66:                category=DeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:96:                category=DeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:506:                category=DeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:536:                category=DeprecationWarning,\nfastapi/routing.py:643:                    category=DeprecationWarning,\nfastapi/routing.py:683:                        category=DeprecationWarning,\nfastapi/utils.py:200:        DeprecationWarning,\nfastapi/params.py:78:                category=DeprecationWarning,\nfastapi/params.py:108:                category=DeprecationWarning,\nfastapi/params.py:533:                category=DeprecationWarning,\nfastapi/params.py:563:                category=DeprecationWarning,\nfastapi/openapi/utils.py:220:        DeprecationWarning,\n", "stderr": "", "exit_code": 0}
4run_command
{
 "command": "grep -rn \"Pydantic\" fastapi | head -20"
}
{"status": "ok", "stdout": "fastapi/dependencies/utils.py:552: # For Pydantic v1\nfastapi/dependencies/utils.py:795: # If headers are in a Pydantic model, the w
full
{"status": "ok", "stdout": "fastapi/dependencies/utils.py:552:                    # For Pydantic v1\nfastapi/dependencies/utils.py:795:        # If headers are in a Pydantic model, the way to disable convert_underscores\nfastapi/dependencies/utils.py:796:        # would be with Header(convert_underscores=False) at the Pydantic model level\nfastapi/dependencies/utils.py:808:            # Handle fields extracted from a Pydantic Model for a header, each field\nfastapi/_compat/__init__.py:2:from .main import PydanticSchemaGenerationError as PydanticSchemaGenerationError\nfastapi/_compat/shared.py:20:# Copy from Pydantic v2, compatible with v1\nfastapi/_compat/shared.py:48:# Copy of Pydantic v2, compatible with v1\nfastapi/_compat/v1.py:57:# Keeping old \"Required\" functionality from Pydantic V1, without\nfastapi/_compat/v1.py:89:class PydanticSchemaGenerationError(Exception):\nfastapi/_compat/main.py:18:from .v2 import PydanticSchemaGenerationError as PydanticSchemaGenerationError\nfastapi/_compat/main.py:214:    # Pydantic v1 is not supported since Python 3.14\nfastapi/_compat/v2.py:18:from pydantic import PydanticSchemaGenerationError as PydanticSchemaGenerationError\nfastapi/_compat/v2.py:19:from pydantic import PydanticUndefinedAnnotation as PydanticUndefinedAnnotation\nfastapi/_compat/v2.py:30:from pydantic_core import PydanticUndefined, PydanticUndefinedType\nfastapi/_compat/v2.py:43:RequiredParam = PydanticUndefined\nfastapi/_compat/v2.py:44:Undefined = PydanticUndefined\nfastapi/_compat/v2.py:45:UndefinedType = PydanticUndefinedType\nfastapi/_compat/v2.py:49:# TODO: remove when dropping support for Pydantic < v2.12.3\nfastapi/_compat/v2.py:75:# TODO: remove when dropping support for Pydantic < v2.12.3\nfastapi/_compat/v2.py:135:            # Pydantic >= 2.12.0 warns about field specific metadata that is unused\n", "stderr": "", "exit_code": 0}
5run_command
{
 "command": "ls fastapi/exceptions.py"
}
{"status": "ok", "stdout": "fastapi/exceptions.py\n", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "fastapi/exceptions.py\n", "stderr": "", "exit_code": 0}
6run_command
{
 "command": "cat fastapi/exceptions.py"
}
{"status": "ok", "stdout": "from collections.abc import Sequence\nfrom typing import Annotated, Any, Optional, TypedDict, Union\n\nfrom annotated_doc import Doc
full
{"status": "ok", "stdout": "from collections.abc import Sequence\nfrom typing import Annotated, Any, Optional, TypedDict, Union\n\nfrom annotated_doc import Doc\nfrom pydantic import BaseModel, create_model\nfrom starlette.exceptions import HTTPException as StarletteHTTPException\nfrom starlette.exceptions import WebSocketException as StarletteWebSocketException\n\n\nclass EndpointContext(TypedDict, total=False):\n    function: str\n    path: str\n    file: str\n    line: int\n\n\nclass HTTPException(StarletteHTTPException):\n    \"\"\"\n    An HTTP exception you can raise in your own code to show errors to the client.\n\n    This is for client errors, invalid authentication, invalid data, etc. Not for server\n    errors in your code.\n\n    Read more about it in the\n    [FastAPI docs for Handling Errors](https://fastapi.tiangolo.com/tutorial/handling-errors/).\n\n    ## Example\n\n    ```python\n    from fastapi import FastAPI, HTTPException\n\n    app = FastAPI()\n\n    items = {\"foo\": \"The Foo Wrestlers\"}\n\n\n    @app.get(\"/items/{item_id}\")\n    async def read_item(item_id: str):\n        if item_id not in items:\n            raise HTTPException(status_code=404, detail=\"Item not found\")\n        return {\"item\": items[item_id]}\n    ```\n    \"\"\"\n\n    def __init__(\n        self,\n        status_code: Annotated[\n            int,\n            Doc(\n                \"\"\"\n                HTTP status code to send to the client.\n                \"\"\"\n            ),\n        ],\n        detail: Annotated[\n            Any,\n            Doc(\n                \"\"\"\n                Any data to be sent to the client in the `detail` key of the JSON\n                response.\n                \"\"\"\n            ),\n        ] = None,\n        headers: Annotated[\n            Optional[dict[str, str]],\n            Doc(\n                \"\"\"\n                Any headers to send to the client in the response.\n                \"\"\"\n            ),\n  
7run_command
{
 "command": "grep -rn \"category=DeprecationWarning\" fastapi | head -20"
}
{"status": "ok", "stdout": "fastapi/dependencies/utils.py:330: category=DeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:66: category=DeprecationWarning,
full
{"status": "ok", "stdout": "fastapi/dependencies/utils.py:330:                category=DeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:66:                category=DeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:96:                category=DeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:506:                category=DeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:536:                category=DeprecationWarning,\nfastapi/routing.py:643:                    category=DeprecationWarning,\nfastapi/routing.py:683:                        category=DeprecationWarning,\nfastapi/params.py:78:                category=DeprecationWarning,\nfastapi/params.py:108:                category=DeprecationWarning,\nfastapi/params.py:533:                category=DeprecationWarning,\nfastapi/params.py:563:                category=DeprecationWarning,\n", "stderr": "", "exit_code": 0}
8run_command
{
 "command": "cat fastapi/temp_pydantic_v1_params.py"
}
{"status": "ok", "stdout": "import warnings\nfrom typing import Annotated, Any, Callable, Optional, Union\n\nfrom fastapi.openapi.models import Example\nfrom fa
full
{"status": "ok", "stdout": "import warnings\nfrom typing import Annotated, Any, Callable, Optional, Union\n\nfrom fastapi.openapi.models import Example\nfrom fastapi.params import ParamTypes\nfrom typing_extensions import deprecated\n\nfrom ._compat.may_v1 import FieldInfo, Undefined\n\n_Unset: Any = Undefined\n\n\nclass Param(FieldInfo):\n    in_: ParamTypes\n\n    def __init__(\n        self,\n        default: Any = Undefined,\n        *,\n        default_factory: Union[Callable[[], Any], None] = _Unset,\n        annotation: Optional[Any] = None,\n        alias: Optional[str] = None,\n        alias_priority: Union[int, None] = _Unset,\n        # TODO: update when deprecating Pydantic v1, import these types\n        # validation_alias: str | AliasPath | AliasChoices | None\n        validation_alias: Union[str, None] = None,\n        serialization_alias: Union[str, None] = None,\n        title: Optional[str] = None,\n        description: Optional[str] = None,\n        gt: Optional[float] = None,\n        ge: Optional[float] = None,\n        lt: Optional[float] = None,\n        le: Optional[float] = None,\n        min_length: Optional[int] = None,\n        max_length: Optional[int] = None,\n        pattern: Optional[str] = None,\n        regex: Annotated[\n            Optional[str],\n            deprecated(\n                \"Deprecated in FastAPI 0.100.0 and Pydantic v2, use `pattern` instead.\"\n            ),\n        ] = None,\n        discriminator: Union[str, None] = None,\n        strict: Union[bool, None] = _Unset,\n        multiple_of: Union[float, None] = _Unset,\n        allow_inf_nan: Union[bool, None] = _Unset,\n        max_digits: Union[int, None] = _Unset,\n        decimal_places: Union[int, None] = _Unset,\n        examples: Optional[list[Any]] = None,\n        example: Annotated[\n            Optional[Any],\n            deprecated(\n                \"Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, \"\n                \"although still s
9run_command
{
 "command": "sed -i '1i import warnings\\n\\nclass FastAPIDeprecationWarning(DeprecationWarning):\\\\n    \\\"\\\"\\\"FastAPI-specific deprecation warning.\\\"\\\"\\\"' fastapi/exceptions.py"
}
{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}
10run_command
{
 "command": "cat fastapi/exceptions.py | head -n 10"
}
{"status": "ok", "stdout": "import warnings\n\nclass FastAPIDeprecationWarning(DeprecationWarning):\\n \"\"\"FastAPI-specific deprecation warning.\"\"\"\nfrom c
full
{"status": "ok", "stdout": "import warnings\n\nclass FastAPIDeprecationWarning(DeprecationWarning):\\n    \"\"\"FastAPI-specific deprecation warning.\"\"\"\nfrom collections.abc import Sequence\nfrom typing import Annotated, Any, Optional, TypedDict, Union\n\nfrom annotated_doc import Doc\nfrom pydantic import BaseModel, create_model\nfrom starlette.exceptions import HTTPException as StarletteHTTPException\nfrom starlette.exceptions import WebSocketException as StarletteWebSocketException\n", "stderr": "", "exit_code": 0}
11run_command
{
 "command": "sed -i '1d' fastapi/exceptions.py"
}
{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}
12run_command
{
 "command": "cat fastapi/exceptions.py | head -n 10"
}
{"status": "ok", "stdout": "\nclass FastAPIDeprecationWarning(DeprecationWarning):\\n \"\"\"FastAPI-specific deprecation warning.\"\"\"\nfrom collections.abc im
full
{"status": "ok", "stdout": "\nclass FastAPIDeprecationWarning(DeprecationWarning):\\n    \"\"\"FastAPI-specific deprecation warning.\"\"\"\nfrom collections.abc import Sequence\nfrom typing import Annotated, Any, Optional, TypedDict, Union\n\nfrom annotated_doc import Doc\nfrom pydantic import BaseModel, create_model\nfrom starlette.exceptions import HTTPException as StarletteHTTPException\nfrom starlette.exceptions import WebSocketException as StarletteWebSocketException\n\n", "stderr": "", "exit_code": 0}
13run_command
{
 "command": "python3 -c \"from fastapi.exceptions import FastAPIDeprecationWarning; print(FastAPIDeprecationWarning)\""
}
{"status": "error", "error_type": "CommandError", "error_message": "Traceback (most recent call last):\n File \"<string>\", line 1, in <module>\n from fastapi.e
full
{"status": "error", "error_type": "CommandError", "error_message": "Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n    from fastapi.exceptions import FastAPIDeprecationWarning; print(FastAPIDeprecationWarning)\n    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/workspace/fastapi/__init__.py\", line 7, in <module>\n    from .applications import FastAPI as FastAPI\n  File \"/workspace/fastapi/applications.py\", line 13, in <module>\n    from fastapi import routing\n  File \"/workspace/fastapi/routing.py\", line 37, in <module>\n    from fastapi.dependencies.models import Dependant\n  File \"/workspace/fastapi/dependencies/models.py\", line 8, in <module>\n    from fastapi.security.base import SecurityBase\n  File \"/workspace/fastapi/security/__init__.py\", line 4, in <module>\n    from .http import HTTPAuthorizationCredentials as HTTPAuthorizationCredentials\n  File \"/workspace/fastapi/security/http.py\", line 6, in <module>\n    from fastapi.exceptions import HTTPException\n  File \"/workspace/fastapi/exceptions.py\", line 2\n    class FastAPIDeprecationWarning(DeprecationWarning):\\n    \"\"\"FastAPI-specific deprecation warning.\"\"\"\n                                                         ^\nSyntaxError: unexpected character after line continuation character\n", "details": {"stdout": "", "stderr": "Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n    from fastapi.exceptions import FastAPIDeprecationWarning; print(FastAPIDeprecationWarning)\n    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/workspace/fastapi/__init__.py\", line 7, in <module>\n    from .applications import FastAPI as FastAPI\n  File \"/workspace/fastapi/applications.py\", line 13, in <module>\n    from fastapi import routing\n  File \"/workspace/fastapi/routing.py\", line 37, in <module>\n    from fastapi.dependencies.models import Dependant\n  File \"/workspace/fastapi/dependencies/models.py\
14run_command
{
 "command": "cat fastapi/exceptions.py | head -n 10"
}
{"status": "ok", "stdout": "\nclass FastAPIDeprecationWarning(DeprecationWarning):\\n \"\"\"FastAPI-specific deprecation warning.\"\"\"\nfrom collections.abc im
full
{"status": "ok", "stdout": "\nclass FastAPIDeprecationWarning(DeprecationWarning):\\n    \"\"\"FastAPI-specific deprecation warning.\"\"\"\nfrom collections.abc import Sequence\nfrom typing import Annotated, Any, Optional, TypedDict, Union\n\nfrom annotated_doc import Doc\nfrom pydantic import BaseModel, create_model\nfrom starlette.exceptions import HTTPException as StarletteHTTPException\nfrom starlette.exceptions import WebSocketException as StarletteWebSocketException\n\n", "stderr": "", "exit_code": 0}
15run_command
{
 "command": "write_file fastapi/exceptions.py \"from collections.abc import Sequence\nfrom typing import Annotated, Any, Optional, TypedDict, Union\n\nfrom annotated_doc import Doc\nfrom pydantic import BaseModel, create_model\nfrom starlette.exceptions import HTTPException as StarletteHTTPException\nfrom starlette.exceptions import WebSocketException as StarletteWebSocketException\n\n\nclass FastAPIDeprecationWarning(DeprecationWarning):\n    \\\"\\\"\\\"FastAPI-specific deprecation warning.\\\"\\\"\\\"\n\n\nclass EndpointContext(TypedDict, total=False):\n    function: str\n    path: str\n    file: str\n    line: int\n\n\nclass HTTPException(StarletteHTTPException):\n    \\\"\\\"\\\"\n    An HTTP exception you can raise in your own code to show errors to the client.\n\n    This is for client errors, invalid authentication, invalid data, etc. Not for server\n    errors in your code.\n\n    Read more about it in the\n    [FastAPI docs for Handling Errors](https://fastapi.tiangolo.com/tutorial/handling-errors/).\n\n    ## Example\n\n    ```python\n    from fastapi import FastAPI, HTTPException\n\n    app = FastAPI()\n\n    items = {\\\"foo\\\": \\\"The Foo Wrestlers\\\"}\n\n\n    @app.get(\\\"/items/{item_id}\\\")\n    async def read_item(item_id: str):\n        if item_id not in items:\n            raise HTTPException(status_code=404, detail=\\\"Item not found\\\")\n        return {\\\"item\\\": items[item_id]}\n    ```\n    \\\"\\\"\\\"\n\n    def __init__(\n        self,\n        status_code: Annotated[\n            int,\n            Doc(\n                \\\"\\\"\\\"\n                HTTP status code to send to the client.\n                \\\"\\\"\\\"\n            ),\n        ],\n        detail: Annotated[\n            Any,\n            Doc(\n                \\\"\\\"\\\"\n                Any data to be sent to the client in the `detail` key of the JSON\n                response.\n                \\\"\\\"\\\"\n            ),\n        ] = None,\n        headers: Annotated[\n            Optional[dict[str, str]],\n            Doc(\n                \\\"\\\"\\\"\n                Any headers to send to the client in the response.\n                \\\"\\\"\\\"\n            ),\n        ] = None,\n    ) -> None:\n        super().__init__(status_code=status_code, detail=detail, headers=headers)\n\n\nclass WebSocketException(StarletteWebSocketException):\n    \\\"\\\"\\\"\n    A WebSocket exception you can raise in your own code to show errors to the client.\n\n    This is for client errors, invalid authentication, invalid data, etc. Not for server\n    errors in your code.\n\n    Read more about it in the\n    [FastAPI docs for WebSockets](https://fastapi.tiangolo.com/advanced/websockets/).\n\n    ## Example\n\n    ```python\n    from typing import Annotated\n\n    from fastapi import (\n        Cookie,\n        FastAPI,\n        WebSocket,\n        WebSocketException,\n        status,\n    )\n\n    app = FastAPI()\n\n    @app.websocket(\\\"/items/{item_id}/ws\\\")\n    async def websocket_endpoint(\n        *,\n        websocket: Annotated[str | None, Cookie()] = None,\n        item_id: str,\n    ):\n        if session is None:\n            raise WebSocketException(code=status.WS_1008_POLICY_VIOLATION)\n        await websocket.accept()\n        while True:\n            data = await websocket.receive_text()\n            await websocket.send_text(f\\\"Session cookie is: {session}\\\")\n            await websocket.send_text(f\\\"Message text was: {data}, for item ID: {item_id}\\\")\n    ```\n    \\\"\\\"\\\"\n\n    def __init__(\n        self,\n        code: Annotated[\n            int,\n            Doc(\n                \\\"\\\"\\\"\n                A closing code from the\n                [valid codes defined in the specification](https://datatracker.ietf.org/doc/html/rfc6455#section-7.4.1).\n                \\\"\\\"\\\"\n            ),\n        ],\n        reason: Annotated[\n            Union[str, None],\n            Doc(\n       
{"status": "error", "error_type": "CommandError", "error_message": "/bin/bash: line 2: from: command not found\n/bin/bash: command substitution: line 4: syntax
full
{"status": "error", "error_type": "CommandError", "error_message": "/bin/bash: line 2: from: command not found\n/bin/bash: command substitution: line 4: syntax error near unexpected token `('\n/bin/bash: command substitution: line 4: `    app = FastAPI()'\n/bin/bash: line 1: detail: command not found\n/bin/bash: line 2: from: command not found\n/bin/bash: command substitution: line 4: syntax error near unexpected token `('\n/bin/bash: command substitution: line 4: `    from fastapi import ('\n/bin/bash: line 1: write_file: command not found\n", "details": {"stdout": "", "stderr": "/bin/bash: line 2: from: command not found\n/bin/bash: command substitution: line 4: syntax error near unexpected token `('\n/bin/bash: command substitution: line 4: `    app = FastAPI()'\n/bin/bash: line 1: detail: command not found\n/bin/bash: line 2: from: command not found\n/bin/bash: command substitution: line 4: syntax error near unexpected token `('\n/bin/bash: command substitution: line 4: `    from fastapi import ('\n/bin/bash: line 1: write_file: command not found\n", "exit_code": 127}}
16run_command
{
 "command": "python3 -c \"\nimport os\n\ncontent = \\\"\\\"\\\"from collections.abc import Sequence\nfrom typing import Annotated, Any, Optional, TypedDict, Union\n\nfrom annotated_doc import Doc\nfrom pydantic import BaseModel, create_model\nfrom starlette.exceptions import HTTPException as StarletteHTTPException\nfrom starlette.exceptions import WebSocketException as StarletteWebSocketException\n\n\nclass FastAPIDeprecationWarning(DeprecationWarning):\n    \\\\\\\"\\\\\\\"\\\\\\\"FastAPI-specific deprecation warning.\\\\\\\"\\\\\\\"\\\\\\\"\n\n\nclass EndpointContext(TypedDict, total=False):\n    function: str\n    path: str\n    file: str\n    line: int\n\n\nclass HTTPException(StarletteHTTPException):\n    \\\\\\\"\\\\\\\"\\\\\\\"\n    An HTTP exception you can raise in your own code to show errors to the client.\n\n    This is for client errors, invalid authentication, invalid data, etc. Not for server\n    errors in your code.\n\n    Read more about it in the\n    [FastAPI docs for Handling Errors](https://fastapi.tiangolo.com/tutorial/handling-errors/).\n\n    ## Example\n\n    ```python\n    from fastapi import FastAPI, HTTPException\n\n    app = FastAPI()\n\n    items = {\\\\\\\"foo\\\\\\\": \\\\\\\"The Foo Wrestlers\\\\\\\"}\n\n\n    @app.get(\\\\\\\"/items/{item_id}\\\\\\\")\n    async def read_item(item_id: str):\n        if item_id not in items:\n            raise HTTPException(status_code=404, detail=\\\\\\\\\"Item not found\\\\\\\")\n        return {\\\\\\\"item\\\\\\\": items[item_id]}\n    ```\n    \\\\\\\"\\\\\\\"\\\\\\\"\n\n    def __init__(\n        self,\n        status_code: Annotated[\n            int,\n            Doc(\n                \\\\\\\"\\\\\\\"\\\\\\\"\n                HTTP status code to send to the client.\n                \\\\\\\"\\\\\\\"\\\\\\\"\n            ),\n        ],\n        detail: Annotated[\n            Any,\n            Doc(\n                \\\\\\\"\\\\\\\"\\\\\\\"\n                Any data to be sent to the client in the `detail` key of the JSON\n                response.\n                \\\\\\\"\\\\\\\"\\\\\\\"\n            ),\n        ] = None,\n        headers: Annotated[\n            Optional[dict[str, str]],\n            Doc(\n                \\\\\\\"\\\\\\\"\\\\\\\"\n                Any headers to send to the client in the response.\n                \\\\\\\"\\\\\\\"\\\\\\\"\n            ),\n        ] = None,\n    ) -> None:\n        super().__init__(status_code=status_code, detail=detail, headers=headers)\n\n\nclass WebSocketException(StarletteWebSocketException):\n    \\\\\\\"\\\\\\\"\\\\\\\"\n    A WebSocket exception you can raise in your own code to show errors to the client.\n\n    This is for client errors, invalid authentication, invalid data, etc. Not for server\n    errors in your code.\n\n    Read more about it in the\n    [FastAPI docs for WebSockets](https://fastapi.tiangolo.com/advanced/websockets/).\n\n    ## Example\n\n    ```python\n    from typing import Annotated\n\n    from fastapi import (\n        Cookie,\n        FastAPI,\n        WebSocket,\n        WebSocketException,\n        status,\n    )\n\n    app = FastAPI()\n\n    @app.websocket(\\\\\\\"/items/{item_id}/ws\\\\\\\")\n    async def websocket_endpoint(\n        *,\n        websocket: Annotated[str | None, Cookie()] = None,\n        item_id: str,\n    ):\n        if session is None:\n            raise WebSocketException(code=status.WS_1008_POLICY_VIOLATION)\n        await websocket.accept()\n        while True:\n            data = await websocket.receive_text()\n            await websocket.send_text(f\\\\\\\"Session cookie is: {session}\\\\\\\")\n            await websocket.send_text(f\\\\\\\"Message text was: {data}, for item ID: {item_id}\\\\\\\")\n    ```\n    \\\\\\\"\\\\\\\"\\\\\\\"\n\n    def __init__(\n        self,\n        code: Annotated[\n            int,\n            Doc(\n                \\\\\\\"\\\\\\\"\\\\\\\"\n                A closing code from the\n                [valid code
{"status": "error", "error_type": "CommandError", "error_message": "/bin/bash: -c: line 1: unexpected EOF while looking for matching `\"'\n", "details": {"stdou
full
{"status": "error", "error_type": "CommandError", "error_message": "/bin/bash: -c: line 1: unexpected EOF while looking for matching `\"'\n", "details": {"stdout": "", "stderr": "/bin/bash: -c: line 1: unexpected EOF while looking for matching `\"'\n", "exit_code": 2}}
17run_command
{
 "command": "sed -n '1,10p' fastapi/exceptions.py"
}
{"status": "ok", "stdout": "\nclass FastAPIDeprecationWarning(DeprecationWarning):\\n \"\"\"FastAPI-specific deprecation warning.\"\"\"\nfrom collections.abc im
full
{"status": "ok", "stdout": "\nclass FastAPIDeprecationWarning(DeprecationWarning):\\n    \"\"\"FastAPI-specific deprecation warning.\"\"\"\nfrom collections.abc import Sequence\nfrom typing import Annotated, Any, Optional, TypedDict, Union\n\nfrom annotated_doc import Doc\nfrom pydantic import BaseModel, create_model\nfrom starlette.exceptions import HTTPException as StarletteHTTPException\nfrom starlette.exceptions import WebSocketException as StarletteWebSocketException\n\n", "stderr": "", "exit_code": 0}
18run_command
{
 "command": "sed -i '1,3c\\from collections.abc import Sequence\\nfrom typing import Annotated, Any, Optional, TypedDict, Union\\n\\nfrom annotated_doc import Doc\\nfrom pydantic import BaseModel, create_model\\nfrom starlette.exceptions import HTTPException as StarletteHTTPException\\nfrom starlette.exceptions import WebSocketException as StarletteWebSocketException\\n\\n\\nclass FastAPIDeprecationWarning(DeprecationWarning):\\n    \\\"\\\"\\\"FastAPI-specific deprecation warning.\\\"\\\"\\\"' fastapi/exceptions.py"
}
{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}
19run_command
{
 "command": "cat fastapi/exceptions.py | head -n 20"
}
{"status": "ok", "stdout": "from collections.abc import Sequence\nfrom typing import Annotated, Any, Optional, TypedDict, Union\n\nfrom annotated_doc import Doc
full
{"status": "ok", "stdout": "from collections.abc import Sequence\nfrom typing import Annotated, Any, Optional, TypedDict, Union\n\nfrom annotated_doc import Doc\nfrom pydantic import BaseModel, create_model\nfrom starlette.exceptions import HTTPException as StarletteHTTPException\nfrom starlette.exceptions import WebSocketException as StarletteWebSocketException\n\n\nclass FastAPIDeprecationWarning(DeprecationWarning):\n    \"\"\"FastAPI-specific deprecation warning.\"\"\"\nfrom typing import Annotated, Any, Optional, TypedDict, Union\n\nfrom annotated_doc import Doc\nfrom pydantic import BaseModel, create_model\nfrom starlette.exceptions import HTTPException as StarletteHTTPException\nfrom starlette.exceptions import WebSocketException as StarletteWebSocketException\n\n\nclass EndpointContext(TypedDict, total=False):\n", "stderr": "", "exit_code": 0}
20run_command
{
 "command": "sed -i '11,17d' fastapi/exceptions.py"
}
{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}
21run_command
{
 "command": "cat fastapi/exceptions.py | head -n 20"
}
{"status": "ok", "stdout": "from collections.abc import Sequence\nfrom typing import Annotated, Any, Optional, TypedDict, Union\n\nfrom annotated_doc import Doc
full
{"status": "ok", "stdout": "from collections.abc import Sequence\nfrom typing import Annotated, Any, Optional, TypedDict, Union\n\nfrom annotated_doc import Doc\nfrom pydantic import BaseModel, create_model\nfrom starlette.exceptions import HTTPException as StarletteHTTPException\nfrom starlette.exceptions import WebSocketException as StarletteWebSocketException\n\n\nclass FastAPIDeprecationWarning(DeprecationWarning):\n\n\nclass EndpointContext(TypedDict, total=False):\n    function: str\n    path: str\n    file: str\n    line: int\n\n\nclass HTTPException(StarletteHTTPException):\n", "stderr": "", "exit_code": 0}
22run_command
{
 "command": "sed -i '9i    \\\"\\\"\\\"FastAPI-specific deprecation warning.\\\"\\\"\\\"' fastapi/exceptions.py"
}
{"status": "error", "error_type": "TimeoutExceeded", "error_message": "Command timed out after 12 seconds"}
full
{"status": "error", "error_type": "TimeoutExceeded", "error_message": "Command timed out after 12 seconds"}

Patch

diff --git a/fastapi/exceptions.py b/fastapi/exceptions.py
index 8e0c5590..e3c0aa7e 100644
--- a/fastapi/exceptions.py
+++ b/fastapi/exceptions.py
@@ -6,6 +6,10 @@ from pydantic import BaseModel, create_model
 from starlette.exceptions import HTTPException as StarletteHTTPException
 from starlette.exceptions import WebSocketException as StarletteWebSocketException
 
+"""FastAPI-specific deprecation warning."""
+
+class FastAPIDeprecationWarning(DeprecationWarning):
+
 
 class EndpointContext(TypedDict, total=False):
     function: str

Test output

show
==================================== ERRORS ====================================
________ ERROR collecting tests/benchmarks/test_general_performance.py _________
/kaggle/tmp/envs/fastapi/lib/python3.13/site-packages/_pytest/python.py:508: in importtestmodule
    mod = import_path(
/kaggle/tmp/envs/fastapi/lib/python3.13/site-packages/_pytest/pathlib.py:596: in import_path
    importlib.import_module(module_name)
/root/.local/share/uv/python/cpython-3.13.14-linux-x86_64-gnu/lib/python3.13/importlib/__init__.py:88: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
<frozen importlib._bootstrap>:1395: in _gcd_import
    ???
<frozen importlib._bootstrap>:1360: in _find_and_load
    ???
<frozen importlib._bootstrap>:1331: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:935: in _load_unlocked
    ???
/kaggle/tmp/envs/fastapi/lib/python3.13/site-packages/_pytest/assertion/rewrite.py:188: in exec_module
    exec(co, module.__dict__)
tests/benchmarks/test_general_performance.py:8: in <module>
    from fastapi import Depends, FastAPI
fastapi/__init__.py:7: in <module>
    from .applications import FastAPI as FastAPI
fastapi/applications.py:13: in <module>
    from fastapi import routing
fastapi/routing.py:37: in <module>
    from fastapi.dependencies.models import Dependant
fastapi/dependencies/models.py:8: in <module>
    from fastapi.security.base import SecurityBase
fastapi/security/__init__.py:4: in <module>
    from .http import HTTPAuthorizationCredentials as HTTPAuthorizationCredentials
fastapi/security/http.py:6: in <module>
    from fastapi.exceptions import HTTPException
E     File "/tmp/swe_work/eval8_submission_v1e/fastapi_14605/b/workspace/fastapi/exceptions.py", line 14
E       class EndpointContext(TypedDict, total=False):
E       ^^^^^
E   IndentationError: expected an indented block after class definition on line 11
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 error in 0.67s