base.py
python
sha256:25d96102cb2d69a038356dff26f4633156da2f1faf98fe0d0e4438ff3f367f12
refactor: rename 0054/0055 migrations to standard convention
Sonnet 4.6
minor
⚠ breaking
23 days ago
| 1 | """Shared Pydantic base with camelCase wire-format serialization.""" |
| 2 | |
| 3 | from pydantic import BaseModel, ConfigDict |
| 4 | |
| 5 | def to_camel(name: str) -> str: |
| 6 | """Convert snake_case to camelCase for JSON serialization.""" |
| 7 | parts = name.split("_") |
| 8 | return f"{parts[0]}{''.join(w.capitalize() for w in parts[1:])}" |
| 9 | |
| 10 | class CamelModel(BaseModel): |
| 11 | """Base model that serializes to camelCase on the wire. |
| 12 | |
| 13 | - Python code uses snake_case field names (PEP 8) |
| 14 | - JSON on the wire uses camelCase (web convention) |
| 15 | - ``model_dump()`` returns snake_case (internal use) |
| 16 | - ``model_dump(by_alias=True)`` returns camelCase (wire use) |
| 17 | """ |
| 18 | |
| 19 | model_config = ConfigDict( |
| 20 | alias_generator=to_camel, |
| 21 | populate_by_name=True, |
| 22 | ) |
File History
2 commits
sha256:25d96102cb2d69a038356dff26f4633156da2f1faf98fe0d0e4438ff3f367f12
refactor: rename 0054/0055 migrations to standard convention
Sonnet 4.6
minor
⚠
23 days ago
sha256:4aed3d8601c8dd3ed37074de35f11f4a9699a0a4b99d43727048fd3f8e6fd13d
chore: doc sweep, ignore wrangler build state, misc fixes
Sonnet 4.6
minor
⚠
25 days ago