Skip to content
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(parser): only infer type hints when necessary #4183

Merged
merged 1 commit into from
Apr 23, 2024

Conversation

raymondbutcher
Copy link
Contributor

@raymondbutcher raymondbutcher commented Apr 23, 2024

Issue number: #4184

Summary

Changes

Please provide a summary of what's being changed

This changes the event_parser decorator to only infer type hints when necessary.

It was breaking in codebases that conditionally import type hints using the typing.TYPE_CHECKING constant as described in PEP 563.

When the model is provided, there is no need to infer anything.

User experience

Please share what the user experience looks like before and after this change

N/A

Checklist

If your change doesn't seem to apply, please leave them unchecked.

Is this a breaking change? No.

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

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.

This was breaking in codebases that conditionally import type hints using the `typing.TYPE_CHECKING` constant as described in [PEP 563](https://peps.python.org/pep-0563/#runtime-annotation-resolution-and-type-checking).

When the model is provided, there is no need to infer anything.

Signed-off-by: Raymond Butcher <[email protected]>
@raymondbutcher raymondbutcher requested a review from a team as a code owner April 23, 2024 12:38
Copy link

boring-cyborg bot commented Apr 23, 2024

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 23, 2024
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@leandrodamascena leandrodamascena changed the title fix(parser): only infer type hints when necessary refactor(parser): only infer type hints when necessary Apr 23, 2024
@github-actions github-actions bot added enhancement bug Something isn't working labels Apr 23, 2024
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.16%. Comparing base (e14e768) to head (933c1eb).
Report is 335 commits behind head on develop.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4183      +/-   ##
===========================================
- Coverage    96.38%   96.16%   -0.22%     
===========================================
  Files          214      218       +4     
  Lines        10030    10461     +431     
  Branches      1846     1936      +90     
===========================================
+ Hits          9667    10060     +393     
- Misses         259      283      +24     
- Partials       104      118      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@leandrodamascena leandrodamascena linked an issue Apr 23, 2024 that may be closed by this pull request
2 tasks
@github-actions github-actions bot removed the bug Something isn't working label Apr 23, 2024
@leandrodamascena
Copy link
Contributor

Thanks for this PR @raymondbutcher! A small improvement that avoids unnecessary code execution in an environment where every millisecond counts. Good catch!

@leandrodamascena leandrodamascena merged commit fe26d1c into aws-powertools:develop Apr 23, 2024
20 checks passed
Copy link

boring-cyborg bot commented Apr 23, 2024

Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience!

@raymondbutcher
Copy link
Contributor Author

raymondbutcher commented Apr 23, 2024

That was quick, thanks @leandrodamascena!

@raymondbutcher raymondbutcher deleted the patch-1 branch April 23, 2024 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tech debt: Only infer type hints when necessary in parser_event decorator
3 participants