Examples#
Auto-generated documentation for AppSync type annotations stubs module mypy-boto3-appsync.
Client#
Implicit type annotations#
Can be used with boto3-stubs[appsync]
package installed.
Write your AppSync
code as usual,
type checking and code completion should work out of the box.
Client method usage example#
# AppSyncClient usage example
from boto3.session import Session
session = Session()
client = session.client("appsync") # (1)
result = client.associate_api() # (2)
- client: AppSyncClient
- result: AssociateApiResponseTypeDef
Paginator usage example#
# ListApiKeysPaginator usage example
from boto3.session import Session
session = Session()
client = session.client("appsync") # (1)
paginator = client.get_paginator("list_api_keys") # (2)
for item in paginator.paginate(...):
print(item) # (3)
- client: AppSyncClient
- paginator: ListApiKeysPaginator
- item: ListApiKeysResponseTypeDef
Explicit type annotations#
With boto3-stubs-lite[appsync]
or a standalone mypy_boto3_appsync
package, you have to explicitly specify client: AppSyncClient
type annotation.
All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.
Client method usage example#
# AppSyncClient usage example with type annotations
from boto3.session import Session
from mypy_boto3_appsync.client import AppSyncClient
from mypy_boto3_appsync.type_defs import AssociateApiResponseTypeDef
from mypy_boto3_appsync.type_defs import AssociateApiRequestTypeDef
session = Session()
client: AppSyncClient = session.client("appsync")
kwargs: AssociateApiRequestTypeDef = {...}
result: AssociateApiResponseTypeDef = client.associate_api(**kwargs)
Paginator usage example#
# ListApiKeysPaginator usage example with type annotations
from boto3.session import Session
from mypy_boto3_appsync.client import AppSyncClient
from mypy_boto3_appsync.paginator import ListApiKeysPaginator
from mypy_boto3_appsync.type_defs import ListApiKeysResponseTypeDef
session = Session()
client: AppSyncClient = session.client("appsync")
paginator: ListApiKeysPaginator = client.get_paginator("list_api_keys")
for item in paginator.paginate(...):
item: ListApiKeysResponseTypeDef
print(item)