mypy-boto3-savingsplans: Type Annotations for AWS Boto3 SavingsPlans

1.42.62 · active · verified Sat Apr 11

mypy-boto3-savingsplans provides drop-in type annotations for the `boto3` AWS SDK's SavingsPlans service. It enhances static type checking and IDE auto-completion for `boto3.client('savingsplans')` calls. This package, currently at version `1.42.62`, is generated by `mypy-boto3-builder` and its releases are typically synchronized with `boto3` versions and `mypy-boto3-builder` updates.

Warnings

Install

Imports

Quickstart

This example demonstrates how to explicitly type a `boto3` SavingsPlans client using `mypy-boto3-savingsplans` for improved static analysis and IDE auto-completion. It then calls a sample API method.

import boto3
from boto3.session import Session
from mypy_boto3_savingsplans.client import SavingsPlansClient
from typing import TYPE_CHECKING

# Ensure AWS credentials are configured (e.g., via environment variables, ~/.aws/credentials)
# For example, using environment variables for demonstration:
# import os
# os.environ['AWS_ACCESS_KEY_ID'] = os.environ.get('AWS_ACCESS_KEY_ID', 'YOUR_ACCESS_KEY')
# os.environ['AWS_SECRET_ACCESS_KEY'] = os.environ.get('AWS_SECRET_ACCESS_KEY', 'YOUR_SECRET_KEY')
# os.environ['AWS_REGION'] = os.environ.get('AWS_REGION', 'us-east-1')

# Recommended: Explicitly type the client for full IDE support and static analysis
if TYPE_CHECKING:
    client: SavingsPlansClient = Session().client('savingsplans')
else:
    client = Session().client('savingsplans')

# Example usage with type-checked methods
try:
    response = client.describe_savings_plans(maxResults=10)
    print("Successfully described Savings Plans:")
    for sp in response.get('savingsPlans', []):
        print(f"  - {sp.get('savingsPlanArn')}")
except client.exceptions.ClientError as e:
    print(f"Error describing Savings Plans: {e}")

view raw JSON →