-
-
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
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.7
pydantic compiled: True
install path: /Users/ahedges/.pyenv/versions/3.7.8/envs/sdf/lib/python3.7/site-packages/pydantic
python version: 3.7.8 (default, Sep 16 2020, 18:33:23) [Clang 11.0.3 (clang-1103.0.32.59)]
platform: Darwin-19.6.0-x86_64-i386-64bit
optional deps. installed: ['typing-extensions']
I created a file with the following code:
from pydantic import BaseModel, Field, PrivateAttr
class TestObject(BaseModel):
public_field: str = Field()
_private_field: str = PrivateAttr()I then ran mypy (version 0.790) using the pydantic plugin. I received the following type error:
test.py:5: error: Incompatible types in assignment (expression has type "PrivateAttr", variable has type "str")
Found 1 error in 1 file (checked 1 source file)
PrivateAttr should likely not cause a type error here, similarly to how Field works.
Metadata
Metadata
Assignees
Labels
bug V1Bug related to Pydantic V1.XBug related to Pydantic V1.X