optionlab
optionlab copied to clipboard
TypeError when run using Python version 3.12.3
I get an error when running this line of code when using Python version 3.12.3.
from optionlab import VERSION, run_strategy
TypeError: 'list' is not a valid discriminated union variant; should be a BaseModel or dataclass
It seems this problem has to do with Pydantic version >= 2.9: https://github.com/koxudaxi/datamodel-code-generator/issues/1937 It works with Pydantic 2.8.2.
Line 206 in models.py: strategy: list[Strategy] = Field(..., min_length=1, discriminator="type") This is the line that generates the error above for Pydantic >= 2.9.
Solved.