-
Notifications
You must be signed in to change notification settings - Fork 106
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
Deprecate OmegaConf.is_optional #700
Conversation
omegaconf/omegaconf.py
Outdated
warnings.warn( | ||
"`OmegaConf.is_optional()` is deprecated, see https://github.com/omry/omegaconf/issues/698", | ||
stacklevel=2, | ||
) | ||
return _is_optional(obj, key) |
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.
I am not sure there is a good reason behind defaulting to True.
If there isn't any, I think you can maintain the old deprecated implementation here for now and make a more strict internal _is_optional.
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.
I think that the defaulting to True is for the case where _is_optional(obj, key)
is called and key
cannot be found.
Currently, no code in the omegaconf/
directory is using this "defaulting to True" branch, as all the calls use the one-argument signature _is_optional(obj)
(though some code in the tests/
directory does use the two-argument signature).
Instead of returning True
in the case where key
cannot be found, what do you think about raising ConfigKeyError
?
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.
Since it's an internal function and the branch is not used now, I suggest using assertion to ensure that it's not tripping anyone.
If we ever need to do something if the key does not exist we can easily change this.
Make a pass on the usage to convince yourself it's not current;y possible for a user to hit this branch though.
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.
Make a pass on the usage to convince yourself it's not current;y possible for a user to hit this branch though.
Yup, it's not possible for a user to hit.
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.
lgtm
Closes #698