Type Annotations for boto3 Runtime for Bedrock Data Automation
mypy-boto3-bedrock-data-automation-runtime provides type annotations for the `boto3` AWS SDK, specifically for the `RuntimeforBedrockDataAutomation` service, ensuring type safety and improved IDE auto-completion. It is part of the `mypy-boto3-builder` ecosystem, currently at version 1.42.44, and follows a frequent release cadence, often synchronizing with `boto3` updates to provide up-to-date type information.
Warnings
- breaking Support for Python 3.8 has been removed for all `mypy-boto3-builder` generated packages, including this one, starting with `mypy-boto3-builder` version 8.12.0. The minimum required Python version is now 3.9.
- breaking The `mypy-boto3-builder` migrated to PEP 561 compliant packages in version 8.12.0. While largely internal, this may affect custom build systems or environments that relied on previous packaging structures.
- breaking TypeDef naming conventions can change between major `mypy-boto3-builder` versions. For example, `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`. While this specific change affects the CloudFront service, it's indicative of potential similar changes across other services including Bedrock Data Automation Runtime.
- gotcha This package provides *only* type annotations. It does not include the `boto3` library itself. `boto3` must be installed separately in your project for the code to run at runtime.
- gotcha PyCharm may experience slow performance or high CPU usage when dealing with `Literal` overloads in `mypy-boto3` packages. This is a known issue (PY-40997) within PyCharm.
- gotcha A specific fix for `ToolUseTypeType` literal was applied for the `bedrock-runtime` service in `mypy-boto3-builder` 8.12.0. While this package is for `bedrock-data-automation-runtime`, similar service-specific literal typing issues might appear or have been fixed in past versions, requiring updates.
Install
-
pip install mypy-boto3-bedrock-data-automation-runtime -
pip install 'boto3-stubs[bedrock-data-automation-runtime]'
Imports
- RuntimeforBedrockDataAutomationClient
from mypy_boto3_bedrock_data_automation_runtime.client import RuntimeforBedrockDataAutomationClient
- ListTagsForResourceResponseTypeDef
from mypy_boto3_bedrock_data_automation_runtime.type_defs import ListTagsForResourceResponseTypeDef
Quickstart
import boto3
from mypy_boto3_bedrock_data_automation_runtime.client import RuntimeforBedrockDataAutomationClient
from os import environ
def get_bedrock_data_automation_runtime_client() -> RuntimeforBedrockDataAutomationClient:
"""
Initializes and returns a typed Bedrock Data Automation Runtime client.
"""
# Using environment variables for AWS credentials is a common practice
# and makes the example runnable without hardcoding.
# In a real application, boto3 will automatically look for credentials
# in various locations (e.g., ~/.aws/credentials, IAM roles).
aws_access_key_id = environ.get('AWS_ACCESS_KEY_ID', 'YOUR_ACCESS_KEY')
aws_secret_access_key = environ.get('AWS_SECRET_ACCESS_KEY', 'YOUR_SECRET_KEY')
aws_region = environ.get('AWS_REGION', 'us-east-1')
# The actual boto3 client is untyped; mypy-boto3 provides the type hint.
client: RuntimeforBedrockDataAutomationClient = boto3.client(
"bedrock-data-automation-runtime",
region_name=aws_region,
aws_access_key_id=aws_access_key_id,
aws_secret_access_key=aws_secret_access_key
)
return client
if __name__ == "__main__":
bedrock_data_automation_client = get_bedrock_data_automation_runtime_client()
print(f"Successfully created Bedrock Data Automation Runtime client: {bedrock_data_automation_client}")
# Example of calling a method (requires a valid resourceARN for actual execution)
# This demonstrates type-checked interaction with the client.
# In a real application, consult AWS Bedrock Data Automation Runtime API docs for valid operations.
try:
# Replace with a real resource ARN if you want to run this successfully
response = bedrock_data_automation_client.list_tags_for_resource(resourceARN="arn:aws:bedrock:us-east-1:123456789012:data-automation/example")
print("list_tags_for_resource call successful:")
print(response)
except Exception as e:
print(f"Caught exception during list_tags_for_resource call (expected if ARN is not real): {e}")