Hi community, I’m currently working on the <PR> su...
# contribute
n
Hi community, I’m currently working on the PR supporting superset matching in Union Types (the goal). I noticed an issue where, if default values aren’t specified for
Optional
fields, they are marked as required in the generated JSON schema. After investigating, I found that in Python,
Optional
means a field can be
None
or a specified type, but it still requires a value when creating the class. Therefore, the generated JSON schema will mark them as required. Since determining if a field is required is crucial for checking if they are in superset relationships, would it be reasonable to require a default value for
Optional
fields while using the superset match? Or maybe there are any better solutions? cc @damp-lion-88352 @cool-lifeguard-49380 @thankful-minister-83577 @damp-rain-31363
Currently this works ``````
Currently this works
Copy code
# upstream
@dataclass
class A:
    a: int

# downstream
@dataclass
class A:
    a: int
    b: Optional[str] = None
d
Vincent you are awesome🤩
c
Is this related to this proposal https://github.com/flyteorg/flyte/issues/5887 by @high-park-82026 ?
d
I think not
since we are using json schema to compare different dataclass
but not using literal type's field
c
Commented one small concern about this here. Maybe the concern is void, curious what you think 🙏
d
just 1 on 1 with Vincent
this problem is solved
he will update more info here
n
I updated some information on the PR descriptions and discussion. Please feel free to check it out, provide advice, or review the code!