diff --git a/news/698.api_change b/news/698.api_change new file mode 100644 index 000000000..3a13562b1 --- /dev/null +++ b/news/698.api_change @@ -0,0 +1 @@ +Removed support for `OmegaConf.is_optional()`. diff --git a/omegaconf/omegaconf.py b/omegaconf/omegaconf.py index d23b2b15b..5c6ec5e83 100644 --- a/omegaconf/omegaconf.py +++ b/omegaconf/omegaconf.py @@ -612,21 +612,6 @@ def is_missing(cfg: Any, key: DictKeyType) -> bool: except (UnsupportedInterpolationType, KeyError, AttributeError): return False - # DEPRECATED: remove in 2.2 - @staticmethod - def is_optional(obj: Any, key: Optional[Union[int, str]] = None) -> bool: - warnings.warn( - "`OmegaConf.is_optional()` is deprecated, see https://github.com/omry/omegaconf/issues/698", - stacklevel=2, - ) - if key is not None: - assert isinstance(obj, Container) - obj = obj._get_node(key) - if isinstance(obj, Node): - return obj._is_optional() - else: - return True - # DEPRECATED: remove in 2.2 @staticmethod def is_none(obj: Any, key: Optional[Union[int, DictKeyType]] = None) -> bool: diff --git a/tests/test_omegaconf.py b/tests/test_omegaconf.py index 4a3517eea..dd4ce43ee 100644 --- a/tests/test_omegaconf.py +++ b/tests/test_omegaconf.py @@ -1,6 +1,5 @@ import pathlib import platform -import re from pathlib import Path from typing import Any @@ -227,21 +226,6 @@ def test_is_dict(cfg: Any, expected: bool) -> None: assert OmegaConf.is_dict(cfg) == expected -def test_is_optional_deprecation() -> None: - with warns(UserWarning, match=re.escape("`OmegaConf.is_optional()` is deprecated")): - OmegaConf.is_optional("xxx") - - -def test_coverage_for_deprecated_OmegaConf_is_optional() -> None: - cfg = OmegaConf.create({"node": 123}) - with warns(UserWarning): - assert OmegaConf.is_optional(cfg) - with warns(UserWarning): - assert OmegaConf.is_optional(cfg, "node") - with warns(UserWarning): - assert OmegaConf.is_optional("not_a_node") - - @mark.parametrize("is_none", [True, False]) @mark.parametrize( "fac",