{"id":1848,"library":"mypy-boto3-ecr","title":"mypy-boto3-ecr Type Stubs","description":"mypy-boto3-ecr provides type annotations for the AWS Elastic Container Registry (ECR) service client within `boto3`. These stubs allow static type checkers like MyPy to validate usage of ECR API calls, improving code reliability and developer experience. The current version is 1.42.86, and packages are updated frequently, typically in sync with `boto3` and `botocore` releases.","status":"active","version":"1.42.86","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["boto3","aws","mypy","typing","stubs","ecr","type-annotations"],"install":[{"cmd":"pip install mypy-boto3-ecr","lang":"bash","label":"Install package"}],"dependencies":[{"reason":"Provides the runtime functionality for which these are type stubs. It must be installed separately.","package":"boto3"},{"reason":"Required for full type hint compatibility on Python versions older than 3.11, especially for `NotRequired` and `TypeAlias`.","package":"typing-extensions","optional":true}],"imports":[{"note":"Type stubs are provided by `mypy_boto3_ecr`, not directly from `boto3`.","wrong":"from boto3.client import ECRClient","symbol":"ECRClient","correct":"from mypy_boto3_ecr import ECRClient"},{"symbol":"DescribeRepositoriesPaginator","correct":"from mypy_boto3_ecr.paginator import DescribeRepositoriesPaginator"},{"symbol":"ImageScanFindingsWaiter","correct":"from mypy_boto3_ecr.waiter import ImageScanFindingsWaiter"},{"symbol":"RepositoryTypeDef","correct":"from mypy_boto3_ecr.type_defs import RepositoryTypeDef"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_ecr import ECRClient\n\ndef list_ecr_repos(ecr_client: ECRClient) -> None:\n    \"\"\"Lists ECR repositories with type hints.\"\"\"\n    print(f\"Listing ECR repositories in region {ecr_client.meta.region_name}:\")\n    try:\n        response = ecr_client.describe_repositories()\n        repositories = response.get('repositories', [])\n        if repositories:\n            for repo in repositories:\n                print(f\"- {repo['repositoryName']} (URI: {repo['repositoryUri']})\")\n        else:\n            print(\"No ECR repositories found.\")\n    except Exception as e:\n        print(f\"Error listing repositories: {e}\")\n\nif __name__ == \"__main__\":\n    # Ensure AWS credentials are configured (e.g., via ~/.aws/credentials or env vars)\n    # The actual client object comes from boto3, mypy-boto3-ecr provides the type annotation.\n    ecr_client: ECRClient = boto3.client(\n        \"ecr\",\n        region_name=\"us-east-1\",\n        aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', ''),\n        aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', '')\n    )\n    list_ecr_repos(ecr_client)\n","lang":"python","description":"This example demonstrates how to use `mypy-boto3-ecr` to type hint a `boto3` ECR client. It lists your ECR repositories, showing how the `ECRClient` type ensures correct method calls and access to response dict keys."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or a later version.","message":"Python 3.8 is no longer supported for any `mypy-boto3` packages, including `mypy-boto3-ecr`, as of `mypy-boto3-builder` version 8.12.0. Users on Python 3.8 will need to upgrade to Python 3.9 or newer.","severity":"breaking","affected_versions":"mypy-boto3-builder>=8.12.0, mypy-boto3-ecr>=1.42.86"},{"fix":"Ensure `pip install boto3` is executed in your environment alongside `pip install mypy-boto3-ecr`.","message":"This package only provides type stubs. You must install `boto3` separately for runtime functionality. `mypy-boto3-ecr` does not include the AWS SDK itself.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Periodically update both `boto3` and `mypy-boto3-ecr` (`pip install --upgrade boto3 mypy-boto3-ecr`). Check the `mypy-boto3-builder` release notes for details on which `boto3` version a stub release targets.","message":"Type stubs are generated for specific `boto3` and `botocore` versions. Mismatches between your installed `boto3` version and the `mypy-boto3-ecr` stubs can lead to incorrect type checking or missing attributes/methods. It's recommended to keep `boto3` and `mypy-boto3-ecr` versions as close as possible.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update `TypeDef` references in your code to match the new shorter names by inspecting the `.type_defs` module or referring to the `mypy-boto3` documentation.","message":"As of `mypy-boto3-builder` 8.9.0, some `TypeDef` names were shortened (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). If you manually referenced these types, your code might break.","severity":"breaking","affected_versions":"mypy-boto3-builder>=8.9.0, mypy-boto3-ecr>=1.42.x (corresponding to builder v8.9.0+)"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}