mypy-boto3-codeguruprofiler Type Stubs

1.42.3 · active · verified Sat Apr 11

mypy-boto3-codeguruprofiler provides comprehensive type annotations for the `boto3` CodeGuruProfiler service, enhancing code quality and developer experience by enabling static type checking with tools like `mypy` and improving IDE autocompletion. Currently at version 1.42.3, it is part of the `mypy-boto3` ecosystem, which sees frequent updates, typically aligning with `boto3` releases and undergoing major revisions with its `mypy-boto3-builder`.

Warnings

Install

Imports

Quickstart

Demonstrates how to initialize a `boto3` CodeGuruProfiler client with explicit type hints from `mypy-boto3-codeguruprofiler` and call an API, ensuring static type checking by `mypy`. For `mypy` to work, `boto3` and `mypy` must also be installed.

import boto3
from typing import TYPE_CHECKING
import os

# Ensure you have AWS credentials configured (e.g., via environment variables or ~/.aws/credentials)
# For a runnable example, we use a default session.

if TYPE_CHECKING:
    from mypy_boto3_codeguruprofiler.client import CodeGuruProfilerClient
    from mypy_boto3_codeguruprofiler.type_defs import ListProfilingGroupsOutputTypeDef

# Initialize boto3 client with explicit type annotation
# This enables IDE autocompletion and static type checking by mypy.
client: "CodeGuruProfilerClient" = boto3.client("codeguruprofiler")

try:
    # Example API call with type-hinted response
    response: "ListProfilingGroupsOutputTypeDef" = client.list_profiling_groups()

    print("Successfully listed CodeGuruProfiler profiling groups:")
    if response.get("profilingGroups"):
        for group in response["profilingGroups"]:
            print(f"  - Name: {group.get('name')}, Arn: {group.get('arn')}")
    else:
        print("  No profiling groups found.")

except Exception as e:
    print(f"An error occurred: {e}")
    print("Please ensure your AWS credentials are configured and you have permissions to list CodeGuruProfiler profiling groups.")

view raw JSON →