mypy-boto3-appsync Type Annotations
mypy-boto3-appsync provides official type annotations for the `boto3` AppSync client, generated by `mypy-boto3-builder`. It enhances development with static type checking for AWS SDK operations related to AppSync, helping catch errors before runtime. The current version is 1.42.6, and releases are frequent, typically in sync with `boto3` updates and `mypy-boto3-builder` enhancements.
Warnings
- breaking Python 3.8 support was removed for all `mypy-boto3` packages. Projects targeting Python 3.8 will need to upgrade to Python 3.9 or newer.
- breaking `mypy-boto3` packages migrated to PEP 561. While this generally improves compatibility, specific `mypy` configurations (e.g., `MYPYPATH` usage) or older `mypy` versions might need adjustment.
- breaking TypeDef names were refactored for brevity and consistency. For example, `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`. Conflicting TypeDef names had their `Extra` postfix moved.
- gotcha This package only provides type hints for `boto3`. You must install `boto3` itself to have the runtime functionality.
- gotcha The `mypy-boto3` ecosystem moved from a monolithic `mypy-boto3` package to granular `boto3-stubs-*` (e.g., `mypy-boto3-appsync`). Legacy `mypy-boto3` is no longer generated with the current builder.
- gotcha AWS service names can change, leading to updated package names for `mypy-boto3` stubs. For example, `sms-voice` was deprecated in favor of `pinpoint-sms-voice`.
Install
-
pip install boto3 mypy-boto3-appsync
Imports
- AppSyncClient
from mypy_boto3_appsync.client import AppSyncClient
- ListGraphqlApisResponseTypeDef
from mypy_boto3_appsync.type_defs import ListGraphqlApisResponseTypeDef
Quickstart
import boto3
from mypy_boto3_appsync.client import AppSyncClient
from mypy_boto3_appsync.type_defs import ListGraphqlApisResponseTypeDef
# Instantiate the boto3 client with type annotation
client: AppSyncClient = boto3.client("appsync")
try:
# Example: List GraphQL APIs (requires appropriate AWS credentials)
response: ListGraphqlApisResponseTypeDef = client.list_graphql_apis()
print("Successfully listed GraphQL APIs:")
for api in response.get("graphqlApis", []):
print(f" - {api.get('name')} (API ID: {api.get('apiId')})")
except client.exceptions.UnauthorizedException as e:
print(f"Authentication error: {e}. Make sure your AWS credentials are configured.")
except Exception as e:
print(f"An error occurred: {e}")