Skip to content

Static typing: Untyped event_source decorator with mypy --strict #3568

Closed as not planned
@JakubSosnovec

Description

@JakubSosnovec

Static type checker used

mypy (project's standard)

AWS Lambda function runtime

3.12

Powertools for AWS Lambda (Python) version

2.30.2

Static type checker info

Just mypy --strict, with mypy version 1.8.0.
Output: error: Untyped decorator makes function "handler" untyped [misc]

Code snippet

$ pip freeze
aws-lambda-powertools==2.30.2
mypy==1.8.0
mypy-extensions==1.0.0
typing_extensions==4.9.0

$ cat main.py  --plain
from typing import Any
from aws_lambda_powertools.utilities.data_classes import SQSEvent, event_source
from aws_lambda_powertools.utilities.typing import LambdaContext
@event_source(data_class=SQSEvent)
def handler(event: SQSEvent, _context: LambdaContext) -> dict[str, Any]:
    return {}

$ mypy --strict main.py
main.py:7: error: Untyped decorator makes function "handler" untyped  [misc]
Found 1 error in 1 file (checked 1 source file)

Possible Solution

Very similar to #1060 which is claimed to be solved, but this issue appears in the latest release, mypy in strict mode still doesnt understand the return type. Maybe it came back?

Metadata

Metadata

Assignees

No one assigned

    Labels

    rejectedtypingStatic typing definition related issues (mypy, pyright, etc.)

    Type

    No type

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions