Closed
Description
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)