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

Dict subclass data not preserved during assignment #584

Closed
Jasha10 opened this issue Mar 8, 2021 · 2 comments · Fixed by #653
Closed

Dict subclass data not preserved during assignment #584

Jasha10 opened this issue Mar 8, 2021 · 2 comments · Fixed by #653
Labels
bug Something isn't working
Milestone

Comments

@Jasha10
Copy link
Collaborator

Jasha10 commented Mar 8, 2021

Describe the bug
When a Dict subclass is assigned to an omegaconf Node, the data from the dict is thrown away.

To Reproduce

$ cat tmp.py
from dataclasses import dataclass
from typing import Dict
from omegaconf import OmegaConf

@dataclass
class Str2Str(Dict[str, str]):
    x: int = 0

a = Str2Str()
assert a.x == 0
a["y"] = 1
assert a["y"] == 1
cfg_a = OmegaConf.create(a)
assert cfg_a.x == 0
assert "y" in cfg_a
assert cfg_a["y"] == 1
$ python tmp.py
Traceback (most recent call last):
  File "/Users/lappy486/omegaconf/tmp.py", line 18, in <module>
    assert "y" in cfg_a
AssertionError

Expected behavior
We expect the above assertions to succeed.

Additional context

  • OmegaConf version: 2.1.0dev20
  • Python version: 3.9.1
  • Operating system : MacOS
@Jasha10 Jasha10 added the bug Something isn't working label Mar 8, 2021
@Jasha10
Copy link
Collaborator Author

Jasha10 commented Mar 8, 2021

Filed based on comments here: #581 (comment)

@omry
Copy link
Owner

omry commented Mar 9, 2021

Yup, definitely smells like a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants