{"id":3047,"library":"mypy-boto3-cloudsearch","title":"mypy-boto3-cloudsearch Type Annotations","description":"mypy-boto3-cloudsearch provides comprehensive type annotations for the `boto3` AWS CloudSearch service, enabling static type checking for improved code quality and developer experience. It is automatically generated with `mypy-boto3-builder` and is compatible with various IDEs and type checkers like `mypy` and `pyright`. Currently at version 1.42.3, its release cycle is frequent, aligning with updates to the underlying `boto3` library.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["mypy","boto3","aws","cloudsearch","type-hints","type-stubs","static-analysis","pep-561"],"install":[{"cmd":"pip install mypy-boto3-cloudsearch boto3","lang":"bash","label":"Install type stubs and boto3"}],"dependencies":[{"reason":"This package provides type annotations for boto3; boto3 itself must be installed for runtime execution.","package":"boto3"}],"imports":[{"note":"Main client type for CloudSearch service.","symbol":"CloudSearchClient","correct":"from mypy_boto3_cloudsearch import CloudSearchClient"},{"note":"Importing TypedDicts for structured input/output type checking.","symbol":"OptionStatusTypeDef","correct":"from mypy_boto3_cloudsearch.type_defs import OptionStatusTypeDef"},{"note":"Importing Literals for string-based enum type checking.","symbol":"AlgorithmicStemmingType","correct":"from mypy_boto3_cloudsearch.literals import AlgorithmicStemmingType"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING\n\n# Only import type stubs during type checking to avoid runtime dependency\nif TYPE_CHECKING:\n    from mypy_boto3_cloudsearch import CloudSearchClient\n    from mypy_boto3_cloudsearch.type_defs import DomainStatusTypeDef\n\n\ndef list_cloudsearch_domains(region_name: str = 'us-east-1') -> None:\n    # boto3 client is untyped by default without explicit type hints or stubs\n    client = boto3.client('cloudsearch', region_name=region_name)\n\n    # With mypy-boto3-cloudsearch, this client will be type-checked\n    if TYPE_CHECKING:\n        typed_client: CloudSearchClient = client\n        response: DomainStatusTypeDef = typed_client.describe_domains()\n        print(f\"CloudSearch Domains: {response.get('DomainStatusList')}\")\n    else:\n        # Runtime execution path\n        response = client.describe_domains()\n        print(f\"CloudSearch Domains: {response.get('DomainStatusList')}\")\n\n\n# Example usage (will only execute at runtime if TYPE_CHECKING is False)\n# For full functionality, you'll need AWS credentials configured.\n# list_cloudsearch_domains()","lang":"python","description":"This example demonstrates how to initialize a `boto3` CloudSearch client and leverage the `mypy-boto3-cloudsearch` type annotations for static analysis. It includes an `if TYPE_CHECKING:` block, which is a common pattern to ensure the type stub imports do not create runtime dependencies."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or a later version.","message":"As of mypy-boto3-builder 8.12.0 (which generates this package), Python 3.8 is no longer supported. Ensure your project uses Python 3.9 or newer.","severity":"breaking","affected_versions":">=8.12.0 of mypy-boto3-builder and generated packages"},{"fix":"Review your code for explicit TypeDef annotations and adjust names according to the new conventions as indicated by your type checker.","message":"mypy-boto3-builder 8.9.0 introduced naming convention changes for TypeDefs (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). While not specific to CloudSearch in the release notes, similar changes may affect other services' TypeDefs, potentially requiring updates to explicit type hints.","severity":"breaking","affected_versions":">=8.9.0 of mypy-boto3-builder and generated packages"},{"fix":"Ensure `boto3` is included in your project's dependencies (e.g., `pip install boto3`).","message":"This package only provides type annotations. For your code to run, the `boto3` library must also be installed in your environment.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use `from typing import TYPE_CHECKING` and conditional imports: `if TYPE_CHECKING: from mypy_boto3_cloudsearch import CloudSearchClient`.","message":"To prevent type stub packages from becoming runtime dependencies, especially in production environments, it is recommended to wrap `mypy-boto3-cloudsearch` imports within a `if TYPE_CHECKING:` block.","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"}