prodict icon indicating copy to clipboard operation
prodict copied to clipboard

Python Unions in Prodict

Open sei-amellinger opened this issue 2 years ago • 0 comments

Greetings! I have a data structure that I set to be a string (single value) or a dict. So I've tried using this:

class ModelConfig(Prodict):
    label_mapping: typing.Union[Prodict, str]

This works okay for the PyCharm warnings and completion but if I try to assign a prodict I get all sorts of weird errors. So this doesn't work

model_config.label_mapping = Prodict.from_dict({"0": "dog", "1": "cat"})

Is there some sort of Union construct in Prodict that works better than the built in typing?

Thanks!

sei-amellinger avatar May 17 '22 13:05 sei-amellinger