mypy-boto3-supplychain
mypy-boto3-supplychain provides type annotations for the `boto3` AWS SupplyChain service, enhancing static type checking with tools like MyPy, Pyright, and improving IDE auto-completion. It is generated by `mypy-boto3-builder` and is currently at version 1.42.3, following the boto3 release cycle. The project maintains an active release cadence, frequently updating stubs to match new AWS service versions and features.
Warnings
- breaking Support for Python 3.8 has been removed in `mypy-boto3-builder` version 8.12.0 and subsequent `mypy-boto3-*` packages. Projects targeting Python 3.8 will no longer receive updates or new type stubs.
- breaking Starting with `mypy-boto3-builder` 8.9.0, there were breaking changes to `TypeDef` naming conventions. Specifically, packed method arguments may use shorter names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`), and conflicting `TypeDef` 'Extra' postfixes were moved to the end.
- gotcha For optimal static analysis and IDE auto-completion (especially in VSCode), explicit type annotations for `boto3.client` and `boto3.resource` calls are often recommended, even though `mypy-boto3` attempts auto-discovery. PyCharm users might experience slow performance with `Literal` overloads, in which case `boto3-stubs-lite` or external type checkers like MyPy/Pyright are suggested.
- gotcha To prevent `mypy-boto3-*` packages from becoming runtime dependencies, it is best practice to wrap all imports of types from these libraries within a `if typing.TYPE_CHECKING:` block. This ensures they are only used during static analysis.
Install
-
pip install mypy-boto3-supplychain boto3
Imports
- SupplyChainClient
from mypy_boto3_supplychain.client import SupplyChainClient
- ListDataIntegrationFlowsOutputTypeDef
from mypy_boto3_supplychain.type_defs import ListDataIntegrationFlowsOutputTypeDef
Quickstart
import boto3
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from mypy_boto3_supplychain.client import SupplyChainClient
from mypy_boto3_supplychain.type_defs import ListDataIntegrationFlowsOutputTypeDef
def get_supply_chain_flows() -> ListDataIntegrationFlowsOutputTypeDef:
# boto3 client creation is untyped at runtime, hence the type hint below
client: SupplyChainClient = boto3.client("supplychain")
response = client.list_data_integration_flows()
print(f"Found {len(response.get('dataIntegrationFlows', []))} data integration flows.")
return response
if __name__ == "__main__":
# Ensure AWS credentials are configured (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY env vars)
# or AWS CLI configuration.
try:
flows = get_supply_chain_flows()
# Accessing typed properties
for flow in flows.get('dataIntegrationFlows', []):
print(f" Flow ID: {flow['dataIntegrationFlowId']}, Status: {flow['status']}")
except Exception as e:
print(f"An error occurred: {e}")
print("Please ensure 'boto3' is installed and AWS credentials are configured.")