pg.typing.List¶
Accessible via pg.typing.List
.
- class List(element_value, default=MISSING_VALUE, min_size=None, max_size=None, size=None, transform=None, is_noneable=False, frozen=False)[source]¶
Bases:
pg.typing.Generic
,ValueSpecBase
Value spec for list type.
Examples:
# A required non-negative integer list. pg.typing.List(pg.typing.Int(min_value=0)) # A optional str list with 2-5 items. pg.typing.List(pg.typing.Str(), min_size=2, max_size=5).noneable() # An size-2 list of arbitrary types pg.typing.List(pg.typing.Any(), size=2) # A frozen list that prevents subclass to extend/override. pg.typing.List(pg.typing.Int()).freeze([1])
Attributes:
Returns Field specification of list element.
Returns forward references used in this spec.
Returns max size of the list.
Returns max size of the list.
Methods:
format
([compact, verbose, root_indent, ...])Format this object.
to_json
(**kwargs)Returns a plain Python value as a representation for this object.
- format(compact=False, verbose=True, root_indent=0, *, markdown=False, hide_default_values=True, hide_missing_values=True, **kwargs)[source]¶
Format this object.
- Return type:
- property forward_refs: Set[ForwardRef][source]¶
Returns forward references used in this spec.
- to_json(**kwargs)[source]¶
Returns a plain Python value as a representation for this object.
A plain Python value are basic python types that can be serialized into JSON, e.g:
bool
,int
,float
,str
,dict
(with string keys),list
,tuple
where the container types should have plain Python values as their values.