From 730c9d7beb33ce0cd489a51d8a3df2f6006e71d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?=
Date: Thu, 12 May 2022 13:56:03 +0100 Subject: [PATCH] remove support for OmegaConf.is_none() Was slated for removal in 2.2 The deprecation was handled in issue #547 This addresses issue #821 --- news/547.api_change | 1 + omegaconf/omegaconf.py | 15 --------------- tests/test_matrix.py | 4 +--- tests/test_omegaconf.py | 8 -------- 4 files changed, 2 insertions(+), 26 deletions(-) create mode 100644 news/547.api_change diff --git a/news/547.api_change b/news/547.api_change new file mode 100644 index 000000000..00ded5ee8 --- /dev/null +++ b/news/547.api_change @@ -0,0 +1 @@ +Removed support for `OmegaConf.is_none(cfg, "key")`. Please use `cfg.key is None` instead. diff --git a/omegaconf/omegaconf.py b/omegaconf/omegaconf.py index 1ff5c61bd..63862054e 100644 --- a/omegaconf/omegaconf.py +++ b/omegaconf/omegaconf.py @@ -32,7 +32,6 @@ from ._utils import ( _DEFAULT_MARKER_, _ensure_container, - _is_none, format_and_raise, get_dict_key_value_types, get_list_element_type, @@ -610,20 +609,6 @@ def is_optional(obj: Any, key: Optional[Union[int, str]] = None) -> bool: else: return True - # DEPRECATED: remove in 2.2 - @staticmethod - def is_none(obj: Any, key: Optional[Union[int, DictKeyType]] = None) -> bool: - warnings.warn( - "`OmegaConf.is_none()` is deprecated, see https://github.com/omry/omegaconf/issues/547", - stacklevel=2, - ) - - if key is not None: - assert isinstance(obj, Container) - obj = obj._get_node(key) - - return _is_none(obj, resolve=True, throw_on_resolution_failure=False) - @staticmethod def is_interpolation(node: Any, key: Optional[Union[int, str]] = None) -> bool: if key is not None: diff --git a/tests/test_matrix.py b/tests/test_matrix.py index 5a2600bc0..987be1ee2 100644 --- a/tests/test_matrix.py +++ b/tests/test_matrix.py @@ -3,7 +3,7 @@ from pathlib import Path from typing import Any, Optional -from pytest import mark, raises, warns +from pytest import mark, raises from omegaconf import ( BooleanNode, @@ -49,8 +49,6 @@ def verify( assert cfg.get(key) == exp assert OmegaConf.is_missing(cfg, key) == missing - with warns(UserWarning): - assert OmegaConf.is_none(cfg, key) == none_public assert _is_optional(cfg, key) == opt assert OmegaConf.is_interpolation(cfg, key) == inter diff --git a/tests/test_omegaconf.py b/tests/test_omegaconf.py index 4a3517eea..2e37edc81 100644 --- a/tests/test_omegaconf.py +++ b/tests/test_omegaconf.py @@ -301,20 +301,12 @@ def test_is_none(fac: Any, is_none: bool) -> None: ) def test_is_none_interpolation(cfg: Any, key: str, is_none: bool) -> None: cfg = OmegaConf.create(cfg) - with warns(UserWarning): - assert OmegaConf.is_none(cfg, key) == is_none check = _is_none( cfg._get_node(key), resolve=True, throw_on_resolution_failure=False ) assert check == is_none -def test_is_none_invalid_node() -> None: - cfg = OmegaConf.create({}) - with warns(UserWarning): - assert OmegaConf.is_none(cfg, "invalid") - - @mark.parametrize( "fac", [