Type Annotations for Boto3 B2BI

1.42.3 · active · verified Sat Apr 11

mypy-boto3-b2bi provides comprehensive type annotations for the AWS B2BI service client in `boto3`. It's part of the `mypy-boto3` collection, which generates type stubs for all `boto3` services, enhancing developer experience with static analysis and auto-completion. The current version is 1.42.3, and new versions are released frequently, typically mirroring `boto3` updates and `mypy-boto3-builder` releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate a B2BI client from `boto3` and apply the `mypy-boto3-b2bi` type annotations. It performs a simple `list_partnerships` operation, showcasing how static analysis can infer types for client methods and response structures.

import boto3
from mypy_boto3_b2bi import B2BIClient
from typing import Dict, Any

# The actual client comes from boto3. The B2BIClient type from mypy_boto3_b2bi
# is used to provide type hints for static analysis.

try:
    # Assuming AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)
    client: B2BIClient = boto3.client("b2bi")

    # Example operation: List Partnerships
    # mypy will now validate the parameters and the structure of the response.
    response = client.list_partnerships(
        MaxResults=5 # Optional: limit the number of results
    )

    partnerships = response.get('partnerships', [])
    print(f"Found {len(partnerships)} B2BI partnerships.")
    for partnership in partnerships:
        print(f" - Partnership ID: {partnership.get('partnershipId')}, Name: {partnership.get('name')}")

except Exception as e:
    print(f"An error occurred: {e}")
    print("Ensure 'boto3' and 'mypy-boto3-b2bi' are installed and AWS credentials are configured.")

view raw JSON →