{"id":3613,"library":"mypy-boto3-lex-models","title":"mypy-boto3-lex-models Type Stubs for LexModelBuildingService","description":"mypy-boto3-lex-models provides type annotations for the boto3 LexModelBuildingService, ensuring compatibility with static type checkers like mypy and IDEs such as VSCode and PyCharm. It is generated by the `mypy-boto3-builder` project and is updated frequently to align with new `boto3` releases. This library helps in catching potential bugs, improving code completion, and enhancing the overall developer experience when interacting with the AWS Lex Model Building service.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["typing","mypy","boto3","aws","lex-models","type-stubs","static-analysis","type-checking"],"install":[{"cmd":"pip install mypy-boto3-lex-models","lang":"bash","label":"Standalone package"},{"cmd":"pip install 'boto3-stubs[lex-models]'","lang":"bash","label":"As part of boto3-stubs"}],"dependencies":[{"reason":"Runtime dependency for the stubs to be useful; provides the actual AWS SDK functionality.","package":"boto3","optional":false},{"reason":"May be required for full type annotation support on older Python versions, though Python 3.9+ handles most natively.","package":"typing-extensions","optional":true}],"imports":[{"symbol":"LexModelBuildingServiceClient","correct":"from mypy_boto3_lex_models import LexModelBuildingServiceClient"},{"symbol":"GetBotVersionsResponseTypeDef","correct":"from mypy_boto3_lex_models.type_defs import GetBotVersionsResponseTypeDef"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING\n\nif TYPE_CHECKING:\n    from mypy_boto3_lex_models import LexModelBuildingServiceClient\n    from mypy_boto3_lex_models.type_defs import GetBotVersionsResponseTypeDef\n\ndef list_lex_bots_typed() -> 'GetBotVersionsResponseTypeDef':\n    \"\"\"Lists Lex V1 bots with type annotations.\"\"\"\n    # Type checker/IDE will infer client type, but explicit annotation is good practice\n    client: LexModelBuildingServiceClient = boto3.client(\"lex-models\")\n    response = client.get_bot_versions()\n    print(f\"Found {len(response.get('bots', []))} Lex V1 bots.\")\n    for bot in response.get('bots', []):\n        print(f\"  - {bot.get('name')} (Version: {bot.get('version')})\")\n    return response\n\nif __name__ == \"__main__\":\n    # Ensure AWS credentials (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION)\n    # are configured in your environment or ~/.aws/credentials and ~/.aws/config\n    list_lex_bots_typed()","lang":"python","description":"This quickstart demonstrates how to use `mypy-boto3-lex-models` to add type annotations to your boto3 client for the Lex Model Building Service. It shows importing the client type and a common response `TypeDef`, then using it to list Lex V1 bots with improved type checking and IDE support. The `TYPE_CHECKING` block ensures type imports are only active during static analysis, avoiding runtime dependencies."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or a later supported version.","message":"Python 3.8 support was removed for all `mypy-boto3` packages with `mypy-boto3-builder 8.12.0` and later. Users must upgrade to Python 3.9 or newer.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.12.0 (generating mypy-boto3-* packages)"},{"fix":"Most modern type checkers (mypy, pyright) should automatically detect PEP 561 packages. Ensure your type checker and environment are up to date.","message":"Packages migrated to PEP 561. This change affects how type checkers discover and use the stubs. Ensure your type checker is configured to correctly find PEP 561 compliant packages.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.12.0 (generating mypy-boto3-* packages)"},{"fix":"Update explicit `TypeDef` references in your code to match the new naming conventions, or rely on implicit type inference where possible.","message":"TypeDef naming conventions changed in `mypy-boto3-builder 8.9.0`. Packed method arguments use shorter names (`CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`), and conflicting `Extra` postfixes moved (`CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`).","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.9.0 (generating mypy-boto3-* packages)"},{"fix":"Consider using the `boto3-stubs` or `types-boto3` umbrella package with service-specific extras if you use multiple AWS services.","message":"While standalone `mypy-boto3-lex-models` is installable, for managing multiple AWS service stubs, `pip install 'boto3-stubs[lex-models]'` (or `types-boto3[lex-models]`) is often recommended. This keeps service stubs version-locked to `boto3` and simplifies dependency management.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use `pip install 'boto3-stubs-lite[lex-models]'` instead of the full version.","message":"PyCharm users might experience slow performance with Literal overloads. For better IDE responsiveness, especially with many services, consider installing the 'lite' version of stubs (e.g., `boto3-stubs-lite[lex-models]`).","severity":"gotcha","affected_versions":"All versions (specific to PyCharm)"},{"fix":"Add an `else` branch to your `TYPE_CHECKING` guard: `else: LexModelBuildingServiceClient = object`.","message":"When using `from typing import TYPE_CHECKING` guards to conditionally import stubs for Pylint compatibility, Pylint might report 'undefined variable' errors outside the `TYPE_CHECKING` block. A common workaround is to assign `object` to the type hints in the `else` branch.","severity":"gotcha","affected_versions":"All versions (specific to Pylint)"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}