failed WRONG_FIX wrong_fix · 13 tool calls · 118 s · fastapi/fastapi
🗑️ Deprecate `ORJSONResponse` and `UJSONResponse` 🗑️ Deprecate `ORJSONResponse` and `UJSONResponse` Now that there's better performance by default, with response models: https://github.com/fastapi/fastapi/pull/14962 This removes `ujson` and `orjson` from the `"fastapi[all]"` extras. To use these responses, `ujson` or `orjson` need to be explicitly installed.
| # | Tool | Arguments | Result |
|---|---|---|---|
| 1 | run_command | {
"command": "( grep -rn 'ORJSONResponse' --include=*.py . || echo '<IMPORTANT> NO MATCH FOUND. DO NOT TRY SAME COMMAND.' ) | head -40\n"
} | {"status": "ok", "stdout": "./tests/test_orjson_response_class.py:2:from fastapi.responses import ORJSONResponse\n./tests/test_orjson_response_class.py:6:app = full{"status": "ok", "stdout": "./tests/test_orjson_response_class.py:2:from fastapi.responses import ORJSONResponse\n./tests/test_orjson_response_class.py:6:app = FastAPI(default_response_class=ORJSONResponse)\n./tests/test_default_response_class.py:9:class ORJSONResponse(JSONResponse):\n./tests/test_default_response_class.py:20:app = FastAPI(default_response_class=ORJSONResponse)\n./fastapi/responses.py:36:class ORJSONResponse(JSONResponse):\n./fastapi/responses.py:45: assert orjson is not None, \"orjson must be installed to use ORJSONResponse\"\n./fastapi/applications.py:369: from fastapi.responses import ORJSONResponse\n./fastapi/applications.py:371: app = FastAPI(default_response_class=ORJSONResponse)\n./fastapi/applications.py:1461: from fastapi.responses import ORJSONResponse\n./fastapi/applications.py:1469: default_response_class=ORJSONResponse,\n./docs_src/custom_response/tutorial009c_py310.py:9:class CustomORJSONResponse(Response):\n./docs_src/custom_response/tutorial009c_py310.py:17:@app.get(\"/\", response_class=CustomORJSONResponse)\n./docs_src/custom_response/tutorial001b_py310.py:2:from fastapi.responses import ORJSONResponse\n./docs_src/custom_response/tutorial001b_py310.py:7:@app.get(\"/items/\", response_class=ORJSONResponse)\n./docs_src/custom_response/tutorial001b_py310.py:9: return ORJSONResponse([{\"item_id\": \"Foo\"}])\n", "stderr": "", "exit_code": 0} |
| 2 | run_command | {
"command": "( grep -rn 'UJSONResponse' --include=*.py . || echo '<IMPORTANT> NO MATCH FOUND. DO NOT TRY SAME COMMAND.' ) | head -40\n"
} | {"status": "ok", "stdout": "./fastapi/responses.py:23:class UJSONResponse(JSONResponse):\n./fastapi/responses.py:32: assert ujson is not None, \"ujson must be ifull{"status": "ok", "stdout": "./fastapi/responses.py:23:class UJSONResponse(JSONResponse):\n./fastapi/responses.py:32: assert ujson is not None, \"ujson must be installed to use UJSONResponse\"\n./docs_src/custom_response/tutorial001_py310.py:2:from fastapi.responses import UJSONResponse\n./docs_src/custom_response/tutorial001_py310.py:7:@app.get(\"/items/\", response_class=UJSONResponse)\n", "stderr": "", "exit_code": 0} |
| 3 | run_command | {
"command": "sed -n '20,50p' fastapi/responses.py\n"
} | {"status": "ok", "stdout": " orjson = None # type: ignore\n\n\nclass UJSONResponse(JSONResponse):\n \"\"\"\n JSON response using the high-performance ujson librfull{"status": "ok", "stdout": " orjson = None # type: ignore\n\n\nclass UJSONResponse(JSONResponse):\n \"\"\"\n JSON response using the high-performance ujson library to serialize data to JSON.\n\n Read more about it in the\n [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).\n \"\"\"\n\n def render(self, content: Any) -> bytes:\n assert ujson is not None, \"ujson must be installed to use UJSONResponse\"\n return ujson.dumps(content, ensure_ascii=False).encode(\"utf-8\")\n\n\nclass ORJSONResponse(JSONResponse):\n \"\"\"\n JSON response using the high-performance orjson library to serialize data to JSON.\n\n Read more about it in the\n [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).\n \"\"\"\n\n def render(self, content: Any) -> bytes:\n assert orjson is not None, \"orjson must be installed to use ORJSONResponse\"\n return orjson.dumps(\n content, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_SERIALIZE_NUMPY\n )\n", "stderr": "", "exit_code": 0} |
| 4 | run_command | {
"command": "grep -n \"from warnings import warn\" fastapi/responses.py || grep -n \"import warnings\" fastapi/responses.py\n"
} | {"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}} |
| 5 | run_command | {
"command": "python3 -c \"import warnings; print(warnings.__file__)\"\n"
} | {"status": "ok", "stdout": "/Users/jp/.local/share/uv/python/cpython-3.13.15-macos-aarch64-none/lib/python3.13/warnings.py\n", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "/Users/jp/.local/share/uv/python/cpython-3.13.15-macos-aarch64-none/lib/python3.13/warnings.py\n", "stderr": "", "exit_code": 0} |
| 6 | run_command | {
"command": "cd /workspace && python3 - <<'PY'\nfrom pathlib import Path\np = Path(\"fastapi/responses.py\")\ns = p.read_text()\n\n# Add warnings import at the top\nif \"import warnings\" not in s:\n # Find a good place to put it, e.g., after other imports. \n # Let's check the top of the file.\n lines = s.splitlines()\n import_found = False\n for i, line in enumerate(lines):\n if line.startswith(\"from\") or line.startswith(\"import\"):\n import_found = True\n # We can just prepend it to the first import or add it after\n break\n \n # Let's just put it at the top for simplicity, or better, find where JSONResponse is imported\n # Wait, JSONResponse is defined in the same file.\n # Let's just add it at the top.\n s = \"import warnings\\n\" + s\n\n# Deprecate UJSONResponse\nold_ujson = \"\"\"class UJSONResponse(JSONResponse):\"\"\"\nnew_ujson = \"\"\"\nclass UJSONResponse(JSONResponse):\n def __init__(self, *args, **kwargs):\n warnings.warn(\n \"UJSONResponse is deprecated. Use JSONResponse instead, as it is now performant enough for most use cases.\",\n DeprecationWarning,\n stacklevel=2,\n )\n super().__init__(*args, **kwargs)\"\"\"\n\n# This is not quite right because I should use a decorator or put it in __init__.\n# Let's use warnings.warn in __init__.\n\n# Let's refine the replacement.\n# I need to be careful about the indentation and existing code.\n\n# Actually, a better way to deprecate a class is to warn in __init__.\n# But let's see if there is a better way.\n# In many libraries, they use a decorator or just warn in __init__.\n\n# Let's try this for UJSONResponse:\nujson_replacement = \"\"\"class UJSONResponse(JSONResponse):\n \\\"\\\"\\\"\n JSON response using the high-performance ujson library to serialize data to JSON.\n\n Read more about it in the\n [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).\n \\\"\\\"\\\"\n\n def __init__(self, *args, **kwargs):\n warnings.warn(\n \"UJSONResponse is deprecated. Use JSONResponse instead, as it is now performant enough for most use cases.\",\n DeprecationWarning,\n stacklevel=2,\n )\n super().__init__(*args, **kwargs)\n\n def render(self, content: Any) -> bytes:\n assert ujson is not None, \\\"ujson must be installed to use UJSONResponse\\\"\n return ujson.dumps(content, ensure_ascii=False).encode(\\\"utf-8\\\")\"\"\"\n\n# And for ORJSONResponse:\norjson_replacement = \"\"\"class ORJSONResponse(JSONResponse):\n \\\"\\\"\\\"\n JSON response using the high-performance orjson library to serialize data to JSON.\n\n Read more about it in the\n [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).\n \\\"\\\"\\\"\n\n def __init__(self, *args, **kwargs):\n warnings.warn(\n \"ORJSONResponse is deprecated. Use JSONResponse instead, as it is now performant enough for most use cases.\",\n DeprecationWarning,\n stacklevel=2,\n )\n super().__init__(*args, **kwargs)\n\n def render(self, content: Any) -> bytes:\n assert orjson is not None, \\\"orjson must be installed to use ORJSONResponse\\\"\n return orjson.dumps(\n content, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_SERIALIZE_NUMPY\n )\"\"\"\n\n# Now let's perform the replacements.\n# We must be careful with exact matches.\n# Let's find the blocks to replace.\n\n# The original code:\n# class UJSONResponse(JSONResponse):\n# \"\"\"...\"\"\"\n# def render(self, content: Any) -> bytes:\n# ...\n\n# Let's use a more robust replacement.\n# I will replace from 'class UJSONResponse' to the end of its render method.\n# And similarly for ORJSONResponse.\n\n# Let's read the file | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 7 | run_command | {
"command": "sed -n '1,45p' fastapi/responses.py\n"
} | {"status": "ok", "stdout": "from typing import Any\n\nfrom starlette.responses import FileResponse as FileResponse # noqa\nfrom starlette.responses import HTMLRfull{"status": "ok", "stdout": "from typing import Any\n\nfrom starlette.responses import FileResponse as FileResponse # noqa\nfrom starlette.responses import HTMLResponse as HTMLResponse # noqa\nfrom starlette.responses import JSONResponse as JSONResponse # noqa\nfrom starlette.responses import PlainTextResponse as PlainTextResponse # noqa\nfrom starlette.responses import RedirectResponse as RedirectResponse # noqa\nfrom starlette.responses import Response as Response # noqa\nfrom starlette.responses import StreamingResponse as StreamingResponse # noqa\n\ntry:\n import ujson\nexcept ImportError: # pragma: nocover\n ujson = None # type: ignore\n\n\ntry:\n import orjson\nexcept ImportError: # pragma: nocover\n orjson = None # type: ignore\n\n\nclass UJSONResponse(JSONResponse):\n \"\"\"\n JSON response using the high-performance ujson library to serialize data to JSON.\n\n Read more about it in the\n [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).\n \"\"\"\n\n def render(self, content: Any) -> bytes:\n assert ujson is not None, \"ujson must be installed to use UJSONResponse\"\n return ujson.dumps(content, ensure_ascii=False).encode(\"utf-8\")\n\n\nclass ORJSONResponse(JSONResponse):\n \"\"\"\n JSON response using the high-performance orjson library to serialize data to JSON.\n\n Read more about it in the\n [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).\n \"\"\"\n\n def render(self, content: Any) -> bytes:\n assert orjson is not None, \"orjson must be installed to use ORJSONResponse\"\n", "stderr": "", "exit_code": 0} |
| 8 | run_command | {
"command": "cd /workspace && python3 - <<'PY'\nfrom pathlib import Path\np = Path(\"fastapi/responses.py\")\ns = p.read_text()\n\n# Add import warnings\n# It should be with other imports. Let's put it after starlette imports.\nimport_section = \"from starlette.responses import StreamingResponse as StreamingResponse # noqa\"\ns = s.replace(import_section, import_section + \"\\nimport warnings\")\n\n# Deprecate UJSONResponse\nold_ujson = \"\"\"class UJSONResponse(JSONResponse):\n \\\"\\\"\\\"\n JSON response using the high-performance ujson library to serialize data to JSON.\n\n Read more about it in the\n [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).\n \\\"\\\"\\\"\n\n def render(self, content: Any) -> bytes:\n assert ujson is not None, \\\"ujson must be installed to use UJSONResponse\\\"\n return ujson.dumps(content, ensure_ascii=False).encode(\\\"utf-8\\\")\"\"\"\n\nnew_ujson = \"\"\"class UJSONResponse(JSONResponse):\n \\\"\\\"\\\"\n JSON response using the high-performance ujson library to serialize data to JSON.\n\n Read more about it in the\n [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).\n \\\"\\\"\\\"\n\n def __init__(self, *args, **kwargs):\n warnings.warn(\n \"UJSONResponse is deprecated. Use JSONResponse instead, as it is now performant enough for most use cases.\",\n DeprecationWarning,\n stacklevel=2,\n )\n super().__init__(*args, **kwargs)\n\n def render(self, content: Any) -> bytes:\n assert ujson is not None, \\\"ujson must be installed to use UJSONResponse\\\"\n return ujson.dumps(content, ensure_ascii=False).encode(\\\"utf-8\\\")\"\"\"\n\n# Deprecate ORJSONResponse\nold_orjson = \"\"\"class ORJSONResponse(JSONResponse):\n \\\"\\\"\\\"\n JSON response using the high-performance orjson library to serialize data to JSON.\n\n Read more about it in the\n [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).\n \\\"\\\"\\\"\n\n def render(self, content: Any) -> bytes:\n assert orjson is not None, \\\"orjson must be installed to use ORJSONResponse\\\"\n return orjson.dumps(\n content, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_SERIALIZE_NUMPY\n )\"\"\"\n\nnew_orjson = \"\"\"class ORJSONResponse(JSONResponse):\n \\\"\\\"\\\"\n JSON response using the high-performance orjson library to serialize data to JSON.\n\n Read more about it in the\n [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).\n \\\"\\\"\\\"\n\n def __init__(self, *args, **kwargs):\n warnings.warn(\n \"ORJSONResponse is deprecated. Use JSONResponse instead, as it is now performant enough for most use cases.\",\n DeprecationWarning,\n stacklevel=2,\n )\n super().__init__(*args, **kwargs)\n\n def render(self, content: Any) -> bytes:\n assert orjson is not None, \\\"orjson must be installed to use ORJSONResponse\\\"\n return orjson.dumps(\n content, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_SERIALIZE_NUMPY\n )\"\"\"\n\ns = s.replace(old_ujson, new_ujson)\ns = s.replace(old_orjson, new_orjson)\n\np.write_text(s)\nPY\n"
} | {"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}full{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0} |
| 9 | run_command | {
"command": "sed -n '1,60p' fastapi/responses.py\n"
} | {"status": "ok", "stdout": "from typing import Any\n\nfrom starlette.responses import FileResponse as FileResponse # noqa\nfrom starlette.responses import HTMLRfull{"status": "ok", "stdout": "from typing import Any\n\nfrom starlette.responses import FileResponse as FileResponse # noqa\nfrom starlette.responses import HTMLResponse as HTMLResponse # noqa\nfrom starlette.responses import JSONResponse as JSONResponse # noqa\nfrom starlette.responses import PlainTextResponse as PlainTextResponse # noqa\nfrom starlette.responses import RedirectResponse as RedirectResponse # noqa\nfrom starlette.responses import Response as Response # noqa\nfrom starlette.responses import StreamingResponse as StreamingResponse # noqa\nimport warnings\n\ntry:\n import ujson\nexcept ImportError: # pragma: nocover\n ujson = None # type: ignore\n\n\ntry:\n import orjson\nexcept ImportError: # pragma: nocover\n orjson = None # type: ignore\n\n\nclass UJSONResponse(JSONResponse):\n \"\"\"\n JSON response using the high-performance ujson library to serialize data to JSON.\n\n Read more about it in the\n [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).\n \"\"\"\n\n def __init__(self, *args, **kwargs):\n warnings.warn(\n \"UJSONResponse is deprecated. Use JSONResponse instead, as it is now performant enough for most use cases.\",\n DeprecationWarning,\n stacklevel=2,\n )\n super().__init__(*args, **kwargs)\n\n def render(self, content: Any) -> bytes:\n assert ujson is not None, \"ujson must be installed to use UJSONResponse\"\n return ujson.dumps(content, ensure_ascii=False).encode(\"utf-8\")\n\n\nclass ORJSONResponse(JSONResponse):\n \"\"\"\n JSON response using the high-performance orjson library to serialize data to JSON.\n\n Read more about it in the\n [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).\n \"\"\"\n\n def __init__(self, *args, **kwargs):\n warnings.warn(\n |
| 10 | run_command | {
"command": "sed -n '60,75p' fastapi/responses.py\n"
} | {"status": "ok", "stdout": "\n def render(self, content: Any) -> bytes:\n assert orjson is not None, \"orjson must be installed to use ORJSONResponse\"\n returnfull{"status": "ok", "stdout": "\n def render(self, content: Any) -> bytes:\n assert orjson is not None, \"orjson must be installed to use ORJSONResponse\"\n return orjson.dumps(\n content, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_SERIALIZE_NUMPY\n )\n", "stderr": "", "exit_code": 0} |
| 11 | run_command | {
"command": "cd /workspace && python3 - <<'PY'\nimport warnings\nfrom fastapi.responses import UJSONResponse, ORJSONResponse\n\n# This should trigger a warning.\nwith warnings.catch_warnings(record=True) as w:\n warnings.simplefilter(\"always\")\n UJSONResponse({\"foo\": \"bar\"})\n for warning in w:\n print(f\"UJSONResponse warning: {warning.message}\")\n\nwith warnings.catch_warnings(record=True) as w:\n warnings.simplefilter(\"always\")\n ORJSONResponse({\"foo\": \"bar\"})\n for warning in w:\n print(f\"ORJSONResponse warning: {warning.message}\")\nPY\n"
} | {"status": "ok", "stdout": "UJSONResponse warning: UJSONResponse is deprecated. Use JSONResponse instead, as it is now performant enough for most use cases.\nORfull{"status": "ok", "stdout": "UJSONResponse warning: UJSONResponse is deprecated. Use JSONResponse instead, as it is now performant enough for most use cases.\nORJSONResponse warning: ORJSONResponse is deprecated. Use JSONResponse instead, as it is now performant enough for most use cases.\n", "stderr": "", "exit_code": 0} |
| 12 | run_command | {
"command": "git status\n"
} | {"status": "ok", "stdout": "On branch main\nChanges not staged for commit:\n (use \"git add <file>...\" to update what will be committed)\n (use \"git restore <full{"status": "ok", "stdout": "On branch main\nChanges not staged for commit:\n (use \"git add <file>...\" to update what will be committed)\n (use \"git restore <file>...\" to discard changes in working directory)\n\tmodified: fastapi/responses.py\n\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n", "stderr": "", "exit_code": 0} |
| 13 | run_command | {
"command": "git diff\n"
} | {"status": "ok", "stdout": "diff --git a/fastapi/responses.py b/fastapi/responses.py\nindex 6c8db6f3..f1ef0050 100644\n--- a/fastapi/responses.py\n+++ b/fastapifull{"status": "ok", "stdout": "diff --git a/fastapi/responses.py b/fastapi/responses.py\nindex 6c8db6f3..f1ef0050 100644\n--- a/fastapi/responses.py\n+++ b/fastapi/responses.py\n@@ -7,6 +7,7 @@ from starlette.responses import PlainTextResponse as PlainTextResponse # noqa\n from starlette.responses import RedirectResponse as RedirectResponse # noqa\n from starlette.responses import Response as Response # noqa\n from starlette.responses import StreamingResponse as StreamingResponse # noqa\n+import warnings\n \n try:\n import ujson\n@@ -28,6 +29,14 @@ class UJSONResponse(JSONResponse):\n [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).\n \"\"\"\n \n+ def __init__(self, *args, **kwargs):\n+ warnings.warn(\n+ \"UJSONResponse is deprecated. Use JSONResponse instead, as it is now performant enough for most use cases.\",\n+ DeprecationWarning,\n+ stacklevel=2,\n+ )\n+ super().__init__(*args, **kwargs)\n+\n def render(self, content: Any) -> bytes:\n assert ujson is not None, \"ujson must be installed to use UJSONResponse\"\n return ujson.dumps(content, ensure_ascii=False).encode(\"utf-8\")\n@@ -41,6 +50,14 @@ class ORJSONResponse(JSONResponse):\n [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).\n \"\"\"\n \n+ def __init__(self, *args, **kwargs):\n+ warnings.warn(\n+ \"ORJSONResponse is deprecated. Use JSONResponse instead, as it is now performant enough for most use cases.\",\n+ DeprecationWarning,\n+ stacklevel=2,\n+ )\n+ super().__init__(*args, **kwargs)\n+\n def render(self, content: Any) -> bytes:\n assert orjson is not None, \"orjson must be installed to use ORJSONResponse\"\n return orjson.dumps(\n", "stderr": "", "exit_code": 0} |
| 14 | submit_patch | {} | {"status": "ok", "patch_size": 1855, "files_changed": 1}full{"status": "ok", "patch_size": 1855, "files_changed": 1} |
diff --git a/fastapi/responses.py b/fastapi/responses.py
index 6c8db6f3..f1ef0050 100644
--- a/fastapi/responses.py
+++ b/fastapi/responses.py
@@ -7,6 +7,7 @@ from starlette.responses import PlainTextResponse as PlainTextResponse # noqa
from starlette.responses import RedirectResponse as RedirectResponse # noqa
from starlette.responses import Response as Response # noqa
from starlette.responses import StreamingResponse as StreamingResponse # noqa
+import warnings
try:
import ujson
@@ -28,6 +29,14 @@ class UJSONResponse(JSONResponse):
[FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).
"""
+ def __init__(self, *args, **kwargs):
+ warnings.warn(
+ "UJSONResponse is deprecated. Use JSONResponse instead, as it is now performant enough for most use cases.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ super().__init__(*args, **kwargs)
+
def render(self, content: Any) -> bytes:
assert ujson is not None, "ujson must be installed to use UJSONResponse"
return ujson.dumps(content, ensure_ascii=False).encode("utf-8")
@@ -41,6 +50,14 @@ class ORJSONResponse(JSONResponse):
[FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).
"""
+ def __init__(self, *args, **kwargs):
+ warnings.warn(
+ "ORJSONResponse is deprecated. Use JSONResponse instead, as it is now performant enough for most use cases.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ super().__init__(*args, **kwargs)
+
def render(self, content: Any) -> bytes:
assert orjson is not None, "orjson must be installed to use ORJSONResponse"
return orjson.dumps(
.F
=================================== FAILURES ===================================
________________ test_orjson_response_emits_deprecation_warning ________________
def test_orjson_response_emits_deprecation_warning():
> with pytest.warns(FastAPIDeprecationWarning, match="ORJSONResponse is deprecated"):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E Failed: DID NOT WARN. No warnings of type (<class 'fastapi.exceptions.FastAPIDeprecationWarning'>,) were emitted.
E Emitted warnings: [ DeprecationWarning('ORJSONResponse is deprecated. Use JSONResponse instead, as it is now performant enough for most use cases.')].
tests/test_deprecated_responses.py:42: Failed
=============================== warnings summary ===============================
../../../../../../../Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/overlays/starlette-0.52.1-py3-none-any/starlette/testclient.py:45
/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/overlays/starlette-0.52.1-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_deprecated_responses.py::test_orjson_response_returns_correct_data
/private/tmp/swe_work/pod_r5_v1i/fastapi_14964/b/workspace/fastapi/routing.py:475: DeprecationWarning: ORJSONResponse is deprecated. Use JSONResponse instead, as it is now performant enough for most use cases.
response = actual_response_class(content, **response_args)
tests/test_deprecated_responses.py::test_orjson_response_emits_deprecation_warning
/private/tmp/swe_work/pod_r5_v1i/fastapi_14964/b/workspace/tests/test_deprecated_responses.py:43: DeprecationWarning: ORJSONResponse is deprecated. Use JSONResponse instead, as it is now performant enough for most use cases.
ORJSONResponse(content={"hello": "world"})
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 failed, 1 passed, 3 warnings in 0.83s