-
-
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())":
pydantic version: 1.8.2
pydantic compiled: False
install path: /Users/kyleamos/Library/Caches/pypoetry/virtualenvs/api-KwVDv1SR-py3.9/lib/python3.9/site-packages/pydantic
python version: 3.9.1 (default, Jan 18 2022, 12:54:24) [Clang 13.0.0 (clang-1300.0.29.30)]
platform: macOS-12.1-arm64-arm-64bit
optional deps. installed: ['email-validator', 'typing-extensions']
from pydantic import BaseConfig, BaseModel, Field
class Foo(BaseModel):
class Config(BaseConfig):
allow_population_by_field_name = True
bar_: int = Field(..., alias="bar")
expected_value = 2
assert Foo(bar=expected_value).bar_ == expected_value
assert Foo.construct(bar=expected_value).bar_ == expected_value # AttributeError: 'Foo' object has no attribute 'bar_'
...dbradley771 and gusutabopb
Metadata
Metadata
Assignees
Labels
bug V1Bug related to Pydantic V1.XBug related to Pydantic V1.X