Skip to content

Examples#

Index > ServiceDiscovery > Examples

Auto-generated documentation for ServiceDiscovery type annotations stubs module types-boto3-servicediscovery.

Client#

Implicit type annotations#

Can be used with types-boto3[servicediscovery] package installed.

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

# ServiceDiscoveryClient usage example

from boto3.session import Session


session = Session()

client = session.client("servicediscovery")  # (1)
result = client.create_http_namespace()  # (2)
  1. client: ServiceDiscoveryClient
  2. result: CreateHttpNamespaceResponseTypeDef
# ListInstancesPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("list_instances")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: ServiceDiscoveryClient
  2. paginator: ListInstancesPaginator
  3. item: ListInstancesResponseTypeDef

Explicit type annotations#

With types-boto3-lite[servicediscovery] or a standalone types_boto3_servicediscovery package, you have to explicitly specify client: ServiceDiscoveryClient 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.

# ServiceDiscoveryClient usage example with type annotations

from boto3.session import Session

from types_boto3_servicediscovery.client import ServiceDiscoveryClient
from types_boto3_servicediscovery.type_defs import CreateHttpNamespaceResponseTypeDef
from types_boto3_servicediscovery.type_defs import CreateHttpNamespaceRequestRequestTypeDef


session = Session()

client: ServiceDiscoveryClient = session.client("servicediscovery")

kwargs: CreateHttpNamespaceRequestRequestTypeDef = {...}
result: CreateHttpNamespaceResponseTypeDef = client.create_http_namespace(**kwargs)
# ListInstancesPaginator usage example with type annotations

from boto3.session import Session

from types_boto3_servicediscovery.client import ServiceDiscoveryClient
from types_boto3_servicediscovery.paginator import ListInstancesPaginator
from types_boto3_servicediscovery.type_defs import ListInstancesResponseTypeDef


session = Session()
client: ServiceDiscoveryClient = session.client("servicediscovery")

paginator: ListInstancesPaginator = client.get_paginator("list_instances")
for item in paginator.paginate(...):
    item: ListInstancesResponseTypeDef
    print(item)