Type annotations for boto3 AppRunner
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
- breaking Python 3.8 support was removed starting with `mypy-boto3-builder` version 8.12.0. Users on Python 3.8 or older will need to upgrade their Python version to use recent `mypy-boto3` packages.
- breaking The `mypy-boto3-builder` version 8.9.0 introduced breaking changes to generated TypeDef names. Specifically, arguments for methods may use shorter names, and 'Extra' postfixes were moved to the end of conflicting TypeDef names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`). If you were directly referencing generated TypeDef names, these might have changed.
- gotcha While `boto3-stubs` (the umbrella project) offers implicit type annotations, explicit type annotations for `boto3.client` and `boto3.session.client` calls are often recommended for the best experience with IDEs (like VSCode, PyCharm) and strict `mypy` configurations.
- gotcha This package provides *type annotations* for `boto3`'s AppRunner client. It does not include `boto3` itself. You must install `boto3` separately for your code to run at runtime.
- gotcha When using `if TYPE_CHECKING:` to conditionally import type hints, `pylint` may incorrectly report 'undefined variable' warnings. This can be mitigated by assigning `object` to the type aliases in the `else` branch.
Install
-
pip install boto3 mypy mypy-boto3-apprunner
Imports
- AppRunnerClient
from mypy_boto3_apprunner.client import AppRunnerClient
- ServiceSummaryTypeDef
from mypy_boto3_apprunner.type_defs import ServiceSummaryTypeDef
Quickstart
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}")