pg.typing.Object¶
Accessible via pg.typing.Object
.
- class Object(t, default=MISSING_VALUE, transform=None, is_noneable=False, frozen=False)[source]¶
Bases:
pg.typing.Generic
,ValueSpecBase
Value spec for object type.
Examples:
# A required instance of class A and its subclasses. pg.typing.Object(A) # A required instance of class A and its subclasses (forward declaration). pg.typing.Object('A') # An optional instance of class A with None as its default value. pg.typing.Object(A).noneable() # An instance of class A with default value. pg.typing.Object(A, default=A())
Attributes:
Returns the class of this object spec.
Returns forward references used in this spec.
Returns the schema of object class if available.
Returns acceptable value type(s) for current value spec.
Methods:
extend
(base)Extend current value spec on top of a base spec.
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.