mypy-boto3-workmailmessageflow Type Annotations
mypy-boto3-workmailmessageflow provides type annotations (stubs) for the boto3 WorkMailMessageFlow service. These stubs enhance static analysis, autocomplete, and type checking in IDEs and tools like MyPy. The package is currently at version 1.42.3, generated by mypy-boto3-builder 8.12.0, and typically releases updates in alignment with new boto3 and botocore versions.
Warnings
- breaking As of mypy-boto3-builder version 8.12.0, support for Python 3.8 has been removed across all generated `mypy-boto3` packages, including `mypy-boto3-workmailmessageflow`. Projects using Python 3.8 will encounter issues.
- breaking The `mypy-boto3-builder` (version 8.12.0) migrated to PEP 561 compliant stub-only packages. This might affect how type checkers locate and interpret stubs if your tooling or project setup relies on older assumptions about stub package structure.
- breaking In `mypy-boto3-builder` version 8.9.0, TypeDef naming conventions changed for packed method arguments (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`) and the `Extra` postfix for conflicting TypeDefs was moved. This could break type checking for code explicitly importing or referencing these generated type definitions.
- gotcha `mypy-boto3-workmailmessageflow` provides *only* type annotations, not the `boto3` library itself. You must install `boto3` separately for your code to run at runtime.
- gotcha While some IDEs and `mypy` might infer types, explicitly annotating `boto3.client` calls (e.g., `client: WorkMailMessageFlowClient = boto3.client("workmailmessageflow")`) is highly recommended for optimal autocomplete and precise type checking.
- gotcha PyCharm users might experience slow performance with `Literal` overloads due to a known IDE issue (PY-40997). For resource-constrained environments or performance-sensitive setups, `boto3-stubs-lite` is recommended as an alternative.
Install
-
pip install mypy-boto3-workmailmessageflow boto3
Imports
- WorkMailMessageFlowClient
from mypy_boto3_workmailmessageflow import WorkMailMessageFlowClient
Quickstart
import boto3
from mypy_boto3_workmailmessageflow import WorkMailMessageFlowClient
from os import environ
# Instantiate a WorkMailMessageFlow client with type hints
client: WorkMailMessageFlowClient = boto3.client(
"workmailmessageflow",
region_name=environ.get("AWS_REGION", "us-east-1"),
aws_access_key_id=environ.get("AWS_ACCESS_KEY_ID", ""),
aws_secret_access_key=environ.get("AWS_SECRET_ACCESS_KEY", "")
)
# Example usage: Get raw message content (requires an existing message ID)
# Replace 'your-message-id' with an actual message ID from WorkMailMessageFlow
try:
message_id = environ.get("WORKMAIL_MESSAGE_ID", "your-message-id")
response = client.get_raw_message_content(
messageId=message_id
)
print(f"Successfully retrieved message content for ID: {message_id}")
# The Body is a StreamingBody, read its content
# with response['messageContent']._raw_stream as stream:
# print(stream.read().decode('utf-8'))
except client.exceptions.MessageNotFoundException:
print(f"Message with ID '{message_id}' not found.")
except Exception as e:
print(f"An error occurred: {e}")