Skip to content

Commit

Permalink
fix: do not show changes for empty dicts
Browse files Browse the repository at this point in the history
  • Loading branch information
netomi committed Sep 4, 2024
1 parent 75314a5 commit 42dd132
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 7 additions & 6 deletions otterdog/models/organization_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,15 @@ def to_jsonnet(
if is_set_and_present(self.custom_properties) and len(self.custom_properties) > 0:
default_org_custom_property = CustomProperty.from_model_data(config.default_org_custom_property_config)

printer.println("custom_properties+: [")
printer.level_up()
if len(self.custom_properties) > 0:
printer.println("custom_properties+: [")
printer.level_up()

for custom_property in self.custom_properties:
custom_property.to_jsonnet(printer, config, context, False, default_org_custom_property)
for custom_property in self.custom_properties:
custom_property.to_jsonnet(printer, config, context, False, default_org_custom_property)

printer.level_down()
printer.println("],")
printer.level_down()
printer.println("],")

if is_set_and_present(self.workflows):
default_workflow_settings = cast(OrganizationSettings, default_object).workflows
Expand Down
5 changes: 4 additions & 1 deletion otterdog/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ def is_different_ignoring_order(value: Any, other_value: Any) -> bool:
def patch_to_other(value: Any, other_value: Any) -> tuple[bool, Any]:
if isinstance(value, dict):
if len(other_value) == 0:
return True, value
if len(value) > 0:
return True, value
else:
return False, None
else:
raise ValueError("non-empty dictionary values not supported yet")
elif isinstance(value, list):
Expand Down

0 comments on commit 42dd132

Please sign in to comment.