Skip to content

Commit

Permalink
minor: cleanr usage of flag_override in DictConfig and ListConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
omry committed Mar 9, 2021
1 parent b7b90c3 commit cfdc972
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 3 additions & 4 deletions omegaconf/dictconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,10 +641,9 @@ def _set_value_impl(
self._metadata.flags = copy.deepcopy(flags)
# disable struct and readonly for the construction phase
# retaining other flags like allow_objects. The real flags are restored at the end of this function
with flag_override(self, "struct", False):
with flag_override(self, "readonly", False):
for k, v in value.__dict__["_content"].items():
self.__setitem__(k, v)
with flag_override(self, ["struct", "readonly"], False):
for k, v in value.__dict__["_content"].items():
self.__setitem__(k, v)

elif isinstance(value, dict):
for k, v in value.items():
Expand Down
7 changes: 3 additions & 4 deletions omegaconf/listconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,9 @@ def _set_value_impl(
self._metadata.flags = copy.deepcopy(flags)
# disable struct and readonly for the construction phase
# retaining other flags like allow_objects. The real flags are restored at the end of this function
with flag_override(self, "struct", False):
with flag_override(self, "readonly", False):
for item in value._iter_ex(resolve=False):
self.append(item)
with flag_override(self, ["struct", "readonly"], False):
for item in value._iter_ex(resolve=False):
self.append(item)
elif is_primitive_list(value):
for item in value:
self.append(item)
Expand Down

0 comments on commit cfdc972

Please sign in to comment.