Skip to content

Commit

Permalink
Add __match_args__ to dataclasses with no fields (#15749)
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdanal authored Jul 22, 2023
1 parent 6bdcc92 commit d2022a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 0 additions & 1 deletion mypy/plugins/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ def transform(self) -> bool:
and (
"__match_args__" not in info.names or info.names["__match_args__"].plugin_generated
)
and attributes
and py_version >= (3, 10)
):
str_type = self._api.named_type("builtins.str")
Expand Down
5 changes: 5 additions & 0 deletions test-data/unit/check-dataclasses.test
Original file line number Diff line number Diff line change
Expand Up @@ -1892,6 +1892,11 @@ class Two:
bar: int
t: Two
reveal_type(t.__match_args__) # N: Revealed type is "Tuple[Literal['bar']]"
@dataclass
class Empty:
...
e: Empty
reveal_type(e.__match_args__) # N: Revealed type is "Tuple[]"
[builtins fixtures/dataclasses.pyi]

[case testDataclassWithoutMatchArgs]
Expand Down

0 comments on commit d2022a0

Please sign in to comment.