mypy-boto3-glacier Type Stubs

1.42.30 · active · verified Sat Apr 11

mypy-boto3-glacier provides a complete set of type annotations (stubs) for the AWS Boto3 Glacier service. These stubs enhance developer experience by enabling static type checking with tools like mypy, and providing improved autocomplete in IDEs for Glacier client, resource, paginator, waiter, and type definitions. It is generated by the `mypy-boto3-builder` project and is currently at version 1.42.30, reflecting a close alignment with `boto3`'s release cycle, ensuring frequent updates for new AWS features and API changes.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to obtain a type-hinted Glacier client using `mypy-boto3-glacier` and perform a basic operation like creating a vault. Explicit type annotations on `boto3.client` calls enable full type checking and IDE autocomplete.

import boto3
from mypy_boto3_glacier.client import GlacierClient
from mypy_boto3_glacier.type_defs import CreateVaultOutputTypeDef
import os

def get_glacier_client() -> GlacierClient:
    # Using explicit type annotation for better IDE support and static analysis
    client: GlacierClient = boto3.client(
        "glacier",
        region_name=os.environ.get('AWS_REGION', 'us-east-1'),
        aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', ''),
        aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', '')
    )
    return client

def create_glacier_vault(client: GlacierClient, vault_name: str) -> CreateVaultOutputTypeDef:
    response: CreateVaultOutputTypeDef = client.create_vault(vaultName=vault_name)
    return response

if __name__ == '__main__':
    glacier_client = get_glacier_client()
    # Example of type-hinted usage
    try:
        vault_info = create_glacier_vault(glacier_client, "my-typed-vault")
        print(f"Vault created: {vault_info.get('location')}")
    except glacier_client.exceptions.ResourceAlreadyExistsException:
        print("Vault already exists.")
    except Exception as e:
        print(f"An error occurred: {e}")

view raw JSON →