Skip to content

Commit

Permalink
Update exclusive_primary_alt_value_setting to handle None dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
QMalcolm committed Apr 30, 2024
1 parent e1c7839 commit 0d960b2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 4 additions & 5 deletions core/dbt/config/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,12 +837,11 @@ def read_project_flags(project_dir: str, profiles_dir: str) -> ProjectFlags:
project_flags = profile_project_flags

if project_flags is not None:
# if warn_error_options are set, handle collapsing `include` and `error` as well as
# collapsing `exclude` and `warn`
# handle collapsing `include` and `error` as well as collapsing `exclude` and `warn`
# for warn_error_options
warn_error_options = project_flags.get("warn_error_options")
if warn_error_options:
exclusive_primary_alt_value_setting(warn_error_options, "include", "error")
exclusive_primary_alt_value_setting(warn_error_options, "exclude", "warn")
exclusive_primary_alt_value_setting(warn_error_options, "include", "error")
exclusive_primary_alt_value_setting(warn_error_options, "exclude", "warn")

ProjectFlags.validate(project_flags)
return ProjectFlags.from_dict(project_flags)
Expand Down
7 changes: 5 additions & 2 deletions core/dbt/config/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict
from typing import Any, Dict, Optional


from dbt.clients import yaml_helper
Expand Down Expand Up @@ -26,7 +26,7 @@ def parse_cli_yaml_string(var_string: str, cli_option_name: str) -> Dict[str, An


def exclusive_primary_alt_value_setting(
dictionary: Dict[str, Any], primary: str, alt: str
dictionary: Optional[Dict[str, Any]], primary: str, alt: str
) -> None:
"""Munges in place under the primary the options for the primary and alt values
Expand All @@ -35,6 +35,9 @@ def exclusive_primary_alt_value_setting(
the dictionary to ensure the primary key contains the values. If neither are set, nothing happens.
"""

if dictionary is None:
return

primary_options = dictionary.get(primary)
alt_options = dictionary.get(alt)

Expand Down

0 comments on commit 0d960b2

Please sign in to comment.