Exemplo n.º 1
0
    def _validate_and_convert_impl(self, value: Any) -> str:
        from omegaconf import OmegaConf

        if OmegaConf.is_config(value) or is_primitive_container(value):
            raise ValidationError(
                "Cannot convert '$VALUE_TYPE' to string: '$VALUE'")
        return str(value)
Exemplo n.º 2
0
    def validate_and_convert(self, value: Any) -> Optional[str]:
        from omegaconf import OmegaConf

        if OmegaConf.is_config(value) or is_primitive_container(value):
            raise ValidationError(
                "Cannot convert '$VALUE_TYPE' to string : '$VALUE'")
        return str(value) if value is not None else None
Exemplo n.º 3
0
def test_update_merge_set(cfg: Any, key: str, value: Any, merge: bool,
                          expected: Any) -> None:
    cfg = _ensure_container(cfg)
    if is_primitive_container(expected):
        OmegaConf.update(cfg, key, value, merge=merge)
        assert cfg == expected
    else:
        with expected:
            OmegaConf.update(cfg, key, value, merge=merge)