{"id":3692,"library":"mypy-boto3-rum","title":"mypy-boto3-rum: CloudWatchRUM Type Stubs","description":"mypy-boto3-rum provides type annotations for the `boto3` CloudWatchRUM service, enhancing static analysis with tools like Mypy and Pyright. It is part of the `mypy-boto3` family of packages, generated by `mypy-boto3-builder`. The library is actively maintained with frequent updates, aligning with `boto3` releases to ensure up-to-date type information.","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-hints","cloudwatchrum","static-analysis","devops"],"install":[{"cmd":"pip install mypy-boto3-rum boto3","lang":"bash","label":"Install with boto3"}],"dependencies":[{"reason":"Runtime library for AWS SDK interactions, these are type stubs for it.","package":"boto3","optional":false},{"reason":"Required for compatibility with older Python versions and advanced typing features.","package":"typing-extensions"}],"imports":[{"note":"Used for explicit type annotation of the boto3 client.","symbol":"CloudWatchRUMClient","correct":"from mypy_boto3_rum.client import CloudWatchRUMClient"},{"note":"mypy-boto3 stubs enhance the existing `boto3` library; you don't typically import service clients directly from `boto3` in this manner for type checking.","wrong":"from boto3.rum import CloudWatchRUMClient","symbol":"boto3","correct":"import boto3"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING\n\n# For explicit type hinting, especially helpful for IDEs\nif TYPE_CHECKING:\n    from mypy_boto3_rum.client import CloudWatchRUMClient\n    from mypy_boto3_rum.type_defs import ListAppMonitorsResponseTypeDef\n\n\ndef get_rum_client() -> 'CloudWatchRUMClient':\n    \"\"\"Initializes and returns a typed CloudWatchRUM client.\"\"\"\n    # Mypy will correctly infer the type of 'client' if mypy-boto3-rum is installed\n    client: CloudWatchRUMClient = boto3.client('rum')\n    return client\n\n\ndef list_rum_app_monitors():\n    client = get_rum_client()\n    try:\n        response: ListAppMonitorsResponseTypeDef = client.list_app_monitors()\n        print(f\"Found {len(response.get('AppMonitorSummaries', []))} app monitors.\")\n        for monitor_summary in response.get('AppMonitorSummaries', []):\n            print(f\"  - {monitor_summary.get('Name')}: {monitor_summary.get('Id')}\")\n    except client.exceptions.ResourceNotFoundException:\n        print(\"No CloudWatch RUM app monitors found.\")\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n\n\nif __name__ == '__main__':\n    # This assumes AWS credentials are configured (e.g., via ~/.aws/credentials or env vars)\n    # For a real application, consider explicit region and credentials\n    list_rum_app_monitors()\n","lang":"python","description":"This example demonstrates how to initialize a `boto3` CloudWatchRUM client and use it to list app monitors, benefiting from `mypy-boto3-rum`'s type annotations for improved code completion and static analysis. Explicit type hints are included for better IDE support."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or a later version.","message":"Python 3.8 support has been removed as of `mypy-boto3-builder` version 8.12.0. Ensure your project runs on Python 3.9 or newer.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.12.0, mypy-boto3-rum (all versions generated by builder >=8.12.0)"},{"fix":"Update your `mypy` installation to the latest version. Verify `mypy` configuration to ensure stub discovery is working correctly.","message":"The `mypy-boto3` ecosystem migrated to PEP 561 compliant packages with `mypy-boto3-builder` 8.12.0. While largely backward compatible, it changes how type checkers discover stubs. Ensure your `mypy` is up to date.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.12.0"},{"fix":"Consult the `mypy-boto3` documentation for the specific service to find the updated `TypeDef` names and adjust your imports accordingly.","message":"Some generated `TypeDef` names were shortened in `mypy-boto3-builder` 8.9.0 (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). If you were explicitly importing and using such type definitions, they might have changed.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.9.0"},{"fix":"Add explicit type annotations for clients, resources, paginators, and waiters (e.g., `client: CloudWatchRUMClient = boto3.client('rum')`).","message":"For optimal code completion and type inference in IDEs like VSCode or PyCharm, it is often recommended to use explicit type annotations for `boto3.client` and `boto3.resource` calls, even though `mypy` might infer them implicitly.","severity":"gotcha","affected_versions":"All"},{"fix":"Set type-hinted variables to `object` in the `else` branch of `if TYPE_CHECKING:` blocks to satisfy Pylint.","message":"Pylint might raise `undefined-variable` warnings when using `mypy-boto3` stubs with `TYPE_CHECKING` guards.","severity":"gotcha","affected_versions":"All"},{"fix":"Consider installing `boto3-stubs-lite` (if available for CloudWatchRUM) or disabling PyCharm's built-in type checker and relying on `mypy` or `pyright` for checks.","message":"PyCharm users might experience slow performance or high CPU usage due to the complexity of `boto3-stubs`'s literal overloads.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}