Skip to content

Examples#

Index > ConfigService > Examples

Auto-generated documentation for ConfigService type annotations stubs module mypy-boto3-config.

Client#

Implicit type annotations#

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

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

# ConfigServiceClient usage example

from boto3.session import Session


session = Session()

client = session.client("config")  # (1)
result = client.associate_resource_types()  # (2)
  1. client: ConfigServiceClient
  2. result: AssociateResourceTypesResponseTypeDef
# DescribeAggregateComplianceByConfigRulesPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("describe_aggregate_compliance_by_config_rules")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: ConfigServiceClient
  2. paginator: DescribeAggregateComplianceByConfigRulesPaginator
  3. item: DescribeAggregateComplianceByConfigRulesResponseTypeDef

Explicit type annotations#

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

# ConfigServiceClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_config.client import ConfigServiceClient
from mypy_boto3_config.type_defs import AssociateResourceTypesResponseTypeDef
from mypy_boto3_config.type_defs import AssociateResourceTypesRequestRequestTypeDef


session = Session()

client: ConfigServiceClient = session.client("config")

kwargs: AssociateResourceTypesRequestRequestTypeDef = {...}
result: AssociateResourceTypesResponseTypeDef = client.associate_resource_types(**kwargs)
# DescribeAggregateComplianceByConfigRulesPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_config.client import ConfigServiceClient
from mypy_boto3_config.paginator import DescribeAggregateComplianceByConfigRulesPaginator
from mypy_boto3_config.type_defs import DescribeAggregateComplianceByConfigRulesResponseTypeDef


session = Session()
client: ConfigServiceClient = session.client("config")

paginator: DescribeAggregateComplianceByConfigRulesPaginator = client.get_paginator("describe_aggregate_compliance_by_config_rules")
for item in paginator.paginate(...):
    item: DescribeAggregateComplianceByConfigRulesResponseTypeDef
    print(item)