Skip to content

Examples#

Index > CodeArtifact > Examples

Auto-generated documentation for CodeArtifact type annotations stubs module types-boto3-codeartifact.

Client#

Implicit type annotations#

Can be used with types-boto3[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)
  1. client: CodeArtifactClient
  2. 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)
  1. client: CodeArtifactClient
  2. paginator: ListAllowedRepositoriesForGroupPaginator
  3. item: ListAllowedRepositoriesForGroupResultTypeDef

Explicit type annotations#

With types-boto3-lite[codeartifact] or a standalone types_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 types_boto3_codeartifact.client import CodeArtifactClient
from types_boto3_codeartifact.type_defs import AssociateExternalConnectionResultTypeDef
from types_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 types_boto3_codeartifact.client import CodeArtifactClient
from types_boto3_codeartifact.paginator import ListAllowedRepositoriesForGroupPaginator
from types_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)