Type Annotations for Boto3 Bedrock Agent Core Control
This library provides PEP 561-compliant type annotations for the `boto3` Bedrock Agent Core Control service, enabling static type checking with tools like `mypy`. It helps developers catch type-related errors early and improves IDE autocompletion for `boto3`. The current version is 1.42.87, and it is updated frequently to align with new `boto3` releases.
Warnings
- breaking Python 3.8 support has been removed from `mypy-boto3-builder` versions 8.12.0 and later, which affects generated stub packages. Users on Python 3.8 will encounter issues.
- breaking Migration to PEP 561 package structure (`mypy-boto3-builder 8.12.0+`) might require updates to custom `mypy` configurations that rely on older module resolution paths. This primarily affects advanced `mypy` setups.
- breaking TypeDef naming conventions were changed in `mypy-boto3-builder 8.9.0` to resolve conflicts and shorten names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`). If you directly import specific `TypeDef` names, they might have changed.
- gotcha This library provides *only* type annotations for `boto3`. You must explicitly install `boto3` (e.g., `pip install boto3`) for your code to run at runtime.
- gotcha AWS service APIs (and thus `boto3`'s implementation) are constantly updated. To ensure your type hints are accurate and reflect the latest API, you should periodically update `mypy-boto3-bedrock-agentcore-control`.
- gotcha When initializing the client, ensure the service name passed to `boto3.client()` exactly matches the service for which the stubs are provided. The correct name is 'bedrock-agent-core-control'.
Install
-
pip install boto3 mypy-boto3-bedrock-agentcore-control
Imports
- BedrockAgentCoreControlClient
from mypy_boto3_bedrock_agent_core_control.client import BedrockAgentCoreControlClient
- ListAgentsResponseTypeDef
from mypy_boto3_bedrock_agent_core_control.type_defs import ListAgentsResponseTypeDef
Quickstart
import boto3
from mypy_boto3_bedrock_agent_core_control.client import BedrockAgentCoreControlClient
from mypy_boto3_bedrock_agent_core_control.type_defs import ListAgentsRequestRequestTypeDef, ListAgentsResponseTypeDef
from typing import TYPE_CHECKING, cast
# Ensure boto3 is configured, e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION_NAME env vars
# This example does not use actual credentials, but they would be needed for a real call.
# Use TYPE_CHECKING for type hints that are not needed at runtime
if TYPE_CHECKING:
# Cast the boto3 client to the specific type stub for better type checking
client: BedrockAgentCoreControlClient = cast(BedrockAgentCoreControlClient, boto3.client("bedrock-agent-core-control"))
else:
client = boto3.client("bedrock-agent-core-control")
# Example of using a typed request and response
try:
request: ListAgentsRequestRequestTypeDef = {
"maxResults": 10
}
response: ListAgentsResponseTypeDef = client.list_agents(**request)
print(f"Successfully listed agents. Total agents found: {len(response.get('agentSummaries', []))}")
for agent in response.get('agentSummaries', []):
print(f" - Agent ID: {agent['agentId']}, Status: {agent['agentStatus']}")
except Exception as e:
print(f"Error listing agents: {e}")
print("Ensure your AWS credentials and region are configured correctly and Bedrock Agent Core Control is available.")