Skip to content

Static typing: @metrics.log_metrics decorator #4088

@ChrisHills463

Description

@ChrisHills463

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.

Activity

added
triagePending triage from maintainers
typingStatic typing definition related issues (mypy, pyright, etc.)
on Apr 8, 2024
boring-cyborg

boring-cyborg commented on Apr 8, 2024

@boring-cyborg

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

changed the title [-]Static typing: TITLE[/-] [+]Static typing: @metrics.log_metrics decorator[/+] on Apr 8, 2024
self-assigned this
on Apr 8, 2024
rubenfonseca

rubenfonseca commented on Apr 8, 2024

@rubenfonseca
Contributor

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

leandrodamascena

leandrodamascena commented on Apr 8, 2024

@leandrodamascena
Contributor

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

16 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

typingStatic typing definition related issues (mypy, pyright, etc.)

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

    Participants

    @rubenfonseca@alanwill@heitorlessa@leandrodamascena@ChrisHills463

    Issue actions

      Static typing: @metrics.log_metrics decorator · Issue #4088 · aws-powertools/powertools-lambda-python