Type Annotations for aiobotocore Lambda
types-aiobotocore-lambda provides machine-generated type annotations (stubs) for the aiobotocore Lambda service, enabling static type checking and improved IDE autocompletion for asynchronous AWS SDK usage in Python. It is part of the mypy-boto3-builder project, currently at version 3.4.0, with regular updates following upstream aiobotocore and botocore releases.
Warnings
- breaking Python 3.8 is no longer supported. Packages generated by mypy-boto3-builder 8.12.0 and later require Python 3.9 or higher.
- breaking Breaking changes in generated TypeDef naming conventions were introduced. Type definitions like `CreateDistributionRequestRequestTypeDef` might have been shortened to `CreateDistributionRequestTypeDef`.
- deprecated The `sms-voice` service was deprecated in favor of `pinpoint-sms-voice`. While this specific package is for Lambda, users transitioning from broader `types-aiobotocore` installations might encounter this if they used `sms-voice` types.
- gotcha PyCharm users may experience slow performance due to Literal overloads. The `types-aiobotocore-lite` package is recommended as an alternative for better IDE responsiveness.
Install
-
pip install types-aiobotocore-lambda -
pip install 'types-aiobotocore[lambda]'
Imports
- LambdaClient
from types_aiobotocore_lambda.client import LambdaClient
- LambdaServiceResource
from types_aiobotocore_lambda.service_resource import LambdaServiceResource
- Exceptions
from types_aiobotocore_lambda.client import Exceptions
Quickstart
import asyncio
from aiobotocore.session import get_session
from types_aiobotocore_lambda.client import LambdaClient
async def list_lambda_functions():
session = get_session()
# Ensure AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set in environment
# or ~/.aws/credentials for this to run.
async with session.create_client("lambda") as client:
client: LambdaClient # Explicit type hint for static analysis
response = await client.list_functions()
for func in response.get("Functions", []):
print(f"Function Name: {func['FunctionName']}, Runtime: {func['Runtime']}")
if __name__ == "__main__":
asyncio.run(list_lambda_functions())