Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static typing: @metrics.log_metrics decorator #4088

Open
ChrisHills463 opened this issue Apr 8, 2024 · 4 comments
Open

Static typing: @metrics.log_metrics decorator #4088

ChrisHills463 opened this issue Apr 8, 2024 · 4 comments
Labels
help wanted Could use a second pair of eyes/hands typing Static typing definition related issues (mypy, pyright, etc.)

Comments

@ChrisHills463
Copy link

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 ChrisHills463 added triage Pending triage from maintainers typing Static typing definition related issues (mypy, pyright, etc.) labels Apr 8, 2024
Copy link

boring-cyborg bot commented Apr 8, 2024

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

@ChrisHills463 ChrisHills463 changed the title Static typing: TITLE Static typing: @metrics.log_metrics decorator Apr 8, 2024
@rubenfonseca rubenfonseca self-assigned this Apr 8, 2024
@rubenfonseca
Copy link
Contributor

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

@leandrodamascena
Copy link
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

@alanwill
Copy link

@rubenfonseca @leandrodamascena any idea when this should be resolved or if there's a workaround? We've recently moved to using powertools throughout our app with many lambda functions and this keeps being a pesky linter error to stare at daily and not able to action. Any guidance would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Could use a second pair of eyes/hands typing Static typing definition related issues (mypy, pyright, etc.)
Projects
Status: Backlog
Development

No branches or pull requests

5 participants