pg.typing.Tuple¶
Accessible via pg.typing.Tuple
.
- class Tuple(element_values, 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 tuple type.
Examples:
# A required tuple with 2 items which are non-negative integers. pg.typing.Tuple([pg.typing.Int(min_value=0), pg.typing.Int(min_value=0)]) # A optional int tuple of size 3 with None as its default value. pg.typing.Tuple(pg.typing.Int(), size=3).noneable() # A int tuple with minimal size 1 and maximal size 5. pg.typing.Tuple(pg.typing.Int(), min_size=1, max_size=5) # A (int, float) tuple with default value (1, 1.0). pg.typing.Tuple([pg.typing.Int(), pg.typing.Float()], default=(1, 1.0)) # A frozen tuple that prevents subclass to extend/override. pg.typing.Tuple(pg.typing.Int()).freeze((1,))
Attributes:
Returns Field specification for tuple elements.
Returns True if current Tuple spec is fixed length.
Returns forward references used in this spec.
Returns max size of this tuple.
Returns max size of this tuple.
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]¶
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.