Skip to content

Examples#

Index > Billing > Examples

Auto-generated documentation for Billing type annotations stubs module mypy-boto3-billing.

Client#

Implicit type annotations#

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

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

Client method usage example#

# BillingClient usage example

from boto3.session import Session


session = Session()

client = session.client("billing")  # (1)
result = client.create_billing_view()  # (2)
  1. client: BillingClient
  2. result: CreateBillingViewResponseTypeDef

Paginator usage example#

# ListBillingViewsPaginator usage example

from boto3.session import Session


session = Session()
client = session.client("billing")  # (1)

paginator = client.get_paginator("list_billing_views")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: BillingClient
  2. paginator: ListBillingViewsPaginator
  3. item: ListBillingViewsResponseTypeDef

Explicit type annotations#

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

# BillingClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_billing.client import BillingClient
from mypy_boto3_billing.type_defs import CreateBillingViewResponseTypeDef
from mypy_boto3_billing.type_defs import CreateBillingViewRequestTypeDef


session = Session()

client: BillingClient = session.client("billing")

kwargs: CreateBillingViewRequestTypeDef = {...}
result: CreateBillingViewResponseTypeDef = client.create_billing_view(**kwargs)

Paginator usage example#

# ListBillingViewsPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_billing.client import BillingClient
from mypy_boto3_billing.paginator import ListBillingViewsPaginator
from mypy_boto3_billing.type_defs import ListBillingViewsResponseTypeDef


session = Session()
client: BillingClient = session.client("billing")

paginator: ListBillingViewsPaginator = client.get_paginator("list_billing_views")
for item in paginator.paginate(...):
    item: ListBillingViewsResponseTypeDef
    print(item)