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

Inconsistent handling of fields without a value if dataclass or not. #411

Closed
omry opened this issue Oct 18, 2020 · 1 comment
Closed

Inconsistent handling of fields without a value if dataclass or not. #411

omry opened this issue Oct 18, 2020 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@omry
Copy link
Owner

omry commented Oct 18, 2020

Fields annotated as dataclass without a value auto-expends but primitive fields are turning into MISSING.
In the example below, User and age are treated differently.
I would expect both to be MISSING ('???').
Fixing it is a breaking change, need to evaluate it carefully.

from omegaconf import OmegaConf
from dataclasses import dataclass, field
from typing import Dict

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

@dataclass
class Config:
    user: User

cfg : Config = OmegaConf.structured(Config)
print(cfg)


$ python 2.py 
{'user': {'age': '???', 'name': 'foo'}}
@omry omry added the bug Something isn't working label Oct 18, 2020
@omry omry added this to the OmegaConf 2.1 milestone Oct 18, 2020
@omry
Copy link
Owner Author

omry commented Dec 26, 2020

Done, duplicate of #390.

@omry omry closed this as completed Feb 3, 2021
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

No branches or pull requests

1 participant