mypy-boto3-greengrassv2 Type Annotations

1.42.3 · active · verified Sat Apr 11

Type annotations for the boto3 GreengrassV2 service (version 1.42.3), generated with `mypy-boto3-builder`. This library provides static type checking for boto3 interactions, enhancing code readability, catching errors early, and improving IDE support. Its releases typically align with boto3 updates and the `mypy-boto3-builder`'s development cycle.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `boto3` GreengrassV2 client with type hints provided by `mypy-boto3-greengrassv2`. It includes an example of listing Greengrass Core Devices and correctly typing the client and the response, leveraging `TYPE_CHECKING` to prevent runtime dependencies on the stub package.

from typing import TYPE_CHECKING
import boto3

if TYPE_CHECKING:
    from mypy_boto3_greengrassv2.client import GreengrassV2Client
    from mypy_boto3_greengrassv2.type_defs import ListCoreDevicesResponseTypeDef

def list_greengrass_core_devices() -> ListCoreDevicesResponseTypeDef:
    # Initialize a boto3 client (runtime object)
    client: GreengrassV2Client = boto3.client("greengrassv2")

    # Use the type-hinted client
    response: ListCoreDevicesResponseTypeDef = client.list_core_devices()
    print("Found Greengrass Core Devices:")
    for device in response.get("coreDevices", []):
        print(f"  - {device.get('coreDeviceThingName')} (ARN: {device.get('coreDeviceArn')})")
    return response

if __name__ == "__main__":
    # This example requires valid AWS credentials configured in your environment
    # (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION environment variables)
    try:
        list_greengrass_core_devices()
    except Exception as e:
        print(f"An error occurred: {e}")

view raw JSON →