Type annotations for aiobotocore Elastic Load Balancing V2
This library provides type annotations for the `aiobotocore` client interacting with the AWS Elastic Load Balancing V2 (ELBv2) service. It is generated by `mypy-boto3-builder` and ensures type-safe asynchronous AWS interactions. The current version is 3.4.0, and the `mypy-boto3-builder` project has a frequent release cadence, often aligning with new AWS service features and SDK updates.
Common errors
-
ModuleNotFoundError: No module named 'types_aiobotocore_elbv2'
cause The type stub package is not installed in your environment.fixRun `pip install types-aiobotocore-elbv2`. -
ModuleNotFoundError: No module named 'aiobotocore'
cause The runtime library for interacting with AWS is not installed.fixRun `pip install aiobotocore`. -
Argument of type "str" cannot be assigned to parameter "load_balancer_arn" of type "LoadBalancerArnType" in call to "delete_load_balancer"
cause Mypy is flagging an incorrect type for a function argument. This often happens if you're passing a plain string when a `Literal` type or a more specific `TypedDict` is expected, or if your types-aiobotocore version is out of sync with your aiobotocore version.fixConsult the `types-aiobotocore-elbv2` documentation or source for the correct `TypeDef` or `Literal` type. Ensure your `aiobotocore` and `types-aiobotocore-elbv2` versions are compatible and up-to-date. -
error: Incompatible types in assignment (expression has type "BaseClient", variable has type "ELBv2Client")
cause You are assigning the result of `session.create_client('elbv2')` to a variable explicitly type-hinted as `ELBv2Client` without a type assertion or without the correct import.fixEnsure you are importing `ELBv2Client` from `types_aiobotocore_elbv2.client` and explicitly type-hinting the client instance: `elbv2_client: ELBv2Client = client`.
Warnings
- breaking Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0. Users on Python 3.8 must upgrade their Python version to 3.9 or newer.
- breaking Type definition (TypeDef) argument names might have changed in `mypy-boto3-builder` version 8.9.0 for brevity (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`).
- gotcha This library provides *type annotations* only. `aiobotocore` (and optionally `boto3` if you mix async/sync operations) must be installed separately for the code to run at runtime.
- gotcha The `mypy-boto3-builder` projects now use PEP 561 packaging. While this generally improves compatibility, ensure you are not relying on internal builder structures or non-standard import paths that might have changed.
Install
-
pip install types-aiobotocore-elbv2 aiobotocore
Imports
- ELBv2Client
from types_aiobotocore.elbv2 import ELBv2Client
from types_aiobotocore_elbv2.client import ELBv2Client
- DescribeLoadBalancersOutputTypeDef
from types_aiobotocore_elbv2.client import DescribeLoadBalancersOutputTypeDef
from types_aiobotocore_elbv2.type_defs import DescribeLoadBalancersOutputTypeDef
Quickstart
import asyncio
from aiobotocore.session import get_session
from types_aiobotocore_elbv2.client import ELBv2Client
async def describe_elbv2_load_balancers():
session = get_session()
async with session.create_client("elbv2") as client:
# Explicitly type-hint the client for static analysis
elbv2_client: ELBv2Client = client
response = await elbv2_client.describe_load_balancers()
print(f"ELBv2 Load Balancers: {response.get('LoadBalancers')}")
if __name__ == "__main__":
asyncio.run(describe_elbv2_load_balancers())