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
MonkeyType is not working in IPython #68
Comments
Hi, thanks for the report! Can you give repro steps for how MonkeyType previously worked usefully in an IPython notebook, that fails today? The reason we disabled tracing from |
The use cases are scattered at the moment, but I am hopeful that MonkeyType can be used to provide interactive type annotations why someone is developing interactively. The current prototype creates cell magics that use the MonkeyType profiler. The magics will either write the stubs to a file, show the stub in the next input, or show the retyped stub. I was validating this concept off of these tests. This code was working with version |
Cool, thanks! Yeah, I can see why this used to work and no longer does. I think it's reasonable for MonkeyType to not record traces from |
Hmm, it won't be quite that simple. The code filter API only gets the code object, not the frame (which may have been a design mistake); I don't think it's possible to tell from the code object alone whether the module name is
I guess I lean toward option 1? Otherwise I'd go for 3, but that seems like a lot of work unless we discover more use cases for giving code filters access to the frame. @mpage any preferences? |
I have no problem with lifting that filter. I put it in place mostly because I didn't think storing In recap, the problem I had (when I put in Maybe another option would be collect it but maybe gate it from being used by the tooling (for example, maybe hide it by default in
I actually think this is a very good idea and might be worth the breaking change. I can't speak for others, but it wouldn't break anything for me since the default filter is good enough for my use cases. |
Thanks for digging into this issue y'all Users of projects like python-fire, doit and luigi could get value from MonkeyType in the It would rad if In IPython, this configuration could be done as an IPython extension similar to the way the |
I realized there's a significant downside to passing the entire frame to code filters; it breaks the LRU cache we have on the default code filter, which makes a big perf difference. We see the same code object many times over, but every frame is different. So I guess I reluctantly lean towards option 2 (filter out |
I've been staring at
or as a
|
I think it'd be preferable to implement this filter in I don't see any rationale here for introducing a dataclass dependency. |
This commit moves the filtering logic for main modules to the CallTraceLoggerStore. All of the tests pass and this works in IPython.
The newer version of MonkeyType does not work in IPython. I think e8bb8a6 could be the reason.
An interactive session in IPython will
assert __name__ == '__main__'
it would still be meaningful to capture theCallTrace
so folks could interactively type their notebook/python source.I can totally understand if this falls outside the scope of the project.
The text was updated successfully, but these errors were encountered: