def get_declared_enums(metadata, schema, default):
    """
    Return a dict mapping SQLAlchemy enumeration types to the set of their
    declared values.

    :param metadata:
        ...

    :param str schema:
        Schema name (e.g. "public").

    :returns dict:
        {
            "my_enum": frozenset(["a", "b", "c"]),
        }
    """
    types = set(column.type
                for table in metadata.tables.values()
                for column in table.columns
                if (isinstance(column.type, sqlalchemy.Enum) and
                    schema == (column.type.schema or default)))
    return {t.name: frozenset(t.enums) for t in types}
Return a dict mapping SQLAlchemy enumeration types to the set of their
    declared values.

    :param metadata:
        ...

    :param str schema:
        Schema name (e.g. "public").

    :returns dict:
        {
            "my_enum": frozenset(["a", "b", "c"]),
        }