{"id":3035,"library":"mypy-boto3-bedrock","title":"mypy-boto3-bedrock Type Stubs","description":"mypy-boto3-bedrock provides comprehensive type annotations for the `boto3` Bedrock service. It is part of the `boto3-stubs` ecosystem, automatically generated by `mypy-boto3-builder`, ensuring compatibility with `boto3`'s official releases. This library enhances static analysis with tools like `mypy` and `pyright`, offering improved code completion and helping identify potential bugs in `boto3` Bedrock client usage. The version number of `mypy-boto3-bedrock` is synchronized with the corresponding `boto3` version it provides stubs for.","status":"active","version":"1.42.83","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["AWS","boto3","mypy","type-hints","bedrock","stubs","static-analysis"],"install":[{"cmd":"pip install mypy-boto3-bedrock boto3","lang":"bash","label":"Install standalone stubs and boto3"},{"cmd":"pip install 'boto3-stubs[bedrock]' boto3","lang":"bash","label":"Install via boto3-stubs extras (recommended for multiple services)"}],"dependencies":[{"reason":"This package provides type stubs for boto3's Bedrock client. Boto3 itself must be installed by the user to execute the code that is being type-checked.","package":"boto3","optional":false}],"imports":[{"symbol":"BedrockClient","correct":"from mypy_boto3_bedrock.client import BedrockClient"},{"note":"Example of importing a generated Literal type.","symbol":"AgreementStatusType","correct":"from mypy_boto3_bedrock.literals import AgreementStatusType"},{"note":"Example of importing a generated TypedDict.","symbol":"ModelEnforcementOutputTypeDef","correct":"from mypy_boto3_bedrock.type_defs import ModelEnforcementOutputTypeDef"}],"quickstart":{"code":"import os\nfrom typing import TYPE_CHECKING\n\nimport boto3\nfrom boto3.session import Session\n\n# Conditionally import type stubs only during type checking\n# This avoids a runtime dependency on mypy-boto3-bedrock\nif TYPE_CHECKING:\n    from mypy_boto3_bedrock.client import BedrockClient\n    from mypy_boto3_bedrock.type_defs import ListFoundationModelsResponseTypeDef\n\ndef get_bedrock_client() -> 'BedrockClient':\n    # Ensure AWS credentials are configured (e.g., via environment variables or AWS CLI config)\n    # For this example, we use a default session.\n    # In a real application, consider explicit credential management.\n    session = Session(region_name=os.environ.get('AWS_REGION', 'us-east-1'))\n    client: BedrockClient = session.client('bedrock')\n    return client\n\ndef list_bedrock_foundation_models() -> None:\n    client = get_bedrock_client()\n    print(f\"Client type: {type(client)}\")\n    try:\n        response: ListFoundationModelsResponseTypeDef = client.list_foundation_models()\n        print(\"Successfully listed Bedrock foundation models:\")\n        for model in response['modelSummaries']:\n            print(f\"  - {model['modelId']} ({model['modelName']})\")\n    except Exception as e:\n        print(f\"Error listing models: {e}\")\n\nif __name__ == '__main__':\n    list_bedrock_foundation_models()","lang":"python","description":"This quickstart demonstrates how to set up type checking for the `boto3` Bedrock client using `mypy-boto3-bedrock`. It explicitly type hints the `boto3` client with `BedrockClient` and shows how to use a generated `TypeDef` for a response object, enabling static analysis and IDE autocompletion for Bedrock API calls."},"warnings":[{"fix":"Upgrade your project's Python interpreter to 3.9 or higher.","message":"Starting with `mypy-boto3-builder` version 8.12.0 (which generated `mypy-boto3-bedrock` 1.42.83 and newer), support for Python 3.8 has been removed. Projects using these stubs must target Python 3.9 or newer.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0; mypy-boto3-bedrock >= 1.42.83"},{"fix":"Ensure your `mypy` or `pyright` configuration is up-to-date and correctly set up to use PEP 561 compliant stub packages. Typically, no manual action is needed beyond installing the stubs correctly.","message":"All `mypy-boto3-*` packages, including `mypy-boto3-bedrock`, have migrated to PEP 561 compliant distribution. This changes how type checkers might discover and consume the stubs.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0; mypy-boto3-bedrock >= 1.42.83"},{"fix":"Review your explicit `TypeDef` imports and update them according to the new naming conventions. Consult the specific package's documentation for exact changes if a `TypeDef` name causes issues.","message":"Service-specific `TypeDef` naming conventions changed for clarity in `mypy-boto3-builder` 8.9.0. For example, `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`. This affects direct imports of generated `TypeDef` names.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.9.0; corresponding mypy-boto3-* packages built with it."},{"fix":"For PyCharm, consider installing `boto3-stubs-lite[bedrock]` instead of `boto3-stubs[bedrock]` or `mypy-boto3-bedrock` directly, and explicitly annotate types. Example: `pip install 'boto3-stubs-lite[bedrock]'`.","message":"PyCharm users may experience performance issues with `Literal` overloads when using full `boto3-stubs` packages. The `boto3-stubs-lite` variants are recommended as a workaround for PyCharm until this issue is resolved.","severity":"gotcha","affected_versions":"All versions, specific to PyCharm IDE."},{"fix":"Wrap your stub imports within a `if TYPE_CHECKING:` block to ensure they are only visible to type checkers and ignored by Pylint at runtime. The quickstart example demonstrates this pattern.","message":"Pylint might report 'undefined variable' errors when using type stubs without `TYPE_CHECKING` guards, as it attempts to evaluate imports at runtime.","severity":"gotcha","affected_versions":"All versions, specific to Pylint usage."}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}