{"id":3119,"library":"mypy-boto3-opensearch","title":"mypy-boto3-opensearch type stubs","description":"mypy-boto3-opensearch provides static type annotations for the boto3 OpenSearchService client and its data structures. It's part of the `mypy-boto3` project, which programmatically generates up-to-date type stubs for all boto3 services. The library's releases closely follow boto3's release cadence, ensuring compatibility with the latest AWS SDK features. The current version is 1.42.81.","status":"active","version":"1.42.81","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["boto3","mypy","aws","opensearch","types","stubs","type-checking"],"install":[{"cmd":"pip install mypy-boto3-opensearch","lang":"bash","label":"Install library"}],"dependencies":[{"reason":"Provides the AWS SDK for Python that these stubs annotate.","package":"boto3"},{"reason":"Provides backported typing features for older Python versions, automatically installed when needed.","package":"typing-extensions","optional":true}],"imports":[{"symbol":"OpenSearchServiceClient","correct":"from mypy_boto3_opensearch.client import OpenSearchServiceClient"},{"symbol":"ListDomainNamesResponseTypeDef","correct":"from mypy_boto3_opensearch.type_defs import ListDomainNamesResponseTypeDef"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_opensearch.client import OpenSearchServiceClient\nfrom mypy_boto3_opensearch.type_defs import ListDomainNamesResponseTypeDef\nimport os\n\n# Ensure AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)\n# For demonstration, using environment variables if available\naws_access_key_id = os.environ.get('AWS_ACCESS_KEY_ID', 'YOUR_ACCESS_KEY')\naws_secret_access_key = os.environ.get('AWS_SECRET_ACCESS_KEY', 'YOUR_SECRET_KEY')\naws_session_token = os.environ.get('AWS_SESSION_TOKEN', None)\n\n# Initialize the boto3 client for OpenSearchService, type-hinted for mypy-boto3 stubs\nclient: OpenSearchServiceClient = boto3.client(\n    \"opensearch\",\n    region_name=\"us-east-1\",\n    aws_access_key_id=aws_access_key_id,\n    aws_secret_access_key=aws_secret_access_key,\n    aws_session_token=aws_session_token\n)\n\ntry:\n    # Use the client; type-checking will now be active when running `mypy`\n    response: ListDomainNamesResponseTypeDef = client.list_domain_names()\n    print(\"OpenSearch Domains:\")\n    if response.get(\"DomainNames\"):\n        for domain in response[\"DomainNames\"]:\n            print(f\"- {domain.get('DomainName')}\")\n    else:\n        print(\n            \"No domains found in us-east-1 region or credentials not configured correctly.\"\n        )\nexcept Exception as e:\n    print(f\"Error listing domains: {e}\")\n\n# To verify type checking, save this code as `your_script.py` and run `mypy your_script.py` in your terminal.","lang":"python","description":"This quickstart demonstrates how to use the `mypy-boto3-opensearch` stubs with a `boto3` OpenSearchService client. It initializes a type-hinted client, calls `list_domain_names`, and prints the results. Remember to have `boto3` installed and AWS credentials configured. The example uses environment variables for credentials, but `boto3` supports various credential providers. Run `mypy your_script.py` to see type checking in action."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher.","message":"Python 3.8 support has been removed. Projects using `mypy-boto3-opensearch` must use Python 3.9 or newer.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0 (affecting stub packages generated from this builder version onwards)"},{"fix":"Ensure your packaging and build tools are up-to-date and compatible with PEP 561. Reinstalling packages might resolve issues.","message":"The `mypy-boto3` ecosystem migrated to PEP 561 compliant packages. This improves how type checkers discover stubs but might require updates to custom build systems or environments that expect older packaging structures.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0 (affecting stub packages generated from this builder version onwards)"},{"fix":"Review your codebase for TypeDef usages and update names according to the new conventions if they were affected.","message":"Some TypeDef names were changed for improved consistency (e.g., `CreateDistributionRequestRequestTypeDef` to `CreateDistributionRequestTypeDef`). This change applies broadly across services and might affect custom type hints for OpenSearchService-related types.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.9.0 (affecting stub packages generated from this builder version onwards)"},{"fix":"Ensure both `boto3` and `mypy-boto3-opensearch` are installed (`pip install boto3 mypy-boto3-opensearch`).","message":"`mypy-boto3-opensearch` provides type annotations for `boto3`, it is not a replacement for `boto3` itself. You must `pip install boto3` separately.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install `mypy` (`pip install mypy`) and integrate it into your development workflow.","message":"This library provides type *stubs*. To actually perform type checking, you need to install and run `mypy` (or another compatible type checker) on your codebase.","severity":"gotcha","affected_versions":"All versions"},{"fix":"When creating a client, use `boto3.client(\"opensearch\")`.","message":"The service name for OpenSearch in `boto3.client()` is `opensearch`, not `opensearchservice` or `os`.","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"}