mypy-boto3-codeartifact Type Stubs
mypy-boto3-codeartifact provides type annotations for the `boto3` AWS CodeArtifact service, enhancing type checking for `boto3` users. It's automatically generated by `mypy-boto3-builder`. The current version is 1.42.3, and it follows a frequent release cadence, often mirroring `boto3` updates and `mypy-boto3-builder`'s own release schedule.
Warnings
- breaking Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0, affecting all generated stub packages including `mypy-boto3-codeartifact`. Users on Python 3.8 will not receive type stubs for versions generated with this builder or newer.
- breaking Type Definition naming conventions changed in `mypy-boto3-builder` version 8.9.0. This might affect explicit type hints using `TypeDef` suffixes, for example, `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`.
- gotcha `mypy-boto3-codeartifact` only provides type stubs, not the actual `boto3` library. You must install `boto3` separately for your code to run.
- gotcha For best compatibility, the version of `mypy-boto3-codeartifact` should ideally match the major and minor version of your installed `boto3` library.
- gotcha The builder migrated to PEP 561 compliant packages in version 8.12.0. While this improves type checker compatibility, ensure your type checker is up-to-date and configured correctly to pick up the stubs.
Install
-
pip install boto3 mypy-boto3-codeartifact
Imports
- CodeArtifactClient
from mypy_boto3_codeartifact.client import CodeArtifactClient
- Service Resource, Paginator, Waiter
from mypy_boto3_codeartifact import CodeArtifactClient, CodeArtifactServiceResource, Paginator, Waiter
Quickstart
import boto3
from mypy_boto3_codeartifact.client import CodeArtifactClient
from typing import TYPE_CHECKING
# For runtime, you use boto3 as usual
client = boto3.client("codeartifact")
# For type checking, mypy will infer types based on the stubs
# You can also explicitly annotate:
if TYPE_CHECKING:
typed_client: CodeArtifactClient = boto3.client("codeartifact")
# Example of a typed call (won't run without AWS credentials & region)
# try:
# domain_response = typed_client.list_domains()
# print(domain_response['domains'][0]['name'])
# except Exception as e:
# print(f"Could not list domains: {e}")
print("CodeArtifact client initialized. Type checking will use mypy-boto3-codeartifact stubs.")