mypy-boto3-mq

1.42.3 · active · verified Sat Apr 11

mypy-boto3-mq provides type annotations for the AWS Boto3 MQ service client, enabling static type checking with tools like mypy, Pyright, and enhanced IDE autocompletion for `boto3.client('mq')`. It is a standalone stub package generated by the `mypy-boto3-builder` tool. The version (1.42.3) aligns with the corresponding `boto3` version, ensuring compatibility, and it is actively maintained with updates mirroring new `boto3` releases.

Warnings

Install

Imports

Quickstart

Demonstrates how to initialize an MQ client with type hints and call a basic operation like `list_brokers()`. Ensure `boto3` is installed and AWS credentials are configured in your environment.

import boto3
from mypy_boto3_mq import MQClient
from mypy_boto3_mq.type_defs import ListBrokersResponseTypeDef
import os

# Ensure AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)
# For example, by setting AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION
# os.environ['AWS_REGION'] = os.environ.get('AWS_REGION', 'us-east-1')

def list_mq_brokers() -> None:
    client: MQClient = boto3.client("mq")
    
    try:
        # Example: List Amazon MQ brokers
        response: ListBrokersResponseTypeDef = client.list_brokers()
        brokers = response.get('BrokerSummaries', [])
        
        if brokers:
            print("Amazon MQ Brokers found:")
            for broker in brokers:
                print(f"  - Name: {broker.get('BrokerName')}, ARN: {broker.get('BrokerArn')}")
        else:
            print("No Amazon MQ brokers found.")

    except client.exceptions.ClientError as e:
        print(f"Error listing brokers: {e}")

if __name__ == "__main__":
    list_mq_brokers()

view raw JSON →