Skip to content

Commit

Permalink
deprecation warning pretty
Browse files Browse the repository at this point in the history
  • Loading branch information
pereman2 committed Jul 23, 2020
1 parent a5e2dfc commit 1d03c19
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions omegaconf/basecontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
_get_value,
_is_interpolation,
_resolve_optional,
get_omega_conf_dumper,
get_ref_type,
get_value_kind,
get_yaml_loader,
Expand Down Expand Up @@ -216,32 +215,18 @@ def convert(val: Node) -> Any:
assert False

def pretty(self, resolve: bool = False, sort_keys: bool = False) -> str:
"""
returns a yaml dump of this config object.
:param resolve: if True, will return a string with the interpolations resolved, otherwise
interpolations are preserved
:param sort_keys: If True, will print dict keys in sorted order. default False.
:return: A string containing the yaml representation.
"""
from omegaconf import OmegaConf

warnings.warn(
"""
pretty() is deprecated, use OmegaConf.to_yaml() and resolve
now defaults to True (Since 2.0.1)
pretty() is deprecated and will be removed in a future version.
Use OmegaConf.to_yaml. Please note that the default value for
resolve has changed to True.
""",
category=UserWarning,
stacklevel=2,
)

container = OmegaConf.to_container(self, resolve=resolve, enum_to_str=True)
return yaml.dump( # type: ignore
container,
default_flow_style=False,
allow_unicode=True,
sort_keys=sort_keys,
Dumper=get_omega_conf_dumper(),
)
return OmegaConf.to_yaml(self, resolve=resolve, sort_keys=sort_keys)

@staticmethod
def _map_merge(dest: "BaseContainer", src: "BaseContainer") -> None:
Expand Down

0 comments on commit 1d03c19

Please sign in to comment.