-
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
refactor(event_source): fix type hint #4165
refactor(event_source): fix type hint #4165
Conversation
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. |
Fixes #3568. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## develop #4165 +/- ##
===========================================
- Coverage 96.38% 96.16% -0.22%
===========================================
Files 214 218 +4
Lines 10030 10459 +429
Branches 1846 1934 +88
===========================================
+ Hits 9667 10058 +391
- Misses 259 283 +24
- Partials 104 118 +14 ☔ View full report in Codecov by Sentry. |
Hello @robmoss2k! Thanks for submitting this PR and putting effort to solve this problem. Can you export the libs that are installed in your virtual environment and how you are running the tests? I'm still having problems here with strict check in mypy. My tests applying this fix: requirements.txt
main.pyfrom typing import Any
from aws_lambda_powertools.utilities.data_classes import SQSEvent, event_source
from aws_lambda_powertools.utilities.typing import LambdaContext
@event_source(data_class=SQSEvent)
def handler(event: SQSEvent, _context: LambdaContext) -> dict[str, Any]:
return {} running mypy(.venv) ➜ leo mypy -V
mypy 1.8.0 (compiled: yes)
(.venv) ➜ leo mypy --strict main.py
main.py:5: error: Untyped decorator makes function "handler" untyped [misc]
Found 1 error in 1 file (checked 1 source file) Thanks and please let me know if I'm missing something. |
Quality Gate passedIssues Measures |
It seems this change is breaking a lot of things on our CI |
It's not finished. I need a solid block of time to spend on it. Don't approve it before it's finished. I will get back to it. Feels like I've bitten off more than I can chew... But I don't like to lose. |
No worries, it's a hard task, as not everything can be made into strict typing -- for the decorator factory, the new |
Hello @robmoss2k! Thank you for putting in the effort here and helping us make the project more strict/strongly typed, which is a big challenge, we really appreciate your effort. But we are closing this PR as not planned for now. We are about to release Powertools v3 and we will not prioritize that at the moment as we will put v2 in maintenance mode soon. Another thing is that refactoring method signatures and introducing changes to such important utilities can create some unexpected side effects, which we don't want at this point. For Powertools v4, we plan to refactor the modules and make the project more strict typed. Again, thanks for your time here and feel free to reopen if you want. |
Issue number: #3568
Summary
Changes
Add the
Any
return type to the event_source function definition. Thehandler
argument already specifies that it will returnAny
andevent_source
returns whateverhandler
returns.User experience
mypy --strict
won't throwerror: Untyped decorator makes function "handler" untyped [misc]
any longer.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.