Skip to content

Programming the Debug Console's rendering of user data #825

Closed

Description

@yoni-lavi

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.

image

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

  1. fabioz commented on Jan 24, 2022

    @fabioz
    Collaborator

    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 ;)

  2. fabioz commented on Jan 27, 2022

    @fabioz
    Collaborator

    Closing since there is a way to do it.

    yoni-lavi please let me know if you have any issues using that...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions