{"id":3121,"library":"mypy-boto3-pi","title":"mypy-boto3-pi Type Stubs","description":"This package provides type annotations (stubs) for the 'pi' (Performance Insights) service client within the `boto3` library. It's part of the `mypy-boto3` project, which offers comprehensive type hints for all `boto3` services. The current version is 1.42.3, typically updated frequently to align with new `boto3` and AWS API releases.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["boto3","mypy","type-hints","aws","performance-insights","pi"],"install":[{"cmd":"pip install mypy-boto3-pi boto3","lang":"bash","label":"Install stubs and boto3"}],"dependencies":[{"reason":"This package provides type stubs for boto3; boto3 itself must be installed to use the AWS SDK functionality.","package":"boto3","optional":false}],"imports":[{"symbol":"PIClient","correct":"from mypy_boto3_pi.client import PIClient"},{"symbol":"GetDimensionKeyDetailsResponseTypeDef","correct":"from mypy_boto3_pi.type_defs import GetDimensionKeyDetailsResponseTypeDef"},{"note":"mypy-boto3-pi provides stubs for boto3, not a separate runtime library. You import boto3 and mypy uses the stubs implicitly.","wrong":"import mypy_boto3_pi","symbol":"boto3","correct":"import boto3"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_pi.client import PIClient\nfrom mypy_boto3_pi.type_defs import GetDimensionKeyDetailsResponseTypeDef\nfrom typing import TYPE_CHECKING\n\n# Boto3 client without type hints (mypy will infer if stubs are installed)\nclient = boto3.client('pi')\nprint(f\"Client type (runtime): {type(client)}\")\n\n# Type-hinted client for better IDE support and static analysis\npi_client: PIClient = boto3.client('pi')\n\n# Example usage with type-hinted response\n# This call requires valid AWS credentials configured (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION_NAME env vars)\n# and an existing DB instance identifier.\n# Replace 'db-instance-id' with a real instance if running.\nif TYPE_CHECKING:\n    # Define a dummy response for type checking only\n    dummy_response: GetDimensionKeyDetailsResponseTypeDef = {\n        'AlignedEndTime': '', 'AlignedStartTime': '', 'Keys': []\n    }\n\ntry:\n    response: GetDimensionKeyDetailsResponseTypeDef = pi_client.get_dimension_key_details(\n        ServiceType='RDS',\n        Identifier='your-db-instance-id',\n        Group='DB_INSTANCE',\n        GroupIdentifier='your-db-instance-id'\n    )\n    print(\"Successfully called get_dimension_key_details (types applied).\")\n    # Further processing with type-hinted response\nexcept Exception as e:\n    print(f\"Could not call AWS PI service: {e}. Ensure 'your-db-instance-id' is valid and credentials are set.\")\n\n# Accessing fields with type safety\n# if response and response['Keys']:\n#     print(response['Keys'][0]['Dimensions'])\n","lang":"python","description":"This quickstart demonstrates how to use `mypy-boto3-pi` for type-hinting your `boto3` PI client. The stubs allow `mypy` and IDEs to provide accurate type information for client methods and their return types, improving code quality and reducing runtime errors. Remember to replace placeholder values like 'your-db-instance-id' and ensure you have valid AWS credentials configured."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher. For example, `pyenv install 3.9.19` or similar.","message":"Python 3.8 support has been removed. All `mypy-boto3` packages now require Python 3.9 or newer.","severity":"breaking","affected_versions":"mypy-boto3-builder 8.12.0+"},{"fix":"Review your code for explicitly imported TypeDefs and update their names according to the new, shorter convention. Your IDE should highlight these errors.","message":"Type definition (TypeDef) naming conventions were changed for consistency. For example, `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`. This affects all service packages.","severity":"breaking","affected_versions":"mypy-boto3-builder 8.9.0+"},{"fix":"Always install both `boto3` and the specific `mypy-boto3-*` stub package: `pip install boto3 mypy-boto3-pi`.","message":"This package (`mypy-boto3-pi`) provides only type stubs. It does not include the `boto3` runtime library itself. You must install `boto3` separately for your code to actually interact with AWS services.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consult the official AWS Boto3 documentation for the current service names and use the correct string in `boto3.client('service-name')`.","message":"Service names within AWS (and thus boto3) can change or be deprecated. For example, the `sms-voice` service was removed and replaced by `pinpoint-sms-voice` (mypy-boto3-builder 8.11.0). If a service client fails to resolve types, verify its current name.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure `mypy` is up-to-date (`pip install --upgrade mypy`). If issues persist, simplify your `mypy` configuration and rely on standard package installation paths.","message":"The `mypy-boto3` project migrated to PEP 561 compliant packages. While generally seamless, if you have complex `mypy` configurations (e.g., `MYPYPATH` environment variables) or are using older `mypy` versions, you might encounter issues with stub discovery.","severity":"gotcha","affected_versions":"mypy-boto3-builder 8.12.0+"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}