failed WRONG_FIX UNSUBMITTED wrong_fix_unsubmitted(budget) ยท 33 tool calls ยท 311 s ยท fastapi/fastapi
๐ 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 | Arguments | Result |
|---|---|---|---|
| 1 | run_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", "exit_code": 0} |
| 2 | run_command | {
"command": "grep -rn \"pydantic.v1\" fastapi | head -20"
} | {"status": "ok", "stdout": "fastapi/dependencies/utils.py:47:from fastapi._compat.shared import annotation_is_pydantic_v1\nfastapi/dependencies/utils.py:75:fromfull{"status": "ok", "stdout": "fastapi/dependencies/utils.py:47:from fastapi._compat.shared import annotation_is_pydantic_v1\nfastapi/dependencies/utils.py:75:from .. import temp_pydantic_v1_params\nfastapi/dependencies/utils.py:328: \"pydantic.v1 is deprecated and will soon stop being supported by FastAPI.\"\nfastapi/dependencies/utils.py:334: param_details.field.field_info, (params.Body, temp_pydantic_v1_params.Body)\nfastapi/dependencies/utils.py:403: temp_pydantic_v1_params.Param,\nfastapi/dependencies/utils.py:405: temp_pydantic_v1_params.Body,\nfastapi/dependencies/utils.py:494: if annotation_is_pydantic_v1(use_annotation):\nfastapi/dependencies/utils.py:495: field_info = temp_pydantic_v1_params.Body( # type: ignore[assignment]\nfastapi/dependencies/utils.py:511: field_info, (params.Path, temp_pydantic_v1_params.Path)\nfastapi/dependencies/utils.py:517: isinstance(field_info, (params.Param, temp_pydantic_v1_params.Param))\nfastapi/dependencies/utils.py:526: if isinstance(field_info, (params.Form, temp_pydantic_v1_params.Form)):\nfastapi/dependencies/utils.py:546: elif isinstance(field_info, (params.Query, temp_pydantic_v1_params.Query)):\nfastapi/dependencies/utils.py:765: isinstance(field.field_info, (params.Form, temp_pydantic_v1_params.Form))\nfastapi/dependencies/utils.py:835: assert isinstance(field_info, (params.Param, temp_pydantic_v1_params.Param)), (\nfastapi/dependencies/utils.py:847: assert isinstance(field_info, (params.Param, temp_pydantic_v1_params.Param)), (\nfastapi/dependencies/utils.py:896: isinstance(first_field.field_info, (params.Form, temp_pydantic_v1_params.Form))\nfastapi/dependencies/utils.py:914: isinstance(field_info, (params.File, temp_pydantic_v1_params.File))\nfastapi/dependencies/utils.py:921: and isinstance(field_info, (params.File, temp_pydantic_v1_ |
| 3 | run_command | {
"command": "ls fastapi/exceptions.py"
} | {"status": "ok", "stdout": "fastapi/exceptions.py\n", "exit_code": 0}full{"status": "ok", "stdout": "fastapi/exceptions.py\n", "exit_code": 0} |
| 4 | read_file | {
"filepath": "fastapi/exceptions.py"
} | {"status": "ok", "filepath": "fastapi/exceptions.py", "content": "from collections.abc import Sequence\nfrom typing import Annotated, Any, Optional, TypedDict, full{"status": "ok", "filepath": "fastapi/exceptions.py", "content": "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 |
| 5 | run_command | {
"command": "grep -rn \"DeprecationWarning\" fastapi/temp_pydantic_v1_params.py"
} | {"status": "ok", "stdout": "66: category=DeprecationWarning,\n96: category=DeprecationWarning,\n506: category=DeprecationWarning,\n536: category=DeprecationWarnfull{"status": "ok", "stdout": "66: category=DeprecationWarning,\n96: category=DeprecationWarning,\n506: category=DeprecationWarning,\n536: category=DeprecationWarning,\n", "exit_code": 0} |
| 6 | run_command | {
"command": "grep -rn \"DeprecationWarning\" fastapi/params.py"
} | {"status": "ok", "stdout": "78: category=DeprecationWarning,\n108: category=DeprecationWarning,\n533: category=DeprecationWarning,\n563: category=DeprecationWarfull{"status": "ok", "stdout": "78: category=DeprecationWarning,\n108: category=DeprecationWarning,\n533: category=DeprecationWarning,\n563: category=DeprecationWarning,\n", "exit_code": 0} |
| 7 | run_command | {
"command": "grep -rn \"DeprecationWarning\" fastapi/routing.py"
} | {"status": "ok", "stdout": "643: category=DeprecationWarning,\n683: category=DeprecationWarning,\n", "exit_code": 0}full{"status": "ok", "stdout": "643: category=DeprecationWarning,\n683: category=DeprecationWarning,\n", "exit_code": 0} |
| 8 | edit_file | {
"filepath": "fastapi/exceptions.py",
"new_string": "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 FastAPI deprecation warning.\n \\\"\\\"\\\"\n\n\nclass EndpointContext(TypedDict, total=False):",
"old_string": "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):"
} | {"status": "ok", "filepath": "fastapi/exceptions.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/exceptions.py\n+++ b/fastapi/exceptions.py\nfull{"status": "ok", "filepath": "fastapi/exceptions.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/exceptions.py\n+++ b/fastapi/exceptions.py\n@@ -5,6 +5,12 @@\n from pydantic import BaseModel, create_model\n from starlette.exceptions import HTTPException as StarletteHTTPException\n from starlette.exceptions import WebSocketException as StarletteWebSocketException\n+\n+\n+class FastAPIDeprecationWarning(DeprecationWarning):\n+ \\\"\\\"\\\"\n+ FastAPI deprecation warning.\n+ \\\"\\\"\\\"\n \n \n class EndpointContext(TypedDict, total=False):\n", "is_truncated": false} |
| 9 | run_command | {
"command": "grep -rn \"DeprecationWarning\" fastapi | grep -v \"exceptions.py\""
} | {"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", "exit_code": 0} |
| 10 | read_file | {
"filepath": "fastapi/dependencies/utils.py",
"start_line": 320,
"end_line": 340
} | {"status": "ok", "filepath": "fastapi/dependencies/utils.py", "content": " ):\n assert param_details.field is None, (\n f\"Cannot specify multiple FastAPI annotfull{"status": "ok", "filepath": "fastapi/dependencies/utils.py", "content": " ):\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", "start_line": 320, "end_line": 340, "total_lines": 1069, "is_truncated": false} |
| 11 | edit_file | {
"filepath": "fastapi/dependencies/utils.py",
"new_string": "from . import params\nfrom . import temp_pydantic_v1_params\nfrom fastapi.exceptions import FastAPIDeprecationWarning",
"old_string": "from . import params\nfrom . import temp_pydantic_v1_params"
} | {"status": "error", "error_type": "FileEditError", "error_message": "old_string not found in file (tried exact, flexible and regex matching)"}full{"status": "error", "error_type": "FileEditError", "error_message": "old_string not found in file (tried exact, flexible and regex matching)"} |
| 12 | read_file | {
"end_line": 100,
"filepath": "fastapi/dependencies/utils.py",
"start_line": 1
} | {"status": "ok", "filepath": "fastapi/dependencies/utils.py", "content": "import dataclasses\nimport inspect\nimport sys\nimport warnings\nfrom collections.abc full{"status": "ok", "filepath": "fastapi/dependencies/utils.py", "content": "import dataclasses\nimport inspect\nimport sys\nimport warnings\nfrom collections.abc import Coroutine, Mapping, Sequence\nfrom contextlib import AsyncExitStack, contextmanager\nfrom copy import copy, deepcopy\nfrom dataclasses import dataclass\nfrom typing import (\n Annotated,\n Any,\n Callable,\n ForwardRef,\n Optional,\n Union,\n cast,\n)\n\nimport anyio\nfrom fastapi import params\nfrom fastapi._compat import (\n ModelField,\n RequiredParam,\n Undefined,\n _is_error_wrapper,\n _is_model_class,\n copy_field_info,\n create_body_model,\n evaluate_forwardref,\n field_annotation_is_scalar,\n get_annotation_from_field_info,\n get_cached_model_fields,\n get_missing_field_error,\n is_bytes_field,\n is_bytes_sequence_field,\n is_scalar_field,\n is_scalar_sequence_field,\n is_sequence_field,\n is_uploadfile_or_nonable_uploadfile_annotation,\n is_uploadfile_sequence_annotation,\n lenient_issubclass,\n may_v1,\n sequence_types,\n serialize_sequence_value,\n value_is_sequence,\n)\nfrom fastapi._compat.shared import annotation_is_pydantic_v1\nfrom fastapi.background import BackgroundTasks\nfrom fastapi.concurrency import (\n asynccontextmanager,\n contextmanager_in_threadpool,\n)\nfrom fastapi.dependencies.models import Dependant\nfrom fastapi.exceptions import DependencyScopeError\nfrom fastapi.logger import logger\nfrom fastapi.security.oauth2 import SecurityScopes\nfrom fastapi.types import DependencyCacheKey\nfrom fastapi.utils import create_model_field, get_path_param_names\nfrom pydantic import BaseModel\nfrom pydantic.fields import FieldInfo\nfrom starlette.background import BackgroundTasks as StarletteBackgroundTasks\nfrom starlette.concurrency import run_in_threadpool\nfrom starlette.datastructures import (\n FormData,\n Headers,\n ImmutableMultiDict,\n QueryParams,\n UploadFile,\n |
| 13 | edit_file | {
"filepath": "fastapi/dependencies/utils.py",
"new_string": "from fastapi.exceptions import DependencyScopeError, FastAPIDeprecationWarning",
"old_string": "from fastapi.exceptions import DependencyScopeError"
} | {"status": "ok", "filepath": "fastapi/dependencies/utils.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/dependencies/utils.py\n+++ b/fastapifull{"status": "ok", "filepath": "fastapi/dependencies/utils.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/dependencies/utils.py\n+++ b/fastapi/dependencies/utils.py\n@@ -51,7 +51,7 @@\n contextmanager_in_threadpool,\n )\n from fastapi.dependencies.models import Dependant\n-from fastapi.exceptions import DependencyScopeError\n+from fastapi.exceptions import DependencyScopeError, FastAPIDeprecationWarning\n from fastapi.logger import logger\n from fastapi.security.oauth2 import SecurityScopes\n from fastapi.types import DependencyCacheKey\n", "is_truncated": false} |
| 14 | edit_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/fastapifull{"status": "ok", "filepath": "fastapi/dependencies/utils.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/dependencies/utils.py\n+++ b/fastapi/dependencies/utils.py\n@@ -327,7 +327,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} |
| 15 | run_command | {
"command": "grep -rn \"category=DeprecationWarning\" fastapi/temp_pydantic_v1_params.py"
} | {"status": "ok", "stdout": "66: category=DeprecationWarning,\n96: category=DeprecationWarning,\n506: category=DeprecationWarning,\n536: category=DeprecationWarnfull{"status": "ok", "stdout": "66: category=DeprecationWarning,\n96: category=DeprecationWarning,\n506: category=DeprecationWarning,\n536: category=DeprecationWarning,\n", "exit_code": 0} |
| 16 | read_file | {
"end_line": 100,
"filepath": "fastapi/temp_pydantic_v1_params.py",
"start_line": 1
} | {"status": "ok", "filepath": "fastapi/temp_pydantic_v1_params.py", "content": "import warnings\nfrom typing import Annotated, Any, Callable, Optional, Union\n\nfull{"status": "ok", "filepath": "fastapi/temp_pydantic_v1_params.py", "content": "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 Sch |
| 17 | edit_file | {
"filepath": "fastapi/temp_pydantic_v1_params.py",
"new_string": "import warnings\nfrom typing import Annotated, Any, Callable, Optional, Union\n\nfrom fastapi.openapi.models import Example\nfrom fastapi.params import ParamTypes\nfrom fastapi.exceptions import FastAPIDeprecationWarning\nfrom typing_extensions import deprecated",
"old_string": "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"
} | {"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@@ -3,6 +3,7 @@\n \n from fastapi.openapi.models import Example\n from fastapi.params import ParamTypes\n+from fastapi.exceptions import FastAPIDeprecationWarning\n from typing_extensions import deprecated\n \n from ._compat.may_v1 import FieldInfo, Undefined\n", "is_truncated": false} |
| 18 | edit_file | {
"filepath": "fastapi/temp_pydantic_v1_params.py",
"new_string": " category=FastAPIDeprecationWarning,",
"old_string": " category=DeprecationWarning,"
} | {"status": "error", "error_type": "FileEditError", "error_message": "old_string matched 4 occurrences; provide more context or set allow_multiple"}full{"status": "error", "error_type": "FileEditError", "error_message": "old_string matched 4 occurrences; provide more context or set allow_multiple"} |
| 19 | edit_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} |
| 20 | run_command | {
"command": "grep -rn \"category=DeprecationWarning\" fastapi/params.py"
} | {"status": "ok", "stdout": "78: category=DeprecationWarning,\n108: category=DeprecationWarning,\n533: category=DeprecationWarning,\n563: category=DeprecationWarfull{"status": "ok", "stdout": "78: category=DeprecationWarning,\n108: category=DeprecationWarning,\n533: category=DeprecationWarning,\n563: category=DeprecationWarning,\n", "exit_code": 0} |
| 21 | read_file | {
"end_line": 50,
"filepath": "fastapi/params.py",
"start_line": 1
} | {"status": "ok", "filepath": "fastapi/params.py", "content": "import warnings\nfrom collections.abc import Sequence\nfrom dataclasses import dataclass\nfrom enufull{"status": "ok", "filepath": "fastapi/params.py", "content": "import warnings\nfrom collections.abc import Sequence\nfrom dataclasses import dataclass\nfrom enum import Enum\nfrom typing import Annotated, Any, Callable, Optional, Union\n\nfrom fastapi.openapi.models import Example\nfrom pydantic.fields import FieldInfo\nfrom typing_extensions import Literal, deprecated\n\nfrom ._compat import (\n Undefined,\n)\n\n_Unset: Any = Undefined\n\n\nclass ParamTypes(Enum):\n query = \"query\"\n header = \"header\"\n path = \"path\"\n cookie = \"cookie\"\n\n\nclass Param(FieldInfo): # type: ignore[misc]\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", "start_line": 1, "end_line": 50, "total_lines": 769, "is_truncated": false} |
| 22 | edit_file | {
"filepath": "fastapi/params.py",
"new_string": "import warnings\nfrom collections.abc import Sequence\nfrom dataclasses import dataclass\nfrom enum import Enum\nfrom typing import Annotated, Any, Callable, Optional, Union\n\nfrom fastapi.openapi.models import Example\nfrom fastapi.exceptions import FastAPIDeprecationWarning\nfrom pydantic.fields import FieldInfo\nfrom typing_extensions import Literal, deprecated",
"old_string": "import warnings\nfrom collections.abc import Sequence\nfrom dataclasses import dataclass\nfrom enum import Enum\nfrom typing import Annotated, Any, Callable, Optional, Union\n\nfrom fastapi.openapi.models import Example\nfrom pydantic.fields import FieldInfo\nfrom typing_extensions import Literal, deprecated"
} | {"status": "ok", "filepath": "fastapi/params.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/params.py\n+++ b/fastapi/params.py\n@@ -5,6 +5,7full{"status": "ok", "filepath": "fastapi/params.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/params.py\n+++ b/fastapi/params.py\n@@ -5,6 +5,7 @@\n from typing import Annotated, Any, Callable, Optional, Union\n \n from fastapi.openapi.models import Example\n+from fastapi.exceptions import FastAPIDeprecationWarning\n from pydantic.fields import FieldInfo\n from typing_extensions import Literal, deprecated\n \n", "is_truncated": false} |
| 23 | edit_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 +76full{"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} |
| 24 | run_command | {
"command": "grep -rn \"category=DeprecationWarning\" fastapi/routing.py"
} | {"status": "ok", "stdout": "643: category=DeprecationWarning,\n683: category=DeprecationWarning,\n", "exit_code": 0}full{"status": "ok", "stdout": "643: category=DeprecationWarning,\n683: category=DeprecationWarning,\n", "exit_code": 0} |
| 25 | read_file | {
"end_line": 100,
"filepath": "fastapi/routing.py",
"start_line": 1
} | {"status": "ok", "filepath": "fastapi/routing.py", "content": "import email.message\nimport functools\nimport inspect\nimport json\nimport warnings\nfrom collecfull{"status": "ok", "filepath": "fastapi/routing.py", "content": "import email.message\nimport functools\nimport inspect\nimport json\nimport warnings\nfrom collections.abc import (\n AsyncIterator,\n Awaitable,\n Collection,\n Coroutine,\n Mapping,\n Sequence,\n)\nfrom contextlib import AsyncExitStack, asynccontextmanager\nfrom enum import Enum, IntEnum\nfrom typing import (\n Annotated,\n Any,\n Callable,\n Optional,\n Union,\n)\n\nfrom annotated_doc import Doc\nfrom fastapi import params, temp_pydantic_v1_params\nfrom fastapi._compat import (\n ModelField,\n Undefined,\n _get_model_config,\n _model_dump,\n _normalize_errors,\n annotation_is_pydantic_v1,\n lenient_issubclass,\n may_v1,\n)\nfrom fastapi.datastructures import Default, DefaultPlaceholder\nfrom fastapi.dependencies.models import Dependant\nfrom fastapi.dependencies.utils import (\n _should_embed_body_fields,\n get_body_field,\n get_dependant,\n get_flat_dependant,\n get_parameterless_sub_dependant,\n get_typed_return_annotation,\n solve_dependencies,\n)\nfrom fastapi.encoders import jsonable_encoder\nfrom fastapi.exceptions import (\n EndpointContext,\n FastAPIError,\n RequestValidationError,\n ResponseValidationError,\n WebSocketRequestValidationError,\n)\nfrom fastapi.types import DecoratedCallable, IncEx\nfrom fastapi.utils import (\n create_cloned_field,\n create_model_field,\n generate_unique_id,\n get_value_or_default,\n is_body_allowed_for_status_code,\n)\nfrom starlette import routing\nfrom starlette._exception_handler import wrap_app_handling_exceptions\nfrom starlette._utils import is_async_callable\nfrom starlette.concurrency import run_in_threadpool\nfrom starlette.exceptions import HTTPException\nfrom starlette.requests import Request\nfrom starlette.responses import JSONResponse, Response\nfrom starlette.routing import (\n BaseRoute,\n Match,\n compile_path,\n get_name,\n) |
| 26 | edit_file | {
"filepath": "fastapi/routing.py",
"new_string": "from fastapi.exceptions import (\n EndpointContext,\n FastAPIError,\n FastAPIDeprecationWarning,\n RequestValidationError,\n ResponseValidationError,\n WebSocketRequestValidationError,\n)",
"old_string": "from fastapi.exceptions import (\n EndpointContext,\n FastAPIError,\n RequestValidationError,\n ResponseValidationError,\n WebSocketRequestValidationError,\n)"
} | {"status": "ok", "filepath": "fastapi/routing.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/routing.py\n+++ b/fastapi/routing.py\n@@ -48,6 full{"status": "ok", "filepath": "fastapi/routing.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/routing.py\n+++ b/fastapi/routing.py\n@@ -48,6 +48,7 @@\n from fastapi.exceptions import (\n EndpointContext,\n FastAPIError,\n+ FastAPIDeprecationWarning,\n RequestValidationError,\n ResponseValidationError,\n WebSocketRequestValidationError,\n", "is_truncated": false} |
| 27 | edit_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,7full{"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} |
| 28 | run_command | {
"command": "grep -rn \"DeprecationWarning\" fastapi | grep -v \"FastAPIDeprecationWarning\""
} | {"status": "ok", "stdout": "fastapi/utils.py:200: DeprecationWarning,\nfastapi/openapi/utils.py:220: DeprecationWarning,\n", "exit_code": 0}full{"status": "ok", "stdout": "fastapi/utils.py:200: DeprecationWarning,\nfastapi/openapi/utils.py:220: DeprecationWarning,\n", "exit_code": 0} |
| 29 | read_file | {
"end_line": 220,
"filepath": "fastapi/utils.py",
"start_line": 190
} | {"status": "ok", "filepath": "fastapi/utils.py", "content": " new_field.populate_validators() # type: ignore[attr-defined]\n return new_field\n\n\ndef generate_full{"status": "ok", "filepath": "fastapi/utils.py", "content": " new_field.populate_validators() # type: ignore[attr-defined]\n return new_field\n\n\ndef generate_operation_id_for_path(\n *, name: str, path: str, method: str\n) -> str: # pragma: nocover\n warnings.warn(\n \"fastapi.utils.generate_operation_id_for_path() was deprecated, \"\n \"it is not used internally, and will be removed soon\",\n DeprecationWarning,\n stacklevel=2,\n )\n operation_id = f\"{name}{path}\"\n operation_id = re.sub(r\"\\W\", \"_\", operation_id)\n operation_id = f\"{operation_id}_{method.lower()}\"\n return operation_id\n\n\ndef generate_unique_id(route: \"APIRoute\") -> str:\n operation_id = f\"{route.name}{route.path_format}\"\n operation_id = re.sub(r\"\\W\", \"_\", operation_id)\n assert route.methods\n operation_id = f\"{operation_id}_{list(route.methods)[0].lower()}\"\n return operation_id\n\n\ndef deep_dict_update(main_dict: dict[Any, Any], update_dict: dict[Any, Any]) -> None:\n for key, value in update_dict.items():\n if (\n key in main_dict\n", "start_line": 190, "end_line": 220, "total_lines": 250, "is_truncated": false} |
| 30 | read_file | {
"end_line": 230,
"filepath": "fastapi/openapi/utils.py",
"start_line": 210
} | {"status": "ok", "filepath": "fastapi/openapi/utils.py", "content": " request_body_oai[\"content\"] = {request_media_type: request_media_content}\n return requefull{"status": "ok", "filepath": "fastapi/openapi/utils.py", "content": " request_body_oai[\"content\"] = {request_media_type: request_media_content}\n return request_body_oai\n\n\ndef generate_operation_id(\n *, route: routing.APIRoute, method: str\n) -> str: # pragma: nocover\n warnings.warn(\n \"fastapi.openapi.utils.generate_operation_id() was deprecated, \"\n \"it is not used internally, and will be removed soon\",\n DeprecationWarning,\n stacklevel=2,\n )\n if route.operation_id:\n return route.operation_id\n path: str = route.path_format\n return generate_operation_id_for_path(name=route.name, path=path, method=method)\n\n\ndef generate_operation_summary(*, route: routing.APIRoute, method: str) -> str:\n if route.summary:\n", "start_line": 210, "end_line": 230, "total_lines": 569, "is_truncated": false} |
| 31 | edit_file | {
"filepath": "fastapi/utils.py",
"new_string": "from fastapi.exceptions import FastAPIDeprecationWarning",
"old_string": "import warnings"
} | {"status": "ok", "filepath": "fastapi/utils.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/utils.py\n+++ b/fastapi/utils.py\n@@ -1,5 +1,5 @@full{"status": "ok", "filepath": "fastapi/utils.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/utils.py\n+++ b/fastapi/utils.py\n@@ -1,5 +1,5 @@\n import re\n-import warnings\n+from fastapi.exceptions import FastAPIDeprecationWarning\n from collections.abc import MutableMapping\n from typing import (\n TYPE_CHECKING,\n", "is_truncated": false} |
| 32 | edit_file | {
"filepath": "fastapi/utils.py",
"new_string": "import warnings\nfrom fastapi.exceptions import FastAPIDeprecationWarning",
"old_string": "from fastapi.exceptions import FastAPIDeprecationWarning"
} | {"status": "ok", "filepath": "fastapi/utils.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/utils.py\n+++ b/fastapi/utils.py\n@@ -1,4 +1,5 @@full{"status": "ok", "filepath": "fastapi/utils.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/utils.py\n+++ b/fastapi/utils.py\n@@ -1,4 +1,5 @@\n import re\n+import warnings\n from fastapi.exceptions import FastAPIDeprecationWarning\n from collections.abc import MutableMapping\n from typing import (\n", "is_truncated": false} |
| 33 | edit_file | {
"filepath": "fastapi/utils.py",
"new_string": " DeprecationWarning,",
"old_string": " FastAPIDeprecationWarning,"
} | {"status": "error", "error_type": "FileEditError", "error_message": "old_string not found in file (tried exact, flexible and regex matching)"}full{"status": "error", "error_type": "FileEditError", "error_message": "old_string not found in file (tried exact, flexible and regex matching)"} |
diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py
index 39d0bd89..af2bed9a 100644
--- a/fastapi/dependencies/utils.py
+++ b/fastapi/dependencies/utils.py
@@ -51,7 +51,7 @@ from fastapi.concurrency import (
contextmanager_in_threadpool,
)
from fastapi.dependencies.models import Dependant
-from fastapi.exceptions import DependencyScopeError
+from fastapi.exceptions import DependencyScopeError, FastAPIDeprecationWarning
from fastapi.logger import logger
from fastapi.security.oauth2 import SecurityScopes
from fastapi.types import DependencyCacheKey
@@ -327,7 +327,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..2fa167d9 100644
--- a/fastapi/exceptions.py
+++ b/fastapi/exceptions.py
@@ -7,6 +7,12 @@ from starlette.exceptions import HTTPException as StarletteHTTPException
from starlette.exceptions import WebSocketException as StarletteWebSocketException
+class FastAPIDeprecationWarning(DeprecationWarning):
+ \"\"\"
+ FastAPI deprecation warning.
+ \"\"\"
+
+
class EndpointContext(TypedDict, total=False):
function: str
path: str
diff --git a/fastapi/params.py b/fastapi/params.py
index c776c4a5..562b1036 100644
--- a/fastapi/params.py
+++ b/fastapi/params.py
@@ -5,6 +5,7 @@ from enum import Enum
from typing import Annotated, Any, Callable, Optional, Union
from fastapi.openapi.models import Example
+from fastapi.exceptions import FastAPIDeprecationWarning
from pydantic.fields import FieldInfo
from typing_extensions import Literal, deprecated
@@ -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..44207200 100644
--- a/fastapi/routing.py
+++ b/fastapi/routing.py
@@ -48,6 +48,7 @@ from fastapi.encoders import jsonable_encoder
from fastapi.exceptions import (
EndpointContext,
FastAPIError,
+ FastAPIDeprecationWarning,
RequestValidationError,
ResponseValidationError,
WebSocketRequestValidationError,
@@ -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..252c801c 100644
--- a/fastapi/temp_pydantic_v1_params.py
+++ b/fastapi/temp_pydantic_v1_params.py
@@ -3,6 +3,7 @@ from typing import Annotated, Any, Callable, Optional, Union
from fastapi.openapi.models import Example
from fastapi.params import ParamTypes
+from fastapi.exceptions import FastAPIDeprecationWarning
from typing_extensions import deprecated
from ._compat.may_v1 import FieldInfo, Undefined
@@ -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
diff --git a/fastapi/utils.py b/fastapi/utils.py
index c4631d7e..97e9b515 100644
--- a/fastapi/utils.py
+++ b/fastapi/utils.py
@@ -1,5 +1,6 @@
import re
import warnings
+from fastapi.exceptions import FastAPIDeprecationWarning
from collections.abc import MutableMapping
from typing import (
TYPE_CHECKING,
==================================== 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:25: in <module>
from fastapi import params, temp_pydantic_v1_params
fastapi/params.py:8: in <module>
from fastapi.exceptions import FastAPIDeprecationWarning
E File "/tmp/swe_work/eval3_submission_v2t/fastapi_14605/b/workspace/fastapi/exceptions.py", line 11
E \"\"\"
E ^
E SyntaxError: unexpected character after line continuation character
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 error in 0.63s