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

Error merging list with dicts into a list with dataclass #348

Closed
omry opened this issue Aug 29, 2020 · 0 comments · Fixed by #349
Closed

Error merging list with dicts into a list with dataclass #348

omry opened this issue Aug 29, 2020 · 0 comments · Fixed by #349
Labels
bug Something isn't working

Comments

@omry
Copy link
Owner

omry commented Aug 29, 2020

Error when merging a List with compatible list elements into a list of Structured Configs.

from dataclasses import field, dataclass
from typing import List
from omegaconf import OmegaConf, MISSING

@dataclass
class User:
    name: str = MISSING
    age: int = MISSING

@dataclass
class Users:
    list: List[User] = field(default_factory=list)

cfg = OmegaConf.merge(Users, {"list": [{"name": "Bond", "age": 7}]})

Result:

omegaconf.errors.ValidationError: Invalid type assigned : str is not a subclass of DataClass2. value: aaa
	full_key: list1[1]
	reference_type=List[DataClass2]
	object_type=list
@omry omry added the bug Something isn't working label Aug 29, 2020
@omry omry added this to the OmegaConf 2.0.1 milestone Aug 29, 2020
@omry omry changed the title Error merging list with dict into list with dataclass Error merging list with dicts into a list with dataclass Aug 29, 2020
@omry omry closed this as completed in #349 Aug 29, 2020
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.

1 participant