Type Annotations for aiobotocore Athena
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
-
ModuleNotFoundError: No module named 'aiobotocore'
cause The `types-aiobotocore-athena` package only provides type hints; the actual `aiobotocore` library is not installed.fixInstall the `aiobotocore` library: `pip install aiobotocore`. -
error: Library stubs not installed for "aiobotocore.session" [no-any-unimported]
cause Mypy cannot find type information for `aiobotocore` because the stub package for Athena is installed, but the core `aiobotocore` stubs or the specific service stubs are not being correctly picked up, or the stub package itself is missing.fixEnsure `types-aiobotocore-athena` is installed and that MyPy is configured to check your environment. Sometimes explicitly installing `types-aiobotocore` (the umbrella package) can help, or if using `aiobotocore` as a dependency in `pyproject.toml`, ensure it's in a section MyPy checks. -
AttributeError: 'AthenaClient' object has no attribute 'non_existent_method'
cause The code is attempting to call a method on the Athena client that does not exist in the installed `aiobotocore` version or is a typo. The type stubs reflect the latest `aiobotocore` API, which might differ from an older runtime version.fixCheck the `aiobotocore` documentation for the correct method name and available APIs for your installed version. Ensure your `aiobotocore` installation is up-to-date: `pip install --upgrade aiobotocore`.
Warnings
- breaking Python 3.8 support was removed from `mypy-boto3-builder` (which generates these stubs) in version 8.12.0. Users on Python 3.8 or older will need to upgrade their Python version to `>=3.9` or use an older stub version.
- breaking Type definition (TypeDef) naming conventions changed in `mypy-boto3-builder` 8.9.0. This includes shorter names for packed method arguments (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`) and moving the `Extra` postfix. Code explicitly importing and using these `TypeDefs` may break.
- gotcha This package (`types-aiobotocore-athena`) provides *only* type annotations. You must install `aiobotocore` separately for the actual asynchronous AWS SDK functionality at runtime. For static type checking, `mypy` is also required as a development dependency.
- gotcha The `mypy-boto3` ecosystem migrated to PEP 561-compliant packages in `mypy-boto3-builder` 8.12.0. While this generally improves compatibility, some tools or custom configurations that relied on older stub discovery mechanisms might require adjustments.
- gotcha Occasionally, specific AWS services may be renamed or deprecated within the `aiobotocore` ecosystem (e.g., `sms-voice` was replaced by `pinpoint-sms-voice` in `mypy-boto3-builder` 8.11.0). While this specific stub is for Athena, keep an eye on upstream `aiobotocore` changes, as they might eventually affect the service name or availability.
Install
-
pip install types-aiobotocore-athena aiobotocore
Imports
- AthenaClient
from types_aiobotocore_athena.client import AthenaClient
- BatchGetNamedQueryOutputTypeDef
from types_aiobotocore_athena.client import BatchGetNamedQueryOutputTypeDef
from types_aiobotocore_athena.type_defs import BatchGetNamedQueryOutputTypeDef
- AuthenticationTypeType
from types_aiobotocore_athena.type_defs import AuthenticationTypeType
from types_aiobotocore_athena.literals import AuthenticationTypeType
Quickstart
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())