Errors⚓︎
errors
⚓︎
Structured table errors with source location details.
The package raises errors that are useful both to humans and to tools. Human messages explain what failed; stable codes and source coordinates let pytest, CLIs, and editor integrations render diagnostics without scraping strings.
Info
Row and column coordinates are one-based and refer to the original source
table whenever a TableCell is available.
TableErrorCode
⚓︎
Stable machine-readable categories for table failures.
Human-readable messages may improve over time. Integrations should use these codes when grouping diagnostics or deciding how to present them.
Warning
Codes are part of the supported diagnostic contract. Prefer adding new codes over changing existing meanings.
TableError
⚓︎
TableError(
message: str,
*,
schema: type | str | None = None,
field: str | None = None,
field_name: str | None = None,
field_label: str | None = None,
source_uri: str | None = None,
row: int | None = None,
column: int | None = None,
item_id: Any = _UNSET,
value: Any = _UNSET,
source_value: Any = _UNSET,
logical_value: Any = _UNSET,
code: TableErrorCode | str = TABLE_ERROR,
hint: str | None = None,
severity: DiagnosticSeverity | str = ERROR,
cause: BaseException | None = None,
)
Bases: ValueError
Represent one source-aware table diagnostic.
The structured attributes are intentionally public. Test runners and editor integrations can inspect them without parsing the human-readable error message.
Attributes:
-
message(str) –Human-readable failure summary.
-
schema(str | None) –Schema display name when known.
-
field(str | None) –Legacy human-facing field label associated with the failure.
-
field_name(str | None) –Python attribute name associated with the failure.
-
field_label(str | None) –Authored field label associated with the failure.
-
source_uri(str | None) –URI of the source document when known.
-
row(int | None) –One-based source row.
-
column(int | None) –One-based source column.
-
item_id(Any | None) –Parsed item ID when the failing record has one.
-
value(Any | None) –Legacy alias for the offending source value.
-
code(str) –Stable machine-readable diagnostic code.
-
hint(str | None) –Optional remediation text.
Info
TableError inherits ValueError so project validators can
raise ordinary value errors while the schema lifecycle wraps them in a
table-aware diagnostic.
Initialize one structured table diagnostic.
Parameters:
-
message(str) –Human-readable failure summary.
-
schema(type | str | None, default:None) –Schema class or display name associated with the failure.
-
field(str | None, default:None) –Legacy human-facing field label.
-
field_name(str | None, default:None) –Python attribute name for the declared field.
-
field_label(str | None, default:None) –Authored canonical or alias label for the field.
-
source_uri(str | None, default:None) –URI of the source document when known.
-
row(int | None, default:None) –One-based source row.
-
column(int | None, default:None) –One-based source column.
-
item_id(Any, default:_UNSET) –Parsed item identifier when available.
-
value(Any, default:_UNSET) –Offending source value. Omit to represent "no value".
-
source_value(Any, default:_UNSET) –Original authored value, superseding
value. -
logical_value(Any, default:_UNSET) –Current value after table transformation.
-
code(TableErrorCode | str, default:TABLE_ERROR) –Stable diagnostic category.
-
hint(str | None, default:None) –Optional user-facing remediation.
-
severity(DiagnosticSeverity | str, default:ERROR) –Diagnostic severity.
-
cause(BaseException | None, default:None) –Original exception when this error wraps another failure.
Warning
Passing value=None means the offending value is explicitly
None. Omit value entirely when no value should be reported.
logical_value
property
⚓︎
logical_value: Any | None
Return the current transformed value when present.
has_value
property
⚓︎
has_value: bool
Return whether the diagnostic contains an offending value.
Returns:
-
bool–Truewhenvaluewas supplied to the error constructor.
Info
This distinguishes an omitted value from an explicit None.
from_diagnostic
classmethod
⚓︎
from_diagnostic(diagnostic: Diagnostic) -> TableError
Create a compatibility exception around an existing diagnostic.
from_cell
classmethod
⚓︎
from_cell(
message: str,
cell: TableCell,
*,
schema: type | str | None = None,
field: str | None = None,
field_name: str | None = None,
field_label: str | None = None,
source_uri: str | None = None,
item_id: Any = _UNSET,
code: TableErrorCode | str = TABLE_ERROR,
hint: str | None = None,
severity: DiagnosticSeverity | str = ERROR,
cause: BaseException | None = None,
) -> TableError
Create an error located at a cell's original source.
This helper is useful inside custom table transformations. It reports the source syntax, not merely the current transformed value.
Parameters:
-
message(str) –Human-readable failure summary.
-
cell(TableCell) –Source-aware cell that caused the error.
-
schema(type | str | None, default:None) –Schema class or display name associated with the failure.
-
field(str | None, default:None) –Legacy human-facing field label.
-
field_name(str | None, default:None) –Python attribute name for the declared field.
-
field_label(str | None, default:None) –Authored canonical or alias label for the field.
-
source_uri(str | None, default:None) –Source document URI, overriding the cell URI.
-
item_id(Any, default:_UNSET) –Parsed item identifier when available.
-
code(TableErrorCode | str, default:TABLE_ERROR) –Stable diagnostic category.
-
hint(str | None, default:None) –Optional user-facing remediation.
-
severity(DiagnosticSeverity | str, default:ERROR) –Diagnostic severity.
-
cause(BaseException | None, default:None) –Original exception when this error wraps another failure.
Returns:
-
TableError–A
TableErrorpopulated fromcellsource coordinates.
TableErrors
⚓︎
TableErrors(errors: list[TableError] | tuple[TableError, ...])
Bases: ValueError
Aggregate raised when collect mode finds several table failures.
The contained errors retain their normal structured attributes and source locations. The aggregate itself is intentionally small so test runners, editor extensions, and command-line tools can render diagnostics in the format most useful to their users.
Attributes:
-
errors–Immutable tuple of collected
TableErrorobjects.
Info
Collection preserves discovery order so rendered diagnostics follow the table as closely as possible.
Initialize an aggregate of one or more diagnostics.
Parameters:
-
errors(list[TableError] | tuple[TableError, ...]) –Non-empty sequence of structured table errors.
Raises:
-
ValueError–If
errorsis empty.
Warning
Empty aggregates are rejected because their string representation would imply a failure without any actionable diagnostic.
diagnostics
property
⚓︎
diagnostics: tuple[Diagnostic, ...]
Return underlying immutable diagnostics in discovery order.
__iter__
⚓︎
__iter__() -> Iterator[TableError]
Iterate over diagnostics in discovery order.
Returns:
-
Iterator[TableError]–Iterator over contained
TableErrorobjects.
Info
This lets callers use list(exc) or simple loops without
reaching into exc.errors directly.
SchemaDefinitionError
⚓︎
Bases: ValueError
Report an invalid schema declaration before table input is parsed.
Attributes:
-
message–Human-readable declaration problem.
-
schema–Name of the schema being created when available.
Warning
These errors normally occur during class creation. Explicit variant families may be completed by decorators, so their family-wide checks run when the family is described or first finalized for parsing.
Initialize a schema-definition failure.
Parameters:
-
message(str) –Human-readable declaration problem.
-
schema(str | None, default:None) –Optional schema name associated with the problem.
Info
The formatted exception includes the schema name because these failures often occur during import before any table is parsed.