def __setstate__(self, d: Dict[str, Any]) -> None: from omegaconf import DictConfig from omegaconf._utils import is_generic_dict, is_generic_list if isinstance(self, DictConfig): key_type = d["_metadata"].key_type # backward compatibility to load OmegaConf 2.0 configs if key_type is None: key_type = Any d["_metadata"].key_type = key_type element_type = d["_metadata"].element_type # backward compatibility to load OmegaConf 2.0 configs if element_type is None: element_type = Any d["_metadata"].element_type = element_type ref_type = d["_metadata"].ref_type if is_container_annotation(ref_type): if is_generic_dict(ref_type): d["_metadata"].ref_type = Dict[key_type, element_type] # type: ignore elif is_generic_list(ref_type): d["_metadata"].ref_type = List[element_type] # type: ignore else: assert False d["_flags_cache"] = None self.__dict__.update(d)
def __setstate__(self, d: Dict[str, Any]) -> None: from omegaconf import DictConfig from omegaconf._utils import is_generic_dict, is_generic_list if isinstance(self, DictConfig): key_type = d["_metadata"].key_type element_type = d["_metadata"].element_type ref_type = d["_metadata"].ref_type if is_container_annotation(ref_type): if is_generic_dict(ref_type): d["_metadata"].ref_type = Dict[key_type, element_type] # type: ignore elif is_generic_list(ref_type): d["_metadata"].ref_type = List[element_type] # type: ignore else: assert False self.__dict__.update(d)