ParentLookup

class parent_lookup.lookup.ParentLookup(parent_type: type[TParent])

Bases: Generic

Descriptor that resolves a parent instance for a child object.

The descriptor is intended for declaration on child classes to avoid repeating explicit find_parent methods. It delegates lookup resolution to lookup_registry and returns None when no parent is found.

Parameters:

parent_type (type[TParent])

__init__(parent_type: type[TParent]) → None

Configure the parent type that this descriptor resolves.

Parameters:

parent_type (type[TParent]) – The class of parent objects to look up.

Return type:

None

Methods

__init__(parent_type)

Configure the parent type that this descriptor resolves.