Skip to content

Commit e40bf53

Browse files
authored
Fix changing omegaconf_absolute_to_relative_paths not taking effect after parsing once (#805)
1 parent 693c3d8 commit e40bf53

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Fixed
2929
(`#789 <https://github.com/omni-us/jsonargparse/pull/789>`__).
3030
- Misleading error message for invalid value for ``Literal`` strings (`#790
3131
<https://github.com/omni-us/jsonargparse/pull/790>`__).
32+
- Changing ``omegaconf_absolute_to_relative_paths`` not taking effect after
33+
parsing once (`#805 <https://github.com/omni-us/jsonargparse/pull/805>`__).
3234

3335
Changed
3436
^^^^^^^

jsonargparse_tests/test_omegaconf.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from jsonargparse_tests.conftest import get_parser_help, skip_if_omegaconf_unavailable
1919

2020
if omegaconf_support:
21-
from omegaconf import OmegaConf
21+
from omegaconf import OmegaConf, errors
2222

2323

2424
@pytest.fixture(autouse=True)
@@ -66,9 +66,6 @@ def test_omegaconf_interpolation_in_subcommands(mode, parser, subparser):
6666
subparser.add_argument("--source", type=str)
6767
subparser.add_argument("--target", type=str)
6868

69-
if mode == "omegaconf+absolute":
70-
set_parsing_settings(omegaconf_absolute_to_relative_paths=True)
71-
7269
parser.parser_mode = mode.replace("absolute", "")
7370
subcommands = parser.add_subcommands()
7471
subcommands.add_subcommand("sub", subparser)
@@ -77,6 +74,12 @@ def test_omegaconf_interpolation_in_subcommands(mode, parser, subparser):
7774
"source": "hello",
7875
"target": "${.source}" if mode == "omegaconf+" else "${source}",
7976
}
77+
78+
if mode == "omegaconf+absolute":
79+
with pytest.raises(errors.InterpolationKeyError):
80+
parser.parse_args(["sub", f"--config={yaml_dump(config)}"])
81+
set_parsing_settings(omegaconf_absolute_to_relative_paths=True)
82+
8083
cfg = parser.parse_args(["sub", f"--config={yaml_dump(config)}"])
8184
assert cfg.sub.target == "hello"
8285

0 commit comments

Comments
 (0)