{"id":8734,"library":"types-aiobotocore-ses","title":"Type Annotations for aiobotocore SES","description":"The `types-aiobotocore-ses` library provides static type annotations for `aiobotocore`'s SES (Simple Email Service) client. Currently at version 3.4.0, it is generated by `mypy-boto3-builder 8.12.0` and enhances development with `mypy`, `pyright`, and IDE auto-completion for asynchronous AWS operations. It is part of a larger project offering type stubs for various `aiobotocore` services, with releases generally aligned with `aiobotocore` versions.","status":"active","version":"3.4.0","language":"en","source_language":"en","source_url":"https://github.com/youtype/types-aiobotocore","tags":["python","aws","aiobotocore","types","mypy","SES","type-hints","async"],"install":[{"cmd":"pip install types-aiobotocore-ses","lang":"bash","label":"Install only SES types"},{"cmd":"pip install 'types-aiobotocore[ses]' # Recommended for managing multiple service types","lang":"bash","label":"Install via main types-aiobotocore package"}],"dependencies":[{"reason":"Provides the runtime functionality for AWS asynchronous clients. This package only adds type annotations.","package":"aiobotocore","optional":false},{"reason":"Requires Python 3.9 or newer.","package":"python","optional":false}],"imports":[{"symbol":"SESClient","correct":"from types_aiobotocore_ses.client import SESClient"},{"note":"Type definitions (TypedDicts) are located in the `type_defs` submodule, not directly in `client`.","wrong":"from types_aiobotocore_ses.client import SendEmailRequestTypeDef","symbol":"SendEmailRequestTypeDef","correct":"from types_aiobotocore_ses.type_defs import SendEmailRequestTypeDef"},{"symbol":"BehaviorOnMXFailureType","correct":"from types_aiobotocore_ses.literals import BehaviorOnMXFailureType"}],"quickstart":{"code":"import asyncio\nfrom typing import TYPE_CHECKING\n\nfrom aiobotocore.session import get_session\n\n# These imports are only for type checking and won't be bundled at runtime\nif TYPE_CHECKING:\n    from types_aiobotocore_ses.client import SESClient\n    from types_aiobotocore_ses.type_defs import SendEmailResponseTypeDef\n\nasync def send_test_email(recipient: str, sender: str, subject: str, body: str):\n    session = get_session()\n    async with session.create_client(\"ses\", region_name=\"us-east-1\") as client:\n        # Explicit type annotation for the client enables full IDE support and static analysis\n        client: \"SESClient\"\n\n        try:\n            response: \"SendEmailResponseTypeDef\" = await client.send_email(\n                Source=sender,\n                Destination={\n                    \"ToAddresses\": [recipient]\n                },\n                Message={\n                    \"Subject\": {\"Data\": subject},\n                    \"Body\": {\"Text\": {\"Data\": body}}\n                }\n            )\n            print(f\"Email sent! Message ID: {response.get('MessageId')}\")\n            return response\n        except Exception as e:\n            print(f\"Error sending email: {e}\")\n            raise\n\nif __name__ == \"__main__\":\n    # Replace with actual email addresses and content\n    recipient_email = \"test@example.com\"\n    sender_email = \"noreply@example.com\"\n    email_subject = \"Hello from aiobotocore SES!\"\n    email_body = \"This is a test email sent using aiobotocore with type hints.\"\n\n    # Make sure AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)\n    # For this example, we'll use os.environ.get for placeholders if actual credentials aren't set.\n    # In a real application, you'd configure aiobotocore session for credentials.\n    # Example: os.environ.get('AWS_ACCESS_KEY_ID', 'YOUR_ACCESS_KEY')\n    #          os.environ.get('AWS_SECRET_ACCESS_KEY', 'YOUR_SECRET_KEY')\n    #          os.environ.get('AWS_REGION', 'us-east-1')\n\n    asyncio.run(send_test_email(recipient_email, sender_email, email_subject, email_body))\n","lang":"python","description":"This quickstart demonstrates how to initialize an `aiobotocore` SES client and use it to send an email, leveraging the `types-aiobotocore-ses` annotations for enhanced type checking and IDE auto-completion. The `TYPE_CHECKING` block ensures type imports are only active during static analysis."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer.","message":"Support for Python 3.8 was removed starting with `mypy-boto3-builder 8.12.0` (which generated `types-aiobotocore-ses 3.4.0`). Projects using Python 3.8 will need to upgrade to Python 3.9 or later.","severity":"breaking","affected_versions":">=3.4.0"},{"fix":"Ensure `aiobotocore` is installed alongside `types-aiobotocore-ses` (e.g., `pip install aiobotocore types-aiobotocore-ses`).","message":"`types-aiobotocore-ses` is a 'stubs only' package. It provides type annotations but does not install `aiobotocore` itself or any other runtime dependencies. Your project must explicitly install `aiobotocore` (e.g., `pip install aiobotocore`) for the code to run.","severity":"gotcha","affected_versions":"All"},{"fix":"Keep `types-aiobotocore-ses` and `aiobotocore` versions synchronized, or use the `types-aiobotocore` umbrella package with service extras to manage compatibility (e.g., `pip install 'types-aiobotocore[ses]'`).","message":"For optimal type checking, the version of `types-aiobotocore-ses` should ideally match or be compatible with your installed `aiobotocore` version. Mismatched versions might lead to incorrect or missing type hints, especially after significant AWS API changes.","severity":"gotcha","affected_versions":"All"},{"fix":"Update your code to use the shorter or adjusted TypeDef names as per the `types-aiobotocore-ses` documentation.","message":"Starting with `mypy-boto3-builder 8.9.0`, TypeDef names for packed method arguments were shortened (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`), and conflicting TypeDef `Extra` postfixes were moved. This affects all generated type stubs, including SES, if you relied on the older, longer names.","severity":"breaking","affected_versions":">=3.1.0 (corresponds to builder 8.9.0 and later)"},{"fix":"Implement the `if TYPE_CHECKING: ... else: var = object` pattern to satisfy Pylint, as shown in the package's documentation. Example: `if TYPE_CHECKING: from .client import SESClient else: SESClient = object`","message":"When using `Pylint` with type annotations imported under `typing.TYPE_CHECKING`, Pylint might report 'undefined variables'.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install `aiobotocore` explicitly: `pip install aiobotocore`","cause":"The `types-aiobotocore-ses` package only provides type hints (stubs) and does not install the actual `aiobotocore` runtime library.","error":"ModuleNotFoundError: No module named 'aiobotocore'"},{"fix":"Ensure `types-aiobotocore-ses` is installed: `pip install types-aiobotocore-ses` or `pip install 'types-aiobotocore[ses]'`.","cause":"The type stubs for `aiobotocore` or the specific SES service are not installed or not correctly recognized by your type checker.","error":"mypy: error: Missing type annotations for ... (e.g., client methods or responses)"},{"fix":"Consult the `types-aiobotocore-ses` documentation or your IDE's auto-completion to use the correct `TypedDict` for complex arguments, or ensure `Literal` values are correctly used (e.g., `from types_aiobotocore_ses.type_defs import SendEmailRequestTypeDef`).","cause":"You are providing an argument with a type that does not match the expected `TypedDict` or `Literal` type defined in the stubs.","error":"Argument \"Source\" to \"send_email\" of \"SESClient\" has incompatible type \"str\"; expected \"EmailAddress\"; (or similar type mismatch errors)"},{"fix":"Ensure all `aiobotocore` client methods are `await`ed, and that they are called from within an `async def` function, which is then run using `asyncio.run()` or similar methods.","cause":"You are attempting to call an `async` function (e.g., an `aiobotocore` client method) without awaiting it, or outside of an `async` context.","error":"TypeError: 'coroutine' object is not callable (or similar runtime errors related to async functions)"}]}