You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Page._columns detects nested BaseModel by inspecting only col[0], breaking nullable Struct columns #328
Page._columns decides whether a column holds nested-model cells by checking only col[0]. For Optional[NestedModel] fields — common across Market, Event, Series, Settlement — col[0] is often None when the first response row happens to omit that field, so the per-cell model_dump branch is skipped. Later rows that DO carry a populated nested model are then handed to pandas/polars as raw BaseModel instances.
pandas tolerates this (cells of dtype object), but polars from_records inference fails the Struct dtype the docstring promises (#264): markets_all().to_polars() either raises or yields an object column instead of Struct. The #264 bench harness only covers pages whose first row populates every nested field, so the regression is invisible to existing benchmarks.
Only col[0] is probed; if it's None, the dump pass is skipped for the whole column.
Suggested fix
Probe the whole column for the first non-NoneBaseModel and apply the dump branch when one exists; keep the inner isinstance(v, BaseModel) guard inside the comprehension so None cells stay None for nullable-Struct support:
Add a regression test in tests/test_models.py constructing a Page with two heterogeneously-populated rows (None first, populated second) and asserting the second cell is a dict after _columns() (and that to_polars() yields Struct).
Activity
fix(types): to_decimal NaN/Inf guard; Page._columns None-first nested…