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
Is your feature request related to a problem? Please describe.
TypedDict is a convenient way to tell mypy about the allowed keys in a dict. However, using a TypedDict as the type of a structured config causes an error.
from omegaconf import OmegaConf, MISSING
import attr
from typing import TypedDict
class Foo(TypedDict):
foo: str
@attr.s(auto_attribs=True)
class Bar:
f: Foo = MISSING
Bar(f={'foo': 'a'})
Out [39]:
Bar(f={'foo': 'a'})
In [40]:
OmegaConf.structured(Bar)
Truncated Traceback (Use C-c C-$ to view full TB):
~/dev/devr/py/.venv/lib/python3.8/site-packages/omegaconf/_utils.py in _raise(ex, cause)
608 else:
609 ex.__cause__ = None
--> 610 raise ex # set end OC_CAUSE=1 for full backtrace
611
612
ValidationError: Unexpected object type : Foo
full_key:
reference_type=None
object_type=None
Describe the solution you'd like
I'd like TypedDict to be supported.
The text was updated successfully, but these errors were encountered:
NOTE: The runtime behavior of a typed dict after #474 is that it's just like a regular dict.
The extra type information is ignored at runtime. I am not currently interested in supporting additional inputs beyond dataclass and attr classes for Structured Configs.
Is your feature request related to a problem? Please describe.
TypedDict
is a convenient way to tellmypy
about the allowed keys in a dict. However, using a TypedDict as the type of a structured config causes an error.Describe the solution you'd like
I'd like TypedDict to be supported.
The text was updated successfully, but these errors were encountered: