mypy-boto3-workmail Type Annotations
mypy-boto3-workmail provides type annotations for the `boto3` WorkMail service, enabling static type checking with tools like MyPy and Pyright for `boto3.client('workmail')` calls. It is automatically generated by `mypy-boto3-builder` and is frequently updated in sync with `boto3` and `botocore` releases to provide up-to-date type hints.
Warnings
- breaking Python 3.8 support was removed starting with `mypy-boto3-builder` version 8.12.0. If you are using an older Python version, you must use an older `mypy-boto3-workmail` release or upgrade your Python environment.
- breaking TypeDef naming conventions changed in `mypy-boto3-builder` version 8.9.0. Specifically, 'RequestRequestTypeDef' was shortened to 'RequestTypeDef' and 'Extra' postfixes moved to the end. This can break existing explicit `TypeDef` imports.
- gotcha Pylint may raise `undefined-variable` warnings for type-hinted `boto3` clients when `mypy-boto3-workmail` is installed. This is due to how Pylint handles the `TYPE_CHECKING` guard.
- gotcha This package provides *only* type annotations. You must also install the `boto3` library to actually make AWS API calls at runtime.
- gotcha For PyCharm users, there can be performance issues with `Literal` overloads provided by `mypy-boto3-workmail`. PyCharm's indexing might be slow.
Install
-
pip install mypy-boto3-workmail boto3 -
pip install 'boto3-stubs[workmail]' boto3
Imports
- WorkMailClient
from mypy_boto3_workmail.client import WorkMailClient
- AccessControlRuleTypeDef
from mypy_boto3_workmail.type_defs import AccessControlRuleTypeDef
- AccessControlRuleEffectType
from mypy_boto3_workmail.literals import AccessControlRuleEffectType
Quickstart
import boto3
from mypy_boto3_workmail.client import WorkMailClient
from typing import TYPE_CHECKING
if TYPE_CHECKING:
client: WorkMailClient
else:
client = boto3.client("workmail")
# Example usage: List organizations
# client = boto3.client("workmail") # In actual runtime, use this line
try:
response = client.list_organizations(MaxResults=5) # Type-checked call
for org in response.get("OrganizationSummaries", []):
print(f"Organization ID: {org['OrganizationId']}, State: {org['State']}")
except client.exceptions.OrganizationNotFoundException:
print("No WorkMail organizations found.")
except Exception as e:
print(f"An error occurred: {e}")