{"id":3582,"library":"mypy-boto3-forecastquery","title":"mypy-boto3-forecastquery Type Stubs","description":"mypy-boto3-forecastquery provides static type annotations for the AWS Boto3 ForecastQueryService client, enhancing development with autocompletion, type checking, and improved code readability in IDEs and static analysis tools like MyPy and Pyright. It is generated by the mypy-boto3-builder project and is currently at version 1.42.3, typically updated in sync with Boto3 releases.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","boto3","mypy","typing","type-stubs","forecastquery","static-analysis"],"install":[{"cmd":"pip install mypy-boto3-forecastquery boto3","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"This package provides type stubs for the `boto3` library; `boto3` itself is a runtime dependency.","package":"boto3"},{"reason":"May be required for full type hint compatibility on older Python versions (<3.9) to support modern typing features, though recent builder versions removed Python 3.8 support.","package":"typing-extensions"}],"imports":[{"note":"Boto3's native client does not provide type hints; these are in the stub package. Importing directly from `mypy_boto3_forecastquery` is also incorrect; the client is in the `client` submodule.","wrong":"from boto3.client import ForecastQueryService","symbol":"ForecastQueryServiceClient","correct":"from mypy_boto3_forecastquery.client import ForecastQueryServiceClient"},{"note":"Response types and other type definitions are found in the `type_defs` submodule.","symbol":"QueryForecastResponseTypeDef","correct":"from mypy_boto3_forecastquery.type_defs import QueryForecastResponseTypeDef"},{"note":"Service name literals are provided for explicit typing.","symbol":"ForecastQueryServiceName","correct":"from mypy_boto3_forecastquery.literals import ForecastQueryServiceName"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING\nfrom mypy_boto3_forecastquery.type_defs import QueryForecastResponseTypeDef\n\nif TYPE_CHECKING:\n    from mypy_boto3_forecastquery.client import ForecastQueryServiceClient\n\n\ndef get_forecast_query_client() -> 'ForecastQueryServiceClient':\n    \"\"\"Returns a typed ForecastQueryService client.\"\"\"\n    return boto3.client(\"forecastquery\")\n\n\ndef main():\n    client = get_forecast_query_client()\n    try:\n        response: QueryForecastResponseTypeDef = client.query_forecast(\n            ForecastArn='arn:aws:forecast:us-east-1:123456789012:forecast/my-forecast-name',\n            StartDate='2023-01-01T00:00:00Z',\n            EndDate='2023-01-07T00:00:00Z',\n            Filters={'item_id': 'item_abc'}\n        )\n        print(\"Forecast data retrieved:\")\n        for item in response.get('Forecast', {}).get('Predictions', {}).get('mean', []):\n            print(f\"  Timestamp: {item['Timestamp']}, Value: {item['Value']}\")\n    except client.exceptions.ResourceNotFoundException:\n        print(\"Forecast not found. Ensure ARN and filters are correct.\")\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n\nif __name__ == \"__main__\":\n    # Replace with a valid Forecast ARN and region for actual execution\n    # os.environ['AWS_ACCESS_KEY_ID'] = 'YOUR_ACCESS_KEY'\n    # os.environ['AWS_SECRET_ACCESS_KEY'] = 'YOUR_SECRET_KEY'\n    # os.environ['AWS_REGION'] = 'us-east-1'\n    main()\n","lang":"python","description":"This quickstart demonstrates how to obtain a type-hinted ForecastQueryService client using `mypy-boto3-forecastquery` and perform a `query_forecast` operation. The `if TYPE_CHECKING:` block ensures that `mypy-boto3-forecastquery` remains a development-only dependency."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or later. Ensure your type checker (e.g., mypy) is configured to correctly discover PEP 561 type packages if using isolated environments.","message":"Starting with `mypy-boto3-builder` version 8.12.0 (which generated `mypy-boto3-forecastquery` 1.42.3), support for Python 3.8 has been removed. Projects using this package must use Python 3.9 or newer. This release also migrated to PEP 561 compliant packages.","severity":"breaking","affected_versions":">=1.42.3"},{"fix":"Review and update explicit TypeDef imports and references in your code to match the new naming conventions. Consult the `mypy-boto3-builder` release notes for details.","message":"Version 8.9.0 of `mypy-boto3-builder` introduced breaking changes in TypeDef naming conventions (e.g., shorter names, repositioning of 'Extra' postfix). This may affect existing code that explicitly imports or refers to generated TypeDefs.","severity":"breaking","affected_versions":"Generated by `mypy-boto3-builder` >=8.9.0"},{"fix":"Ensure both `boto3` and `mypy-boto3-forecastquery` are installed in your development environment. Keep their versions aligned to prevent mismatches in type hints.","message":"It is crucial to install `mypy-boto3-forecastquery` alongside `boto3`. Without the stub package, IDEs and static type checkers cannot provide accurate autocompletion or type validation for `boto3`'s dynamically generated clients.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For PyCharm users, `mypy-boto3-lite` (e.g., `boto3-stubs-lite[forecastquery]`) is recommended as a lighter alternative that avoids some overloads. Alternatively, disable PyCharm's built-in type checker and rely on `mypy` or `pyright` for static analysis.","message":"PyCharm may experience slow performance or high CPU usage when handling `Literal` overloads within `mypy-boto3` packages.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Wrap type-only imports within an `if TYPE_CHECKING:` block and provide runtime fallbacks (e.g., `object`) if necessary for non-type-checking environments.","message":"Using `if TYPE_CHECKING:` when importing types is a best practice to ensure `mypy-boto3-forecastquery` remains a development-only dependency. Without it, some linters (like Pylint) might complain about undefined variables or the type stub package could become a runtime dependency.","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"}