mypy-boto3-opensearchserverless Type Stubs

1.42.75 · active · verified Sat Apr 11

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.

Warnings

Install

Imports

Quickstart

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.

import boto3
from typing import TYPE_CHECKING

# Import the specific client stub for type annotation
from mypy_boto3_opensearchserverless.client import OpenSearchServiceServerlessClient

# To make mypy aware of the typed client, use TYPE_CHECKING
if TYPE_CHECKING:
    client: OpenSearchServiceServerlessClient = boto3.client("opensearchserverless")
else:
    client = boto3.client("opensearchserverless")

# Example usage: listing collections
try:
    # This call will be type-checked based on the stub annotations
    response = client.list_collections(maxResults=1)
    print(f"First collection details: {response.get('collectionDetails', [])}")
except Exception as e:
    print(f"Error listing collections (expected if no auth/resources configured): {e}")

# Example of using a TypeDef (e.g., for creating a collection)
# from mypy_boto3_opensearchserverless.type_defs import CreateCollectionRequestTypeDef
# 
# # mypy will validate the structure of this dictionary
# collection_config: CreateCollectionRequestTypeDef = {
#     "name": "my-typed-collection",
#     "type": "SEARCH",
#     "description": "A collection created with type-checked parameters"
# }
# print(f"Collection configuration: {collection_config}")

view raw JSON →