Skip to content

Static typing: @metrics.log_metrics decorator #4088

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

Closed
ChrisHills463 opened this issue Apr 8, 2024 · 7 comments · Fixed by #6000
Closed

Static typing: @metrics.log_metrics decorator #4088

ChrisHills463 opened this issue Apr 8, 2024 · 7 comments · Fixed by #6000
Assignees
Labels
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.

@leandrodamascena leandrodamascena moved this from Backlog to Working on it in Powertools for AWS Lambda (Python) Feb 3, 2025
@leandrodamascena leandrodamascena removed the help wanted Could use a second pair of eyes/hands label Feb 3, 2025
@leandrodamascena leandrodamascena self-assigned this Feb 3, 2025
@leandrodamascena
Copy link
Contributor

Hey everyone! We have a PR #6000 to improve this type annotation. This will probably be release tomorrow in our alpha releases process and I appreciate any type ok feedback.

While we strive to enhance type safety, it's important to note that supporting strict typing is a best-effort approach and not guaranteed in Powertools.

@github-project-automation github-project-automation bot moved this from Working on it to Coming soon in Powertools for AWS Lambda (Python) Feb 3, 2025
Copy link
Contributor

github-actions bot commented Feb 3, 2025

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

@github-actions github-actions bot added the pending-release Fix or implementation already in dev waiting to be released label Feb 3, 2025
Copy link
Contributor

This is now released under 3.6.0 version!

@github-actions github-actions bot removed the pending-release Fix or implementation already in dev waiting to be released label Feb 11, 2025
@leandrodamascena leandrodamascena moved this from Coming soon to Shipped in Powertools for AWS Lambda (Python) Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typing Static typing definition related issues (mypy, pyright, etc.)
Projects
Status: Shipped
5 participants