basedmypy icon indicating copy to clipboard operation
basedmypy copied to clipboard

`field` function used by `dataclass_transform` class doesn't work with default values if the argument is positional

Open DetachHead opened this issue 1 year ago • 0 comments

Describe the problem, ie expected/actual result (if it's not blatantly obvious)

original issue: https://github.com/pydantic/pydantic/issues/9902 also raised on bpr: https://github.com/DetachHead/basedpyright/issues/536

since mypy is able to detect that the positional argument is for default, then i don't see a reason why it shouldn't apply the dataclass special casing to it

Gist to reproduce

from pydantic import Field
from pydantic.dataclasses import dataclass

@dataclass
class Foo:
    a: int | None = Field(None)
    b: int | None = Field(default=None)


foo = Foo() # error: Argument missing for parameter "a"

Basedmypy version

No response

Command-line flags

No response

Configuration options from pyproject.toml (and other config files)

No response

Python version used

No response

Operating system and version

No response

DetachHead avatar Aug 05 '24 03:08 DetachHead