Skip to content

Examples#

Index > Rekognition > Examples

Auto-generated documentation for Rekognition type annotations stubs module mypy-boto3-rekognition.

Client#

Implicit type annotations#

Can be used with boto3-stubs[rekognition] package installed.

Write your Rekognition code as usual, type checking and code completion should work out of the box.

# RekognitionClient usage example

from boto3.session import Session


session = Session()

client = session.client("rekognition")  # (1)
result = client.associate_faces()  # (2)
  1. client: RekognitionClient
  2. result: AssociateFacesResponseTypeDef
# DescribeProjectVersionsPaginator usage example

from boto3.session import Session


session = Session()
client = session.client("rekognition")  # (1)

paginator = client.get_paginator("describe_project_versions")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: RekognitionClient
  2. paginator: DescribeProjectVersionsPaginator
  3. item: DescribeProjectVersionsResponseTypeDef
# ProjectVersionRunningWaiter usage example

from boto3.session import Session


session = Session()
client = session.client("rekognition")  # (1)

waiter = client.get_waiter("project_version_running")  # (2)
waiter.wait()
  1. client: RekognitionClient
  2. waiter: ProjectVersionRunningWaiter

Explicit type annotations#

With boto3-stubs-lite[rekognition] or a standalone mypy_boto3_rekognition package, you have to explicitly specify client: RekognitionClient 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.

# RekognitionClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_rekognition.client import RekognitionClient
from mypy_boto3_rekognition.type_defs import AssociateFacesResponseTypeDef
from mypy_boto3_rekognition.type_defs import AssociateFacesRequestRequestTypeDef


session = Session()

client: RekognitionClient = session.client("rekognition")

kwargs: AssociateFacesRequestRequestTypeDef = {...}
result: AssociateFacesResponseTypeDef = client.associate_faces(**kwargs)
# DescribeProjectVersionsPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_rekognition.client import RekognitionClient
from mypy_boto3_rekognition.paginator import DescribeProjectVersionsPaginator
from mypy_boto3_rekognition.type_defs import DescribeProjectVersionsResponseTypeDef


session = Session()
client: RekognitionClient = session.client("rekognition")

paginator: DescribeProjectVersionsPaginator = client.get_paginator("describe_project_versions")
for item in paginator.paginate(...):
    item: DescribeProjectVersionsResponseTypeDef
    print(item)
# ProjectVersionRunningWaiter usage example with type annotations

from boto3.session import Session

from mypy_boto3_rekognition.client import RekognitionClient
from mypy_boto3_rekognition.waiter import ProjectVersionRunningWaiter

session = Session()
client: RekognitionClient = session.client("rekognition")

waiter: ProjectVersionRunningWaiter = client.get_waiter("project_version_running")
waiter.wait()