Initial Checks
Description
pydantic version 1.10.6 + mypy 1.1.1 + mypy plugin causes error with previously ok code.
Note: mypy plugin is irrelevant, and does not affect the output in this usecase
Using Field with a description on an optional Field, without an explicit default=None, used to work
$ mypy sample.py
sample.py:10: error: Missing named argument "bar" for "Sample" [call-arg]
Found 1 error in 1 file (checked 1 source file)
Error started happening with pydantic 1.10.4, version 1.10.2 does not have this issue
versions >1.10.2 now require the explicit default=None on Optional fields.
This seems like a bug, if not please advise.
Example Code
from typing import Optional
from pydantic import BaseModel, Field
class Sample(BaseModel):
foo: str
bar: Optional[str] = Field(description="optional")
Sample(foo="hello world")
Python, Pydantic & OS Version
pydantic version: 1.10.6
pydantic compiled: True
install path: /home/hatem/projects/inventory_service/venv/lib/python3.8/site-packages/pydantic
python version: 3.8.10 (default, Sep 28 2021, 16:10:42) [GCC 9.3.0]
platform: Linux-5.11.0-37-generic-x86_64-with-glibc2.29
optional deps. installed: ['dotenv', 'typing-extensions']
Affected Components
Initial Checks
Description
pydantic version 1.10.6 + mypy 1.1.1 + mypy plugin causes error with previously ok code.
Note: mypy plugin is irrelevant, and does not affect the output in this usecase
Using Field with a description on an optional Field, without an explicit default=None, used to work
Error started happening with pydantic 1.10.4, version 1.10.2 does not have this issue
versions >1.10.2 now require the explicit default=None on Optional fields.
This seems like a bug, if not please advise.
Example Code
Python, Pydantic & OS Version
Affected Components
.dict()and.json()construct(), pickling, private attributes, ORM mode