Asked about Pydantic and type checkers in practice

What is a discriminated union and when would you use one?

An answer that works

A union of shapes with a tag field that says which shape an object is. It suits outputs that can be one of several actions, and gives precise errors because the validator knows which shape to check.

Reading an answer is not being able to give one. The section that teaches this is Pydantic and type checkers in practice, 5 hours of Typing & validation.

Learn this properly