-
Notifications
You must be signed in to change notification settings - Fork 116
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 subclassing dict #707
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.
Looking good.
Can you run this on Hydra to see if it would fail any tests?
omegaconf/_utils.py
Outdated
warnings.warn( | ||
"Subclassing of `Dict` by Structured Config classes is deprecated", | ||
UserWarning, | ||
stacklevel=2, | ||
stacklevel=1, | ||
) |
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.
With stacklevel=2
we get a warning that looks like this:
$ python tmp.py
/home/jbss/omegaconf.git/omegaconf/_utils.py:373: UserWarning: Subclassing of `Dict` by Structured Config classes is deprecated
dict_subclass_data = extract_dict_subclass_data(obj=obj, parent=dummy_parent)
With stacklevel=1
we get a warning that looks like this:
$ python tmp.py
/home/jbss/omegaconf.git/omegaconf/_utils.py:240: UserWarning: Subclassing of `Dict` by Structured Config classes is deprecated
warnings.warn(
I changed 2 -> 1 because I thought the dict_subclass_data = extract_dict_subclass_data(...)
was confusing...
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.
The exact interesting stack frame is probably not in a fixed depth.
Try to get it to issue the line calling OmegaConf.create()
in the simple case.
Also, add the name of the type subclassing Dict to the warning.
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.
It seems that there are no conflicts 👍 |
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 nits.
Also, add a news fragment.
tests/test_errors.py
Outdated
def test_dict_subclass_error() -> None: | ||
src = Str2Int() | ||
src["bar"] = "qux" # type: ignore | ||
# expected.finalize(cfg) |
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.
remove comment?
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.
Done in 192c9db.
tests/test_errors.py
Outdated
def test_dict_subclass_error() -> None: | ||
src = Str2Int() |
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.
Add a comment explaining what this function is testing and why it's a separate function.
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.
Done in b58bcd5.
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.
shipit
Closes #663