Skip to content

Commit

Permalink
Fix value with anyof schema
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Gu <[email protected]>
  • Loading branch information
tylergu committed Feb 13, 2024
1 parent 757ffb3 commit 2c35c3f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions acto/input/value_with_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ def mutate(self, p_delete=0.05, p_replace=0.1):
self.store[child_key].mutate()

def update(self, value):
if value is None:
self.store = None
if isinstance(value, enum.Enum):
value = value.value
if value is None:
self.store = None
if isinstance(value, dict):
self.store = {}
for k, v in value.items():
Expand Down Expand Up @@ -270,10 +270,10 @@ def mutate(self, p_delete=0.05, p_replace=0.1):
self.store[index].mutate()

def update(self, value):
if value is None:
self.store = None
if isinstance(value, enum.Enum):
value = value.value
if value is None:
self.store = None
elif isinstance(value, list):
self.store = []
for i in value:
Expand Down Expand Up @@ -428,6 +428,8 @@ def get_value_by_path(self, path: list):

def create_path(self, path: list):
"""Ensures the path exists"""
if len(path) == 0:
return

# XXX: Complicated, no use case yet, let's implement later
raise NotImplementedError
Expand All @@ -438,6 +440,9 @@ def set_value_by_path(self, value, path):
else:
self.store.set_value_by_path(value, path)

def value(self):
return self.store


class ValueWithBasicSchema(ValueWithSchema):
"""Value with schema attached for Number/Integer, Bool, String"""
Expand Down Expand Up @@ -475,11 +480,11 @@ def mutate(self, p_delete=0.05, p_replace=0.1):
self.update(self.schema.gen())

def update(self, value):
if isinstance(value, enum.Enum):
value = value.value
if value is None:
self.store = None
else:
if isinstance(value, enum.Enum):
value = value.value
self.store = value

def get_value_by_path(self, path: list):
Expand Down

0 comments on commit 2c35c3f

Please sign in to comment.