-
Notifications
You must be signed in to change notification settings - Fork 410
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
refactor(metrics): Improve type annotations for metrics decorator #6000
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #6000 +/- ##
========================================
Coverage 96.24% 96.24%
========================================
Files 234 234
Lines 11016 11016
Branches 798 798
========================================
Hits 10602 10602
Misses 327 327
Partials 87 87 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved 👏
|
…s-powertools#6000) Fix type annotation with metrics decorator
Issue number: #4088
Summary
Changes
Description
This PR improves type annotations for the metrics decorator
@metrics.log_metrics
. While we strive to enhance type safety, it's important to note that supporting strict typing is a best-effort approach and not guaranteed in Powertools.This new annotation type supports dependency injection scenario as well. We cannot anticipate all possible return types for a Lambda function, so the best approach is to define
Callable[..., Any]
as the expected return for this decorator.User experience
This will improve pyright/mypy errors report.
Checklist
If your change doesn't seem to apply, please leave them unchecked.
Is this a breaking change?
RFC issue number:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.