{"id":3646,"library":"mypy-boto3-network-firewall","title":"Type Annotations for boto3 NetworkFirewall","description":"mypy-boto3-network-firewall provides comprehensive type annotations for the AWS boto3 Network Firewall service (version 1.42.3). These type stubs are generated by mypy-boto3-builder (version 8.12.0) and enhance developer experience in IDEs like VSCode and PyCharm, as well as with static type checkers such as Mypy and Pyright. The library is actively maintained, with updates released in sync with new boto3 versions and improvements to the underlying builder.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["type-hints","mypy","boto3","aws","network-firewall","pyright","stub"],"install":[{"cmd":"pip install mypy-boto3-network-firewall","lang":"bash","label":"Install standalone package"},{"cmd":"pip install 'boto3-stubs[network-firewall]' # Recommended for combined use with boto3-stubs","lang":"bash","label":"Install as part of boto3-stubs (recommended)"}],"dependencies":[{"reason":"Provides type annotations for the boto3 library, specifically for the Network Firewall service. A compatible version of boto3 is required at runtime.","package":"boto3","optional":false},{"reason":"A static type checker that consumes these annotations.","package":"mypy","optional":true},{"reason":"A static type checker that consumes these annotations.","package":"pyright","optional":true},{"reason":"Required for proper handling of certain type constructs in older Python versions supported by the builder, though less critical for Python 3.9+ which this package primarily targets.","package":"typing-extensions","optional":false}],"imports":[{"note":"Imports the type for the boto3 NetworkFirewall client.","symbol":"NetworkFirewallClient","correct":"from mypy_boto3_network_firewall.client import NetworkFirewallClient"},{"note":"Imports literals for service names, useful for type-safe client creation.","symbol":"NetworkFirewallServiceName","correct":"from mypy_boto3_network_firewall.literals import NetworkFirewallServiceName"},{"note":"Imports specific TypedDicts and other type definitions for request/response payloads.","symbol":"FirewallPolicyStatusType","correct":"from mypy_boto3_network_firewall.type_defs import FirewallPolicyStatusType"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING\n\nif TYPE_CHECKING:\n    from mypy_boto3_network_firewall.client import NetworkFirewallClient\n\ndef list_network_firewalls():\n    # The AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are typically picked\n    # up from environment variables or AWS config files.\n    # Using os.environ.get for example purposes to avoid hardcoding credentials.\n    client: NetworkFirewallClient = boto3.client(\n        \"network-firewall\",\n        region_name=os.environ.get('AWS_REGION', 'us-east-1')\n    )\n\n    response = client.list_firewalls(\n        MaxResults=5 # Limit for demonstration\n    )\n\n    print(\"Found Firewalls:\")\n    for firewall in response.get(\"Firewalls\", []):\n        print(f\"  - {firewall.get('FirewallName')} ({firewall.get('FirewallArn')})\")\n\nif __name__ == \"__main__\":\n    import os\n    # Set dummy AWS credentials for local execution without actual AWS calls\n    # For actual execution, ensure valid credentials and region are configured.\n    os.environ['AWS_ACCESS_KEY_ID'] = os.environ.get('AWS_ACCESS_KEY_ID', 'testing')\n    os.environ['AWS_SECRET_ACCESS_KEY'] = os.environ.get('AWS_SECRET_ACCESS_KEY', 'testing')\n    os.environ['AWS_SESSION_TOKEN'] = os.environ.get('AWS_SESSION_TOKEN', 'testing')\n\n    try:\n        list_network_firewalls()\n    except Exception as e:\n        print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to initialize a `boto3` NetworkFirewall client with type annotations and perform a basic operation like listing firewalls. The `TYPE_CHECKING` block ensures type hints are only present during type checking, avoiding runtime dependencies on `mypy-boto3-network-firewall`."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer. Consider using Python 3.9+ for all `mypy-boto3-*` packages.","message":"Support for Python 3.8 was removed in mypy-boto3-builder 8.12.0. As mypy-boto3-network-firewall 1.42.3 was generated with this builder version, it requires Python 3.9 or higher. Ensure your environment meets this requirement.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.12.0, mypy-boto3-network-firewall >=1.42.3"},{"fix":"If encountering issues with type checker discovery, perform a clean reinstall of `mypy-boto3-network-firewall` and ensure your `mypy` or `pyright` configuration is up to date.","message":"The `mypy-boto3-builder` (version 8.12.0) migrated to PEP 561 compliant packages. This change might affect how type checkers locate stubs in some environments or require a clean reinstall of stub packages.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.12.0, mypy-boto3-network-firewall >=1.42.3"},{"fix":"Install `boto3` with a version matching or closely compatible with your `mypy-boto3-network-firewall` package version. For example, if using `mypy-boto3-network-firewall==1.42.3`, install `boto3==1.42.3`.","message":"The version of `mypy-boto3-network-firewall` (e.g., 1.42.3) directly corresponds to the `boto3` and `botocore` version it provides stubs for, not the `mypy-boto3-builder` version. Ensure your installed `boto3` version is compatible with the `mypy-boto3-network-firewall` version for accurate type checking.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If you directly import and use `TypeDef` classes, you may need to update their names in your code to match the new conventions. Review the specific `type_defs` for `network-firewall` if you encounter type resolution errors.","message":"The `mypy-boto3-builder` (from version 8.9.0) introduced breaking changes to `TypeDef` naming conventions, such as shortening names for packed method arguments (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`) and moving the `Extra` postfix for conflicting names.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.9.0"},{"fix":"Implement the recommended workaround by conditionally setting the types to `object` outside the `TYPE_CHECKING` block. Example: `if TYPE_CHECKING: from mypy_boto3_ec2.client import EC2Client else: EC2Client = object`.","message":"When using `mypy-boto3` stubs with Pylint, if you employ `TYPE_CHECKING` guards to conditionally import types, Pylint might incorrectly report `undefined-variable` warnings for the type-hinted variables. This is a known issue with Pylint.","severity":"gotcha","affected_versions":"All versions when used with Pylint"},{"fix":"Explicitly add type annotations to your `boto3` client, paginator, or waiter objects, as shown in the quickstart example, to ensure optimal IDE support.","message":"While static type checkers like mypy and pyright can often infer types, some IDEs (especially older versions of VSCode with Pylance) might require explicit type annotations for `boto3.client`, `boto3.session.client`, `client.get_waiter`, and `client.get_paginator` calls to provide full autocomplete and type hinting.","severity":"gotcha","affected_versions":"All versions when using certain IDEs/language servers"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}