Skip to content

fix(parser): type hints should reflect primitive types support#8175

Open
catarinacps wants to merge 1 commit intoaws-powertools:developfrom
catarinacps:fix/parser-type-hints-accordingly
Open

fix(parser): type hints should reflect primitive types support#8175
catarinacps wants to merge 1 commit intoaws-powertools:developfrom
catarinacps:fix/parser-type-hints-accordingly

Conversation

@catarinacps
Copy link
Copy Markdown

@catarinacps catarinacps commented Apr 26, 2026

Issue number: closes #8174

Summary

As per #4502, primitive types are supported by the parser utility. However, the type hints utilized in the functions and envelopes there do not reflect that at the moment, making type checkers lack when inferring the return types, for example. This aims to improve this situation by adjusting the type hints there.

Changes

Please provide a summary of what's being changed

This PR thus changes the TypeVar used in the envelope types' functions to T, introduced in #4502. It also sets the BaseEnvelope parser(...) method with envelope overload return type hint to T | list[T | None] | None to allow those subclasses to overload the method correctly.

User experience

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

Before:

image

After the change the type checker will be able to narrow the type to list[EUMMessage], as that is the actual return type that should be shown.


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.

As per aws-powertools#4502, primitive types are supported by the `parser` utility. However, the type hints utilized in the functions and envelopes there do not reflect that at the moment, making type checkers lack when inferring the return types, for example. This aims to improve this situation by adjusting the type hints there.
@catarinacps catarinacps requested a review from a team as a code owner April 26, 2026 20:36
@catarinacps catarinacps requested a review from ConnorKirk April 26, 2026 20:36
@boring-cyborg
Copy link
Copy Markdown

boring-cyborg Bot commented Apr 26, 2026

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

@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 26, 2026
@sonarqubecloud
Copy link
Copy Markdown

@powertools-for-aws-oss-automation
Copy link
Copy Markdown

Not all issues are linked correctly.

Please link each issue to the PR either manually or using a closing keyword in the format fixes #<issue-number> format.

If mentioning more than one issue, separate them with commas: i.e. fixes #<issue-number-1>, closes #<issue-number-2>.

@catarinacps catarinacps changed the title fix: parser type hints should reflect primitive types fix: parser type hints should reflect primitive types support Apr 26, 2026
@catarinacps catarinacps changed the title fix: parser type hints should reflect primitive types support fix(parser): type hints should reflect primitive types support Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Static typing: parser utility type hints should reflect primitive types support

1 participant