Skip to content

Commit b9109d6

Browse files
committed
first pass: turn on jsonschema deprecations by default
1 parent 1219bd4 commit b9109d6

File tree

6 files changed

+1
-27
lines changed

6 files changed

+1
-27
lines changed

core/dbt/jsonschemas/jsonschemas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def _get_allowed_config_fields_from_error_path(
141141

142142

143143
def _can_run_validations() -> bool:
144-
if not os.environ.get("DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS"):
144+
if os.environ.get("DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS", "true").lower() == "false":
145145
return False
146146

147147
invocation_context = get_invocation_context()

tests/functional/deprecations/test_deprecations.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ def models(self):
316316
"models.yml": invalid_deprecation_date_yaml,
317317
}
318318

319-
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
320319
def test_deprecated_invalid_deprecation_date(self, project):
321320
event_catcher = EventCatcher(GenericJSONSchemaValidationDeprecation)
322321
note_catcher = EventCatcher(Note)
@@ -362,7 +361,6 @@ def models(self):
362361
}
363362

364363
@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
365-
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
366364
def test_custom_key_in_config_deprecation(self, project):
367365
event_catcher = EventCatcher(CustomKeyInConfigDeprecation)
368366
run_dbt(
@@ -384,7 +382,6 @@ def models(self):
384382
}
385383

386384
@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
387-
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
388385
def test_custom_key_in_config_sql_deprecation(self, project):
389386
event_catcher = EventCatcher(CustomKeyInConfigDeprecation)
390387
run_dbt(
@@ -415,7 +412,6 @@ def models(self):
415412
}
416413

417414
@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
418-
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
419415
def test_multiple_custom_keys_in_config_deprecation(self, project):
420416
event_catcher = EventCatcher(CustomKeyInConfigDeprecation)
421417
run_dbt(
@@ -442,7 +438,6 @@ def models(self):
442438
}
443439

444440
@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
445-
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
446441
def test_custom_key_in_object_deprecation(self, project):
447442
event_catcher = EventCatcher(CustomKeyInObjectDeprecation)
448443
run_dbt(["parse", "--no-partial-parse"], callbacks=[event_catcher.catch])
@@ -486,7 +481,6 @@ def test_jsonschema_validation_deprecations_arent_run_without_env_var(
486481

487482

488483
class TestHappyPathProjectHasNoDeprecations:
489-
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
490484
@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
491485
def test_happy_path_project_has_no_deprecations(self, happy_path_project):
492486
event_cathcer = EventCatcher(DeprecationsSummary)
@@ -498,7 +492,6 @@ def test_happy_path_project_has_no_deprecations(self, happy_path_project):
498492

499493

500494
class TestBaseProjectHasNoDeprecations:
501-
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
502495
@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
503496
def test_base_project_has_no_deprecations(self, project):
504497
event_cathcer = EventCatcher(DeprecationsSummary)
@@ -707,7 +700,6 @@ class TestMissingPlusPrefixDeprecation:
707700
def project_config_update(self):
708701
return {"seeds": {"path": {"enabled": True}}}
709702

710-
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
711703
@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
712704
def test_missing_plus_prefix_deprecation(self, project):
713705
event_catcher = EventCatcher(MissingPlusPrefixDeprecation)
@@ -721,7 +713,6 @@ class TestMissingPlusPrefixDeprecationSubPath:
721713
def project_config_update(self):
722714
return {"seeds": {"path": {"+enabled": True, "sub_path": {"enabled": True}}}}
723715

724-
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
725716
@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
726717
def test_missing_plus_prefix_deprecation_sub_path(self, project):
727718
event_catcher = EventCatcher(MissingPlusPrefixDeprecation)
@@ -735,7 +726,6 @@ class TestMissingPlusPrefixDeprecationCustomConfig:
735726
def project_config_update(self):
736727
return {"seeds": {"path": {"custom_config": True, "sub_path": {"+enabled": True}}}}
737728

738-
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
739729
@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
740730
def test_missing_plus_prefix_deprecation_sub_path(self, project):
741731
event_catcher = EventCatcher(MissingPlusPrefixDeprecation)
@@ -749,7 +739,6 @@ class TestCustomConfigInDbtProjectYmlNoDeprecation:
749739
def project_config_update(self):
750740
return {"seeds": {"path": {"+custom_config": True}}}
751741

752-
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
753742
@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
754743
def test_missing_plus_prefix_deprecation_sub_path(self, project):
755744
note_catcher = EventCatcher(Note)
@@ -782,10 +771,6 @@ def test_jsonschema_validation_gating(
782771
dbt_private_run_jsonschema_validations: bool,
783772
expected_events: int,
784773
) -> None:
785-
mocker.patch.dict(
786-
os.environ,
787-
{"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": dbt_private_run_jsonschema_validations},
788-
)
789774

790775
if postgres_is_valid:
791776
supported_adapters_with_postgres = {
@@ -911,7 +896,6 @@ def models(self):
911896
"models.yml": property_moved_to_config_yaml,
912897
}
913898

914-
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
915899
@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
916900
def test_property_moved_to_config_deprecation(self, project):
917901
event_catcher = EventCatcher(PropertyMovedToConfigDeprecation)

tests/functional/source_overrides/test_simple_source_override.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
from datetime import datetime, timedelta, timezone
32
from unittest import mock
43

@@ -99,7 +98,6 @@ def _set_updated_at_to(self, insert_id, delta, project):
9998
return insert_id + 1
10099

101100
@mock.patch("dbt.jsonschemas.jsonschemas._JSONSCHEMA_SUPPORTED_ADAPTERS", {"postgres"})
102-
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
103101
def test_source_overrides(self, project):
104102
insert_id = 101
105103

tests/functional/test_project.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
from unittest import mock
32

43
import yaml
@@ -28,7 +27,6 @@ def test_project(self, project, mocker: MockerFixture) -> None:
2827
class TestGenericJsonSchemaValidationDeprecation:
2928
"""Ensure that the generic jsonschema validation deprecation can be fired"""
3029

31-
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
3230
def test_project(self, project, project_root: str) -> None:
3331

3432
# `name` was already required prior to this deprecation, so this deprecation doesn't

tests/unit/config/test_project.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,6 @@ def test_impossible_version_range(self, project_dict: Dict[str, Any]) -> None:
622622

623623
class TestDeprecations:
624624

625-
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
626625
def test_jsonschema_validate(self) -> None:
627626
from dbt.jsonschemas.jsonschemas import jsonschema_validate
628627

tests/unit/test_jsonschemas.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import os
2-
from unittest import mock
3-
41
from dbt.deprecations import (
52
CustomKeyInConfigDeprecation,
63
CustomKeyInObjectDeprecation,
@@ -14,7 +11,6 @@
1411

1512

1613
class TestValidateModelConfigNoError:
17-
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
1814
def test_validate_model_config_no_error(self):
1915
safe_set_invocation_context()
2016
get_invocation_context().uses_adapter("snowflake")
@@ -27,7 +23,6 @@ def test_validate_model_config_no_error(self):
2723
validate_model_config(config, "test.yml")
2824
assert len(caught_events) == 0
2925

30-
@mock.patch.dict(os.environ, {"DBT_ENV_PRIVATE_RUN_JSONSCHEMA_VALIDATIONS": "True"})
3126
def test_validate_model_config_error(self):
3227
safe_set_invocation_context()
3328
get_invocation_context().uses_adapter("snowflake")

0 commit comments

Comments
 (0)