Skip to content

version resilient model could not handle type alias correctly #2035

@tadelesh

Description

@tadelesh

For example,

MyNamedUnion = Union["UnionModel1", "UnionModel2"]

class ModelWithNamedUnionProperty(Model):
    named_union: "MyNamedUnion" = rest_field(name="namedUnion")

class UnionModel1(Model):
    prop1: int = rest_field()

class UnionModel2(Model):
    prop2: int = rest_field()

test = ModelWithNamedUnionProperty({"namedUnion": {"prop1": 1}})

currently, test.named_union is a raw dict, the MyNamedUnion typing is not handled correctly.

Metadata

Metadata

Assignees

Labels

bugThis issue requires a change to an existing behavior in the product in order to be resolved.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions