pg.typing.Type¶
Accessible via pg.typing.Type
.
- class Type(t, default=MISSING_VALUE, is_noneable=False, frozen=False)[source]¶
Bases:
pg.typing.Generic
,ValueSpecBase
Value spec for type.
Examples:
# A required type or subclass of A. pg.typing.Type(A) # An required type or subclass of A (forward declaration). pg.typing.Type('A') # An optional type or subclass of A. pg.typing.Type(A).noneable() # A required type or subclass of A with default value B # (B is a subclass of A). pg.typing.Type(A, default=B)
Methods:
format
(*[, markdown])Format this object.
to_json
(**kwargs)Returns a plain Python value as a representation for this object.
Attributes:
Returns forward references used in this spec.
Returns desired 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.