{"id":3034,"library":"mypy-boto3-bedrock-agentcore","title":"Type annotations for AWS BedrockAgentCore (boto3)","description":"mypy-boto3-bedrock-agentcore provides type annotations for the boto3 BedrockAgentCore service, enhancing developer experience with static analysis tools like Mypy, Pyright, and IDEs such as VSCode and PyCharm. It's automatically generated by `mypy-boto3-builder` (currently v8.12.0) and typically releases new versions in sync with `boto3` updates, ensuring up-to-date type information for AWS SDK for Python users. This is an active project with frequent updates.","status":"active","version":"1.42.87","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["boto3","aws","bedrock-agentcore","mypy","type-hints","stubs","static-analysis"],"install":[{"cmd":"pip install boto3 mypy-boto3-bedrock-agentcore","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Runtime dependency for which this package provides type stubs.","package":"boto3","optional":false},{"reason":"Primary static type checker for which these stubs are designed. Other type checkers like Pyright are also supported.","package":"mypy","optional":true},{"reason":"May be required for full type compatibility on Python versions older than 3.9.","package":"typing-extensions","optional":true}],"imports":[{"note":"This imports the runtime client without type annotations. The stub package provides the explicit `BedrockAgentCoreClient` type.","wrong":"from boto3.client import BedrockAgentCore","symbol":"BedrockAgentCoreClient","correct":"from mypy_boto3_bedrock_agentcore import BedrockAgentCoreClient"},{"note":"Imports specific TypedDicts for request/response bodies, paginators, and other service-specific structures for precise type checking.","symbol":"ListAgentsResponseTypeDef","correct":"from mypy_boto3_bedrock_agentcore.type_defs import ListAgentsResponseTypeDef"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING, List\nimport os\n\n# These imports are only for type checking, not for runtime execution\nif TYPE_CHECKING:\n    from mypy_boto3_bedrock_agentcore import BedrockAgentCoreClient\n    from mypy_boto3_bedrock_agentcore.type_defs import AgentSummaryTypeDef, ListAgentsResponseTypeDef\n\ndef get_bedrock_agent_core_client() -> \"BedrockAgentCoreClient\":\n    \"\"\"\n    Returns a type-hinted BedrockAgentCore client.\n    \"\"\"\n    # boto3.client returns a botocore.client.BedrockAgentCore instance,\n    # which mypy-boto3 stubs enhance with static type information.\n    # Ensure AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_REGION are set as environment variables\n    client: BedrockAgentCoreClient = boto3.client(\n        \"bedrock-agent-core\",\n        region_name=os.environ.get('AWS_REGION', 'us-east-1') # Default region if not set\n    )\n    return client\n\ndef list_bedrock_agents():\n    \"\"\"\n    Lists Bedrock Agents with type hints.\n    \"\"\"\n    client = get_bedrock_agent_core_client()\n    print(\"Listing Bedrock Agents...\")\n    try:\n        # The response is type-checked against ListAgentsResponseTypeDef\n        response: ListAgentsResponseTypeDef = client.list_agents()\n        agents: List[AgentSummaryTypeDef] = response.get(\"agentSummaries\", [])\n\n        if agents:\n            for agent in agents:\n                print(f\"  Agent Name: {agent.get('agentName')}, Status: {agent.get('agentStatus')}\")\n        else:\n            print(\"  No Bedrock Agents found in the configured region.\")\n    except Exception as e:\n        print(f\"Error listing agents: {e}\")\n\nif __name__ == \"__main__\":\n    # Example of setting environment variables (replace with your actual credentials/region)\n    # os.environ['AWS_ACCESS_KEY_ID'] = 'YOUR_ACCESS_KEY'\n    # os.environ['AWS_SECRET_ACCESS_KEY'] = 'YOUR_SECRET_KEY'\n    # os.environ['AWS_REGION'] = 'us-east-1'\n    \n    # This will attempt to use credentials from environment variables, ~/.aws/credentials, or IAM role.\n    list_bedrock_agents()","lang":"python","description":"This quickstart demonstrates how to instantiate a type-hinted BedrockAgentCore client using `boto3` and perform a basic `list_agents` operation. It includes explicit type annotations for the client and response, which static analysis tools will leverage for improved code completion and error checking. The `TYPE_CHECKING` block prevents the type stub package from being a runtime dependency."},"warnings":[{"fix":"Upgrade your project's Python interpreter to version 3.9 or newer.","message":"Python 3.8 support has been removed in `mypy-boto3-builder` version 8.12.0, which generates these type stubs. Projects using `mypy-boto3-bedrock-agentcore` will no longer be type-checked or compatible with Python 3.8 environments.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.12.0 (and generated packages like mypy-boto3-bedrock-agentcore 1.42.87+)"},{"fix":"Update TypeDef names in your code to reflect the new, shorter naming conventions. Refer to the specific service's `type_defs` module for the correct names.","message":"Type definition (TypeDef) names for packed method arguments were shortened in `mypy-boto3-builder` version 8.9.0. This change might break existing type hints if you were explicitly importing and using these TypeDefs (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`).","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.9.0 (and generated packages)"},{"fix":"Explicitly declare the client type, e.g., `client: BedrockAgentCoreClient = boto3.client('bedrock-agent-core')`.","message":"For full auto-completion and type checking benefits, especially in IDEs like VSCode or PyCharm, it is highly recommended to explicitly annotate the return type of `boto3.client()` calls with the specific `mypy-boto3` client class.","severity":"gotcha","affected_versions":"All versions"},{"fix":"In the `else` block of `if TYPE_CHECKING:`, set the aliased types to `object` to satisfy Pylint. For example: `if TYPE_CHECKING: from mypy_boto3_ec2 import EC2Client else: EC2Client = object`.","message":"When using `if TYPE_CHECKING:` guards to avoid runtime dependency on `mypy-boto3` packages, Pylint might incorrectly report undefined variables. The `mypy-boto3` documentation provides a workaround.","severity":"gotcha","affected_versions":"All versions when using `TYPE_CHECKING` guards."}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}