Skip to content

Event Handler: API Gateway current_event doesn't show all properties #761

Closed
@heitorlessa

Description

@heitorlessa

When trying to access request_context when using either API Gateway v1 or v2 we can't have type hinting due to ALB being different - both inherit from BaseProxyEvent.

Overloading the internal method _to_proxy_event with all potential returns, even with Literal[ProxyEventType.APIGatewayProxyEvent] didn't seem to yield any result, as MyPy and Intelisense continues to think it's a BaseProxyEvent.

Need a deeper understanding of MyPy and type invariants to potentially solve this.

from aws_lambda_powertools.event_handler.api_gateway import ApiGatewayResolver

app = ApiGatewayResolver()


@app.get("/test")
def test_it():
	# this should autocomplete when not using ALB as the ProxyType argument in ApiGatewayResolver
	app.current_event.request_context.identity.account_id 
    ...


def handler(event, context):
    app.resolve(event, context)


app({}, None)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions