Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b65cd9a

Browse filesBrowse 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
Copy full SHA for b65cd9a

File tree

Expand file treeCollapse file tree

1 file changed

+1
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+1
-3
lines changed

‎mypy/plugins/dataclasses.py

Copy file name to clipboardExpand all lines: mypy/plugins/dataclasses.py
+1-3Lines changed: 1 addition & 3 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.