diff --git a/.changes/unreleased/Fixes-20240905-180248.yaml b/.changes/unreleased/Fixes-20240905-180248.yaml new file mode 100644 index 00000000000..3d18c28a4f6 --- /dev/null +++ b/.changes/unreleased/Fixes-20240905-180248.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: 'Remove deprecation for tests: to data_tests: change' +time: 2024-09-05T18:02:48.086421-04:00 +custom: + Author: gshank + Issue: "10564" diff --git a/core/dbt/contracts/graph/nodes.py b/core/dbt/contracts/graph/nodes.py index 4130a4483f7..b28910c0de3 100644 --- a/core/dbt/contracts/graph/nodes.py +++ b/core/dbt/contracts/graph/nodes.py @@ -18,7 +18,6 @@ from mashumaro.types import SerializableType -from dbt import deprecations from dbt.adapters.base import ConstraintSupport from dbt.adapters.factory import get_adapter_constraint_support from dbt.artifacts.resources import Analysis as AnalysisResource @@ -1148,12 +1147,6 @@ def validate_data_tests(self, is_root_project: bool): "Invalid test config: cannot have both 'tests' and 'data_tests' defined" ) if self.tests: - if is_root_project: - deprecations.warn( - "project-test-config", - deprecated_path="tests", - exp_path="data_tests", - ) self.data_tests.extend(self.tests) self.tests.clear() @@ -1164,12 +1157,6 @@ def validate_data_tests(self, is_root_project: bool): "Invalid test config: cannot have both 'tests' and 'data_tests' defined" ) if column.tests: - if is_root_project: - deprecations.warn( - "project-test-config", - deprecated_path="tests", - exp_path="data_tests", - ) column.data_tests.extend(column.tests) column.tests.clear() diff --git a/core/dbt/contracts/project.py b/core/dbt/contracts/project.py index b0b7179f333..ac54bfb9574 100644 --- a/core/dbt/contracts/project.py +++ b/core/dbt/contracts/project.py @@ -5,7 +5,6 @@ from mashumaro.types import SerializableType from typing_extensions import Annotated -from dbt import deprecations from dbt.adapters.contracts.connection import QueryComment from dbt.contracts.util import Identifier, list_str from dbt_common.contracts.util import Mergeable @@ -312,10 +311,6 @@ def validate(cls, data): raise ValidationError( "Invalid project config: cannot have both 'tests' and 'data_tests' defined" ) - if "tests" in data: - deprecations.warn( - "project-test-config", deprecated_path="tests", exp_path="data_tests" - ) @dataclass diff --git a/core/dbt/deprecations.py b/core/dbt/deprecations.py index 08ff8862c65..b9c4ab87cfc 100644 --- a/core/dbt/deprecations.py +++ b/core/dbt/deprecations.py @@ -98,11 +98,6 @@ class CollectFreshnessReturnSignature(DBTDeprecation): _event = "CollectFreshnessReturnSignature" -class TestsConfigDeprecation(DBTDeprecation): - _name = "project-test-config" - _event = "TestsConfigDeprecation" - - class ProjectFlagsMovedDeprecation(DBTDeprecation): _name = "project-flags-moved" _event = "ProjectFlagsMovedDeprecation" @@ -167,7 +162,6 @@ def show_callback(): ConfigLogPathDeprecation(), ConfigTargetPathDeprecation(), CollectFreshnessReturnSignature(), - TestsConfigDeprecation(), ProjectFlagsMovedDeprecation(), PackageMaterializationOverrideDeprecation(), ResourceNamesWithSpacesDeprecation(), diff --git a/core/dbt/events/types.py b/core/dbt/events/types.py index 0d125e781b6..dfd95eec6bf 100644 --- a/core/dbt/events/types.py +++ b/core/dbt/events/types.py @@ -388,6 +388,9 @@ def message(self) -> str: return line_wrap_message(warning_tag(f"Deprecated functionality\n\n{description}")) +# Note: this deprecation has been removed, but we are leaving +# the event class here, because users may have specified it in +# warn_error_options. class TestsConfigDeprecation(WarnLevel): def code(self) -> str: return "D012" diff --git a/core/dbt/parser/schemas.py b/core/dbt/parser/schemas.py index 96313425faa..957eb586bcd 100644 --- a/core/dbt/parser/schemas.py +++ b/core/dbt/parser/schemas.py @@ -4,7 +4,6 @@ from dataclasses import dataclass, field from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, Type, TypeVar -from dbt import deprecations from dbt.artifacts.resources import RefArgs from dbt.artifacts.resources.v1.model import TimeSpine from dbt.clients.jinja_static import statically_parse_ref_or_source @@ -568,12 +567,6 @@ def validate_and_rename(data, is_root_project: bool) -> None: raise ValidationError( "Invalid test config: cannot have both 'tests' and 'data_tests' defined" ) - if is_root_project: - deprecations.warn( - "project-test-config", - deprecated_path="tests", - exp_path="data_tests", - ) data["data_tests"] = data.pop("tests") # model-level tests diff --git a/tests/functional/deprecations/test_config_deprecations.py b/tests/functional/deprecations/test_config_deprecations.py index d4e965a8451..077dd7da103 100644 --- a/tests/functional/deprecations/test_config_deprecations.py +++ b/tests/functional/deprecations/test_config_deprecations.py @@ -32,7 +32,7 @@ def test_project_tests_config(self, project): deprecations.reset_deprecations() assert deprecations.active_deprecations == set() run_dbt(["parse"]) - expected = {"project-test-config"} + expected = set() assert expected == deprecations.active_deprecations def test_project_tests_config_fail(self, project): @@ -41,7 +41,7 @@ def test_project_tests_config_fail(self, project): with pytest.raises(CompilationError) as exc: run_dbt(["--warn-error", "--no-partial-parse", "parse"]) exc_str = " ".join(str(exc.value).split()) # flatten all whitespace - expected_msg = "The `tests` config has been renamed to `data_tests`" + expected_msg = "Configuration paths exist in your dbt_project.yml file which do not apply to any resources. There are 1 unused configuration paths: - data_tests" assert expected_msg in exc_str @@ -62,17 +62,13 @@ def test_generic_tests_config(self, project): deprecations.reset_deprecations() assert deprecations.active_deprecations == set() run_dbt(["parse"]) - expected = {"project-test-config"} + expected = set() assert expected == deprecations.active_deprecations def test_generic_tests_fail(self, project): deprecations.reset_deprecations() assert deprecations.active_deprecations == set() - with pytest.raises(CompilationError) as exc: - run_dbt(["--warn-error", "--no-partial-parse", "parse"]) - exc_str = " ".join(str(exc.value).split()) # flatten all whitespace - expected_msg = "The `tests` config has been renamed to `data_tests`" - assert expected_msg in exc_str + run_dbt(["--warn-error", "--no-partial-parse", "parse"]) def test_generic_data_test_parsing(self, project): results = run_dbt(["list", "--resource-type", "test"]) @@ -98,7 +94,7 @@ def test_source_tests_config(self, project): deprecations.reset_deprecations() assert deprecations.active_deprecations == set() run_dbt(["parse"]) - expected = {"project-test-config"} + expected = set() assert expected == deprecations.active_deprecations def test_generic_data_tests(self, project):