mypy-boto3-imagebuilder type stubs
mypy-boto3-imagebuilder provides type annotations for the boto3 AWS Imagebuilder service, enabling static type checking with tools like mypy. It's part of the `mypy-boto3` family of packages, generated by `mypy-boto3-builder`. The package version (1.42.88) aligns with the boto3 version it provides stubs for, and new releases are published regularly to match boto3 updates and builder improvements.
Warnings
- breaking Support for Python 3.8 has been removed. All `mypy-boto3` packages, including `mypy-boto3-imagebuilder`, now require Python 3.9 or newer.
- breaking Packages have migrated to PEP 561, which changes how `mypy` and other type checkers discover stub files. While generally backwards compatible, specific `mypy` configurations or custom stub paths might need adjustment.
- breaking Specific `TypeDef` names for method arguments and conflicting definitions were shortened or renamed, potentially breaking code that explicitly referenced these type definitions.
- gotcha `mypy-boto3-imagebuilder` provides type stubs only. It is not a standalone library and requires `boto3` and `botocore` to be installed for runtime functionality.
- gotcha For optimal type-checking accuracy, the version of `mypy-boto3-imagebuilder` should ideally match the major and minor version of your installed `boto3` library.
Install
-
pip install mypy-boto3-imagebuilder boto3 botocore
Imports
- ImagebuilderClient
from mypy_boto3_imagebuilder.client import ImagebuilderClient
- ImageStateTypeDef
from mypy_boto3_imagebuilder.type_defs import ImageStateTypeDef
Quickstart
import boto3
from mypy_boto3_imagebuilder.client import ImagebuilderClient
from mypy_boto3_imagebuilder.type_defs import ImageSummaryTypeDef
# Instantiate a typed client
client: ImagebuilderClient = boto3.client("imagebuilder")
# Use the client with type-checking benefits
try:
response = client.list_images(filters=[
{
'name': 'name',
'values': ['example-image-name']
}
])
print(f"Found {len(response.get('imageSummaryList', []))} images.")
# Example of accessing a typed item
if response.get('imageSummaryList'):
first_image: ImageSummaryTypeDef = response['imageSummaryList'][0]
print(f"First image ARN: {first_image['arn']}")
except client.exceptions.ClientError as e:
print(f"An AWS error occurred: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")