示例#1
0
 def _set_value(self,
                value: Any,
                flags: Optional[Dict[str, bool]] = None) -> None:
     if self._get_flag("readonly"):
         raise ReadonlyConfigError(
             "Cannot set value of read-only config node")
     self._val = self.validate_and_convert(value)
示例#2
0
文件: nodes.py 项目: 7iW/omegaconf
    def _set_value(self, value: Any, flags: Optional[Dict[str, bool]] = None) -> None:
        if self._get_flag("readonly"):
            raise ReadonlyConfigError("Cannot set value of read-only config node")

        if isinstance(value, str) and get_value_kind(
            value, strict_interpolation_validation=True
        ) in (
            ValueKind.INTERPOLATION,
            ValueKind.MANDATORY_MISSING,
        ):
            self._val = value
        else:
            self._val = self.validate_and_convert(value)
示例#3
0
    def _set_value(self, value: Any, flags: Optional[Dict[str, bool]] = None) -> None:
        from ._utils import ValueKind, get_value_kind

        if self._get_flag("readonly"):
            raise ReadonlyConfigError("Cannot set value of read-only config node")

        if isinstance(value, str) and get_value_kind(value) in (
            ValueKind.INTERPOLATION,
            ValueKind.STR_INTERPOLATION,
            ValueKind.MANDATORY_MISSING,
        ):
            self._val = value
        else:
            if not self._metadata.optional and value is None:
                raise ValidationError("Non optional field cannot be assigned None")
            self._val = self.validate_and_convert(value)