Skip to content

Commit 05ea128

Browse files
committed
changed conditional_dependencies to private
1 parent 53ce3da commit 05ea128

2 files changed

Lines changed: 15 additions & 14 deletions

File tree

synapseclient/extensions/curator/schema_generation.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5066,7 +5066,7 @@ class JSONSchema:
50665066
description: An optional description of the object described by this schema.
50675067
properties: A list of property schemas.
50685068
required: A list of properties required by the schema.
5069-
conditional_dependencies: A mapping of conditional dependencies to be added to the "allOf" keyword in JSON Schema.
5069+
_conditional_dependencies: A mapping of conditional dependencies to be added to the "allOf" keyword in JSON Schema.
50705070
The key is a tuple of (watched_property, enum_value)
50715071
The value is a list of properties that become required when watched_property has the value enum_value.
50725072
"""
@@ -5078,7 +5078,7 @@ class JSONSchema:
50785078
description: str = "TBD"
50795079
properties: dict[str, Property] = field(default_factory=dict)
50805080
required: list[str] = field(default_factory=list)
5081-
conditional_dependencies: dict[tuple[str, str], list[str]] = field(
5081+
_conditional_dependencies: dict[tuple[str, str], list[str]] = field(
50825082
default_factory=dict
50835083
)
50845084

@@ -5106,12 +5106,11 @@ def as_json_schema_dict(
51065106
# in the correct format to be added as is, and they need to be converted to allOf conditions first.
51075107
# Finally the conditional dependencies are removed from the JSON Schema dict because they are not a
51085108
# valid JSON Schema keyword
5109-
if self.conditional_dependencies:
5109+
if self._conditional_dependencies:
51105110
json_schema_dict["allOf"] = self._convert_conditional_properties_to_all_of(
5111-
self.conditional_dependencies
5111+
self._conditional_dependencies
51125112
)
5113-
json_schema_dict.pop("conditional_dependencies")
5114-
5113+
json_schema_dict.pop("_conditional_dependencies")
51155114
return json_schema_dict
51165115

51175116
def add_required_property(self, name: str) -> None:
@@ -5158,11 +5157,14 @@ def add_conditional_dependency(
51585157
enum_value: The value of the watched property that triggers the condition
51595158
dependent_property: The property that becomes required when the condition is triggered
51605159
"""
5161-
if (watched_property, enum_value) not in self.conditional_dependencies:
5162-
self.conditional_dependencies[(watched_property, enum_value)] = []
5163-
self.conditional_dependencies[(watched_property, enum_value)].append(
5164-
dependent_property
5165-
)
5160+
if (watched_property, enum_value) not in self._conditional_dependencies:
5161+
self._conditional_dependencies[(watched_property, enum_value)] = [
5162+
dependent_property
5163+
]
5164+
else:
5165+
self._conditional_dependencies[(watched_property, enum_value)].append(
5166+
dependent_property
5167+
)
51665168

51675169
@staticmethod
51685170
def _convert_conditional_properties_to_all_of(

tests/unit/synapseclient/extensions/unit_test_create_json_schema.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import logging
88
import os
99
from typing import Any, Optional
10-
from unittest import mock
1110
from unittest.mock import Mock
1211

1312
import pytest
@@ -264,7 +263,7 @@ def test_init(self) -> None:
264263
assert schema.description == "TBD"
265264
assert not schema.properties
266265
assert not schema.required
267-
assert not schema.conditional_dependencies
266+
assert not schema._conditional_dependencies
268267

269268
def test_as_json_schema_dict(self) -> None:
270269
"""Test the JSONSchema.as_json_schema_dict method"""
@@ -1261,7 +1260,7 @@ def test_set_conditional_dependencies(
12611260
_set_conditional_dependencies(
12621261
json_schema=json_schema, graph_state=gts, use_display_labels=False
12631262
)
1264-
assert json_schema.conditional_dependencies == expected_conditional_dependencies
1263+
assert json_schema._conditional_dependencies == expected_conditional_dependencies
12651264

12661265

12671266
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)