Skip to main content

Python Runtime Guide

The Python target generates models, typed Request classes, Q and E facades, relation loading, aggregations and async persistence. Generated snake_case names come from centralized naming metadata; templates never form plurals by appending s.

Context-only async execution

Every execution method has exactly one caller-supplied argument:

orders = await (
Q.customer_orders()
.comment("Find orders awaiting review")
.purpose("Prepare the authorized review queue")
.execute_for_list(ctx)
)

The data service is injected while UserContext is initialized and resolved through its required resources. Passing an old second service argument is invalid and raises Python's normal TypeError. Missing context initialization fails closed.

Mutations follow the same context boundary:

await order.audit_as("Approve reviewed order").save(ctx)

Verified providers

DatabaseAsync driver observed in acceptanceFeature status
PostgreSQLasyncpg 0.31.0PASS
MySQLaiomysql 0.3.2PASS
SQLiteaiosqlite 0.22.1PASS

The generated Feature passed dynamic filters, native aggregates, relation loading, exact Top-N, tenant-scoped versioned saves, stale-version rejection and dual audit events on all three providers.

Loaded values and expressions

The generated E facade distinguishes a field loaded with null from a field that was not selected. This distinction is important for partial projections, fallbacks and list traversal. Regenerate and run both compile and provider tests after changing projections or relations.