mypy-boto3-account Type Annotations
Type annotations for boto3 Account 1.42.6 service generated with mypy-boto3-builder 8.12.0. This library provides precise type hints for the AWS Account service, significantly enhancing static analysis capabilities with tools like mypy, VSCode, and PyCharm for improved code quality and developer experience.
Warnings
- breaking Support for Python 3.8 has been removed in `mypy-boto3-builder` version 8.12.0 and subsequently across all generated packages. Projects targeting `mypy-boto3-account` must use Python 3.9 or newer.
- breaking TypeDef naming conventions changed in `mypy-boto3-builder` version 8.9.0. This includes shortening packed argument TypeDefs (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`) and moving `Extra` postfixes (e.g., `CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`). These changes may require updates to existing type hint usage for various services.
- gotcha The `mypy-boto3-builder` and its generated packages migrated to PEP 561 standard packages. This change might affect how type checkers or IDEs discover types if your build setup is not up-to-date or if you rely on older `mypy` versions.
- deprecated The `sms-voice` service was deprecated and removed from `mypy-boto3` builds in version 8.11.0 of the builder. Users should now use `pinpoint-sms-voice` instead.
- gotcha When using `mypy-boto3-account` as a development-only dependency with `TYPE_CHECKING` guards, older versions of `Pylint` might incorrectly complain about undefined variables. This can be mitigated by explicitly assigning `object` to the type hints in the `else` block.
Install
-
pip install mypy-boto3-account boto3 mypy
Imports
- AccountClient
from mypy_boto3_account import AccountClient
- ListRegionsPaginator
from mypy_boto3_account.paginator import ListRegionsPaginator
- AlternateContactTypeType
from mypy_boto3_account.literals import AlternateContactTypeType
- AcceptPrimaryEmailUpdateRequestTypeDef
from mypy_boto3_account.type_defs import AcceptPrimaryEmailUpdateRequestTypeDef
- AccountClient
from typing import TYPE_CHECKING if TYPE_CHECKING: from mypy_boto3_account import AccountClient else: AccountClient = object
Quickstart
from typing import TYPE_CHECKING
import boto3
if TYPE_CHECKING:
from mypy_boto3_account import AccountClient
from mypy_boto3_account.type_defs import ListRegionsResponseTypeDef
def get_account_regions() -> 'ListRegionsResponseTypeDef':
"""Gets a list of regions for the current AWS account."""
client: AccountClient = boto3.client("account")
response: ListRegionsResponseTypeDef = client.list_regions()
return response
if __name__ == "__main__":
# Ensure AWS credentials are configured (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION env vars)
# Or use a local AWS config/credentials file
try:
regions_data = get_account_regions()
print(f"Account Regions: {[r['RegionName'] for r in regions_data.get('Regions', [])]}")
except Exception as e:
print(f"Error: {e}")
print("Ensure AWS credentials and permissions for 'account:ListRegions' are configured.")