palantir / foundry-platform-python

The official Python library for the Foundry API
https://www.palantir.com/docs/foundry/api
Apache License 2.0
15 stars 3 forks source link

Cannot instantiate union types without specifying the type literal #49

Open jettdc opened 3 hours ago

jettdc commented 3 hours ago
string_type = StringType()

is invalid, you need to do

string_type = StringType(type="string")

which is redundant

Proposed solution: Add a default val for literals

something like

class StringType(pydantic.BaseModel):
    type: Literal["string"] = Field(default="string")
    ...
jettdc commented 2 hours ago

This also applies to things like

FullRowChangeDataCaptureConfiguration(type="fullRow", ...)

which should not be necessary, as there is only one valid value there and the class itself should be enough context