โ† pod_r2_v1f

fastapi_14605

failed WRONG_FIX UNSUBMITTED wrong_fix_unsubmitted(timeout) ยท 32 tool calls ยท 0 s ยท fastapi/fastapi

Task input

๐Ÿ”Š 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 calls (0)

#ToolArgumentsResult
No trace captured.

Patch

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

Test output

show
................................F
=================================== FAILURES ===================================
_____________________ test_query_regex_deprecation_warning _____________________

    def test_query_regex_deprecation_warning():
>       with pytest.warns(FastAPIDeprecationWarning, match="`regex` has been deprecated"):
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E       Failed: DID NOT WARN. No warnings of type (<class 'fastapi.exceptions.FastAPIDeprecationWarning'>,) were emitted.
E        Emitted warnings: [ DeprecationWarning('`regex` has been deprecated, please use `pattern` instead')].

tests/test_compat_params_v1.py:508: Failed
=============================== 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]]

tests/test_compat_params_v1.py::test_query_regex_deprecation_warning
  /Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/fastapi/lib/python3.13/site-packages/_pytest/python.py:167: DeprecationWarning: `regex` has been deprecated, please use `pattern` instead
    result = testfunction(**testargs)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 failed, 32 passed, 1 skipped, 2 warnings in 0.73s