Skip to content

Examples#

Index > Lambda > Examples

Auto-generated documentation for Lambda type annotations stubs module types-aiobotocore-lambda.

Client#

Implicit type annotations#

Can be used with types-aioboto3[lambda] package installed.

Write your Lambda code as usual, type checking and code completion should work out of the box.

Client method usage example#

# LambdaClient usage example

from aioboto3.session import Session


session = Session()

async with session.client("lambda") as client:  # (1)
    result = await client.add_layer_version_permission()  # (2)
  1. client: LambdaClient
  2. result: AddLayerVersionPermissionResponseTypeDef

Paginator usage example#

# ListAliasesPaginator usage example

from aioboto3.session import Session


session = Session()

async with session.client("lambda") as client:  # (1)
    paginator = client.get_paginator("list_aliases")  # (2)
    async for item in paginator.paginate(...):
        print(item)  # (3)
  1. client: LambdaClient
  2. paginator: ListAliasesPaginator
  3. item: ListAliasesResponseTypeDef

Waiter usage example#

# FunctionActiveV2Waiter usage example

from aioboto3.session import Session


session = Session()

async with session.client("lambda") as client:  # (1)
    waiter = client.get_waiter("function_active_v2")  # (2)
    await waiter.wait(...)
  1. client: LambdaClient
  2. waiter: FunctionActiveV2Waiter

Explicit type annotations#

With types-aioboto3-lite[lambda] or a standalone types_aiobotocore_lambda package, you have to explicitly specify client: LambdaClient type annotation.

All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.

Client method usage example#

# LambdaClient usage example with type annotations

from aioboto3.session import Session

from types_aiobotocore_lambda.client import LambdaClient
from types_aiobotocore_lambda.type_defs import AddLayerVersionPermissionResponseTypeDef
from types_aiobotocore_lambda.type_defs import AddLayerVersionPermissionRequestTypeDef


session = Session()

client: LambdaClient
async with session.client("lambda") as client:  # (1)
    kwargs: AddLayerVersionPermissionRequestTypeDef = {...}  # (2)
    result: AddLayerVersionPermissionResponseTypeDef = await client.add_layer_version_permission(**kwargs)  # (3)
  1. client: LambdaClient
  2. kwargs: AddLayerVersionPermissionRequestTypeDef
  3. result: AddLayerVersionPermissionResponseTypeDef

Paginator usage example#

# ListAliasesPaginator usage example with type annotations

from aioboto3.session import Session

from types_aiobotocore_lambda.client import LambdaClient
from types_aiobotocore_lambda.paginator import ListAliasesPaginator
from types_aiobotocore_lambda.type_defs import ListAliasesResponseTypeDef


session = Session()

client: LambdaClient
async with session.client("lambda") as client:  # (1)
    paginator: ListAliasesPaginator = client.get_paginator("list_aliases")  # (2)
    async for item in paginator.paginate(...):
        item: ListAliasesResponseTypeDef
        print(item)  # (3)
  1. client: LambdaClient
  2. paginator: ListAliasesPaginator
  3. item: ListAliasesResponseTypeDef

Waiter usage example#

# FunctionActiveV2Waiter usage example with type annotations

from aioboto3.session import Session

from types_aiobotocore_lambda.client import LambdaClient
from types_aiobotocore_lambda.waiter import FunctionActiveV2Waiter


session = Session()

async with session.client("lambda") as client:  # (1)
    waiter = client.get_waiter("function_active_v2")  # (2)
    await waiter.wait(...)
  1. client: LambdaClient
  2. waiter: FunctionActiveV2Waiter