resolved RESOLVED UNSUBMITTED PASS ยท 34 tool calls ยท 302 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": "grep -rn \"DeprecationWarning\" fastapi | head -40"
} | {"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} |
| 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": "python3 - <<'PY'\nfrom pathlib import Path\np = Path(\"fastapi/exceptions.py\")\ns = p.read_text()\nnew_lines = \"\\nclass FastAPIDeprecationWarning(DeprecationWarning):\\n \\\"\\\"\\\"\\n A warning for deprecated FastAPI features.\\n \\\"\\\"\\\"\\n\"\n# Insert after FastAPIError\nold = \"class FastAPIError(RuntimeError):\\n \\\"\\\"\\\"\\n A generic, FastAPI-specific error.\\n \\\"\\\"\\\"\\n\"\nif old in s:\n s = s.replace(old, old + new_lines)\n p.write_text(s)\n print(\"Inserted FastAPIDeprecationWarning\")\nelse:\n print(\"Old text not found\")\nPY\n"
} | {"status": "ok", "stdout": "Inserted FastAPIDeprecationWarning\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "Inserted FastAPIDeprecationWarning\n", "stderr": "", "exit_code": 0} |
| 10 | run_command | {
"command": "sed -n '110,120p' fastapi/exceptions.py"
} | {"status": "ok", "stdout": " await websocket.accept()\n while True:\n data = await websocket.receive_text()\n await websocket.send_text(f\"Session cookie is: {sfull{"status": "ok", "stdout": " await websocket.accept()\n while True:\n data = await websocket.receive_text()\n await websocket.send_text(f\"Session cookie is: {session}\")\n await websocket.send_text(f\"Message text was: {data}, for item ID: {item_id}\")\n ```\n \"\"\"\n\n def __init__(\n self,\n code: Annotated[\n", "stderr": "", "exit_code": 0} |
| 11 | run_command | {
"command": "grep -n \"FastAPIDeprecationWarning\" fastapi/exceptions.py"
} | {"status": "ok", "stdout": "156:class FastAPIDeprecationWarning(DeprecationWarning):\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "156:class FastAPIDeprecationWarning(DeprecationWarning):\n", "stderr": "", "exit_code": 0} |
| 12 | run_command | {
"command": "sed -n '150,160p' fastapi/exceptions.py"
} | {"status": "ok", "stdout": "\nclass FastAPIError(RuntimeError):\n \"\"\"\n A generic, FastAPI-specific error.\n \"\"\"\n\nclass FastAPIDeprecationWarning(Deprecfull{"status": "ok", "stdout": "\nclass FastAPIError(RuntimeError):\n \"\"\"\n A generic, FastAPI-specific error.\n \"\"\"\n\nclass FastAPIDeprecationWarning(DeprecationWarning):\n \"\"\"\n A warning for deprecated FastAPI features.\n \"\"\"\n\n", "stderr": "", "exit_code": 0} |
| 13 | 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} |
| 14 | run_command | {
"command": "python3 - <<'PY'\nimport os\nimport re\n\ndef replace_deprecation_warning(file_path):\n with open(file_path, 'r') as f:\n content = f.read()\n \n # We need to import FastAPIDeprecationWarning if we use it.\n # If the file doesn't have 'from fastapi.exceptions import ...', we might need to add it.\n # However, many files might already import from fastapi.exceptions.\n \n # Replace category=DeprecationWarning with category=FastAPIDeprecationWarning\n new_content = content.replace('category=DeprecationWarning', 'category=FastAPIDeprecationWarning')\n \n if new_content != content:\n with open(file_path, 'w') as f:\n f.write(new_content)\n print(f\"Updated {file_path}\")\n\nfiles_to_update = [\n \"fastapi/params.py\",\n \"fastapi/dependencies/utils.py\",\n \"fastapi/routing.py\",\n \"fastapi/temp_pydantic_v1_params.py\",\n]\n\nfor file in files_to_update:\n replace_deprecation_warning(file)\nPY\n"
} | {"status": "ok", "stdout": "Updated fastapi/params.py\nUpdated fastapi/dependencies/utils.py\nUpdated fastapi/routing.py\nUpdated fastapi/temp_pydantic_v1_paramfull{"status": "ok", "stdout": "Updated fastapi/params.py\nUpdated fastapi/dependencies/utils.py\nUpdated fastapi/routing.py\nUpdated fastapi/temp_pydantic_v1_params.py\n", "stderr": "", "exit_code": 0} |
| 15 | run_command | {
"command": "grep -rn \"FastAPIDeprecationWarning\" fastapi | head -20"
} | {"status": "ok", "stdout": "fastapi/params.py:78: category=FastAPIDeprecationWarning,\nfastapi/params.py:108: category=FastAPIDeprecationWarning,\nfastapi/paramfull{"status": "ok", "stdout": "fastapi/params.py:78: category=FastAPIDeprecationWarning,\nfastapi/params.py:108: category=FastAPIDeprecationWarning,\nfastapi/params.py:533: category=FastAPIDeprecationWarning,\nfastapi/params.py:563: category=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:66: category=FastAPIDeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:96: category=FastAPIDeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:506: category=FastAPIDeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:536: category=FastAPIDeprecationWarning,\nfastapi/exceptions.py:156:class FastAPIDeprecationWarning(DeprecationWarning):\n", "stderr": "", "exit_code": 0} |
| 16 | run_command | {
"command": "grep -rn \"DeprecationWarning\" fastapi | head -20"
} | {"status": "ok", "stdout": "fastapi/params.py:78: category=FastAPIDeprecationWarning,\nfastapi/params.py:108: category=FastAPIDeprecationWarning,\nfastapi/paramfull{"status": "ok", "stdout": "fastapi/params.py:78: category=FastAPIDeprecationWarning,\nfastapi/params.py:108: category=FastAPIDeprecationWarning,\nfastapi/params.py:533: category=FastAPIDeprecationWarning,\nfastapi/params.py:563: category=FastAPIDeprecationWarning,\nfastapi/dependencies/utils.py:330: category=FastAPIDeprecationWarning,\nfastapi/openapi/utils.py:220: DeprecationWarning,\nfastapi/utils.py:200: DeprecationWarning,\nfastapi/routing.py:643: category=FastAPIDeprecationWarning,\nfastapi/routing.py:683: category=FastAPIDeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:66: category=FastAPIDeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:96: category=FastAPIDeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:506: category=FastAPIDeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:536: category=FastAPIDeprecationWarning,\nfastapi/exceptions.py:156:class FastAPIDeprecationWarning(DeprecationWarning):\n", "stderr": "", "exit_code": 0} |
| 17 | run_command | {
"command": "grep -rn \"DeprecationWarning\" fastapi | grep -v \"FastAPIDeprecationWarning\""
} | {"status": "ok", "stdout": "fastapi/openapi/utils.py:220: DeprecationWarning,\nfastapi/utils.py:200: DeprecationWarning,\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "fastapi/openapi/utils.py:220: DeprecationWarning,\nfastapi/utils.py:200: DeprecationWarning,\n", "stderr": "", "exit_code": 0} |
| 18 | run_command | {
"command": "python3 - <<'PY'\nimport os\nimport re\n\ndef replace_deprecation_warning(file_path):\n with open(file_path, 'r') as f:\n content = f.read()\n \n new_content = content.replace('DeprecationWarning', 'FastAPIDeprecationWarning')\n \n if new_content != content:\n with open(file_path, 'w') as f:\n f.write(new_content)\n print(f\"Updated {file_path}\")\n\nfiles_to_update = [\n \"fastapi/openapi/utils.py\",\n \"fastapi/utils.py\",\n]\n\nfor file in files_to_update:\n replace_deprecation_warning(file)\nPY\n"
} | {"status": "ok", "stdout": "Updated fastapi/openapi/utils.py\nUpdated fastapi/utils.py\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "Updated fastapi/openapi/utils.py\nUpdated fastapi/utils.py\n", "stderr": "", "exit_code": 0} |
| 19 | run_command | {
"command": "grep -rn \"DeprecationWarning\" fastapi | grep -v \"FastAPIDeprecationWarning\""
} | {"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}} |
| 20 | run_command | {
"command": "python3 - <<'PY'\nimport os\nfrom fastapi.exceptions import FastAPIDeprecationWarning\nimport warnings\n\ndef test_warning():\n try:\n warnings.warn(\"Test warning\", category=FastAPIDeprecationWarning)\n print(\"Warning issued successfully\")\n except Exception as e:\n print(f\"Error: {e}\")\n\ntest_warning()\nPY\n"
} | {"status": "ok", "stdout": "Warning issued successfully\n", "stderr": "<stdin>:7: FastAPIDeprecationWarning: Test warning\n", "exit_code": 0}full{"status": "ok", "stdout": "Warning issued successfully\n", "stderr": "<stdin>:7: FastAPIDeprecationWarning: Test warning\n", "exit_code": 0} |
| 21 | run_command | {
"command": "grep -rn \"FastAPIDeprecationWarning\" fastapi | head -20"
} | {"status": "ok", "stdout": "fastapi/params.py:78: category=FastAPIDeprecationWarning,\nfastapi/params.py:108: category=FastAPIDeprecationWarning,\nfastapi/paramfull{"status": "ok", "stdout": "fastapi/params.py:78: category=FastAPIDeprecationWarning,\nfastapi/params.py:108: category=FastAPIDeprecationWarning,\nfastapi/params.py:533: category=FastAPIDeprecationWarning,\nfastapi/params.py:563: category=FastAPIDeprecationWarning,\nfastapi/dependencies/utils.py:330: category=FastAPIDeprecationWarning,\nfastapi/openapi/utils.py:220: FastAPIDeprecationWarning,\nfastapi/utils.py:200: FastAPIDeprecationWarning,\nfastapi/routing.py:643: category=FastAPIDeprecationWarning,\nfastapi/routing.py:683: category=FastAPIDeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:66: category=FastAPIDeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:96: category=FastAPIDeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:506: category=FastAPIDeprecationWarning,\nfastapi/temp_pydantic_v1_params.py:536: category=FastAPIDeprecationWarning,\nfastapi/exceptions.py:156:class FastAPIDeprecationWarning(DeprecationWarning):\n", "stderr": "", "exit_code": 0} |
| 22 | run_command | {
"command": "python3 - <<'PY'\nimport os\nimport re\n\ndef add_import(file_path):\n with open(file_path, 'r') as f:\n content = f.read()\n \n if 'from fastapi.exceptions import' in content:\n # Add FastAPIDeprecationWarning to existing import\n new_content = re.sub(\n r'(from fastapi\\.exceptions import\\s+)(.*)',\n r'\\1FastAPIDeprecationWarning, \\2',\n content,\n count=1\n )\n elif 'import fastapi.exceptions' in content:\n # This is less common, but just in case\n new_content = content.replace('import fastapi.exceptions', 'from fastapi.exceptions import FastAPIDeprecationWarning')\n else:\n # Add new import line at the top of the file, after other imports\n # Find the last import line\n lines = content.splitlines()\n import_index = -1\n for i, line in enumerate(lines):\n if line.startswith('import ') or line.startswith('from '):\n import_index = i\n \n if import_index != -1:\n lines.insert(import_index + 1, 'from fastapi.exceptions import FastAPIDeprecationWarning')\n new_content = '\\n'.join(lines)\n else:\n new_content = 'from fastapi.exceptions import FastAPIDeprecationWarning\\n' + content\n\n if new_content != content:\n with open(file_path, 'w') as f:\n f.write(new_content)\n print(f\"Added import to {file_path}\")\n\nfiles_to_update = [\n \"fastapi/params.py\",\n \"fastapi/dependencies/utils.py\",\n \"fastapi/routing.py\",\n \"fastapi/temp_pydantic_v1_params.py\",\n \"fastapi/openapi/utils.py\",\n \"fastapi/utils.py\",\n]\n\nfor file in files_to_update:\n add_import(file)\nPY\n"
} | {"status": "ok", "stdout": "Added import to fastapi/params.py\nAdded import to fastapi/dependencies/utils.py\nAdded import to fastapi/routing.py\nAdded import tfull{"status": "ok", "stdout": "Added import to fastapi/params.py\nAdded import to fastapi/dependencies/utils.py\nAdded import to fastapi/routing.py\nAdded import to fastapi/temp_pydantic_v1_params.py\nAdded import to fastapi/openapi/utils.py\nAdded import to fastapi/utils.py\n", "stderr": "", "exit_code": 0} |
| 23 | run_command | {
"command": "python3 - <<'PY'\nimport os\nimport re\n\ndef fix_imports(file_path):\n with open(file_path, 'r') as f:\n content = f.read()\n \n # Fix duplicate imports if any\n # e.g. from fastapi.exceptions import FastAPIDeprecationWarning, FastAPIDeprecationWarning\n new_content = re.sub(\n r'(from fastapi\\.exceptions import\\s+)(.*FastAPIDeprecationWarning,?\\s*FastAPIDeprecationWarning.*)',\n r'\\1\\2', # This is not quite right, let's just use a set for imports\n content\n )\n \n # A better way to fix duplicate imports in a line\n lines = content.splitlines()\n for i, line in enumerate(lines):\n if line.startswith('from fastapi.exceptions import'):\n parts = line.split('import')\n imports = parts[1].split(',')\n unique_imports = []\n for imp in imports:\n imp = imp.strip()\n if imp and imp not in unique_imports:\n unique_imports.append(imp)\n lines[i] = f\"from fastapi.exceptions import {', '.join(unique_imports)}\"\n \n new_content = '\\n'.join(lines)\n \n if new_content != content:\n with open(file_path, 'w') as f:\n f.write(new_content)\n print(f\"Fixed imports in {file_path}\")\n\nfiles_to_update = [\n \"fastapi/params.py\",\n \"fastapi/dependencies/utils.py\",\n \"fastapi/routing.py\",\n \"fastapi/temp_pydantic_v1_params.py\",\n \"fastapi/openapi/utils.py\",\n \"fastapi/utils.py\",\n]\n\nfor file in files_to_update:\n fix_imports(file)\nPY\n"
} | {"status": "ok", "stdout": "Fixed imports in fastapi/dependencies/utils.py\nFixed imports in fastapi/routing.py\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "Fixed imports in fastapi/dependencies/utils.py\nFixed imports in fastapi/routing.py\n", "stderr": "", "exit_code": 0} |
| 24 | run_command | {
"command": "python3 - <<'PY'\nimport os\nfrom fastapi.exceptions import FastAPIDeprecationWarning\nimport warnings\n\ndef test_warning():\n try:\n warnings.warn(\"Test warning\", category=FastAPIDeprecationWarning)\n print(\"Warning issued successfully\")\n except Exception as e:\n print(f\"Error: {e}\")\n\ntest_warning()\nPY\n"
} | {"status": "error", "error_type": "CommandError", "error_message": "Traceback (most recent call last):\n File \"<stdin>\", line 2, in <module>\n File \"/privatefull{"status": "error", "error_type": "CommandError", "error_message": "Traceback (most recent call last):\n File \"<stdin>\", line 2, in <module>\n File \"/private/workspace/fastapi/__init__.py\", line 7, in <module>\n from .applications import FastAPI as FastAPI\n File \"/private/workspace/fastapi/applications.py\", line 13, in <module>\n from fastapi import routing\n File \"/private/workspace/fastapi/routing.py\", line 48\n from fastapi.exceptions import FastAPIDeprecationWarning, (\n ^\nSyntaxError: invalid syntax\n", "details": {"stdout": "", "stderr": "Traceback (most recent call last):\n File \"<stdin>\", line 2, in <module>\n File \"/private/workspace/fastapi/__init__.py\", line 7, in <module>\n from .applications import FastAPI as FastAPI\n File \"/private/workspace/fastapi/applications.py\", line 13, in <module>\n from fastapi import routing\n File \"/private/workspace/fastapi/routing.py\", line 48\n from fastapi.exceptions import FastAPIDeprecationWarning, (\n ^\nSyntaxError: invalid syntax\n", "exit_code": 1}} |
| 25 | run_command | {
"command": "sed -n '40,55p' 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 RequestValidationError,\n ResponseValidationError,\n WebSocketRequestValidationError,\n)\nfrom fastapi.types import DecoratedCallable, IncEx\n", "stderr": "", "exit_code": 0} |
| 26 | run_command | {
"command": "sed -n '40,55p' fastapi/dependencies/utils.py"
} | {"status": "ok", "stdout": " is_uploadfile_sequence_annotation,\n lenient_issubclass,\n may_v1,\n sequence_types,\n serialize_sequence_value,\n value_is_sequencfull{"status": "ok", "stdout": " 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 FastAPIDeprecationWarning, DependencyScopeError\nfrom fastapi.logger import logger\n", "stderr": "", "exit_code": 0} |
| 27 | run_command | {
"command": "python3 - <<'PY'\nimport os\nimport re\n\ndef fix_routing_import(file_path):\n with open(file_path, 'r') as f:\n content = f.read()\n \n # Fix the syntax error in fastapi/routing.py\n # It seems it was: from fastapi.exceptions import FastAPIDeprecationWarning, (\n # We want: from fastapi.exceptions import (\n # FastAPIDeprecationWarning,\n # ...\n # )\n \n new_content = content.replace(\n 'from fastapi.exceptions import FastAPIDeprecationWarning, (',\n 'from fastapi.exceptions import (\\n FastAPIDeprecationWarning,'\n )\n \n with open(file_path, 'w') as f:\n f.write(new_content)\n\nfix_routing_import(\"fastapi/routing.py\")\nPY\n"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 28 | run_command | {
"command": "python3 - <<'PY'\nimport os\nfrom fastapi.exceptions import FastAPIDeprecationWarning\nimport warnings\n\ndef test_warning():\n try:\n warnings.warn(\"Test warning\", category=FastAPIDeprecationWarning)\n print(\"Warning issued successfully\")\n except Exception as e:\n print(f\"Error: {e}\")\n\ntest_warning()\nPY\n"
} | {"status": "error", "error_type": "CommandError", "error_message": "Traceback (most recent call last):\n File \"<stdin>\", line 2, in <module>\n File \"/privatefull{"status": "error", "error_type": "CommandError", "error_message": "Traceback (most recent call last):\n File \"<stdin>\", line 2, in <module>\n File \"/private/workspace/fastapi/__init__.py\", line 7, in <module>\n from .applications import FastAPI as FastAPI\n File \"/private/workspace/fastapi/applications.py\", line 13, in <module>\n from fastapi import routing\n File \"/private/workspace/fastapi/routing.py\", line 25, in <module>\n from fastapi import params, temp_pydantic_v1_params\n File \"/private/workspace/fastapi/params.py\", line 12\n from fastapi.exceptions import FastAPIDeprecationWarning\n ^^^^\nSyntaxError: invalid syntax\n", "details": {"stdout": "", "stderr": "Traceback (most recent call last):\n File \"<stdin>\", line 2, in <module>\n File \"/private/workspace/fastapi/__init__.py\", line 7, in <module>\n from .applications import FastAPI as FastAPI\n File \"/private/workspace/fastapi/applications.py\", line 13, in <module>\n from fastapi import routing\n File \"/private/workspace/fastapi/routing.py\", line 25, in <module>\n from fastapi import params, temp_pydantic_v1_params\n File \"/private/workspace/fastapi/params.py\", line 12\n from fastapi.exceptions import FastAPIDeprecationWarning\n ^^^^\nSyntaxError: invalid syntax\n", "exit_code": 1}} |
| 29 | run_command | {
"command": "sed -n '1,20p' fastapi/params.py"
} | {"status": "ok", "stdout": "import warnings\nfrom collections.abc import Sequence\nfrom dataclasses import dataclass\nfrom enum import Enum\nfrom typing import full{"status": "ok", "stdout": "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 (\nfrom fastapi.exceptions import FastAPIDeprecationWarning\n Undefined,\n)\n\n_Unset: Any = Undefined\n\n\nclass ParamTypes(Enum):\n query = \"query\"\n", "stderr": "", "exit_code": 0} |
| 30 | run_command | {
"command": "python3 - <<'PY'\nimport os\n\ndef fix_params_import(file_path):\n with open(file_path",
"'r') as f": "lines = f.readlines()\n \n # Find the line with 'from ._compat import ('\n # and move the 'from fastapi.exceptions import FastAPIDeprecationWarning' line\n # to before it.\n \n new_lines = [",
"]\n skip_line = False\n for line in lines": "if 'from fastapi.exceptions import FastAPIDeprecationWarning' in line:\n new_lines.append(line)\n skip_line = True\n elif 'from ._compat import (' in line:\n if skip_line:\n # We already added the import",
"but we need to make sure we don't\n # leave a gap or something. Actually, just adding it before is fine.\n pass\n new_lines.append(line)\n else": "new_lines.append(line)\n \n # This is not quite right because I don't know where the import was inserted.\n # Let's just read the file and fix it manually.\n\nwith open(\"fastapi/params.py\"",
"\"r\") as f": "content = f.read()\n\n# The current content is:\n# from ._compat import (\n# from fastapi.exceptions import FastAPIDeprecationWarning\n# Undefined",
"# )\n\n# We want": "# from fastapi.exceptions import FastAPIDeprecationWarning\n# from ._compat import (\n# Undefined",
"# )\n\n# Let's use a regex to fix it.\nimport re\nnew_content = re.sub(\n r'from \\._compat import \\(\\nfrom fastapi\\.exceptions import FastAPIDeprecationWarning\\n Undefined,',\n r'from fastapi.exceptions import FastAPIDeprecationWarning\\nfrom ._compat import (\\n Undefined,',\n content\n)\n\nwith open(\"fastapi/params.py\", \"w\") as f": "f.write(new_content)\nPY\n<|\"|>"
} | {"status": "error", "error_type": "CommandError", "error_message": " File \"<stdin>\", line 4\n with open(file_path\n ^\nSyntaxError: '(' was never closed\n", "full{"status": "error", "error_type": "CommandError", "error_message": " File \"<stdin>\", line 4\n with open(file_path\n ^\nSyntaxError: '(' was never closed\n", "details": {"stdout": "", "stderr": " File \"<stdin>\", line 4\n with open(file_path\n ^\nSyntaxError: '(' was never closed\n", "exit_code": 1}} |
| 31 | run_command | {
"command": "python3 - <<'PY'\nimport os\n\ndef fix_params_import(file_path):\n with open(file_path, 'r') as f:\n lines = f.readlines()\n \n new_lines = []\n import_line = \"\"\n for line in lines:\n if 'from fastapi.exceptions import FastAPIDeprecationWarning' in line:\n import_line = line\n elif 'from ._compat import (' in line:\n if import_line:\n new_lines.append(import_line)\n import_line = \"\"\n new_lines.append(line)\n else:\n if not (import_line == line): # avoid adding it twice if it was already there\n new_lines.append(line)\n \n # If import_line was not added yet\n if import_line:\n new_lines.append(import_line)\n\n with open(file_path, 'w') as f:\n f.write(\"\".join(new_lines))\n\nfix_params_import(\"fastapi/params.py\")\nPY\n"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 32 | run_command | {
"command": "sed -n '1,20p' fastapi/params.py"
} | {"status": "ok", "stdout": "import warnings\nfrom collections.abc import Sequence\nfrom dataclasses import dataclass\nfrom enum import Enum\nfrom typing import full{"status": "ok", "stdout": "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", "stderr": "", "exit_code": 0} |
| 33 | run_command | {
"command": "grep \"FastAPIDeprecationWarning\" fastapi/params.py"
} | {"status": "ok", "stdout": " category=FastAPIDeprecationWarning,\n category=FastAPIDeprecationWarning,\n category=FastAPIDeprecationWarning,\n category=FastAPIDfull{"status": "ok", "stdout": " category=FastAPIDeprecationWarning,\n category=FastAPIDeprecationWarning,\n category=FastAPIDeprecationWarning,\n category=FastAPIDeprecationWarning,\n scopes: Optional[Sequence[str]] = Nonefrom fastapi.exceptions import FastAPIDeprecationWarning\n", "stderr": "", "exit_code": 0} |
| 34 | run_command | {
"command": "python3 - <<'PY'\nimport os\n\ndef fix_params_import_again(file_path):\n with open(file_path, 'r') as f:\n content = f.read()\n \n # Remove the misplaced import\n content = content.replace('from fastapi.exceptions import FastAPIDeprecationWarning', '')\n \n # Add it at the top\n lines = content.splitlines()\n lines.insert(0, 'from fastapi.exceptions import FastAPIDeprecationWarning')\n \n with open(file_path, 'w') as f:\n f.write('\\n'.join(lines))\n\nfix_params_import_again(\"fastapi/params.py\")\nPY\n"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py
index 39d0bd89..518b3f80 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 FastAPIDeprecationWarning, DependencyScopeError
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(
@@ -1066,4 +1066,4 @@ def get_body_field(
def get_validation_alias(field: ModelField) -> str:
va = getattr(field, "validation_alias", None)
- return va or field.alias
+ return va or field.alias
\ No newline at end of file
diff --git a/fastapi/exceptions.py b/fastapi/exceptions.py
index 8e0c5590..ee602b28 100644
--- a/fastapi/exceptions.py
+++ b/fastapi/exceptions.py
@@ -153,6 +153,11 @@ class FastAPIError(RuntimeError):
A generic, FastAPI-specific error.
"""
+class FastAPIDeprecationWarning(DeprecationWarning):
+ """
+ A warning for deprecated FastAPI features.
+ """
+
class DependencyScopeError(FastAPIError):
"""
diff --git a/fastapi/openapi/utils.py b/fastapi/openapi/utils.py
index a99d4188..7482941e 100644
--- a/fastapi/openapi/utils.py
+++ b/fastapi/openapi/utils.py
@@ -39,6 +39,7 @@ from starlette.routing import BaseRoute
from typing_extensions import Literal
from .._compat import _is_model_field
+from fastapi.exceptions import FastAPIDeprecationWarning
validation_error_definition = {
"title": "ValidationError",
@@ -217,7 +218,7 @@ def generate_operation_id(
warnings.warn(
"fastapi.openapi.utils.generate_operation_id() was deprecated, "
"it is not used internally, and will be removed soon",
- DeprecationWarning,
+ FastAPIDeprecationWarning,
stacklevel=2,
)
if route.operation_id:
@@ -566,4 +567,4 @@ def get_openapi(
output["tags"] = tags
if external_docs:
output["externalDocs"] = external_docs
- return jsonable_encoder(OpenAPI(**output), by_alias=True, exclude_none=True) # type: ignore
+ return jsonable_encoder(OpenAPI(**output), by_alias=True, exclude_none=True) # type: ignore
\ No newline at end of file
diff --git a/fastapi/params.py b/fastapi/params.py
index c776c4a5..9dd4ac84 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
@@ -766,4 +767,4 @@ class Depends:
@dataclass(frozen=True)
class Security(Depends):
- scopes: Optional[Sequence[str]] = None
+ scopes: Optional[Sequence[str]] = None
\ No newline at end of file
diff --git a/fastapi/routing.py b/fastapi/routing.py
index 2770e325..a0737bda 100644
--- a/fastapi/routing.py
+++ b/fastapi/routing.py
@@ -46,6 +46,7 @@ from fastapi.dependencies.utils import (
)
from fastapi.encoders import jsonable_encoder
from fastapi.exceptions import (
+ FastAPIDeprecationWarning,
EndpointContext,
FastAPIError,
RequestValidationError,
@@ -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(
@@ -4580,4 +4581,4 @@ class APIRouter(routing.Router):
self.add_event_handler(event_type, func)
return func
- return decorator
+ return decorator
\ No newline at end of file
diff --git a/fastapi/temp_pydantic_v1_params.py b/fastapi/temp_pydantic_v1_params.py
index 1bda0ea9..e2834a3d 100644
--- a/fastapi/temp_pydantic_v1_params.py
+++ b/fastapi/temp_pydantic_v1_params.py
@@ -6,6 +6,7 @@ from fastapi.params import ParamTypes
from typing_extensions import deprecated
from ._compat.may_v1 import FieldInfo, Undefined
+from fastapi.exceptions import FastAPIDeprecationWarning
_Unset: Any = 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
@@ -714,4 +715,4 @@ class File(Form):
include_in_schema=include_in_schema,
json_schema_extra=json_schema_extra,
**extra,
- )
+ )
\ No newline at end of file
diff --git a/fastapi/utils.py b/fastapi/utils.py
index c4631d7e..af8e2dec 100644
--- a/fastapi/utils.py
+++ b/fastapi/utils.py
@@ -28,6 +28,7 @@ from pydantic.fields import FieldInfo
from typing_extensions import Literal
from ._compat import v2
+from fastapi.exceptions import FastAPIDeprecationWarning
if TYPE_CHECKING: # pragma: nocover
from .routing import APIRoute
@@ -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}"
@@ -247,4 +248,4 @@ def get_value_or_default(
for item in items:
if not isinstance(item, DefaultPlaceholder):
return item
- return first_item
+ return first_item
\ No newline at end of file
........................................................................ [ 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.94s