Examples#
Index > Comprehend > Examples
Auto-generated documentation for Comprehend type annotations stubs module types-boto3-comprehend.
Client#
Implicit type annotations#
Can be used with types-boto3[comprehend]
package installed.
Write your Comprehend
code as usual,
type checking and code completion should work out of the box.
# ComprehendClient usage example
from boto3.session import Session
session = Session()
client = session.client("comprehend") # (1)
result = client.batch_detect_dominant_language() # (2)
- client: ComprehendClient
- result: BatchDetectDominantLanguageResponseTypeDef
# ListDocumentClassificationJobsPaginator usage example
from boto3.session import Session
session = Session()
client = session.client("comprehend") # (1)
paginator = client.get_paginator("list_document_classification_jobs") # (2)
for item in paginator.paginate(...):
print(item) # (3)
- client: ComprehendClient
- paginator: ListDocumentClassificationJobsPaginator
- item: ListDocumentClassificationJobsResponseTypeDef
Explicit type annotations#
With types-boto3-lite[comprehend]
or a standalone types_boto3_comprehend
package, you have to explicitly specify client: ComprehendClient
type annotation.
All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.
# ComprehendClient usage example with type annotations
from boto3.session import Session
from types_boto3_comprehend.client import ComprehendClient
from types_boto3_comprehend.type_defs import BatchDetectDominantLanguageResponseTypeDef
from types_boto3_comprehend.type_defs import BatchDetectDominantLanguageRequestRequestTypeDef
session = Session()
client: ComprehendClient = session.client("comprehend")
kwargs: BatchDetectDominantLanguageRequestRequestTypeDef = {...}
result: BatchDetectDominantLanguageResponseTypeDef = client.batch_detect_dominant_language(**kwargs)
# ListDocumentClassificationJobsPaginator usage example with type annotations
from boto3.session import Session
from types_boto3_comprehend.client import ComprehendClient
from types_boto3_comprehend.paginator import ListDocumentClassificationJobsPaginator
from types_boto3_comprehend.type_defs import ListDocumentClassificationJobsResponseTypeDef
session = Session()
client: ComprehendClient = session.client("comprehend")
paginator: ListDocumentClassificationJobsPaginator = client.get_paginator("list_document_classification_jobs")
for item in paginator.paginate(...):
item: ListDocumentClassificationJobsResponseTypeDef
print(item)