Type Annotations for boto3 DataZone

1.42.85 · active · verified Sat Apr 11

mypy-boto3-datazone provides type annotations for the boto3 DataZone service, enabling static type checking with tools like mypy, pyright, and enhanced IDE autocomplete. It is part of the `boto3-stubs` ecosystem, generated by `mypy-boto3-builder`. The current version is 1.42.85, released in sync with boto3 versions, ensuring compatibility and a frequent update cadence.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `mypy-boto3-datazone` to add type hints to a boto3 DataZone client. It shows importing the client type and a common `TypeDef` for a response, then using them with a standard `boto3` client call. The `TYPE_CHECKING` block ensures the stub package is only used for type analysis, not runtime.

import boto3
from mypy_boto3_datazone.client import DataZoneClient
from mypy_boto3_datazone.type_defs import ListDomainsOutputTypeDef
from typing import TYPE_CHECKING, cast

if TYPE_CHECKING:
    client: DataZoneClient = boto3.client("datazone")
else:
    client = boto3.client("datazone")

def list_datazone_domains() -> ListDomainsOutputTypeDef:
    """Lists DataZone domains with type hints."""
    # Example: List domains
    response = client.list_domains()
    print(f"Found {len(response.get('items', []))} DataZone domains.")
    return cast(ListDomainsOutputTypeDef, response)

if __name__ == "__main__":
    # Ensure boto3 is configured (e.g., AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
    # For demonstration, we'll assume default config or environment variables.
    try:
        domains = list_datazone_domains()
        for domain in domains.get('items', []):
            print(f"- Domain ID: {domain.get('id')}, Name: {domain.get('name')}")
    except Exception as e:
        print(f"Error listing domains: {e}")
        # In a real application, you'd handle specific boto3 exceptions.

view raw JSON →