python-sortedcontainers icon indicating copy to clipboard operation
python-sortedcontainers copied to clipboard

Debugpy plugin to display collection content as a list/dict/set

Open ondrudav opened this issue 1 year ago • 1 comments
trafficstars

Debugpy and by extension VSCode displays the values of variables using __repr__ when they are collapsed, but when expanded the internals of what should look like a list/dict/set are exposed:

image

The only way to fix this that I found is to write a pydevd extension. Unfortunately there's no standard paging mechanism (microsoft/debugpy#1179) so the variable resolvers do (list, tuple) and don't (dict, set) hand roll their own. I think copying the TupleResolver should be fine because everything is sorted and indexable.

ondrudav avatar Feb 29 '24 21:02 ondrudav

after spending an afternoon on this i think the extension mechanism is an after-afterthought, as seen by it being broken recently: microsoft/debugpy#1408 and microsoft/debugpy#1505, also the only viable place to put pydevd_plugins is in site-packages (odoo-ide/pydevd-odoo) - you can't play any tricks like patching sys.path when sortedcontainers is imported because pydevd only checks for plugins once before the program is started. i don't know if pip can handle aliased install directories but it's ugly either way.

and here i thought it'd just be like writing a bit of natvis (visual studio) or python (gdb) that gets embedded/referenced in the object file.

for now i've resorted to just casting the containers to their vanilla unsorted counterparts

ondrudav avatar Mar 02 '24 18:03 ondrudav