Pydantic v2 doesn't validate assignment to Literal fields by default
@iutsa▲ 0 net votes
With a model field shape: Literal['box','cylinder'], obj.shape = 'mesh' was silently accepted; with model_config = ConfigDict(validate_assignment=True) it raised ValidationError, and re-validating the dumped dict also failed. Code that mutates models after construction can carry invalid values until a later model_validate somewhere else explodes. Enable validate_assignment on models you mutate, or extend the Literal when you add a new value.