Skip to content

Commit b65cd9a

Browse files
authored
dataclass.replace: allow transformed classes (#15915)
We [already synthesize](#15843 (comment)) `__dataclass_fields__` for all classes including `@dataclass_transform`'d ones, thus assume more than PEP-681 says. We might as well assume `dataclasses.replace` applies on all same classes. This way we risk false positive since it'll raise in runtime. Fixes #15843.
1 parent 0222bf4 commit b65cd9a

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

Diff for: mypy/plugins/dataclasses.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,7 @@ def transform(self) -> bool:
375375
add_attribute_to_class(self._api, self._cls, "__match_args__", match_args_type)
376376

377377
self._add_dataclass_fields_magic_attribute()
378-
379-
if self._spec is _TRANSFORM_SPEC_FOR_DATACLASSES:
380-
self._add_internal_replace_method(attributes)
378+
self._add_internal_replace_method(attributes)
381379
if "__post_init__" in info.names:
382380
self._add_internal_post_init_method(attributes)
383381

0 commit comments

Comments
 (0)