Type annotations for boto3 AppRunner

1.42.3 · active · verified Sat Apr 11

mypy-boto3-apprunner provides type annotations for the AWS AppRunner service client, compatible with boto3 version 1.42.3. It is generated by the `mypy-boto3-builder` and is part of a larger ecosystem providing comprehensive type hints for `boto3`, `botocore`, `aiobotocore`, and `aioboto3`. The project is actively maintained with regular updates to reflect changes in `boto3` and Python typing standards.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `mypy-boto3-apprunner` to provide type hints for the AppRunner client. It fetches a list of AppRunner services, leveraging the `AppRunnerClient` type for autocompletion and static analysis. The `TYPE_CHECKING` guard ensures the type-only imports don't introduce runtime dependencies.

import boto3
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from mypy_boto3_apprunner.client import AppRunnerClient
    from mypy_boto3_apprunner.type_defs import ServiceSummaryTypeDef


def get_apprunner_services() -> list['ServiceSummaryTypeDef']:
    client: AppRunnerClient = boto3.client("apprunner")
    response = client.list_services(
        MaxResults=5, 
        NextToken=None # Use actual token for pagination in real apps
    )
    return response.get("ServiceSummaryList", [])


if __name__ == "__main__":
    # This code block will run at runtime, but only if boto3 is configured.
    # For type checking, mypy will use the stubs.
    # Ensure AWS credentials are set up (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION_NAME env vars)
    # or ~/.aws/credentials and ~/.aws/config
    try:
        services = get_apprunner_services()
        print(f"Found {len(services)} AppRunner services:")
        for service in services:
            print(f"  - {service['ServiceName']} (Status: {service['Status']})")
    except Exception as e:
        print(f"Error fetching AppRunner services: {e}")

view raw JSON →