{"id":3360,"library":"mypy-boto3-forecast","title":"mypy-boto3-forecast type stubs","description":"This library provides type annotations (stubs) for `boto3`'s ForecastService, enabling static type checking with tools like MyPy. Its versioning closely tracks the corresponding `boto3` versions, ensuring compatibility with specific AWS API releases. It is actively maintained with frequent updates reflecting changes in the AWS Forecast service API.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["boto3","mypy","aws","typing","stubs","forecast","type-checking","static-analysis"],"install":[{"cmd":"pip install mypy-boto3-forecast boto3 mypy","lang":"bash","label":"Install for boto3, mypy, and Forecast stubs"}],"dependencies":[],"imports":[{"note":"Import the typed client for the Forecast service.","symbol":"ForecastClient","correct":"from mypy_boto3_forecast.client import ForecastClient"},{"note":"Import the typed resource for the Forecast service, if using resource API.","symbol":"ForecastServiceResource","correct":"from mypy_boto3_forecast.service_resource import ForecastServiceResource"},{"note":"Import specific TypedDicts for request/response bodies.","symbol":"ListDatasetsResponseTypeDef","correct":"from mypy_boto3_forecast.type_defs import ListDatasetsResponseTypeDef"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_forecast.client import ForecastClient\nfrom mypy_boto3_forecast.type_defs import ListDatasetsResponseTypeDef\nimport os\n\n# Ensure boto3 is configured (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION_NAME env vars)\n# or ~/.aws/credentials and ~/.aws/config\n\n# Create a typed boto3 client for Forecast\n# The actual client is created by boto3.client, mypy-boto3 provides the type hint.\nclient: ForecastClient = boto3.client(\n    \"forecast\",\n    region_name=os.environ.get('AWS_REGION_NAME', 'us-east-1')\n)\n\ntry:\n    # Example API call with type-hinted response\n    response: ListDatasetsResponseTypeDef = client.list_datasets(MaxResults=10)\n    \n    print(\"Successfully listed Forecast datasets:\")\n    for dataset in response.get('Datasets', []):\n        print(f\"- {dataset.get('DatasetName', 'N/A')} (ARN: {dataset.get('DatasetArn', 'N/A')})\")\n\nexcept Exception as e:\n    print(f\"Error listing datasets (check AWS credentials and permissions): {e}\")\n    # In a real application, you might want to log the full exception details\n\n# To type-check this code, save it as e.g. `forecast_app.py` and run:\n# pip install mypy boto3 mypy-boto3-forecast\n# mypy forecast_app.py","lang":"python","description":"This example demonstrates how to initialize a typed `boto3` Forecast client and make a simple API call. The `mypy-boto3-forecast` library adds static type hints, allowing tools like MyPy to catch potential issues before runtime. Remember to configure your AWS credentials for the code to run successfully."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer. If you must use Python 3.8, use an older `mypy-boto3-forecast` version, but be aware it won't have the latest AWS API types.","message":"Starting with `mypy-boto3-builder` version 8.12.0 (which generated `mypy-boto3-forecast` 1.42.3 and newer), Python 3.8 support has been removed. All generated stub packages now require Python 3.9 or higher.","severity":"breaking","affected_versions":"mypy-boto3-forecast >= 1.42.3"},{"fix":"Keep your `mypy-boto3-forecast` and `boto3` versions synchronized. For example, if you use `boto3==1.x.y`, install `mypy-boto3-forecast==1.x.z`.","message":"The version of `mypy-boto3-forecast` must ideally match the major and minor version of your installed `boto3` library to ensure accurate type checking. Mismatched versions can lead to incorrect type hints for new or deprecated API features.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review the API changes in the `mypy-boto3` documentation or `boto3` documentation for the specific service and adjust TypeDef names in your code if you encounter `NameError` or type resolution issues during static analysis.","message":"Builder version 8.9.0 (affecting stub packages generated after this builder version) introduced breaking changes in how some TypeDef names are generated, favoring shorter names or resolving conflicts. Code explicitly referencing old, longer TypeDef names might break.","severity":"breaking","affected_versions":"mypy-boto3-forecast generated by builder >= 8.9.0"},{"fix":"Install either `mypy-boto3` for all service stubs or `mypy-boto3-forecast` for only the Forecast service stubs, not both for the same service.","message":"Installing `mypy-boto3` (which includes stubs for all AWS services) alongside `mypy-boto3-forecast` (stubs for a single service) is redundant for the Forecast service. While usually harmless, it can increase installation size.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Integrate `mypy` into your development workflow (e.g., CI/CD, pre-commit hooks) to continuously type-check your code.","message":"These are type stubs and provide no runtime functionality. To benefit from `mypy-boto3-forecast`, you must explicitly run `mypy` (or another compatible type checker) on your codebase. The stubs do not alter `boto3`'s runtime behavior.","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"}