{"id":1849,"library":"mypy-boto3-ssm","title":"Type Annotations for boto3 SSM","description":"mypy-boto3-ssm provides comprehensive type annotations for the AWS Boto3 SSM (Systems Manager) client. This library enhances static analysis, improves auto-completion in IDEs like VSCode and PyCharm, and enables early detection of potential runtime errors with type checkers like Mypy. It is currently at version 1.42.54, which aligns with a specific Boto3 version, and is generated using the `mypy-boto3-builder` (version 8.12.0). The project maintains an active release cadence, syncing with Boto3 updates.","status":"active","version":"1.42.54","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["boto3","aws","mypy","type-annotations","stubs","ssm","static-analysis","ide-support"],"install":[{"cmd":"pip install boto3 mypy-boto3-ssm","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Runtime dependency for the AWS SDK for Python. `mypy-boto3-ssm` provides only type stubs, not the actual Boto3 implementation.","package":"boto3","optional":false}],"imports":[{"note":"Import the typed client for Boto3 SSM.","symbol":"SSMClient","correct":"from mypy_boto3_ssm.client import SSMClient"},{"note":"Import specific TypedDicts for precise type hints on API response structures.","symbol":"GetParameterResultTypeDef","correct":"from mypy_boto3_ssm.type_defs import GetParameterResultTypeDef"},{"note":"While functional, this lacks static type information. For type hints, you should annotate the client variable with `SSMClient`.","wrong":"client = boto3.client(\"ssm\")","symbol":"Session().client(\"ssm\")"}],"quickstart":{"code":"import os\nimport boto3\nfrom mypy_boto3_ssm.client import SSMClient\nfrom mypy_boto3_ssm.type_defs import GetParameterResultTypeDef\n\ndef get_ssm_parameter(name: str) -> str | None:\n    # Ensure AWS credentials are available (e.g., via environment variables, ~/.aws/credentials)\n    # For local testing, you might need to mock or ensure a valid AWS setup.\n    \n    # Explicitly type the client for mypy compatibility and IDE autocompletion\n    client: SSMClient = boto3.client(\"ssm\")\n\n    try:\n        response: GetParameterResultTypeDef = client.get_parameter(Name=name, WithDecryption=True)\n        return response.get(\"Parameter\", {}).get(\"Value\")\n    except client.exceptions.ParameterNotFound:\n        print(f\"Parameter '{name}' not found.\")\n        return None\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n        return None\n\n# Example usage (requires an actual AWS SSM parameter and credentials)\n# You might need to set AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION\n# os.environ['AWS_ACCESS_KEY_ID'] = os.environ.get('AWS_ACCESS_KEY_ID', '')\n# os.environ['AWS_SECRET_ACCESS_KEY'] = os.environ.get('AWS_SECRET_ACCESS_KEY', '')\n# os.environ['AWS_REGION'] = os.environ.get('AWS_REGION', 'us-east-1')\n\n# Example parameter name - replace with one existing in your AWS account\n# parameter_name = \"/my/test/parameter\"\n# parameter_value = get_ssm_parameter(parameter_name)\n# if parameter_value:\n#    print(f\"Value of '{parameter_name}': {parameter_value}\")\n# else:\n#    print(f\"Could not retrieve value for '{parameter_name}'.\")","lang":"python","description":"This quickstart demonstrates how to get a type-hinted AWS SSM client and retrieve a parameter. It uses explicit type annotations for the client and the response, leveraging the `mypy-boto3-ssm` stubs for static analysis and IDE support. Remember to have `boto3` installed and your AWS credentials configured."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher.","message":"Support for Python 3.8 has been removed in `mypy-boto3-builder` version 8.12.0 and subsequent generated packages. Users on Python 3.8 or older must upgrade to Python 3.9+ to use the latest `mypy-boto3-ssm` versions.","severity":"breaking","affected_versions":">=8.12.0 of builder, >=1.42.54 of stubs"},{"fix":"Explicitly install `mypy-boto3-ssm` alongside `boto3`. For broader Boto3 typing, `boto3-stubs` is an alternative, but `mypy-boto3-ssm` is for this specific service.","message":"The `mypy-boto3` ecosystem migrated to PEP 561 compliant packages in builder version 8.12.0. While this primarily affects how type checkers find stubs, ensure explicit installation of service-specific stub packages (`mypy-boto3-ssm`) rather than relying on `boto3-stubs` for specific services if you encounter import issues.","severity":"breaking","affected_versions":">=8.12.0 of builder, >=1.42.54 of stubs"},{"fix":"Update your `TypeDef` import paths and names to match the new conventions, referring to the `mypy-boto3-ssm` documentation for specific services.","message":"TypeDef naming conventions changed in builder version 8.9.0, typically shortening names (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). While the example refers to a different service, similar renames might affect SSM-related `TypeDef` imports. Always check documentation for specific `TypeDef` names.","severity":"breaking","affected_versions":">=8.9.0 of builder"},{"fix":"Always include `pip install boto3` in your project's setup alongside `pip install mypy-boto3-ssm`.","message":"`mypy-boto3-ssm` provides only type stubs, not the actual runtime implementation of the AWS SDK. You must install `boto3` separately for your code to execute correctly.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Instead of `response: dict = client.get_parameter(...)`, use `from mypy_boto3_ssm.type_defs import MyServiceResultTypeDef; response: MyServiceResultTypeDef = client.get_parameter(...)`.","message":"For the most precise type checking of Boto3 API responses, it is recommended to explicitly import and use the generated `TypeDef` objects (e.g., `GetParameterResultTypeDef`) from `mypy_boto3_ssm.type_defs`. This provides richer type information than generic `dict` annotations.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}