{"id":3573,"library":"mypy-boto3-drs","title":"Type Annotations for boto3 DRS","description":"mypy-boto3-drs provides comprehensive type annotations for the AWS Disaster Recovery Service (DRS) client within the boto3 library. Version 1.42.86 is currently available, generated by mypy-boto3-builder 8.12.0. The project maintains an active release cadence, frequently updating stubs to align with new boto3 and botocore versions, ensuring compatibility with popular type checkers like mypy and pyright, as well as IDEs like VSCode and PyCharm.","status":"active","version":"1.42.86","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","boto3","mypy","type-hinting","stubs","drs","cloud"],"install":[{"cmd":"pip install mypy-boto3-drs","lang":"bash","label":"Install standalone package"},{"cmd":"pip install 'boto3-stubs[drs]' --extra-index-url https://pypi.org/simple/","lang":"bash","label":"Install via boto3-stubs (recommended)"}],"dependencies":[{"reason":"Provides the AWS SDK for Python that these type stubs annotate.","package":"boto3"},{"reason":"Primary type checker for which these stubs are designed.","package":"mypy","optional":true},{"reason":"Alternative type checker supported by these stubs.","package":"pyright","optional":true}],"imports":[{"note":"While you call `boto3.client('drs')`, the static type for type checking comes from `mypy_boto3_drs`.","wrong":"from boto3.client import DRSClient","symbol":"DRSClient","correct":"from mypy_boto3_drs import DRSClient"},{"note":"Import type definitions (TypedDicts) for API response structures from the `type_defs` submodule.","symbol":"DescribeRecoveryInstancesResponseTypeDef","correct":"from mypy_boto3_drs.type_defs import DescribeRecoveryInstancesResponseTypeDef"},{"note":"Import Paginator types for paginated API calls.","symbol":"DRSPaginator","correct":"from mypy_boto3_drs.paginator import DescribeRecoveryInstancesPaginator"}],"quickstart":{"code":"from typing import TYPE_CHECKING\nimport boto3\nimport os\n\nif TYPE_CHECKING:\n    from mypy_boto3_drs import DRSClient\n    from mypy_boto3_drs.type_defs import DescribeRecoveryInstancesResponseTypeDef\n\n# Configure AWS credentials and region, e.g., via environment variables or ~/.aws/credentials\n# For quickstart, ensure default session is configured or pass explicit creds/region.\n\ndef get_drs_recovery_instances() -> None:\n    # Explicitly type the client for mypy/IDE support\n    client: DRSClient = boto3.client(\"drs\", region_name=os.environ.get(\"AWS_REGION\", \"us-east-1\"))\n    \n    try:\n        # Example: Describe recovery instances\n        response: DescribeRecoveryInstancesResponseTypeDef = client.describe_recovery_instances()\n        \n        print(f\"Found {len(response['items'])} DRS Recovery Instances:\")\n        for instance in response['items']:\n            print(f\"  - Instance ID: {instance.get('recoveryInstanceID')}, Status: {instance.get('lifeCycle', {}).get('status')}\")\n\n    except Exception as e:\n        print(f\"Error describing DRS recovery instances: {e}\")\n\nif __name__ == \"__main__\":\n    # Set dummy values for AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION if not configured\n    os.environ.setdefault('AWS_ACCESS_KEY_ID', 'testing')\n    os.environ.setdefault('AWS_SECRET_ACCESS_KEY', 'testing')\n    os.environ.setdefault('AWS_REGION', 'us-east-1')\n    get_drs_recovery_instances()","lang":"python","description":"This quickstart demonstrates how to initialize a typed DRS client using `mypy-boto3-drs` and `boto3`, and then perform a basic API call (`describe_recovery_instances`). It includes the recommended `TYPE_CHECKING` guard for conditional import of stubs and explicit type annotation for the client object."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher. The `requires_python` metadata explicitly states `>=3.9`.","message":"Starting with `mypy-boto3-builder` version 8.12.0 (which generated `mypy-boto3-drs 1.42.86`), support for Python 3.8 has been removed across all `mypy-boto3` packages.","severity":"breaking","affected_versions":"mypy-boto3-drs >= 1.42.75.0 (corresponding to builder 8.12.0) and all newer versions."},{"fix":"Review your code for any explicit imports or references to `TypeDef` names and update them according to the new naming conventions. Consult the `mypy-boto3` documentation for service-specific `type_defs`.","message":"The `mypy-boto3-builder` (version 8.9.0 and later, which includes 8.12.0 that generated this stub) introduced breaking changes to `TypeDef` naming conventions. Specifically, 'TypeDefs for packed method arguments use shorter names if possible' and 'Conflicting TypeDef Extra postfix moved to the end'.","severity":"breaking","affected_versions":"mypy-boto3-drs packages generated by builder 8.9.0 or newer."},{"fix":"For PyCharm, consider `pip install boto3-stubs-lite[drs]` or configuring PyCharm to use an external type checker like `mypy` or `pyright`.","message":"PyCharm users might experience slow performance and high CPU usage due to `Literal` overloads when using `boto3-stubs`. It is recommended to use `boto3-stubs-lite` (if explicit type annotations are acceptable) or disable PyCharm's internal type checker and rely on `mypy` or `pyright`.","severity":"gotcha","affected_versions":"All versions when used with PyCharm."},{"fix":"To fix this, explicitly set the types to `object` in the non-`TYPE_CHECKING` block: `if TYPE_CHECKING: from mypy_boto3_drs import DRSClient else: DRSClient = object`.","message":"When using `TYPE_CHECKING` for conditional imports with Pylint, it might report 'undefined variable' errors for the aliased types in the runtime block. This is a known Pylint issue.","severity":"gotcha","affected_versions":"All versions when using `TYPE_CHECKING` with Pylint."}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}