{"id":3096,"library":"mypy-boto3-grafana","title":"Type Annotations for boto3 AWS ManagedGrafana","description":"mypy-boto3-grafana provides static type annotations for the boto3 AWS ManagedGrafana service. It helps developers leverage mypy and IDEs for better code completion and error checking when working with boto3. The package is generated by `mypy-boto3-builder` and is updated frequently to align with new boto3 releases and AWS service updates, currently at version 1.42.51.","status":"active","version":"1.42.51","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","boto3","mypy","type-hints","grafana","static-analysis"],"install":[{"cmd":"pip install boto3 mypy-boto3-grafana","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Provides the AWS SDK for Python. These are type stubs for boto3.","package":"boto3","optional":false},{"reason":"Static type checker that utilizes these annotations.","package":"mypy","optional":true}],"imports":[{"note":"Import the client type directly for explicit type hinting.","symbol":"ManagedGrafanaClient","correct":"from mypy_boto3_grafana.client import ManagedGrafanaClient"},{"note":"Import specific TypedDicts for response or request structures.","symbol":"ListWorkspacesResponseTypeDef","correct":"from mypy_boto3_grafana.type_defs import ListWorkspacesResponseTypeDef"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING\n\nif TYPE_CHECKING:\n    from mypy_boto3_grafana.client import ManagedGrafanaClient\n    from mypy_boto3_grafana.type_defs import ListWorkspacesResponseTypeDef\n\ndef get_grafana_workspaces():\n    # In a real application, consider using environment variables or other secure methods for credentials\n    client: ManagedGrafanaClient = boto3.client(\"grafana\")\n\n    # Example: List AWS Grafana workspaces\n    response: ListWorkspacesResponseTypeDef = client.list_workspaces()\n    for workspace in response.get(\"workspaces\", []):\n        print(f\"Workspace Name: {workspace.get('workspaceName')}, Status: {workspace.get('workspaceStatus')}\")\n\nif __name__ == \"__main__\":\n    get_grafana_workspaces()\n\n# To type-check this file: mypy your_script_name.py","lang":"python","description":"This quickstart demonstrates how to use the `mypy-boto3-grafana` type annotations with a boto3 client. It explicitly types the client and a response object, allowing `mypy` to catch potential type mismatches."},"warnings":[{"fix":"Upgrade to Python 3.9+ or pin `mypy-boto3-grafana` to a version compatible with Python 3.8 (e.g., versions generated by `mypy-boto3-builder < 8.12.0`).","message":"Starting with `mypy-boto3-builder` version 8.12.0, support for Python 3.8 was removed. Projects using older Python versions must pin to an older `mypy-boto3-grafana` version generated by a builder prior to 8.12.0 or upgrade their Python version.","severity":"breaking","affected_versions":">=8.12.0 of mypy-boto3-builder (which generates mypy-boto3-grafana)"},{"fix":"Review your code for explicit TypeDef imports and update names according to the new conventions (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`, `CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`).","message":"Version 8.9.0 of `mypy-boto3-builder` introduced breaking changes in TypeDef naming conventions, potentially causing import errors or type mismatches if you were explicitly referencing generated TypedDicts with the old naming scheme.","severity":"breaking","affected_versions":">=8.9.0 of mypy-boto3-builder (and generated stubs)"},{"fix":"Add explicit type annotations for boto3 client, resource, waiter, and paginator objects, as shown in the quickstart example.","message":"While some IDEs (like PyCharm) and `mypy` can infer types for `boto3.client` calls, explicit type annotations (e.g., `client: ManagedGrafanaClient = boto3.client(\"grafana\")`) are often recommended for optimal autocompletion and comprehensive type checking, especially when using VSCode or the `boto3-stubs-lite` packages.","severity":"gotcha","affected_versions":"All"},{"fix":"As a workaround, you can assign `object` to the type-hinted variables outside the `TYPE_CHECKING` block: `if TYPE_CHECKING: from mypy_boto3_grafana.client import ManagedGrafanaClient else: ManagedGrafanaClient = object`.","message":"Pylint may complain about undefined variables when using `typing.TYPE_CHECKING` guards. This is a known issue with Pylint's static analysis when types are only defined conditionally.","severity":"gotcha","affected_versions":"All, with Pylint"},{"fix":"It is recommended to use `boto3-stubs-lite` (e.g., `mypy-boto3-grafana-lite` if available, or `boto3-stubs-lite[grafana]`) or disable PyCharm's internal type checker and rely solely on `mypy` or `pyright` instead.","message":"PyCharm users might experience slow performance or high CPU usage due to how it handles `Literal` overloads. This can be particularly noticeable with comprehensive stub packages like `mypy-boto3-grafana`.","severity":"gotcha","affected_versions":"All, with PyCharm"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}