Type Annotations for boto3 NetworkManager
mypy-boto3-networkmanager provides type annotations for the `boto3` NetworkManager service. It is part of the `mypy-boto3` project, generated by `mypy-boto3-builder`, ensuring static type checking for the AWS SDK for Python (Boto3). It helps catch API usage errors at development time. The current version is 1.42.3 and new versions are frequently released to align with `boto3` updates and `mypy-boto3-builder` improvements.
Warnings
- breaking `mypy-boto3` packages (including `mypy-boto3-networkmanager`) no longer support Python 3.8 as of `mypy-boto3-builder` version 8.12.0. The minimum required Python version is now 3.9.
- breaking Type definition naming conventions changed in `mypy-boto3-builder` version 8.9.0. This primarily affects `TypeDef` names which may have become shorter (e.g., `RequestRequestTypeDef` to `RequestTypeDef`) or had postfixes moved (e.g., `ExtraRequestTypeDef` to `RequestExtraTypeDef`).
- gotcha This package provides only type stubs. `boto3` must be installed separately in your project for the code to run at runtime. `mypy-boto3-networkmanager` does not automatically install `boto3`.
- gotcha For optimal type checking, the version of `mypy-boto3-networkmanager` should closely match your installed `boto3` version. Mismatched versions can lead to incorrect type hints or missed type errors.
- gotcha Migration to PEP 561 packages in `mypy-boto3-builder` version 8.12.0 means packages are now installed in an editable mode by default if using modern pip. While this generally improves discovery, it might interact unexpectedly with specific build systems or older environments.
Install
-
pip install mypy-boto3-networkmanager boto3
Imports
- NetworkManagerClient
from mypy_boto3_networkmanager.client import NetworkManagerClient
- ServiceName
from mypy_boto3_networkmanager.literals import ServiceName
Quickstart
import boto3
from mypy_boto3_networkmanager import NetworkManagerClient
def list_all_core_networks() -> None:
# Initialize the client with type hinting
client: NetworkManagerClient = boto3.client("networkmanager")
print("Listing Core Networks...")
try:
response = client.list_core_networks()
core_networks = response.get("CoreNetworks", [])
if core_networks:
for cn in core_networks:
print(f" - {cn.get('CoreNetworkId')} ({cn.get('State')})")
else:
print(" No Core Networks found.")
except Exception as e:
print(f"An error occurred: {e}")
if __name__ == "__main__":
list_all_core_networks()