{"id":3672,"library":"mypy-boto3-pinpoint-email","title":"Type Annotations for Boto3 Pinpoint Email","description":"mypy-boto3-pinpoint-email provides comprehensive type annotations for the Amazon Pinpoint Email Service client in the boto3 library, ensuring static type checking with tools like Mypy, improved IDE auto-completion, and early detection of potential runtime errors. It is currently at version 1.42.3 and is actively maintained with updates released in sync with boto3 and botocore, generated by the mypy-boto3-builder.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["AWS","Boto3","Type Checking","Mypy","Pinpoint","Email"],"install":[{"cmd":"pip install boto3 mypy-boto3-pinpoint-email","lang":"bash","label":"Install package"}],"dependencies":[{"reason":"Runtime dependency for interacting with AWS services.","package":"boto3"},{"reason":"Static type checker, as this library provides type stubs for it.","package":"mypy","optional":true},{"reason":"Requires Python 3.9 or higher due to recent builder changes.","package":"python","version":">=3.9"}],"imports":[{"note":"For type hints, import the client type directly from mypy_boto3_pinpoint_email.client. Relying solely on boto3.client('pinpoint-email') will not provide full type-checking benefits without explicit annotation or other mypy-boto3 features.","wrong":"from boto3.client import pinpointemail","symbol":"PinpointEmailClient","correct":"from mypy_boto3_pinpoint_email.client import PinpointEmailClient"},{"note":"Standard import for creating a boto3 session.","symbol":"Session","correct":"from boto3.session import Session"}],"quickstart":{"code":"import os\nfrom typing import TYPE_CHECKING\n\nimport boto3\nfrom boto3.session import Session\n\n# Import PinpointEmailClient for type hinting, conditionally for runtime performance\nif TYPE_CHECKING:\n    from mypy_boto3_pinpoint_email.client import PinpointEmailClient\n    from mypy_boto3_pinpoint_email.type_defs import SendEmailResponseTypeDef\n\ndef send_pinpoint_email(recipient_email: str, sender_email: str, subject: str, body: str) -> None:\n    \"\"\"Sends an email using AWS Pinpoint Email service.\"\"\"\n    session = Session()\n    client: 'PinpointEmailClient' = session.client(\"pinpoint-email\")\n\n    response: 'SendEmailResponseTypeDef' = client.send_email(\n        FromEmailAddress=sender_email,\n        Destination={\n            'ToAddresses': [\n                recipient_email,\n            ],\n        },\n        Content={\n            'Simple': {\n                'Subject': {\n                    'Data': subject,\n                    'Charset': 'UTF-8'\n                },\n                'Body': {\n                    'Text': {\n                        'Data': body,\n                        'Charset': 'UTF-8'\n                    }\n                }\n            }\n        }\n    )\n    print(f\"Email sent! Message ID: {response['MessageId']}\")\n\nif __name__ == \"__main__\":\n    # Replace with your verified sender and recipient email addresses\n    # Ensure these are set as environment variables for production\n    SENDER = os.environ.get('PINPOINT_SENDER_EMAIL', 'verified@example.com')\n    RECIPIENT = os.environ.get('PINPOINT_RECIPIENT_EMAIL', 'recipient@example.com')\n    EMAIL_SUBJECT = \"Hello from mypy-boto3 Pinpoint Email!\"\n    EMAIL_BODY = \"This is a test email sent using AWS Pinpoint Email with type annotations.\"\n\n    if SENDER == 'verified@example.com' or RECIPIENT == 'recipient@example.com':\n        print(\"Please set PINPOINT_SENDER_EMAIL and PINPOINT_RECIPIENT_EMAIL environment variables.\")\n        print(\"Make sure the sender email is verified in AWS Pinpoint Email.\")\n    else:\n        send_pinpoint_email(RECIPIENT, SENDER, EMAIL_SUBJECT, EMAIL_BODY)\n","lang":"python","description":"This quickstart demonstrates how to initialize the Pinpoint Email client with type annotations and send a simple email. It uses environment variables for sender and recipient emails for safe execution."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or a later version.","message":"As of mypy-boto3-builder 8.12.0, Python 3.8 support has been removed. Ensure your projects use Python 3.9 or newer.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0 (affecting mypy-boto3-pinpoint-email >= 1.42.0)"},{"fix":"Consult the official mypy-boto3 documentation for the updated TypeDef names and adjust your import statements and type annotations accordingly.","message":"Type definition (TypeDef) naming conventions underwent breaking changes in mypy-boto3-builder 8.9.0. This may affect direct imports of TypeDefs from `mypy_boto3_pinpoint_email.type_defs` or similar modules, potentially leading to 'name not found' errors.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.9.0 (affecting mypy-boto3-pinpoint-email versions generated by it)"},{"fix":"Always use explicit type annotations for boto3 clients and resources: `client: 'PinpointEmailClient' = session.client('pinpoint-email')`.","message":"For optimal IDE auto-completion and type hinting, especially in VSCode or PyCharm, explicit type annotations are recommended when obtaining a client, e.g., `client: PinpointEmailClient = session.client('pinpoint-email')`.","severity":"gotcha","affected_versions":"All"},{"fix":"Implement conditional type assignment: `if TYPE_CHECKING: from mypy_boto3_pinpoint_email.client import PinpointEmailClient else: PinpointEmailClient = object`.","message":"Pylint may report undefined variable errors when using `typing.TYPE_CHECKING` guards. A workaround is to conditionally assign `object` to types when `TYPE_CHECKING` is false.","severity":"gotcha","affected_versions":"All"},{"fix":"Always verify service names and corresponding stub package imports against the latest mypy-boto3 documentation, especially after a boto3 or mypy-boto3-builder update.","message":"While not directly for `pinpoint-email`, a related service, `sms-voice`, was deprecated in mypy-boto3-builder 8.11.0 in favor of `pinpoint-sms-voice`. This highlights a general pattern where AWS service name changes can lead to stub package changes, requiring updates to imports for affected services.","severity":"deprecated","affected_versions":"mypy-boto3-builder >= 8.11.0"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}