mypy-boto3-batch provides comprehensive type annotations for the AWS Boto3 Batch service, generated automatically with mypy-boto3-builder. It enhances development experience by enabling static type checking with tools like MyPy, Pyright, and improving autocompletion in IDEs such as VSCode and PyCharm. The library is actively maintained, with updates released frequently to align with new Boto3 versions and address issues.
Install & Compatibility
Where this runs
tested against v1.43.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.10
9/10 runs
9/10 runs
py 3.11
9/10 runs
9/10 runs
py 3.12
9/10 runs
9/10 runs
py 3.13
9/10 runs
9/10 runs
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
BatchClient
✓ from mypy_boto3_batch.client import BatchClient
For explicit type annotations of the boto3 Batch client.
BatchServiceResource
✓ from mypy_boto3_batch.service_resource import BatchServiceResource
For explicit type annotations of the boto3 Batch service resource (if applicable).
ArrayJobDependencyType
✓ from mypy_boto3_batch.literals import ArrayJobDependencyType
For type-hinting literal values used in Batch API calls.
ArrayPropertiesDetailTypeDef
✓ from mypy_boto3_batch.type_defs import ArrayPropertiesDetailTypeDef
For type-hinting dictionary structures (TypedDicts) used in Batch API calls.
This quickstart demonstrates how to obtain a type-hinted Batch client and perform basic operations like describing job queues and listing jobs using a paginator. The `TYPE_CHECKING` block ensures that `mypy-boto3-batch` is only a development dependency. Remember that `boto3` itself needs to be configured with AWS credentials to make actual API calls.
import boto3
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from mypy_boto3_batch.client import BatchClient
from mypy_boto3_batch.type_defs import DescribeJobQueuesResponseTypeDef
# Example of a Paginator import
from mypy_boto3_batch.paginators import ListJobsPaginator
def get_batch_client() -> 'BatchClient':
"""Returns a type-hinted boto3 Batch client."""
return boto3.client("batch")
def describe_queues() -> 'DescribeJobQueuesResponseTypeDef':
"""Describes Batch job queues with type hints."""
client: BatchClient = get_batch_client()
response = client.describe_job_queues()
print(f"Job Queues: {len(response['jobQueues'])}")
return response
def list_all_jobs():
"""Lists all jobs using a paginator with type hints."""
client: BatchClient = get_batch_client()
paginator: ListJobsPaginator = client.get_paginator('list_jobs')
for page in paginator.paginate(jobQueue='example-queue'): # Replace 'example-queue' with an actual queue
for job in page.get('jobSummaryList', []):
print(f"Job ID: {job['jobId']}, Name: {job['jobName']}")
# Example usage (requires AWS credentials and an existing Batch setup)
if __name__ == '__main__':
# This code will execute if you have AWS credentials configured
# and an AWS Batch environment. For type checking, no actual AWS call is needed.
# To run this, ensure boto3 is configured, e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION
# Or by using 'aws configure'
try:
queues_response = describe_queues()
# You can add more complex logic here
# list_all_jobs() # Uncomment to test paginator, requires a valid jobQueue
except Exception as e:
print(f"Error interacting with AWS Batch (this is expected if AWS credentials/resources are not set up): {e}")
Debug
Known issues
breakingSupport for Python 3.8 has been removed across all `mypy-boto3-*` packages, starting with `mypy-boto3-builder` version 8.12.0.fixUpgrade your Python environment to 3.9 or newer.
affects: mypy-boto3-builder >= 8.12.0, mypy-boto3-batch >= 1.42.76
breakingTypeDef naming conventions were changed, potentially affecting custom code that directly imports and uses generated TypeDefs. For instance, `CreateDistributionRequestRequestTypeDef` might become `CreateDistributionRequestTypeDef`, and `Extra` postfixes are moved to the end.fixReview your code for direct `TypeDef` imports and adjust names according to the updated conventions. Refer to the `mypy-boto3-builder` changelog for specific renaming patterns.
affects: mypy-boto3-builder >= 8.9.0, mypy-boto3-batch >= 1.34.0 (approximate)
gotchaWhen using PyCharm, performance issues with `Literal` overloads have been reported (issue PY-40997). This may lead to slow performance and high CPU usage.fixConsider using `boto3-stubs-lite` (if available for Batch), disabling PyCharm's internal type checker in favor of MyPy or Pyright, or relying on explicit type annotations rather than full overload inference. Install `mypy` or `pyright` and configure PyCharm to use them.
affects: All versions
gotchaFor optimal IDE autocompletion and type checking, especially in VSCode without Pylance, explicit type annotations for `boto3.client()` calls are recommended, even if `boto3-stubs` provides some implicit type discovery.fixAlways add explicit type hints like `client: BatchClient = boto3.client('batch')` to leverage the full power of the stubs. affects: All versions
gotchaTo avoid `mypy-boto3-batch` becoming a production dependency and to prevent `pylint` complaints about undefined variables when the stub package is not installed in production, it is recommended to wrap stub imports within a `if TYPE_CHECKING:` block.fixEnclose all `mypy_boto3_batch` imports within `from typing import TYPE_CHECKING; if TYPE_CHECKING: ...` blocks. For runtime use, fallback to `object` or remove type hints.
affects: All versions
breakingBoto3 itself will no longer support Python 3.9 starting April 29, 2026. It is recommended to upgrade to Python 3.10 or later for continued service updates, bug fixes, and security updates.fixUpgrade your Python environment to 3.10 or newer.
affects: All `mypy-boto3-*` packages when used with Python 3.9
Audit
Dependencies
boto3requiredThis package provides type stubs for the `boto3` library; `boto3` must be installed separately for runtime functionality.