{"id":2127,"library":"mypy-boto3-athena","title":"mypy-boto3-athena Type Stubs","description":"mypy-boto3-athena provides PEP 561 compliant type annotations (stubs) for the boto3 Athena service. It allows static type checkers like MyPy to validate usage of boto3's Athena client, improving code quality and catching errors early. The package is generated by mypy-boto3-builder, and its releases are frequent, typically mirroring boto3 updates and builder enhancements. Current version is 1.42.43.","status":"active","version":"1.42.43","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["boto3","aws","type-stubs","mypy","athena","type-checking"],"install":[{"cmd":"pip install mypy-boto3-athena","lang":"bash","label":"Install stubs for Athena"},{"cmd":"pip install boto3","lang":"bash","label":"Install core boto3 library (required)"}],"dependencies":[{"reason":"This package provides type stubs for boto3's Athena client. The actual boto3 library must be installed separately to run the code.","package":"boto3","optional":false}],"imports":[{"symbol":"AthenaClient","correct":"from mypy_boto3_athena.client import AthenaClient"},{"note":"Pre-8.9.0, TypeDefs sometimes had 'Request' duplicated (e.g., RequestRequestTypeDef). This was shortened in 8.9.0.","wrong":"from mypy_boto3_athena.type_defs import StartQueryExecutionRequestRequestTypeDef","symbol":"StartQueryExecutionInputRequestTypeDef","correct":"from mypy_boto3_athena.type_defs import StartQueryExecutionInputRequestTypeDef"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_athena.client import AthenaClient\nfrom mypy_boto3_athena.type_defs import StartQueryExecutionInputRequestTypeDef\nimport os\n\n# Instantiate a boto3 Athena client with type annotations\ndef get_athena_client() -> AthenaClient:\n    return boto3.client(\"athena\", region_name=os.environ.get('AWS_REGION', 'us-east-1'))\n\nclient: AthenaClient = get_athena_client()\n\n# Define input using a TypeDef for static checking\nquery_execution_input: StartQueryExecutionInputRequestTypeDef = {\n    \"QueryString\": \"SELECT 1 FROM \\\"AwsDataCatalog\\\".\\\"default\\\".\\\"test_table\\\" LIMIT 1;\",\n    \"WorkGroup\": os.environ.get('ATHENA_WORKGROUP', 'primary'),\n    \"ResultConfiguration\": {\n        \"OutputLocation\": os.environ.get('ATHENA_OUTPUT_LOCATION', 's3://your-athena-results-bucket/'),\n    },\n}\n\nprint(f\"Client type: {type(client)}\")\nprint(\"Type checking for Athena operations is now enabled.\")\n\n# Example of a type-checked call (uncomment to run, requires valid AWS setup)\n# try:\n#     response = client.start_query_execution(**query_execution_input)\n#     print(f\"Query Execution ID: {response['QueryExecutionId']}\")\n# except Exception as e:\n#     print(f\"Error starting query (ensure AWS_REGION, ATHENA_WORKGROUP, ATHENA_OUTPUT_LOCATION are set and valid): {e}\")\n","lang":"python","description":"This quickstart demonstrates how to initialize an Athena client with type annotations from `mypy-boto3-athena` and define input parameters using TypeDefs, enabling static type checking for your boto3 calls. It assumes `boto3` is already installed and configured with AWS credentials."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer.","message":"Python 3.8 support has been removed since `mypy-boto3-builder` version 8.12.0. All `mypy-boto3` packages built with this builder or later will require Python 3.9 or higher.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0 (and dependent mypy-boto3-* packages)"},{"fix":"Ensure your MyPy version is up-to-date and that your environment correctly resolves PEP 561-compliant stub packages. For most users, this change is transparent.","message":"Migration to PEP 561 packages in `mypy-boto3-builder` version 8.12.0 changes the internal structure and how type checkers locate stubs. While user-facing imports are generally stable, some tooling or custom MyPy configurations might require adjustments.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0 (and dependent mypy-boto3-* packages)"},{"fix":"Always install `boto3` alongside `mypy-boto3-athena`.","message":"This package provides only type stubs, not the functional `boto3` library itself. You must explicitly install `boto3` (e.g., `pip install boto3`) for your code to run.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consult the `mypy-boto3` documentation or regenerate your code's type hints to reflect the new TypeDef names. Your IDE's autocomplete can often help identify the correct names.","message":"In `mypy-boto3-builder` version 8.9.0, TypeDef naming conventions were updated. This included shortening duplicated 'Request' suffixes (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`) and moving 'Extra' postfixes. If you directly imported specific TypeDefs, their names might have changed.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.9.0 (and dependent mypy-boto3-* packages)"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}