mypy-boto3-freetier

1.42.3 · active · verified Sat Apr 11

mypy-boto3-freetier provides type annotations (type stubs) for the boto3 FreeTier service, enhancing developer experience with static type checking in Python projects. It is part of the larger `mypy-boto3` ecosystem, generated by `mypy-boto3-builder`, and its versions typically align with corresponding `boto3` releases, with frequent updates to reflect AWS service changes.

Warnings

Install

Imports

Quickstart

This example demonstrates how to use the `mypy-boto3-freetier` stubs to get type-hinted interaction with the boto3 FreeTier client. It shows importing the `FreeTierClient` for type annotations and a specific `TypeDef` for response parsing, ensuring static type checkers like mypy can validate your code.

import boto3
from mypy_boto3_freetier.client import FreeTierClient
from mypy_boto3_freetier.type_defs import GetFreeTierUsageResponseTypeDef

def get_freetier_usage() -> GetFreeTierUsageResponseTypeDef:
    # mypy-boto3-freetier provides type hints for this client
    client: FreeTierClient = boto3.client('freetier')
    response: GetFreeTierUsageResponseTypeDef = client.get_free_tier_usage()
    print(f"Free Tier Usage: {response.get('FreeTierUsages')}")
    return response

if __name__ == '__main__':
    # Ensure AWS credentials are configured or available via environment variables
    # For local testing, you might need to mock boto3 or ensure credentials are set.
    # Example: os.environ['AWS_ACCESS_KEY_ID'] = '...' 
    #          os.environ['AWS_SECRET_ACCESS_KEY'] = '...' 
    #          os.environ['AWS_DEFAULT_REGION'] = 'us-east-1'
    
    try:
        get_freetier_usage()
    except Exception as e:
        print(f"Error fetching Free Tier usage: {e}")

view raw JSON →