{"id":3054,"library":"mypy-boto3-codeguruprofiler","title":"mypy-boto3-codeguruprofiler Type Stubs","description":"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`.","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-stubs","codeguruprofiler","typing","static-analysis"],"install":[{"cmd":"pip install mypy-boto3-codeguruprofiler boto3 mypy","lang":"bash","label":"Install package and core dependencies"}],"dependencies":[{"reason":"The AWS SDK for Python, which these type stubs annotate.","package":"boto3"},{"reason":"The primary static type checker that utilizes these stubs for validation.","package":"mypy"},{"reason":"Requires Python 3.9 or higher as of mypy-boto3-builder 8.12.0.","package":"python","optional":false}],"imports":[{"note":"While `boto3.client` works at runtime, `mypy` and IDEs require explicit import of the client type from `mypy-boto3-codeguruprofiler` for full type checking and autocompletion.","wrong":"import boto3; client = boto3.client('codeguruprofiler')","symbol":"CodeGuruProfilerClient","correct":"from mypy_boto3_codeguruprofiler.client import CodeGuruProfilerClient"},{"note":"Type definitions for API responses are available in the `type_defs` submodule for more precise type checking of dictionary structures.","symbol":"ListProfilingGroupsOutputTypeDef","correct":"from mypy_boto3_codeguruprofiler.type_defs import ListProfilingGroupsOutputTypeDef"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING\nimport os\n\n# Ensure you have AWS credentials configured (e.g., via environment variables or ~/.aws/credentials)\n# For a runnable example, we use a default session.\n\nif TYPE_CHECKING:\n    from mypy_boto3_codeguruprofiler.client import CodeGuruProfilerClient\n    from mypy_boto3_codeguruprofiler.type_defs import ListProfilingGroupsOutputTypeDef\n\n# Initialize boto3 client with explicit type annotation\n# This enables IDE autocompletion and static type checking by mypy.\nclient: \"CodeGuruProfilerClient\" = boto3.client(\"codeguruprofiler\")\n\ntry:\n    # Example API call with type-hinted response\n    response: \"ListProfilingGroupsOutputTypeDef\" = client.list_profiling_groups()\n\n    print(\"Successfully listed CodeGuruProfiler profiling groups:\")\n    if response.get(\"profilingGroups\"):\n        for group in response[\"profilingGroups\"]:\n            print(f\"  - Name: {group.get('name')}, Arn: {group.get('arn')}\")\n    else:\n        print(\"  No profiling groups found.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure your AWS credentials are configured and you have permissions to list CodeGuruProfiler profiling groups.\")\n","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer.","message":"Support for Python 3.8 was removed in `mypy-boto3-builder` 8.12.0 (the generator for these stubs), meaning `mypy-boto3-codeguruprofiler` and other generated packages now require Python 3.9 or higher.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0"},{"fix":"For new projects or multi-service setups, consider `pip install 'types-boto3[codeguruprofiler]'`.","message":"Starting from `mypy-boto3-builder` 8.12.0, all packages migrated to PEP 561 compliant distribution. While individual service packages like `mypy-boto3-codeguruprofiler` still work, the recommended installation for multiple services is `pip install 'types-boto3[SERVICE1,SERVICE2]'`.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0"},{"fix":"Review and update custom type definitions or explicit TypeDef imports to reflect the new naming conventions if you are using affected services.","message":"In `mypy-boto3-builder` 8.9.0, TypeDefs for packed method arguments were refactored to use shorter names (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). Additionally, conflicting `Extra` postfixes were moved to the end (`CreateDistributionExtraRequestTypeDef` became `CreateDistributionRequestExtraTypeDef`). This might impact existing code that directly references these specific TypeDef names.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.9.0"},{"fix":"It is recommended to use `boto3-stubs-lite` (if applicable for your service) or to disable PyCharm's type checker and rely on external tools like `mypy` or `pyright`.","message":"PyCharm users might experience slow performance and high CPU usage due to Literal overloads (issue PY-40997).","severity":"gotcha","affected_versions":"All versions with PyCharm"},{"fix":"To resolve this, set all type-hinted variables to `object` in the `else` branch of the `TYPE_CHECKING` block. Example: `if TYPE_CHECKING: from my_lib import MyClass else: MyClass = object`.","message":"When using `if TYPE_CHECKING:` guards to make type stubs a `dev` dependency, `pylint` might complain about undefined variables in the runtime branch.","severity":"gotcha","affected_versions":"All versions with Pylint and TYPE_CHECKING"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}