mypy-boto3-license-manager Type Stubs for Boto3

1.42.3 · active · verified Sat Apr 11

mypy-boto3-license-manager provides type annotations (stubs) for the `boto3` AWS SDK's LicenseManager service. It enables static type checking for `boto3` code interacting with License Manager, helping developers catch type-related errors before runtime. This package is part of the `mypy-boto3` ecosystem, generated by `mypy-boto3-builder`. The current version is 1.42.3, closely aligned with `boto3` releases and updated frequently.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `boto3` client for License Manager and type-annotate it using `LicenseManagerClient`. It also shows how to use generated `TypedDict` for request parameters and response items, allowing `mypy` to validate your API calls.

import boto3
from mypy_boto3_license_manager.client import LicenseManagerClient
from mypy_boto3_license_manager.type_defs import (
    LicenseConfigurationTypeDef,
    ListLicenseConfigurationsRequestRequestTypeDef
)
import os

def get_license_configurations(region: str) -> list[LicenseConfigurationTypeDef]:
    # It's crucial to explicitly cast the client for mypy to pick up the types
    client: LicenseManagerClient = boto3.client("license-manager", region_name=region)

    # Example of using a TypedDict for a request payload
    request: ListLicenseConfigurationsRequestRequestTypeDef = {
        "MaxResults": 5,
    }
    response = client.list_license_configurations(**request)
    return response.get("LicenseConfigurations", [])

if __name__ == "__main__":
    # Example usage - ensure AWS credentials are configured (e.g., via env vars or ~/.aws/credentials)
    # mypy will check this code for type consistency at compile time
    # actual runtime execution requires valid AWS credentials and region.
    aws_region = os.environ.get('AWS_REGION_NAME', 'us-east-1')
    print(f"Fetching License Manager configurations in region: {aws_region}")
    try:
        configurations = get_license_configurations(aws_region)
        if configurations:
            for config in configurations:
                print(f"  ARN: {config.get('LicenseConfigurationArn')}, Name: {config.get('LicenseConfigurationName')}")
        else:
            print("  No license configurations found.")
    except Exception as e:
        print(f"Error fetching configurations: {e}")

view raw JSON →