{"id":3071,"library":"mypy-boto3-devicefarm","title":"mypy-boto3-devicefarm","description":"mypy-boto3-devicefarm provides comprehensive type annotations for the boto3 DeviceFarm service, enabling static type checking with tools like mypy. These type stubs enhance IDE autocompletion, improve code readability, and help catch potential runtime errors before deployment. It is currently at version 1.42.3, with releases closely mirroring `boto3` updates via the `mypy-boto3-builder`.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["AWS","boto3","mypy","type-hinting","static-analysis","devops","devicefarm"],"install":[{"cmd":"pip install mypy-boto3-devicefarm boto3","lang":"bash","label":"Install with boto3"}],"dependencies":[{"reason":"Runtime dependency for type checking. `mypy-boto3-devicefarm` provides type stubs for `boto3`'s DeviceFarm service. Although not a direct Python dependency, `boto3` must be installed to use these type stubs effectively.","package":"boto3","optional":false},{"reason":"Requires Python 3.9 or higher. Support for Python 3.8 was removed in `mypy-boto3-builder` 8.12.0, which generates these type stubs.","package":"python","optional":false}],"imports":[{"note":"The primary type hint for the boto3 DeviceFarm client.","symbol":"DeviceFarmClient","correct":"from mypy_boto3_devicefarm.client import DeviceFarmClient"},{"note":"Type hint for the literal service name string, useful for `boto3.client()` calls.","symbol":"DeviceFarmServiceName","correct":"from mypy_boto3_devicefarm.literals import DeviceFarmServiceName"},{"note":"An example TypedDict for the response structure of a DeviceFarm API call.","symbol":"ListDevicesResponseTypeDef","correct":"from mypy_boto3_devicefarm.type_defs import ListDevicesResponseTypeDef"}],"quickstart":{"code":"import os\nimport boto3\nfrom typing import TYPE_CHECKING\n\nif TYPE_CHECKING:\n    from mypy_boto3_devicefarm.client import DeviceFarmClient\n    from mypy_boto3_devicefarm.type_defs import ListDevicesResponseTypeDef\n\ndef get_devicefarm_client() -> 'DeviceFarmClient':\n    \"\"\"Returns a type-hinted boto3 DeviceFarm client.\"\"\"\n    # Ensure AWS credentials are available via environment variables or other boto3 config\n    # e.g., AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION\n    session = boto3.Session(\n        aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY'),\n        aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET'),\n        region_name=os.environ.get('AWS_REGION', 'us-west-2') # Device Farm is region-specific\n    )\n    client: DeviceFarmClient = session.client('devicefarm')\n    return client\n\ndef list_devicefarm_devices():\n    \"\"\"Lists available Device Farm devices with type hints.\"\"\"\n    client = get_devicefarm_client()\n    \n    print(\"Attempting to list Device Farm devices...\")\n    try:\n        response: ListDevicesResponseTypeDef = client.list_devices(filters=[{'attribute': 'PLATFORM', 'operator': 'EQUALS', 'values': ['ANDROID']}])\n        devices = response.get('devices', [])\n        if devices:\n            print(f\"Found {len(devices)} Android devices:\")\n            for device in devices:\n                print(f\"  - {device.get('name')} (ARN: {device.get('arn')})\")\n        else:\n            print(\"No Android devices found.\")\n    except client.exceptions.ServiceException as e:\n        print(f\"AWS Service Error: {e}\")\n    except Exception as e:\n        print(f\"An unexpected error occurred: {e}\")\n\nif __name__ == '__main__':\n    list_devicefarm_devices()","lang":"python","description":"This quickstart demonstrates how to obtain a type-hinted `boto3` DeviceFarm client and use it to call `list_devices`. It includes conditional type imports (`if TYPE_CHECKING`) for clean runtime behavior and shows how to type-hint both the client object and API call responses. Remember to configure your AWS credentials and region, as Device Farm is a region-specific service."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or later. If unable to upgrade Python, use an older `mypy-boto3-devicefarm` version that supported Python 3.8 (e.g., < 1.42.0).","message":"Python 3.8 support was removed in `mypy-boto3-builder` version 8.12.0, which generates these type stubs. Consequently, `mypy-boto3-devicefarm` versions 1.42.x and newer require Python 3.9 or higher.","severity":"breaking","affected_versions":"mypy-boto3-devicefarm >= 1.42.0"},{"fix":"Update your code to use the new TypeDef naming conventions. Refer to the `mypy-boto3-builder` documentation or regenerate stubs locally to find the correct names.","message":"TypeDef naming conventions changed in `mypy-boto3-builder` 8.9.0. TypeDefs for packed method arguments now use shorter names (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`), and conflicting `Extra` postfixes are moved to the end (e.g., `CreateDistributionExtraRequestTypeDef` to `CreateDistributionRequestExtraTypeDef`). Code relying on older, explicit TypeDef names may break.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.9.0 (affecting mypy-boto3-devicefarm versions generated by it)"},{"fix":"Ensure `boto3` is installed alongside `mypy-boto3-devicefarm` (e.g., `pip install boto3 mypy-boto3-devicefarm`).","message":"`mypy-boto3-devicefarm` provides only type annotations for static analysis; it does not include the `boto3` runtime itself. For your code to run, `boto3` must be installed separately.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install `mypy-boto3-devicefarm` with a version that matches your `boto3` installation (e.g., `pip install boto3==1.x.y mypy-boto3-devicefarm==1.x.y`).","message":"For optimal type checking and IDE experience, the version of `mypy-boto3-devicefarm` should ideally align with your installed `boto3` version. Mismatched versions can lead to incorrect or incomplete type hints.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Add explicit type annotations for boto3 client creations, as shown in the quickstart example.","message":"While many IDEs and type checkers can infer types, explicitly annotating `boto3.client` and `boto3.session.client` calls with the `DeviceFarmClient` type (e.g., `client: DeviceFarmClient = session.client('devicefarm')`) is recommended for the most robust type checking and best autocompletion, especially in environments like VSCode.","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"}