Skip to content

Examples#

Index > FreeTier > Examples

Auto-generated documentation for FreeTier type annotations stubs module mypy-boto3-freetier.

Client#

Implicit type annotations#

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

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

# FreeTierClient usage example

from boto3.session import Session


session = Session()

client = session.client("freetier")  # (1)
result = client.get_free_tier_usage()  # (2)
  1. client: FreeTierClient
  2. result: GetFreeTierUsageResponseTypeDef
# GetFreeTierUsagePaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("get_free_tier_usage")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: FreeTierClient
  2. paginator: GetFreeTierUsagePaginator
  3. item: GetFreeTierUsageResponseTypeDef

Explicit type annotations#

With boto3-stubs-lite[freetier] or a standalone mypy_boto3_freetier package, you have to explicitly specify client: FreeTierClient 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.

# FreeTierClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_freetier.client import FreeTierClient
from mypy_boto3_freetier.type_defs import GetFreeTierUsageResponseTypeDef
from mypy_boto3_freetier.type_defs import GetFreeTierUsageRequestRequestTypeDef


session = Session()

client: FreeTierClient = session.client("freetier")

kwargs: GetFreeTierUsageRequestRequestTypeDef = {...}
result: GetFreeTierUsageResponseTypeDef = client.get_free_tier_usage(**kwargs)
# GetFreeTierUsagePaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_freetier.client import FreeTierClient
from mypy_boto3_freetier.paginator import GetFreeTierUsagePaginator
from mypy_boto3_freetier.type_defs import GetFreeTierUsageResponseTypeDef


session = Session()
client: FreeTierClient = session.client("freetier")

paginator: GetFreeTierUsagePaginator = client.get_paginator("get_free_tier_usage")
for item in paginator.paginate(...):
    item: GetFreeTierUsageResponseTypeDef
    print(item)