Skip to content

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

Closed
@tiagohconte

Description

@tiagohconte
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

Activity

added
triagePending triage from maintainers
typingStatic typing definition related issues (mypy, pyright, etc.)
on Feb 28, 2025
boring-cyborg

boring-cyborg commented on Feb 28, 2025

@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

leandrodamascena

leandrodamascena commented on Feb 28, 2025

@leandrodamascena
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!

moved this from Triage to Pending customer in Powertools for AWS Lambda (Python)on Mar 1, 2025
tiagohconte

tiagohconte commented on Mar 1, 2025

@tiagohconte
ContributorAuthor

Oi @leandrodamascena, tudo bem e contigo?

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

moved this from Pending customer to Working on it in Powertools for AWS Lambda (Python)on Mar 3, 2025
github-actions

github-actions commented on Mar 3, 2025

@github-actions
Contributor

⚠️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.

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

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

    Participants

    @leandrodamascena@tiagohconte

    Issue actions

      Static typing: Argument missing for parameter "context" when using `@tracer.capture_lambda_handler(capture_response=False)` · Issue #6188 · aws-powertools/powertools-lambda-python