Type Annotations for boto3 EMR Containers
mypy-boto3-emr-containers provides static type annotations (stubs) for the boto3 EMR Containers service, enhancing development with type-checking capabilities. It ensures type safety when using boto3 clients, resources, and collections for EMR Containers, preventing common runtime errors. The library is automatically generated by mypy-boto3-builder and typically releases new versions in sync with boto3 and botocore updates.
Warnings
- breaking Python 3.8 support was removed for all mypy-boto3 packages, including mypy-boto3-emr-containers, starting with mypy-boto3-builder v8.12.0.
- gotcha This package provides *type stubs* for boto3, not boto3 itself. You must install `boto3` separately for your code to run.
- breaking TypeDef naming conventions changed significantly with mypy-boto3-builder v8.9.0. Some TypeDefs for packed method arguments or conflicting names received shorter or reordered postfixes (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`).
Install
-
pip install mypy-boto3-emr-containers boto3 -
pip install mypy-boto3-emr-containers
Imports
- EMRContainersClient
from mypy_boto3_emr_containers import EMRContainersClient
- ListVirtualClustersOutputTypeDef
from mypy_boto3_emr_containers.type_defs import ListVirtualClustersOutputTypeDef
Quickstart
import boto3
from mypy_boto3_emr_containers import EMRContainersClient
from mypy_boto3_emr_containers.type_defs import ListVirtualClustersOutputTypeDef
def get_emr_containers_client() -> EMRContainersClient:
"""Returns a type-hinted EMR Containers client."""
# Ensure boto3 is installed: pip install boto3 mypy-boto3-emr-containers
client: EMRContainersClient = boto3.client("emr-containers")
return client
def list_virtual_clusters() -> None:
"""Lists EMR Containers virtual clusters with type checking."""
client = get_emr_containers_client()
try:
response: ListVirtualClustersOutputTypeDef = client.list_virtual_clusters()
print("Successfully listed virtual clusters:")
for cluster in response.get("virtualClusters", []):
name = cluster.get("name", "N/A")
cluster_id = cluster.get("id", "N/A")
status = cluster.get("status", {}).get("state", "UNKNOWN")
print(f" - Name: {name}, ID: {cluster_id}, Status: {status}")
if not response.get("virtualClusters"):
print(" No virtual clusters found.")
except Exception as e:
print(f"Error listing virtual clusters: {e}")
if __name__ == "__main__":
list_virtual_clusters()