aws-powertools / powertools-lambda-python

A developer toolkit to implement Serverless best practices and increase developer velocity.
https://docs.powertools.aws.dev/lambda/python/latest/
MIT No Attribution
2.89k stars 397 forks source link

Static typing: @metrics.log_metrics decorator #4088

Open ChrisHills463 opened 7 months ago

ChrisHills463 commented 7 months ago

Static type checker used

pyright/pylance

AWS Lambda function runtime

3.11

Powertools for AWS Lambda (Python) version

latest

Static type checker info

# error: Argument missing for parameter "context" (reportGeneralTypeIssues)

Code snippet

@metrics.log_metrics(capture_cold_start_metric=True)   # error: Argument missing for parameter "context" (reportGeneralTypeIssues)
def lambda_handler(event: dict, context: LambdaContext) -> dict:
    return app.resolve(event, context)

Possible Solution

This is a known issue with pyright (see pyright#3265). See also this Discord discussion.

boring-cyborg[bot] commented 7 months ago

Thanks for opening your first issue here! We'll come back to you as soon as we can. In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

rubenfonseca commented 7 months ago

Confirmed I'm seeing this too. Added to the backlog. Thank you for opening this @ChrisHills463

leandrodamascena commented 7 months ago

I'm not sure if it's related (I haven't checked), but we recently had a small refactoring on some parts of this code:

https://github.com/aws-powertools/powertools-lambda-python/pull/3460/files#diff-49bfc9264b598c920d5bef978e668726dc09f7a8fc27f4aae974849ecab60ee2