-
-
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
Bug
pydantic version: 1.5.1
default_factory gets run twice before any object instantiation. This is obvious for callables with side-effects:
>>> from pydantic import BaseModel, Field
>>> class Seq():
... def __init__(self):
... self.v = 0
... def __call__(self):
... self.v += 1
... return self.v
...
>>> class MyModel(BaseModel):
... id: int = Field(default_factory=Seq())
...
>>> MyModel()
MyModel(id=3)bharel
Metadata
Metadata
Assignees
Labels
bug V1Bug related to Pydantic V1.XBug related to Pydantic V1.X