{"id":2603,"library":"mypy-boto3-emr","title":"Type annotations for boto3 EMR","description":"mypy-boto3-emr provides high-quality type annotations for the AWS boto3 EMR (Elastic MapReduce) service. It allows developers to leverage static type checking with tools like MyPy, improving code reliability and developer experience when working with boto3. The library is currently at version 1.42.77 and is part of the `youtype/mypy_boto3_builder` project, which generates new stub packages frequently, typically aligning with boto3/botocore releases.","status":"active","version":"1.42.77","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["mypy","boto3","aws","type-hinting","emr","stubs","static-analysis"],"install":[{"cmd":"pip install mypy-boto3-emr","lang":"bash","label":"Install the EMR stubs"},{"cmd":"pip install boto3 mypy","lang":"bash","label":"Install runtime and type checker"}],"dependencies":[{"reason":"This package provides type stubs for boto3; boto3 itself is required for runtime functionality.","package":"boto3","optional":false},{"reason":"Required for static type checking. The stubs are only useful if MyPy or a similar type checker is used.","package":"mypy","optional":false}],"imports":[{"note":"Import the typed client object for explicit type hints.","symbol":"EMRClient","correct":"from mypy_boto3_emr.client import EMRClient"},{"note":"Import specific TypeDef objects for precise typing of API responses or request parameters.","symbol":"ListClustersOutputTypeDef","correct":"from mypy_boto3_emr.type_defs import ListClustersOutputTypeDef"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING, List, Dict, Any\nimport os\n\n# Conditional import for type checking only\nif TYPE_CHECKING:\n    from mypy_boto3_emr.client import EMRClient\n    from mypy_boto3_emr.type_defs import ListClustersOutputTypeDef, ClusterSummaryTypeDef\n\n# Example function using type hints\ndef get_running_emr_clusters() -> List[ClusterSummaryTypeDef]:\n    # The client variable is explicitly typed for MyPy\n    client: EMRClient = boto3.client(\n        \"emr\",\n        region_name=os.environ.get('AWS_REGION', 'us-east-1'),\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    )\n\n    # The response variable is explicitly typed\n    response: ListClustersOutputTypeDef = client.list_clusters(ClusterStates=['RUNNING'])\n\n    clusters: List[ClusterSummaryTypeDef] = response.get('Clusters', [])\n    print(f\"Found {len(clusters)} running EMR clusters.\")\n    for cluster in clusters:\n        print(f\"  - Cluster ID: {cluster['Id']}, Name: {cluster['Name']}\")\n    return clusters\n\nif __name__ == \"__main__\":\n    # This code will run, but type hints are only checked by MyPy\n    get_running_emr_clusters()\n","lang":"python","description":"This quickstart demonstrates how to use `mypy-boto3-emr` to add type hints to your boto3 EMR client and API responses. The `TYPE_CHECKING` block ensures that stub imports are only processed by the type checker, avoiding runtime import errors if the stubs are not installed. Explicitly typing the client and response objects allows MyPy to provide comprehensive checks."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer. If you must use Python 3.8, you will be limited to older versions of `mypy-boto3-emr`.","message":"Support for Python 3.8 has been removed in `mypy-boto3-builder` version 8.12.0. Users on Python 3.8 will need to upgrade to Python 3.9 or newer to use the latest stub packages.","severity":"breaking","affected_versions":">=8.12.0 of mypy-boto3-builder (and generated stubs)"},{"fix":"Review your code for explicit imports of `_type_defs` and adjust the `TypeDef` names according to the new conventions.","message":"TypeDef naming conventions changed significantly in `mypy-boto3-builder` version 8.9.0. Specifically, redundant 'Request' suffixes were removed (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`), and 'Extra' postfixes moved to the end of the name. This may break explicit imports of TypeDefs.","severity":"breaking","affected_versions":">=8.9.0 of mypy-boto3-builder (and generated stubs)"},{"fix":"Ensure `boto3` is installed alongside `mypy-boto3-emr` (e.g., `pip install boto3 mypy-boto3-emr`).","message":"`mypy-boto3-emr` provides *only* type stubs for the EMR service. It does not include the runtime `boto3` library itself. For your code to run, `boto3` must be installed separately.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Stay updated with `boto3` and `mypy-boto3` releases. If a service name changes, update your `boto3.client()` calls and install the correct `mypy-boto3-servicename` package.","message":"AWS service names can change or be deprecated over time (e.g., `sms-voice` was replaced by `pinpoint-sms-voice` in builder 8.11.0). This means the corresponding `mypy-boto3` stub package names might also change or be removed. Always consult the latest `boto3` and `mypy-boto3` documentation for current service names.","severity":"gotcha","affected_versions":"All versions (ecosystem-wide)"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}