Closed
Description
Static type checker used
pyright/pylance
AWS Lambda function runtime
3.12
Powertools for AWS Lambda (Python) version
latest
Static type checker info
Argument of type "(event: SNSEvent, context: Unknown) -> dict[str, Unknown]" cannot be assigned to parameter "lambda_handler" of type "((Dict[Unknown, Unknown], Any) -> Any) | ((Dict[Unknown, Unknown], Any, Dict[Unknown, Unknown] | None) -> Any) | None" in function "capture_lambda_handler"
Type "(event: SNSEvent, context: Unknown) -> dict[str, Unknown]" is incompatible with type "((Dict[Unknown, Unknown], Any) -> Any) | ((Dict[Unknown, Unknown], Any, Dict[Unknown, Unknown] | None) -> Any) | None"
Type "(event: SNSEvent, context: Unknown) -> dict[str, Unknown]" is incompatible with type "(Dict[Unknown, Unknown], Any) -> Any"
Parameter 1: type "Dict[Unknown, Unknown]" is incompatible with type "SNSEvent"
"Dict[Unknown, Unknown]" is incompatible with "SNSEvent"
Type "(event: SNSEvent, context: Unknown) -> dict[str, Unknown]" is incompatible with type "(Dict[Unknown, Unknown], Any, Dict[Unknown, Unknown] | None) -> Any"
Function accepts too many positional parameters; expected 2 but received 3
Parameter 1: type "Dict[Unknown, Unknown]" is incompatible with type "SNSEvent"
"Dict[Unknown, Unknown]" is incompatible with "SNSEvent"
Code snippet
from aws_lambda_powertools import Logger, Tracer
from aws_lambda_powertools.utilities.data_classes import SNSEvent, event_source
tracer = Tracer()
logger = Logger()
@logger.inject_lambda_context
@tracer.capture_lambda_handler
@event_source(data_class=SNSEvent)
def lambda_handler(event: SNSEvent, context: LambdaContext): ...
Possible Solution
When using the tracer.capture_lambda_handler
decorator with event_source
decorator Pylance is complaining about type mismatch. Checking the logger.inject_lambda_context
I think we could use AnyCallableT
.
Does that make sense to create a PR for this? Or is too broad of a type? I will create a small PR anyway.
Metadata
Metadata
Assignees
Type
Projects
Status
Closed