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"
)........................................................................ [ 38%]
........................................................................ [ 77%]
.............E
==================================== ERRORS ====================================
_______________ ERROR at setup of test_call[tutorial002_an_py39] _______________
request = <SubRequest 'client' for <Function test_call[tutorial002_an_py39]>>
@pytest.fixture(
name="client",
params=[
"tutorial002_an_py39",
pytest.param("tutorial002_an_py310", marks=needs_py310),
],
)
def get_client(request: pytest.FixtureRequest):
with warnings.catch_warnings(record=True):
warnings.filterwarnings(
"ignore",
message=r"pydantic\.v1 is deprecated and will soon stop being supported by FastAPI\..*",
category=DeprecationWarning,
)
> mod = importlib.import_module(f"docs_src.pydantic_v1_in_v2.{request.param}")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/test_tutorial/test_pydantic_v1_in_v2/test_tutorial002.py:34:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/Users/jp/.local/share/uv/python/cpython-3.13.15-macos-aarch64-none/lib/python3.13/importlib/__init__.py:88: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
<frozen importlib._bootstrap>:1395: in _gcd_import
???
<frozen importlib._bootstrap>:1360: in _find_and_load
???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
name = 'docs_src.pydantic_v1_in_v2.tutorial002_an_py39'
import_ = <function _gcd_import at 0x1041a84a0>
> ???
E ModuleNotFoundError: No module named 'docs_src.pydantic_v1_in_v2.tutorial002_an_py39'
<frozen importlib._bootstrap>:1324: ModuleNotFoundError
=============================== 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 !!!!!!!!!!!!!!!!!!!!!!!!!!!
157 passed, 1 skipped, 1 warning, 1 error in 2.40s