{"id":3097,"library":"mypy-boto3-greengrassv2","title":"mypy-boto3-greengrassv2 Type Annotations","description":"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.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["AWS","boto3","mypy","type hints","GreengrassV2","stubs","typing"],"install":[{"cmd":"pip install mypy-boto3-greengrassv2","lang":"bash","label":"Install service-specific stubs"},{"cmd":"pip install 'boto3-stubs[greengrassv2]'","lang":"bash","label":"Install via boto3-stubs extras"}],"dependencies":[{"reason":"This package provides type stubs for boto3. The user's code will depend on boto3 at runtime.","package":"boto3","optional":false}],"imports":[{"note":"Imports directly from boto3 will not provide static type checking. The correct import path is from the mypy-boto3-greengrassv2 package for client type hints.","wrong":"from boto3.client import GreengrassV2Client","symbol":"GreengrassV2Client","correct":"from mypy_boto3_greengrassv2.client import GreengrassV2Client"},{"note":"Type definitions for API response and request structures are available in the 'type_defs' submodule.","symbol":"AssociateClientDeviceWithCoreDeviceEntryTypeDef","correct":"from mypy_boto3_greengrassv2.type_defs import AssociateClientDeviceWithCoreDeviceEntryTypeDef"}],"quickstart":{"code":"from typing import TYPE_CHECKING\nimport boto3\n\nif TYPE_CHECKING:\n    from mypy_boto3_greengrassv2.client import GreengrassV2Client\n    from mypy_boto3_greengrassv2.type_defs import ListCoreDevicesResponseTypeDef\n\ndef list_greengrass_core_devices() -> ListCoreDevicesResponseTypeDef:\n    # Initialize a boto3 client (runtime object)\n    client: GreengrassV2Client = boto3.client(\"greengrassv2\")\n\n    # Use the type-hinted client\n    response: ListCoreDevicesResponseTypeDef = client.list_core_devices()\n    print(\"Found Greengrass Core Devices:\")\n    for device in response.get(\"coreDevices\", []):\n        print(f\"  - {device.get('coreDeviceThingName')} (ARN: {device.get('coreDeviceArn')})\")\n    return response\n\nif __name__ == \"__main__\":\n    # This example requires valid AWS credentials configured in your environment\n    # (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION environment variables)\n    try:\n        list_greengrass_core_devices()\n    except Exception as e:\n        print(f\"An error occurred: {e}\")","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade Python to 3.9+ or pin `mypy-boto3-greengrassv2` to a version compatible with Python 3.8 (e.g., one generated by `mypy-boto3-builder < 8.12.0`).","message":"`mypy-boto3-builder` (which generates this package) removed support for Python 3.8 starting from version 8.12.0. This means `mypy-boto3-greengrassv2` versions generated by `mypy-boto3-builder >= 8.12.0` require Python 3.9 or newer. Projects on Python 3.8 must pin an older version of `mypy-boto3-greengrassv2` or upgrade their Python interpreter.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0 (and dependent mypy-boto3-* packages)"},{"fix":"Update explicit TypeDef imports and usage to reflect the new naming conventions. Refer to the specific service's documentation or the `mypy-boto3-builder` changelog for details.","message":"Starting with `mypy-boto3-builder 8.9.0`, there were breaking changes to TypeDef naming conventions, such as `CreateDistributionRequestRequestTypeDef` becoming `CreateDistributionRequestTypeDef` and conflicting `Extra` postfixes being moved (e.g., `CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`). Code that explicitly imports and uses these TypeDefs may need adjustment.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.9.0 (and dependent mypy-boto3-* packages)"},{"fix":"Always use `from typing import TYPE_CHECKING` and wrap stub imports like `if TYPE_CHECKING: from mypy_boto3_greengrassv2.client import GreengrassV2Client` to ensure they are only active during static analysis.","message":"Forgetting to wrap `mypy-boto3-*` imports within an `if TYPE_CHECKING:` block can inadvertently make the stub package a runtime dependency, which is typically undesirable for production deployments.","severity":"gotcha","affected_versions":"All versions"},{"fix":"To resolve `pylint` warnings, explicitly set the type-hinted variables to `object` in the `else` branch of the `TYPE_CHECKING` block. For example: `else: GreengrassV2Client = object`.","message":"When using `if TYPE_CHECKING:` blocks for stub imports, `pylint` might complain about undefined variables in the `else` branch. This is because `pylint` may not fully understand the `TYPE_CHECKING` guard.","severity":"gotcha","affected_versions":"All versions, specifically when using `pylint`"},{"fix":"Ensure you are installing `mypy-boto3-greengrassv2` or using the `boto3-stubs[greengrassv2]` extra, and not an older or alternative stub package if you want the latest features and fixes from the `mypy-boto3` ecosystem.","message":"Confusion between `boto3-stubs` and `mypy-boto3` packages is common. While `boto3-stubs` was an alternative, `mypy-boto3` (and its specific service packages like `mypy-boto3-greengrassv2`) is the actively maintained and recommended solution for up-to-date and comprehensive type annotations for `boto3`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}