{"id":3167,"library":"mypy-boto3-wafv2","title":"Type Annotations for boto3 WAFV2","description":"Type annotations for boto3 WAFV2 service, part of the `mypy-boto3` project. This project provides comprehensive type hints for `boto3` and `aioboto3` AWS SDKs, enhancing static analysis, IDE autocompletion, and catching type-related errors before runtime. It closely follows `botocore` updates, generating up-to-date service-specific stubs. The current version is 1.42.57, generated with `mypy-boto3-builder` 8.12.0.","status":"active","version":"1.42.57","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["mypy","boto3","aws","type-hints","wafv2","static-analysis","autocompletion"],"install":[{"cmd":"pip install mypy-boto3-wafv2","lang":"bash","label":"Install service-specific stubs"},{"cmd":"pip install 'boto3-stubs[wafv2]'","lang":"bash","label":"Install as part of boto3-stubs meta-package"}],"dependencies":[{"reason":"This package provides type hints for boto3. Boto3 itself must be installed for the code to run.","package":"boto3","optional":false},{"reason":"Required for static type checking; pyright is also supported.","package":"mypy","optional":true}],"imports":[{"note":"For client type annotation.","symbol":"WAFV2Client","correct":"from mypy_boto3_wafv2 import WAFV2Client"},{"note":"Alternative explicit client import path.","symbol":"WAFV2Client","correct":"from mypy_boto3_wafv2.client import WAFV2Client"},{"note":"For type definitions (TypedDicts) for service responses or request parameters.","symbol":"APIKeySummaryTypeDef","correct":"from mypy_boto3_wafv2.type_defs import APIKeySummaryTypeDef"},{"note":"For literal types representing specific allowed string values.","symbol":"ActionValueType","correct":"from mypy_boto3_wafv2.literals import ActionValueType"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING\nfrom mypy_boto3_wafv2 import WAFV2Client\n\nif TYPE_CHECKING:\n    # Only imported for type checking, not for runtime\n    pass\n\ndef get_wafv2_client() -> WAFV2Client:\n    # The boto3.client call is automatically typed by mypy-boto3\n    # if 'boto3-stubs' or 'mypy-boto3-wafv2' is installed.\n    client: WAFV2Client = boto3.client(\"wafv2\")\n    return client\n\n# Example usage (runtime functionality requires AWS credentials)\n# client = get_wafv2_client()\n# try:\n#     response = client.list_web_acls(Scope='CLOUDFRONT')\n#     print(response['WebACLs'])\n# except Exception as e:\n#     print(f\"Error listing Web ACLs: {e}\")","lang":"python","description":"Demonstrates how to obtain a type-hinted WAFV2 client using boto3. The `TYPE_CHECKING` block is a common pattern to avoid runtime dependencies on the stub package while still getting type hints during static analysis."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or later.","message":"Python 3.8 support has been removed since `mypy-boto3-builder` version 8.12.0. All `mypy-boto3-*` packages now require Python 3.9 or newer.","severity":"breaking","affected_versions":">=8.12.0 of mypy-boto3-builder, affecting all generated stubs"},{"fix":"Ensure your environment correctly handles PEP 561 compliant stub packages. Most standard Python tools (pip, setuptools) should handle this automatically.","message":"The `mypy-boto3` project migrated to PEP 561 for package structure with `mypy-boto3-builder` 8.12.0. This changes how stub packages are distributed and might affect custom tooling or build processes that relied on the previous package layout.","severity":"breaking","affected_versions":">=8.12.0 of mypy-boto3-builder, affecting all generated stubs"},{"fix":"Update your code to use the new, shorter TypeDef names. Refer to the specific service's documentation for correct names or rely on IDE autocompletion.","message":"Type definition (TypedDict) naming conventions were changed in `mypy-boto3-builder` 8.9.0. This can break code that explicitly references old TypeDef names (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`).","severity":"breaking","affected_versions":">=8.9.0 of mypy-boto3-builder, affecting all generated stubs"},{"fix":"In the `else` block of your `TYPE_CHECKING` guard, explicitly assign the imported types to `object`, e.g., `else: WAFV2Client = object`.","message":"When using `if TYPE_CHECKING:` guards to conditionally import type hints, Pylint might report undefined variables if the types are not explicitly assigned to `object` in the `else` branch. Mypy and other type checkers are generally fine without this.","severity":"gotcha","affected_versions":"All versions when using Pylint with `TYPE_CHECKING` guards"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}