Skip to content

Python Unions in Prodict #38

@sei-amellinger

Description

@sei-amellinger

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions