mypy-boto3-iam Type Stubs

1.42.64 · active · verified Sun Mar 29

mypy-boto3-iam provides static type annotations for the boto3 IAM service client, resources, and related types. It enables type checking with tools like MyPy, Pyright, and enhances IDE auto-completion for `boto3.client('iam')` calls. Currently at version 1.42.64, it is part of the frequently updated `mypy-boto3-builder` ecosystem, with releases often tied to new boto3 versions.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to obtain a type-hinted IAM client using `mypy-boto3-iam` and call a method like `get_account_summary`. The `TYPE_CHECKING` block ensures type imports are only active during type checking, avoiding runtime dependencies if desired. For full type coverage, ensure `boto3` is also installed in your environment.

from typing import TYPE_CHECKING
import boto3

if TYPE_CHECKING:
    from mypy_boto3_iam.client import IAMClient
    from mypy_boto3_iam.type_defs import GetAccountSummaryResponseTypeDef

def get_iam_account_summary() -> 'GetAccountSummaryResponseTypeDef':
    # The 'iam' client is type-hinted by mypy-boto3-iam after installation.
    client: IAMClient = boto3.client("iam")
    summary = client.get_account_summary()
    print(f"IAM Account Summary: {summary['SummaryMap']}")
    return summary

if __name__ == "__main__":
    # Ensure AWS credentials are configured (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN env vars or ~/.aws/credentials)
    try:
        get_iam_account_summary()
    except Exception as e:
        print(f"An error occurred: {e}")

view raw JSON →