Skip to content

Commit

Permalink
remove support for OmegaConf.is_none()
Browse files Browse the repository at this point in the history
Was slated for removal in 2.2

The deprecation was handled in issue #547
This addresses issue #821
  • Loading branch information
pixelb committed May 13, 2022
1 parent d64ebc5 commit 730c9d7
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 26 deletions.
1 change: 1 addition & 0 deletions news/547.api_change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed support for `OmegaConf.is_none(cfg, "key")`. Please use `cfg.key is None` instead.
15 changes: 0 additions & 15 deletions omegaconf/omegaconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions tests/test_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down
8 changes: 0 additions & 8 deletions tests/test_omegaconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
[
Expand Down

0 comments on commit 730c9d7

Please sign in to comment.