Skip to content

Examples#

Index > DirectoryService > Examples

Auto-generated documentation for DirectoryService type annotations stubs module mypy-boto3-ds.

Client#

Implicit type annotations#

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

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

# DirectoryServiceClient usage example

from boto3.session import Session


session = Session()

client = session.client("ds")  # (1)
result = client.accept_shared_directory()  # (2)
  1. client: DirectoryServiceClient
  2. result: AcceptSharedDirectoryResultTypeDef
# DescribeClientAuthenticationSettingsPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("describe_client_authentication_settings")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: DirectoryServiceClient
  2. paginator: DescribeClientAuthenticationSettingsPaginator
  3. item: DescribeClientAuthenticationSettingsResultTypeDef

Explicit type annotations#

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

# DirectoryServiceClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_ds.client import DirectoryServiceClient
from mypy_boto3_ds.type_defs import AcceptSharedDirectoryResultTypeDef
from mypy_boto3_ds.type_defs import AcceptSharedDirectoryRequestRequestTypeDef


session = Session()

client: DirectoryServiceClient = session.client("ds")

kwargs: AcceptSharedDirectoryRequestRequestTypeDef = {...}
result: AcceptSharedDirectoryResultTypeDef = client.accept_shared_directory(**kwargs)
# DescribeClientAuthenticationSettingsPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_ds.client import DirectoryServiceClient
from mypy_boto3_ds.paginator import DescribeClientAuthenticationSettingsPaginator
from mypy_boto3_ds.type_defs import DescribeClientAuthenticationSettingsResultTypeDef


session = Session()
client: DirectoryServiceClient = session.client("ds")

paginator: DescribeClientAuthenticationSettingsPaginator = client.get_paginator("describe_client_authentication_settings")
for item in paginator.paginate(...):
    item: DescribeClientAuthenticationSettingsResultTypeDef
    print(item)