mypy-boto3-waf

1.42.3 · active · verified Sat Apr 11

mypy-boto3-waf provides type annotations for the AWS WAF service client in boto3, enabling static type checking with tools like Mypy. It is part of the mypy-boto3-builder project, which generates stubs for all boto3 services. The library is actively maintained, with version 1.42.3 available, and releases are frequent, typically aligned with updates to boto3 and the builder itself.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and use the type hints for the AWS WAF client. By annotating the boto3 client with `WAFClient`, Mypy can provide static analysis for WAF service calls, ensuring correct parameter types and return values.

import boto3
from mypy_boto3_waf.client import WAFClient

def get_waf_webacls() -> None:
    # mypy will now correctly type-check 'client'
    client: WAFClient = boto3.client("waf")
    try:
        response = client.list_web_acls()
        for web_acl in response.get("WebACLs", []):
            print(f"WebACL Name: {web_acl['Name']}, ID: {web_acl['WebACLId']}")
    except Exception as e:
        print(f"Error listing WebACLs: {e}")

if __name__ == "__main__":
    get_waf_webacls()

view raw JSON →