{"id":7817,"library":"types-aiobotocore-iam","title":"Type annotations for aiobotocore IAM","description":"types-aiobotocore-iam provides comprehensive type annotations for the `aiobotocore` AWS IAM service, enhancing static type checking with tools like MyPy, Pyright, and improving IDE auto-completion. This package, currently at version 3.4.0, is generated by `mypy-boto3-builder` and follows the `aiobotocore` release cycle, ensuring frequent updates to match new AWS service features and API changes. [7, 19]","status":"active","version":"3.4.0","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["type-hints","mypy","pyright","aiobotocore","aws","iam","async","asyncio","stubs","static-analysis"],"install":[{"cmd":"pip install types-aiobotocore-iam","lang":"bash","label":"Install standalone IAM stubs"},{"cmd":"pip install 'types-aiobotocore[iam]'","lang":"bash","label":"Install IAM stubs as part of types-aiobotocore"}],"dependencies":[{"reason":"Provides the asynchronous AWS client that these stubs type-hint.","package":"aiobotocore"}],"imports":[{"note":"When using standalone service packages, the import path is directly from the service package. The `types-aiobotocore` package uses extras and internal paths for its bundled stubs.","wrong":"from types_aiobotocore.iam import IAMClient","symbol":"IAMClient","correct":"from types_aiobotocore_iam.client import IAMClient"},{"note":"TypedDicts for API responses and request parameters are found in the `type_defs` submodule.","symbol":"ListUsersResponseTypeDef","correct":"from types_aiobotocore_iam.type_defs import ListUsersResponseTypeDef"}],"quickstart":{"code":"import asyncio\nfrom typing import TYPE_CHECKING\n\nfrom aiobotocore.session import get_session\n\n# Import type stubs only during type checking to avoid runtime dependencies\nif TYPE_CHECKING:\n    from types_aiobotocore_iam.client import IAMClient\n    from types_aiobotocore_iam.type_defs import ListUsersResponseTypeDef\n\nasync def list_iam_users():\n    session = get_session()\n    async with session.create_client(\"iam\") as client:\n        # Explicitly hint the client type for better IDE support\n        client: IAMClient = client\n\n        print(\"Listing IAM users...\")\n        try:\n            # Type-hint the response for static analysis and auto-completion\n            response: ListUsersResponseTypeDef = await client.list_users()\n            for user in response.get(\"Users\", []):\n                print(f\"  User: {user.get('UserName')} (ARN: {user.get('Arn')})\")\n        except Exception as e:\n            print(f\"Error listing users: {e}\")\n\nif __name__ == \"__main__\":\n    # This example requires valid AWS credentials configured in the environment\n    # or ~/.aws/credentials. Ensure your IAM user has 'iam:ListUsers' permission.\n    asyncio.run(list_iam_users())\n","lang":"python","description":"This quickstart demonstrates how to use `types-aiobotocore-iam` to provide type hints for an `aiobotocore` IAM client. It shows importing the `IAMClient` and a response `TypeDef` within a `TYPE_CHECKING` block for static analysis, then uses it to list IAM users."},"warnings":[{"fix":"Upgrade your project's Python version to 3.9 or newer. Ensure your `requires_python` is set appropriately. [2]","message":"Support for Python 3.8 has been removed in `mypy-boto3-builder` version 8.12.0 and subsequent `types-aiobotocore-*` packages. Projects targeting Python 3.8 will no longer receive updates or new type stubs.","severity":"breaking","affected_versions":">=3.4.0 (for types-aiobotocore-iam), >=8.12.0 (for mypy-boto3-builder)"},{"fix":"Update your code to use the new `TypeDef` names. Consult the `types-aiobotocore` documentation or regenerate stubs if using `mypy-boto3-builder` directly. [14]","message":"Starting with `mypy-boto3-builder` 8.9.0, there were breaking changes to `TypeDef` naming conventions. Specifically, `TypeDefs` for packed method arguments use shorter names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`), and conflicting `TypeDef` 'Extra' postfixes were moved to the end (e.g., `CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`).","severity":"breaking","affected_versions":"<3.4.0 (for types-aiobotocore-iam), >=8.9.0 (for mypy-boto3-builder)"},{"fix":"Enclose type stub imports like `from types_aiobotocore_iam.client import IAMClient` within `if TYPE_CHECKING:` conditional blocks. [2, 6]","message":"To prevent `types-aiobotocore-*` packages from becoming runtime dependencies, it is best practice to wrap all imports of types from these libraries within a `if typing.TYPE_CHECKING:` block.","severity":"gotcha","affected_versions":"All versions"},{"fix":"It is recommended to use an external type checker like MyPy or Pyright instead of PyCharm's built-in one. Alternatively, consider using `types-aiobotocore-lite` or disable PyCharm's type checker for these libraries. [7, 20]","message":"PyCharm's built-in type checker may experience slow performance and high CPU usage, especially with `Literal` overloads present in these stubs. This is a known issue (PY-40997).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure the package is installed via `pip install types-aiobotocore-iam` or `pip install 'types-aiobotocore[iam]'`. Double-check the import statement for correct spelling.","cause":"The `types-aiobotocore-iam` package is not installed, or there's a typo in the import path.","error":"ModuleNotFoundError: No module named 'types_aiobotocore_iam.client'"},{"fix":"Ensure `aiobotocore` and `types-aiobotocore-iam` are compatible versions (preferably the same major.minor version). Upgrade your type checker (MyPy, Pyright) to the latest stable version. [7]","cause":"This error or similar type-checking errors (e.g., 'no attribute', 'unexpected keyword argument') often indicate a mismatch between the installed `aiobotocore` version and `types-aiobotocore-iam` version, or the use of an older type checker.","error":"mypy: error: Missing attribute '__iter__' for 'IAMClient'"},{"fix":"Update the IAM policy attached to your AWS credentials to grant `iam:ListUsers` permission (or whatever specific permission is missing). [21, 24]","cause":"This is an AWS permissions error, not an issue with the type stubs. The IAM user or role executing the code lacks the necessary permissions to perform the requested AWS API call.","error":"An error occurred (AccessDeniedException) when calling the ListUsers operation: User: arn:aws:iam::123456789012:user/MyUser is not authorized to perform: iam:ListUsers on resource: arn:aws:iam::123456789012:user/*"}]}