{"id":3145,"library":"mypy-boto3-shield","title":"mypy-boto3-shield Type Annotations","description":"mypy-boto3-shield provides type annotations for the AWS boto3 Shield service (version 1.42.3), enabling static type checking and improved IDE support. It is automatically generated by the `mypy-boto3-builder` tool, which frequently updates to match new `boto3` releases and features.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["mypy","boto3","aws","type-hints","stubs","shield","typings"],"install":[{"cmd":"pip install mypy-boto3-shield","lang":"bash","label":"Install service-specific stubs"},{"cmd":"pip install boto3-stubs[shield]","lang":"bash","label":"Install via boto3-stubs (recommended)"}],"dependencies":[{"reason":"Runtime dependency for the AWS SDK for Python (Boto3).","package":"boto3"},{"reason":"Static type checker, for which these annotations are primarily intended.","package":"mypy"},{"reason":"Requires Python 3.9 or higher.","package":"python","optional":false}],"imports":[{"symbol":"ShieldClient","correct":"from mypy_boto3_shield import ShieldClient"},{"symbol":"ListAttacksPaginator","correct":"from mypy_boto3_shield.paginator import ListAttacksPaginator"},{"symbol":"ResponseActionOutputTypeDef","correct":"from mypy_boto3_shield.type_defs import ResponseActionOutputTypeDef"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING\n\nif TYPE_CHECKING:\n    from mypy_boto3_shield import ShieldClient\n    from mypy_boto3_shield.type_defs import ListAttacksResponseTypeDef\n\n# Instantiate a Shield client with type hints\nclient: \"ShieldClient\" = boto3.client(\"shield\")\n\n# Example of using a client method with type checking\ntry:\n    response: \"ListAttacksResponseTypeDef\" = client.list_attacks()\n    print(f\"Found {len(response.get('Attacks', []))} Shield attacks.\")\nexcept Exception as e:\n    print(f\"Error listing attacks: {e}\")\n\n# Example of a TypedDict for input (if applicable, or output)\ndef process_response_action(action: \"ResponseActionOutputTypeDef\") -> None:\n    if 'Block' in action:\n        print(f\"Action is a block: {action['Block']}\")\n    elif 'Count' in action:\n        print(f\"Action is a count: {action['Count']}\")\n\n# For demonstration, typically this comes from an API call\nexample_action: \"ResponseActionOutputTypeDef\" = {\"Block\": {}}\nprocess_response_action(example_action)","lang":"python","description":"This quickstart demonstrates how to obtain a type-hinted `ShieldClient` and use its methods, benefiting from autocompletion and static type checking. It also shows an example of using a generated `TypedDict` for clearer data structure definitions. The `TYPE_CHECKING` block ensures type imports are only active during type-checking."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher.","message":"As of mypy-boto3-builder version 8.12.0, support for Python 3.8 has been removed across all generated `mypy-boto3` packages, including `mypy-boto3-shield`. Users on Python 3.8 will need to upgrade to Python 3.9 or newer.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.12.0"},{"fix":"Review and update `TypeDef` names in your type annotations according to the new conventions.","message":"mypy-boto3-builder version 8.9.0 introduced breaking changes to `TypeDef` naming conventions, such as shortening `CreateDistributionRequestRequestTypeDef` to `CreateDistributionRequestTypeDef` and adjusting postfixes for conflicting names. This may require updating type annotation references in your codebase if you're upgrading from older versions.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.9.0"},{"fix":"Prefer `boto3-stubs[service_name]` or direct `mypy-boto3-service_name` installations over the legacy `mypy-boto3` package.","message":"The original `mypy-boto3` package is considered legacy. It is recommended to use `boto3-stubs` (the umbrella package) or install individual service stubs like `mypy-boto3-shield` directly for better compatibility and maintenance.","severity":"deprecated","affected_versions":"All versions"},{"fix":"Consider `pip uninstall boto3-stubs && pip install boto3-stubs-lite` or configure PyCharm to use an external type checker.","message":"PyCharm may experience slow performance with `Literal` overloads from `mypy-boto3` stubs (issue PY-40997). If this occurs, it's recommended to use `boto3-stubs-lite` (if available for the service) or to disable PyCharm's internal type checker and rely on external tools like `mypy` or `pyright`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Add explicit type annotations when instantiating clients, paginators, and waiters for optimal IDE support.","message":"While `mypy-boto3` generally provides auto-discovery of types for `boto3.client` calls, explicit type annotations for the client object (e.g., `client: ShieldClient = boto3.client('shield')`) are often necessary for the best autocompletion and type-checking experience in IDEs like VSCode and PyCharm, especially for methods like `get_paginator` or `get_waiter`.","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"}