Skip to content

Examples#

Index > Batch > Examples

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

Client#

Implicit type annotations#

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

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

Client method usage example#

# BatchClient usage example

from boto3.session import Session


session = Session()

client = session.client("batch")  # (1)
result = client.create_compute_environment()  # (2)
  1. client: BatchClient
  2. result: CreateComputeEnvironmentResponseTypeDef

Paginator usage example#

# DescribeComputeEnvironmentsPaginator usage example

from boto3.session import Session


session = Session()
client = session.client("batch")  # (1)

paginator = client.get_paginator("describe_compute_environments")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: BatchClient
  2. paginator: DescribeComputeEnvironmentsPaginator
  3. item: DescribeComputeEnvironmentsResponseTypeDef

Explicit type annotations#

With types-boto3-lite[batch] or a standalone types_boto3_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.

Client method usage example#

# BatchClient usage example with type annotations

from boto3.session import Session

from types_boto3_batch.client import BatchClient
from types_boto3_batch.type_defs import CreateComputeEnvironmentResponseTypeDef
from types_boto3_batch.type_defs import CreateComputeEnvironmentRequestTypeDef


session = Session()

client: BatchClient = session.client("batch")

kwargs: CreateComputeEnvironmentRequestTypeDef = {...}
result: CreateComputeEnvironmentResponseTypeDef = client.create_compute_environment(**kwargs)

Paginator usage example#

# DescribeComputeEnvironmentsPaginator usage example with type annotations

from boto3.session import Session

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


session = Session()
client: BatchClient = session.client("batch")

paginator: DescribeComputeEnvironmentsPaginator = client.get_paginator("describe_compute_environments")
for item in paginator.paginate(...):
    item: DescribeComputeEnvironmentsResponseTypeDef
    print(item)