Install & Compatibility
Where this runs
tested against v1.43.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.610s · 118MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 7.7s · import 0.567s · 116MB
115MB installed
● package 115MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ElasticLoadBalancingClient
✓ from mypy_boto3_elb.client import ElasticLoadBalancingClient
For type-hinting the ELB client object.
LoadBalancerDescriptionTypeDef
✓ from mypy_boto3_elb.type_defs import LoadBalancerDescriptionTypeDef
For type-hinting specific dictionary-based response structures.
Paginator
✓ from mypy_boto3_elb.paginator import DescribeLoadBalancersPaginator
For type-hinting paginator objects specific to ELB operations.
This quickstart demonstrates how to initialize an Elastic Load Balancing (ELB) client with type hints and use it to list classic load balancers. The `TYPE_CHECKING` block ensures that type-related imports are only active during static analysis, preventing runtime overhead. Replace dummy AWS credentials or ensure they are configured in your environment.
import boto3
from typing import TYPE_CHECKING
import os
# Ensure boto3 is configured, e.g., via environment variables or AWS CLI config
# For quickstart, using dummy values if not set in environment
os.environ.setdefault('AWS_ACCESS_KEY_ID', 'YOUR_ACCESS_KEY')
os.environ.setdefault('AWS_SECRET_ACCESS_KEY', 'YOUR_SECRET_KEY')
os.environ.setdefault('AWS_DEFAULT_REGION', 'us-east-1')
if TYPE_CHECKING:
from mypy_boto3_elb.client import ElasticLoadBalancingClient
from mypy_boto3_elb.type_defs import LoadBalancerDescriptionTypeDef
def list_classic_load_balancers() -> None:
"""Lists classic load balancers and their DNS names with type hints."""
# boto3.client automatically infers the return type if mypy-boto3-elb is installed
client: ElasticLoadBalancingClient = boto3.client("elb")
try:
response = client.describe_load_balancers()
load_balancers: list[LoadBalancerDescriptionTypeDef] = response["LoadBalancerDescriptions"]
if not load_balancers:
print("No classic load balancers found.")
return
print("Classic Load Balancers:")
for lb in load_balancers:
print(f" Name: {lb['LoadBalancerName']}")
print(f" DNS Name: {lb['DNSName']}")
print(f" Scheme: {lb.get('Scheme', 'internet-facing')}") # 'Scheme' might be optional
except Exception as e:
print(f"Error describing load balancers: {e}")
if __name__ == "__main__":
list_classic_load_balancers()
Debug
Known issues
breakingSupport for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0 (affecting all generated stubs). Users on Python 3.8 must either upgrade Python or pin `mypy-boto3-builder` and generated stubs to an older version.fixUpgrade your Python environment to 3.9 or newer.
affects: mypy-boto3-builder >=8.12.0, mypy-boto3-elb >=1.42.3
breakingTypeDef naming conventions changed in `mypy-boto3-builder` 8.9.0. Specifically, argument TypeDefs may use shorter names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`), and conflicting 'Extra' postfixes moved to the end.fixUpdate your code to use the new TypeDef names. Refer to the specific service's documentation for exact changes.
affects: mypy-boto3-builder >=8.9.0, mypy-boto3-elb >=1.42.3
gotchaThe version of `mypy-boto3-elb` is designed to match the version of `boto3`. For optimal compatibility and correct type inference, it is highly recommended to install `mypy-boto3-elb` (or `boto3-stubs[elb]`) that corresponds to your installed `boto3` version.fixEnsure `pip install mypy-boto3-elb==X.Y.Z` where X.Y.Z matches your `boto3` version, or use `pip install 'boto3-stubs[boto3]'` for synced installation if using the meta-package.
affects: All versions
gotchaWhen using PyCharm, you might experience slow performance with Literal overloads. The maintainers recommend using `boto3-stubs-lite` (e.g., `pip install 'boto3-stubs-lite[elb]'`) or disabling PyCharm's built-in type checker in favor of MyPy or Pyright.fixConsider `boto3-stubs-lite[elb]` for reduced memory footprint or rely on external type checkers.
affects: All versions, specifically with PyCharm
gotchaPylint may report 'undefined variable' errors for type-hinted `boto3` clients/resources outside of `TYPE_CHECKING` blocks. To mitigate this, define mock `object` types for the imported symbols outside the `TYPE_CHECKING` block.fixWrap type imports in `if TYPE_CHECKING:` block and define fallback `object` assignments, as shown in the quickstart example comments.
affects: All versions, specifically with Pylint
gotchaAll `mypy-boto3` packages migrated to `PEP 561` package format in `mypy-boto3-builder` 8.12.0. While this primarily impacts package structure, ensure your tooling (e.g., custom build systems) is compatible with this standard.fixVerify that your environment correctly handles `py.typed` files and PEP 561 compliant stub packages.
affects: mypy-boto3-builder >=8.12.0, mypy-boto3-elb >=1.42.3
Upgrade
Version history
1.43.0latest on PyPI · released Apr 29, 2026
Audit
Dependencies
boto3requiredRuntime library for AWS API interaction.
mypyoptionalStatic type checker.
pyrightoptionalAlternative static type checker.