You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Programming the Debug Console's rendering of user data #825
If this feature already exists, I was unable to find it (either the feature itself, or the request for one, or any discussion of it whatsoever):
Here's a couple of examples for things I'd like the data visualizer to do:
(1) It seems to have the ability to browse items inside iterables and mappings, but it seems to work on certain types, but not others.
What I would expect is that any Python object that implements a Mapping protocol will be viewed as one, then otherwise if it's Iterable it will be viewed as one.
But as you can see, list, dict and defaultdict render their items as expected, whereas MappingProxyType, dict_keys and dict_values (or zip for that matter) don't.
Is there a way to program VS code's debugger to make it recognize additional types?
(2) Suppose I want it to use the human-readable __str__ instead of __repr__ for inspected values, could I do that?
Activity
fabioz commentedon Jan 24, 2022
It is possible to customize as needed for custom types.
There's some basic documentation in https://github.com/microsoft/debugpy/blob/main/src/debugpy/_vendored/pydevd/pydevd_plugins/extensions/README.md
and you can use as an example the customizations for numpy/django/pandas in:
https://github.com/microsoft/debugpy/tree/main/src/debugpy/_vendored/pydevd/pydevd_plugins/extensions/types
Now, if it's for something basic (such as defaultdict), an option could be creating it at:
https://github.com/microsoft/debugpy/blob/main/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_resolver.py
and adding it to the list of default resolvers in:
https://github.com/microsoft/debugpy/blob/main/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_xml.py#L38
and providing a pull request ;)
fabioz commentedon Jan 27, 2022
Closing since there is a way to do it.
yoni-lavi please let me know if you have any issues using that...