Skip to content

Commit d2022a0

Browse files
authored
Add __match_args__ to dataclasses with no fields (#15749)
1 parent 6bdcc92 commit d2022a0

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

mypy/plugins/dataclasses.py

-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ def transform(self) -> bool:
365365
and (
366366
"__match_args__" not in info.names or info.names["__match_args__"].plugin_generated
367367
)
368-
and attributes
369368
and py_version >= (3, 10)
370369
):
371370
str_type = self._api.named_type("builtins.str")

test-data/unit/check-dataclasses.test

+5
Original file line numberDiff line numberDiff line change
@@ -1892,6 +1892,11 @@ class Two:
18921892
bar: int
18931893
t: Two
18941894
reveal_type(t.__match_args__) # N: Revealed type is "Tuple[Literal['bar']]"
1895+
@dataclass
1896+
class Empty:
1897+
...
1898+
e: Empty
1899+
reveal_type(e.__match_args__) # N: Revealed type is "Tuple[]"
18951900
[builtins fixtures/dataclasses.pyi]
18961901

18971902
[case testDataclassWithoutMatchArgs]

0 commit comments

Comments
 (0)