โ† eval8_submission_v1a

fastapi_14605

resolved RESOLVED UNSUBMITTED PASS ยท 31 tool calls ยท 305 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 (31)

#ToolArgumentsResult
1run_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}
2run_command
{
 "command": "ls fastapi/__init__.py"
}
{"status": "ok", "stdout": "fastapi/__init__.py\n", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "fastapi/__init__.py\n", "stderr": "", "exit_code": 0}
3run_command
{
 "command": "cat fastapi/__init__.py"
}
{"status": "ok", "stdout": "\"\"\"FastAPI framework, high performance, easy to learn, fast to code, ready for production\"\"\"\n\n__version__ = \"0.127.0\"\n\nf
full
{"status": "ok", "stdout": "\"\"\"FastAPI framework, high performance, easy to learn, fast to code, ready for production\"\"\"\n\n__version__ = \"0.127.0\"\n\nfrom starlette import status as status\n\nfrom .applications import FastAPI as FastAPI\nfrom .background import BackgroundTasks as BackgroundTasks\nfrom .datastructures import UploadFile as UploadFile\nfrom .exceptions import HTTPException as HTTPException\nfrom .exceptions import WebSocketException as WebSocketException\nfrom .param_functions import Body as Body\nfrom .param_functions import Cookie as Cookie\nfrom .param_functions import Depends as Depends\nfrom .param_functions import File as File\nfrom .param_functions import Form as Form\nfrom .param_functions import Header as Header\nfrom .param_functions import Path as Path\nfrom .param_functions import Query as Query\nfrom .param_functions import Security as Security\nfrom .requests import Request as Request\nfrom .responses import Response as Response\nfrom .routing import APIRouter as APIRouter\nfrom .websockets import WebSocket as WebSocket\nfrom .websockets import WebSocketDisconnect as WebSocketDisconnect\n", "stderr": "", "exit_code": 0}
4run_command
{
 "command": "grep -rn \"class \" fastapi/exceptions.py"
}
{"status": "ok", "stdout": "10:class EndpointContext(TypedDict, total=False):\n17:class HTTPException(StarletteHTTPException):\n76:class WebSocketException(Star
full
{"status": "ok", "stdout": "10:class EndpointContext(TypedDict, total=False):\n17:class HTTPException(StarletteHTTPException):\n76:class WebSocketException(StarletteWebSocketException):\n151:class FastAPIError(RuntimeError):\n157:class DependencyScopeError(FastAPIError):\n164:class ValidationException(Exception):\n202:class RequestValidationError(ValidationException):\n214:class WebSocketRequestValidationError(ValidationException):\n224:class ResponseValidationError(ValidationException):\n", "stderr": "", "exit_code": 0}
5edit_file
{
 "filepath": "fastapi/exceptions.py",
 "new_string": "class FastAPIError(RuntimeError):\n    pass\n\n\nclass FastAPIDeprecationWarning(DeprecationWarning):\n    pass\n\n\nclass DependencyScopeError(FastAPIError):\n",
 "old_string": "class FastAPIError(RuntimeError):\n    pass\n\n\nclass DependencyScopeError(FastAPIError):\n"
}
{"status": "error", "error_type": "FileEditError", "error_message": "Failed to replace: old_string not found. Ensure you're not escaping content incorrectly and
full
{"status": "error", "error_type": "FileEditError", "error_message": "Failed to replace: old_string not found. Ensure you're not escaping content incorrectly and check whitespace, indentation, and context."}
6run_command
{
 "command": "sed -n '150,165p' fastapi/exceptions.py"
}
{"status": "ok", "stdout": "\nclass FastAPIError(RuntimeError):\n \"\"\"\n A generic, FastAPI-specific error.\n \"\"\"\n\n\nclass DependencyScopeError(FastAPIEr
full
{"status": "ok", "stdout": "\nclass FastAPIError(RuntimeError):\n    \"\"\"\n    A generic, FastAPI-specific error.\n    \"\"\"\n\n\nclass DependencyScopeError(FastAPIError):\n    \"\"\"\n    A dependency declared that it depends on another dependency with an invalid\n    (narrower) scope.\n    \"\"\"\n\n\nclass ValidationException(Exception):\n    def __init__(\n", "stderr": "", "exit_code": 0}
7edit_file
{
 "filepath": "fastapi/exceptions.py",
 "new_string": "class FastAPIError(RuntimeError):\n    \"\"\"\n    A generic, FastAPI-specific error.\n    \"\"\"\n\n\nclass FastAPIDeprecationWarning(DeprecationWarning):\n    pass\n\n\nclass DependencyScopeError(FastAPIError):\n",
 "old_string": "class FastAPIError(RuntimeError):\n    \"\"\"\n    A generic, FastAPI-specific error.\n    \"\"\"\n\n\nclass DependencyScopeError(FastAPIError):\n"
}
{"status": "ok", "filepath": "fastapi/exceptions.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/exceptions.py\n+++ b/fastapi/exceptions.py\n
full
{"status": "ok", "filepath": "fastapi/exceptions.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/exceptions.py\n+++ b/fastapi/exceptions.py\n@@ -154,6 +154,10 @@\n     \"\"\"\n \n \n+class FastAPIDeprecationWarning(DeprecationWarning):\n+    pass\n+\n+\n class DependencyScopeError(FastAPIError):\n     \"\"\"\n     A dependency declared that it depends on another dependency with an invalid\n", "is_truncated": false}
8run_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}
9run_command
{
 "command": "grep -n \"category=DeprecationWarning\" fastapi/temp_pydantic_v1_params.py"
}
{"status": "ok", "stdout": "66: category=DeprecationWarning,\n96: category=DeprecationWarning,\n506: category=DeprecationWarning,\n536: category=DeprecationWarn
full
{"status": "ok", "stdout": "66:                category=DeprecationWarning,\n96:                category=DeprecationWarning,\n506:                category=DeprecationWarning,\n536:                category=DeprecationWarning,\n", "stderr": "", "exit_code": 0}
10run_command
{
 "command": "sed -n '60,70p' fastapi/temp_pydantic_v1_params.py"
}
{"status": "ok", "stdout": " json_schema_extra: Union[dict[str, Any], None] = None,\n **extra: Any,\n ):\n if example is not _Unset:\n warnings.warn(\n \"`examp
full
{"status": "ok", "stdout": "        json_schema_extra: Union[dict[str, Any], None] = None,\n        **extra: Any,\n    ):\n        if example is not _Unset:\n            warnings.warn(\n                \"`example` has been deprecated, please use `examples` instead\",\n                category=DeprecationWarning,\n                stacklevel=4,\n            )\n        self.example = example\n        self.include_in_schema = include_in_schema\n", "stderr": "", "exit_code": 0}
11run_command
{
 "command": "grep -n \"import warnings\" fastapi/temp_pydantic_v1_params.py"
}
{"status": "ok", "stdout": "1:import warnings\n", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "1:import warnings\n", "stderr": "", "exit_code": 0}
12run_command
{
 "command": "grep -n \"from fastapi import\" fastapi/temp_pydantic_v1_params.py"
}
{"status": "error", "error_type": "CommandError", "error_message": "", "details": {"stdout": "", "stderr": "", "exit_code": 1}}
full
{"status": "error", "error_type": "CommandError", "error_message": "", "details": {"stdout": "", "stderr": "", "exit_code": 1}}
13run_command
{
 "command": "grep -n \"from fastapi.exceptions import\" fastapi/temp_pydantic_v1_params.py"
}
{"status": "error", "error_type": "CommandError", "error_message": "", "details": {"stdout": "", "stderr": "", "exit_code": 1}}
full
{"status": "error", "error_type": "CommandError", "error_message": "", "details": {"stdout": "", "stderr": "", "exit_code": 1}}
14edit_file
{
 "filepath": "fastapi/temp_pydantic_v1_params.py",
 "new_string": "import warnings\nfrom fastapi.exceptions import FastAPIDeprecationWarning\n",
 "old_string": "import warnings\n"
}
{"status": "ok", "filepath": "fastapi/temp_pydantic_v1_params.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/temp_pydantic_v1_params.py\n+++
full
{"status": "ok", "filepath": "fastapi/temp_pydantic_v1_params.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/temp_pydantic_v1_params.py\n+++ b/fastapi/temp_pydantic_v1_params.py\n@@ -1,4 +1,5 @@\n import warnings\n+from fastapi.exceptions import FastAPIDeprecationWarning\n from typing import Annotated, Any, Callable, Optional, Union\n \n from fastapi.openapi.models import Example\n", "is_truncated": false}
15edit_file
{
 "filepath": "fastapi/temp_pydantic_v1_params.py",
 "new_string": "                category=FastAPIDeprecationWarning,",
 "old_string": "                category=DeprecationWarning,",
 "allow_multiple": true
}
{"status": "ok", "filepath": "fastapi/temp_pydantic_v1_params.py", "occurrences": 4, "strategy": "exact", "diff": "--- a/fastapi/temp_pydantic_v1_params.py\n+++
full
{"status": "ok", "filepath": "fastapi/temp_pydantic_v1_params.py", "occurrences": 4, "strategy": "exact", "diff": "--- a/fastapi/temp_pydantic_v1_params.py\n+++ b/fastapi/temp_pydantic_v1_params.py\n@@ -64,7 +64,7 @@\n         if example is not _Unset:\n             warnings.warn(\n                 \"`example` has been deprecated, please use `examples` instead\",\n-                category=DeprecationWarning,\n+                category=FastAPIDeprecationWarning,\n                 stacklevel=4,\n             )\n         self.example = example\n@@ -94,7 +94,7 @@\n         if regex is not None:\n             warnings.warn(\n                 \"`regex` has been deprecated, please use `pattern` instead\",\n-                category=DeprecationWarning,\n+                category=FastAPIDeprecationWarning,\n                 stacklevel=4,\n             )\n         current_json_schema_extra = json_schema_extra or extra\n@@ -504,7 +504,7 @@\n         if example is not _Unset:\n             warnings.warn(\n                 \"`example` has been deprecated, please use `examples` instead\",\n-                category=DeprecationWarning,\n+                category=FastAPIDeprecationWarning,\n                 stacklevel=4,\n             )\n         self.example = example\n@@ -534,7 +534,7 @@\n         if regex is not None:\n             warnings.warn(\n                 \"`regex` has been deprecated, please use `pattern` instead\",\n-                category=DeprecationWarning,\n+                category=FastAPIDeprecationWarning,\n                 stacklevel=4,\n             )\n         current_json_schema_extra = json_schema_extra or extra\n", "is_truncated": false}
16run_command
{
 "command": "grep -n \"category=DeprecationWarning\" fastapi/dependencies/utils.py"
}
{"status": "ok", "stdout": "330: category=DeprecationWarning,\n", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "330:                category=DeprecationWarning,\n", "stderr": "", "exit_code": 0}
17run_command
{
 "command": "sed -n '320,340p' fastapi/dependencies/utils.py"
}
{"status": "ok", "stdout": " ):\n assert param_details.field is None, (\n f\"Cannot specify multiple FastAPI annotations for {param_name!r}\"\n )\n continue\n a
full
{"status": "ok", "stdout": "        ):\n            assert param_details.field is None, (\n                f\"Cannot specify multiple FastAPI annotations for {param_name!r}\"\n            )\n            continue\n        assert param_details.field is not None\n        if isinstance(param_details.field, may_v1.ModelField):\n            warnings.warn(\n                \"pydantic.v1 is deprecated and will soon stop being supported by FastAPI.\"\n                f\" Please update the param {param_name}: {param_details.type_annotation!r}.\",\n                category=DeprecationWarning,\n                stacklevel=5,\n            )\n        if isinstance(\n            param_details.field.field_info, (params.Body, temp_pydantic_v1_params.Body)\n        ):\n            dependant.body_params.append(param_details.field)\n        else:\n            add_param_to_fields(field=param_details.field, dependant=dependant)\n    return dependant\n\n", "stderr": "", "exit_code": 0}
18run_command
{
 "command": "grep -n \"import warnings\" fastapi/dependencies/utils.py"
}
{"status": "ok", "stdout": "4:import warnings\n", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "4:import warnings\n", "stderr": "", "exit_code": 0}
19edit_file
{
 "filepath": "fastapi/dependencies/utils.py",
 "new_string": "import warnings\nfrom fastapi.exceptions import FastAPIDeprecationWarning\n",
 "old_string": "import warnings\n"
}
{"status": "ok", "filepath": "fastapi/dependencies/utils.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/dependencies/utils.py\n+++ b/fastapi
full
{"status": "ok", "filepath": "fastapi/dependencies/utils.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/dependencies/utils.py\n+++ b/fastapi/dependencies/utils.py\n@@ -2,6 +2,7 @@\n import inspect\n import sys\n import warnings\n+from fastapi.exceptions import FastAPIDeprecationWarning\n from collections.abc import Coroutine, Mapping, Sequence\n from contextlib import AsyncExitStack, contextmanager\n from copy import copy, deepcopy\n", "is_truncated": false}
20edit_file
{
 "filepath": "fastapi/dependencies/utils.py",
 "new_string": "                category=FastAPIDeprecationWarning,",
 "old_string": "                category=DeprecationWarning,"
}
{"status": "ok", "filepath": "fastapi/dependencies/utils.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/dependencies/utils.py\n+++ b/fastapi
full
{"status": "ok", "filepath": "fastapi/dependencies/utils.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/dependencies/utils.py\n+++ b/fastapi/dependencies/utils.py\n@@ -328,7 +328,7 @@\n             warnings.warn(\n                 \"pydantic.v1 is deprecated and will soon stop being supported by FastAPI.\"\n                 f\" Please update the param {param_name}: {param_details.type_annotation!r}.\",\n-                category=DeprecationWarning,\n+                category=FastAPIDeprecationWarning,\n                 stacklevel=5,\n             )\n         if isinstance(\n", "is_truncated": false}
21run_command
{
 "command": "grep -n \"category=DeprecationWarning\" fastapi/routing.py"
}
{"status": "ok", "stdout": "643: category=DeprecationWarning,\n683: category=DeprecationWarning,\n", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "643:                    category=DeprecationWarning,\n683:                        category=DeprecationWarning,\n", "stderr": "", "exit_code": 0}
22run_command
{
 "command": "sed -n '630,650p' fastapi/routing.py"
}
{"status": "ok", "stdout": " # normalize enums e.g. http.HTTPStatus\n if isinstance(status_code, IntEnum):\n status_code = int(status_code)\n self.status_code =
full
{"status": "ok", "stdout": "        # normalize enums e.g. http.HTTPStatus\n        if isinstance(status_code, IntEnum):\n            status_code = int(status_code)\n        self.status_code = status_code\n        if self.response_model:\n            assert is_body_allowed_for_status_code(status_code), (\n                f\"Status code {status_code} must not have a response body\"\n            )\n            response_name = \"Response_\" + self.unique_id\n            if annotation_is_pydantic_v1(self.response_model):\n                warnings.warn(\n                    \"pydantic.v1 is deprecated and will soon stop being supported by FastAPI.\"\n                    f\" Please update the response model {self.response_model!r}.\",\n                    category=DeprecationWarning,\n                    stacklevel=4,\n                )\n            self.response_field = create_model_field(\n                name=response_name,\n                type_=self.response_model,\n                mode=\"serialization\",\n            )\n", "stderr": "", "exit_code": 0}
23run_command
{
 "command": "sed -n '670,690p' fastapi/routing.py"
}
{"status": "ok", "stdout": " response_fields = {}\n for additional_status_code, response in self.responses.items():\n assert isinstance(response, dict), \"An ad
full
{"status": "ok", "stdout": "        response_fields = {}\n        for additional_status_code, response in self.responses.items():\n            assert isinstance(response, dict), \"An additional response must be a dict\"\n            model = response.get(\"model\")\n            if model:\n                assert is_body_allowed_for_status_code(additional_status_code), (\n                    f\"Status code {additional_status_code} must not have a response body\"\n                )\n                response_name = f\"Response_{additional_status_code}_{self.unique_id}\"\n                if annotation_is_pydantic_v1(model):\n                    warnings.warn(\n                        \"pydantic.v1 is deprecated and will soon stop being supported by FastAPI.\"\n                        f\" In responses={{}}, please update {model}.\",\n                        category=DeprecationWarning,\n                        stacklevel=4,\n                    )\n                response_field = create_model_field(\n                    name=response_name, type_=model, mode=\"serialization\"\n                )\n                response_fields[additional_status_code] = response_field\n        if response_fields:\n", "stderr": "", "exit_code": 0}
24run_command
{
 "command": "grep -n \"import warnings\" fastapi/routing.py"
}
{"status": "ok", "stdout": "5:import warnings\n", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "5:import warnings\n", "stderr": "", "exit_code": 0}
25edit_file
{
 "filepath": "fastapi/routing.py",
 "new_string": "import warnings\nfrom fastapi.exceptions import FastAPIDeprecationWarning\n",
 "old_string": "import warnings\n"
}
{"status": "ok", "filepath": "fastapi/routing.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/routing.py\n+++ b/fastapi/routing.py\n@@ -3,6 +
full
{"status": "ok", "filepath": "fastapi/routing.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/routing.py\n+++ b/fastapi/routing.py\n@@ -3,6 +3,7 @@\n import inspect\n import json\n import warnings\n+from fastapi.exceptions import FastAPIDeprecationWarning\n from collections.abc import (\n     AsyncIterator,\n     Awaitable,\n", "is_truncated": false}
26edit_file
{
 "allow_multiple": true,
 "filepath": "fastapi/routing.py",
 "new_string": "                    category=FastAPIDeprecationWarning,",
 "old_string": "                    category=DeprecationWarning,"
}
{"status": "ok", "filepath": "fastapi/routing.py", "occurrences": 2, "strategy": "exact", "diff": "--- a/fastapi/routing.py\n+++ b/fastapi/routing.py\n@@ -641,7
full
{"status": "ok", "filepath": "fastapi/routing.py", "occurrences": 2, "strategy": "exact", "diff": "--- a/fastapi/routing.py\n+++ b/fastapi/routing.py\n@@ -641,7 +641,7 @@\n                 warnings.warn(\n                     \"pydantic.v1 is deprecated and will soon stop being supported by FastAPI.\"\n                     f\" Please update the response model {self.response_model!r}.\",\n-                    category=DeprecationWarning,\n+                    category=FastAPIDeprecationWarning,\n                     stacklevel=4,\n                 )\n             self.response_field = create_model_field(\n@@ -681,7 +681,7 @@\n                     warnings.warn(\n                         \"pydantic.v1 is deprecated and will soon stop being supported by FastAPI.\"\n                         f\" In responses={{}}, please update {model}.\",\n-                        category=DeprecationWarning,\n+                        category=FastAPIDeprecationWarning,\n                         stacklevel=4,\n                     )\n                 response_field = create_model_field(\n", "is_truncated": false}
27run_command
{
 "command": "grep -n \"category=DeprecationWarning\" fastapi/params.py"
}
{"status": "ok", "stdout": "78: category=DeprecationWarning,\n108: category=DeprecationWarning,\n533: category=DeprecationWarning,\n563: category=DeprecationWar
full
{"status": "ok", "stdout": "78:                category=DeprecationWarning,\n108:                category=DeprecationWarning,\n533:                category=DeprecationWarning,\n563:                category=DeprecationWarning,\n", "stderr": "", "exit_code": 0}
28run_command
{
 "command": "sed -n '70,85p' fastapi/params.py"
}
{"status": "ok", "stdout": " deprecated: Union[deprecated, str, bool, None] = None,\n include_in_schema: bool = True,\n json_schema_extra: Union[dict[str, Any],
full
{"status": "ok", "stdout": "        deprecated: Union[deprecated, str, bool, None] = None,\n        include_in_schema: bool = True,\n        json_schema_extra: Union[dict[str, Any], None] = None,\n        **extra: Any,\n    ):\n        if example is not _Unset:\n            warnings.warn(\n                \"`example` has been deprecated, please use `examples` instead\",\n                category=DeprecationWarning,\n                stacklevel=4,\n            )\n        self.example = example\n        self.include_in_schema = include_in_schema\n        self.openapi_examples = openapi_examples\n        kwargs = dict(\n            default=default,\n", "stderr": "", "exit_code": 0}
29run_command
{
 "command": "grep -n \"import warnings\" fastapi/params.py"
}
{"status": "ok", "stdout": "1:import warnings\n", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "1:import warnings\n", "stderr": "", "exit_code": 0}
30edit_file
{
 "filepath": "fastapi/params.py",
 "new_string": "import warnings\nfrom fastapi.exceptions import FastAPIDeprecationWarning\n",
 "old_string": "import warnings\n"
}
{"status": "ok", "filepath": "fastapi/params.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/params.py\n+++ b/fastapi/params.py\n@@ -1,4 +1,5
full
{"status": "ok", "filepath": "fastapi/params.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/params.py\n+++ b/fastapi/params.py\n@@ -1,4 +1,5 @@\n import warnings\n+from fastapi.exceptions import FastAPIDeprecationWarning\n from collections.abc import Sequence\n from dataclasses import dataclass\n from enum import Enum\n", "is_truncated": false}
31edit_file
{
 "allow_multiple": true,
 "filepath": "fastapi/params.py",
 "new_string": "                category=FastAPIDeprecationWarning,",
 "old_string": "                category=DeprecationWarning,"
}
{"status": "ok", "filepath": "fastapi/params.py", "occurrences": 4, "strategy": "exact", "diff": "--- a/fastapi/params.py\n+++ b/fastapi/params.py\n@@ -76,7 +76
full
{"status": "ok", "filepath": "fastapi/params.py", "occurrences": 4, "strategy": "exact", "diff": "--- a/fastapi/params.py\n+++ b/fastapi/params.py\n@@ -76,7 +76,7 @@\n         if example is not _Unset:\n             warnings.warn(\n                 \"`example` has been deprecated, please use `examples` instead\",\n-                category=DeprecationWarning,\n+                category=FastAPIDeprecationWarning,\n                 stacklevel=4,\n             )\n         self.example = example\n@@ -106,7 +106,7 @@\n         if regex is not None:\n             warnings.warn(\n                 \"`regex` has been deprecated, please use `pattern` instead\",\n-                category=DeprecationWarning,\n+                category=FastAPIDeprecationWarning,\n                 stacklevel=4,\n             )\n         current_json_schema_extra = json_schema_extra or extra\n@@ -531,7 +531,7 @@\n         if example is not _Unset:\n             warnings.warn(\n                 \"`example` has been deprecated, please use `examples` instead\",\n-                category=DeprecationWarning,\n+                category=FastAPIDeprecationWarning,\n                 stacklevel=4,\n             )\n         self.example = example\n@@ -561,7 +561,7 @@\n         if regex is not None:\n             warnings.warn(\n                 \"`regex` has been deprecated, please use `pattern` instead\",\n-                category=DeprecationWarning,\n+                category=FastAPIDeprecationWarning,\n                 stacklevel=4,\n             )\n         current_json_schema_extra = json_schema_extra or extra\n", "is_truncated": false}

Patch

diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py
index 39d0bd89..d7ee5d0f 100644
--- a/fastapi/dependencies/utils.py
+++ b/fastapi/dependencies/utils.py
@@ -2,6 +2,7 @@ import dataclasses
 import inspect
 import sys
 import warnings
+from fastapi.exceptions import FastAPIDeprecationWarning
 from collections.abc import Coroutine, Mapping, Sequence
 from contextlib import AsyncExitStack, contextmanager
 from copy import copy, deepcopy
@@ -327,7 +328,7 @@ def get_dependant(
             warnings.warn(
                 "pydantic.v1 is deprecated and will soon stop being supported by FastAPI."
                 f" Please update the param {param_name}: {param_details.type_annotation!r}.",
-                category=DeprecationWarning,
+                category=FastAPIDeprecationWarning,
                 stacklevel=5,
             )
         if isinstance(
diff --git a/fastapi/exceptions.py b/fastapi/exceptions.py
index 8e0c5590..29ac1e4e 100644
--- a/fastapi/exceptions.py
+++ b/fastapi/exceptions.py
@@ -154,6 +154,10 @@ class FastAPIError(RuntimeError):
     """
 
 
+class FastAPIDeprecationWarning(DeprecationWarning):
+    pass
+
+
 class DependencyScopeError(FastAPIError):
     """
     A dependency declared that it depends on another dependency with an invalid
diff --git a/fastapi/params.py b/fastapi/params.py
index c776c4a5..e1637f7b 100644
--- a/fastapi/params.py
+++ b/fastapi/params.py
@@ -1,4 +1,5 @@
 import warnings
+from fastapi.exceptions import FastAPIDeprecationWarning
 from collections.abc import Sequence
 from dataclasses import dataclass
 from enum import Enum
@@ -75,7 +76,7 @@ class Param(FieldInfo):  # type: ignore[misc]
         if example is not _Unset:
             warnings.warn(
                 "`example` has been deprecated, please use `examples` instead",
-                category=DeprecationWarning,
+                category=FastAPIDeprecationWarning,
                 stacklevel=4,
             )
         self.example = example
@@ -105,7 +106,7 @@ class Param(FieldInfo):  # type: ignore[misc]
         if regex is not None:
             warnings.warn(
                 "`regex` has been deprecated, please use `pattern` instead",
-                category=DeprecationWarning,
+                category=FastAPIDeprecationWarning,
                 stacklevel=4,
             )
         current_json_schema_extra = json_schema_extra or extra
@@ -530,7 +531,7 @@ class Body(FieldInfo):  # type: ignore[misc]
         if example is not _Unset:
             warnings.warn(
                 "`example` has been deprecated, please use `examples` instead",
-                category=DeprecationWarning,
+                category=FastAPIDeprecationWarning,
                 stacklevel=4,
             )
         self.example = example
@@ -560,7 +561,7 @@ class Body(FieldInfo):  # type: ignore[misc]
         if regex is not None:
             warnings.warn(
                 "`regex` has been deprecated, please use `pattern` instead",
-                category=DeprecationWarning,
+                category=FastAPIDeprecationWarning,
                 stacklevel=4,
             )
         current_json_schema_extra = json_schema_extra or extra
diff --git a/fastapi/routing.py b/fastapi/routing.py
index 2770e325..1e2b1473 100644
--- a/fastapi/routing.py
+++ b/fastapi/routing.py
@@ -3,6 +3,7 @@ import functools
 import inspect
 import json
 import warnings
+from fastapi.exceptions import FastAPIDeprecationWarning
 from collections.abc import (
     AsyncIterator,
     Awaitable,
@@ -640,7 +641,7 @@ class APIRoute(routing.Route):
                 warnings.warn(
                     "pydantic.v1 is deprecated and will soon stop being supported by FastAPI."
                     f" Please update the response model {self.response_model!r}.",
-                    category=DeprecationWarning,
+                    category=FastAPIDeprecationWarning,
                     stacklevel=4,
                 )
             self.response_field = create_model_field(
@@ -680,7 +681,7 @@ class APIRoute(routing.Route):
                     warnings.warn(
                         "pydantic.v1 is deprecated and will soon stop being supported by FastAPI."
                         f" In responses={{}}, please update {model}.",
-                        category=DeprecationWarning,
+                        category=FastAPIDeprecationWarning,
                         stacklevel=4,
                     )
                 response_field = create_model_field(
diff --git a/fastapi/temp_pydantic_v1_params.py b/fastapi/temp_pydantic_v1_params.py
index 1bda0ea9..d85bc388 100644
--- a/fastapi/temp_pydantic_v1_params.py
+++ b/fastapi/temp_pydantic_v1_params.py
@@ -1,4 +1,5 @@
 import warnings
+from fastapi.exceptions import FastAPIDeprecationWarning
 from typing import Annotated, Any, Callable, Optional, Union
 
 from fastapi.openapi.models import Example
@@ -63,7 +64,7 @@ class Param(FieldInfo):
         if example is not _Unset:
             warnings.warn(
                 "`example` has been deprecated, please use `examples` instead",
-                category=DeprecationWarning,
+                category=FastAPIDeprecationWarning,
                 stacklevel=4,
             )
         self.example = example
@@ -93,7 +94,7 @@ class Param(FieldInfo):
         if regex is not None:
             warnings.warn(
                 "`regex` has been deprecated, please use `pattern` instead",
-                category=DeprecationWarning,
+                category=FastAPIDeprecationWarning,
                 stacklevel=4,
             )
         current_json_schema_extra = json_schema_extra or extra
@@ -503,7 +504,7 @@ class Body(FieldInfo):
         if example is not _Unset:
             warnings.warn(
                 "`example` has been deprecated, please use `examples` instead",
-                category=DeprecationWarning,
+                category=FastAPIDeprecationWarning,
                 stacklevel=4,
             )
         self.example = example
@@ -533,7 +534,7 @@ class Body(FieldInfo):
         if regex is not None:
             warnings.warn(
                 "`regex` has been deprecated, please use `pattern` instead",
-                category=DeprecationWarning,
+                category=FastAPIDeprecationWarning,
                 stacklevel=4,
             )
         current_json_schema_extra = json_schema_extra or extra

Test output

show
........................................................................ [ 72%]
...........................                                              [100%]
=============================== warnings summary ===============================
../../../../../../kaggle/tmp/envs/overlays/starlette-0.50.0-py3-none-any/starlette/testclient.py:45
  /kaggle/tmp/envs/overlays/starlette-0.50.0-py3-none-any/starlette/testclient.py:45: DeprecationWarning: The anyio.abc.BlockingPortal alias is deprecated, use anyio.from_thread.BlockingPortal instead.
    _PortalFactoryType = Callable[[], AbstractContextManager[anyio.abc.BlockingPortal]]

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
99 passed, 1 skipped, 1 warning in 1.55s