-
Notifications
You must be signed in to change notification settings - Fork 403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: APIGatewayRestResolver(enable_validation=True)
incompatible with from __future__ import annotations
#5098
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
Looking at this now. |
Hey @jmahlik! I can confirm that we have something weird here when we try to use TypeAdapter to convert the model. I know that Pydantic has some limitations when working with
I totally agree that you shouldn't ship boto stubs to production, they are more suitable for development environments. In the meantime, you can use quotes ( Thanks. |
@jmahlik Thanks, we're pausing new additions for a couple of weeks whilst we work on v3, once this is released we'll get back to working on features and bugs :D |
I've been struggling for a long time to find this out... The sample code below is from the doc, and it does not work with I use Ruff as a linter/formatter, and Ruff wants me to add
|
Just a quick update: I’ll be focusing on this issue this week and will provide some updates soon. |
I encountered this issue yesterday, and it was very difficult for me to identify the root cause. Would it be possible for |
Expected Behaviour
Using the data validation feature of the
event resolvers
doesn't appear compatible withfrom __future__ import annotations
. There's undefined refs when trying to rebuild the model in the TypeAdapter.It would be ideal to import annotations so type defs are ignored at runtime. Additionally, when using boto stubs they really shouldn't be shipped at runtime since they can be pretty large.
Current Behaviour
See details for stack trace.
Code snippet
Possible Solution
The closest thing I could find was this fastapi issue fastapi/fastapi#10007. I've tried
Input = ForwardRef("Input")
from the pydantic docs but that doesn't appear to resolve the issue.One workaround is to stringify the annotations not required at runtime i.e.
This isn't ideal but it does work.
Steps to Reproduce
Run the file.
Environment:
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.12
Packaging format used
PyPi
Debugging logs
No response
The text was updated successfully, but these errors were encountered: