Skip to content

treex.field

Source code in treeo/utils.py
def field(
    default: tp.Any = dataclasses.MISSING,
    *,
    node: bool,
    kind: type = type(None),
    default_factory: tp.Optional[tp.Callable[[], tp.Any]] = None,
    init: bool = True,
    repr: bool = True,
    hash: tp.Optional[bool] = None,
    compare: bool = True,
    opaque: tp.Union[bool, OpaquePredicate] = False,
) -> tp.Any:

    return dataclasses.field(
        default=default,
        metadata={
            "node": node,
            "kind": kind,
            "opaque": opaque,
        },
        default_factory=default_factory
        if default_factory is not None
        else dataclasses.MISSING,
        init=init,
        repr=repr,
        hash=hash,
        compare=compare,
    )