Terms

Inheritance diagram of dbt_contracts.contracts.terms.ContractTerm, dbt_contracts.contracts.terms.ChildContractTerm, dbt_contracts.contracts.terms.ParentContractTerm

Classes

ContractTerm()

A part of a contract meant to apply checks on a specific item according to a set of rules.

ChildContractTerm()

ParentContractTerm()

class dbt_contracts.contracts.terms.ContractTerm

Bases: ContractPart, Generic

A part of a contract meant to apply checks on a specific item according to a set of rules.

May also process an item while also taking into account its parent item e.g. a Column (child item) within a Model (parent item)

needs_catalog: ClassVar[bool] = False

Mark if this term requires a loaded catalog to operate. The catalog must then be provided by the ContractContext for the term to execute successfully.

needs_manifest: ClassVar[bool] = False

Mark if this term requires a loaded manifest to operate. The manifest must then be provided by the ContractContext for the term to execute successfully.

abstractmethod run(item: I, context: ContractContext) → bool

Run this term on the given item.

Parameters:
  • item – The item to check.

  • context – The contract context to use.

Returns:

Boolean for if the item passes the term.

class dbt_contracts.contracts.terms.ChildContractTerm

Bases: ContractTerm, Generic

abstractmethod run(item: I, context: ContractContext, parent: P = None) → bool

Run this term on the given item and its parent.

Parameters:
  • item – The item to check.

  • context – The contract context to use.

  • parent – The parent item that the given child item belongs to if available.

Returns:

Boolean for if the item passes the term.

class dbt_contracts.contracts.terms.ParentContractTerm

Bases: ContractTerm, Generic

Modules

column

macro

model

node

properties

source