mypy-boto3-comprehend type annotations

1.42.3 · active · verified Sat Apr 11

mypy-boto3-comprehend provides type annotations for the `boto3` Comprehend service, compatible with `mypy`, `pyright`, VSCode, PyCharm, and other tools. It is part of the `mypy-boto3` ecosystem, with its types automatically generated by `mypy-boto3-builder`. The library ensures that all public classes and methods of the `boto3` Comprehend service have valid, up-to-date type annotations extracted from `botocore` schemas, including documentation links. The project follows a frequent release cadence, often aligning with `boto3` updates.

Warnings

Install

Imports

Quickstart

This example demonstrates how to obtain a Comprehend client with and without explicit type annotations. Explicitly typing the client with `ComprehendClient` from `mypy_boto3_comprehend` provides full type checking and autocompletion for `boto3` operations on the Comprehend service.

import boto3
from mypy_boto3_comprehend import ComprehendClient
from typing import TYPE_CHECKING

# Boto3 client without explicit typing (type checkers may infer correctly)
client = boto3.client("comprehend")
client.detect_dominant_language(Text="Hello, this is a test.")

# Explicit typing for better IDE support and type checking
if TYPE_CHECKING:
    # In a real scenario, use actual AWS credentials
    # or ensure they are configured via environment variables or ~/.aws/credentials
    session = boto3.Session(region_name='us-east-1') # Or any appropriate region
    typed_client: ComprehendClient = session.client("comprehend")
    
    response = typed_client.detect_dominant_language(Text="Hola, esto es una prueba.")
    print(response['Languages'][0]['LanguageCode'])

view raw JSON →