Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable Explorer display of pathlib.Path not very helpful #12683

Closed
gb119 opened this issue May 10, 2020 · 5 comments
Closed

Variable Explorer display of pathlib.Path not very helpful #12683

gb119 opened this issue May 10, 2020 · 5 comments

Comments

@gb119
Copy link

gb119 commented May 10, 2020

Description

What steps will reproduce the problem?

Create a variable that is a pathlib.Path e.g.

import pathlib
pth = pathlib.Path.cwd()

Observe that the entry for pth in the Variable Explorer doesn't in fact readily give you much infromation about the path!

repr(pth) would be more useful.

Versions

  • Spyder version: 4.1.3
  • Python version: 3.7.7
  • Qt version: 5.9.6
  • PyQt5 version: 5.9.2
  • Operating System: Windows 10

Dependencies


# Mandatory:
atomicwrites >=1.2.0           :  1.3.0 (OK)
chardet >=2.0.0                :  3.0.4 (OK)
cloudpickle >=0.5.0            :  1.3.0 (OK)
diff_match_patch >=20181111    :  20181111 (OK)
intervaltree                   :  None (OK)
IPython >=4.0                  :  7.13.0 (OK)
jedi =0.15.2                   :  0.15.2 (OK)
nbconvert >=4.0                :  5.6.1 (OK)
numpydoc >=0.6.0               :  0.9.2 (OK)
paramiko >=2.4.0               :  2.7.1 (OK)
parso =0.5.2                   :  0.5.2 (OK)
pexpect >=4.4.0                :  4.8.0 (OK)
pickleshare >=0.4              :  0.7.5 (OK)
psutil >=5.3                   :  5.7.0 (OK)
pygments >=2.0                 :  2.6.1 (OK)
pylint >=0.25                  :  2.4.4 (OK)
pyls >=0.31.9;<0.32.0          :  0.31.9 (OK)
qdarkstyle >=2.8               :  2.8 (OK)
qtawesome >=0.5.7              :  0.7.0 (OK)
qtconsole >=4.6.0              :  4.7.2 (OK)
qtpy >=1.5.0                   :  1.9.0 (OK)
rtree >=0.8.3                  :  0.9.3 (OK)
sphinx >=0.6.6                 :  2.4.4 (OK)
spyder_kernels >=1.9.1;<1.10.0 :  1.9.1 (OK)
watchdog                       :  None (OK)
zmq >=17                       :  18.1.1 (OK)

# Optional:
cython >=0.21                  :  0.29.15 (OK)
matplotlib >=2.0.0             :  3.1.3 (OK)
numpy >=1.7                    :  1.18.1 (OK)
pandas >=0.13.1                :  1.0.3 (OK)
scipy >=0.17.0                 :  1.3.2 (OK)
sympy >=0.7.3                  :  1.4 (OK)
@goanpeca
Copy link
Member

goanpeca commented May 10, 2020

Hi @gb119, thanks for your suggestion. Indeed the value displayed is not very helpful at first glance, clicking on it however does provide more information.

Screen Shot 2020-05-10 at 17 37 01


@spyder-ide/core-developers do you think we should have:

1.) some curated list of default objects and methods to use for the value on the Collections Editor of the Variable Explorer

object_value_method = {
    'pathlib.PosixPath': '__repr__',
}

This will of course keep growing in time but could provide better results for the value object.

2.) Or would it make sense to always use the repr() of objects for which we do not have a buitlin editor?

Thanks

@jitseniesen
Copy link
Member

some curated list of default objects and methods to use for the value on the Collections Editor

Sounds good, with (further down the line) the possibility for users to add to it. Actually, I think that for many types we can just use str or repr.

Or would it make sense to always use the repr() of objects for which we do not have a buitlin editor?

I seem to remember that there were problems with this because the string representation can be extremely long.

@gb119
Copy link
Author

gb119 commented May 11, 2020

You could make it an option on the variable explorer to use an object's repr() for all unknown object types - leave it off for the current behaviour, on for to have a read-only truncated display of the objects repr.
Longer term, it would be nice if I could provide some class or functions that I could register with the variable explorer so that my own objects could have an editor or nice representation - some sort of decorator that I could apply to a 'repr_spyder' function like I can for rich display on Jupyter...

@jitseniesen
Copy link
Member

Issues #6338 and #7092 are about the wider than just pathlib.Path so we should probably consolidate the discussion in one location.

@goanpeca
Copy link
Member

Fair enough @jitseniesen , closing in favor of those issues. Please follow the progress there @gb119

Cheers!

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

No branches or pull requests

3 participants