powertools-lambda-python icon indicating copy to clipboard operation
powertools-lambda-python copied to clipboard

Static typing: @metrics.log_metrics decorator

Open ChrisHills463 opened this issue 1 year ago • 3 comments

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.

ChrisHills463 avatar Apr 08 '24 12:04 ChrisHills463

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

boring-cyborg[bot] avatar Apr 08 '24 12:04 boring-cyborg[bot]

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

rubenfonseca avatar Apr 08 '24 12:04 rubenfonseca

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

leandrodamascena avatar Apr 08 '24 12:04 leandrodamascena