Type Annotations for Boto3 IAM Roles Anywhere

1.42.5 · active · verified Sat Apr 11

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

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `boto3` IAM Roles Anywhere client and apply the type hints provided by `mypy-boto3-rolesanywhere`. This allows for static type checking and improved IDE auto-completion when interacting with the service. Ensure `boto3` is also installed.

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

view raw JSON →