Type annotations for aiobotocore SSM
types-aiobotocore-ssm provides comprehensive type annotations for the `aiobotocore` SSM (Systems Manager) service, enhancing static type checking with tools like MyPy. It is generated by `mypy-boto3-builder` (version 8.12.0 for the current 3.4.0 release of the stubs) and receives frequent updates, typically in sync with `aiobotocore` releases and `mypy-boto3-builder` enhancements.
Common errors
-
ModuleNotFoundError: No module named 'types_aiobotocore_ssm'
cause The `types-aiobotocore-ssm` package is either not installed, or there is a typo in the import statement.fixEnsure the package is installed with `pip install types-aiobotocore-ssm`. Verify the import path is `from types_aiobotocore_ssm.client import SSMClient` (using underscores, not hyphens). -
TypeError: Argument of type 'SSMClient' cannot be assigned to parameter 'client' of type 'SSMClient' in aiobotocore.session.ClientCreator.create_client
cause This error, or similar type mismatches for `client` methods, often indicates that the `aiobotocore` runtime library is not installed, or that the type checker is not correctly linking the stubs with the runtime.fixVerify that `aiobotocore` is installed (`pip install aiobotocore`). Ensure your type checker (e.g., MyPy) is correctly configured and running against your environment. For explicit typing, consider `client: SSMClient` after `create_client`. -
AttributeError: 'SSMClient' object has no attribute 'send_command' (or similar method error)
cause You are likely calling an asynchronous method on the `aiobotocore` client without using `await`, or attempting to use a `boto3` client method signature on an `aiobotocore` client.fixEnsure all client calls are `await`ed, as `aiobotocore` clients are asynchronous. For example, `await client.send_command(...)`. Also, double-check method names against `aiobotocore`'s documentation, as they might differ slightly from `boto3`.
Warnings
- breaking Python 3.8 support has been removed from all `mypy-boto3-builder` generated stub packages, including `types-aiobotocore-ssm`, starting with `mypy-boto3-builder` version 8.12.0.
- breaking Type definition (TypeDef) naming conventions were changed in `mypy-boto3-builder` version 8.9.0. This includes shorter names for packed method arguments (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`) and moving the `Extra` postfix. Code explicitly importing and using these TypeDefs may break.
- gotcha `types-aiobotocore-ssm` provides only type annotations (stubs) for the `aiobotocore` SSM client. It does not include the actual `aiobotocore` runtime library, which must be installed separately for your application to function.
- gotcha As of `mypy-boto3-builder` 8.12.0, stub packages have migrated to PEP 561 compliance. This means stubs are installed alongside the runtime library and are automatically discovered by type checkers like MyPy. If you had custom configurations for stub discovery, they might need adjustment.
- gotcha PyCharm users might experience slow performance or high CPU usage with Literal overloads in type stubs (issue PY-40997).
Install
-
pip install types-aiobotocore-ssm aiobotocore -
pip install 'types-aiobotocore[ssm]' aiobotocore
Imports
- SSMClient
from types_aiobotocore_ssm.client import SSMClient
- CommandExecutedWaiter
from types_aiobotocore_ssm.waiter import CommandExecutedWaiter
- AccountSharingInfoTypeDef
from types_aiobotocore_ssm.type_defs import AccountSharingInfoTypeDef
- AccessRequestStatusType
from types_aiobotocore_ssm.literals import AccessRequestStatusType
Quickstart
import asyncio
from aiobotocore.session import get_session
from types_aiobotocore_ssm.client import SSMClient
from types_aiobotocore_ssm.waiter import CommandExecutedWaiter
async def describe_instance_information():
session = get_session()
async with session.create_client("ssm") as client: # type: SSMClient
# Use explicit type annotation for client for clarity, though often inferred
print("Describing instance information...")
response = await client.describe_instance_information(
MaxResults=5
)
print(f"Instances: {[instance['InstanceId'] for instance in response.get('InstanceInformationList', [])]}")
# Example of using a waiter
print("Getting CommandExecuted waiter...")
waiter: CommandExecutedWaiter = client.get_waiter("command_executed")
# await waiter.wait(CommandId="your-command-id", InstanceId="your-instance-id")
print("Waiter retrieved. Actual wait requires command/instance IDs.")
if __name__ == "__main__":
asyncio.run(describe_instance_information())