Properties

Inheritance diagram of dbt_contracts.contracts.conditions.properties.IsMaterializedCondition, dbt_contracts.contracts.conditions.properties.MetaCondition, dbt_contracts.contracts.conditions.properties.NameCondition, dbt_contracts.contracts.conditions.properties.PathCondition, dbt_contracts.contracts.conditions.properties.TagCondition

Classes

IsMaterializedCondition()

Filter {kind} taking only those which are not ephemeral.

MetaCondition(*, meta, ...)

Filter {kind} based on their meta values.

NameCondition(*[, include, exclude, match_all])

Filter {kind} based on their names.

PathCondition(*[, include, exclude, match_all])

Filter {kind} based on their paths.

TagCondition(*[, tags])

Filter {kind} based on their tags.

class dbt_contracts.contracts.conditions.properties.NameCondition(*, include: Annotated[Sequence[str], BeforeValidator(func=to_tuple, json_schema_input_type=PydanticUndefined)] = (), exclude: Annotated[Sequence[str], BeforeValidator(func=to_tuple, json_schema_input_type=PydanticUndefined)] = (), match_all: bool = False)

Bases: ContractCondition, PatternMatcher

Filter {kind} based on their names.

run(item: (<class 'dbt.artifacts.resources.base.BaseResource'>, <class 'dbt.artifacts.resources.v1.components.ColumnInfo'>, <class 'dbt.artifacts.resources.v1.macro.MacroArgument'>)) → bool

Run this condition to check whether the given item should be processed.

class dbt_contracts.contracts.conditions.properties.PathCondition(*, include: Annotated[Sequence[str], BeforeValidator(func=to_tuple, json_schema_input_type=PydanticUndefined)] = (), exclude: Annotated[Sequence[str], BeforeValidator(func=to_tuple, json_schema_input_type=PydanticUndefined)] = (), match_all: bool = False)

Bases: ContractCondition, PatternMatcher

Filter {kind} based on their paths. Paths must match patterns which are relative to the root directory of the dbt project. Paths are always matched with forward slashes as separators on every OS, so patterns should use forward slashes e.g. models/staging.

__EXAMPLE__

You may define the paths as a list of lists where each part is a subdirectory within the path. These parts will then be unified by joining them with forward slashes.

include:
- ["path", "to", "folder1"]
- ["path", "to", "folder2"]
- ["path", "to", "folder3"]
exclude:
- ["path", "to", "another", "folder1"]
- ["path", "to", "another", "folder2"]
- ["path", "to", "another", "folder3"]
classmethod unify_chunked_path_values(values: str | Sequence[str] | Sequence[Sequence[str]]) → tuple[str, ...]

Unify all path values into a tuple of strings. Also merges path parts into a single path separated by forward slashes.

run(item: BaseResource) → bool

Run this condition to check whether the given item should be processed.

class dbt_contracts.contracts.conditions.properties.TagCondition(*, tags: Annotated[Sequence[str], BeforeValidator(func=to_tuple, json_schema_input_type=PydanticUndefined)] = ())

Bases: ContractCondition

Filter {kind} based on their tags.

tags: Annotated[Sequence[str], BeforeValidator(func=to_tuple, json_schema_input_type=PydanticUndefined)]
run(item: ParsedResource | ColumnInfo) → bool

Run this condition to check whether the given item should be processed.

class dbt_contracts.contracts.conditions.properties.MetaCondition(*, meta: ~collections.abc.Mapping[str, ~collections.abc.Sequence[str]] = <factory>)

Bases: ContractCondition

Filter {kind} based on their meta values.

meta: Mapping[str, Sequence[str]]
classmethod make_meta_values_tuple(meta: Mapping[str, str | Sequence[str]]) → dict[str, tuple[str]]

Convert all meta values to tuples

run(item: ParsedResource | ColumnInfo) → bool

Run this condition to check whether the given item should be processed.

class dbt_contracts.contracts.conditions.properties.IsMaterializedCondition

Bases: ContractCondition

Filter {kind} taking only those which are not ephemeral.

run(item: ParsedResource) → bool

Run this condition to check whether the given item should be processed.