{"id":3046,"library":"mypy-boto3-cloudhsmv2","title":"mypy-boto3-cloudhsmv2","description":"mypy-boto3-cloudhsmv2 provides type annotations (stubs) for the `boto3` AWS SDK, specifically for the CloudHSMV2 service. It enhances development experience by enabling static type checking for `boto3` clients and responses. The library is currently at version 1.42.3, with releases closely mirroring `boto3` service updates and more frequent updates for the underlying `mypy-boto3-builder`.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["AWS","boto3","mypy","type-annotations","stubs","cloudhsmv2","static-analysis"],"install":[{"cmd":"pip install mypy-boto3-cloudhsmv2","lang":"bash","label":"Install library"},{"cmd":"pip install boto3 mypy","lang":"bash","label":"Install runtime dependency and type checker"}],"dependencies":[{"reason":"This library provides type annotations for boto3; boto3 itself is required for actual runtime.","package":"boto3","optional":false},{"reason":"Provides backports of type hinting features; a runtime dependency for older Python versions or specific features.","package":"typing-extensions","optional":true}],"imports":[{"symbol":"CloudHSMV2Client","correct":"from mypy_boto3_cloudhsmv2.client import CloudHSMV2Client"},{"symbol":"DescribeClustersResponseTypeDef","correct":"from mypy_boto3_cloudhsmv2.type_defs import DescribeClustersResponseTypeDef"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_cloudhsmv2.client import CloudHSMV2Client\nfrom mypy_boto3_cloudhsmv2.type_defs import DescribeClustersResponseTypeDef\nimport os # For example credentials\n\ndef get_cloudhsmv2_clusters() -> None:\n    # Ensure AWS credentials are configured (e.g., via environment variables, ~/.aws/credentials)\n    # For this example to run without errors, ensure AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, \n    # and AWS_REGION are set in your environment if not using IAM roles or config files.\n    \n    # The type annotation helps type checkers understand the client's methods and return types.\n    client: CloudHSMV2Client = boto3.client(\"cloudhsmv2\", region_name=os.environ.get('AWS_REGION', 'us-east-1'))\n    \n    try:\n        response: DescribeClustersResponseTypeDef = client.describe_clusters()\n        print(\"Successfully described CloudHSM V2 clusters:\")\n        for cluster in response.get('Clusters', []):\n            print(f\"  - Cluster ID: {cluster.get('ClusterId')}, State: {cluster.get('State')}\")\n    except Exception as e:\n        print(f\"Error describing clusters: {e}\")\n\nif __name__ == \"__main__\":\n    # This code requires valid AWS credentials to run successfully.\n    # For type checking, simply running `mypy your_script.py` is sufficient.\n    get_cloudhsmv2_clusters()\n","lang":"python","description":"This example demonstrates how to use `mypy-boto3-cloudhsmv2` for type-hinted interaction with the CloudHSMV2 service. It shows how to obtain a type-annotated client and call an operation (`describe_clusters`), with type checkers verifying argument and return types. For actual execution, ensure AWS credentials are configured in your environment."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher. For Python 3.8 support, pin to a version <8.12.0 if compatible with your boto3 version.","message":"Support for Python 3.8 was removed in version 8.12.0 of the `mypy-boto3-builder` and subsequently in generated packages like `mypy-boto3-cloudhsmv2`.","severity":"breaking","affected_versions":">=8.12.0"},{"fix":"Review your code for direct references to `mypy-boto3` generated TypedDict names and update them according to the new conventions. Consult the specific service's `mypy-boto3` package `type_defs.pyi` for current names.","message":"TypeDef naming conventions changed in version 8.9.0 (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). This can break code that explicitly imports or references these generated type definition names.","severity":"breaking","affected_versions":">=8.9.0"},{"fix":"Ensure `boto3` is installed in your environment: `pip install boto3`.","message":"This library provides *type stubs* for `boto3`, it does not include `boto3` itself. You must install `boto3` separately to actually run your code.","severity":"gotcha","affected_versions":"All"},{"fix":"Ideally, align `mypy-boto3-cloudhsmv2` with your `boto3` version. `mypy-boto3` packages are typically generated to match specific `boto3` versions (as indicated in their summary/description).","message":"For effective type checking, the version of `mypy-boto3-cloudhsmv2` should closely match the `boto3` version you are using. Mismatched versions can lead to incorrect type hints or missing attributes.","severity":"gotcha","affected_versions":"All"},{"fix":"Install `mypy` (or another compatible type checker) with `pip install mypy` and integrate it into your development workflow (e.g., `mypy your_script.py`).","message":"To benefit from these type annotations, you need to use a static type checker like `mypy`. Simply installing the stubs will not magically add type checking to your runtime Python code.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}