mypy-boto3-eks-auth type annotations
mypy-boto3-eks-auth provides type annotations for the boto3 EKSAuth service, enabling static type checking for AWS EKSAuth client interactions. It is generated by the mypy-boto3-builder project and is currently at version 1.42.3, with updates frequently released alongside new boto3 versions or builder changes.
Warnings
- breaking Python 3.8 support has been removed since `mypy-boto3-builder` version 8.12.0. Users must use Python 3.9 or newer.
- breaking Packages migrated to PEP 561 standard with `mypy-boto3-builder` version 8.12.0. This might affect how static analysis tools (like mypy) discover and utilize the stub files, especially in complex project setups.
- breaking TypeDef names were changed for clarity and to resolve conflicts in `mypy-boto3-builder` version 8.9.0. If you explicitly imported TypeDefs, their names might have changed (e.g., `CreateDistributionRequestRequestTypeDef` to `CreateDistributionRequestTypeDef`, or `Extra` postfix moved).
- gotcha This package provides *type stubs* for `boto3`. You must also install `boto3` itself for your code to run at runtime.
- gotcha These type annotations are only effective when used with a static type checker like `mypy`. Without running `mypy`, you will not get the benefits of type checking.
Install
-
pip install mypy-boto3-eks-auth
Imports
- EKSAuthClient
from mypy_boto3_eks_auth.client import EKSAuthClient
- GetTokenResponseTypeDef
from mypy_boto3_eks_auth.type_defs import GetTokenResponseTypeDef
Quickstart
import boto3
from mypy_boto3_eks_auth.client import EKSAuthClient
from mypy_boto3_eks_auth.type_defs import GetTokenResponseTypeDef
import os
# Type-hint the boto3 client directly for static analysis
eks_auth_client: EKSAuthClient = boto3.client(
"eks-auth",
aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY'),
aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET'),
region_name=os.environ.get('AWS_REGION', 'us-west-2') # EKS is region-specific
)
print(f"Client object type: {type(eks_auth_client)}")
# Demonstrating a method call that mypy would type-check.
# This call requires a valid EKS cluster name and proper AWS credentials to succeed at runtime.
# For quickstart, we wrap it in a try-except as it might fail without real setup.
cluster_name = os.environ.get('EKS_CLUSTER_NAME', 'your-eks-cluster-name')
try:
# This will likely result in an authentication/authorization error without real AWS credentials
# and a valid EKS cluster configured.
response: GetTokenResponseTypeDef = eks_auth_client.get_token(clusterName=cluster_name)
print(f"Successfully called get_token (type checked):")
print(f" Token expiry: {response.get('expiration', 'N/A')}")
except Exception as e:
print(f"Error calling get_token (expected without real setup or valid cluster): {e}")
# To verify type checking, you would run `mypy your_script_name.py`