-
Notifications
You must be signed in to change notification settings - Fork 365
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
Static typing: Untyped event_source decorator with mypy --strict #3568
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
Hi @JakubSosnovec! Thanks for bringing this question! Strict typing has been on our radar for a long time and we are correcting what is possible every time we release a new version, but this project is not 100% compatible with strict typing and we are investigating how to include it in our roadmap, but we do not have an ETA for that. I'll add this issue to our backlog and see if we can do something specifically for this case. @heitorlessa would love to hear your thoughts here. BTW, I'm trying here with mypy 1.4+ and Powertoos 1.25.7 and I get the same error. It seems like something is still unresolved. ❯ pip freeze
aws-lambda-powertools==1.25.7
aws-xray-sdk==2.12.1
boto3==1.34.10
botocore==1.34.10
fastjsonschema==2.19.1
jmespath==0.10.0
mypy==1.4.1
mypy-extensions==1.0.0
python-dateutil==2.8.2
s3transfer==0.10.0
six==1.16.0
tomli==2.0.1
typing-extensions==4.9.0
urllib3==1.26.18
wrapt==1.16.0 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:4: error: Untyped decorator makes function "handler" untyped [misc]
Found 1 error in 1 file (checked 1 source file) |
The simple fix for this to remove the error for |
@leandrodamascena - PR with fix submitted. Quite possibly the smallest one you'll ever see... |
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
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?
The text was updated successfully, but these errors were encountered: