Skip to content

__match_args__ is not added to dataclasses with no fields #15748

Closed
@hamdanal

Description

@hamdanal

Bug Report

stubtest complains about missing __match_args__ if the dataclass has no fields

To Reproduce

Consider this python file:

from dataclasses import dataclass
from typing import ClassVar

@dataclass
class Good:
    x: ClassVar[bool]
    y: int = 0

@dataclass
class Bad:
    x: ClassVar[bool]

and the corresponding stub file

from dataclasses import dataclass
from typing import ClassVar

@dataclass
class Good:
    x: ClassVar[bool]
    y: int = ...

@dataclass
class Bad:
    x: ClassVar[bool]

Expected Behavior

Success: no issues found in 1 module

Actual Behavior

error: t.Bad.__match_args__ is not present in stub
Stub: in file /tmp/st-bug/t.pyi
MISSING
Runtime:
()

Found 1 error (checked 1 module)

Your Environment

  • Mypy version used: mypy 1.4.1 (compiled: yes)
  • Mypy command-line flags: N/A
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.10.6

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions