Skip to content

feat(table): support dataclasses and TypedDicts in Table component#385

Open
Aditya4ever wants to merge 1 commit intopydantic:mainfrom
Aditya4ever:feat/table-dataclass-typeddict-support
Open

feat(table): support dataclasses and TypedDicts in Table component#385
Aditya4ever wants to merge 1 commit intopydantic:mainfrom
Aditya4ever:feat/table-dataclass-typeddict-support

Conversation

@Aditya4ever
Copy link

Description

Implements support for Python dataclasses and TypedDicts in the Table component, addressing the TODO in fastui/components/tables.py.

Changes

  • Used pydantic.SkipValidation on the data field to bypass BaseModel validation
  • Updated _fill_columns to use pydantic.TypeAdapter with mode='serialization'
  • Preserved backward compatibility for Pydantic models (explicit title behavior)

Testing

  • All 70 existing tests pass
  • Verified with reproduction script for both dataclasses and TypedDicts
  • Computed fields continue to work correctly

Example Usage

from dataclasses import dataclass
from fastui.components import Table

@dataclass
class User:
    id: int
    name: str

users = [User(id=1, name='John')]
table = Table(data=users)  # Now works!

@codecov
Copy link

codecov bot commented Nov 23, 2025

Codecov Report

❌ Patch coverage is 81.08108% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/python-fastui/fastui/components/tables.py 81.08% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant