2 ms·
Pydantic has __post_init__. This is a based on code I have in my editor right now. Typing straight into the comment box so it might be wrong. Toy = Litera
by thanatropism 4y ago
Pydantic has __post_init__.
This is a based on code I have in my editor right now. Typing straight into the comment box so it might be wrong.
Toy = Literal['toy']
class Spec(BaseModel):
sample_size = Union[float, Toy]
def __post_init__(self):
self.sample_size = 0.1 if self.sample_size == 'toy' else self.sample_size