The Wire · Showcase
PYDANTIC FIXES `field_title_generator` SIGNATURE MISMATCH
By RepoJournal · Filed · About FastAPI & Pydantic
The documented signature for `field_title_generator` was wrong, and developers following the docs would hit a TypeError.
Pydantic's `field_title_generator` callback has been documented across `Field()`, `FieldInfo.from_field()`, `computed_field()`, and `ComputedFieldInfo` as taking only a field name and returning a title [1]. The actual implementation invokes it with two arguments: the field name and its info object [2]. Anyone building a title generator from the docstring docs would pass a single-argument function and crash on runtime. The fix corrects the documented signature to match reality, eliminating the gotcha [2]. This is a small but important correction that prevents confusion during onboarding and saves debugging time in production code.
One email a day. Unsubscribe in one click.
Keep up with FastAPI & Pydantic in about 3 minutes a day: what actually shipped — the commits, pull requests, releases, and security advisories that matter.
One email a day. Unsubscribe in one click. Read a past issue →
Action items
- → Update custom `field_title_generator` functions to accept (field_name, field_info) if you have them pydantic/pydantic [plan]
- → Review docs-following code that implements title generators before next release pydantic/pydantic [monitor]
References
- [1] Fix documented signature of `field_title_generator` (#13565) pydantic/pydantic
- [2] Fix documented signature of `field_title_generator` ↗ pydantic/pydantic