Type Annotations for Boto3 IAM Roles Anywhere
mypy-boto3-rolesanywhere provides static type annotations for the `boto3` IAM Roles Anywhere service client. It is part of the `mypy-boto3` project, which generates comprehensive type stubs for all AWS services supported by `boto3`, significantly enhancing code quality and developer experience through static analysis. The library is actively maintained with frequent updates, currently at version 1.42.5, typically aligning with `boto3` and `botocore` releases.
Warnings
- breaking Support for Python 3.8 was removed starting with `mypy-boto3-builder` version 8.12.0. Packages generated by this builder (including `mypy-boto3-rolesanywhere`) will not function correctly on Python 3.8.
- breaking The `mypy-boto3` ecosystem, including `mypy-boto3-rolesanywhere`, migrated to PEP 561 compliant packages with `mypy-boto3-builder` version 8.12.0. This might affect advanced build setups or custom type checking configurations.
- gotcha This library provides type stubs only. For runtime functionality, the `boto3` library must be installed alongside `mypy-boto3-rolesanywhere`. Forgetting `pip install boto3` is a common mistake.
- breaking TypeDef argument names for methods were shortened and conflicting TypeDef `Extra` postfixes were reordered in `mypy-boto3-builder` version 8.9.0. If you explicitly import or reference specific TypeDefs for request/response bodies, their names may have changed.
Install
-
pip install mypy-boto3-rolesanywhere -
pip install boto3 mypy-boto3-rolesanywhere
Imports
- RolesAnywhereClient
from mypy_boto3_rolesanywhere.client import RolesAnywhereClient
- ListProfilesResponseTypeDef
from mypy_boto3_rolesanywhere.type_defs import ListProfilesResponseTypeDef
Quickstart
import boto3
from mypy_boto3_rolesanywhere.client import RolesAnywhereClient
from mypy_boto3_rolesanywhere.type_defs import ListProfilesResponseTypeDef
# Get a Boto3 Roles Anywhere client, explicitly typed for mypy
client: RolesAnywhereClient = boto3.client("rolesanywhere")
try:
# Call an operation; mypy will now provide completions and type checking
response: ListProfilesResponseTypeDef = client.list_profiles()
print(f"Successfully listed {len(response.get('profiles', []))} RolesAnywhere profiles.")
if 'nextToken' in response:
print(f"Next token available: {response['nextToken']}")
except client.exceptions.AccessDeniedException as e:
print(f"Access Denied: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")