Type annotations for boto3 ServerlessApplicationRepository

1.42.3 · active · verified Sat Apr 11

mypy-boto3-serverlessrepo provides static type annotations for the boto3 ServerlessApplicationRepository service, compatible with tools like VSCode, PyCharm, mypy, and pyright. It is part of the larger mypy-boto3 project, with packages updated hourly from boto3 documentation to ensure compatibility and accuracy. The current version is 1.42.3.

Warnings

Install

Imports

Quickstart

Demonstrates how to obtain a ServerlessApplicationRepository client with type annotations and use a TypedDict for request parameters. Explicit type annotations are recommended for full IDE support. Note that this example will not fully execute a `create_application` call without a complete application template body.

import boto3
from typing import TYPE_CHECKING
from mypy_boto3_serverlessrepo.client import ServerlessApplicationRepositoryClient
from mypy_boto3_serverlessrepo.type_defs import CreateApplicationRequestTypeDef


# Boto3 client without type hints (mypy/IDE might infer, but explicit is better)
client_untyped = boto3.client('serverlessrepo')

# Boto3 client with explicit type hints
if TYPE_CHECKING:
    client: ServerlessApplicationRepositoryClient = boto3.client('serverlessrepo')
else:
    client = boto3.client('serverlessrepo')

# Example using a TypedDict for request parameters
application_params: CreateApplicationRequestTypeDef = {
    'Author': 'MyCompany',
    'Description': 'A sample serverless application.',
    'Name': 'MySampleApp',
    'HomePageUrl': 'https://example.com/myapp',
    'Labels': ['python', 'example'],
    'SourceCodeUrl': 'https://github.com/mycompany/myapp'
}

try:
    # In a real scenario, you'd add necessary fields like 'AppTemplateBody' or 'SemanticVersion'
    # For a quickstart, we'll just demonstrate the client type checking.
    # This call would typically fail without required fields or actual template body.
    # response = client.create_application(**application_params)
    print("Client type checking is active.")
    print(f"Expected return type for list_applications: {{client.list_applications.__annotations__.get('return')}}")
except Exception as e:
    print(f"An error occurred (expected for incomplete example): {e}")

view raw JSON →