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 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
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 usage example
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 CreateDetectorRequestRequestTypeDef


session = Session()

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

kwargs: CreateDetectorRequestRequestTypeDef = {...}
result: CreateDetectorResponseTypeDef = client.create_detector(**kwargs)
Paginator usage example
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)