resolved RESOLVED PASS ยท 30 tool calls ยท 136 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/params.py:78: category=DeprecationWarning,\nfastapi/params.py:108: category=DeprecationWarning,\nfastapi/params.py:533: catefull{"status": "ok", "stdout": "fastapi/params.py:78: category=DeprecationWarning,\nfastapi/params.py:108: category=DeprecationWarning,\nfastapi/params.py:533: category=DeprecationWarning,\nfastapi/params.py:563: category=DeprecationWarning,\nfastapi/dependencies/utils.py:330: category=DeprecationWarning,\nfastapi/openapi/utils.py:220: DeprecationWarning,\nfastapi/utils.py:200: DeprecationWarning,\nfastapi/routing.py:643: category=DeprecationWarning,\nfastapi/routing.py:683: 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,\n", "stderr": "", "exit_code": 0} |
| 2 | run_command | {
"command": "ls fastapi/__init__.py fastapi/utils.py"
} | {"status": "ok", "stdout": "fastapi/__init__.py\nfastapi/utils.py\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "fastapi/__init__.py\nfastapi/utils.py\n", "stderr": "", "exit_code": 0} |
| 3 | run_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\nffull{"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} |
| 4 | run_command | {
"command": "cat fastapi/utils.py"
} | {"status": "ok", "stdout": "import re\nimport warnings\nfrom collections.abc import MutableMapping\nfrom typing import (\n TYPE_CHECKING,\n Any,\n Optional,\n Ufull{"status": "ok", "stdout": "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: \"\n \"https://fastapi.tiang |
| 5 | run_command | {
"command": "grep -rn \"DeprecationWarning\" fastapi/temp_pydantic_v1_params.py"
} | {"status": "ok", "stdout": "fastapi/temp_pydantic_v1_params.py:66: category=DeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:96: category=DeprecationWarnfull{"status": "ok", "stdout": "fastapi/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,\n", "stderr": "", "exit_code": 0} |
| 6 | run_command | {
"command": "cat fastapi/temp_pydantic_v1_params.py"
} | {"status": "ok", "stdout": "import warnings\nfrom typing import Annotated, Any, Callable, Optional, Union\n\nfrom fastapi.openapi.models import Example\nfrom fafull{"status": "ok", "stdout": "import warnings\nfrom typing import Annotated, Any, Callable, Optional, Union\n\nfrom fastapi.openapi.models import Example\nfrom fastapi.params import ParamTypes\nfrom typing_extensions import deprecated\n\nfrom ._compat.may_v1 import FieldInfo, Undefined\n\n_Unset: Any = Undefined\n\n\nclass Param(FieldInfo):\n in_: ParamTypes\n\n def __init__(\n self,\n default: Any = Undefined,\n *,\n default_factory: Union[Callable[[], Any], None] = _Unset,\n annotation: Optional[Any] = None,\n alias: Optional[str] = None,\n alias_priority: Union[int, None] = _Unset,\n # TODO: update when deprecating Pydantic v1, import these types\n # validation_alias: str | AliasPath | AliasChoices | None\n validation_alias: Union[str, None] = None,\n serialization_alias: Union[str, None] = None,\n title: Optional[str] = None,\n description: Optional[str] = None,\n gt: Optional[float] = None,\n ge: Optional[float] = None,\n lt: Optional[float] = None,\n le: Optional[float] = None,\n min_length: Optional[int] = None,\n max_length: Optional[int] = None,\n pattern: Optional[str] = None,\n regex: Annotated[\n Optional[str],\n deprecated(\n \"Deprecated in FastAPI 0.100.0 and Pydantic v2, use `pattern` instead.\"\n ),\n ] = None,\n discriminator: Union[str, None] = None,\n strict: Union[bool, None] = _Unset,\n multiple_of: Union[float, None] = _Unset,\n allow_inf_nan: Union[bool, None] = _Unset,\n max_digits: Union[int, None] = _Unset,\n decimal_places: Union[int, None] = _Unset,\n examples: Optional[list[Any]] = None,\n example: Annotated[\n Optional[Any],\n deprecated(\n \"Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, \"\n \"although still s |
| 7 | run_command | {
"command": "ls fastapi/exceptions.py"
} | {"status": "ok", "stdout": "fastapi/exceptions.py\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "fastapi/exceptions.py\n", "stderr": "", "exit_code": 0} |
| 8 | run_command | {
"command": "cat fastapi/exceptions.py"
} | {"status": "ok", "stdout": "from collections.abc import Sequence\nfrom typing import Annotated, Any, Optional, TypedDict, Union\n\nfrom annotated_doc import Docfull{"status": "ok", "stdout": "from collections.abc import Sequence\nfrom typing import Annotated, Any, Optional, TypedDict, Union\n\nfrom annotated_doc import Doc\nfrom pydantic import BaseModel, create_model\nfrom starlette.exceptions import HTTPException as StarletteHTTPException\nfrom starlette.exceptions import WebSocketException as StarletteWebSocketException\n\n\nclass EndpointContext(TypedDict, total=False):\n function: str\n path: str\n file: str\n line: int\n\n\nclass HTTPException(StarletteHTTPException):\n \"\"\"\n An HTTP exception you can raise in your own code to show errors to the client.\n\n This is for client errors, invalid authentication, invalid data, etc. Not for server\n errors in your code.\n\n Read more about it in the\n [FastAPI docs for Handling Errors](https://fastapi.tiangolo.com/tutorial/handling-errors/).\n\n ## Example\n\n ```python\n from fastapi import FastAPI, HTTPException\n\n app = FastAPI()\n\n items = {\"foo\": \"The Foo Wrestlers\"}\n\n\n @app.get(\"/items/{item_id}\")\n async def read_item(item_id: str):\n if item_id not in items:\n raise HTTPException(status_code=404, detail=\"Item not found\")\n return {\"item\": items[item_id]}\n ```\n \"\"\"\n\n def __init__(\n self,\n status_code: Annotated[\n int,\n Doc(\n \"\"\"\n HTTP status code to send to the client.\n \"\"\"\n ),\n ],\n detail: Annotated[\n Any,\n Doc(\n \"\"\"\n Any data to be sent to the client in the `detail` key of the JSON\n response.\n \"\"\"\n ),\n ] = None,\n headers: Annotated[\n Optional[dict[str, str]],\n Doc(\n \"\"\"\n Any headers to send to the client in the response.\n \"\"\"\n ),\n |
| 9 | run_command | {
"command": "cat fastapi/exceptions.py | tail -n 20"
} | {"status": "ok", "stdout": "class WebSocketRequestValidationError(ValidationException):\n def __init__(\n self,\n errors: Sequence[Any],\n *,\n endpoint_ctx: Opfull{"status": "ok", "stdout": "class WebSocketRequestValidationError(ValidationException):\n def __init__(\n self,\n errors: Sequence[Any],\n *,\n endpoint_ctx: Optional[EndpointContext] = None,\n ) -> None:\n super().__init__(errors, endpoint_ctx=endpoint_ctx)\n\n\nclass ResponseValidationError(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", "stderr": "", "exit_code": 0} |
| 10 | run_command | {
"command": "cd /workspace && python3 - <<'PY'\nfrom pathlib import Path\np = Path(\"fastapi/exceptions.py\")\ns = p.read_text()\n# Find a good place to insert FastAPIDeprecationWarning. \n# After FastAPIError seems reasonable.\nold = \"\"\"class FastAPIError(RuntimeError):\n \\\"\\\"\\\"\n A generic, FastAPI-specific error.\n \\\"\\\"\\\"\n\"\"\"\nnew = \"\"\"class FastAPIError(RuntimeError):\n \\\"\\\"\\\"\n A generic, FastAPI-specific error.\n \\\"\\\"\\\"\n\n\nclass FastAPIDeprecationWarning(DeprecationWarning):\n \\\"\\\"\\\"\n A warning for deprecated FastAPI features.\n \\\"\\\"\\\"\n\"\"\"\nassert s.count(old) == 1, (\"old text found this many times:\", s.count(old))\nt = s.replace(old, new)\np.write_text(t)\nPY\n"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 11 | run_command | {
"command": "sed -n '100,110p' fastapi/exceptions.py"
} | {"status": "ok", "stdout": "\n @app.websocket(\"/items/{item_id}/ws\")\n async def websocket_endpoint(\n *,\n websocket: WebSocket,\n session: Annotated[str | Nfull{"status": "ok", "stdout": "\n @app.websocket(\"/items/{item_id}/ws\")\n async def websocket_endpoint(\n *,\n websocket: WebSocket,\n session: Annotated[str | None, Cookie()] = None,\n item_id: str,\n ):\n if session is None:\n raise WebSocketException(code=status.WS_1008_POLICY_VIOLATION)\n await websocket.accept()\n", "stderr": "", "exit_code": 0} |
| 12 | run_command | {
"command": "grep -n \"FastAPIDeprecationWarning\" fastapi/exceptions.py"
} | {"status": "ok", "stdout": "157:class FastAPIDeprecationWarning(DeprecationWarning):\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "157:class FastAPIDeprecationWarning(DeprecationWarning):\n", "stderr": "", "exit_code": 0} |
| 13 | run_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 FastAPIDeprecationWarning(Deprfull{"status": "ok", "stdout": "\nclass FastAPIError(RuntimeError):\n \"\"\"\n A generic, FastAPI-specific error.\n \"\"\"\n\n\nclass FastAPIDeprecationWarning(DeprecationWarning):\n \"\"\"\n A warning for deprecated FastAPI features.\n \"\"\"\n\n\nclass DependencyScopeError(FastAPIError):\n \"\"\"\n A dependency declared that it depends on another dependency with an invalid\n", "stderr": "", "exit_code": 0} |
| 14 | run_command | {
"command": "grep -rn \"category=DeprecationWarning\" fastapi | head -20"
} | {"status": "ok", "stdout": "fastapi/params.py:78: category=DeprecationWarning,\nfastapi/params.py:108: category=DeprecationWarning,\nfastapi/params.py:533: catefull{"status": "ok", "stdout": "fastapi/params.py:78: category=DeprecationWarning,\nfastapi/params.py:108: category=DeprecationWarning,\nfastapi/params.py:533: category=DeprecationWarning,\nfastapi/params.py:563: category=DeprecationWarning,\nfastapi/dependencies/utils.py:330: category=DeprecationWarning,\nfastapi/routing.py:643: category=DeprecationWarning,\nfastapi/routing.py:683: 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,\n", "stderr": "", "exit_code": 0} |
| 15 | run_command | {
"command": "cd /workspace && python3 - <<'PY'\nimport re\nfrom pathlib import Path\n\nfiles_to_fix = [\n \"fastapi/params.py\",\n \"fastapi/dependencies/utils.py\",\n \"fastapi/routing.py\",\n \"fastapi/temp_pydantic_v1_params.py\",\n]\n\nfor file_path in files_to_fix:\n p = Path(file_path)\n if not p.exists():\n continue\n s = p.read_text()\n \n # We need to import FastAPIDeprecationWarning if it's not already imported.\n # It's in fastapi.exceptions.\n if \"from fastapi.exceptions import FastAPIDeprecationWarning\" not in s:\n # Try to find where other fastapi.exceptions are imported from\n if \"from fastapi.exceptions import\" in s:\n # Add it to the existing import\n s = re.sub(r\"from fastapi.exceptions import (.*)\", r\"from fastapi.exceptions import \\1, FastAPIDeprecationWarning\", s)\n else:\n # Add a new import line. \n # Usually imports are at the top.\n # Let's find the first import and put it after.\n # Or just put it at the top.\n s = \"from fastapi.exceptions import FastAPIDeprecationWarning\\n\" + s\n\n s = s.replace(\"category=DeprecationWarning\", \"category=FastAPIDeprecationWarning\")\n p.write_text(s)\nPY\n"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 16 | run_command | {
"command": "grep -rn \"FastAPIDeprecationWarning\" fastapi | head -20"
} | {"status": "ok", "stdout": "fastapi/params.py:1:from fastapi.exceptions import FastAPIDeprecationWarning\nfastapi/params.py:79: category=FastAPIDeprecationWarnifull{"status": "ok", "stdout": "fastapi/params.py:1:from fastapi.exceptions import FastAPIDeprecationWarning\nfastapi/params.py:79: category=FastAPIDeprecationWarning,\nfastapi/params.py:109: category=FastAPIDeprecationWarning,\nfastapi/params.py:534: category=FastAPIDeprecationWarning,\nfastapi/params.py:564: category=FastAPIDeprecationWarning,\nfastapi/dependencies/utils.py:54:from fastapi.exceptions import DependencyScopeError, FastAPIDeprecationWarning\nfastapi/dependencies/utils.py:330: category=FastAPIDeprecationWarning,\nfastapi/routing.py:48:from fastapi.exceptions import (, FastAPIDeprecationWarning\nfastapi/routing.py:643: category=FastAPIDeprecationWarning,\nfastapi/routing.py:683: category=FastAPIDeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:1: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/exceptions.py:157:class FastAPIDeprecationWarning(DeprecationWarning):\n", "stderr": "", "exit_code": 0} |
| 17 | run_command | {
"command": "sed -n '40,50p' fastapi/routing.py"
} | {"status": "ok", "stdout": " get_body_field,\n get_dependant,\n get_flat_dependant,\n get_parameterless_sub_dependant,\n get_typed_return_annotation,\n solve_defull{"status": "ok", "stdout": " 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 (, FastAPIDeprecationWarning\n EndpointContext,\n FastAPIError,\n", "stderr": "", "exit_code": 0} |
| 18 | run_command | {
"command": "cd /workspace && python3 - <<'PY'\nfrom pathlib import Path\np = Path(\"fastapi/routing.py\")\ns = p.read_text()\n# Fix the broken import: \"from fastapi.exceptions import (, FastAPIDeprecationWarning\"\n# It seems I used a regex that was too aggressive or the original file had something weird.\n# Let's see what was there before.\n# Original was probably \"from fastapi.exceptions import FastAPIError\" or something.\n\n# Let's just fix it manually.\n# Looking at the sed output:\n# from fastapi.exceptions import (, FastAPIDeprecationWarning\n# EndpointContext,\n# FastAPIError,\n\n# It seems it was:\n# from fastapi.exceptions import (\n# EndpointContext,\n# FastAPIError,\n# )\n\n# And my regex: s = re.sub(r\"from fastapi.exceptions import (.*)\", r\"from fastapi.exceptions import \\1, FastAPIDeprecationWarning\", s)\n# replaced \"from fastapi.exceptions import (\" with \"from fastapi.exceptions import (, FastAPIDeprecationWarning\"\n\n# Let's fix it.\nold = \"from fastapi.exceptions import (, FastAPIDeprecationWarning\"\nnew = \"from fastapi.exceptions import (\"\n# Wait, I need to add FastAPIDeprecationWarning inside the parentheses.\n\n# Let's just read the file and fix it properly.\ns = p.read_text()\n# Find the block:\n# from fastapi.exceptions import (\n# EndpointContext,\n# FastAPIError,\n# )\n# and change it to:\n# from fastapi.exceptions import (\n# EndpointContext,\n# FastAPIError,\n# FastAPIDeprecationWarning,\n# )\n\n# Let's try to find the line with FastAPIDeprecationWarning and fix the surrounding.\n# The current state is:\n# from fastapi.exceptions import (, FastAPIDeprecationWarning\n# EndpointContext,\n# FastAPIError,\n\n# This is definitely broken.\n\n# Let's just use a simpler approach for all files.\nPY\n"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 19 | run_command | {
"command": "cd /workspace && python3 - <<'PY'\nfrom pathlib import Path\nimport re\n\nfiles_to_fix = [\n \"fastapi/params.py\",\n \"fastapi/dependencies/utils.py\",\n \"fastapi/routing.py\",\n \"fastapi/temp_pydantic_v1_params.py\",\n]\n\nfor file_path in files_to_fix:\n p = Path(file_path)\n if not p.exists():\n continue\n s = p.read_text()\n \n # First, remove any FastAPIDeprecationWarning imports we added to start fresh\n # (but keep the category changes)\n # Actually, let's just fix the imports.\n \n # Remove the broken import we might have added\n s = s.replace(\"from fastapi.exceptions import (, FastAPIDeprecationWarning\", \"from fastapi.exceptions import (\")\n \n # Now let's handle imports properly.\n if \"from fastapi.exceptions import\" in s:\n # If it's a multi-line import with parentheses\n if \"from fastapi.exceptions import (\" in s:\n # Add FastAPIDeprecationWarning before the closing parenthesis\n # This is tricky with regex. Let's use a simpler way.\n # Find the closing parenthesis of the import.\n # This is still tricky.\n pass\n else:\n # Single line import: from fastapi.exceptions import A, B\n # We already did this, but let's make sure it's clean.\n pass\n\n # Let's just use a very simple approach: \n # If \"from fastapi.exceptions import\" is present, \n # and \"FastAPIDeprecationWarning\" is not, \n # add \"from fastapi.exceptions import FastAPIDeprecationWarning\" at the top.\n # This might result in duplicate imports from the same module, but it's safe.\n \n if \"FastAPIDeprecationWarning\" not in s:\n s = \"from fastapi.exceptions import FastAPIDeprecationWarning\\n\" + s\n \n # Ensure category is correct\n s = s.replace(\"category=DeprecationWarning\", \"category=FastAPIDeprecationWarning\")\n \n p.write_text(s)\nPY\n"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 20 | run_command | {
"command": "grep -rn \"FastAPIDeprecationWarning\" fastapi | head -20"
} | {"status": "ok", "stdout": "fastapi/params.py:1:from fastapi.exceptions import FastAPIDeprecationWarning\nfastapi/params.py:79: category=FastAPIDeprecationWarnifull{"status": "ok", "stdout": "fastapi/params.py:1:from fastapi.exceptions import FastAPIDeprecationWarning\nfastapi/params.py:79: category=FastAPIDeprecationWarning,\nfastapi/params.py:109: category=FastAPIDeprecationWarning,\nfastapi/params.py:534: category=FastAPIDeprecationWarning,\nfastapi/params.py:564: category=FastAPIDeprecationWarning,\nfastapi/dependencies/utils.py:54:from fastapi.exceptions import DependencyScopeError, FastAPIDeprecationWarning\nfastapi/dependencies/utils.py:330: category=FastAPIDeprecationWarning,\nfastapi/routing.py:643: category=FastAPIDeprecationWarning,\nfastapi/routing.py:683: category=FastAPIDeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:1: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/exceptions.py:157:class FastAPIDeprecationWarning(DeprecationWarning):\n", "stderr": "", "exit_code": 0} |
| 21 | run_command | {
"command": "cat fastapi/routing.py | head -n 60"
} | {"status": "ok", "stdout": "import email.message\nimport functools\nimport inspect\nimport json\nimport warnings\nfrom collections.abc import (\n AsyncIterator,full{"status": "ok", "stdout": "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", "stderr": "", "exit_code": 0} |
| 22 | run_command | {
"command": "cd /workspace && python3 - <<'PY'\nfrom pathlib import Path\np = Path(\"fastapi/routing.py\")\ns = p.read_text()\n# Add FastAPIDeprecationWarning to the import block\nold = \"\"\"from fastapi.exceptions import (\n EndpointContext,\n FastAPIError,\n RequestValidationError,\n ResponseValidationError,\n WebSocketRequestValidationError,\n)\"\"\"\nnew = \"\"\"from fastapi.exceptions import (\n EndpointContext,\n FastAPIError,\n RequestValidationError,\n ResponseValidationError,\n WebSocketRequestValidationError,\n FastAPIDeprecationWarning,\n)\"\"\"\nif old in s:\n s = s.replace(old, new)\n p.write_text(s)\nPY\n"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 23 | run_command | {
"command": "cat fastapi/routing.py | sed -n '45,55p'"
} | {"status": "ok", "stdout": " solve_dependencies,\n)\nfrom fastapi.encoders import jsonable_encoder\nfrom fastapi.exceptions import (\n EndpointContext,\n FastAPfull{"status": "ok", "stdout": " solve_dependencies,\n)\nfrom fastapi.encoders import jsonable_encoder\nfrom fastapi.exceptions import (\n EndpointContext,\n FastAPIError,\n RequestValidationError,\n ResponseValidationError,\n WebSocketRequestValidationError,\n FastAPIDeprecationWarning,\n)\n", "stderr": "", "exit_code": 0} |
| 24 | run_command | {
"command": "cd /workspace && python3 - <<'PY'\nfrom pathlib import Path\np = Path(\"fastapi/dependencies/utils.py\")\ns = p.read_text()\n# Fix the import in fastapi/dependencies/utils.py\n# It currently has: from fastapi.exceptions import DependencyScopeError, FastAPIDeprecationWarning\n# Let's check if it's okay.\n# If it's a single line import, it's fine.\nPY\n"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 25 | run_command | {
"command": "grep \"from fastapi.exceptions import\" fastapi/dependencies/utils.py"
} | {"status": "ok", "stdout": "from fastapi.exceptions import DependencyScopeError, FastAPIDeprecationWarning\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "from fastapi.exceptions import DependencyScopeError, FastAPIDeprecationWarning\n", "stderr": "", "exit_code": 0} |
| 26 | run_command | {
"command": "grep \"from fastapi.exceptions import\" fastapi/params.py"
} | {"status": "ok", "stdout": "from fastapi.exceptions import FastAPIDeprecationWarning\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "from fastapi.exceptions import FastAPIDeprecationWarning\n", "stderr": "", "exit_code": 0} |
| 27 | run_command | {
"command": "grep \"from fastapi.exceptions import\" fastapi/temp_pydantic_v1_params.py"
} | {"status": "ok", "stdout": "from fastapi.exceptions import FastAPIDeprecationWarning\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "from fastapi.exceptions import FastAPIDeprecationWarning\n", "stderr": "", "exit_code": 0} |
| 28 | run_command | {
"command": "git diff"
} | {"status": "ok", "stdout": "diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py\nindex 39d0bd89..af2bed9a 100644\n--- a/fastapi/dependencfull{"status": "ok", "stdout": "diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py\nindex 39d0bd89..af2bed9a 100644\n--- a/fastapi/dependencies/utils.py\n+++ b/fastapi/dependencies/utils.py\n@@ -51,7 +51,7 @@ from fastapi.concurrency import (\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@@ -327,7 +327,7 @@ def get_dependant(\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(\ndiff --git a/fastapi/exceptions.py b/fastapi/exceptions.py\nindex 8e0c5590..8e943574 100644\n--- a/fastapi/exceptions.py\n+++ b/fastapi/exceptions.py\n@@ -154,6 +154,12 @@ class FastAPIError(RuntimeError):\n \"\"\"\n \n \n+class FastAPIDeprecationWarning(DeprecationWarning):\n+ \"\"\"\n+ A warning for deprecated FastAPI features.\n+ \"\"\"\n+\n+\n class DependencyScopeError(FastAPIError):\n \"\"\"\n A dependency declared that it depends on another dependency with an invalid\ndiff --git a/fastapi/params.py b/fastapi/params.py\nindex c776c4a5..6fbcdee6 100644\n--- a/fastapi/params.py\n+++ b/fastapi/params.py\n@@ -1,3 +1,4 @@\n+from fastapi.exceptions import FastAPIDeprecationWarning\n import warnings\n from collections.abc import Sequence\n from dataclasses import dataclass\n@@ -75,7 +76,7 @@ class Param(FieldInfo): # type: ignore[misc]\n if example is not _Unset:\n warnings.warn(\n |
| 29 | run_command | {
"command": "git diff fastapi/temp_pydantic_v1_params.py"
} | {"status": "ok", "stdout": "diff --git a/fastapi/temp_pydantic_v1_params.py b/fastapi/temp_pydantic_v1_params.py\nindex 1bda0ea9..38f870f2 100644\n--- a/fastapifull{"status": "ok", "stdout": "diff --git a/fastapi/temp_pydantic_v1_params.py b/fastapi/temp_pydantic_v1_params.py\nindex 1bda0ea9..38f870f2 100644\n--- a/fastapi/temp_pydantic_v1_params.py\n+++ b/fastapi/temp_pydantic_v1_params.py\n@@ -1,3 +1,4 @@\n+from fastapi.exceptions import FastAPIDeprecationWarning\n import warnings\n from typing import Annotated, Any, Callable, Optional, Union\n \n@@ -63,7 +64,7 @@ class Param(FieldInfo):\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@@ -93,7 +94,7 @@ class Param(FieldInfo):\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@@ -503,7 +504,7 @@ class Body(FieldInfo):\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@@ -533,7 +534,7 @@ class Body(FieldInfo):\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", "stderr": "", "exit_code": 0} |
| 30 | run_command | {
"command": "submit_patch"
} | {"status": "error", "error_type": "CommandError", "error_message": "/bin/bash: submit_patch: command not found\n", "details": {"stdout": "", "stderr": "/bin/basfull{"status": "error", "error_type": "CommandError", "error_message": "/bin/bash: submit_patch: command not found\n", "details": {"stdout": "", "stderr": "/bin/bash: submit_patch: command not found\n", "exit_code": 127}} |
| 31 | submit_patch | {} | {"status": "ok", "patch_size": 6596, "files_changed": 5}full{"status": "ok", "patch_size": 6596, "files_changed": 5} |
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..8e943574 100644
--- a/fastapi/exceptions.py
+++ b/fastapi/exceptions.py
@@ -154,6 +154,12 @@ class FastAPIError(RuntimeError):
"""
+class FastAPIDeprecationWarning(DeprecationWarning):
+ """
+ A warning for deprecated FastAPI features.
+ """
+
+
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..6fbcdee6 100644
--- a/fastapi/params.py
+++ b/fastapi/params.py
@@ -1,3 +1,4 @@
+from fastapi.exceptions import FastAPIDeprecationWarning
import warnings
from collections.abc import Sequence
from dataclasses import dataclass
@@ -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..7ef87195 100644
--- a/fastapi/routing.py
+++ b/fastapi/routing.py
@@ -51,6 +51,7 @@ from fastapi.exceptions import (
RequestValidationError,
ResponseValidationError,
WebSocketRequestValidationError,
+ FastAPIDeprecationWarning,
)
from fastapi.types import DecoratedCallable, IncEx
from fastapi.utils import (
@@ -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..38f870f2 100644
--- a/fastapi/temp_pydantic_v1_params.py
+++ b/fastapi/temp_pydantic_v1_params.py
@@ -1,3 +1,4 @@
+from fastapi.exceptions import FastAPIDeprecationWarning
import warnings
from typing import Annotated, Any, Callable, Optional, Union
@@ -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
........................................................................ [ 72%]
........................... [100%]
=============================== warnings summary ===============================
../../../../../../../Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/overlays/starlette-0.50.0-py3-none-any/starlette/testclient.py:45
/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.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 0.91s