Skip to content

Static typing: Argument missing for parameter "context" when using @tracer.capture_lambda_handler(capture_response=False) #6188

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
tiagohconte opened this issue Feb 28, 2025 · 4 comments · Fixed by #6197
Assignees
Labels
typing Static typing definition related issues (mypy, pyright, etc.)

Comments

@tiagohconte
Copy link
Contributor

Static type checker used

pyright/pylance

AWS Lambda function runtime

3.11

Powertools for AWS Lambda (Python) version

3.6.0

Static type checker info

Argument missing for parameter "context"

The issue only happens when there is any parameter set in capture_lambda_handler.

Code snippet

@logger.inject_lambda_context(log_event=True)
@tracer.capture_lambda_handler(capture_response=False)
def handle(event, context: LambdaContext) -> dict:
    return app.resolve(event, context)

Possible Solution

May be related to #4088 and #4795

@tiagohconte tiagohconte added triage Pending triage from maintainers typing Static typing definition related issues (mypy, pyright, etc.) labels Feb 28, 2025
Copy link

boring-cyborg bot commented Feb 28, 2025

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

@leandrodamascena
Copy link
Contributor

Oi @tiagohconte, tudo bem?!

We are missing the return type annotation in the capture_lambda_handler decorator, that's why pyright is complaining and mypy will complain too. Although we don't fully support strict typing in Powertools, I see we might fix this. Do you want to submit a PR to fix it? I think annotating the return type with a Callable with Event and Context should solve the problem.

Obrigado!

@leandrodamascena leandrodamascena moved this from Triage to Pending customer in Powertools for AWS Lambda (Python) Mar 1, 2025
@leandrodamascena leandrodamascena removed the triage Pending triage from maintainers label Mar 1, 2025
@tiagohconte
Copy link
Contributor Author

Oi @leandrodamascena, tudo bem e contigo?

Thanks for the quick response! Just opened a PR to solve the issue 😃

Copy link
Contributor

github-actions bot commented Mar 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.

@leandrodamascena leandrodamascena moved this from Coming soon to Shipped in Powertools for AWS Lambda (Python) Mar 7, 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
2 participants