{"id":3568,"library":"mypy-boto3-connectcampaigns","title":"Type Annotations for boto3 ConnectCampaignService","description":"mypy-boto3-connectcampaigns provides comprehensive type annotations for the AWS boto3 ConnectCampaignService. It's automatically generated with mypy-boto3-builder, ensuring up-to-date and accurate type hints for boto3 client calls, paginators, waiters, literals, and TypeDefs. This library helps developers leverage static analysis with tools like MyPy, Pyright, and IDEs for improved code quality and auto-completion. The current version is 1.42.3, following the boto3 release cycle.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["boto3","aws","mypy","typing","type-hints","stubs","connectcampaigns","static-analysis"],"install":[{"cmd":"pip install mypy-boto3-connectcampaigns boto3","lang":"bash","label":"Install standalone"},{"cmd":"pip install 'boto3-stubs[connectcampaigns]' boto3","lang":"bash","label":"Install via boto3-stubs (recommended)"}],"dependencies":[{"reason":"Runtime dependency for the AWS SDK, which these stubs annotate.","package":"boto3"},{"reason":"Optional, for static type checking; this library provides the types.","package":"mypy","optional":true}],"imports":[{"note":"Client type annotation for boto3.client('connectcampaigns')","symbol":"ConnectCampaignServiceClient","correct":"from mypy_boto3_connectcampaigns import ConnectCampaignServiceClient"},{"note":"Paginator type annotation for client.get_paginator('list_campaigns')","symbol":"ListCampaignsPaginator","correct":"from mypy_boto3_connectcampaigns.paginator import ListCampaignsPaginator"},{"note":"Literal type for campaign states","symbol":"CampaignStateType","correct":"from mypy_boto3_connectcampaigns.literals import CampaignStateType"},{"note":"TypedDict for CreateCampaign API request parameters","symbol":"CreateCampaignRequestTypeDef","correct":"from mypy_boto3_connectcampaigns.type_defs import CreateCampaignRequestTypeDef"}],"quickstart":{"code":"import boto3\nimport os\nfrom typing import TYPE_CHECKING\n\n# Conditional import for type checking only\nif TYPE_CHECKING:\n    from mypy_boto3_connectcampaigns import ConnectCampaignServiceClient\n    from mypy_boto3_connectcampaigns.type_defs import CreateCampaignRequestTypeDef\n\n\ndef create_campaign_typed(\n    client: 'ConnectCampaignServiceClient',\n    instance_id: str,\n    campaign_name: str\n) -> dict:\n    dialer_config: CreateCampaignRequestTypeDef['dialerConfig'] = {\n        'progressiveDialerConfig': {\n            'bandwidthAllocation': 1.0,\n            'dialingCapacity': 100.0\n        }\n    }\n    outbound_config: CreateCampaignRequestTypeDef['outboundCallConfig'] = {\n        'connectContactFlowId': os.environ.get('CONNECT_CONTACT_FLOW_ID', 'dummy-flow-id'),\n        'connectQueueId': os.environ.get('CONNECT_QUEUE_ID', 'dummy-queue-id'),\n    }\n\n    response = client.create_campaign(\n        name=campaign_name,\n        connectInstanceId=instance_id,\n        dialerConfig=dialer_config,\n        outboundCallConfig=outbound_config\n    )\n    print(f\"Created campaign: {response.get('id')}\")\n    return response\n\n\n# Example usage (runtime without type checking dependency)\nif __name__ == \"__main__\":\n    # In a real scenario, these would be actual AWS resource IDs\n    connect_instance_id = os.environ.get(\n        'CONNECT_INSTANCE_ID', \n        'arn:aws:connect:us-east-1:123456789012:instance/dummy-instance-id'\n    )\n    campaign_name = \"MyTestCampaign\"\n\n    # Boto3 client without explicit type hint for runtime\n    # Type checkers (like mypy) will infer ConnectCampaignServiceClient\n    connect_campaigns_client = boto3.client('connectcampaigns')\n\n    # Using the typed function\n    print(\"Attempting to create a campaign...\")\n    try:\n        # This call would typically fail without valid AWS credentials and resource IDs\n        # For demonstration, we'll catch the expected client error\n        result = create_campaign_typed(\n            connect_campaigns_client, # type: ignore # Mypy might complain without explicit cast or if not in TYPE_CHECKING block\n            connect_instance_id,\n            campaign_name\n        )\n        print(f\"Function returned (actual creation might fail without real AWS setup): {result}\")\n    except Exception as e:\n        print(f\"Caught expected error during campaign creation (requires valid AWS setup): {e}\")\n        print(\"Please ensure CONNECT_INSTANCE_ID, CONNECT_CONTACT_FLOW_ID, CONNECT_QUEUE_ID env vars are set for a successful run.\")","lang":"python","description":"This quickstart demonstrates how to use the `mypy-boto3-connectcampaigns` type annotations with a boto3 client. It shows explicit type hints for the client and a `TypeDef` for request parameters, which is particularly useful for complex AWS API calls. It includes a `TYPE_CHECKING` block to ensure the stub dependency is only active during static analysis, preventing runtime issues if the stub is not installed or to reduce production package size."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or a later version. Ensure `python_requires='>=3.9'` is set in your project.","message":"Python 3.8 support has been removed since `mypy-boto3-builder` version 8.12.0. Users must upgrade to Python 3.9 or newer.","severity":"breaking","affected_versions":">=8.12.0 (builder), all stubs generated by it."},{"fix":"Update your code to use the new TypeDef names as per the latest generated stubs. Refer to the documentation or your IDE's auto-completion.","message":"TypeDef naming conventions changed in `mypy-boto3-builder` version 8.9.0. Packed method argument TypeDefs use shorter names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`), and conflicting 'Extra' postfixes moved to the end (e.g., `CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`).","severity":"breaking","affected_versions":">=8.9.0 (builder), all stubs generated by it."},{"fix":"If your project uses `sms-voice`, switch to `pinpoint-sms-voice` for both runtime boto3 calls and type annotations.","message":"The `sms-voice` service was deprecated and removed from `mypy-boto3-builder` in version 8.11.0. Users of `sms-voice` stubs should migrate to `pinpoint-sms-voice`.","severity":"deprecated","affected_versions":">=8.11.0 (builder), stubs related to `sms-voice`"},{"fix":"Add explicit type hints, e.g., `client: ConnectCampaignServiceClient = boto3.client('connectcampaigns')`.","message":"While MyPy and PyCharm often infer types automatically, VSCode and some other IDEs might require explicit type annotations for `boto3.client`, `boto3.session.client`, `client.get_waiter`, and `client.get_paginator` calls for full auto-completion and type checking.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Wrap stub imports with `if TYPE_CHECKING:` and define runtime placeholders with `else: MyType = object`.","message":"For conditional type checking to avoid runtime dependencies on stubs (e.g., in production builds) or to address `pylint` warnings about undefined variables, use `typing.TYPE_CHECKING` with fallback to `object`.","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"}