Skip to content

Examples#

Index > GuardDuty > Examples

Auto-generated documentation for GuardDuty type annotations stubs module mypy-boto3-guardduty.

Client#

Implicit type annotations#

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

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

Client method usage example#

# GuardDutyClient usage example

from boto3.session import Session


session = Session()

client = session.client("guardduty")  # (1)
result = client.create_detector()  # (2)
  1. client: GuardDutyClient
  2. result: CreateDetectorResponseTypeDef

Paginator usage example#

# DescribeMalwareScansPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("describe_malware_scans")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: GuardDutyClient
  2. paginator: DescribeMalwareScansPaginator
  3. item: DescribeMalwareScansResponseTypeDef

Explicit type annotations#

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

# GuardDutyClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_guardduty.client import GuardDutyClient
from mypy_boto3_guardduty.type_defs import CreateDetectorResponseTypeDef
from mypy_boto3_guardduty.type_defs import CreateDetectorRequestTypeDef


session = Session()

client: GuardDutyClient = session.client("guardduty")

kwargs: CreateDetectorRequestTypeDef = {...}
result: CreateDetectorResponseTypeDef = client.create_detector(**kwargs)

Paginator usage example#

# DescribeMalwareScansPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_guardduty.client import GuardDutyClient
from mypy_boto3_guardduty.paginator import DescribeMalwareScansPaginator
from mypy_boto3_guardduty.type_defs import DescribeMalwareScansResponseTypeDef


session = Session()
client: GuardDutyClient = session.client("guardduty")

paginator: DescribeMalwareScansPaginator = client.get_paginator("describe_malware_scans")
for item in paginator.paginate(...):
    item: DescribeMalwareScansResponseTypeDef
    print(item)