Skip to content

Commit ada9e63

Browse files
authored
skip type checking deprecation_date on the basis of jsonschemas (#11823)
* skip type checking deprecation_date on the basis of jsonschemas * update test
1 parent 69d19eb commit ada9e63

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

core/dbt/jsonschemas.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ def jsonschema_validate(schema: Dict[str, Any], json: Dict[str, Any], file_path:
120120
file=file_path,
121121
key_path=key_path,
122122
)
123-
elif error.validator == "type" and "deprecation_date" not in error_path:
124-
# Not deprecating invalid types yet, except for pre-existing deprecation_date deprecation
123+
elif error.validator == "type":
124+
# Not deprecating invalid types yet
125125
pass
126126
elif error.validator == "anyOf" and len(error_path) > 0 and error_path[-1] == "config":
127127
for sub_error in error.context or []:

tests/functional/deprecations/test_deprecations.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
from dbt import deprecations
1111
from dbt.cli.main import dbtRunner
1212
from dbt.clients.registry import _get_cached
13-
from dbt.deprecations import (
14-
GenericJSONSchemaValidationDeprecation as GenericJSONSchemaValidationDeprecationCore,
15-
)
1613
from dbt.events.types import (
1714
CustomKeyInConfigDeprecation,
1815
CustomKeyInObjectDeprecation,
@@ -321,16 +318,9 @@ def test_deprecated_invalid_deprecation_date(self, project):
321318
True
322319
), "Expected an exception to be raised, because a model object can't be created with a deprecation_date as an int"
323320

324-
if GenericJSONSchemaValidationDeprecationCore()._is_preview:
325-
assert len(note_catcher.caught_events) == 1
326-
assert len(event_catcher.caught_events) == 0
327-
event = note_catcher.caught_events[0]
328-
else:
329-
assert len(event_catcher.caught_events) == 1
330-
assert len(note_catcher.caught_events) == 0
331-
event = event_catcher.caught_events[0]
332-
333-
assert "1 is not of type 'string', 'null' in file" in event.info.msg
321+
# type-based jsonschema validation is not enabled, so no deprecations are raised even though deprecation_date is an int
322+
assert len(event_catcher.caught_events) == 0
323+
assert len(note_catcher.caught_events) == 0
334324

335325

336326
class TestDuplicateYAMLKeysInSchemaFiles:

0 commit comments

Comments
 (0)