{"id":3635,"library":"mypy-boto3-memorydb","title":"Type Annotations for boto3 MemoryDB","description":"mypy-boto3-memorydb provides type annotations for the AWS boto3 MemoryDB service, compatible with mypy, VSCode, PyCharm, and other type-checking tools. It offers comprehensive type hints for clients, paginators, waiters, and TypeDefs, ensuring better code quality and developer experience. The current version is 1.42.3 and it's actively maintained as part of the `mypy-boto3-builder` project, which releases updates in sync with boto3 service changes.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["typing","mypy","boto3","aws","memorydb","stubs","type-hints"],"install":[{"cmd":"pip install mypy-boto3-memorydb boto3 mypy","lang":"bash","label":"Install standalone package"},{"cmd":"pip install 'boto3-stubs[memorydb]' boto3 mypy","lang":"bash","label":"Install via boto3-stubs extra"}],"dependencies":[{"reason":"Provides runtime functionality for AWS services; this package provides type stubs for it.","package":"boto3","optional":false},{"reason":"A static type checker that utilizes these annotations.","package":"mypy","optional":true},{"reason":"Requires Python 3.9 or newer.","package":"python","optional":false}],"imports":[{"symbol":"MemoryDBClient","correct":"from mypy_boto3_memorydb.client import MemoryDBClient"},{"symbol":"DescribeClustersPaginator","correct":"from mypy_boto3_memorydb.paginator import DescribeClustersPaginator"},{"note":"Type definitions are in the `type_defs` submodule, not directly under `client`.","wrong":"from mypy_boto3_memorydb.client import ResponseMetadataTypeDef","symbol":"ResponseMetadataTypeDef","correct":"from mypy_boto3_memorydb.type_defs import ResponseMetadataTypeDef"},{"symbol":"MemoryDBServiceName","correct":"from mypy_boto3_memorydb.literals import MemoryDBServiceName"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING\n\nif TYPE_CHECKING:\n    from mypy_boto3_memorydb.client import MemoryDBClient\n    from mypy_boto3_memorydb.type_defs import CreateClusterResponseTypeDef\n\n\ndef create_memorydb_cluster(cluster_name: str, node_type: str, num_shards: int) -> CreateClusterResponseTypeDef:\n    client: MemoryDBClient = boto3.client(\"memorydb\")\n    response = client.create_cluster(\n        ClusterName=cluster_name,\n        NodeType=node_type,\n        NumShards=num_shards,\n        Engine=\"redis\",\n        SnapshotRetentionLimit=7,\n        SubnetGroupName='default',\n        ParameterGroupName='default.memorydb.redis6'\n    )\n    print(f\"Created MemoryDB cluster: {response['Cluster']['ClusterName']}\")\n    return response\n\n# Example usage (ensure you have AWS credentials configured)\n# create_memorydb_cluster(\"my-test-cluster\", \"db.r6g.large\", 1)","lang":"python","description":"This quickstart demonstrates how to initialize a MemoryDB client with type annotations. The `TYPE_CHECKING` block ensures that the type imports are only used by the type checker and do not introduce runtime dependencies. The client object `client` is explicitly annotated with `MemoryDBClient` for full type-checking and IDE auto-completion. This example creates a MemoryDB cluster."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer.","message":"Python 3.8 support has been removed in `mypy-boto3-builder` version 8.12.0, which generates `mypy-boto3-memorydb`. Consequently, this package (1.42.3 and newer) requires Python 3.9 or higher.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.12.0, mypy-boto3-memorydb >=1.42.0"},{"fix":"Review and update your TypeDef imports and usages according to the new naming conventions. Refer to the specific service's `type_defs` documentation.","message":"Breaking changes were introduced in `mypy-boto3-builder` 8.9.0 regarding TypeDef naming conventions. TypeDefs for packed method arguments use shorter names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`), and conflicting `Extra` postfixes were moved (e.g., `CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`). This may require updates to existing type hints.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.9.0, mypy-boto3-memorydb matching that builder version"},{"fix":"Ensure `boto3` and `mypy` are installed: `pip install boto3 mypy`.","message":"This package provides *only type stubs*. You must install the `boto3` library separately for your code to run correctly. `mypy` is also required for static type checking.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install `boto3-stubs-lite[memorydb]` instead: `pip install 'boto3-stubs-lite[memorydb]' boto3`.","message":"For PyCharm users, if you experience slow performance due to `Literal` overloads, it is recommended to use the `boto3-stubs-lite` alternative, which provides a more RAM-friendly experience at the cost of requiring more explicit type annotations.","severity":"gotcha","affected_versions":"All versions, specifically affecting PyCharm users"},{"fix":"Explicitly annotate `boto3.client()` return values with the corresponding `mypy-boto3-service.client` type (e.g., `client: MemoryDBClient = boto3.client('memorydb')`).","message":"For optimal auto-completion and type checking in IDEs like VSCode or with older `mypy` versions, it's often necessary to use explicit type annotations for `boto3.client()` calls, as shown in the quickstart.","severity":"gotcha","affected_versions":"All versions"},{"fix":"When troubleshooting or reporting issues, be aware of both version numbers. The package version correlates to the `boto3` version, while the builder version indicates the generator's capabilities.","message":"The version of `mypy-boto3-memorydb` (e.g., 1.42.3) indicates the `boto3` version it provides stubs for. However, the underlying `mypy-boto3-builder` version (e.g., 8.12.0) is independent and refers to the builder's own release cycle and features.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}