Skip to content

Examples#

Index > CodeCommit > Examples

Auto-generated documentation for CodeCommit type annotations stubs module mypy-boto3-codecommit.

Client#

Implicit type annotations#

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

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

# CodeCommitClient usage example

from boto3.session import Session


session = Session()

client = session.client("codecommit")  # (1)
result = client.associate_approval_rule_template_with_repository()  # (2)
  1. client: CodeCommitClient
  2. result: EmptyResponseMetadataTypeDef
# DescribePullRequestEventsPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("describe_pull_request_events")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: CodeCommitClient
  2. paginator: DescribePullRequestEventsPaginator
  3. item: DescribePullRequestEventsOutputTypeDef

Explicit type annotations#

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

# CodeCommitClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_codecommit.client import CodeCommitClient
from mypy_boto3_codecommit.type_defs import EmptyResponseMetadataTypeDef
from mypy_boto3_codecommit.type_defs import AssociateApprovalRuleTemplateWithRepositoryInputRequestTypeDef


session = Session()

client: CodeCommitClient = session.client("codecommit")

kwargs: AssociateApprovalRuleTemplateWithRepositoryInputRequestTypeDef = {...}
result: EmptyResponseMetadataTypeDef = client.associate_approval_rule_template_with_repository(**kwargs)
# DescribePullRequestEventsPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_codecommit.client import CodeCommitClient
from mypy_boto3_codecommit.paginator import DescribePullRequestEventsPaginator
from mypy_boto3_codecommit.type_defs import DescribePullRequestEventsOutputTypeDef


session = Session()
client: CodeCommitClient = session.client("codecommit")

paginator: DescribePullRequestEventsPaginator = client.get_paginator("describe_pull_request_events")
for item in paginator.paginate(...):
    item: DescribePullRequestEventsOutputTypeDef
    print(item)