mypy-boto3-savingsplans: Type Annotations for AWS Boto3 SavingsPlans
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
- breaking Support for Python 3.8 was removed starting with `mypy-boto3-builder` version 8.12.0. Ensure your project uses Python 3.9 or higher for compatibility.
- breaking All `mypy-boto3` packages, including `mypy-boto3-savingsplans`, migrated to PEP 561 compatible packages with `mypy-boto3-builder` 8.12.0. This changes how type checkers discover stubs.
- gotcha For optimal IDE auto-completion and static type checking, explicitly type your `boto3` client instance using the imported `SavingsPlansClient` type, especially when using `boto3.session.Session().client(...)`.
- breaking TypeDef naming conventions were changed in `mypy-boto3-builder` 8.9.0. This could affect code that directly references generated `TypedDict` names (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`).
- gotcha The `mypy-boto3` ecosystem offers individual service packages (e.g., `mypy-boto3-savingsplans`) and an umbrella `boto3-stubs` package with extras (e.g., `boto3-stubs[savingsplans]`). Choose the installation method that best suits your project's dependency management.
- gotcha Mypy itself has evolving Python version support. While `mypy-boto3-savingsplans` requires Python 3.9+, ensure your `mypy` version is compatible with your target Python runtime.
Install
-
pip install boto3 mypy mypy-boto3-savingsplans -
pip install boto3 mypy 'boto3-stubs[savingsplans]'
Imports
- SavingsPlansClient
from mypy_boto3_savingsplans.client import SavingsPlansClient
Quickstart
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}")