{"id":3574,"library":"mypy-boto3-ds-data","title":"Type Annotations for boto3 DirectoryServiceData","description":"mypy-boto3-ds-data provides type annotations for the `boto3` DirectoryServiceData service, enabling robust static type checking with tools like Mypy. It is part of the `mypy-boto3` project, which generates comprehensive stubs for all AWS services based on their API definitions. The current version, 1.42.3, is designed to align with recent `boto3` releases and receives frequent updates.","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","stubs","directoryservicedata","type-checking"],"install":[{"cmd":"pip install mypy-boto3-ds-data","lang":"bash","label":"Install service stub"},{"cmd":"pip install boto3","lang":"bash","label":"Install boto3 (runtime dependency)"}],"dependencies":[],"imports":[{"note":"Client type stubs are imported from the `mypy_boto3_ds_data` package, not directly from `boto3`.","wrong":"from boto3.client import DirectoryServiceDataClient","symbol":"DirectoryServiceDataClient","correct":"from mypy_boto3_ds_data.client import DirectoryServiceDataClient"},{"note":"Type definitions for service request/response objects are found in `mypy_boto3_ds_data.type_defs`.","symbol":"ListTagsForResourceRequestRequestTypeDef","correct":"from mypy_boto3_ds_data.type_defs import ListTagsForResourceRequestRequestTypeDef"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_ds_data.client import DirectoryServiceDataClient\nfrom mypy_boto3_ds_data.type_defs import ListTagsForResourceRequestRequestTypeDef\nimport os\n\ndef get_directory_service_data_client() -> DirectoryServiceDataClient:\n    \"\"\"Initializes and returns a type-hinted DirectoryServiceData client.\"\"\"\n    # Actual credentials will come from environment variables or AWS config\n    # os.environ.get('AWS_ACCESS_KEY_ID', ''), etc.\n    return boto3.client(\"ds-data\")\n\nclient: DirectoryServiceDataClient = get_directory_service_data_client()\n\n# Example usage with type-checked parameters\n# Replace 'd-xxxxxxxxxx' with an actual Directory ID in your AWS account\n# or handle if the resource might not exist.\nresource_id = os.environ.get('DS_DATA_RESOURCE_ID', 'd-xxxxxxxxxx') # Placeholder\n\ntry:\n    params: ListTagsForResourceRequestRequestTypeDef = {\n        \"ResourceId\": resource_id\n    }\n    response = client.list_tags_for_resource(**params)\n    print(\"Tags for resource:\")\n    for tag in response.get('Tags', []):\n        print(f\"  {tag['Key']}: {tag['Value']}\")\nexcept client.exceptions.ResourceNotFoundException:\n    print(f\"Resource ID '{resource_id}' not found. Please provide a valid Directory ID.\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to initialize a type-hinted `DirectoryServiceDataClient` and use it to call a service method like `list_tags_for_resource`. It shows importing the client type and a request `TypeDef` for enhanced type checking. Remember to replace placeholder `ResourceId` with a valid one in your AWS account for actual execution."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher. If unable to upgrade, pin `mypy-boto3-builder` to `<8.12.0` and regenerate stubs, or use an older `mypy-boto3-*` package version if available.","message":"mypy-boto3-builder 8.12.0 removed support for Python 3.8. Projects relying on older Python versions for stubs will need to use an older builder version or upgrade Python.","severity":"breaking","affected_versions":">=8.12.0 (builder)"},{"fix":"Ensure `boto3` is installed in your project: `pip install boto3`.","message":"This package (`mypy-boto3-ds-data`) provides only type stubs. You must install `boto3` separately to have the actual runtime functionality.","severity":"gotcha","affected_versions":"All"},{"fix":"Keep your `mypy-boto3-ds-data` package version in sync with your `boto3` version. The `mypy-boto3` project aims to release stubs aligned with `boto3` releases.","message":"Type stubs are generated for specific `boto3` versions. Using `mypy-boto3-ds-data` with a significantly mismatched `boto3` version can lead to incorrect or incomplete type checking, as API definitions may differ.","severity":"gotcha","affected_versions":"All"},{"fix":"Use `from mypy_boto3_ds_data.client import DirectoryServiceDataClient` (or similar for other services/types) when type-hinting clients and service-specific types.","message":"When type-hinting a boto3 client or resource, the specific type definitions (e.g., `DirectoryServiceDataClient`) are imported from the `mypy_boto3_SERVICE_NAME` package, not directly from `boto3`.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}