예제 #1
0
파일: nodes.py 프로젝트: Jasha10/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")
     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
파일: nodes.py 프로젝트: pereman2/omegaconf
    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)