{"id":3084,"library":"mypy-boto3-elb","title":"mypy-boto3-elb Type Stubs for AWS Elastic Load Balancing","description":"mypy-boto3-elb provides type annotations for the `boto3` Elastic Load Balancing (ELB) service. It allows static type checkers like MyPy and Pyright to validate `boto3` calls, improving code quality and developer experience. The library version 1.42.3 matches the corresponding `boto3` version, and it's actively maintained with frequent updates reflecting changes in AWS services and `boto3` itself.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","boto3","mypy","type-hints","elb","elastic-load-balancing","stubs","type-checking"],"install":[{"cmd":"pip install mypy-boto3-elb boto3 mypy","lang":"bash","label":"Standalone Installation (recommended for specific service)"},{"cmd":"pip install 'boto3-stubs[elb]' boto3 mypy","lang":"bash","label":"Installation via boto3-stubs meta-package"}],"dependencies":[{"reason":"Runtime library for AWS API interaction.","package":"boto3","optional":false},{"reason":"Static type checker.","package":"mypy","optional":true},{"reason":"Alternative static type checker.","package":"pyright","optional":true}],"imports":[{"note":"For type-hinting the ELB client object.","symbol":"ElasticLoadBalancingClient","correct":"from mypy_boto3_elb.client import ElasticLoadBalancingClient"},{"note":"For type-hinting specific dictionary-based response structures.","symbol":"LoadBalancerDescriptionTypeDef","correct":"from mypy_boto3_elb.type_defs import LoadBalancerDescriptionTypeDef"},{"note":"For type-hinting paginator objects specific to ELB operations.","symbol":"Paginator","correct":"from mypy_boto3_elb.paginator import DescribeLoadBalancersPaginator"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING\nimport os\n\n# Ensure boto3 is configured, e.g., via environment variables or AWS CLI config\n# For quickstart, using dummy values if not set in environment\nos.environ.setdefault('AWS_ACCESS_KEY_ID', 'YOUR_ACCESS_KEY')\nos.environ.setdefault('AWS_SECRET_ACCESS_KEY', 'YOUR_SECRET_KEY')\nos.environ.setdefault('AWS_DEFAULT_REGION', 'us-east-1')\n\nif TYPE_CHECKING:\n    from mypy_boto3_elb.client import ElasticLoadBalancingClient\n    from mypy_boto3_elb.type_defs import LoadBalancerDescriptionTypeDef\n\ndef list_classic_load_balancers() -> None:\n    \"\"\"Lists classic load balancers and their DNS names with type hints.\"\"\"\n    # boto3.client automatically infers the return type if mypy-boto3-elb is installed\n    client: ElasticLoadBalancingClient = boto3.client(\"elb\")\n    \n    try:\n        response = client.describe_load_balancers()\n        load_balancers: list[LoadBalancerDescriptionTypeDef] = response[\"LoadBalancerDescriptions\"]\n        \n        if not load_balancers:\n            print(\"No classic load balancers found.\")\n            return\n\n        print(\"Classic Load Balancers:\")\n        for lb in load_balancers:\n            print(f\"  Name: {lb['LoadBalancerName']}\")\n            print(f\"  DNS Name: {lb['DNSName']}\")\n            print(f\"  Scheme: {lb.get('Scheme', 'internet-facing')}\") # 'Scheme' might be optional\n    except Exception as e:\n        print(f\"Error describing load balancers: {e}\")\n\nif __name__ == \"__main__\":\n    list_classic_load_balancers()\n","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer.","message":"Support 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.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.12.0, mypy-boto3-elb >=1.42.3"},{"fix":"Update your code to use the new TypeDef names. Refer to the specific service's documentation for exact changes.","message":"TypeDef 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.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.9.0, mypy-boto3-elb >=1.42.3"},{"fix":"Ensure `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.","message":"The 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consider `boto3-stubs-lite[elb]` for reduced memory footprint or rely on external type checkers.","message":"When 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.","severity":"gotcha","affected_versions":"All versions, specifically with PyCharm"},{"fix":"Wrap type imports in `if TYPE_CHECKING:` block and define fallback `object` assignments, as shown in the quickstart example comments.","message":"Pylint 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.","severity":"gotcha","affected_versions":"All versions, specifically with Pylint"},{"fix":"Verify that your environment correctly handles `py.typed` files and PEP 561 compliant stub packages.","message":"All `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.","severity":"gotcha","affected_versions":"mypy-boto3-builder >=8.12.0, mypy-boto3-elb >=1.42.3"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}