Type Annotations for boto3 EKS

1.42.85 · active · verified Sat Apr 11

mypy-boto3-eks provides high-quality type annotations for the boto3 EKS client and service-specific types, enabling static type checking with Mypy and enhancing IDE autocompletion. It is part of the larger `mypy-boto3` ecosystem, generated by `mypy-boto3-builder`. The current version is 1.42.85, and releases are frequent, typically tracking `boto3` versions closely.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `mypy-boto3-eks` to add type hints to your `boto3` EKS client interactions. It shows importing the `EKSClient` type and a response `TypeDef`, allowing Mypy to validate your code and IDEs to provide better autocompletion.

import boto3
from mypy_boto3_eks.client import EKSClient
from mypy_boto3_eks.type_defs import ListClustersResponseTypeDef

# Initialize a Boto3 EKS client with type hinting from mypy-boto3-eks
client: EKSClient = boto3.client("eks")

# Call a client method and ensure the response is correctly typed
response: ListClustersResponseTypeDef = client.list_clusters()

print("Found EKS clusters:")
for cluster in response.get("clusters", []):
    print(f"- {cluster['name']} (version: {cluster.get('version', 'N/A')})")

# mypy will now provide checks for attribute access and types
# Example: if 'nextToken' is present, its type is known
if 'nextToken' in response:
    next_token: str = response['nextToken']
    print(f"Next Token: {next_token}")

view raw JSON →