Skip to content

Binding inspector

The binding inspector compares a validated Spec with Python implementation signatures before compilation.

It checks that implementations accept declared arguments as keywords, that required parameters are declared, and that available argument and return annotations agree with the function contract.

The build package uses this inspector before invoking the Compiler. The inspector is independent of plan compilation and can inspect a Spec and return portable signature metadata for use by callers.

Inspect callable implementations bound to a Spec.

BindingInspection

Compare one Spec binding with its inspected Python implementation.

INSPECTION_DEPENDENCIES class-attribute instance-attribute

INSPECTION_DEPENDENCIES: dict[str, tuple[str, ...]] = {'inspect_declared_arguments': (), 'inspect_keyword_arguments': ('inspect_declared_arguments',), 'inspect_argument_annotations': ('inspect_keyword_arguments',), 'inspect_required_parameters': ('inspect_argument_annotations',), 'inspect_dataframe_contract': ('inspect_required_parameters',), 'inspect_return_annotation': ('inspect_dataframe_contract',)}

function instance-attribute

function = function

signature instance-attribute

signature = signature

dataframe_classes instance-attribute

dataframe_classes = dataframes.DataFrameClasses().resolve() if dataframe_classes is None else dataframe_classes

dataframe_inspection instance-attribute

dataframe_inspection = inspection.DataFrameInspection(signature, self.dataframe_classes)

inspect_spec classmethod

inspect_spec(spec_definition: Spec | Mapping[str, FunctionTemplate], entrypoints: Mapping[str, Entrypoint] | None = None, *, dataframe_classes: DataFrameClasses | None = None) -> dict[str, entrypoint.Signature]

Inspect every enabled function bound by the Spec.

inspect

inspect() -> None

Run all binding inspections in prerequisite order.

Raises:

Type Description
ValueError

The implementation violates the binding contract.

CycleError

Inspection dependencies contain a cycle.

inspect_declared_arguments

inspect_declared_arguments() -> None

Require each declared argument to be accepted by the implementation.

inspect_keyword_arguments

inspect_keyword_arguments() -> None

Require declared arguments to be passable as keywords.

inspect_argument_annotations

inspect_argument_annotations() -> None

Require annotated parameters to accept their declared argument types.

inspect_required_parameters

inspect_required_parameters() -> None

Reject required implementation parameters absent from the declaration.

inspect_dataframe_contract

inspect_dataframe_contract() -> None

Reject declarations with too many dataframe arguments.

inspect_return_annotation

inspect_return_annotation() -> None

Reject known Python return annotations that contradict the function contract.