-
Notifications
You must be signed in to change notification settings - Fork 24
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
FR: Make plum work with ipython's autoreload #38
Comments
This is a good suggestion! I unfortunately currently do not have the bandwidth to investigate this in the short term, but will definitely keep it in mind. |
Also tagging @seeM here. This issue is unfortunately a tricky one to fix. Just to document what's going wrong, here's a minimal example. Consider the minimal module from __future__ import annotations
class A:
def test(self) -> A:
# Hello
return self We now have the following behaviour: In [1]: from core import A
In [2]: from typing import get_type_hints
In [3]: get_type_hints(A.test)["return"] == A
Out[3]: True
In [4]: # Make changes and trigger autoreload
In [5]: get_type_hints(A.test)["return"] == A
Out[5]: False (This is on Python 3.9.) I think it's necessary to carefully pin down how If this particular case can be fixed, I think good support for |
I had investigated the issue a bit, and eventually realized that the best course of action would be for someone to contact the developers of iPython to ask them to add an hook to auto reload so that when he reloads a class/files plugins can ask to be notified about it. |
@PhilipVinc That's interesting. I suppose hooking into autoreload would be the way go about this: upon every autoreload, clear all cache. I'm wondering, is the above example expected behaviour? Should Perhaps not relevant to this issue, but I'm tempted to strip out all current functionality to handle forward references from the package and just rely on |
Experimental support thanks to #44 by @PhilipVinc is included in the latest release |
The two don't work well together.
I think it's because autoreload changes the classes of objects, but for some reason forgets to update the Types in plum's dispatch tables.
Should be investigated...
The text was updated successfully, but these errors were encountered: