mypy-boto3-ecr-public Type Annotations

1.42.3 · active · verified Sat Apr 11

mypy-boto3-ecr-public provides static type annotations for the boto3 ECR Public service. It's part of the `boto3-stubs` project, generated by `mypy-boto3-builder` version 8.12.0, ensuring compatibility with boto3 1.42.3. The library enables robust type checking with tools like mypy and pyright, and enhances IDE features such as auto-completion and type hints for AWS service clients. It is actively maintained with releases frequently synchronized with boto3 updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `mypy-boto3-ecr-public` to get type annotations for the ECR Public client and list public repositories. It shows explicit type hinting for the boto3 client.

import boto3
from mypy_boto3_ecr_public.client import ECRPublicClient
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    # Only import for type checking, avoid runtime dependency if not strictly needed
    # Or, rely on the installed mypy-boto3-ecr-public for runtime type discovery
    pass

def list_public_repositories(region: str = "us-east-1") -> None:
    client: ECRPublicClient = boto3.client("ecr-public", region_name=region)
    try:
        response = client.describe_repositories()
        print(f"Public ECR Repositories in {region}:")
        for repo in response.get("repositories", []):
            print(f"  - {repo['repositoryName']} (URI: {repo['repositoryUri']})")
    except Exception as e:
        print(f"Error listing repositories: {e}")

if __name__ == "__main__":
    # Note: AWS credentials (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION)
    # or ~/.aws/credentials are required for boto3 to function.
    list_public_repositories()

view raw JSON →