Examples#
Index > ServiceDiscovery > Examples
Auto-generated documentation for ServiceDiscovery type annotations stubs module mypy-boto3-servicediscovery.
Client#
Implicit type annotations#
Can be used with boto3-stubs[servicediscovery]
package installed.
Write your ServiceDiscovery
code as usual,
type checking and code completion should work out of the box.
Client method usage example#
# ServiceDiscoveryClient usage example
from boto3.session import Session
session = Session()
client = session.client("servicediscovery") # (1)
result = client.create_http_namespace() # (2)
- client: ServiceDiscoveryClient
- result: CreateHttpNamespaceResponseTypeDef
Paginator usage example#
# 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)
- client: ServiceDiscoveryClient
- paginator: ListInstancesPaginator
- item: ListInstancesResponseTypeDef
Explicit type annotations#
With boto3-stubs-lite[servicediscovery]
or a standalone mypy_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.
Client method usage example#
# ServiceDiscoveryClient usage example with type annotations
from boto3.session import Session
from mypy_boto3_servicediscovery.client import ServiceDiscoveryClient
from mypy_boto3_servicediscovery.type_defs import CreateHttpNamespaceResponseTypeDef
from mypy_boto3_servicediscovery.type_defs import CreateHttpNamespaceRequestTypeDef
session = Session()
client: ServiceDiscoveryClient = session.client("servicediscovery")
kwargs: CreateHttpNamespaceRequestTypeDef = {...}
result: CreateHttpNamespaceResponseTypeDef = client.create_http_namespace(**kwargs)
Paginator usage example#
# ListInstancesPaginator usage example with type annotations
from boto3.session import Session
from mypy_boto3_servicediscovery.client import ServiceDiscoveryClient
from mypy_boto3_servicediscovery.paginator import ListInstancesPaginator
from mypy_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)