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.

Client usage example
from boto3.session import Session


session = Session()

client = session.client("rekognition")  # (1)
result = client.compare_faces()  # (2)
  1. client: RekognitionClient
  2. result: CompareFacesResponseTypeDef
Paginator 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
Waiter 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.

Client usage example
from boto3.session import Session

from mypy_boto3_rekognition.client import RekognitionClient
from mypy_boto3_rekognition.type_defs import CompareFacesResponseTypeDef
from mypy_boto3_rekognition.type_defs import CompareFacesRequestRequestTypeDef


session = Session()

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

kwargs: CompareFacesRequestRequestTypeDef = {...}
result: CompareFacesResponseTypeDef = client.compare_faces(**kwargs)
Paginator usage example
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)
Waiter usage example
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()