mypy-boto3-connect-contact-lens type stubs
mypy-boto3-connect-contact-lens provides type annotations for the boto3 Connect Contact Lens service, ensuring static type checking for your AWS interactions. It's automatically generated by `mypy-boto3-builder` and aims to keep parity with `boto3` releases, providing updated stubs frequently.
Warnings
- breaking Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0 (which generates these stubs). Projects using this library now require Python 3.9 or newer.
- breaking Several TypeDef naming conventions changed in `mypy-boto3-builder` version 8.9.0. Specifically, argument TypeDefs were shortened (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`) and conflicting `Extra` postfixes moved to the end (e.g., `CreateDistributionExtraRequestTypeDef` became `CreateDistributionRequestExtraTypeDef`).
- gotcha mypy-boto3 stubs are designed to match specific `boto3` versions. To ensure correct type checking, you should always keep your `mypy-boto3-*` packages in sync with your installed `boto3` version.
- gotcha When using `boto3.client('service-name')`, `mypy` will automatically pick up the installed type stubs, so explicit `from mypy_boto3_service_name.client import ServiceClient` imports are not strictly required for basic client usage. However, for accessing specific `TypeDef` classes or for clearer function signatures, explicit imports are still necessary.
Install
-
pip install mypy-boto3-connect-contact-lens
Imports
- ConnectContactLensClient
from mypy_boto3_connect_contact_lens.client import ConnectContactLensClient
- Service Resource, Paginator, Waiter types
from mypy_boto3_connect_contact_lens import ConnectContactLensClient, ConnectContactLensServiceResource, Paginator, Waiter
- TypeDefs
from mypy_boto3_connect_contact_lens.type_defs import ListRealtimeContactAnalysisSegmentsRequestRequestTypeDef
Quickstart
import boto3
from mypy_boto3_connect_contact_lens.client import ConnectContactLensClient
from mypy_boto3_connect_contact_lens.type_defs import ListRealtimeContactAnalysisSegmentsRequestRequestTypeDef
import os
# mypy will infer the type from boto3.client if stubs are installed
client: ConnectContactLensClient = boto3.client(
"connect-contact-lens",
aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY'),
aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET'),
region_name=os.environ.get('AWS_REGION', 'us-east-1')
)
def list_segments(client: ConnectContactLensClient):
params: ListRealtimeContactAnalysisSegmentsRequestRequestTypeDef = {
"InstanceId": "your-instance-id", # Replace with your Connect instance ID
"ContactId": "your-contact-id" # Replace with a valid Contact ID
}
try:
response = client.list_realtime_contact_analysis_segments(**params)
print("Segments found:", response.get("Segments", []))
except client.exceptions.ResourceNotFoundException:
print("Instance or Contact not found. Please provide valid IDs.")
except Exception as e:
print(f"An error occurred: {e}")
# Example usage (requires valid AWS credentials and resource IDs for actual execution)
# list_segments(client)