bridge.pipelines.protocols.none_propagation module

bridge.pipelines.protocols.none_propagation module#

SafeAttr proxy class for safe attribute/item access and deep unwrapping utility.

class bridge.pipelines.protocols.none_propagation.SafeAttr(v)[source]#

Bases: object

A proxy class that safely accesses attributes and items of an underlying object. If an attribute or item does not exist, it returns a SafeAttr wrapping None instead of raising an exception.

unwrap(default=None)[source]#

Unwrap the underlying value, or return default if None.

Parameters:

default (Any) – The default value to return if the underlying value is None.

Returns:

The deeply unwrapped value.

Return type:

Any

bridge.pipelines.protocols.none_propagation.deep_unwrap(v, *, _seen=None)[source]#

Recursively unwrap SafeAttr instances within common container types.

Parameters:
  • v (Any) – The value to unwrap.

  • _seen (set | None) – Internal set to track seen object IDs for cycle detection.

Returns:

The deeply unwrapped value.

Return type:

Any