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

Deprecate OmegaConf.is_optional #700

Merged
merged 8 commits into from
Apr 29, 2021
Merged

Deprecate OmegaConf.is_optional #700

merged 8 commits into from
Apr 29, 2021

Conversation

Jasha10
Copy link
Collaborator

@Jasha10 Jasha10 commented Apr 28, 2021

Closes #698

Comment on lines 592 to 596
warnings.warn(
"`OmegaConf.is_optional()` is deprecated, see https://github.com/omry/omegaconf/issues/698",
stacklevel=2,
)
return _is_optional(obj, key)
Copy link
Owner

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.

Copy link
Collaborator Author

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?

Copy link
Owner

@omry omry Apr 29, 2021

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.

Copy link
Collaborator Author

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.

omegaconf/_utils.py Outdated Show resolved Hide resolved
Copy link
Owner

@omry omry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Jasha10 Jasha10 merged commit 0ba497e into omry:master Apr 29, 2021
@Jasha10 Jasha10 deleted the close698 branch April 29, 2021 23:21
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

Successfully merging this pull request may close these issues.

Deprecate public OmegaConf.is_optional() API
2 participants