mypy-boto3-schemas

1.42.3 · active · verified Fri Apr 10

mypy-boto3-schemas provides type annotations for the AWS Schemas service within the boto3 library, enhancing static type checking for Python applications. It is part of the `mypy-boto3` family of projects, generated by `mypy-boto3-builder`. The current version is 1.42.3 and new versions are released frequently to keep pace with boto3 updates and new AWS service features.

Warnings

Install

Imports

Quickstart

Demonstrates how to import and use a TypeDef for the AWS Schemas service. It includes a `TYPE_CHECKING` block to guard against runtime dependencies on the stub package for production environments, which is a common pattern for `mypy-boto3` users. It shows how to define a schema input using the `CreateSchemaInputRequestTypeDef`.

from typing import TYPE_CHECKING
from mypy_boto3_schemas.type_defs import CreateSchemaInputRequestTypeDef

if TYPE_CHECKING:
    import boto3
    from mypy_boto3_schemas.client import SchemasClient

def create_example_schema(client: "SchemasClient") -> None:
    # Example of a TypeDef for schema creation input
    schema_input: CreateSchemaInputRequestTypeDef = {
        "RegistryName": "my-registry",
        "SchemaName": "my-schema",
        "Content": "{\"type\": \"object\", \"properties\": {\"foo\": {\"type\": \"string\"}}}",
        "Type": "OpenApi3", # Or 'JSONSchema', 'WSDL', 'XSD'
    }
    
    print(f"Attempting to create schema: {schema_input['SchemaName']}")
    # In a real application, you would call a boto3 client method here, e.g.:
    # client.create_schema(**schema_input)

# Example usage (requires boto3 to be installed and configured)
if __name__ == "__main__":
    # This part would typically interact with a real boto3 client
    # For demonstration, we'll use a mock if boto3 is not present
    try:
        import boto3
        schemas_client: "SchemasClient" = boto3.client("schemas")
        create_example_schema(schemas_client)
    except ImportError:
        print("boto3 not installed. Skipping live client example, but type hints are still valid.")

view raw JSON →