Install & Compatibility
Where this runs
tested against v1.43.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.670s · 84.7MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 6.6s · import 0.624s · 82MB
82MB installed
● package 82MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
GreengrassClient
✓ from mypy_boto3_greengrass.client import GreengrassClient
Type hint for the Greengrass service client.
GetCoreDefinitionResponseTypeDef
✓ from mypy_boto3_greengrass.type_defs import GetCoreDefinitionResponseTypeDef
Type hint for the response dictionary of Greengrass operations. Full list of TypeDefs available in documentation.
GreengrassServiceResource
✓ from mypy_boto3_greengrass.service_resource import GreengrassServiceResource
Type hint for the Greengrass service resource (if applicable for the service).
This quickstart demonstrates how to use `mypy-boto3-greengrass` for type hinting your `boto3` Greengrass client. It highlights the use of `TYPE_CHECKING` for conditional imports, ensuring the stubs are only used during static analysis. When `mypy` processes this code, it uses `GreengrassClient` and `GetCoreDefinitionResponseTypeDef` to validate client methods and response structures. At runtime, the standard `boto3` client is used.
import boto3
import os
from typing import TYPE_CHECKING, Dict, Any
# Conditional import for type checking only to avoid runtime dependency
# if mypy-boto3-greengrass is not installed in production environments.
if TYPE_CHECKING:
from mypy_boto3_greengrass.client import GreengrassClient
from mypy_boto3_greengrass.type_defs import GetCoreDefinitionResponseTypeDef
def get_core_definition_name(core_definition_id: str) -> str:
"""
Retrieves the name of a Greengrass core definition using type-hinted boto3.
Type annotations ensure static analysis correctness.
"""
# Initialize boto3 client. mypy-boto3 provides stubs for its methods.
client = boto3.client("greengrass", region_name=os.environ.get("AWS_REGION", "us-east-1"))
# Asserting the client type for static analysis with mypy.
# At runtime, 'client' is a regular boto3 client.
if TYPE_CHECKING:
greengrass_client: GreengrassClient = client
response: GetCoreDefinitionResponseTypeDef = greengrass_client.get_core_definition(
CoreDefinitionId=core_definition_id
)
else:
# Runtime execution uses the actual boto3 client without explicit type assertion.
# This branch is taken if TYPE_CHECKING is False (e.g., in production).
response = client.get_core_definition(CoreDefinitionId=core_definition_id)
# Mypy will now correctly check access to 'Name' and its type
return response['Name']
if __name__ == "__main__":
# For this to make actual AWS calls, ensure AWS_ACCESS_KEY_ID,
# AWS_SECRET_ACCESS_KEY (and optionally AWS_REGION) are set in your environment.
# Otherwise, it will attempt a call that might fail with an AWS error.
print("Note: This example requires AWS credentials for live execution.")
print(" To run 'mypy' on this file, ensure 'mypy boto3 mypy-boto3-greengrass' are installed.")
print(" Example: 'mypy your_script_name.py'")
example_core_id = "your-greengrass-core-definition-id"
if os.environ.get("AWS_ACCESS_KEY_ID") and os.environ.get("AWS_SECRET_ACCESS_KEY"):
print(f"\nAttempting to get Greengrass Core Definition name for ID: {example_core_id}")
try:
core_name = get_core_definition_name(example_core_id)
print(f"Retrieved Core Definition Name: {core_name}")
except Exception as e:
print(f"An error occurred during AWS call: {e}")
print("Please ensure the Core Definition ID is valid and credentials are correct.")
else:
print("\nAWS credentials not found. Skipping live AWS call.")
print("To test type-checking, you can run 'mypy' on this file without credentials.")
Debug
Known issues
breakingSupport for Python 3.8 has been removed in `mypy-boto3-builder` version 8.12.0, affecting all generated `mypy-boto3-*` packages, including `mypy-boto3-greengrass`.fixUpgrade your Python environment to 3.9 or newer.
affects: mypy-boto3-builder >= 8.12.0, mypy-boto3-greengrass >= 1.42.3
breakingTypeDef naming conventions changed in `mypy-boto3-builder` 8.9.0. Specifically, packed method arguments use shorter names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`), and conflicting `Extra` postfixes are moved to the end.fixReview your code for explicit imports or uses of `TypeDef` names and adjust them according to the new conventions.
affects: mypy-boto3-builder >= 8.9.0, mypy-boto3-greengrass >= 1.42.0 (approx)
gotcha`mypy-boto3-greengrass` provides only type annotations; `boto3` itself is a separate runtime dependency and must be installed alongside these stubs for your application to function.fixEnsure `pip install boto3` is executed in your environment.
affects: All
gotchaTo benefit from these type stubs, a static type checker like `mypy` or `pyright` must be installed and configured in your development environment.fixInstall `mypy` (`pip install mypy`) and integrate it into your CI/CD pipeline or IDE.
affects: All
gotchaIt is generally recommended that the major.minor version of `mypy-boto3-greengrass` matches the major.minor version of your installed `boto3` library for optimal compatibility and accuracy of type hints.fixWhen updating `boto3`, also update `mypy-boto3-greengrass` to a compatible version.
affects: All
gotchaFor production deployments, consider using `if TYPE_CHECKING:` blocks for importing `mypy-boto3-*` modules to avoid adding `mypy-boto3-greengrass` as a runtime dependency. Some linters like `pylint` might complain about undefined variables without additional `else: ClientType = object` blocks.fixWrap type stub imports in `if TYPE_CHECKING:` blocks and, if using `pylint`, add `else` branches assigning `object` to client types.
affects: All
Upgrade
Version history
1.43.0latest on PyPI · released Apr 29, 2026
Audit
Dependencies
boto3requiredRuntime dependency for actual AWS SDK functionality. `mypy-boto3-greengrass` provides only type stubs, not the implementation.
mypyrequiredRequired for static type checking. The stubs are consumed by the Mypy checker.
typing-extensionsoptionalMay be required for Python versions < 3.9 to support certain type features, though often handled automatically.