mypy-boto3-s3tables Type Annotations

1.42.80 · active · verified Sat Apr 11

mypy-boto3-s3tables provides type annotations for the `boto3` AWS SDK's S3Tables service. Generated by `mypy-boto3-builder`, it enhances developer experience by enabling static type checking with tools like MyPy and improving IDE features such as autocompletion and error detection for `boto3` calls. The package versions are synchronized with `boto3` releases, ensuring a regular and active update cadence.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to obtain a type-hinted `S3TablesClient` and use it to interact with the service, leveraging type definitions for method arguments and return values. The `if TYPE_CHECKING:` block ensures that `mypy-boto3-s3tables` is only a development dependency.

from typing import TYPE_CHECKING
import boto3
from boto3.session import Session

if TYPE_CHECKING:
    from mypy_boto3_s3tables.client import S3TablesClient
    from mypy_boto3_s3tables.type_defs import ListNamespacesOutputTypeDef

def get_s3tables_client() -> 'S3TablesClient':
    """Initializes and returns a type-hinted S3Tables client."""
    session: Session = boto3.session.Session()
    client: S3TablesClient = session.client('s3tables')
    return client

def list_s3tables_namespaces() -> None:
    """Lists S3Tables namespaces with type checking."""
    client = get_s3tables_client()
    
    # Use a dummy list for illustration, as actual AWS calls require credentials
    # If you have AWS credentials configured, uncomment the line below:
    # response: ListNamespacesOutputTypeDef = client.list_namespaces()
    
    # Example with a mock response for type checking demonstration:
    response: ListNamespacesOutputTypeDef = {
        'namespaces': [
            {'namespaceArn': 'arn:aws:s3tables:REGION:ACCOUNT:namespace/example1', 'namespaceName': 'example1'},
            {'namespaceArn': 'arn:aws:s3tables:REGION:ACCOUNT:namespace/example2', 'namespaceName': 'example2'}
        ],
        'ResponseMetadata': {
            'RequestId': 'example-request-id',
            'HTTPStatusCode': 200,
            'HTTPHeaders': {},
            'RetryAttempts': 0
        }
    }
    
    for namespace in response['namespaces']:
        print(f"Namespace ARN: {namespace['namespaceArn']}, Name: {namespace['namespaceName']}")

if __name__ == "__main__":
    list_s3tables_namespaces()

view raw JSON →