mypy-boto3-artifact Type Stubs

1.42.13 · active · verified Sat Apr 11

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

Install

Imports

Quickstart

This quickstart demonstrates how to use `mypy-boto3-artifact` type stubs with `boto3` to interact with the AWS Artifact service, specifically listing available reports. It leverages type hints for compile-time validation of client methods and response structures.

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.")

view raw JSON →