Closed cknd closed 2 years ago
I'm working on a library of the kind that was discussed in better-exceptions and IPython and planning on using it here. It's entirely AST based and satisfies these requirements. It uses https://github.com/gristlabs/asttokens for the second point and https://github.com/alexmojaki/executing for some extra functionality.
sounds very promising!
If you're interested in a sneak peek or following progress, I've just created the repo here: https://github.com/alexmojaki/stack_data
Still lots of work to do though.
👀
the solution is #52
Currently, to find out where in the code which variable names occur, I traverse the code token-by-token and apply a sort of ad hoc stack machine that detects stuff like the beginning of function definitions, dot attributes etc. This is clearly nuts, and purely a path effect (= it's how ipython's ultratb does it, and then my scope expanded and here we are). https://github.com/cknd/stackprinter/blob/master/stackprinter/source_inspection.py
This approach works for now, but it has hit its limits. For example, I'd like to ignore the left-hand side of named arguments in function calls.
Goals: