Skip to content

Bug: SQSEnvelope return type not compatible with parse #6348

Open
@Mavtti

Description

@Mavtti

Expected Behaviour

No mypy error when using from aws_lambda_powertools.utilities.parser import parse function with SQSEnveloppe.
Since SQS payload returns a list of events, the return type could be a list of my model.

Current Behaviour

Mypy returns an error since there's no overload for the function from aws_lambda_powertools.utilities.parser import parse where the return type is List[T].
I've to use type: ignore

Code snippet

my_events: list[MyClass] = parse(
            events, model=MyClass, envelope=envelopes.SqsEnvelope  # type: ignore
        )

Possible Solution

Add overload with return type List[T] for function parse

Steps to Reproduce

Use parse function with a pydantic model and SQSEnveloppe.
Run mypy

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.9

Packaging format used

PyPi

Debugging logs

Thanks for the repo, it's great !

Metadata

Metadata

Labels

bugSomething isn't workingtypingStatic typing definition related issues (mypy, pyright, etc.)

Type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions