Type Annotations for boto3 AppRegistry

1.42.3 · active · verified Sat Apr 11

mypy-boto3-servicecatalog-appregistry provides PEP 561 compliant type annotations for the AWS AppRegistry service client in boto3. It helps developers leverage static type checking with tools like mypy, ensuring correctness and improving autocompletion for boto3 interactions. The current version is 1.42.3, generated by mypy-boto3-builder 8.12.0, with frequent releases synchronised with boto3 updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to obtain a type-hinted `AppRegistryClient` from `boto3` and use it to call an API operation. It also shows how to import and use response `TypeDef` objects for more granular type checking, typically under a `TYPE_CHECKING` guard.

import boto3
from mypy_boto3_servicecatalog_appregistry.client import AppRegistryClient
from typing import TYPE_CHECKING

# For advanced type checking of response objects
if TYPE_CHECKING:
    from mypy_boto3_servicecatalog_appregistry.type_defs import CreateApplicationResponseTypeDef

def create_example_application(app_name: str, app_description: str):
    # boto3 client is untyped by default
    client = boto3.client(
        "servicecatalog-appregistry",
        aws_access_key_id="AKIATEST", # Using dummy creds for example
        aws_secret_access_key="SECRET",
        region_name="us-east-1"
    )

    # Type hint the client for mypy
    typed_client: AppRegistryClient = client

    # With the typed_client, autocompletion and type checking work
    response = typed_client.create_application(
        name=app_name,
        description=app_description
    )

    # TYPE_CHECKING guard ensures this import is only for static analysis
    if TYPE_CHECKING:
        response_typed: CreateApplicationResponseTypeDef = response
        print(f"Application ID: {response_typed['application']['id']}")
    else:
        print(f"Application ID: {response['application']['id']}")

# To run this example, replace dummy creds and provide a unique application name
# create_example_application("MyUniqueApp", "Managed by mypy-boto3 example")

view raw JSON →