failed WRONG_FIX UNSUBMITTED wrong_fix_unsubmitted(budget) ยท 36 tool calls ยท 304 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", "stderr": "", "exit_code": 0} |
| 2 | run_command | {
"command": "grep -rn \"Pydantic v1\" fastapi | head -20"
} | {"status": "ok", "stdout": "fastapi/dependencies/utils.py:552: # For Pydantic v1\nfastapi/_compat/main.py:214: # Pydantic v1 is not supported since Python 3.14\full{"status": "ok", "stdout": "fastapi/dependencies/utils.py:552: # For Pydantic v1\nfastapi/_compat/main.py:214: # Pydantic v1 is not supported since Python 3.14\nfastapi/_compat/v2.py:259: # TODO remove when deprecating Pydantic v1\nfastapi/_compat/v2.py:493:# Duplicate of several schema functions from Pydantic v1 to make them compatible with\nfastapi/temp_pydantic_v1_params.py:24: # TODO: update when deprecating Pydantic v1, import these types\nfastapi/temp_pydantic_v1_params.py:122: # TODO: update when deprecating Pydantic v1, import these types\nfastapi/temp_pydantic_v1_params.py:208: # TODO: update when deprecating Pydantic v1, import these types\nfastapi/temp_pydantic_v1_params.py:292: # TODO: update when deprecating Pydantic v1, import these types\nfastapi/temp_pydantic_v1_params.py:378: # TODO: update when deprecating Pydantic v1, import these types\nfastapi/temp_pydantic_v1_params.py:462: # TODO: update when deprecating Pydantic v1, import these types\nfastapi/temp_pydantic_v1_params.py:562: # TODO: update when deprecating Pydantic v1, import these types\nfastapi/temp_pydantic_v1_params.py:646: # TODO: update when deprecating Pydantic v1, import these types\nfastapi/routing.py:658: # TODO: remove when deprecating Pydantic v1\nfastapi/encoders.py:31:# Taken from Pydantic v1 as is\nfastapi/encoders.py:36:# Adapted from Pydantic v1\nfastapi/encoders.py:228: # TODO: remove when deprecating Pydantic v1\nfastapi/encoders.py:250: # TODO: remove when deprecating Pydantic v1\nfastapi/param_functions.py:57: # TODO: update when deprecating Pydantic v1, import these types\nfastapi/param_functions.py:382: # TODO: update when deprecating Pydantic v1, import these types\nfastapi/param_functions.py:686: # TODO: update when deprecating Pydantic v1, import these types\n", "stderr": "", "exit_code": 0} |
| 3 | read_file | {
"filepath": "fastapi/utils.py",
"start_line": "180",
"end_line": "220"
} | {"status": "error", "error_type": "FileReadError", "error_message": "'>' not supported between instances of 'int' and 'str'"}full{"status": "error", "error_type": "FileReadError", "error_message": "'>' not supported between instances of 'int' and 'str'"} |
| 4 | read_file | {
"filepath": "fastapi/utils.py"
} | {"status": "ok", "filepath": "fastapi/utils.py", "content": "import re\nimport warnings\nfrom collections.abc import MutableMapping\nfrom typing import (\n TYPEfull{"status": "ok", "filepath": "fastapi/utils.py", "content": "import re\nimport warnings\nfrom collections.abc import MutableMapping\nfrom typing import (\n TYPE_CHECKING,\n Any,\n Optional,\n Union,\n cast,\n)\nfrom weakref import WeakKeyDictionary\n\nimport fastapi\nfrom fastapi._compat import (\n BaseConfig,\n ModelField,\n PydanticSchemaGenerationError,\n Undefined,\n UndefinedType,\n Validator,\n annotation_is_pydantic_v1,\n lenient_issubclass,\n may_v1,\n)\nfrom fastapi.datastructures import DefaultPlaceholder, DefaultType\nfrom pydantic import BaseModel\nfrom pydantic.fields import FieldInfo\nfrom typing_extensions import Literal\n\nfrom ._compat import v2\n\nif TYPE_CHECKING: # pragma: nocover\n from .routing import APIRoute\n\n# Cache for `create_cloned_field`\n_CLONED_TYPES_CACHE: MutableMapping[type[BaseModel], type[BaseModel]] = (\n WeakKeyDictionary()\n)\n\n\ndef is_body_allowed_for_status_code(status_code: Union[int, str, None]) -> bool:\n if status_code is None:\n return True\n # Ref: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#patterned-fields-1\n if status_code in {\n \"default\",\n \"1XX\",\n \"2XX\",\n \"3XX\",\n \"4XX\",\n \"5XX\",\n }:\n return True\n current_status_code = int(status_code)\n return not (current_status_code < 200 or current_status_code in {204, 205, 304})\n\n\ndef get_path_param_names(path: str) -> set[str]:\n return set(re.findall(\"{(.*?)}\", path))\n\n\n_invalid_args_message = (\n \"Invalid args for response field! Hint: \"\n \"check that {type_} is a valid Pydantic field type. \"\n \"If you are using a return type annotation that is not a valid Pydantic \"\n \"field (e.g. Union[Response, dict, None]) you can disable generating the \"\n \"response model from the type annotation with the path operation decorator \"\n \"parameter response_model=None. Read more |
| 5 | read_file | {
"filepath": "fastapi/utils.py",
"start_line": "151"
} | {"status": "error", "error_type": "FileReadError", "error_message": "'>' not supported between instances of 'int' and 'str'"}full{"status": "error", "error_type": "FileReadError", "error_message": "'>' not supported between instances of 'int' and 'str'"} |
| 6 | run_command | {
"command": "grep -n \"DeprecationWarning\" fastapi/utils.py"
} | {"status": "ok", "stdout": "200: DeprecationWarning,\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "200: DeprecationWarning,\n", "stderr": "", "exit_code": 0} |
| 7 | read_file | {
"filepath": "fastapi/utils.py",
"start_line": "190",
"end_line": "210"
} | {"status": "error", "error_type": "FileReadError", "error_message": "'>' not supported between instances of 'int' and 'str'"}full{"status": "error", "error_type": "FileReadError", "error_message": "'>' not supported between instances of 'int' and 'str'"} |
| 8 | run_command | {
"command": "sed -n '190,210p' fastapi/utils.py"
} | {"status": "ok", "stdout": " new_field.populate_validators() # type: ignore[attr-defined]\n return new_field\n\n\ndef generate_operation_id_for_path(\n *, name:full{"status": "ok", "stdout": " 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", "stderr": "", "exit_code": 0} |
| 9 | run_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} |
| 10 | run_command | {
"command": "grep -rn \"Pydantic v1\" fastapi/temp_pydantic_v1_params.py"
} | {"status": "ok", "stdout": "24: # TODO: update when deprecating Pydantic v1, import these types\n122: # TODO: update when deprecating Pydantic v1, import these full{"status": "ok", "stdout": "24: # TODO: update when deprecating Pydantic v1, import these types\n122: # TODO: update when deprecating Pydantic v1, import these types\n208: # TODO: update when deprecating Pydantic v1, import these types\n292: # TODO: update when deprecating Pydantic v1, import these types\n378: # TODO: update when deprecating Pydantic v1, import these types\n462: # TODO: update when deprecating Pydantic v1, import these types\n562: # TODO: update when deprecating Pydantic v1, import these types\n646: # TODO: update when deprecating Pydantic v1, import these types\n", "stderr": "", "exit_code": 0} |
| 11 | read_file | {
"filepath": "fastapi/temp_pydantic_v1_params.py"
} | {"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 |
| 12 | run_command | {
"command": "grep -rn \"class FastAPIError\" fastapi | head -20"
} | {"status": "ok", "stdout": "fastapi/exceptions.py:151:class FastAPIError(RuntimeError):\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "fastapi/exceptions.py:151:class FastAPIError(RuntimeError):\n", "stderr": "", "exit_code": 0} |
| 13 | 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 |
| 14 | read_file | {
"filepath": "fastapi/exceptions.py",
"start_line": "151"
} | {"status": "error", "error_type": "FileReadError", "error_message": "'>' not supported between instances of 'int' and 'str'"}full{"status": "error", "error_type": "FileReadError", "error_message": "'>' not supported between instances of 'int' and 'str'"} |
| 15 | run_command | {
"command": "sed -n '151,233p' fastapi/exceptions.py"
} | {"status": "ok", "stdout": "class FastAPIError(RuntimeError):\n \"\"\"\n A generic, FastAPI-specific error.\n \"\"\"\n\n\nclass DependencyScopeError(FastAPIErrofull{"status": "ok", "stdout": "class 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 self,\n errors: Sequence[Any],\n *,\n endpoint_ctx: Optional[EndpointContext] = None,\n ) -> None:\n self._errors = errors\n self.endpoint_ctx = endpoint_ctx\n\n ctx = endpoint_ctx or {}\n self.endpoint_function = ctx.get(\"function\")\n self.endpoint_path = ctx.get(\"path\")\n self.endpoint_file = ctx.get(\"file\")\n self.endpoint_line = ctx.get(\"line\")\n\n def errors(self) -> Sequence[Any]:\n return self._errors\n\n def _format_endpoint_context(self) -> str:\n if not (self.endpoint_file and self.endpoint_line and self.endpoint_function):\n if self.endpoint_path:\n return f\"\\n Endpoint: {self.endpoint_path}\"\n return \"\"\n\n context = f'\\n File \"{self.endpoint_file}\", line {self.endpoint_line}, in {self.endpoint_function}'\n if self.endpoint_path:\n context += f\"\\n {self.endpoint_path}\"\n return context\n\n def __str__(self) -> str:\n message = f\"{len(self._errors)} validation error{'s' if len(self._errors) != 1 else ''}:\\n\"\n for err in self._errors:\n message += f\" {err}\\n\"\n message += self._format_endpoint_context()\n return message.rstrip()\n\n\nclass RequestValidationError(ValidationException):\n def __init__(\n self,\n errors: Sequence[Any],\n *,\n body: Any = None,\n endpoint_ctx: Optional[EndpointContext] = None,\n ) -> None:\n super().__init__(errors, endpoint_ctx=endpoint_ctx)\n self.body = body\n\n\nclass WebSo |
| 16 | edit_file | {
"filepath": "fastapi/exceptions.py",
"new_string": "class FastAPIError(RuntimeError):\n \"\"\"\n A generic, FastAPI-specific error.\n \"\"\"\n\n\nclass FastAPIDeprecationWarning(DeprecationWarning):\n \"\"\"\n A FastAPI-specific deprecation warning.\n \"\"\"\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\nfull{"status": "ok", "filepath": "fastapi/exceptions.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/exceptions.py\n+++ b/fastapi/exceptions.py\n@@ -154,6 +154,12 @@\n \"\"\"\n \n \n+class FastAPIDeprecationWarning(DeprecationWarning):\n+ \"\"\"\n+ A FastAPI-specific deprecation warning.\n+ \"\"\"\n+\n+\n class DependencyScopeError(FastAPIError):\n \"\"\"\n A dependency declared that it depends on another dependency with an invalid\n", "is_truncated": false} |
| 17 | run_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} |
| 18 | run_command | {
"command": "grep -rn \"DeprecationWarning\" fastapi | head -20"
} | {"status": "ok", "stdout": "fastapi/dependencies/utils.py:330: category=DeprecationWarning,\nfastapi/exceptions.py:157:class FastAPIDeprecationWarning(Deprecatifull{"status": "ok", "stdout": "fastapi/dependencies/utils.py:330: category=DeprecationWarning,\nfastapi/exceptions.py:157:class FastAPIDeprecationWarning(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} |
| 19 | 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", "stderr": "", "exit_code": 0} |
| 20 | edit_file | {
"filepath": "fastapi/temp_pydantic_v1_params.py",
"new_string": "from fastapi.exceptions import FastAPIDeprecationWarning\nfrom fastapi.openapi.models import Example\n",
"old_string": "from fastapi.openapi.models import Example\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,6 +1,7 @@\n import warnings\n from typing import Annotated, Any, Callable, Optional, Union\n \n+from fastapi.exceptions import FastAPIDeprecationWarning\n from fastapi.openapi.models import Example\n from fastapi.params import ParamTypes\n from typing_extensions import deprecated\n", "is_truncated": false} |
| 21 | edit_file | {
"filepath": "fastapi/temp_pydantic_v1_params.py",
"new_string": " category=FastAPIDeprecationWarning,\n",
"old_string": " category=DeprecationWarning,\n",
"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} |
| 22 | run_command | {
"command": "grep -rn \"category=DeprecationWarning\" fastapi | head -20"
} | {"status": "ok", "stdout": "fastapi/dependencies/utils.py:330: category=DeprecationWarning,\nfastapi/routing.py:643: category=DeprecationWarning,\nfastapi/routifull{"status": "ok", "stdout": "fastapi/dependencies/utils.py:330: 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} |
| 23 | run_command | {
"command": "grep -rn \"DeprecationWarning\" fastapi | grep -v \"exceptions.py\" | grep -v \"temp_pydantic_v1_params.py\""
} | {"status": "ok", "stdout": "fastapi/dependencies/utils.py:330: category=DeprecationWarning,\nfastapi/routing.py:643: category=DeprecationWarning,\nfastapi/routifull{"status": "ok", "stdout": "fastapi/dependencies/utils.py:330: 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} |
| 24 | run_command | {
"command": "grep -rn \"category=DeprecationWarning\" fastapi | head -20"
} | {"status": "ok", "stdout": "fastapi/dependencies/utils.py:330: category=DeprecationWarning,\nfastapi/routing.py:643: category=DeprecationWarning,\nfastapi/routifull{"status": "ok", "stdout": "fastapi/dependencies/utils.py:330: 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} |
| 25 | edit_file | {
"filepath": "fastapi/params.py",
"new_string": "from 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,4full{"status": "ok", "filepath": "fastapi/params.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/params.py\n+++ b/fastapi/params.py\n@@ -1,4 +1,4 @@\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} |
| 26 | edit_file | {
"allow_multiple": true,
"filepath": "fastapi/params.py",
"new_string": " category=FastAPIDeprecationWarning,\n",
"old_string": " category=DeprecationWarning,\n"
} | {"status": "ok", "filepath": "fastapi/params.py", "occurrences": 4, "strategy": "exact", "diff": "--- a/fastapi/params.py\n+++ b/fastapi/params.py\n@@ -75,7 +75full{"status": "ok", "filepath": "fastapi/params.py", "occurrences": 4, "strategy": "exact", "diff": "--- a/fastapi/params.py\n+++ b/fastapi/params.py\n@@ -75,7 +75,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@@ -105,7 +105,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@@ -530,7 +530,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@@ -560,7 +560,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} |
| 27 | run_command | {
"command": "grep -rn \"category=DeprecationWarning\" fastapi | head -20"
} | {"status": "ok", "stdout": "fastapi/dependencies/utils.py:330: category=DeprecationWarning,\nfastapi/routing.py:643: category=DeprecationWarning,\nfastapi/routifull{"status": "ok", "stdout": "fastapi/dependencies/utils.py:330: category=DeprecationWarning,\nfastapi/routing.py:643: category=DeprecationWarning,\nfastapi/routing.py:683: category=DeprecationWarning,\n", "stderr": "", "exit_code": 0} |
| 28 | edit_file | {
"filepath": "fastapi/routing.py",
"new_string": "from 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@@ -2,7 +full{"status": "ok", "filepath": "fastapi/routing.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/routing.py\n+++ b/fastapi/routing.py\n@@ -2,7 +2,7 @@\n import functools\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} |
| 29 | edit_file | {
"allow_multiple": true,
"filepath": "fastapi/routing.py",
"new_string": " category=FastAPIDeprecationWarning,\n",
"old_string": " category=DeprecationWarning,\n"
} | {"status": "ok", "filepath": "fastapi/routing.py", "occurrences": 2, "strategy": "exact", "diff": "--- a/fastapi/routing.py\n+++ b/fastapi/routing.py\n@@ -640,7full{"status": "ok", "filepath": "fastapi/routing.py", "occurrences": 2, "strategy": "exact", "diff": "--- a/fastapi/routing.py\n+++ b/fastapi/routing.py\n@@ -640,7 +640,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@@ -680,7 +680,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} |
| 30 | edit_file | {
"filepath": "fastapi/dependencies/utils.py",
"new_string": "from 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/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@@ -1,7 +1,7 @@\n import dataclasses\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} |
| 31 | edit_file | {
"filepath": "fastapi/dependencies/utils.py",
"new_string": " category=FastAPIDeprecationWarning,\n",
"old_string": " category=DeprecationWarning,\n"
} | {"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} |
| 32 | run_command | {
"command": "grep -rn \"category=DeprecationWarning\" fastapi"
} | {"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}} |
| 33 | run_command | {
"command": "grep -rn \"DeprecationWarning\" fastapi | grep -v \"exceptions.py\""
} | {"status": "ok", "stdout": "fastapi/dependencies/utils.py:4:from fastapi.exceptions import FastAPIDeprecationWarning\nfastapi/dependencies/utils.py:330: categorfull{"status": "ok", "stdout": "fastapi/dependencies/utils.py:4:from fastapi.exceptions import FastAPIDeprecationWarning\nfastapi/dependencies/utils.py:330: category=FastAPIDeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:4:from fastapi.exceptions import FastAPIDeprecationWarning\nfastapi/temp_pydantic_v1_params.py:67: category=FastAPIDeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:97: category=FastAPIDeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:507: category=FastAPIDeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:537: category=FastAPIDeprecationWarning,\nfastapi/routing.py:5:from fastapi.exceptions import FastAPIDeprecationWarning\nfastapi/routing.py:643: category=FastAPIDeprecationWarning,\nfastapi/routing.py:683: category=FastAPIDeprecationWarning,\nfastapi/utils.py:200: DeprecationWarning,\nfastapi/params.py:1:from fastapi.exceptions import FastAPIDeprecationWarning\nfastapi/params.py:78: category=FastAPIDeprecationWarning,\nfastapi/params.py:108: category=FastAPIDeprecationWarning,\nfastapi/params.py:533: category=FastAPIDeprecationWarning,\nfastapi/params.py:563: category=FastAPIDeprecationWarning,\nfastapi/openapi/utils.py:220: DeprecationWarning,\n", "stderr": "", "exit_code": 0} |
| 34 | run_command | {
"command": "sed -n '190,210p' fastapi/utils.py"
} | {"status": "ok", "stdout": " new_field.populate_validators() # type: ignore[attr-defined]\n return new_field\n\n\ndef generate_operation_id_for_path(\n *, name:full{"status": "ok", "stdout": " 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", "stderr": "", "exit_code": 0} |
| 35 | edit_file | {
"filepath": "fastapi/utils.py",
"new_string": "from fastapi.exceptions import FastAPIDeprecationWarning\nimport re\nimport warnings\n",
"old_string": "import re\nimport warnings\n"
} | {"status": "ok", "filepath": "fastapi/utils.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/utils.py\n+++ b/fastapi/utils.py\n@@ -1,3 +1,4 @@full{"status": "ok", "filepath": "fastapi/utils.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/utils.py\n+++ b/fastapi/utils.py\n@@ -1,3 +1,4 @@\n+from fastapi.exceptions import FastAPIDeprecationWarning\n import re\n import warnings\n from collections.abc import MutableMapping\n", "is_truncated": false} |
| 36 | edit_file | {
"filepath": "fastapi/utils.py",
"new_string": " FastAPIDeprecationWarning,\n",
"old_string": " DeprecationWarning,\n"
} | {"status": "ok", "filepath": "fastapi/utils.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/utils.py\n+++ b/fastapi/utils.py\n@@ -198,7 +198,full{"status": "ok", "filepath": "fastapi/utils.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/fastapi/utils.py\n+++ b/fastapi/utils.py\n@@ -198,7 +198,7 @@\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+ FastAPIDeprecationWarning,\n stacklevel=2,\n )\n operation_id = f\"{name}{path}\"\n", "is_truncated": false} |
diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py
index 39d0bd89..2d0ea964 100644
--- a/fastapi/dependencies/utils.py
+++ b/fastapi/dependencies/utils.py
@@ -1,7 +1,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 +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..05f8f216 100644
--- a/fastapi/exceptions.py
+++ b/fastapi/exceptions.py
@@ -154,6 +154,12 @@ class FastAPIError(RuntimeError):
"""
+class FastAPIDeprecationWarning(DeprecationWarning):
+ """
+ A FastAPI-specific deprecation warning.
+ """
+
+
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..aa6c138e 100644
--- a/fastapi/params.py
+++ b/fastapi/params.py
@@ -1,4 +1,4 @@
-import warnings
+from fastapi.exceptions import FastAPIDeprecationWarning
from collections.abc import Sequence
from dataclasses import dataclass
from enum import Enum
@@ -75,7 +75,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 +105,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 +530,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 +560,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..24af6aa1 100644
--- a/fastapi/routing.py
+++ b/fastapi/routing.py
@@ -2,7 +2,7 @@ import email.message
import functools
import inspect
import json
-import warnings
+from fastapi.exceptions import FastAPIDeprecationWarning
from collections.abc import (
AsyncIterator,
Awaitable,
@@ -640,7 +640,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 +680,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..62230e42 100644
--- a/fastapi/temp_pydantic_v1_params.py
+++ b/fastapi/temp_pydantic_v1_params.py
@@ -1,6 +1,7 @@
import warnings
from typing import Annotated, Any, Callable, Optional, Union
+from fastapi.exceptions import FastAPIDeprecationWarning
from fastapi.openapi.models import Example
from fastapi.params import ParamTypes
from typing_extensions import deprecated
@@ -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..28a5f47e 100644
--- a/fastapi/utils.py
+++ b/fastapi/utils.py
@@ -1,3 +1,4 @@
+from fastapi.exceptions import FastAPIDeprecationWarning
import re
import warnings
from collections.abc import MutableMapping
@@ -197,7 +198,7 @@ def generate_operation_id_for_path(
warnings.warn(
"fastapi.utils.generate_operation_id_for_path() was deprecated, "
"it is not used internally, and will be removed soon",
- DeprecationWarning,
+ FastAPIDeprecationWarning,
stacklevel=2,
)
operation_id = f"{name}{path}"
==================================== ERRORS ====================================
_______________ ERROR collecting tests/test_compat_params_v1.py ________________
tests/test_compat_params_v1.py:41: in <module>
@app.get("/items/{item_id}")
^^^^^^^^^^^^^^^^^^^^^^^^^^^
fastapi/routing.py:1138: in decorator
self.add_api_route(
fastapi/routing.py:1077: in add_api_route
route = route_class(
fastapi/routing.py:696: in __init__
self.dependant = get_dependant(
fastapi/dependencies/utils.py:327: in get_dependant
warnings.warn(
^^^^^^^^
E NameError: name 'warnings' is not defined. Did you forget to import 'warnings'?
=============================== 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
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 skipped, 1 warning, 1 error in 0.93s