-
Notifications
You must be signed in to change notification settings - Fork 122
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
Improved handling of None
values in node validation
#592
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks ok.
A few inline comments.
Also, are there any known bugs this is fixing? If so, can you add corresponding tests?
def test_none_value_in_quoted_string(restore_resolvers: Any) -> None: | ||
OmegaConf.register_new_resolver("test", lambda x: x) | ||
cfg = OmegaConf.create({"x": "${test:'${missing}'}", "missing": None}) | ||
assert cfg.x == "None" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, so quoting an interpolation is equivalent to casting the resolved value to a string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. To clarify, there are two situations:
- The interpolation is exactly surrounded by quotes (
"${...}"
) => we resolve it normally but cast the result to string. - There are other characters around the interpolation (
"hello ${...} and hi"
) => this is strictly equivalent to regular string interpolations
I think this is the most intuitive behavior.
No user-facing bug that I know of. This is why it was originally part of #578 after the interpolation type validation (because it was fixing bugs there) This PR still adds some tests of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few refactorings and type-signature changes:
Co-authored-by: Jasha10 <[email protected]>
Co-authored-by: Jasha10 <[email protected]>
Co-authored-by: Jasha10 <[email protected]>
Co-authored-by: Jasha10 <[email protected]>
Co-authored-by: Jasha10 <[email protected]>
This PR extracts some of the changes from #578, related to the handling of
None
values.Note that the test
test_none_value_in_quoted_string
added here is not directly related to these changes (since it worked before this PR too), but it is good to have this test in before #578.