mypy-boto3-sso-admin Type Annotations
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
- deprecated This `mypy-boto3-*` package is considered a 'legacy' stub format. The `mypy-boto3-builder` project officially recommends using the `boto3-stubs` packages (e.g., `pip install 'boto3-stubs[sso-admin]'`) for PEP 561 compliant type checking, which allows simpler imports from the standard `boto3` namespace.
- breaking Starting with `mypy-boto3-builder` version 8.12.0 (which generates this stub package), support for Python 3.8 was removed for all generated packages.
- gotcha Type stubs are tightly coupled to the `boto3` library version. Installing `mypy-boto3-sso-admin` for a `boto3` version significantly different from `1.42.41` can lead to incorrect or incomplete type hints.
- breaking In `mypy-boto3-builder` version 8.9.0, there were breaking changes to TypeDef naming conventions. Specifically, argument TypeDefs were shortened (e.g., `RequestRequestTypeDef` -> `RequestTypeDef`) and conflicting `Extra` postfixes were moved (e.g., `ExtraRequestTypeDef` -> `RequestExtraTypeDef`).
- gotcha Although `mypy-boto3-sso-admin` imports are explicit, ensure you run `mypy` with the correct configuration to pick up third-party type stubs. For some environments, `mypy` might require `mypy_path` configuration or `enable_incomplete_feature = "Implicit Namespace Packages"`.
Install
-
pip install mypy-boto3-sso-admin mypy boto3
Imports
- SSOAdminClient
from mypy_boto3_sso_admin.client import SSOAdminClient
- ListInstancesResponseTypeDef
from mypy_boto3_sso_admin.type_defs import ListInstancesResponseTypeDef
Quickstart
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.")