Parse Context⚓︎
context
⚓︎
Context objects passed through table and cell parsing.
Contexts keep project-owned dependencies separate from schema declarations. They are immutable containers passed through transformers, parsers, default factories, and validation hooks during one parse operation.
Info
talika copies user mappings into read-only views so parser code can
read dependencies without accidentally mutating caller-owned state.
ParseContext
dataclass
⚓︎
ParseContext(user_data: Mapping[str, Any] = (lambda: MappingProxyType({}))())
Project-owned dependencies and settings for one parse operation.
The library copies the supplied mapping and exposes it as read-only
user_data. Cell parsers, table transformers, and record validators all
receive data originating from this same context object.
Attributes:
from_value
classmethod
⚓︎
from_value(value: Mapping[str, Any] | ParseContext | None) -> ParseContext
Normalize raw context input.
Parameters:
-
value(Mapping[str, Any] | ParseContext | None) –None, an existingParseContext, or a project mapping.
Returns:
-
ParseContext–A
ParseContextinstance with read-onlyuser_data.
Raises:
-
TypeError–If
valuecannot be copied as a mapping.
Info
Existing ParseContext objects pass through unchanged, which lets
advanced callers construct and reuse immutable context values.
CellContext
dataclass
⚓︎
CellContext(
schema: type,
field_name: str,
field_label: str,
row: int | None,
column: int | None,
item_id: Any | None,
source_value: str,
user_data: Mapping[str, Any],
source_uri: str | None = None,
)
Source location and project data supplied to a field parser.
value is passed separately to a field parser and represents the
current, possibly transformed value. source_value records what was
written in the original Gherkin data table before table transformation.
Attributes:
-
schema(type) –Concrete schema class parsing the cell.
-
field_name(str) –Python attribute name receiving the parsed value.
-
field_label(str) –Canonical Gherkin data table label for the field.
-
row(int | None) –One-based source row when available.
-
column(int | None) –One-based source column when available.
-
item_id(Any | None) –Parsed record ID when available.
-
source_value(str) –Original feature-file text before transformation.
-
user_data(Mapping[str, Any]) –Read-only project data from
ParseContext. -
source_uri(str | None) –URI of the source document when known.
Warning
Parser functions receive the current value as a separate argument. Use
source_value only when diagnostics or project syntax need the
original feature text.
DefaultContext
dataclass
⚓︎
DefaultContext(
schema: type,
field_name: str,
field_label: str,
item_id: Any | None,
user_data: Mapping[str, Any],
source_uri: str | None = None,
)
Context supplied when a missing optional field uses a factory.
Default factories do not have a source cell because the field was omitted from the Gherkin data table. They still receive the selected schema, field identity, item ID when available, and the same read-only project data supplied to the parse operation.
Attributes:
-
schema(type) –Concrete schema class building the default.
-
field_name(str) –Python attribute name receiving the default.
-
field_label(str) –Canonical Gherkin data table label for the field.
-
item_id(Any | None) –Parsed record ID when available.
-
user_data(Mapping[str, Any]) –Read-only project data from
ParseContext. -
source_uri(str | None) –URI of the source document when known.
Info
Default factories run only for missing optional fields, not for explicit empty cells.