From 0d960b27e71207f0893b307c021ab1b37b652863 Mon Sep 17 00:00:00 2001 From: Quigley Malcolm Date: Tue, 30 Apr 2024 15:37:06 -0700 Subject: [PATCH] Update `exclusive_primary_alt_value_setting` to handle `None` dictionary --- core/dbt/config/project.py | 9 ++++----- core/dbt/config/utils.py | 7 +++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/core/dbt/config/project.py b/core/dbt/config/project.py index 79c5a1e881c..7309df3cbd6 100644 --- a/core/dbt/config/project.py +++ b/core/dbt/config/project.py @@ -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) diff --git a/core/dbt/config/utils.py b/core/dbt/config/utils.py index 0bd9f1eb6a5..b3a40af884a 100644 --- a/core/dbt/config/utils.py +++ b/core/dbt/config/utils.py @@ -1,4 +1,4 @@ -from typing import Any, Dict +from typing import Any, Dict, Optional from dbt.clients import yaml_helper @@ -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 @@ -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)