pydantic-pycharm-plugin icon indicating copy to clipboard operation
pydantic-pycharm-plugin copied to clipboard

no warning on instantiation of dataclass when fields, that define default as Field(...), are omitted

Open Krzysztof-Nerwinski opened this issue 2 years ago • 0 comments

When instantiating a pydantic dataclass with any field configured with default values as Field(...) there are not warnings if value is omitted. Runtime works like it should.

from dataclasses import dataclass

from pydantic import Field
from pydantic.dataclasses import dataclass as py_dataclass


@dataclass(kw_only=True)
class DefaultDataclass:
    param: list[str]


@py_dataclass(kw_only=True)
class PydanticDataclass:
    param: list[str] = Field(..., min_items=1, )


default = DefaultDataclass()
pydantic = PydanticDataclass()

Current Behavior: image

Expected behavior If any pydantic dataclasses attribute is defined with default as Field(..., **kwargs) it should mark attribute as required without default.

  • IDE: [IntelliJ IDEA 2022.2.2 (Ultimate Edition) with Python plugin v. 222.4167.37 ]
  • OS: [ Ubuntu 22.04 ]
  • Pydantic Version [ 1.10.2 ]
  • Plugin version [ 0.3.13 ]

Thank you for this plugin. It's a great help when working with pydantic.

Krzysztof-Nerwinski avatar Sep 29 '22 14:09 Krzysztof-Nerwinski