Examples#
Auto-generated documentation for Shield type annotations stubs module mypy-boto3-shield.
Client#
Implicit type annotations#
Can be used with boto3-stubs[shield]
package installed.
Write your Shield
code as usual,
type checking and code completion should work out of the box.
Client method usage example#
# ShieldClient usage example
from boto3.session import Session
session = Session()
client = session.client("shield") # (1)
result = client.create_protection() # (2)
- client: ShieldClient
- result: CreateProtectionResponseTypeDef
Paginator usage example#
# ListAttacksPaginator usage example
from boto3.session import Session
session = Session()
client = session.client("shield") # (1)
paginator = client.get_paginator("list_attacks") # (2)
for item in paginator.paginate(...):
print(item) # (3)
- client: ShieldClient
- paginator: ListAttacksPaginator
- item: ListAttacksResponseTypeDef
Explicit type annotations#
With boto3-stubs-lite[shield]
or a standalone mypy_boto3_shield
package, you have to explicitly specify client: ShieldClient
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#
# ShieldClient usage example with type annotations
from boto3.session import Session
from mypy_boto3_shield.client import ShieldClient
from mypy_boto3_shield.type_defs import CreateProtectionResponseTypeDef
from mypy_boto3_shield.type_defs import CreateProtectionRequestTypeDef
session = Session()
client: ShieldClient = session.client("shield")
kwargs: CreateProtectionRequestTypeDef = {...}
result: CreateProtectionResponseTypeDef = client.create_protection(**kwargs)
Paginator usage example#
# ListAttacksPaginator usage example with type annotations
from boto3.session import Session
from mypy_boto3_shield.client import ShieldClient
from mypy_boto3_shield.paginator import ListAttacksPaginator
from mypy_boto3_shield.type_defs import ListAttacksResponseTypeDef
session = Session()
client: ShieldClient = session.client("shield")
paginator: ListAttacksPaginator = client.get_paginator("list_attacks")
for item in paginator.paginate(...):
item: ListAttacksResponseTypeDef
print(item)