Type Annotations for aiobotocore Athena

3.4.0 · active · verified Thu Apr 16

This library provides comprehensive static type annotations for the `aiobotocore` AWS Athena service client. Generated by `mypy-boto3-builder`, it enhances code reliability and developer experience by enabling static type checking with tools like MyPy, offering features such as autocompletion and early error detection. It is currently at version 3.4.0, generated with `mypy-boto3-builder 8.12.0`, and receives frequent updates in sync with new `aiobotocore` releases and builder improvements. Python 3.9+ is required.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to use `types-aiobotocore-athena` with `aiobotocore` to list Athena workgroups. It includes explicit type annotations for the client, allowing IDEs and static analyzers like MyPy to provide intelligent autocompletion and type checking for Athena client methods and their return types. Remember to set up actual AWS credentials for real-world usage.

import asyncio
import os
from aiobotocore.session import get_session
from types_aiobotocore_athena.client import AthenaClient
from types_aiobotocore_athena.type_defs import StartQueryExecutionOutputTypeDef


async def list_athena_workgroups() -> None:
    session = get_session()
    # For demonstration, using dummy credentials. Replace with actual config or env vars.
    aws_access_key_id = os.environ.get('AWS_ACCESS_KEY_ID', 'testing')
    aws_secret_access_key = os.environ.get('AWS_SECRET_ACCESS_KEY', 'testing')
    aws_session_token = os.environ.get('AWS_SESSION_TOKEN', 'testing')

    async with session.create_client(
        "athena",
        region_name="us-east-1",
        aws_access_key_id=aws_access_key_id,
        aws_secret_access_key=aws_secret_access_key,
        aws_session_token=aws_session_token
    ) as client:
        client: AthenaClient # Explicit type annotation is optional but recommended
        try:
            response = await client.list_work_groups()
            print("Athena Workgroups:")
            for wg in response.get('WorkGroups', []):
                print(f"  - {wg.get('Name')} (State: {wg.get('State')})")
        except client.exceptions.ClientError as e:
            print(f"Error listing workgroups: {e}")

async def run_example():
    await list_athena_workgroups()

if __name__ == "__main__":
    asyncio.run(run_example())

view raw JSON →