pg.typing.create_field¶
Accessible via pg.typing.create_field.
- create_field(field_or_def, auto_typing=True, accept_value_as_annotation=True, parent_module=None)[source]¶
Creates
Fieldfrom its equivalence.- Return type:
- Parameters:
field_or_def – a
Fieldobject 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_valuemethod). 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.
parent_module – (Optional) parent module for defining this field, which will be used for forward reference lookup.
- Returns:
A
Fieldobject.