{"id":3060,"library":"mypy-boto3-comprehend","title":"mypy-boto3-comprehend type annotations","description":"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.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["type hints","mypy","boto3","aws","comprehend","stubs","type checking"],"install":[{"cmd":"pip install mypy-boto3-comprehend","lang":"bash","label":"Install standalone package"},{"cmd":"pip install 'boto3-stubs[comprehend]'","lang":"bash","label":"Install as part of boto3-stubs (recommended)"}],"dependencies":[{"reason":"Provides the AWS SDK runtime library that these type annotations are for. Must be installed separately.","package":"boto3","optional":false},{"reason":"Static type checker to utilize these annotations. Alternatively, pyright or an IDE with type checking support can be used.","package":"mypy","optional":true}],"imports":[{"note":"For explicit client typing when using `boto3.client('comprehend')`.","symbol":"ComprehendClient","correct":"from mypy_boto3_comprehend import ComprehendClient"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_comprehend import ComprehendClient\nfrom typing import TYPE_CHECKING\n\n# Boto3 client without explicit typing (type checkers may infer correctly)\nclient = boto3.client(\"comprehend\")\nclient.detect_dominant_language(Text=\"Hello, this is a test.\")\n\n# Explicit typing for better IDE support and type checking\nif TYPE_CHECKING:\n    # In a real scenario, use actual AWS credentials\n    # or ensure they are configured via environment variables or ~/.aws/credentials\n    session = boto3.Session(region_name='us-east-1') # Or any appropriate region\n    typed_client: ComprehendClient = session.client(\"comprehend\")\n    \n    response = typed_client.detect_dominant_language(Text=\"Hola, esto es una prueba.\")\n    print(response['Languages'][0]['LanguageCode'])\n","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or a later version.","message":"Python 3.8 support has been removed across all `mypy-boto3-*` packages, including `mypy-boto3-comprehend`. Projects must use Python 3.9 or newer.","severity":"breaking","affected_versions":"mypy-boto3-builder 8.12.0 and newer (affecting mypy-boto3-comprehend 1.42.3 and newer)"},{"fix":"Ensure your `mypy` or `pyright` configuration and environment are up-to-date and correctly discover PEP 561 stubs. Typically no manual fix is needed for modern setups.","message":"All `mypy-boto3-*` packages, including this one, migrated to PEP 561 compliant distribution. While this is a standard, older toolchains or custom stub paths might require adjustments.","severity":"breaking","affected_versions":"mypy-boto3-builder 8.12.0 and newer (affecting mypy-boto3-comprehend 1.42.3 and newer)"},{"fix":"Ensure `pip install boto3` is executed in your project's environment alongside this stub package.","message":"This package provides *only* type annotations. The `boto3` library itself must be installed in your environment for the code to run. Installing `mypy-boto3-comprehend` does not install `boto3`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consider using `boto3-stubs-lite` instead (e.g., `pip install 'boto3-stubs-lite[comprehend]'`), disabling PyCharm's internal type checker and relying on `mypy` or `pyright` directly, or explicitly typing `session.client()` and `session.resource()` calls.","message":"PyCharm users may experience slow performance or high CPU usage with `boto3-stubs` packages (which `mypy-boto3-comprehend` is part of, or can be installed as an extra). This is due to PyCharm's internal type checker handling of Literal overloads.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}