Closed
Description
What were you trying to accomplish?
I'm trying to use aws_lambda_powertools.utilities.data_classes.event_source
with mypy --strict
, and receive errors about Untyped decorator makes function "handler" untyped
. This is because lambda_handler_decorator
is missing a return value, so mypy doesn't know anything about any function decorated with it (including event_source
):
Expected Behavior
@event_source
and other decorators using @lambda_handler_decorator
should work in mypy strict mode.
Current Behavior
Mypy emits errors.
Possible Solution
- Add an appropriate
Callable[something, here]
return value tolambda_handler_decorator
- Run
mypy --strict
in this package's CI
Steps to Reproduce (for bugs)
requirements:
aws-lambda-powertools==1.25.1
aws-xray-sdk==2.9.0
boto3==1.21.13
botocore==1.24.13
fastjsonschema==2.15.3
future==0.18.2
jmespath==0.10.0
mypy-extensions==0.4.3
mypy==0.931
python-dateutil==2.8.2
s3transfer==0.5.2
six==1.16.0
tomli==2.0.1
typing-extensions==4.1.1
urllib3==1.26.8
wrapt==1.13.3
input.py
:
from typing import Any
from aws_lambda_powertools.middleware_factory import lambda_handler_decorator
from aws_lambda_powertools.utilities.data_classes import (
event_source,
KinesisStreamEvent,
)
@lambda_handler_decorator
def custom_decorator() -> None:
return
@event_source(data_class=KinesisStreamEvent)
@custom_decorator
def handler(event: KinesisStreamEvent, context: Any) -> None:
pass
invocation:
$ mypy --strict input.py
input.py:16: error: Untyped decorator makes function "handler" untyped
input.py:17: error: Untyped decorator makes function "handler" untyped
Environment
- Powertools version used: 1.25.1
- Packaging format (Layers, PyPi): N/A
- AWS Lambda function runtime: N/A
- Debugging logs N/A