pg.typing.Type¶
Accessible via pg.typing.Type.
- class Type(t, default=MISSING_VALUE, is_noneable=False, frozen=False)[source]¶
Bases:
pg.typing.Generic,ValueSpecBaseValue 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([compact, verbose, root_indent])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.
- format(compact=False, verbose=True, root_indent=0, **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,tuplewhere the container types should have plain Python values as their values.