You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
frompydanticimportBaseModelfrompydanticimportExtraclassFoo(BaseModel):
a: intclassConfig:
extra=Extra.allowf=Foo(a=1, b=2)
breakpoint()
print(f) # << raise error. not only 'print', also str(Model), breakpoint().. etc
because
field b that allowed is not in Model.fields
in main.BaseModel
class BaseModel(Representation, metaclass=ModelMetaclass):
...
def __repr_args__(self) -> 'ReprArgs':
return [(k, v) for k, v in self.__dict__.items() if self.__fields__[k].field_info.repr] # KeyError
The text was updated successfully, but these errors were encountered:
* exclude extra field when represent model
* add test code
* fix W293
* add change md
* Update changes/3234-cocolman.md
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* Update pydantic/main.py
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
* Update tests/test_main.py
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
Checks
Bug
Output of
python -c "import pydantic.utils; print(pydantic.utils.version_info())"
:because
field b that allowed is not in Model.fields
in
main.BaseModel
The text was updated successfully, but these errors were encountered: