-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Labels
bug V1Bug related to Pydantic V1.XBug related to Pydantic V1.X
Description
After #884, a child class of a model does not inherit its parent's __str__ and __repr__ overloads.
import pydantic
class Foo(pydantic.BaseModel):
x: int = 3
y: float = 4.2
def __str__(self):
return str(self.y + self.x)
f = Foo()
# Expected: 7.2
# Observed: 7.2
print(str(f))
class Bar(Foo):
z: bool = False
b = Bar()
# Expected: 7.2
# Observed: x=3 y=4.2 z=False
print(str(b))- OS: Ubuntu 19.10
- Python version
import sys; print(sys.version): 3.7.5 (default, Nov 20 2019, 09:21:52) [GCC 9.2.1 20191008] - Pydantic version
import pydantic; print(pydantic.VERSION): 1.1.1
Metadata
Metadata
Assignees
Labels
bug V1Bug related to Pydantic V1.XBug related to Pydantic V1.X