Examples#
Index > ForecastService > Examples
Auto-generated documentation for ForecastService type annotations stubs module mypy-boto3-forecast.
Client#
Implicit type annotations#
Can be used with boto3-stubs[forecast]
package installed.
Write your ForecastService
code as usual,
type checking and code completion should work out of the box.
Client method usage example#
# ForecastServiceClient usage example
from boto3.session import Session
session = Session()
client = session.client("forecast") # (1)
result = client.create_auto_predictor() # (2)
- client: ForecastServiceClient
- result: CreateAutoPredictorResponseTypeDef
Paginator usage example#
# ListDatasetGroupsPaginator usage example
from boto3.session import Session
session = Session()
client = session.client("forecast") # (1)
paginator = client.get_paginator("list_dataset_groups") # (2)
for item in paginator.paginate(...):
print(item) # (3)
- client: ForecastServiceClient
- paginator: ListDatasetGroupsPaginator
- item: ListDatasetGroupsResponseTypeDef
Explicit type annotations#
With boto3-stubs-lite[forecast]
or a standalone mypy_boto3_forecast
package, you have to explicitly specify client: ForecastServiceClient
type annotation.
All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.
Client method usage example#
# ForecastServiceClient usage example with type annotations
from boto3.session import Session
from mypy_boto3_forecast.client import ForecastServiceClient
from mypy_boto3_forecast.type_defs import CreateAutoPredictorResponseTypeDef
from mypy_boto3_forecast.type_defs import CreateAutoPredictorRequestTypeDef
session = Session()
client: ForecastServiceClient = session.client("forecast")
kwargs: CreateAutoPredictorRequestTypeDef = {...}
result: CreateAutoPredictorResponseTypeDef = client.create_auto_predictor(**kwargs)
Paginator usage example#
# ListDatasetGroupsPaginator usage example with type annotations
from boto3.session import Session
from mypy_boto3_forecast.client import ForecastServiceClient
from mypy_boto3_forecast.paginator import ListDatasetGroupsPaginator
from mypy_boto3_forecast.type_defs import ListDatasetGroupsResponseTypeDef
session = Session()
client: ForecastServiceClient = session.client("forecast")
paginator: ListDatasetGroupsPaginator = client.get_paginator("list_dataset_groups")
for item in paginator.paginate(...):
item: ListDatasetGroupsResponseTypeDef
print(item)