Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit becb905

Browse files
hhoppeCarreau
authored andcommitted
Let %autoreload work on modules with frozen dataclasses
See Issue #12411 and Issue #12185. The problem is that a frozen `dataclasses.dataclass` overrides the `__setattr__()` method, so updating its `__class__` member requires going through the base `object` class. This seems to fix the problem.
1 parent 7917253 commit becb905

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

IPython/extensions/autoreload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ class definition and update their __class__ to point to the new class
300300

301301
for ref in refs:
302302
if type(ref) is old:
303-
ref.__class__ = new
303+
object.__setattr__(ref, "__class__", new)
304304

305305

306306
def update_class(old, new):

0 commit comments

Comments
 (0)