Skip to content

Commit

Permalink
Drop __post_serialize__ from SourceDefinition node class
Browse files Browse the repository at this point in the history
The method `__post_serialize__` on the `SourceDefinition` was used for
ensuring the property `_event_status` didn't make it to the serialized
version of the node. Now that resource definition of `SourceDefinition`
handles serialization/deserialization, we can drop `__post_serialize__`
as it is no longer needed.
  • Loading branch information
QMalcolm committed Feb 14, 2024
1 parent 28c1181 commit c6fe862
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
5 changes: 0 additions & 5 deletions core/dbt/contracts/graph/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1230,11 +1230,6 @@ class SourceDefinition(
def resource_class(cls) -> Type[SourceDefinitionResource]:
return SourceDefinitionResource

def __post_serialize__(self, dct):
if "_event_status" in dct:
del dct["_event_status"]
return dct

def same_database_representation(self, other: "SourceDefinition") -> bool:
return (
self.database == other.database
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/test_contracts_graph_parsed.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
TestMetadata,
SemanticModel,
)
from dbt.artifacts.resources import SourceDefinition as SourceDefinitionResource
from dbt import flags
from argparse import Namespace

Expand Down Expand Up @@ -2036,13 +2037,13 @@ def test_basic_source_definition(
node_dict = basic_parsed_source_definition_dict
minimum = minimum_parsed_source_definition_dict

assert_symmetric(node, node_dict, SourceDefinition)
assert_symmetric(node.to_resource(), node_dict, SourceDefinitionResource)

assert node.is_ephemeral is False
assert node.is_refable is False
assert node.has_freshness is False

assert_from_dict(node, minimum, SourceDefinition)
assert_from_dict(node.to_resource(), minimum, SourceDefinitionResource)
pickle.loads(pickle.dumps(node))


Expand All @@ -2063,7 +2064,7 @@ def test_complex_source_definition(
):
node = complex_parsed_source_definition_object
node_dict = complex_parsed_source_definition_dict
assert_symmetric(node, node_dict, SourceDefinition)
assert_symmetric(node.to_resource(), node_dict, SourceDefinitionResource)

assert node.is_ephemeral is False
assert node.is_refable is False
Expand Down

0 comments on commit c6fe862

Please sign in to comment.