{"id":3837,"library":"types-boto3-dynamodb","title":"Type annotations for boto3 DynamoDB","description":"types-boto3-dynamodb provides comprehensive type annotations for the `boto3` AWS SDK's DynamoDB service. It is part of the `types-boto3` project and is generated by `mypy-boto3-builder` 8.12.0. These stubs enhance developer experience by enabling static type checking, autocompletion, and improved readability for `boto3` interactions with DynamoDB, compatible with tools like VSCode, PyCharm, mypy, and pyright. The library is actively maintained with frequent updates to align with new `boto3` versions and Python features.","status":"active","version":"1.42.73","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","boto3","dynamodb","typing","type-hints","mypy","pyright","stubs"],"install":[{"cmd":"pip install 'types-boto3[dynamodb]'","lang":"bash","label":"Recommended (as part of types-boto3 bundle)"},{"cmd":"pip install types-boto3-dynamodb","lang":"bash","label":"Standalone DynamoDB stubs"}],"dependencies":[{"reason":"Provides the runtime functionality for which these stubs offer type hints. This package provides type information, not runtime code.","package":"boto3","optional":false}],"imports":[{"note":"Type for the low-level DynamoDB client.","symbol":"DynamoDBClient","correct":"from types_boto3_dynamodb import DynamoDBClient"},{"note":"Type for the high-level DynamoDB service resource.","symbol":"DynamoDBServiceResource","correct":"from types_boto3_dynamodb import DynamoDBServiceResource"},{"note":"Type for a DynamoDB Table resource object.","symbol":"Table","correct":"from types_boto3_dynamodb.service_resource import Table"},{"note":"Example of importing a specific TypedDict for DynamoDB operation parameters/responses.","symbol":"ArchivalSummaryTypeDef","correct":"from types_boto3_dynamodb.type_defs import ArchivalSummaryTypeDef"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING\n\nif TYPE_CHECKING:\n    from types_boto3_dynamodb import DynamoDBClient, DynamoDBServiceResource\n    from types_boto3_dynamodb.service_resource import Table\n\n\ndef get_dynamodb_client() -> 'DynamoDBClient':\n    \"\"\"Returns a type-hinted DynamoDB client.\"\"\"\n    return boto3.client('dynamodb')\n\n\ndef get_dynamodb_resource() -> 'DynamoDBServiceResource':\n    \"\"\"Returns a type-hinted DynamoDB service resource.\"\"\"\n    return boto3.resource('dynamodb')\n\n\ndef get_table(table_name: str) -> 'Table':\n    \"\"\"Returns a type-hinted DynamoDB Table resource.\"\"\"\n    dynamodb_resource: DynamoDBServiceResource = get_dynamodb_resource()\n    return dynamodb_resource.Table(table_name)\n\n# Example usage (without actual AWS calls):\nclient = get_dynamodb_client()\nprint(f\"DynamoDB client type: {type(client)}\")\n\nresource = get_dynamodb_resource()\nprint(f\"DynamoDB resource type: {type(resource)}\")\n\n# You would typically interact with a real table here\n# table = get_table(\"YourTableName\")\n# print(f\"DynamoDB table type: {type(table)}\")","lang":"python","description":"This quickstart demonstrates how to obtain type-hinted DynamoDB clients, service resources, and table resources using `types-boto3-dynamodb`. It leverages `typing.TYPE_CHECKING` to ensure the type stubs are only used during static analysis, preventing runtime dependencies in production. The `boto3` library must be installed alongside these type stubs for full functionality."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher.","message":"Python 3.8 support has been removed. `types-boto3-dynamodb` and its builder `mypy-boto3-builder` now require Python 3.9 or newer.","severity":"breaking","affected_versions":"mypy-boto3-builder 8.12.0 and later, affecting types-boto3-dynamodb versions generated by it."},{"fix":"Ensure your type checker (e.g., mypy, pyright) is up-to-date and configured to correctly resolve PEP 561 packages. Most users should not encounter issues with standard setups.","message":"The project migrated to PEP 561 compliant packages. This might require adjustments in how some build systems or advanced type checker configurations resolve imports, though direct usage often remains compatible.","severity":"breaking","affected_versions":"mypy-boto3-builder 8.12.0 and later, affecting types-boto3-dynamodb versions generated by it."},{"fix":"Review your code for direct imports or usage of generated TypedDicts and update their names according to the new conventions, referring to the latest generated documentation or code completions.","message":"TypeDef naming conventions were changed for some packed method arguments and conflicting names (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). If you directly reference these generated TypedDicts, your code may break.","severity":"breaking","affected_versions":"mypy-boto3-builder 8.9.0 and later, affecting types-boto3-dynamodb versions generated by it."},{"fix":"Wrap type stub imports and annotations with `if TYPE_CHECKING: ... else: ...` blocks. For example: `if TYPE_CHECKING: from types_boto3_dynamodb import DynamoDBClient else: DynamoDBClient = object`.","message":"For optimal production environments, it is recommended to conditionally import type hints using `if TYPE_CHECKING:` to prevent adding the stub package as a runtime dependency. This avoids potential `pylint` warnings if not handled correctly.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consider using `types-boto3-lite` (a leaner version of stubs) if available for your service, or disable PyCharm's built-in type checker and rely on external tools like mypy or pyright instead for type checking.","message":"PyCharm users might experience slow performance and high CPU usage, especially with `Literal` overloads. This is a known issue (PY-40997) within PyCharm's type checker.","severity":"gotcha","affected_versions":"All versions, specific to PyCharm IDE."},{"fix":"Prefer `types-boto3` and its specific service packages (like `types-boto3-dynamodb`) in new projects and when updating dependencies. Update any `boto3-stubs` references in `install_requires` or similar configurations.","message":"The overarching project name for boto3 type stubs has transitioned from `boto3-stubs` to `types-boto3`. While `types-boto3-dynamodb` remains the specific package for DynamoDB, users migrating from older setups or referencing older documentation should be aware of this change.","severity":"gotcha","affected_versions":"Starting with mypy-boto3-builder 8.x, the main project was renamed."}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}