mypy-boto3-braket type stubs
mypy-boto3-braket provides static type checking and autocompletion for the AWS Braket service within the `boto3` library. It enhances developer experience by offering precise type hints for clients, paginators, waiters, and data transfer objects (TypeDefs). The current version, 1.42.85, is synchronized with its corresponding `boto3` version and is part of the actively maintained `mypy-boto3-builder` ecosystem, which follows a frequent release cadence.
Warnings
- breaking Support for Python 3.8 was officially removed starting with `mypy-boto3-builder` version 8.12.0. If you are using an older Python version, you will encounter compatibility issues.
- breaking Generated TypeDef names were changed in `mypy-boto3-builder` version 8.9.0. Specifically, argument TypeDefs like `CreateDistributionRequestRequestTypeDef` were shortened to `CreateDistributionRequestTypeDef`, and conflicting `Extra` postfixes were moved (e.g., `CreateDistributionExtraRequestTypeDef` became `CreateDistributionRequestExtraTypeDef`).
- gotcha This library provides *only* type annotations for the `boto3` AWS SDK. `boto3` itself is a separate runtime dependency and must be installed alongside `mypy-boto3-braket` for your code to function at runtime. Without `boto3` installed, type checking will still work, but runtime execution will fail.
- gotcha The `mypy-boto3-*` packages are standalone service stubs. For a more integrated experience or to install stubs for multiple services, consider using `boto3-stubs` with service extras (e.g., `pip install 'boto3-stubs[braket]'`). The `mypy-boto3` package is considered legacy and users are encouraged to use `types-boto3` or specific service stubs.
Install
-
pip install mypy-boto3-braket boto3 -
pip install 'boto3-stubs[braket]' boto3
Imports
- BraketClient
from mypy_boto3_braket.client import BraketClient
- CreateQuantumTaskRequestRequestTypeDef
from mypy_boto3_braket.type_defs import CreateQuantumTaskRequestRequestTypeDef
- Session
from boto3.session import Session
Quickstart
import boto3
from mypy_boto3_braket.client import BraketClient
def get_braket_client() -> BraketClient:
# boto3.client('braket') returns a botocore.client.Braket object at runtime.
# mypy-boto3-braket provides the type hint to make it a BraketClient for static analysis.
client: BraketClient = boto3.client('braket')
return client
if __name__ == '__main__':
# Example usage: list quantum tasks (replace with actual region/credentials if running)
braket_client = get_braket_client()
try:
response = braket_client.list_quantum_tasks(
maxResults=5,
# Additional filtering parameters can be added here
)
print(f"Successfully retrieved {len(response['quantumTasks'])} quantum tasks.")
for task in response.get('quantumTasks', []):
print(f" Task ARN: {task['quantumTaskArn']}, Status: {task['status']}")
except Exception as e:
print(f"Error listing quantum tasks: {e}")