-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
bug V1Bug related to Pydantic V1.XBug related to Pydantic V1.X
Description
It seems that this change caused a regression in the latest release. The behavior between static and dynamic classes is different now.
from typing import Optional
from pydantic import create_model, BaseModel
def test_optional_value():
class Test(BaseModel):
field1: str
field2: Optional[str]
Test(field1="a", field2="b")
Test(field1="a")
def test_dynamic_optional_value():
fields = {'field1': (str, ...), 'field2': (Optional[str], ...)}
Test = create_model("Test", __base__=BaseModel, **fields)
Test(field1="a", field2="b")
Test(field1="a")With pydantic 1.1.1 both test cases succeed, with pydantic 1.2 the dynamic test case fails.
Is this expected? Based on the changelog and the documentation I am inclined to think it is not. Should I open a separate bug?
Originally posted by @bartv in #990 (comment)
schneiderfelipe
Metadata
Metadata
Assignees
Labels
bug V1Bug related to Pydantic V1.XBug related to Pydantic V1.X