New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to autoreload @dataclass(frozen=True) #12185
Comments
Hummm... If you know what you are doing then we'll happily take a Pull Request. |
I have observed this in vscode, in particular. Let us say that we have a frozen dataclass in some user-specified module
In a notebook cell we have the following
Next we modify algorithm (or any code in that python file)
...and re-run the cell. I've been seeing two things: (1) the autoreload error as reported by @Techcable; and (2) the cell continues to run despite the error, with unpredictable behavior (i.e., code may or may not be changed, etc). Restarting the python interpreter results in the error disappearing and code running as expected for the first run. |
See Issue ipython#12411 and Issue ipython#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.
See Issue ipython#12411 and Issue ipython#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.
I think you can bypass the FrozenInstanceError by directly invoking object.__setattr__
The text was updated successfully, but these errors were encountered: