Repository navigation
Skip instance updates when an autoreload class is unchanged - #15423
Open
Cherith1222 wants to merge 1 commit into
Open
Cherith1222 wants to merge 1 commit into
Cherith1222 wants to merge 1 commit into
Conversation
Reloading a module that imported functools.partial called update_instances on the same type and raised TypeError. A class that was actually replaced still migrates its instances. AI-assisted (Cursor). Not yet reviewed by a human.
Carreau
force-pushed
the
fix/14984-autoreload-partial
branch
from
October 21, 2026 12:14
f31b593 to
be9b09b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14984.
%autoreloadcalledupdate_instanceson an imported type such asfunctools.partialeven when the reload left that type as the same object. Those instances reject__class__assignment, so the reload raisedTypeErrorand stopped. If the old and new class objects are identical, instance migration is now skipped. A class that was actually replaced still has its instances moved.This is a bug fix, not a new feature or a backwards-incompatible change, so there is no file under
docs/source/whatsnew/pr/.Tests, on Windows with Python 3.13.3, via Resource Sentinel (1 CPU, 1.5 GiB, 1 I/O):
IPython/extensions/autoreload.pychecked out atmain,test_update_instances_skips_unchanged_imported_typefailed withTypeError: __class__ assignment only supported for mutable types or ModuleType subclasses.ruff checkstill reports four existingF541findings intests/test_zzz_autoreload.py(lines 475, 477, 506, and 533). They are not in this diff and were left as they are.ruff formatalso wants to reflow other existing lines in those two files. The lines added here were not part of that.Not run: the full suite, and anything other than Windows.
This patch was drafted with AI assistance (Cursor).