CLI

Inheritance diagram of dbt_contracts.cli.CleanCommand, dbt_contracts.cli.CoreArgs, dbt_contracts.cli.DepsCommand, dbt_contracts.cli.DocsCommand, dbt_contracts.cli.GenerateCommand, dbt_contracts.cli.MainCommand, dbt_contracts.cli.ParseCommand, dbt_contracts.cli.ValidateCommand

Functions

clean()

Main entry point for executing dbt clean

deps()

Main entry point for executing dbt deps

docs()

Main entry point for executing dbt docs generate

generate()

Main entry point for the generate CLI command

parse()

Main entry point for executing dbt parse

validate()

Main entry point for the validator CLI command

Classes

CleanCommand(_case_sensitive, ...)

Run dbt clean.

CoreArgs(_case_sensitive, ...)

The CLI args common to all commands.

DepsCommand(_case_sensitive, ...)

Run dbt deps.

DocsCommand(_case_sensitive, ...)

Run dbt docs generate to generate the catalog.

GenerateCommand(_case_sensitive, ...)

Generate properties files for the configured contracts.

MainCommand(_case_sensitive, ...)

Run one of the contracts commands when running this module directly.

ParseCommand(_case_sensitive, ...)

Run dbt parse to generate the manifest.

ValidateCommand(_case_sensitive, ...)

Validate the configured contracts.

class dbt_contracts.cli.CoreArgs(_case_sensitive: bool | None = None, _nested_model_default_partial_update: bool | None = None, _env_prefix: str | None = None, _env_prefix_target: EnvPrefixTarget | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_file_depth: int | None = None, _env_ignore_empty: bool | None = None, _env_nested_delimiter: str | None = None, _env_nested_max_split: int | None = None, _env_parse_none_str: str | None = None, _env_parse_enums: bool | None = None, _cli_prog_name: str | None = None, _cli_parse_args: bool | list[str] | tuple[str, ...] | None = None, _cli_settings_source: CliSettingsSource[Any] | None = None, _cli_parse_none_str: str | None = None, _cli_hide_none_type: bool | None = None, _cli_avoid_json: bool | None = None, _cli_enforce_required: bool | None = None, _cli_use_class_docs_for_groups: bool | None = None, _cli_show_env_vars: bool | None = None, _cli_exit_on_error: bool | None = None, _cli_prefix: str | None = None, _cli_flag_prefix_char: str | None = None, _cli_implicit_flags: bool | Literal['dual', 'toggle'] | None = None, _cli_ignore_unknown_args: bool | None = None, _cli_kebab_case: bool | Literal['all', 'no_enums'] | None = None, _cli_shortcuts: Mapping[str, str | list[str]] | None = None, _secrets_dir: PathType | None = None, _build_sources: tuple[tuple[PydanticBaseSettingsSource, ...], dict[str, Any]] | None = None, *, profiles_dir: ~pathlib.Path = <factory>, project_dir: ~pathlib.Path = <factory>, profile: str | None = <factory>, target: str | None = <factory>, threads: int | None = None, clean: bool = False, deps: bool = False, config: ~pathlib.Path | None = None, contract: ~typing.Literal['models', 'models.columns', 'sources', 'sources.columns', 'macros', 'macros.arguments'] | None = None, files: ~typing.Annotated[list[str], ~pydantic_settings.sources.types._CliPositionalArg] = <factory>)

Bases: BaseSettings

The CLI args common to all commands. Commands subclass this, running in their cli_cmd method.

prog: ClassVar[str] = 'dbt-contracts'

The name of the command, shown in the help text

profiles_dir: Path
project_dir: Path
profile: str | None
target: str | None
threads: int | None
clean: bool
deps: bool
config: Path | None
contract: Literal['models', 'models.columns', 'sources', 'sources.columns', 'macros', 'macros.arguments'] | None
files: Annotated[list[str], _CliPositionalArg]
classmethod settings_customise_sources(settings_cls: type[BaseSettings], init_settings: PydanticBaseSettingsSource, env_settings: PydanticBaseSettingsSource, dotenv_settings: PydanticBaseSettingsSource, file_secret_settings: PydanticBaseSettingsSource) → tuple[PydanticBaseSettingsSource, ...]

Define the sources and their order for loading the settings values.

Args:

settings_cls: The Settings class. init_settings: The InitSettingsSource instance. env_settings: The EnvSettingsSource instance. dotenv_settings: The DotEnvSettingsSource instance. file_secret_settings: The SecretsSettingsSource instance.

Returns:

A tuple containing the sources and their order for loading the settings values.

classmethod parse(args: list[str] | None = None, prog: str | None = None) → Self

Parse the CLI args without running the command.

Parameters:
  • args – The args to parse. Parses the args given to the current process when None.

  • prog – The name of the program to show in the help text. Defaults to the command’s name.

Returns:

The parsed args.

classmethod run(args: list[str] | None = None, prog: str | None = None) → Self

Parse the CLI args and run the command.

Parameters:
  • args – The args to parse. Parses the args given to the current process when None.

  • prog – The name of the program to show in the help text. Defaults to the command’s name.

Returns:

The parsed args.

to_namespace() → Namespace

Convert these args to the namespace that dbt expects.

class dbt_contracts.cli.CleanCommand(_case_sensitive: bool | None = None, _nested_model_default_partial_update: bool | None = None, _env_prefix: str | None = None, _env_prefix_target: EnvPrefixTarget | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_file_depth: int | None = None, _env_ignore_empty: bool | None = None, _env_nested_delimiter: str | None = None, _env_nested_max_split: int | None = None, _env_parse_none_str: str | None = None, _env_parse_enums: bool | None = None, _cli_prog_name: str | None = None, _cli_parse_args: bool | list[str] | tuple[str, ...] | None = None, _cli_settings_source: CliSettingsSource[Any] | None = None, _cli_parse_none_str: str | None = None, _cli_hide_none_type: bool | None = None, _cli_avoid_json: bool | None = None, _cli_enforce_required: bool | None = None, _cli_use_class_docs_for_groups: bool | None = None, _cli_show_env_vars: bool | None = None, _cli_exit_on_error: bool | None = None, _cli_prefix: str | None = None, _cli_flag_prefix_char: str | None = None, _cli_implicit_flags: bool | Literal['dual', 'toggle'] | None = None, _cli_ignore_unknown_args: bool | None = None, _cli_kebab_case: bool | Literal['all', 'no_enums'] | None = None, _cli_shortcuts: Mapping[str, str | list[str]] | None = None, _secrets_dir: PathType | None = None, _build_sources: tuple[tuple[PydanticBaseSettingsSource, ...], dict[str, Any]] | None = None, *, profiles_dir: ~pathlib.Path = <factory>, project_dir: ~pathlib.Path = <factory>, profile: str | None = <factory>, target: str | None = <factory>, threads: int | None = None, clean: bool = False, deps: bool = False, config: ~pathlib.Path | None = None, contract: ~typing.Literal['models', 'models.columns', 'sources', 'sources.columns', 'macros', 'macros.arguments'] | None = None, files: ~typing.Annotated[list[str], ~pydantic_settings.sources.types._CliPositionalArg] = <factory>)

Bases: CoreArgs

Run dbt clean.

prog: ClassVar[str] = 'dbt-clean'

The name of the command, shown in the help text

cli_cmd() → None

Run dbt clean.

class dbt_contracts.cli.DepsCommand(_case_sensitive: bool | None = None, _nested_model_default_partial_update: bool | None = None, _env_prefix: str | None = None, _env_prefix_target: EnvPrefixTarget | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_file_depth: int | None = None, _env_ignore_empty: bool | None = None, _env_nested_delimiter: str | None = None, _env_nested_max_split: int | None = None, _env_parse_none_str: str | None = None, _env_parse_enums: bool | None = None, _cli_prog_name: str | None = None, _cli_parse_args: bool | list[str] | tuple[str, ...] | None = None, _cli_settings_source: CliSettingsSource[Any] | None = None, _cli_parse_none_str: str | None = None, _cli_hide_none_type: bool | None = None, _cli_avoid_json: bool | None = None, _cli_enforce_required: bool | None = None, _cli_use_class_docs_for_groups: bool | None = None, _cli_show_env_vars: bool | None = None, _cli_exit_on_error: bool | None = None, _cli_prefix: str | None = None, _cli_flag_prefix_char: str | None = None, _cli_implicit_flags: bool | Literal['dual', 'toggle'] | None = None, _cli_ignore_unknown_args: bool | None = None, _cli_kebab_case: bool | Literal['all', 'no_enums'] | None = None, _cli_shortcuts: Mapping[str, str | list[str]] | None = None, _secrets_dir: PathType | None = None, _build_sources: tuple[tuple[PydanticBaseSettingsSource, ...], dict[str, Any]] | None = None, *, profiles_dir: ~pathlib.Path = <factory>, project_dir: ~pathlib.Path = <factory>, profile: str | None = <factory>, target: str | None = <factory>, threads: int | None = None, clean: bool = False, deps: bool = False, config: ~pathlib.Path | None = None, contract: ~typing.Literal['models', 'models.columns', 'sources', 'sources.columns', 'macros', 'macros.arguments'] | None = None, files: ~typing.Annotated[list[str], ~pydantic_settings.sources.types._CliPositionalArg] = <factory>)

Bases: CoreArgs

Run dbt deps.

prog: ClassVar[str] = 'dbt-deps'

The name of the command, shown in the help text

cli_cmd() → None

Run dbt deps.

class dbt_contracts.cli.ParseCommand(_case_sensitive: bool | None = None, _nested_model_default_partial_update: bool | None = None, _env_prefix: str | None = None, _env_prefix_target: EnvPrefixTarget | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_file_depth: int | None = None, _env_ignore_empty: bool | None = None, _env_nested_delimiter: str | None = None, _env_nested_max_split: int | None = None, _env_parse_none_str: str | None = None, _env_parse_enums: bool | None = None, _cli_prog_name: str | None = None, _cli_parse_args: bool | list[str] | tuple[str, ...] | None = None, _cli_settings_source: CliSettingsSource[Any] | None = None, _cli_parse_none_str: str | None = None, _cli_hide_none_type: bool | None = None, _cli_avoid_json: bool | None = None, _cli_enforce_required: bool | None = None, _cli_use_class_docs_for_groups: bool | None = None, _cli_show_env_vars: bool | None = None, _cli_exit_on_error: bool | None = None, _cli_prefix: str | None = None, _cli_flag_prefix_char: str | None = None, _cli_implicit_flags: bool | Literal['dual', 'toggle'] | None = None, _cli_ignore_unknown_args: bool | None = None, _cli_kebab_case: bool | Literal['all', 'no_enums'] | None = None, _cli_shortcuts: Mapping[str, str | list[str]] | None = None, _secrets_dir: PathType | None = None, _build_sources: tuple[tuple[PydanticBaseSettingsSource, ...], dict[str, Any]] | None = None, *, profiles_dir: ~pathlib.Path = <factory>, project_dir: ~pathlib.Path = <factory>, profile: str | None = <factory>, target: str | None = <factory>, threads: int | None = None, clean: bool = False, deps: bool = False, config: ~pathlib.Path | None = None, contract: ~typing.Literal['models', 'models.columns', 'sources', 'sources.columns', 'macros', 'macros.arguments'] | None = None, files: ~typing.Annotated[list[str], ~pydantic_settings.sources.types._CliPositionalArg] = <factory>)

Bases: CoreArgs

Run dbt parse to generate the manifest.

prog: ClassVar[str] = 'dbt-parse'

The name of the command, shown in the help text

cli_cmd() → None

Run dbt parse.

class dbt_contracts.cli.DocsCommand(_case_sensitive: bool | None = None, _nested_model_default_partial_update: bool | None = None, _env_prefix: str | None = None, _env_prefix_target: EnvPrefixTarget | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_file_depth: int | None = None, _env_ignore_empty: bool | None = None, _env_nested_delimiter: str | None = None, _env_nested_max_split: int | None = None, _env_parse_none_str: str | None = None, _env_parse_enums: bool | None = None, _cli_prog_name: str | None = None, _cli_parse_args: bool | list[str] | tuple[str, ...] | None = None, _cli_settings_source: CliSettingsSource[Any] | None = None, _cli_parse_none_str: str | None = None, _cli_hide_none_type: bool | None = None, _cli_avoid_json: bool | None = None, _cli_enforce_required: bool | None = None, _cli_use_class_docs_for_groups: bool | None = None, _cli_show_env_vars: bool | None = None, _cli_exit_on_error: bool | None = None, _cli_prefix: str | None = None, _cli_flag_prefix_char: str | None = None, _cli_implicit_flags: bool | Literal['dual', 'toggle'] | None = None, _cli_ignore_unknown_args: bool | None = None, _cli_kebab_case: bool | Literal['all', 'no_enums'] | None = None, _cli_shortcuts: Mapping[str, str | list[str]] | None = None, _secrets_dir: PathType | None = None, _build_sources: tuple[tuple[PydanticBaseSettingsSource, ...], dict[str, Any]] | None = None, *, profiles_dir: ~pathlib.Path = <factory>, project_dir: ~pathlib.Path = <factory>, profile: str | None = <factory>, target: str | None = <factory>, threads: int | None = None, clean: bool = False, deps: bool = False, config: ~pathlib.Path | None = None, contract: ~typing.Literal['models', 'models.columns', 'sources', 'sources.columns', 'macros', 'macros.arguments'] | None = None, files: ~typing.Annotated[list[str], ~pydantic_settings.sources.types._CliPositionalArg] = <factory>)

Bases: CoreArgs

Run dbt docs generate to generate the catalog.

prog: ClassVar[str] = 'dbt-docs'

The name of the command, shown in the help text

cli_cmd() → None

Run dbt docs generate.

class dbt_contracts.cli.ValidateCommand(_case_sensitive: bool | None = None, _nested_model_default_partial_update: bool | None = None, _env_prefix: str | None = None, _env_prefix_target: EnvPrefixTarget | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_file_depth: int | None = None, _env_ignore_empty: bool | None = None, _env_nested_delimiter: str | None = None, _env_nested_max_split: int | None = None, _env_parse_none_str: str | None = None, _env_parse_enums: bool | None = None, _cli_prog_name: str | None = None, _cli_parse_args: bool | list[str] | tuple[str, ...] | None = None, _cli_settings_source: CliSettingsSource[Any] | None = None, _cli_parse_none_str: str | None = None, _cli_hide_none_type: bool | None = None, _cli_avoid_json: bool | None = None, _cli_enforce_required: bool | None = None, _cli_use_class_docs_for_groups: bool | None = None, _cli_show_env_vars: bool | None = None, _cli_exit_on_error: bool | None = None, _cli_prefix: str | None = None, _cli_flag_prefix_char: str | None = None, _cli_implicit_flags: bool | Literal['dual', 'toggle'] | None = None, _cli_ignore_unknown_args: bool | None = None, _cli_kebab_case: bool | Literal['all', 'no_enums'] | None = None, _cli_shortcuts: Mapping[str, str | list[str]] | None = None, _secrets_dir: PathType | None = None, _build_sources: tuple[tuple[PydanticBaseSettingsSource, ...], dict[str, Any]] | None = None, *, profiles_dir: ~pathlib.Path = <factory>, project_dir: ~pathlib.Path = <factory>, profile: str | None = <factory>, target: str | None = <factory>, threads: int | None = None, clean: bool = False, deps: bool = False, config: ~pathlib.Path | None = None, contract: ~typing.Literal['models', 'models.columns', 'sources', 'sources.columns', 'macros', 'macros.arguments'] | None = None, files: ~typing.Annotated[list[str], ~pydantic_settings.sources.types._CliPositionalArg] = <factory>, output: ~pathlib.Path | None = None, format: ~typing.Literal['txt', 'text', 'json', 'jsonl', 'github-annotations'] | None = None, no_fail: bool = False, terms: ~typing.Annotated[list[str] | None, ~pydantic_settings.sources.types._CliVariadicArg] = None)

Bases: CoreArgs

Validate the configured contracts.

prog: ClassVar[str] = 'dbt-validate'

The name of the command, shown in the help text

output: Path | None
format: Literal['txt', 'text', 'json', 'jsonl', 'github-annotations'] | None
no_fail: bool
terms: Annotated[list[str] | None, _CliVariadicArg]
cli_cmd() → None

Validate the configured contracts, exiting with code 1 when any fail unless no_fail is set.

class dbt_contracts.cli.GenerateCommand(_case_sensitive: bool | None = None, _nested_model_default_partial_update: bool | None = None, _env_prefix: str | None = None, _env_prefix_target: EnvPrefixTarget | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_file_depth: int | None = None, _env_ignore_empty: bool | None = None, _env_nested_delimiter: str | None = None, _env_nested_max_split: int | None = None, _env_parse_none_str: str | None = None, _env_parse_enums: bool | None = None, _cli_prog_name: str | None = None, _cli_parse_args: bool | list[str] | tuple[str, ...] | None = None, _cli_settings_source: CliSettingsSource[Any] | None = None, _cli_parse_none_str: str | None = None, _cli_hide_none_type: bool | None = None, _cli_avoid_json: bool | None = None, _cli_enforce_required: bool | None = None, _cli_use_class_docs_for_groups: bool | None = None, _cli_show_env_vars: bool | None = None, _cli_exit_on_error: bool | None = None, _cli_prefix: str | None = None, _cli_flag_prefix_char: str | None = None, _cli_implicit_flags: bool | Literal['dual', 'toggle'] | None = None, _cli_ignore_unknown_args: bool | None = None, _cli_kebab_case: bool | Literal['all', 'no_enums'] | None = None, _cli_shortcuts: Mapping[str, str | list[str]] | None = None, _secrets_dir: PathType | None = None, _build_sources: tuple[tuple[PydanticBaseSettingsSource, ...], dict[str, Any]] | None = None, *, profiles_dir: ~pathlib.Path = <factory>, project_dir: ~pathlib.Path = <factory>, profile: str | None = <factory>, target: str | None = <factory>, threads: int | None = None, clean: bool = False, deps: bool = False, config: ~pathlib.Path | None = None, contract: ~typing.Literal['models', 'models.columns', 'sources', 'sources.columns', 'macros', 'macros.arguments'] | None = None, files: ~typing.Annotated[list[str], ~pydantic_settings.sources.types._CliPositionalArg] = <factory>)

Bases: CoreArgs

Generate properties files for the configured contracts.

prog: ClassVar[str] = 'dbt-generate'

The name of the command, shown in the help text

cli_cmd() → None

Generate properties files for the configured contracts.

class dbt_contracts.cli.MainCommand(_case_sensitive: bool | None = None, _nested_model_default_partial_update: bool | None = None, _env_prefix: str | None = None, _env_prefix_target: EnvPrefixTarget | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_file_depth: int | None = None, _env_ignore_empty: bool | None = None, _env_nested_delimiter: str | None = None, _env_nested_max_split: int | None = None, _env_parse_none_str: str | None = None, _env_parse_enums: bool | None = None, _cli_prog_name: str | None = None, _cli_parse_args: bool | list[str] | tuple[str, ...] | None = None, _cli_settings_source: CliSettingsSource[Any] | None = None, _cli_parse_none_str: str | None = None, _cli_hide_none_type: bool | None = None, _cli_avoid_json: bool | None = None, _cli_enforce_required: bool | None = None, _cli_use_class_docs_for_groups: bool | None = None, _cli_show_env_vars: bool | None = None, _cli_exit_on_error: bool | None = None, _cli_prefix: str | None = None, _cli_flag_prefix_char: str | None = None, _cli_implicit_flags: bool | Literal['dual', 'toggle'] | None = None, _cli_ignore_unknown_args: bool | None = None, _cli_kebab_case: bool | Literal['all', 'no_enums'] | None = None, _cli_shortcuts: Mapping[str, str | list[str]] | None = None, _secrets_dir: PathType | None = None, _build_sources: tuple[tuple[PydanticBaseSettingsSource, ...], dict[str, Any]] | None = None, *, profiles_dir: ~pathlib.Path = <factory>, project_dir: ~pathlib.Path = <factory>, profile: str | None = <factory>, target: str | None = <factory>, threads: int | None = None, clean: bool = False, deps: bool = False, config: ~pathlib.Path | None = None, contract: ~typing.Literal['models', 'models.columns', 'sources', 'sources.columns', 'macros', 'macros.arguments'] | None = None, files: ~typing.Annotated[list[str], ~pydantic_settings.sources.types._CliPositionalArg] = <factory>, output: ~pathlib.Path | None = None, format: ~typing.Literal['txt', 'text', 'json', 'jsonl', 'github-annotations'] | None = None, no_fail: bool = False, terms: ~typing.Annotated[list[str] | None, ~pydantic_settings.sources.types._CliVariadicArg] = None, operation: ~typing.Literal['validate', 'generate'] = 'validate')

Bases: ValidateCommand

Run one of the contracts commands when running this module directly.

prog: ClassVar[str] = 'dbt-contracts'

The name of the command, shown in the help text

operation: Literal['validate', 'generate']
cli_cmd() → None

Run the given operation with the other args given.

dbt_contracts.cli.clean() → None

Main entry point for executing dbt clean

dbt_contracts.cli.deps() → None

Main entry point for executing dbt deps

dbt_contracts.cli.parse() → None

Main entry point for executing dbt parse

dbt_contracts.cli.docs() → None

Main entry point for executing dbt docs generate

dbt_contracts.cli.validate() → None

Main entry point for the validator CLI command

dbt_contracts.cli.generate() → None

Main entry point for the generate CLI command