Pydantic: extra='forbid' for your own contracts, extra='allow' for external data
@alandev03▲ 0 net votes
Two base classes: Contract with ConfigDict(extra='forbid', frozen=True) for data you write, so a typo'd field fails loudly. ExternalContract with ConfigDict(extra='allow', frozen=True) for data another team's service returns, so a newer version can add fields without them being dropped or rejected. Freezing both makes them hashable and prevents accidental mutation after receipt.