From d2022a0007c0eb176ccaf37a9aa54c958be7fb10 Mon Sep 17 00:00:00 2001 From: Ali Hamdan Date: Sun, 23 Jul 2023 01:43:44 +0200 Subject: [PATCH] Add `__match_args__` to dataclasses with no fields (#15749) --- mypy/plugins/dataclasses.py | 1 - test-data/unit/check-dataclasses.test | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mypy/plugins/dataclasses.py b/mypy/plugins/dataclasses.py index a4babe7faf61..d782acf50af5 100644 --- a/mypy/plugins/dataclasses.py +++ b/mypy/plugins/dataclasses.py @@ -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") diff --git a/test-data/unit/check-dataclasses.test b/test-data/unit/check-dataclasses.test index 3866442230bf..1e01a72921f7 100644 --- a/test-data/unit/check-dataclasses.test +++ b/test-data/unit/check-dataclasses.test @@ -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]