Skip to content

Examples#

Index > CostExplorer > Examples

Auto-generated documentation for CostExplorer type annotations stubs module mypy-boto3-ce.

Client#

Implicit type annotations#

Can be used with boto3-stubs[ce] package installed.

Write your CostExplorer code as usual, type checking and code completion should work out of the box.

Client method usage example#

# CostExplorerClient usage example

from boto3.session import Session


session = Session()

client = session.client("ce")  # (1)
result = client.create_anomaly_monitor()  # (2)
  1. client: CostExplorerClient
  2. result: CreateAnomalyMonitorResponseTypeDef

Explicit type annotations#

With boto3-stubs-lite[ce] or a standalone mypy_boto3_ce package, you have to explicitly specify client: CostExplorerClient 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#

# CostExplorerClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_ce.client import CostExplorerClient
from mypy_boto3_ce.type_defs import CreateAnomalyMonitorResponseTypeDef
from mypy_boto3_ce.type_defs import CreateAnomalyMonitorRequestTypeDef


session = Session()

client: CostExplorerClient = session.client("ce")

kwargs: CreateAnomalyMonitorRequestTypeDef = {...}
result: CreateAnomalyMonitorResponseTypeDef = client.create_anomaly_monitor(**kwargs)