optionlab icon indicating copy to clipboard operation
optionlab copied to clipboard

TypeError when run using Python version 3.12.3

Open hughandersen opened this issue 1 year ago • 2 comments

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

hughandersen avatar Sep 23 '24 23:09 hughandersen

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.

rgaveiga avatar Sep 24 '24 00:09 rgaveiga

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.

rgaveiga avatar Sep 24 '24 01:09 rgaveiga

Solved.

rgaveiga avatar Dec 17 '24 11:12 rgaveiga