mypy-boto3-identitystore Type Annotations

1.42.20 · active · verified Sat Apr 11

mypy-boto3-identitystore provides type annotations for the boto3 IdentityStore service, currently at version 1.42.20. It is part of the larger `boto3-stubs` ecosystem, generated with `mypy-boto3-builder`. This active project releases frequently, often aligning with `boto3` and `botocore` updates, offering enhanced type checking capabilities for tools like MyPy and Pyright, and improved auto-completion in IDEs such as VSCode and PyCharm.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `boto3` IdentityStore client with explicit type annotations provided by `mypy-boto3-identitystore`. This enables your IDE and type checker (like MyPy) to provide accurate auto-completion and static analysis for all service-specific methods and parameters. Remember to have `boto3` installed and AWS credentials configured.

import boto3
from mypy_boto3_identitystore.client import IdentityStoreClient
from os import environ

# Configure AWS credentials and region (e.g., via environment variables or ~/.aws/credentials)
# For a runnable example, we'll use os.environ.get for safe execution.

# Explicitly type the client for mypy/IDE assistance
def get_identitystore_client() -> IdentityStoreClient:
    client: IdentityStoreClient = boto3.client(
        "identitystore",
        region_name=environ.get('AWS_REGION', 'us-east-1')
    )
    return client

# Example usage
if __name__ == "__main__":
    try:
        identitystore_client = get_identitystore_client()
        # Replace with a real IdentityStore ID from your AWS account
        identity_store_id = environ.get('IDENTITY_STORE_ID', 'd-xxxxxxxxxx')
        
        # Example: List users (requires appropriate permissions)
        # Note: This operation might require an actual IdentityStore ID to succeed.
        response = identitystore_client.list_users(IdentityStoreId=identity_store_id)
        print("Successfully listed IdentityStore users (first page).")
        for user in response.get('Users', []):
            print(f"  User ID: {user.get('UserId')}, UserName: {user.get('UserName')}")
        
        # Demonstrating a method that doesn't exist on BaseClient but does on IdentityStoreClient
        # This would be flagged by a type checker without the stub.
        # identitystore_client.non_existent_method() # Mypy error: "IdentityStoreClient" has no attribute "non_existent_method"

    except Exception as e:
        print(f"An error occurred: {e}")
        print("Please ensure 'boto3' is installed, AWS credentials are configured, and IDENTITY_STORE_ID is set if needed.")

view raw JSON →