{"id":3657,"library":"mypy-boto3-opensearchserverless","title":"mypy-boto3-opensearchserverless Type Stubs","description":"mypy-boto3-opensearchserverless provides type annotations for the `boto3` OpenSearchServiceServerless client, generated with `mypy-boto3-builder`. It enhances static type checking for your AWS `boto3` code. The current version is 1.42.75, with new releases frequently (typically aligning with `boto3` and `botocore` updates) due to its auto-generated nature.","status":"active","version":"1.42.75","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["boto3","aws","opensearchserverless","typing","mypy","stubs","type-hinting"],"install":[{"cmd":"pip install boto3 mypy mypy-boto3-opensearchserverless","lang":"bash","label":"Install Boto3, Mypy, and Type Stubs"}],"dependencies":[{"reason":"This package provides type stubs for boto3; boto3 itself must be installed to run your code.","package":"boto3","optional":false},{"reason":"mypy is the static type checker that utilizes these stubs for analysis.","package":"mypy","optional":true}],"imports":[{"note":"Type stubs are imported from the 'mypy_boto3_servicename' package, not directly from 'boto3'.","wrong":"from boto3.opensearchserverless import OpenSearchServiceServerlessClient","symbol":"OpenSearchServiceServerlessClient","correct":"from mypy_boto3_opensearchserverless.client import OpenSearchServiceServerlessClient"},{"note":"All generated type definitions (for request/response bodies, etc.) reside in the `type_defs` submodule of the stub package.","wrong":"from boto3.opensearchserverless.type_defs import CreateCollectionRequestTypeDef","symbol":"TypeDefs","correct":"from mypy_boto3_opensearchserverless.type_defs import CreateCollectionRequestTypeDef"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING\n\n# Import the specific client stub for type annotation\nfrom mypy_boto3_opensearchserverless.client import OpenSearchServiceServerlessClient\n\n# To make mypy aware of the typed client, use TYPE_CHECKING\nif TYPE_CHECKING:\n    client: OpenSearchServiceServerlessClient = boto3.client(\"opensearchserverless\")\nelse:\n    client = boto3.client(\"opensearchserverless\")\n\n# Example usage: listing collections\ntry:\n    # This call will be type-checked based on the stub annotations\n    response = client.list_collections(maxResults=1)\n    print(f\"First collection details: {response.get('collectionDetails', [])}\")\nexcept Exception as e:\n    print(f\"Error listing collections (expected if no auth/resources configured): {e}\")\n\n# Example of using a TypeDef (e.g., for creating a collection)\n# from mypy_boto3_opensearchserverless.type_defs import CreateCollectionRequestTypeDef\n# \n# # mypy will validate the structure of this dictionary\n# collection_config: CreateCollectionRequestTypeDef = {\n#     \"name\": \"my-typed-collection\",\n#     \"type\": \"SEARCH\",\n#     \"description\": \"A collection created with type-checked parameters\"\n# }\n# print(f\"Collection configuration: {collection_config}\")","lang":"python","description":"This quickstart demonstrates how to instantiate a type-hinted OpenSearchServiceServerless client using `boto3` and its corresponding `mypy-boto3` stub. It includes an example API call (`list_collections`) and illustrates how to use `TYPE_CHECKING` for optimal type inference. Remember to configure your AWS credentials for actual execution."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer. Ensure your `requires_python` matches.","message":"Python 3.8 is no longer supported. `mypy-boto3-builder` (which generates these stubs) removed support for Python 3.8 across all packages, migrating to PEP 561.","severity":"breaking","affected_versions":">=8.12.0 (builder version, corresponds to stub versions 1.42.x and higher)"},{"fix":"Review your code for `TypeDef` imports and usage, updating names to reflect the simplified structure.","message":"Type Definition names for method arguments may have changed, becoming shorter. For example, `CreateDistributionRequestRequestTypeDef` might become `CreateDistributionRequestTypeDef`.","severity":"breaking","affected_versions":">=8.9.0 (builder version, check specific stub versions for impact)"},{"fix":"Ensure you `pip install boto3` alongside `mypy-boto3-opensearchserverless`.","message":"This package provides only type stubs. The actual `boto3` library must be installed separately for your code to run.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install `mypy` (`pip install mypy`) and run `mypy your_script.py` to leverage the type annotations.","message":"While the stubs provide type hints, `mypy` itself is required to perform static type checking. Simply installing the stubs does not automatically enable type checks.","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"}