$ the-wire · showcase
PYDANTIC FIXES `field_title_generator` SIGNATURE MISMATCH
By RepoJournal · Filed · About FastAPI & Pydantic · Composed from the cited sources · methodology
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.
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