mypy-boto3-sso-admin Type Annotations

1.42.41 · active · verified Sat Apr 11

mypy-boto3-sso-admin provides static type annotations for the boto3 AWS SSOAdmin service client. It is part of the mypy-boto3 family of stub packages, currently at version 1.42.41. These packages are generated frequently, aligning with boto3 and botocore releases to ensure up-to-date type definitions.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a boto3 SSOAdmin client and use its methods with type annotations provided by `mypy-boto3-sso-admin`. It fetches and prints AWS SSO instances.

import boto3
from mypy_boto3_sso_admin.client import SSOAdminClient
from mypy_boto3_sso_admin.type_defs import ListInstancesResponseTypeDef
from os import environ

# Configure AWS credentials, e.g., via environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION)
# or AWS CLI configuration. For this example, AWS_REGION is explicitly pulled from environment.

def get_sso_admin_client() -> SSOAdminClient:
    """Returns a boto3 SSO Admin client with type annotations from mypy-boto3-sso-admin."""
    # The actual boto3.client() call returns an untyped client at runtime.
    # The 'SSOAdminClient' type hint provides static analysis benefits.
    return boto3.client("sso-admin", region_name=environ.get('AWS_REGION', 'us-east-1'))

client: SSOAdminClient = get_sso_admin_client()

try:
    print("Attempting to list SSO Admin instances...")
    response: ListInstancesResponseTypeDef = client.list_instances()
    print("SSO Admin Instances:")
    for instance in response.get("Instances", []):
        print(f"  ARN: {instance.get('InstanceArn')}, Status: {instance.get('Status')}")

except Exception as e:
    print(f"Error listing SSO Admin instances: {e}")
    print("Ensure AWS credentials and SSO Admin permissions are correctly configured.")
    print("This code requires an AWS account with configured SSO Admin instances and appropriate permissions.")

view raw JSON →