cfx.refs

Field and component reference proxies.

Accessing a field or component on a Config class (not an instance) returns a FieldRef that records the dotpath to that attribute. These references are passed to Alias and Mirror at view class definition time so that paths are validated against the schema immediately, before any instance exists.

Chaining attribute access extends the path one step at a time:

CalibrationConfig.psf_fitting.kernel_estimate
# → FieldRef("psf_fitting.kernel_estimate")

Classes

FieldRef

A reference to a field on a Config class.

ComponentRef

Descriptor installed on a Config class for each component slot.

Module Contents

class cfx.refs.FieldRef(path, resolved_cls)[source]

A reference to a field on a Config class.

Obtained by accessing a field or component as a class attribute rather than on an instance. Attribute chains are validated against the schema at definition time — a typo in the path raises AttributeError immediately, not at the first runtime access.

Pass a FieldRef to Alias or Mirror instead of a plain string to keep paths refactorable via normal IDE rename and go-to-definition tools.

Examples

>>> from cfx import Config, Field, Alias
>>> class Inner(Config):
...     x: float = Field(1.0, "x value")
>>> class Outer(Config, components=[Inner]):
...     pass
>>> Outer.inner.x
FieldRef(...)
>>> Alias(Outer.inner.x)
<...Alias object at ...>
__getattr__(name)[source]
__repr__()[source]
class cfx.refs.ComponentRef(confid, cls)[source]

Descriptor installed on a Config class for each component slot.

Installed automatically by _ConfigType after _nested_classes is built. Returns a FieldRef on class-level access so component paths can be used in Alias and Mirror declarations. On instance access returns the stored sub-config instance as normal.

confid
cls
__set_name__(owner, name)[source]
__get__(obj, objtype=None)[source]