Skip to content

Examples#

Index > Account > Examples

Auto-generated documentation for Account type annotations stubs module mypy-boto3-account.

Client#

Implicit type annotations#

Can be used with boto3-stubs[account] package installed.

Write your Account code as usual, type checking and code completion should work out of the box.

# AccountClient usage example

from boto3.session import Session


session = Session()

client = session.client("account")  # (1)
result = client.accept_primary_email_update()  # (2)
  1. client: AccountClient
  2. result: AcceptPrimaryEmailUpdateResponseTypeDef
# ListRegionsPaginator usage example

from boto3.session import Session


session = Session()
client = session.client("account")  # (1)

paginator = client.get_paginator("list_regions")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: AccountClient
  2. paginator: ListRegionsPaginator
  3. item: ListRegionsResponseTypeDef

Explicit type annotations#

With boto3-stubs-lite[account] or a standalone mypy_boto3_account package, you have to explicitly specify client: AccountClient 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.

# AccountClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_account.client import AccountClient
from mypy_boto3_account.type_defs import AcceptPrimaryEmailUpdateResponseTypeDef
from mypy_boto3_account.type_defs import AcceptPrimaryEmailUpdateRequestRequestTypeDef


session = Session()

client: AccountClient = session.client("account")

kwargs: AcceptPrimaryEmailUpdateRequestRequestTypeDef = {...}
result: AcceptPrimaryEmailUpdateResponseTypeDef = client.accept_primary_email_update(**kwargs)
# ListRegionsPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_account.client import AccountClient
from mypy_boto3_account.paginator import ListRegionsPaginator
from mypy_boto3_account.type_defs import ListRegionsResponseTypeDef


session = Session()
client: AccountClient = session.client("account")

paginator: ListRegionsPaginator = client.get_paginator("list_regions")
for item in paginator.paginate(...):
    item: ListRegionsResponseTypeDef
    print(item)