DynamicRefConfig
Configuration for resolving OFFSET/INDIRECT via constraint-based inference.
Usage
DynamicRefConfig()Prefer building via from_constraints; the constructor is for internal use.
Parameter Attributes
cell_type_env: CellTypeEnvlimits: DynamicRefLimits
Methods
| Name | Description |
|---|---|
| from_constraints() | Build a config from a constraints schema (address keys -> type annotations) and instance data. |
| from_constraints_and_workbook() | Build config from constraints schema plus workbook values for constant cells. |
from_constraints()
Build a config from a constraints schema (address keys -> type annotations) and instance data.
Usage
from_constraints(constraints_schema, constraints_data, *, limits=None)constraints_schema must be a mapping (typically dict[str, type]) whose keys are sheet-qualified addresses (e.g. \"Sheet1!B1\"). Values are typing objects describing domains (Annotated, Literal, etc.). constraints_data may mirror keys for runtime validation elsewhere; it is not validated here.
Raises
TypeError-
If constraints_schema is not a mapping (e.g. a legacy
TypedDictclass passed instead of a dict).
from_constraints_and_workbook()
Build config from constraints schema plus workbook values for constant cells.
Usage
from_constraints_and_workbook(
constraints_schema, workbook_path, *, limits=None, data_only=True
)Constraints whose annotations carry a FromWorkbook marker are treated as singleton domains derived from the current cached value in the workbook. Other constraints are interpreted via constraints_to_cell_type_env as usual.
Performance note: The workbook is opened once in read_only mode and values are read via fastpyxl’s streaming parser. FromWorkbook addresses are sorted by (sheet, row, column) before iteration so that each sheet’s XML is parsed in a single forward pass. For large sheets whose constrained cells sit far down (e.g. row 900+), the initial parse to that row can take tens of seconds; subsequent sequential reads on the same sheet are fast. This is a deliberate tradeoff: FromWorkbook eliminates the maintenance burden of hardcoded Literal values at the cost of a longer config-build step.