pg.typing.create_field¶
Accessible via pg.typing.create_field
.
- create_field(maybe_field, auto_typing=True, accept_value_as_annotation=True)[source]¶
Creates
Field
from its equivalence.- Return type:
- Parameters:
maybe_field – a
Field
object or its equivalence, which is a tuple of 2 - 4 elements: (<key>, <value>, [description], [metadata]). key can be a KeySpec subclass object or string. value can be a ValueSpec subclass object or equivalent value. (seeValueSpec.from_value
method). description is the description of this field. It can be optional when this field overrides the default value of a field defined in parent schema. metadata is an optional field which is a dict of user objects.auto_typing – If True, infer value spec from Python annotations. Otherwise,
pg.typing.Any()
will be used.accept_value_as_annotation – If True, allow default values to be used as annotations when creating the value spec.
- Returns:
A
Field
object.