You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Depends() and Request parameters with a None default are not resolved on Python 3.10 #8648
A route or middleware parameter declared as d: Annotated[str, Depends(get_dep)] = None receives the resolved dependency, and request: Request = None receives the Request, on every supported Python version.
Current Behaviour
On Python 3.10 only, both parameters receive None. typing.get_type_hints on 3.10 wraps the annotation of a parameter whose default is None in Optional[...], so Annotated[str, Depends(...)] becomes Union[Annotated[str, Depends(...)], None]. _get_depends_from_annotation only checks get_origin(annotation) is Annotated, and _find_request_param_name only checks annotation is Request, so neither matches and the parameter falls back to its default. Python 3.11 stopped wrapping, which is why 3.11+ work. Present since Depends() shipped in v3.28.0.
Confirmed in real Lambda functions on python3.10 (layer and zip package) and locally with a 3.10 virtualenv.
Unwrap Optional[X] / X | None before inspecting the annotation, in _get_depends_from_annotation, in the Request injection inside solve_dependencies, and in _find_request_param_name. A small helper _unwrap_optional that returns the single non-None arg of a Union covers all three. Tests with = None defaults fail on 3.10 today and pass with the change.
Steps to Reproduce
Run the snippet with Python 3.10 using tests/events/apiGatewayProxyEvent.json as the event.
This issue is now closed. Please be mindful that future comments are hard for our team to see.
If you need more assistance, please either reopen the issue, or open a new issue referencing this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
Activity
powertools-for-aws-oss-automation commentedon Oct 20, 2026
Warning
This issue is now closed. Please be mindful that future comments are hard for our team to see.
If you need more assistance, please either reopen the issue, or open a new issue referencing this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
github-actions commentedon Oct 22, 2026
This is now released under 3.37.0 version!