Skip to content

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

@Tom01098

Description

@Tom01098
Contributor

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

  • This feature request meets Powertools for AWS Lambda (Python) Tenets
    Should this be considered in other Powertools for AWS Lambda languages? i.e. Java, TypeScript, and .NET

Activity

boring-cyborg

boring-cyborg commented on Oct 5, 2023

@boring-cyborg

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

heitorlessa commented on Oct 6, 2023

@heitorlessa
Contributor

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

added
parserParser (Pydantic) utility
and removed
triagePending triage from maintainers
on Oct 6, 2023
moved this from Backlog to Working on it in Powertools for AWS Lambda (Python)on Oct 8, 2023
github-actions

github-actions commented on Oct 12, 2023

@github-actions
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @heitorlessa@leandrodamascena@Tom01098

    Issue actions

      Feature request: Remove duplication of type when parsing event · Issue #3173 · aws-powertools/powertools-lambda-python