When I want to ignore some fields using attr library, I can use repr=False
option.
But I cloud't find a similar option in pydantic
Please see example code
import typing
import attr
from pydantic import BaseModel
@attr.s(auto_attribs=True)
class AttrTemp:
foo: typing.Any
boo: typing.Any = attr.ib(repr=False)
class Temp(BaseModel):
foo: typing.Any
boo: typing.Any # I don't want to print
class Config:
frozen = True
a = Temp(
foo="test",
boo="test",
)
b = AttrTemp(foo="test", boo="test")
print(a) # foo='test' boo='test'
print(b) # AttrTemp(foo='test')
However, it does not mean that there are no options at all, I can use the syntax print(a.dict(exclude={"boo"}))
Doesn't pydantic have an option like repr=False
?