Skip to content

Commit

Permalink
reverted changes to node_wrap
Browse files Browse the repository at this point in the history
  • Loading branch information
omry committed Mar 10, 2021
1 parent f86f590 commit bcd1d50
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions omegaconf/omegaconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,9 +898,6 @@ def _node_wrap(
ref_type: Any = Any,
) -> Node:
node: Node
allow_objects = parent is not None and parent._get_flag("allow_objects") is True
dummy = parent # OmegaConf.create(flags={"allow_objects": allow_objects})

is_dict = is_primitive_dict(value) or is_dict_annotation(type_)
is_list = (
type(value) in (list, tuple)
Expand All @@ -912,7 +909,7 @@ def _node_wrap(
node = DictConfig(
content=value,
key=key,
parent=dummy,
parent=parent,
ref_type=type_,
is_optional=is_optional,
key_type=key_type,
Expand All @@ -923,7 +920,7 @@ def _node_wrap(
node = ListConfig(
content=value,
key=key,
parent=dummy,
parent=parent,
is_optional=is_optional,
element_type=element_type,
ref_type=ref_type,
Expand All @@ -935,34 +932,33 @@ def _node_wrap(
is_optional=is_optional,
content=value,
key=key,
parent=dummy,
parent=parent,
key_type=key_type,
element_type=element_type,
)
elif type_ == Any or type_ is None:
node = AnyNode(value=value, key=key, parent=dummy, is_optional=is_optional)
node = AnyNode(value=value, key=key, parent=parent, is_optional=is_optional)
elif issubclass(type_, Enum):
node = EnumNode(
enum_type=type_,
value=value,
key=key,
parent=dummy,
parent=parent,
is_optional=is_optional,
)
elif type_ == int:
node = IntegerNode(value=value, key=key, parent=dummy, is_optional=is_optional)
node = IntegerNode(value=value, key=key, parent=parent, is_optional=is_optional)
elif type_ == float:
node = FloatNode(value=value, key=key, parent=dummy, is_optional=is_optional)
node = FloatNode(value=value, key=key, parent=parent, is_optional=is_optional)
elif type_ == bool:
node = BooleanNode(value=value, key=key, parent=dummy, is_optional=is_optional)
node = BooleanNode(value=value, key=key, parent=parent, is_optional=is_optional)
elif type_ == str:
node = StringNode(value=value, key=key, parent=dummy, is_optional=is_optional)
node = StringNode(value=value, key=key, parent=parent, is_optional=is_optional)
else:
if allow_objects:
node = AnyNode(value=value, key=key, parent=dummy, is_optional=is_optional)
if parent is not None and parent._get_flag("allow_objects") is True:
node = AnyNode(value=value, key=key, parent=parent, is_optional=is_optional)
else:
raise ValidationError(f"Unexpected object type : {type_str(type_)}")
node._set_parent(parent)
return node


Expand Down

0 comments on commit bcd1d50

Please sign in to comment.