Skip to content

Commit

Permalink
fix(serialization): set exclude_unset to False by default
Browse files Browse the repository at this point in the history
If set to True it means that any non-null default values created through omission will not be
serialized into JSON/YAML. This is problematic if we are using default values that can be manually
overriden but don't need to be specified explicitely most of the time.
  • Loading branch information
AntoineDao committed Nov 8, 2019
1 parent 0476fb3 commit 7de2337
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions queenbee/schema/qutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ def _keep_name_order_in_yaml():
class BaseModel(PydanticBaseModel):
"""BaseModel with functionality to return the object as a yaml string."""

def yaml(self, exclude_unset=True):
def yaml(self, exclude_unset=False):
return yaml.dump(
self.dict(exclude_unset=exclude_unset),
default_flow_style=False
)

def to_dict(self):
return self.dict(exclude_unset=True)
return self.dict(exclude_unset=False)

def to_json(self, filepath, indent=None):
"""Write workflow to a JSON file.
Expand All @@ -38,7 +38,7 @@ def to_json(self, filepath, indent=None):

def to_yaml(self, filepath):
"""Write workflow to a yaml file."""
content = self.yaml(exclude_unset=True)
content = self.yaml(exclude_unset=False)

with open(filepath, 'w') as out_file:
out_file.write('# This file is generated by queenbee\n')
Expand Down

0 comments on commit 7de2337

Please sign in to comment.