Skip to content

Commit

Permalink
Proper handling of null as default value to the env resolver
Browse files Browse the repository at this point in the history
Fixes omry#230
  • Loading branch information
odelalleau committed Feb 10, 2021
1 parent f0ccb16 commit 1e51bba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/230.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`${env:MYVAR,null}` now properly returns `None` if the environment variable MYVAR is undefined
6 changes: 6 additions & 0 deletions tests/test_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,12 @@ def test_env_node_interpolation(monkeypatch: Any) -> None:
c.my_key


def test_env_default_none(monkeypatch: Any) -> None:
monkeypatch.delenv("my_key", raising=False)
c = OmegaConf.create({"my_key": "${env:my_key, null}"})
assert c.my_key is None


def test_register_resolver_twice_error(restore_resolvers: Any) -> None:
def foo(_: Any) -> int:
return 10
Expand Down

0 comments on commit 1e51bba

Please sign in to comment.