-
-
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
Checks
- I added a descriptive title to this issue
- I have searched (google, github) for similar issues and couldn't find anything
- I have read and followed the docs and still think this is a bug
Bug
Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":
python -c "import pydantic.utils; print(pydantic.utils.version_info())"
pydantic version: 1.8.2
pydantic compiled: False
install path: /Users/Sol/Project/pydantic/pydantic
python version: 3.9.5 (default, Jun 23 2021, 22:47:04) [Clang 11.0.3 (clang-1103.0.32.62)]
platform: macOS-10.15.6-x86_64-i386-64bit
optional deps. installed: ['devtools', 'dotenv', 'email-validator', 'typing-extensions']
from pydantic import BaseModel
from pydantic import Extra
class Foo(BaseModel):
a: int
class Config:
extra = Extra.allow
f = Foo(a=1, b=2)
breakpoint()
print(f) # << raise error. not only 'print', also str(Model), breakpoint().. etcbecause
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
povilasb
Metadata
Metadata
Assignees
Labels
bug V1Bug related to Pydantic V1.XBug related to Pydantic V1.X