{"id":3677,"library":"mypy-boto3-qapps","title":"mypy-boto3-qapps: Type Annotations for AWS QApps","description":"mypy-boto3-qapps provides high-quality type annotations for the `boto3` AWS QApps service client, enabling static type checking with tools like MyPy. It is generated using `mypy-boto3-builder` (currently version 8.12.0) and is updated frequently, often in sync with `boto3` and AWS API changes.","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 Hinting","Stubs","QApps"],"install":[{"cmd":"pip install mypy-boto3-qapps","lang":"bash","label":"Install service stubs"},{"cmd":"pip install boto3","lang":"bash","label":"Install boto3 (if not already installed)"}],"dependencies":[{"reason":"Runtime dependency for the AWS SDK, mypy-boto3-qapps provides type stubs for it.","package":"boto3"}],"imports":[{"symbol":"QAppsClient","correct":"from mypy_boto3_qapps.client import QAppsClient"},{"symbol":"CreateQAppRequestRequestTypeDef","correct":"from mypy_boto3_qapps.type_defs import CreateQAppRequestRequestTypeDef"},{"note":"Resource clients are imported from `service_resource` module, not `resource`.","wrong":"from mypy_boto3_qapps.resource import QAppsServiceResource","symbol":"QAppsServiceResource","correct":"from mypy_boto3_qapps.service_resource import QAppsServiceResource"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING, Dict, Any\n\nfrom mypy_boto3_qapps.client import QAppsClient\nfrom mypy_boto3_qapps.type_defs import CreateQAppRequestRequestTypeDef, CreateQAppResponseTypeDef\n\n# Instantiate the boto3 client, annotated with mypy-boto3 types\n# Use TYPE_CHECKING block to avoid runtime dependency if stubs are dev-only\nif TYPE_CHECKING:\n    client: QAppsClient = boto3.client(\"qapps\")\nelse:\n    client = boto3.client(\"qapps\")\n\n# Example: Create a QApp\n# Note: This is a dummy example; replace placeholder values with actual data.\n# The instanceId typically refers to an Amazon Q instance.\ninstance_id = \"your_amazon_q_instance_id\" # e.g., 'your-instance-id'\n\ncreate_qapp_params: CreateQAppRequestRequestTypeDef = {\n    \"instanceId\": instance_id,\n    \"appDefinition\": {\n        \"appDefinitionArn\": \"arn:aws:qapps:region:account:app/id\", # Example ARN\n        \"appDefinitionType\": \"PACKAGE_JSON\"\n    }\n    # \"tags\": {\"key\": \"value\"} # Optional\n}\n\ntry:\n    print(f\"Attempting to create QApp for instance: {instance_id}\")\n    response: CreateQAppResponseTypeDef = client.create_q_app(\n        **create_qapp_params\n    )\n    print(f\"Successfully created QApp.\")\n    print(f\"App ID: {response.get('appId')}\")\n    print(f\"App ARN: {response.get('appArn')}\")\n    print(f\"Status: {response.get('status')}\")\nexcept client.exceptions.ValidationException as e:\n    print(f\"Validation Error: {e}\")\nexcept client.exceptions.ResourceNotFoundException as e:\n    print(f\"Resource Not Found Error: {e}\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n","lang":"python","description":"Demonstrates how to initialize a `boto3` QApps client with type annotations and use a type-checked `CreateQAppRequestRequestTypeDef` for creating a QApp. The `TYPE_CHECKING` block ensures that stub imports are only active during static analysis, preventing runtime errors if stubs are a dev dependency. Remember to replace placeholder `instanceId` and `appDefinitionArn` with actual values."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or later. If unable to upgrade, pin `mypy-boto3-qapps` to a version compatible with builder < 8.12.0 (e.g., `<1.42.0`).","message":"Starting with `mypy-boto3-builder` version 8.12.0, Python 3.8 is no longer supported for generated type stubs. Projects targeting `mypy-boto3-qapps` (and other `mypy-boto3-*` packages) must use Python 3.9 or newer.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0 (affecting mypy-boto3-qapps >= 1.42.0)"},{"fix":"Review your `from mypy_boto3_qapps.type_defs import ...` statements and adjust TypeDef names according to the new conventions. Consult the `mypy-boto3` documentation for the specific service if needed.","message":"TypeDef naming conventions were changed in `mypy-boto3-builder` 8.9.0. Some TypeDef names, especially those ending with `RequestRequestTypeDef` or `ExtraRequestTypeDef`, have been shortened or reordered (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). This impacts direct imports of TypeDef classes.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.9.0 (affecting mypy-boto3-qapps >= 1.35.0)"},{"fix":"Always install `mypy-boto3-servicename` for the specific services you need, rather than the monolithic `mypy-boto3` package, to optimize install size and avoid unnecessary dependencies.","message":"The `mypy-boto3-*` packages are service-specific type stubs. You must install the specific package for each AWS service you use (e.g., `mypy-boto3-qapps` for QApps). Installing `mypy-boto3` (the meta-package) includes stubs for all services and can lead to a large installation footprint and potential conflicts.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use `from typing import TYPE_CHECKING` and enclose your type hints like `if TYPE_CHECKING: client: QAppsClient = boto3.client('qapps')`.","message":"When annotating a `boto3` client with `mypy-boto3` types, it's best practice to wrap the type annotation in a `if TYPE_CHECKING:` block. This prevents runtime `ImportError` if `mypy-boto3-*` stubs are installed as development dependencies and not available in the production environment.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}