rberga06.utils.types.ref#

class rberga06.utils.types.ref(inner: _T | ReferenceType[_T], /)#

Bases: Generic[_T], SupportsPydanticV2[ref[_T] | weakref.ref[_T] | _T]

Flexible, static reference (can be either a weak or a strong reference).

__init__(inner: _T | ReferenceType[_T], /) None#

Methods

__init__(inner, /)

validate(obj, /)

Instantiate this class from obj.

Attributes

inner

The wrapped value or a weak reference to it.

is_weak

Check if self is a weak reference.

inner: ReferenceType[_T] | _T#

The wrapped value or a weak reference to it.

property is_weak: bool#

Check if self is a weak reference.

classmethod validate(obj: ref[_T] | ReferenceType[_T] | _T, /) Self#

Instantiate this class from obj.