{"id":3670,"library":"mypy-boto3-personalize-runtime","title":"mypy-boto3-personalize-runtime type stubs","description":"mypy-boto3-personalize-runtime provides high-quality type annotations for the AWS SDK for Python (boto3)'s PersonalizeRuntime service. It enables static type checking with tools like Mypy, Pyright, and enhances IDE features like autocompletion for boto3 clients, responses, and related data structures. The current version, 1.42.3, is generated with mypy-boto3-builder 8.12.0 and is updated frequently to align with boto3 releases and new AWS service features.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","boto3","type-hints","mypy","personalize-runtime","stubs","types"],"install":[{"cmd":"pip install mypy-boto3-personalize-runtime boto3","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Provides the AWS SDK for Python, for which these are type stubs.","package":"boto3"},{"reason":"Required for some type features on Python versions older than 3.9, though optional for newer Python versions. Generally good practice to include for robust type hinting.","package":"typing-extensions","optional":true}],"imports":[{"symbol":"PersonalizeRuntimeClient","correct":"from mypy_boto3_personalize_runtime.client import PersonalizeRuntimeClient"},{"symbol":"GetRecommendationsResponseTypeDef","correct":"from mypy_boto3_personalize_runtime.type_defs import GetRecommendationsResponseTypeDef"},{"note":"mypy-boto3 packages provide type stubs, not runtime modules. Use actual boto3 for client instantiation.","wrong":"from mypy_boto3_personalize_runtime import boto3","symbol":"boto3","correct":"import boto3"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING\nimport os\n\nif TYPE_CHECKING:\n    from mypy_boto3_personalize_runtime.client import PersonalizeRuntimeClient\n    from mypy_boto3_personalize_runtime.type_defs import GetRecommendationsResponseTypeDef\n\ndef get_personalize_recommendations(\n    campaign_arn: str, user_id: str, num_results: int = 10\n) -> GetRecommendationsResponseTypeDef:\n    \"\"\"Gets recommendations from AWS Personalize Runtime.\"\"\"\n    client: PersonalizeRuntimeClient = boto3.client(\n        \"personalize-runtime\",\n        region_name=os.environ.get('AWS_REGION', 'us-east-1'),\n        aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', ''),\n        aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', '')\n    )\n    \n    response: GetRecommendationsResponseTypeDef = client.get_recommendations(\n        campaignArn=campaign_arn,\n        userId=user_id,\n        numResults=num_results\n    )\n    return response\n\n# Example usage (requires AWS credentials and a configured Personalize campaign)\n# if __name__ == \"__main__\":\n#     campaign_arn_example = \"arn:aws:personalize:us-east-1:123456789012:campaign/your-campaign-name\"\n#     user_id_example = \"test_user_1\"\n#     try:\n#         recommendations = get_personalize_recommendations(campaign_arn_example, user_id_example)\n#         print(\"Recommended Items:\")\n#         for item in recommendations.get(\"itemList\", []):\n#             print(f\"  Item ID: {item.get('itemId')}\")\n#     except Exception as e:\n#         print(f\"Error getting recommendations: {e}\")","lang":"python","description":"This example demonstrates how to create a type-hinted `PersonalizeRuntimeClient` using `boto3` and explicitly annotate the client object and the response from `get_recommendations`. This allows static type checkers to validate your usage of the client and its response, catching potential errors before runtime. Replace placeholder values with your actual AWS campaign ARN and user ID."},"warnings":[{"fix":"Upgrade Python to 3.9 or higher. If unable to upgrade, pin an older `mypy-boto3-personalize-runtime` version that supported Python 3.8.","message":"As of `mypy-boto3-builder` version 8.12.0 (which generated this stub version), support for Python 3.8 has been removed. Users on Python 3.8 should upgrade their Python version to 3.9+ or use an older `mypy-boto3` stub package version.","severity":"breaking","affected_versions":">=1.42.3 (generated by mypy-boto3-builder 8.12.0)"},{"fix":"Review your code for `_TypeDef` imports and usage, and update names according to the new conventions as indicated by your type checker or documentation.","message":"The `mypy-boto3-builder` (version 8.9.0 and later) introduced changes to `TypeDef` naming conventions. Some generated type definition names may have been shortened or have their `Extra` postfix moved. For example, `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`. While this specific package is for 'personalize-runtime', such a change in the builder could affect similar patterns in type names across services.","severity":"breaking","affected_versions":">=1.42.3 (generated by mypy-boto3-builder 8.9.0+)"},{"fix":"Always explicitly type hint your boto3 client objects, e.g., `client: PersonalizeRuntimeClient = boto3.client(\"personalize-runtime\")`.","message":"When using standalone `mypy-boto3-personalize-runtime` packages (rather than the umbrella `boto3-stubs` with extras), explicit type annotations for `boto3.client()` calls are required for proper type checking and IDE autocompletion. The type checker will not automatically infer the specific client type without the annotation.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consider installing `boto3-stubs-lite[personalize-runtime]` instead of the full package, or configure PyCharm to use an external type checker like `mypy` or `pyright`.","message":"PyCharm users might experience slow performance or high CPU usage due to how it handles `Literal` overloads within `mypy-boto3` stubs. It is sometimes recommended to use `boto3-stubs-lite` (a more RAM-friendly version) or disable PyCharm's internal type checker and rely on `mypy` or `pyright` instead.","severity":"gotcha","affected_versions":"All versions"},{"fix":"To resolve Pylint warnings, assign `object` to the type symbols outside the `TYPE_CHECKING` block. For example: `if TYPE_CHECKING: from mypy_boto3_personalize_runtime.client import PersonalizeRuntimeClient else: PersonalizeRuntimeClient = object`.","message":"Pylint might raise `undefined-variable` warnings when using `TYPE_CHECKING` guards to conditionally import `mypy-boto3` types. This is a known issue with Pylint's interaction with the `TYPE_CHECKING` block.","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"}