pg.MaybePartial

Accessible via pg.MaybePartial, pg.object_utils.MaybePartial.

class MaybePartial[source]

Bases: object

Interface for classes whose instances can be partially constructed.

A MaybePartial object is an object whose __init__ method can accept pg.MISSING_VALUE as its argument values. All symbolic types (see pg.Symbolic) implements this interface, as their symbolic attributes can be partially filled.

Example:

d = pg.Dict(x=pg.MISSING_VALUE, y=1)
assert d.is_partial
assert 'x' in d.missing_values()

Attributes:

is_partial

Returns True if this object is partial.

Methods:

missing_values([flatten])

Returns missing values from this object.

property is_partial: bool[source]

Returns True if this object is partial. Otherwise False.

An object is considered partial when any of its required fields is missing, or at least one member is partial. The subclass can override this method to provide a more efficient solution.

abstract missing_values(flatten=True)[source]

Returns missing values from this object.

Return type:

Dict[str, Any]

Parameters:

flatten – If True, convert nested structures into a flattened dict using key path (delimited by ‘.’ and ‘[]’) as key.

Returns:

A dict of key to MISSING_VALUE.