failed NO_PATCH NO_PATCH UNSUBMITTED empty_patch(None) · None tool calls · 0 s · fastapi/fastapi
✨ Allow using dependables with `functools.partial()` Discussion: https://github.com/tiangolo/fastapi/discussions/9744 Using `functools.partial()` with dependables feels like a very obvious idiom. `partial()` already works for dependables that are plain function, but it doesn't work consistently, partial of async and callable classes didn't work consistently. This PR makes partial() work consistently in all combinations. test_dependency_class.py have been renamed to test_dependency_types.py to reflect its bigger scope now. There's quite a bit of repetition in the tests, part of me wants to just refactor those; but another part of me also wants to keep the tests simple.
| # | Tool | Arguments | Result |
|---|---|---|---|
| No trace captured. | |||
ent/futures/_base.py:460: in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
/Users/jp/.local/share/uv/python/cpython-3.13.15-macos-aarch64-none/lib/python3.13/concurrent/futures/_base.py:402: in __get_result
raise self._exception
/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/fastapi/lib/python3.13/site-packages/anyio/from_thread.py:265: in _call_func
retval = await retval_or_awaitable
^^^^^^^^^^^^^^^^^^^^^^^^^
fastapi/applications.py:1139: in __call__
await super().__call__(scope, receive, send)
/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/overlays/starlette-0.50.0-py3-none-any/starlette/applications.py:107: in __call__
await self.middleware_stack(scope, receive, send)
/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/overlays/starlette-0.50.0-py3-none-any/starlette/middleware/errors.py:186: in __call__
raise exc
/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/overlays/starlette-0.50.0-py3-none-any/starlette/middleware/errors.py:164: in __call__
await self.app(scope, receive, _send)
/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/overlays/starlette-0.50.0-py3-none-any/starlette/middleware/exceptions.py:63: in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/overlays/starlette-0.50.0-py3-none-any/starlette/_exception_handler.py:53: in wrapped_app
raise exc
/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/overlays/starlette-0.50.0-py3-none-any/starlette/_exception_handler.py:42: in wrapped_app
await app(scope, receive, sender)
fastapi/middleware/asyncexitstack.py:18: in __call__
await self.app(scope, receive, send)
/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/overlays/starlette-0.50.0-py3-none-any/starlette/routing.py:716: in __call__
await self.middleware_stack(scope, receive, send)
/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/overlays/starlette-0.50.0-py3-none-any/starlette/routing.py:736: in app
await route.handle(scope, receive, send)
/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/overlays/starlette-0.50.0-py3-none-any/starlette/routing.py:290: in handle
await self.app(scope, receive, send)
fastapi/routing.py:119: in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/overlays/starlette-0.50.0-py3-none-any/starlette/_exception_handler.py:53: in wrapped_app
raise exc
/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/overlays/starlette-0.50.0-py3-none-any/starlette/_exception_handler.py:42: in wrapped_app
await app(scope, receive, sender)
fastapi/routing.py:105: in app
response = await f(request)
^^^^^^^^^^^^^^^^
fastapi/routing.py:407: in app
content = await serialize_response(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
field = ModelField(field_info=FieldInfo(annotation=str, required=True), name='Response_get_partial_async_function_dependency_partial_async_function_dependency_get', mode='serialization')
response_content = <coroutine object async_function_dependency at 0x1103fabc0>
include = None, exclude = None, by_alias = True, exclude_unset = False
exclude_defaults = False, exclude_none = False, is_coroutine = True
async def serialize_response(
*,
field: Optional[ModelField] = None,
response_content: Any,
include: Optional[IncEx] = None,
exclude: Optional[IncEx] = None,
by_alias: bool = True,
exclude_unset: bool = False,
exclude_defaults: bool = False,
exclude_none: bool = False,
is_coroutine: bool = True,
) -> Any:
if field:
errors = []
if not hasattr(field, "serialize"):
# pydantic v1
response_content = _prepare_response_content(
response_content,
exclude_unset=exclude_unset,
exclude_defaults=exclude_defaults,
exclude_none=exclude_none,
)
if is_coroutine:
value, errors_ = field.validate(response_content, {}, loc=("response",))
else:
value, errors_ = await run_in_threadpool(
field.validate, response_content, {}, loc=("response",)
)
if isinstance(errors_, list):
errors.extend(errors_)
elif errors_:
errors.append(errors_)
if errors:
> raise ResponseValidationError(
errors=_normalize_errors(errors), body=response_content
)
E fastapi.exceptions.ResponseValidationError: 1 validation errors:
E {'type': 'string_type', 'loc': ('response',), 'msg': 'Input should be a valid string', 'input': <coroutine object async_function_dependency at 0x1103fabc0>}
fastapi/routing.py:248: ResponseValidationError
=============================== 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 failed, 1 passed, 1 warning in 0.82s
<sys>:0: RuntimeWarning: coroutine 'async_function_dependency' was never awaited