mypy-boto3-ecr-public Type Annotations
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
- breaking Support for Python 3.8 and older versions has been removed. The library now requires Python 3.9 or newer.
- breaking The package structure has migrated to PEP 561 compliance. While this generally improves compatibility, ensure your type checker is up-to-date and configured correctly.
- breaking TypeDef naming conventions for packed method arguments and conflicting names have changed. For example, `CreateDistributionRequestRequestTypeDef` might become `CreateDistributionRequestTypeDef`, and `Extra` postfixes were moved.
- gotcha This library provides *type stubs* only. You must also install `boto3` (e.g., `pip install boto3`) for your code to run at runtime and interact with AWS.
- gotcha PyCharm users might experience slow performance or high CPU usage due to Literal overloads. The project maintainers recommend using `boto3-stubs-lite` or disabling PyCharm's type checker in such cases.
Install
-
pip install mypy-boto3-ecr-public -
pip install 'boto3-stubs[ecr-public]'
Imports
- ECRPublicClient
from mypy_boto3_ecr_public.client import ECRPublicClient
- DescribeImageTagsPaginator
from mypy_boto3_ecr_public.paginator import DescribeImageTagsPaginator
- RepositoryScanningConfigurationFailureTypeDef
from mypy_boto3_ecr_public.type_defs import RepositoryScanningConfigurationFailureTypeDef
Quickstart
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()