mypy-boto3-kendra

1.42.3 · active · verified Sat Apr 11

mypy-boto3-kendra provides static type annotations for the `boto3` AWS Kendra service client, enabling tools like MyPy to perform comprehensive static analysis on code interacting with AWS Kendra. It is a generated stub package, part of the larger `mypy-boto3` project which produces type stubs for all `boto3` services. The library is actively maintained and frequently updated, usually in sync with new `boto3` and `botocore` releases, currently at version 1.42.3.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `mypy-boto3-kendra` with `boto3` to get type-checked interactions with the AWS Kendra service. It initializes a Kendra client and lists available indices, leveraging the `KendraClient` and `ListIndicesOutputTypeDef` type hints for static analysis.

import boto3
from mypy_boto3_kendra.client import KendraClient
from mypy_boto3_kendra.type_defs import IndexConfigurationSummaryTypeDef, ListIndicesOutputTypeDef
from typing import List
import os

def list_kendra_indices() -> List[IndexConfigurationSummaryTypeDef]:
    """Lists Kendra indices and returns their summaries."""
    # Ensure AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)
    # For explicit credential provision (if not using implicit chain):
    # client: KendraClient = boto3.client(
    #     "kendra",
    #     aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', ''),
    #     aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', ''),
    #     region_name=os.environ.get('AWS_REGION', 'us-east-1')
    # )
    
    client: KendraClient = boto3.client("kendra")
    
    # Using type hints for the response
    response: ListIndicesOutputTypeDef = client.list_indices()
    
    indices: List[IndexConfigurationSummaryTypeDef] = response.get('IndexConfigurationSummaryItems', [])
    if indices:
        print(f"Found Kendra indices: {[i['Name'] for i in indices]}")
    else:
        print("No Kendra indices found.")
    
    return indices

if __name__ == "__main__":
    list_kendra_indices()

view raw JSON →