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

Assignment of primitive type to subscripted Dict modifying the value. #409

Closed
4 tasks done
pereman2 opened this issue Oct 18, 2020 · 0 comments · Fixed by #417
Closed
4 tasks done

Assignment of primitive type to subscripted Dict modifying the value. #409

pereman2 opened this issue Oct 18, 2020 · 0 comments · Fixed by #417
Labels
bug Something isn't working
Milestone

Comments

@pereman2
Copy link
Contributor

Describe the bug
Assigning an int into a Subscripted Dict raises an error without a descriptive message also, it modifies the value after it to an empty dict.
To Reproduce

@dataclass
class DictClass:
    foo: Dict[str, int] = field(default_factory=lambda: {"a": 4})

@dataclass
class User:
    age: int = 4
    name: str = "foo"

cfg = OmegaConf.structured(DictClass)
cfg.foo = 10

Output

ValidationError: 
        full_key: foo
        reference_type=Optional[DictClass]
        object_type=DictClass

After the error cfg.foo is modified:
print(cfg.foo) # prints '{}'

Expected behaviour
cfg.foo = 1 should raise a descriptive error message.

Additional context

  • OmegaConf version: 2.1.0
  • Python version: 3.8
  • Operating system : macOS
  • Please provide a minimal repro
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