mypy-boto3-iam Type Stubs
raw JSON → 1.42.64 verified Tue May 12 auth: no python install: stale
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.
pip install mypy-boto3-iam Common errors
error ModuleNotFoundError: No module named 'mypy-boto3-iam' ↓
cause The `mypy-boto3-iam` package, which provides type annotations, has not been installed in your Python environment.
fix
Install the
mypy-boto3-iam package using pip: python -m pip install mypy-boto3-iam or python -m pip install 'boto3-stubs[iam]' for the full stubs package. error error: Skipping analyzing 'boto3': found module but no type hints or library stubs ↓
cause MyPy is unable to find or correctly pick up the installed type stubs for the `boto3` library, even if `mypy-boto3-iam` (or `boto3-stubs[iam]`) is installed. This often happens if the stub package is installed incorrectly or MyPy's environment isn't configured to find it.
error error: "IAMClient" has no attribute "some_method" [attr-defined] ↓
cause This error occurs when MyPy cannot correctly infer the type of your `boto3.client('iam')` object, leading it to believe that specific IAM service methods (like `create_user` or `list_roles`) do not exist on the client. This typically means the type stubs are not being applied effectively, or the client isn't explicitly type-hinted.
fix
Explicitly type hint the IAM client with
IAMClient imported from mypy_boto3_iam.client. For example: from mypy_boto3_iam.client import IAMClient; iam_client: IAMClient = boto3.client('iam'). error error: Missing type parameters for generic type "list" (or "dict", "Sequence", etc.) [type-arg] ↓
cause This is a common MyPy error when generic types (like `list`, `dict`, `Sequence`) are used without specifying their contained types, especially in strict MyPy configurations. Boto3 responses often involve lists and dictionaries, and without specifying their contents, MyPy cannot fully type check them.
fix
Provide explicit type arguments for generic types. For example, instead of
my_list: list = [], use my_list: list[str] = [] or my_list: list[UserTypeDef] = [] when using mypy-boto3-iam's generated type definitions. You can import specific TypeDef types from mypy_boto3_iam.type_defs. Warnings
breaking Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0 and subsequent generated packages, including `mypy-boto3-iam`. The minimum required Python version is now 3.9. ↓
fix Upgrade your Python environment to 3.9 or newer.
breaking In `mypy-boto3-builder` version 8.9.0, type definition names for packed method arguments (`RequestRequestTypeDef` became `RequestTypeDef`) and conflicting `Extra` postfixes (`ExtraRequestTypeDef` became `RequestExtraTypeDef`) were changed. This may break existing type annotations. ↓
fix Update your custom type aliases or explicit type annotations to match the new naming conventions, or regenerate stubs if using `mypy-boto3-builder` locally.
deprecated The `sms-voice` service stubs were removed in `mypy-boto3-builder` version 8.11.0 because the service is no longer supported by AWS. Use `pinpoint-sms-voice` stubs instead. While not directly IAM, this indicates a broader trend in the `mypy-boto3` ecosystem. ↓
fix Migrate any usage of `sms-voice` related stubs to `pinpoint-sms-voice` stubs.
gotcha PyCharm users might experience slow performance or high CPU usage due to how PyCharm handles `Literal` overloads. It is recommended to use `boto3-stubs-lite` (e.g., `pip install 'boto3-stubs-lite[iam]'`) or disable PyCharm's type checker and rely on `mypy` or `pyright`. ↓
fix Consider installing `boto3-stubs-lite[iam]` for improved performance in PyCharm, or configure PyCharm to use external type checkers like MyPy or Pyright.
gotcha When using standalone packages like `mypy-boto3-iam` or `boto3-stubs-lite`, you might need to explicitly annotate the client, resource, waiter, or paginator variables for full type checking and IDE auto-completion, as automatic type inference for `session.client()` overloads is not always available. ↓
fix Explicitly add type annotations, e.g., `client: IAMClient = session.client("iam")`.
gotcha When using `mypy-boto3-iam` or other `mypy-boto3` stubs in a production environment where you want to avoid installing the stubs at runtime, wrap your type imports in a `if TYPE_CHECKING:` block. This prevents unnecessary runtime dependencies but requires setting types to `object` outside of type checking for tools like Pylint. ↓
fix Use `from typing import TYPE_CHECKING; if TYPE_CHECKING: from mypy_boto3_iam.client import IAMClient` and define a fallback `IAMClient = object` for runtime.
breaking `mypy-boto3-iam` provides type stubs for `boto3`, but it does not install `boto3` itself. You must install `boto3` separately (e.g., `pip install boto3`) to use the library at runtime. ↓
fix Install the core boto3 library: 'pip install boto3'.
breaking `mypy-boto3-iam` provides type stubs for `boto3`, but it does not install `boto3` itself. You must install `boto3` separately (e.g., `pip install boto3`) for your application to run. ↓
fix Install `boto3` explicitly (e.g., `pip install boto3`).
Install
pip install 'boto3-stubs[iam]' Install compatibility stale last tested: 2026-05-12
python os / libc variant status wheel install import disk
3.10 alpine (musl) iam wheel - - 21.3M
3.10 alpine (musl) iam - - - -
3.10 alpine (musl) mypy-boto3-iam wheel - - 19.6M
3.10 alpine (musl) mypy-boto3-iam - - - -
3.10 slim (glibc) iam wheel 7.6s - 22M
3.10 slim (glibc) iam - - - -
3.10 slim (glibc) mypy-boto3-iam wheel 1.7s - 20M
3.10 slim (glibc) mypy-boto3-iam - - - -
3.11 alpine (musl) iam wheel - - 23.2M
3.11 alpine (musl) iam - - - -
3.11 alpine (musl) mypy-boto3-iam wheel - - 21.5M
3.11 alpine (musl) mypy-boto3-iam - - - -
3.11 slim (glibc) iam wheel 3.7s - 24M
3.11 slim (glibc) iam - - - -
3.11 slim (glibc) mypy-boto3-iam wheel 1.8s - 22M
3.11 slim (glibc) mypy-boto3-iam - - - -
3.12 alpine (musl) iam wheel - - 14.7M
3.12 alpine (musl) iam - - - -
3.12 alpine (musl) mypy-boto3-iam wheel - - 13.0M
3.12 alpine (musl) mypy-boto3-iam - - - -
3.12 slim (glibc) iam wheel 2.7s - 15M
3.12 slim (glibc) iam - - - -
3.12 slim (glibc) mypy-boto3-iam wheel 1.5s - 14M
3.12 slim (glibc) mypy-boto3-iam - - - -
3.13 alpine (musl) iam wheel - - 14.4M
3.13 alpine (musl) iam - - - -
3.13 alpine (musl) mypy-boto3-iam wheel - - 12.7M
3.13 alpine (musl) mypy-boto3-iam - - - -
3.13 slim (glibc) iam wheel 2.4s - 15M
3.13 slim (glibc) iam - - - -
3.13 slim (glibc) mypy-boto3-iam wheel 1.5s - 13M
3.13 slim (glibc) mypy-boto3-iam - - - -
3.9 alpine (musl) iam wheel - - 20.8M
3.9 alpine (musl) iam - - - -
3.9 alpine (musl) mypy-boto3-iam wheel - - 19.1M
3.9 alpine (musl) mypy-boto3-iam - - - -
3.9 slim (glibc) iam wheel 8.7s - 21M
3.9 slim (glibc) iam - - - -
3.9 slim (glibc) mypy-boto3-iam wheel 2.0s - 20M
3.9 slim (glibc) mypy-boto3-iam - - - -
Imports
- IAMClient
from mypy_boto3_iam.client import IAMClient - IAMServiceResource
from mypy_boto3_iam.service_resource import IAMServiceResource - GetAccountSummaryResponseTypeDef wrong
from mypy_boto3_iam.client import GetAccountSummaryResponseTypeDefcorrectfrom mypy_boto3_iam.type_defs import GetAccountSummaryResponseTypeDef
Quickstart last tested: 2026-04-24
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}")