Examples#
Index > CodeArtifact > Examples
Auto-generated documentation for CodeArtifact type annotations stubs module mypy-boto3-codeartifact.
Client#
Implicit type annotations#
Can be used with boto3-stubs[codeartifact]
package installed.
Write your CodeArtifact
code as usual,
type checking and code completion should work out of the box.
# CodeArtifactClient usage example
from boto3.session import Session
session = Session()
client = session.client("codeartifact") # (1)
result = client.associate_external_connection() # (2)
- client: CodeArtifactClient
- result: AssociateExternalConnectionResultTypeDef
# ListAllowedRepositoriesForGroupPaginator usage example
from boto3.session import Session
session = Session()
client = session.client("codeartifact") # (1)
paginator = client.get_paginator("list_allowed_repositories_for_group") # (2)
for item in paginator.paginate(...):
print(item) # (3)
- client: CodeArtifactClient
- paginator: ListAllowedRepositoriesForGroupPaginator
- item: ListAllowedRepositoriesForGroupResultTypeDef
Explicit type annotations#
With boto3-stubs-lite[codeartifact]
or a standalone mypy_boto3_codeartifact
package, you have to explicitly specify client: CodeArtifactClient
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.
# CodeArtifactClient usage example with type annotations
from boto3.session import Session
from mypy_boto3_codeartifact.client import CodeArtifactClient
from mypy_boto3_codeartifact.type_defs import AssociateExternalConnectionResultTypeDef
from mypy_boto3_codeartifact.type_defs import AssociateExternalConnectionRequestRequestTypeDef
session = Session()
client: CodeArtifactClient = session.client("codeartifact")
kwargs: AssociateExternalConnectionRequestRequestTypeDef = {...}
result: AssociateExternalConnectionResultTypeDef = client.associate_external_connection(**kwargs)
# ListAllowedRepositoriesForGroupPaginator usage example with type annotations
from boto3.session import Session
from mypy_boto3_codeartifact.client import CodeArtifactClient
from mypy_boto3_codeartifact.paginator import ListAllowedRepositoriesForGroupPaginator
from mypy_boto3_codeartifact.type_defs import ListAllowedRepositoriesForGroupResultTypeDef
session = Session()
client: CodeArtifactClient = session.client("codeartifact")
paginator: ListAllowedRepositoriesForGroupPaginator = client.get_paginator("list_allowed_repositories_for_group")
for item in paginator.paginate(...):
item: ListAllowedRepositoriesForGroupResultTypeDef
print(item)