Type Annotations for boto3 AWS ManagedGrafana

1.42.51 · active · verified Sat Apr 11

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.

Warnings

Install

Imports

Quickstart

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.

import boto3
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from mypy_boto3_grafana.client import ManagedGrafanaClient
    from mypy_boto3_grafana.type_defs import ListWorkspacesResponseTypeDef

def get_grafana_workspaces():
    # In a real application, consider using environment variables or other secure methods for credentials
    client: ManagedGrafanaClient = boto3.client("grafana")

    # Example: List AWS Grafana workspaces
    response: ListWorkspacesResponseTypeDef = client.list_workspaces()
    for workspace in response.get("workspaces", []):
        print(f"Workspace Name: {workspace.get('workspaceName')}, Status: {workspace.get('workspaceStatus')}")

if __name__ == "__main__":
    get_grafana_workspaces()

# To type-check this file: mypy your_script_name.py

view raw JSON →