Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix key in cfg semantics to handle edge cases with '???' and with interpolations that cannot be resolved. #50

Closed
omry opened this issue Oct 26, 2019 · 0 comments
Milestone

Comments

@omry
Copy link
Owner

omry commented Oct 26, 2019

Change semantics of key in cfg to be reasonable when key points to '???', or
is an interpolation that points to '???', or an interpolation that cannot be resolved.

desired behavior:

@pytest.mark.parametrize("conf,key,expected", [
    ({"a": 1, "b": {}}, "a", True),
    ({"a": 1, "b": {}}, "b", True),
    ({"a": 1, "b": {}}, "c", False),
    ({"a": 1, "b": "${a}"}, "b", True),
    ({"a": 1, "b": "???"}, "b", False),
    ({"a": 1, "b": "???", "c": "${b}"}, "c", False),
    ({"a": 1, "b": "${not_found}"}, "b", False),
])
def test_in_dict(conf, key, expected):
    conf = OmegaConf.create(conf)
    ret = key in conf
    assert ret == expected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant