Plugins (and persistent Watch expressions) #660
Kevin-Prichard
started this conversation in
Ideas
Replies: 1 comment 6 replies
-
Thanks for all the thought you put into this. Compared to the discussion in #150, I'm more sympathetic to saving watch expressions out of the box. I think some of that code can probably be dusted off, but I still don't like the aspect that |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
pudb has become a regular part of my Python development cycle, and I use it daily. Great, lightweight package that complements Python so well.
There are, however, a few small features things I'd like to add. Number one would be persistent Watch expressions. I'm sure we've all been there, debugging a tough problem with countless restarts of the program, and you gotta add those Watch expressions each time.
For that, @mnieber provided an automation recipe, via AutoKey, in #583 (comment). In that discussion, @inducer brings up the question "How can we better support user-driven automation? ("plugins"?) Should we?"
I'm here to respond to that. Yeah, there are a few choices:
Here are some thoughts that occurred when reading @inducer's response to that thread.
Clicking on things like instance properties would be cool, though they'd need to be made visible somewhere in pudb's UI. While it would save some keystrokes over having to manually type in the reference, it is still limited by repetition.
I found this discussion topic because I wanted a way to persist Watch expressions across python/pudb sessions. Having to add them over and over gets tedious, of course. My thought process started like this- "But, wait- something similar is done for Breakpoints, right? Those are automatically persisted across sessions, loaded from filenames stored in saved-breakpoints-. and breakpoints-.. So, how could I do that for Watch expressions?"
One idea
What are appropriate ways to provide access to pudb resources?
What could this look like?
One challenge for supporting something like this is that much of DebuggerUI's interactivity is essentially a private module defined inside of DebuggerUI.init(). For those data structures and functions to become available, they would need to be hoisted out and become either part of DebuggerUI's attributes, or perhaps another class that is a friend and collaborator (in the C++ sense, of shared access to structures and methods.) I would experiment with just hoisting them to DebuggerUI and then making private/protected those which aren't meant to be directly accessed by external code. However, that is what a proxy class such as PluginContext would do, provide access to those features that are useful to plugin developers.
If the skeleton class outlines I provided above seem incomplete, it is because I have not fully familiarized myself with all aspects of pudb's code, so the full set of features and insertion points that could be provided to PluginBase and PluginContext has yet to occur to me.
Having thought about this, for now I'll probably just modify pudb to provide Watch expression persistence, and maybe submit a PR when I'm happy with it. A big refactor of pudb's internal structure would impact its simplicity, and I don't see many requests or discussion for adding plugins.
UPDATE: I see that @lechat submitted a pull to persist Watch expressions... eight years ago, but it wasn't accepted. I'll see what can be learned from that pull, perhaps worthwhile to catch it up with inducer:main and hopefully get this seemingly useful feature accepted.
Beta Was this translation helpful? Give feedback.
All reactions