import_contract()

Import a contract/schema from an external format.

Usage

Source

import_contract(
    source,
    *,
    format=None,
    **kwargs,
)

Reads an external schema definition and produces a ContractImport with validation steps mapped to Pointblank methods. Use pb.list_adapters() to see all registered formats.

Parameters

source: Any
The source to import from. Can be: (1) a file path (str) to a schema/contract file, or
  1. a Python dict with schema content already loaded.
format: str | None = None

The format identifier (e.g., "json_schema", "frictionless", "dbt", "odcs"). If None, the format is auto-detected from file extension or content.

**kwargs: Any
Format-specific options passed to the adapter.

Returns

ContractImport
An object containing the imported columns, constraints, and methods to generate Validate objects, Contract objects, Python code, or YAML.

Raises

ValueError
If the format cannot be detected or no adapter is registered for it.

Examples

import pointblank as pb

# Import from JSON Schema
result = pb.import_contract("user_profile.schema.json", format="json_schema")
validation = result.to_validate(data=my_df)
validation.interrogate()

# Auto-detect format
result = pb.import_contract("datapackage.json")

# Import from a dict
schema_dict = {"type": "object", "properties": {"age": {"type": "integer", "minimum": 0}}}
result = pb.import_contract(schema_dict, format="json_schema")