You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Using Dict[str, List[str]] or other similar complex value types fails.
To Reproduce
fromdataclassesimportdataclassfromtypingimportDict, Tuple, ListfromomegaconfimportOmegaConf, MISSING@dataclassclassConfig:
# If I change List[str] to the following, same error:# Tuple[str, str]# Tuple[str, ...]# Dict[str, str]data: Dict[str, List[str]] =MISSING# omegaconf.errors.ValidationError: Unsupported value type : typing.List[str]OmegaConf.structured(Config)
Expected behavior
It should work.
Instead you get Validation error (on 2.0) and the following on master:
Traceback (most recent call last):
File "test.py", line 15, in <module>
OmegaConf.structured(Config)
File "/Users/gibiansky/env/lib/python3.7/site-packages/omegaconf/omegaconf.py", line 145, in structured
return OmegaConf.create(obj, parent, flags)
File "/Users/gibiansky/env/lib/python3.7/site-packages/omegaconf/omegaconf.py", line 201, in create
flags=flags,
File "/Users/gibiansky/env/lib/python3.7/site-packages/omegaconf/omegaconf.py", line 254, in _create_impl
flags=flags,
File "/Users/gibiansky/env/lib/python3.7/site-packages/omegaconf/dictconfig.py", line 105, in __init__
format_and_raise(node=None, key=None, value=None, cause=ex, msg=str(ex))
File "/Users/gibiansky/env/lib/python3.7/site-packages/omegaconf/dictconfig.py", line 89, in __init__
self._set_value(content, flags=flags)
File "/Users/gibiansky/env/lib/python3.7/site-packages/omegaconf/dictconfig.py", line 552, in _set_value
raise e
File "/Users/gibiansky/env/lib/python3.7/site-packages/omegaconf/dictconfig.py", line 549, in _set_value
self._set_value_impl(value, flags)
File "/Users/gibiansky/env/lib/python3.7/site-packages/omegaconf/dictconfig.py", line 580, in _set_value_impl
allow_objects=self._get_flag("allow_objects"),
File "/Users/gibiansky/env/lib/python3.7/site-packages/omegaconf/_utils.py", line 312, in get_structured_config_data
return get_dataclass_data(obj, allow_objects=allow_objects)
File "/Users/gibiansky/env/lib/python3.7/site-packages/omegaconf/_utils.py", line 253, in get_dataclass_data
parent=dummy_parent,
File "/Users/gibiansky/env/lib/python3.7/site-packages/omegaconf/omegaconf.py", line 846, in _maybe_wrap
ref_type=ref_type,
File "/Users/gibiansky/env/lib/python3.7/site-packages/omegaconf/omegaconf.py", line 777, in _node_wrap
element_type=element_type,
File "/Users/gibiansky/env/lib/python3.7/site-packages/omegaconf/dictconfig.py", line 105, in __init__
format_and_raise(node=None, key=None, value=None, cause=ex, msg=str(ex))
File "/Users/gibiansky/env/lib/python3.7/site-packages/omegaconf/dictconfig.py", line 77, in __init__
flags=flags,
File "<string>", line 10, in __init__
File "/Users/gibiansky/env/lib/python3.7/site-packages/omegaconf/base.py", line 42, in __post_init__
assert self.element_type is Any or isinstance(self.element_type, type)
AssertionError
Python 3.7.5 on recent Mac OSX.
The text was updated successfully, but these errors were encountered:
@Jasha10 Is there any workaround for this in omegaconf 2.1.1? Typically, I am trying to use a structured config for List[Dict] and fall into the same error. Are simple cases OK, for example List[Tuple[str, List]]?
Describe the bug
Using Dict[str, List[str]] or other similar complex value types fails.
To Reproduce
Expected behavior
It should work.
Instead you get Validation error (on 2.0) and the following on master:
Python 3.7.5 on recent Mac OSX.
The text was updated successfully, but these errors were encountered: