mypy-boto3-chime-sdk-messaging
mypy-boto3-chime-sdk-messaging provides type annotations for the boto3 ChimeSDKMessaging service, enhancing development with static type checking in environments like VSCode, PyCharm, and mypy. It is generated by `mypy-boto3-builder` (currently version 8.12.0) and closely tracks the `boto3` release cycle, with frequent updates to ensure compatibility and comprehensive type hints. The current version is 1.42.3.
Warnings
- breaking Python 3.8 support has been removed by `mypy-boto3-builder` (version 8.12.0). Projects using Python 3.8 will need to upgrade their Python version or use an older `mypy-boto3-builder` version if building stubs locally.
- breaking The `mypy-boto3-builder` (version 8.12.0) migrated to PEP 561 compliant packages. This might require updates to how type checkers resolve stubs, especially in complex project setups.
- breaking In `mypy-boto3-builder` (version 8.9.0), TypeDef names for packed method arguments were shortened (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`), and conflicting `Extra` postfixes were moved (e.g., `CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`). This affects explicit imports of such TypeDefs.
- gotcha To avoid installing `mypy-boto3-chime-sdk-messaging` as a runtime dependency, it is best practice to import specific types within an `if TYPE_CHECKING:` block. This keeps your production environment lighter.
- gotcha PyCharm users might experience slow performance with `Literal` overloads in `mypy-boto3` packages (due to issue PY-40997). For large projects or if performance is an issue, consider using the 'lite' versions (e.g., `boto3-stubs-lite`) which are more RAM-friendly but may require more explicit type annotations.
- gotcha Service names can be renamed or excluded by the `mypy-boto3-builder`. For example, `sms-voice` was removed in builder version 8.11.0. While this specific package is for Chime SDK Messaging, users should be aware that service name changes in `boto3` or `botocore` may lead to corresponding changes in `mypy-boto3` package names.
Install
-
pip install mypy-boto3-chime-sdk-messaging boto3
Imports
- ChimeSDKMessagingClient
from mypy_boto3_chime_sdk_messaging.client import ChimeSDKMessagingClient
- CreateChannelMessageResponseTypeDef
from mypy_boto3_chime_sdk_messaging.type_defs import CreateChannelMessageResponseTypeDef
Quickstart
import boto3
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from mypy_boto3_chime_sdk_messaging.client import ChimeSDKMessagingClient
from mypy_boto3_chime_sdk_messaging.type_defs import CreateChannelMessageResponseTypeDef
def send_chime_message(channel_arn: str, content: str, app_instance_user_arn: str) -> 'CreateChannelMessageResponseTypeDef':
client: ChimeSDKMessagingClient = boto3.client("chime-sdk-messaging", region_name="us-east-1")
response = client.create_channel_message(
ChannelArn=channel_arn,
Content=content,
MessageType="STANDARD",
AppInstanceUserArn=app_instance_user_arn
)
print(f"Message ID: {response.get('ChannelMessage', {}).get('MessageId')}")
return response
# Example usage (replace with actual values for a runnable example)
# if __name__ == "__main__":
# CHANNEL_ARN = os.environ.get('CHIME_CHANNEL_ARN', 'arn:aws:chime:us-east-1:123456789012:app-instance/xxxx/channel/yyyy')
# CONTENT = "Hello from mypy-boto3!"
# APP_INSTANCE_USER_ARN = os.environ.get('CHIME_APP_INSTANCE_USER_ARN', 'arn:aws:chime:us-east-1:123456789012:app-instance-user/zzzz')
#
# if CHANNEL_ARN and APP_INSTANCE_USER_ARN:
# message_response = send_chime_message(CHANNEL_ARN, CONTENT, APP_INSTANCE_USER_ARN)
# print(message_response)
# else:
# print("Please set CHIME_CHANNEL_ARN and CHIME_APP_INSTANCE_USER_ARN environment variables.")