Examples#
Index > CodeCommit > Examples
Auto-generated documentation for CodeCommit type annotations stubs module types-boto3-codecommit.
Client#
Implicit type annotations#
Can be used with types-boto3[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)
- client: CodeCommitClient
- 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)
- client: CodeCommitClient
- paginator: DescribePullRequestEventsPaginator
- item: DescribePullRequestEventsOutputTypeDef
Explicit type annotations#
With types-boto3-lite[codecommit]
or a standalone types_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 types_boto3_codecommit.client import CodeCommitClient
from types_boto3_codecommit.type_defs import EmptyResponseMetadataTypeDef
from types_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 types_boto3_codecommit.client import CodeCommitClient
from types_boto3_codecommit.paginator import DescribePullRequestEventsPaginator
from types_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)