Skip to content

Examples#

Index > Batch > Examples

Auto-generated documentation for Batch type annotations stubs module types-aiobotocore-batch.

Client#

Implicit type annotations#

Can be used with types-aiobotocore[batch] package installed.

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

# BatchClient usage example

from aiobotocore.session import get_session


session = get_session()

async with session.create_client("batch") as client:  # (1)
    result = await client.create_compute_environment()  # (2)
  1. client: BatchClient
  2. result: CreateComputeEnvironmentResponseTypeDef
# DescribeComputeEnvironmentsPaginator usage example

from aiobotocore.session import get_session


session = get_session()

async with session.create_client("batch") as client:  # (1)
    paginator = client.get_paginator("describe_compute_environments")  # (2)
    async for item in paginator.paginate(...):
        print(item)  # (3)
  1. client: BatchClient
  2. paginator: DescribeComputeEnvironmentsPaginator
  3. item: DescribeComputeEnvironmentsResponseTypeDef

Explicit type annotations#

With types-aiobotocore-lite[batch] or a standalone types_aiobotocore_batch package, you have to explicitly specify client: BatchClient 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.

# BatchClient usage example with type annotations

from aiobotocore.session import get_session

from types_aiobotocore_batch.client import BatchClient
from types_aiobotocore_batch.type_defs import CreateComputeEnvironmentResponseTypeDef
from types_aiobotocore_batch.type_defs import CreateComputeEnvironmentRequestRequestTypeDef


session = get_session()

async with session.create_client("batch") as client:
    client: BatchClient
    kwargs: CreateComputeEnvironmentRequestRequestTypeDef = {...}
    result: CreateComputeEnvironmentResponseTypeDef = await client.create_compute_environment(**kwargs)
# DescribeComputeEnvironmentsPaginator usage example with type annotations

from aiobotocore.session import get_session

from types_aiobotocore_batch.client import BatchClient
from types_aiobotocore_batch.paginator import DescribeComputeEnvironmentsPaginator
from types_aiobotocore_batch.type_defs import DescribeComputeEnvironmentsResponseTypeDef


session = get_session()

async with session.create_client("batch") as client:
    client: BatchClient
    paginator: DescribeComputeEnvironmentsPaginator = client.get_paginator("describe_compute_environments")
    async for item in paginator.paginate(...):
        item: DescribeComputeEnvironmentsResponseTypeDef
        print(item)