allows list, tuple, set, frozenset, deque, or generators and casts to a list;
when a generic parameter is provided, the appropriate validation is applied to all items of the list
typing.List
handled the same as list above
tuple
allows list, tuple, set, frozenset, deque, or generators and casts to a tuple;
when generic parameters are provided, the appropriate validation is applied to the respective items of the tuple
typing.Tuple
handled the same as tuple above
deque
allows list, tuple, set, frozenset, deque, or generators and casts to a deque;
when generic parameters are provided, the appropriate validation is applied to the respective items of the deque
Similar to tuple, but creates instances of the given namedtuple class.
types returned from collections.namedtuple
Similar to subclass of typing.NamedTuple, but since field types are not specified, all fields are treated as having
type Any
fromtypingimportNamedTuplefrompydanticimportBaseModel,ValidationErrorclassPoint(NamedTuple):x:inty:intclassModel(BaseModel):p:Pointtry:Model(p=('1.3','2'))exceptValidationErrorase:print(e)""" 1 validation error for Model p.0 Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='1.3', input_type=str] """