Skip to content

Commit 1051d6c

Browse files
Update Lib/dataclasses.py
Co-authored-by: sobolevn <mail@sobolevn.me>
1 parent 9a9ef90 commit 1051d6c

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

Lib/dataclasses.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,8 +1403,7 @@ def _add_slots(cls, is_frozen, weakref_slot, defined_fields):
14031403

14041404
# Fix the class reference in the __annotate__ method
14051405
init = newcls.__init__
1406-
if hasattr(init, "__annotate__"):
1407-
init_annotate = init.__annotate__
1406+
if init_annotate := getattr(init, "__annotate__", None):
14081407
if getattr(init_annotate, "__generated_by_dataclasses__", False):
14091408
_update_func_cell_for__class__(init_annotate, cls, newcls)
14101409

0 commit comments

Comments
 (0)