KotlinIsland / KotlinIsland/basedmypy

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

Open
#727 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
202
Forks
6
PR merge metrics
No merged PRs in 30d

Description

### 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

```python
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_

Contributor guide

Open the contributing guide

Research direction

No source file or test is named. Start by running the supplied Pydantic dataclass example and trace basedmypy’s handling of dataclass_transform field arguments; done means positional Field(None) is treated like keyword default=None and no missing-argument error is reported for a.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.