types-boto3-sns

raw JSON →
1.43.0 verified Fri May 01 auth: no python

Type annotations for boto3 SNS 1.43.0 service generated with mypy-boto3-builder 8.12.0. Provides static type checking for AWS SNS API calls, compatible with mypy, pyright, and type-checkers. Current version: 1.43.0. Release cadence: follows boto3 SNS service updates.

pip install boto3-stubs[sns]
error ModuleNotFoundError: No module named 'mypy_boto3_sns'
cause Installing the wrong package; 'types-boto3-sns' is the PyPI name but the module is 'mypy_boto3_sns'.
fix
Install with 'pip install boto3-stubs[sns]' or 'pip install types-boto3-sns', then import as 'import mypy_boto3_sns'.
error ImportError: cannot import name 'SNSClient' from 'boto3' (unknown location)
cause Trying to import SNSClient from boto3 directly, which does not export type annotations.
fix
From mypy_boto3_sns.client import SNSClient
error TypeError: 'type' object is not subscriptable
cause Using list/dict type hints without importing from typing or using PEP 585 style, e.g., list[str] on Python <3.9.
fix
Upgrade to Python 3.9+ or use 'from typing import List, Dict' and annotate as List[str], etc.
breaking TypeDef names may change between versions due to auto-generation. For example, in version 8.9.0, TypeDefs for packed method arguments were renamed (e.g., CreateDistributionRequestRequestTypeDef -> CreateDistributionRequestTypeDef). Lock your types version to avoid CI breaks.
fix Pin types-boto3-sns to a specific version in your requirements file.
deprecated Python 3.8 support was removed in mypy-boto3-builder 8.12.0. If you are on Python 3.8, upgrade to Python >=3.9 or stick to an older version of types-boto3-sns.
fix Use Python 3.9+ or pin to types-boto3-sns<1.43.0.
gotcha Importing from `types_boto3_sns` directly (with underscore) is a common mistake. The correct top-level package is `mypy_boto3_sns` (with underscore after mypy). `types_boto3_sns` is the PyPI distribution name, not the importable package.
fix Use `import mypy_boto3_sns` or `from mypy_boto3_sns.client import SNSClient`.
pip install types-boto3-sns

Create an SNS client with type annotations and publish an SMS message.

import boto3
from mypy_boto3_sns.client import SNSClient
from mypy_boto3_sns.type_defs import PublishResponseTypeDef

client: SNSClient = boto3.client("sns", region_name="us-east-1")
response: PublishResponseTypeDef = client.publish(
    PhoneNumber="+1234567890",
    Message="Hello from mypy!"
)
print(response["MessageId"])