Type annotations for boto3 RAM service

1.42.59 · active · verified Sat Apr 11

mypy-boto3-ram provides type annotations for the AWS Resource Access Manager (RAM) service for boto3, ensuring type-checking and autocompletion in IDEs. It is currently at version 1.42.59, and is part of the actively maintained `mypy-boto3` family, which frequently updates to match new `boto3` versions and includes features from `mypy-boto3-builder`.

Warnings

Install

Imports

Quickstart

This example demonstrates how to initialize a `RAMClient` with type annotations and use a basic operation like `list_resource_shares`. The type annotation ensures that `mypy` and IDEs provide correct autocompletion and type-checking for RAM service-specific methods and parameters.

import boto3
from mypy_boto3_ram import RAMClient
import os

def list_resource_shares_typed() -> None:
    # It's recommended to explicitly type the client for full type-checking benefits
    # Especially if not installing the full 'boto3-stubs' package
    client: RAMClient = boto3.client("ram", region_name=os.environ.get('AWS_REGION', 'us-east-1'))

    # The client methods are now fully type-checked
    response = client.list_resource_shares(resourceOwner='SELF')
    
    print("Resource Shares:")
    for share in response.get('resourceShares', []):
        print(f"  - {share['name']} ({share['status']})")

if __name__ == "__main__":
    # Ensure AWS credentials/config are set up, e.g., via environment variables or ~/.aws/credentials
    # For this example, we're using a dummy region name; replace with actual if needed.
    list_resource_shares_typed()

view raw JSON →