grapher.Node
Single workbook cell in a dependency graph.
Usage
grapher.Node()Canonical identity is address (CellKey). Change it through DependencyGraph.move_node; assigning address directly raises so relative formula axes cannot silently retarget. Legacy constructors that pass sheet/column/row still work and sync address in __init__.
formula_ast is the primary in-memory formula artifact. Construct nodes with formula_ast= when the tree is already known. normalized_formula is a derived view (render_formula with A1_ABSOLUTE); it is not stored, and the constructor keyword of the same name is only a bootstrap for string input. When an address is available, that bootstrap parses with parse_preserving_axes so $ vs bare A1 is kept; without an anchor, relative intent cannot be recovered. Unparseable cells keep the last known formula text as a fallback so has_formula still holds. DependencyGraph.formula_shapes is an optional eval/codegen overlay; missing or dropped shapes fall back to this AST. The raw workbook string formula is opt-in at extraction (create_dependency_graph(store_raw_formula=True)) and audit-only – on a compressed graph it still holds the pre-compression text, so never re-parse it as the node’s current definition.
is_leaf is true when the node has no outgoing dependency edges (value-only cells and literal-only formulas such as =1+1).
is_array_formula is true when extraction observed a fastpyxl ArrayFormula on this cell. array_formula_ref is the spill / CSE range Excel stored (ref, e.g. E1:E10), or None when that attribute was missing. Write-back emits ArrayFormula from these fields and refuses to scalarize a flagged cell whose ref was not observed. fastpyxl does not distinguish legacy CSE from dynamic-array spills; both round-trip as t="array".
Instances are slotted (no per-instance __dict__). Derived attributes (key, shape, column_index) are served from a process-wide LRU keyed on the canonical address rather than functools.cached_property.
metadata is a read-only Mapping for callers. Nodes without metadata share the immutable EMPTY_METADATA singleton instead of allocating a dict, so node.metadata["k"] = v is not supported (it raises TypeError on a node with no metadata yet). Writers — node hooks included — use set_metadata / update_metadata, or DependencyGraph.set_node_metadata.
Dimension binds and key coordinates live on SeriesCatalog, not on this node. key_point(catalog) and dimension_binds(catalog) are thin adapters that return None for unbound cells.
Parameter Attributes
sheet: str | None = Nonecolumn: str | None = Nonerow: int | None = Noneformula: str | None = Nonevalue: Any = Noneis_leaf: bool = Trueis_target: bool = Falsemetadata: Mapping[str, Any] = EMPTY_METADATAmin_col: str | None = Nonemin_row: int | None = Nonemax_col: str | None = Nonemax_row: int | None = Noneaddress: CellKey | None = Noneformula_ast: AstNode | None = Nonenormalized_formula: str | None = Noneis_array_formula: bool = Falsearray_formula_ref: str | None = None
Attributes
| Name | Description |
|---|---|
| has_formula | True when this cell has a formula AST or unparseable formula text. |
has_formula
True when this cell has a formula AST or unparseable formula text.
has_formula: bool
Methods
| Name | Description |
|---|---|
| apply_formula_text() |
Parse text into formula_ast, or keep it as unparseable fallback.
|
| dimension_binds() |
Series-level dimension binds for this cell in catalog, or None if unbound.
|
| key_point() |
Resolved key coordinates for this cell in catalog, or None if unbound.
|
| set_metadata() |
Replace this node’s metadata with a copy of metadata.
|
| update_metadata() |
Merge updates into this node’s metadata, allocating on first write.
|
apply_formula_text()
Parse text into formula_ast, or keep it as unparseable fallback.
Usage
apply_formula_text(text)When address is set, parse with parse_preserving_axes so $ vs bare A1 is kept. Without an anchor, relative intent cannot be recovered. Clears both when text is missing or blank. Used when a rewrite only has formula strings (the AST parser could not handle the cell).
dimension_binds()
Series-level dimension binds for this cell in catalog, or None if unbound.
Usage
dimension_binds(catalog)key_point()
Resolved key coordinates for this cell in catalog, or None if unbound.
Usage
key_point(catalog)catalog is a SeriesCatalog. Returns a KeyPoint when the cell is bound.
set_metadata()
Replace this node’s metadata with a copy of metadata.
Usage
set_metadata(metadata)Empty or None input drops back to the shared EMPTY_METADATA singleton, so nodes without metadata never own a dict.
update_metadata()
Merge updates into this node’s metadata, allocating on first write.
Usage
update_metadata(updates)