mypy-boto3-artifact Type Stubs
mypy-boto3-artifact provides a set of type annotations (type stubs) for the `boto3` library's AWS Artifact service, enabling static type checking with tools like MyPy. It is generated using `mypy-boto3-builder` and is currently at version 1.42.13. New versions are released frequently, typically in sync with `boto3` updates and `mypy-boto3-builder` enhancements.
Warnings
- breaking Starting with `mypy-boto3-builder` version 8.12.0, Python 3.8 support has been removed from all generated stub packages, including `mypy-boto3-artifact`. Ensure your environment uses Python 3.9 or newer.
- breaking In `mypy-boto3-builder` version 8.9.0, there were breaking changes to how TypeDef names are generated. TypeDefs for packed method arguments use shorter names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`), and conflicting `Extra` postfixes were moved (`CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`). Your existing type hint code might require updates.
- gotcha Since `mypy-boto3-builder` version 8.12.0, packages have migrated to PEP 561. This means stub packages like `mypy-boto3-artifact` are installed alongside the runtime library (`boto3`) and do not replace it. MyPy automatically discovers these stubs. You should install both `boto3` and the specific `mypy-boto3-SERVICE_NAME` package.
- gotcha `mypy-boto3` uses a separate package for each AWS service. If you need type hints for multiple services (e.g., S3 and Artifact), you must install each corresponding stub package (e.g., `mypy-boto3-s3` and `mypy-boto3-artifact`). There is no single `mypy-boto3` package that includes all service stubs.
Install
-
pip install boto3 mypy-boto3-artifact
Imports
- ArtifactClient
from mypy_boto3_artifact.client import ArtifactClient
- ReportSummaryTypeDef
from mypy_boto3_artifact.type_defs import ReportSummaryTypeDef
Quickstart
import boto3
from mypy_boto3_artifact.client import ArtifactClient
from mypy_boto3_artifact.type_defs import ReportSummaryTypeDef
import os # Used to hint at env vars for auth, though boto3 handles it implicitly
def list_artifact_reports() -> list[ReportSummaryTypeDef]:
# boto3 automatically picks up credentials from environment variables (AWS_ACCESS_KEY_ID, etc.),
# ~/.aws/credentials, or IAM roles.
client: ArtifactClient = boto3.client("artifact")
response = client.list_reports()
return response.get("reports", [])
if __name__ == "__main__":
# For a real application, ensure AWS credentials are configured.
# For example, by setting AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
# in your environment.
print("Attempting to list AWS Artifact reports...")
try:
reports = list_artifact_reports()
if reports:
print(f"Found {len(reports)} artifact reports:")
# Print first 3 reports for brevity
for report in reports[:3]:
print(f" - Name: {report.get('reportName', 'N/A')}, ID: {report.get('reportId', 'N/A')}")
else:
print("No AWS Artifact reports found or access denied.")
except Exception as e:
print(f"Error listing reports: {e}")
print("Please ensure you have valid AWS credentials and appropriate permissions for the 'artifact' service.")