failed WRONG_FIX UNSUBMITTED wrong_fix_unsubmitted(None) ยท None tool calls ยท 0 s ยท fastapi/fastapi
๐ Add deprecation warnings when using `pydantic.v1` ๐ Add deprecation warnings when using `pydantic.v1`
| # | Tool | Arguments | Result |
|---|---|---|---|
| No trace captured. | |||
--- a/fastapi/dependencies/utils.py
+++ b/fastapi/dependencies/utils.py
@@ -1,6 +1,7 @@
import dataclasses
import inspect
import sys
+import warnings
from collections.abc import Coroutine, Mapping, Sequence
from contextlib import AsyncExitStack, contextmanager
from copy import copy, deepcopy
@@ -322,6 +323,13 @@ def get_dependant(
)
continue
assert param_details.field is not None
+ if isinstance(param_details.field, may_v1.ModelField):
+ 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,
+ stacklevel=5,
+ )
if isinstance(
param_details.field.field_info, (params.Body, temp_pydantic_v1_params.Body)
):
--- a/fastapi/routing.py
+++ b/fastapi/routing.py
@@ -2,6 +2,7 @@
import functools
import inspect
import json
+import warnings
from collections.abc import (
AsyncIterator,
Awaitable,
@@ -28,6 +29,7 @@
_get_model_config,
_model_dump,
_normalize_errors,
+ annotation_is_pydantic_v1,
lenient_issubclass,
may_v1,
)
@@ -634,6 +636,13 @@ def __init__(
f"Status code {status_code} must not have a response body"
)
response_name = "Response_" + self.unique_id
+ if annotation_is_pydantic_v1(self.response_model):
+ 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,
+ stacklevel=4,
+ )
self.response_field = create_model_field(
name=response_name,
type_=self.response_model,
@@ -667,6 +676,13 @@ def __init__(
f"Status code {additional_status_code} must not have a response body"
)
response_name = f"Response_{additional_status_code}_{self.unique_id}"
+ if annotation_is_pydantic_v1(model):
+ warnings.warn(
+ "pydantic.v1 is deprecated and will soon stop being supported by FastAPI."
+ f" In responses={{}}, please update {model}.",
+ category=DeprecationWarning,
+ stacklevel=4,
+ )
response_field = create_model_field(
name=response_name, type_=model, mode="serialization"
)
==================================== ERRORS ====================================
_______________ ERROR collecting tests/test_compat_params_v1.py ________________
tests/test_compat_params_v1.py:96: in <module>
@app.post("/form-data/")
^^^^^^^^^^^^^^^^^^^^^^^
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:283: in get_dependant
param_details = analyze_param(
fastapi/dependencies/utils.py:527: in analyze_param
ensure_multipart_is_installed()
fastapi/dependencies/utils.py:116: in ensure_multipart_is_installed
raise RuntimeError(multipart_not_installed_error) from None
E RuntimeError: Form data requires "python-multipart" to be installed.
E You can install "python-multipart" with:
E
E pip install python-multipart
=============================== 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
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 skipped, 1 warning, 1 error in 0.86s