Examples#
Index > CognitoIdentity > Examples
Auto-generated documentation for CognitoIdentity type annotations stubs module mypy-boto3-cognito-identity.
Client#
Implicit type annotations#
Can be used with boto3-stubs[cognito-identity]
package installed.
Write your CognitoIdentity
code as usual,
type checking and code completion should work out of the box.
Client method usage example#
# CognitoIdentityClient usage example
from boto3.session import Session
session = Session()
client = session.client("cognito-identity") # (1)
result = client.create_identity_pool() # (2)
- client: CognitoIdentityClient
- result: IdentityPoolTypeDef
Paginator usage example#
# ListIdentityPoolsPaginator usage example
from boto3.session import Session
session = Session()
client = session.client("cognito-identity") # (1)
paginator = client.get_paginator("list_identity_pools") # (2)
for item in paginator.paginate(...):
print(item) # (3)
- client: CognitoIdentityClient
- paginator: ListIdentityPoolsPaginator
- item: ListIdentityPoolsResponseTypeDef
Explicit type annotations#
With boto3-stubs-lite[cognito-identity]
or a standalone mypy_boto3_cognito_identity
package, you have to explicitly specify client: CognitoIdentityClient
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#
# CognitoIdentityClient usage example with type annotations
from boto3.session import Session
from mypy_boto3_cognito_identity.client import CognitoIdentityClient
from mypy_boto3_cognito_identity.type_defs import IdentityPoolTypeDef
from mypy_boto3_cognito_identity.type_defs import CreateIdentityPoolInputTypeDef
session = Session()
client: CognitoIdentityClient = session.client("cognito-identity")
kwargs: CreateIdentityPoolInputTypeDef = {...}
result: IdentityPoolTypeDef = client.create_identity_pool(**kwargs)
Paginator usage example#
# ListIdentityPoolsPaginator usage example with type annotations
from boto3.session import Session
from mypy_boto3_cognito_identity.client import CognitoIdentityClient
from mypy_boto3_cognito_identity.paginator import ListIdentityPoolsPaginator
from mypy_boto3_cognito_identity.type_defs import ListIdentityPoolsResponseTypeDef
session = Session()
client: CognitoIdentityClient = session.client("cognito-identity")
paginator: ListIdentityPoolsPaginator = client.get_paginator("list_identity_pools")
for item in paginator.paginate(...):
item: ListIdentityPoolsResponseTypeDef
print(item)