def render_item_override()

in migrations/env.py [0:0]


def render_item_override(type_: str, item: object, autogen_context: api.AutogenContext) -> str | Literal[False]:
    """Apply custom rendering for SQLModel AutoString.

    Prevents autogenerate from rendering <AutoString>.
    Returns False to indicate no handler for other types.
    """
    # Add import for sqlalchemy as sa if not present
    autogen_context.imports.add("import sqlalchemy as sa")

    if (type_ == "type") and isinstance(item, sqltypes.AutoString):
        # Render sqlmodel.sql.sqltypes.AutoString as sa.String()
        return "sa.String()"

    # Default rendering for other types
    return False