spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.34k stars 1.62k forks source link

Feature Request: Allow imported symbols in Outline Explorer to be collapsed #14302

Closed gb119 closed 1 year ago

gb119 commented 3 years ago

In 4.2.0 the Outline explorer shows classes that are imported from other modules - which I guess is ok, but it would be nice to be able to collapse the list of imported symbols e.g. by showing them under a virtual imports entry to allow one to focus on the classes and functions actually defined in the current file.

e.g. in the attached screen shot image

I'd like to see MarkSheet...BaseTable as sub-entries of some heading that I could collapse or expand.

dalthviz commented 3 years ago

Hi @gb119 thanks for the feedback! what do you think @spyder-ide/core-developers ?

CAM-Gerlach commented 3 years ago

Hmm, I'm not sure I see the same behavior in 4.2.0 on Windows (NSIS/pyinst install), testing on various files from the Spyder source tree, even with all options enabled and on files that import other classes (e.g. Mainwindow). I just see module-level constants and variables if I enabled that option, but I don't see one for imports, so I'm not sure exactly what the current UX is supposed to be, though this seems to sound like a good idea if I understand if correctly. @gb119 or @dalthviz do you have a snippet of minimal example code, and any options that need to be set, in order to demonstrate this behavior? Thanks!

andfoy commented 3 years ago

I think this is more an issue than a feature, it seems that there are other cases that we're not considering in the pyls to prevent Jedi from inspecting other modules' members

gb119 commented 3 years ago

Ok, I think this might actually be an issue not a feature request to change an intentional feature...

A.py

class Aa:
    pass

class Ab:
    pass

B.py

from .A import Ab

class Ba:
    pass

This shows Ab in the outline of B.py, but changing it from a relative import to an absolute import then doesn't show Ab. This is with the variables and attributes unticked in the outline settings.

ccordoba12 commented 3 years ago

Ok, it seems we're not catching relative imports in the Python Language Server (we're already discarding absolute imports returned as symbols by Jedi).

@andfoy, do you think that's possible?

andfoy commented 3 years ago

We need to inspect the symbols call in the pyls, hopefully we can track down this case

ccordoba12 commented 1 year ago

This is solved already, so closing.