{"id":3569,"library":"mypy-boto3-connectcampaignsv2","title":"Type annotations for boto3 Connect Campaign Service V2","description":"mypy-boto3-connectcampaignsv2 provides type annotations for the `boto3` AWS SDK's ConnectCampaignServiceV2. This library enhances developer experience by enabling static type checking with tools like MyPy and providing robust IDE autocompletion for the otherwise dynamically typed `boto3` library. It is currently at version 1.42.45 and is actively maintained with frequent updates tied to `boto3` and `mypy-boto3-builder` releases.","status":"active","version":"1.42.45","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","boto3","mypy","type-hints","stubs","connectcampaignsv2","static-analysis"],"install":[{"cmd":"pip install mypy-boto3-connectcampaignsv2 boto3","lang":"bash","label":"Install library and boto3"},{"cmd":"pip install mypy","lang":"bash","label":"Install MyPy (for type checking)"}],"dependencies":[{"reason":"Runtime dependency for interacting with AWS services.","package":"boto3","optional":false},{"reason":"Static type checker, the primary use case for these stubs.","package":"mypy","optional":true}],"imports":[{"note":"Client type is specifically within the 'client' submodule.","wrong":"from mypy_boto3_connectcampaignsv2 import ConnectCampaignServiceV2Client","symbol":"ConnectCampaignServiceV2Client","correct":"from mypy_boto3_connectcampaignsv2.client import ConnectCampaignServiceV2Client"},{"note":"Type definitions for response objects are crucial for comprehensive type checking.","symbol":"ListCampaignsResponseTypeDef","correct":"from mypy_boto3_connectcampaignsv2.type_defs import ListCampaignsResponseTypeDef"},{"note":"Imports for type-checking only should be guarded by `if TYPE_CHECKING:` to avoid adding stubs as runtime dependencies.","wrong":"from mypy_boto3_connectcampaignsv2.client import ConnectCampaignServiceV2Client","symbol":"TYPE_CHECKING","correct":"from typing import TYPE_CHECKING\n\nif TYPE_CHECKING:\n    from mypy_boto3_connectcampaignsv2.client import ConnectCampaignServiceV2Client"}],"quickstart":{"code":"from __future__ import annotations\nimport boto3\nimport os\nfrom typing import TYPE_CHECKING\n\n# Guard type-only imports with TYPE_CHECKING\nif TYPE_CHECKING:\n    from mypy_boto3_connectcampaignsv2.client import ConnectCampaignServiceV2Client\n    from mypy_boto3_connectcampaignsv2.type_defs import ListCampaignsResponseTypeDef\n\ndef list_all_connect_campaigns() -> ListCampaignsResponseTypeDef:\n    \"\"\"Lists all Connect Campaigns using type-hinted boto3 client.\"\"\"\n    # boto3 client is dynamically typed by default\n    # The type hint from mypy-boto3 provides static analysis capabilities\n    client: ConnectCampaignServiceV2Client = boto3.client(\n        \"connectcampaignsv2\",\n        region_name=os.environ.get(\"AWS_REGION\", \"us-east-1\"),\n        aws_access_key_id=os.environ.get(\"AWS_ACCESS_KEY_ID\", \"\"),\n        aws_secret_access_key=os.environ.get(\"AWS_SECRET_ACCESS_KEY\", \"\")\n    )\n\n    print(\"Fetching Connect Campaigns...\")\n    response: ListCampaignsResponseTypeDef = client.list_campaigns()\n    \n    for campaign in response.get(\"campaigns\", []):\n        print(f\"  Campaign ID: {campaign.get('id')}, Name: {campaign.get('name')}\")\n    \n    print(f\"Total campaigns found: {len(response.get('campaigns', []))}\")\n    return response\n\nif __name__ == \"__main__\":\n    # This code will run even without mypy-boto3 installed, \n    # but mypy would check its types during static analysis.\n    campaign_data = list_all_connect_campaigns()\n    # You can access typed attributes here, e.g., campaign_data['campaigns']\n","lang":"python","description":"Demonstrates how to initialize a type-hinted `boto3` client for ConnectCampaignServiceV2 and perform a simple operation (`list_campaigns`). The `if TYPE_CHECKING:` block ensures that the `mypy-boto3` stubs are only used for static analysis and not as a runtime dependency. Ensure AWS credentials are set in your environment for `boto3` to function."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer. Ensure your `pyproject.toml` or `setup.cfg` reflects `requires-python >= 3.9`.","message":"Python 3.8 support has been removed. `mypy-boto3` packages (including this one) now require Python 3.9 or higher.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0"},{"fix":"No direct code change required for users. Ensure your `mypy` or `pyright` configurations are up-to-date and correctly configured to find third-party stubs.","message":"Migration to PEP 561 packages. This is an internal change primarily affecting how Python tools discover stubs.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0"},{"fix":"Review and update your import paths and variable annotations for `TypeDef` objects to use the new shorter names.","message":"TypeDef names for packed method arguments were shortened. E.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.9.0"},{"fix":"Always install `boto3` alongside `mypy-boto3-connectcampaignsv2` (e.g., `pip install boto3 mypy-boto3-connectcampaignsv2`).","message":"This package only provides type stubs. You must also install `boto3` (the actual AWS SDK) for your code to run.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Try to keep `boto3` and `mypy-boto3-*` packages in sync. `pip install mypy-boto3-builder` can generate stubs compatible with your installed `boto3` version locally.","message":"Version mismatch between `boto3` and `mypy-boto3-*` can lead to incorrect or missing type hints.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always encapsulate type-only imports within `from typing import TYPE_CHECKING` blocks.","message":"Omitting `if TYPE_CHECKING:` for type imports will make `mypy-boto3-connectcampaignsv2` a runtime dependency, which is unnecessary overhead.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}