Type Annotations for boto3 WAFV2

1.42.57 · active · verified Sat Apr 11

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.

Warnings

Install

Imports

Quickstart

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.

import boto3
from typing import TYPE_CHECKING
from mypy_boto3_wafv2 import WAFV2Client

if TYPE_CHECKING:
    # Only imported for type checking, not for runtime
    pass

def get_wafv2_client() -> WAFV2Client:
    # The boto3.client call is automatically typed by mypy-boto3
    # if 'boto3-stubs' or 'mypy-boto3-wafv2' is installed.
    client: WAFV2Client = boto3.client("wafv2")
    return client

# Example usage (runtime functionality requires AWS credentials)
# client = get_wafv2_client()
# try:
#     response = client.list_web_acls(Scope='CLOUDFRONT')
#     print(response['WebACLs'])
# except Exception as e:
#     print(f"Error listing Web ACLs: {e}")

view raw JSON →