mypy-boto3-appstream Type Annotations

1.42.82 · active · verified Sat Apr 11

mypy-boto3-appstream provides comprehensive type annotations for the `boto3` AWS AppStream service, enhancing static analysis with tools like Mypy, Pyright, VSCode, and PyCharm. It is automatically generated by the `mypy-boto3-builder` and aims to keep pace with `boto3` updates, typically releasing new versions in alignment with `boto3`'s release cadence. The current version is 1.42.82.

Warnings

Install

Imports

Quickstart

This example demonstrates how to initialize an AppStream client with type annotations and use a type-hinted `TypeDef` for the response. It queries existing AppStream fleets.

import boto3
from mypy_boto3_appstream import AppStreamClient
from mypy_boto3_appstream.type_defs import DescribeFleetsResultTypeDef

def get_appstream_fleets() -> DescribeFleetsResultTypeDef:
    client: AppStreamClient = boto3.client('appstream')
    response = client.describe_fleets()
    print(f"Found {len(response['Fleets'])} AppStream fleets.")
    return response

if __name__ == '__main__':
    # This quickstart assumes AWS credentials are configured (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION_NAME env vars)
    # or ~/.aws/credentials and ~/.aws/config files.
    # Replace with actual usage or mock for testing if needed.
    # Example of using environment variables for auth (for demonstration, actual auth depends on boto3 setup):
    # import os
    # if not os.environ.get('AWS_ACCESS_KEY_ID'):
    #     os.environ['AWS_ACCESS_KEY_ID'] = 'AKIA...'
    # if not os.environ.get('AWS_SECRET_ACCESS_KEY'):
    #     os.environ['AWS_SECRET_ACCESS_KEY'] = 'secret...'
    # if not os.environ.get('AWS_REGION_NAME'):
    #     os.environ['AWS_REGION_NAME'] = 'us-east-1'

    try:
        fleets_data = get_appstream_fleets()
        # Further processing with type-hinted data, e.g., fleets_data['Fleets'][0]['DisplayName']
    except Exception as e:
        print(f"Error fetching AppStream fleets: {e}")

view raw JSON →