We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug
In Python version >= 3.11, dataclasses prohibits setting the default value to mutable objects
so this is often the case : common: Example = field(default_factory=Example)
common: Example = field(default_factory=Example)
Here, if no assignment is given, the object becomes a _MISSING_TYPE.
When using this type in OmegaConf.structured, an error will occur.
OmegaConf.structured
Just like this facebookresearch/fairseq#5359 (comment)
To Reproduce
Run the code below will get this error
from dataclasses import dataclass, field from typing import List, Any from omegaconf import OmegaConf @dataclass class Example: num: int @dataclass class TestConfig(Example): common: Example = field(default_factory=Example) for k, field_info in TestConfig.__dataclass_fields__.items(): default_value = field_info.default default_factory = field_info.default_factory print( f"Field: {k}, Default Value: {default_value}, Default Factory: {default_factory}" ) mis = OmegaConf.structured(default_factory)
Expected behavior
Maybe add a type judgement for better compatibility.
Additional context
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Describe the bug
In Python version >= 3.11, dataclasses prohibits setting the default value to mutable objects
so this is often the case :
common: Example = field(default_factory=Example)
Here, if no assignment is given, the object becomes a _MISSING_TYPE.
When using this type in
OmegaConf.structured
, an error will occur.Just like this facebookresearch/fairseq#5359 (comment)
To Reproduce
Run the code below will get this error
Expected behavior
Maybe add a type judgement for better compatibility.
Additional context
The text was updated successfully, but these errors were encountered: