What is the difference between a Pydantic default and Optional field?

Separation of type constraints from requiredness.
Both forms are non-required; str = 'guest' rejects None, Optional[str] = None accepts it.
WHAT THIS TESTS: This question tests whether you confuse type system nullability with Pydantic field requiredness. In Pydantic, a field is required only when it has no default value. The type annotation controls what values are valid, while the presence of a default controls what happens when the field is missing from input data.
A GOOD ANSWER COVERS: First, state that both name: str = 'guest' and name: Optional[str] = None make the field non-required because both supply a default value. Second, explain that the plain string version restricts valid input to strings only; if the caller passes None, Pydantic raises a validation error. Third, explain that the Optional version widens the accepted types to str or None; passing None is valid, and omitting the field causes the attribute to be set to None. Fourth, note that on the resulting model instance both attributes are always present, but their types and values differ, which affects downstream serialization and type checking.
COMMON WRONG ANSWERS: A major red flag is claiming that Optional[str] by itself makes a field non-required. In Pydantic v2, name: Optional[str] without a default is still required; it simply allows None as an explicit input. Another red flag is saying that name: str = 'guest' will accept None and fall back to the default. Pydantic does not coerce None to the default; it validates None against the str type and fails. Candidates also sometimes claim that omitted optional fields are absent from the model instance, but Pydantic sets them to their default.
LIKELY FOLLOW-UPS: The interviewer may ask what happens if you write name: Optional[str] with no default, or how to make a field truly required that accepts None. They might also ask about Field(default_factory=list) versus default=[] to probe understanding of mutable defaults, or how exclude_none=True affects model_dump() output.
ONE CONCRETE EXAMPLE: Consider class User(BaseModel): role: str = 'guest'; status: Optional[str] = None. Instantiating User() yields role='guest' and status=None. Instantiating User(role=None) raises a validation error because None is not a valid string. Instantiating User(status='active') sets status='active'. Calling model_dump() on the default instance produces {'role': 'guest', 'status': None}.
Source: pydantic.dev
Read the original → pydantic.dev
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.