mypy-boto3-account Type Annotations

1.42.6 · active · verified Sat Apr 11

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

Install

Imports

Quickstart

This example demonstrates how to obtain an AWS Account client with type annotations and use it to list regions. It employs `TYPE_CHECKING` for safe development-only dependency management and explicit type hints for maximal static analysis benefit.

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.")

view raw JSON →