-
Notifications
You must be signed in to change notification settings - Fork 401
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
Tracer.capture_method decorator does not preserve function type hints #465
Comments
Hey @zlalvani thanks a lot for raising this. While we've had numerous MyPy issues fixed we don't yet have full support for it -- Roadmap item that you can help us +1 to prioritize: aws-powertools/powertools-lambda#3 I'm unsure how to fix this atm as I had thought I've been meaning to refactor I'd appreciate if you have any guidance on how we can satisfy MyPy in a backwards compatible way - happy to provide any guidance if you'd like to try contributing it. Thank you! |
Updating here to let you know the fix will be available in the next release. Update: Spoke too soon. While this works it breaks when using decorator parameters - Potential solution is to use an overload like Pydantic does: pydantic/pydantic#2052 |
Just merged the fix for synchronous functions - Async however requires the new ParamSpec only available in 3.10, so I'll wait for more customers using mypy + async fn as it'll increase the package size by 240K. This will be available in next week's release (1.18.0) -- I'll ping back here once it's released. Thank you again for flagging it @zlalvani |
Hi @zlalvani - This is now fixed in 1.18.0 More details in the release notes: https://github.com/awslabs/aws-lambda-powertools-python/releases/tag/v1.18.0 |
Awesome thanks for the fix! @heitorlessa |
What were you trying to accomplish?
I want to use the
@tracer.capture_method
decorator for detailed function level tracing however it's currently unusable because it disables all errors when linting withmypy
.Expected Behavior
See code example below
Current Behavior
Function signatures (argument and return types) are not preserved when decorated with
@tracer.capture_method
and linting withmypy
.Possible Solution
Mypy can be forced to look at the decorated function signature: https://mypy.readthedocs.io/en/stable/generics.html#declaring-decorators
Steps to Reproduce (for bugs)
mypy==0.782
)Environment
aws-lambda-powertools==1.10.2
The text was updated successfully, but these errors were encountered: