Skip to content

Feature request: Remove duplication of type when parsing event #3173

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

Closed
1 of 2 tasks
Tom01098 opened this issue Oct 5, 2023 · 3 comments · Fixed by #3181
Closed
1 of 2 tasks

Feature request: Remove duplication of type when parsing event #3173

Tom01098 opened this issue Oct 5, 2023 · 3 comments · Fixed by #3181
Assignees
Labels
feature-request feature request parser Parser (Pydantic) utility

Comments

@Tom01098
Copy link
Contributor

Tom01098 commented Oct 5, 2023

Use case

When using the event_parser decorator to parse the event, the type will be duplicated if using type hints as a best practice.

@event_parser(model=Order)
def handler(event: Order, context: LambdaContext):
    ...

Solution/User Experience

I am proposing that we can drop the model parameter as we can infer it from events type hint.

@event_parser
def handler(event: Order, context: LambdaContext):
    ...

I am very happy to contribute this feature request, it should be very small and is totally backwards-compatible (model will still be accepted and chosen before type hints are inspected).

Alternative solutions

Keep as-is.

Acknowledgment

@Tom01098 Tom01098 added feature-request feature request triage Pending triage from maintainers labels Oct 5, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Oct 5, 2023

Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

@heitorlessa
Copy link
Contributor

heitorlessa commented Oct 6, 2023

Great idea @Tom01098 -- please feel free to send a PR as you suggested 🫶

It's still within our Progressive tenet -- explicit for most of us, and implicit via type hint for the cutting edge.

Feel free to ping on Discord or here if we can help with anything

@heitorlessa heitorlessa added parser Parser (Pydantic) utility and removed triage Pending triage from maintainers labels Oct 6, 2023
@heitorlessa heitorlessa moved this from Triage to Ideas in Powertools for AWS Lambda (Python) Oct 6, 2023
@heitorlessa heitorlessa moved this from Ideas to Backlog in Powertools for AWS Lambda (Python) Oct 6, 2023
@leandrodamascena leandrodamascena linked a pull request Oct 8, 2023 that will close this issue
5 tasks
@leandrodamascena leandrodamascena self-assigned this Oct 8, 2023
@leandrodamascena leandrodamascena moved this from Backlog to Working on it in Powertools for AWS Lambda (Python) Oct 8, 2023
@github-project-automation github-project-automation bot moved this from Working on it to Coming soon in Powertools for AWS Lambda (Python) Oct 12, 2023
@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

@leandrodamascena leandrodamascena moved this from Coming soon to Shipped in Powertools for AWS Lambda (Python) Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request feature request parser Parser (Pydantic) utility
Projects
Status: Shipped
Development

Successfully merging a pull request may close this issue.

3 participants