{"id":4822,"library":"types-aiobotocore-sns","title":"Type annotations for aiobotocore SNS","description":"types-aiobotocore-sns provides static type annotations and code completion for `aiobotocore`'s Amazon SNS service client. It ensures type safety and enhances developer experience by integrating with type checkers like MyPy. The current version is 3.4.0, generated by `mypy-boto3-builder` 8.12.0, and new versions are released regularly in sync with `aiobotocore` and `botocore` updates.","status":"active","version":"3.4.0","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["AWS","SNS","async","types","mypy","aiobotocore","type-hinting"],"install":[{"cmd":"pip install types-aiobotocore-sns","lang":"bash","label":"Standalone installation"},{"cmd":"pip install 'types-aiobotocore[sns]'","lang":"bash","label":"As part of the types-aiobotocore meta-package"}],"dependencies":[{"reason":"Provides the underlying asynchronous AWS client for which types are generated.","package":"aiobotocore"},{"reason":"Primary static type checker that benefits from these annotations.","package":"mypy","optional":true}],"imports":[{"note":"For explicit type hinting of the `aiobotocore` SNS client. It's often auto-discovered by IDEs but explicit imports are useful for type checkers.","symbol":"SNSClient","correct":"from types_aiobotocore_sns.client import SNSClient"},{"note":"Example for importing a specific TypedDict for SNS service operation inputs/outputs.","symbol":"PublishInputTypeDef","correct":"from types_aiobotocore_sns.type_defs import PublishInputTypeDef"},{"note":"Example for importing a Literal type, useful for strict type checking of predefined string values.","symbol":"TopicArnType","correct":"from types_aiobotocore_sns.literals import TopicArnType"}],"quickstart":{"code":"import asyncio\nfrom typing import TYPE_CHECKING\nfrom aiobotocore.session import get_session\nimport os\n\nif TYPE_CHECKING:\n    from types_aiobotocore_sns.client import SNSClient\n\nasync def publish_message():\n    session = get_session()\n    # Ensure AWS credentials/config are available via environment variables or config files\n    # e.g., AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION\n    async with session.create_client(\"sns\") as client:\n        client: \"SNSClient\" # Explicit type annotation for IDEs/MyPy\n        topic_arn = os.environ.get('AWS_SNS_TOPIC_ARN', 'arn:aws:sns:REGION:ACCOUNT_ID:MyTopic')\n        message = \"Hello from types-aiobotocore-sns!\"\n        \n        try:\n            response = await client.publish(TopicArn=topic_arn, Message=message)\n            print(f\"Message published: {response['MessageId']}\")\n        except client.exceptions.TopicNotFoundException:\n            print(f\"Error: Topic {topic_arn} not found.\")\n        except Exception as e:\n            print(f\"An error occurred: {e}\")\n\nif __name__ == \"__main__\":\n    # You would typically set AWS_SNS_TOPIC_ARN, AWS_REGION, etc., as environment variables.\n    # For this example, ensure they are set or default values are valid.\n    asyncio.run(publish_message())\n","lang":"python","description":"This quickstart demonstrates how to use `types-aiobotocore-sns` with `aiobotocore` to publish a message to an SNS topic. It includes explicit type hinting for the SNS client, allowing type checkers to validate client calls and provide comprehensive autocomplete. The `TYPE_CHECKING` guard is used to ensure `types-aiobotocore-sns` is only a development dependency."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher. If Python 3.8 is required, pin `types-aiobotocore-sns` to a version generated by `mypy-boto3-builder <8.12.0` (e.g., `types-aiobotocore-sns<3.4.0`).","message":"Support for Python 3.8 has been removed in `mypy-boto3-builder` version 8.12.0 and later, which is used to generate `types-aiobotocore-sns` 3.4.0 and subsequent versions. Projects requiring Python 3.8 must use an older version of `types-aiobotocore-sns`.","severity":"breaking","affected_versions":">=3.4.0"},{"fix":"Update your import statements and references to the new, shorter `TypeDef` names. Consult the `types-aiobotocore-sns` documentation for the correct `TypeDef` names.","message":"In `mypy-boto3-builder` 8.9.0, some `TypeDef` names were shortened (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). If your code explicitly imported these renamed `TypeDefs`, it will break.","severity":"breaking","affected_versions":">=3.2.0 (corresponding to builder 8.9.0)"},{"fix":"Migrate any usage of the `sms-voice` service to `pinpoint-sms-voice` and use the corresponding `types-aiobotocore-pinpoint-sms-voice` package.","message":"The `sms-voice` service was deprecated and removed from `mypy-boto3-builder` (version 8.11.0 onwards). Users should switch to `pinpoint-sms-voice` instead.","severity":"deprecated","affected_versions":">=3.3.0 (corresponding to builder 8.11.0)"},{"fix":"It is recommended to use `types-aiobotocore-lite` instead of the full package, or disable PyCharm's internal type checker and use `mypy` or `pyright` externally.","message":"When using PyCharm, performance issues may occur due to how it handles `Literal` overloads. This can lead to slow performance and high CPU usage.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Wrap all `types_aiobotocore_sns` imports within `if TYPE_CHECKING:` blocks. For non-`TYPE_CHECKING` contexts, you may need to define placeholder `object` assignments for client types if explicitly used in function signatures.","message":"For production deployments, `types-aiobotocore-sns` should typically be a development-only dependency. To avoid runtime dependencies, guard type imports with `typing.TYPE_CHECKING`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}