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

Class / function import as ALIAS leads to incomplete display of the docstring #16464

Open
7 of 10 tasks
wtorsten opened this issue Sep 21, 2021 · 1 comment
Open
7 of 10 tasks

Comments

@wtorsten
Copy link

wtorsten commented Sep 21, 2021

Issue Report Checklist

  • Searched the issues page for similar reports
  • Read the relevant sections of the Spyder Troubleshooting Guide and followed its advice
  • Reproduced the issue after updating with conda update spyder (or pip, if not using Anaconda)
  • Could not reproduce inside jupyter qtconsole (if console-related)
  • Tried basic troubleshooting (if a bug/error)
    • Restarted Spyder
    • Reset preferences with spyder --reset
    • Reinstalled the latest version of Anaconda
    • Tried the other applicable steps from the Troubleshooting Guide
  • Completed the Problem Description, Steps to Reproduce and Version sections below

Problem Description

The tooltip and help pane do not show any interface information for ALIAS NAMES of imported classes.

>>> from MODULE import CLASS as ALIAS

If the original name of the class is used, the interface description is available.
This also applies to all initialized objects.

If these were initiated with the original name,

>>> a = CLASS()

then the tooltip and help pane are complete.

However, if the object was initiated with the ALIAS,

>>> a = ALIAS()

then the interface description is missing.

To make it even crazier:

If the docstring is removed from ClassA, then the script shows no tooltip and no HELP pane vor CLASS. At least the interface description should be displayed.
But ALIAS still shows the old docstring (w/o interface information), although this no longer exists.

If the docstring of class ClassA is activated again and changed, the previous behavior becomes apparent again .. with the changes made in the docstring.

And if the docstring in class ClassA is removed again, the tooltip and HELP pane in CLASS are again empty (correct).
But ALIAS shows the old/first version of docstring from ClassA.

Accordingly, not only is information about classes and functions missing, but incorrect information can also be displayed.

In a repository with SUB-MODULES and several developers ... fatal.

What steps reproduce the problem?

modul.py

class ClassA:
    """
    ClassA
    
    :param a1:
        Argument 1
    :type a1:
        :class:`int`
    """

    def __init__(self, a1: int):
        """initialization"""
        pass

script.py

from test_module import ClassA as MyClassA

screenshot: tooltip and HELP Pane of CLASS

import_class_opt2

screenshot: tooltip and HELP Pane of ALIAS

import_class_as_opt2

What is the expected output? What do you see instead?

expected 1
The tooltip and the HELP pane show the same information for CLASS and ALIAS.

instead 1
The tooltip and the HELP pane for ALIAS do not show any interface information.

expected 2
If docstring of CLASS is removed, tooltip and HELP pane of CLASS and ALIAS showing interface description only.

instead 2
tooltip and HELP pane of CLASS is not shown... not even the interface description
tooltip and HELP pane of ALIAS is still showing the old docstring

expected 3
If docstring of CLASS is activated again and changed, tooltip and HELP pane of CLASS and ALIAS should show the same (except that the interface information is missing -> based on instead 1).

instead 3
as expected based on instead 1

expected 4
If docstring of CLASS is removed again, tooltip and HELP pane of ALIAS must still show the changed docstring (based on instead 2)

instead 4
tooltip and HELP pane of ALIAS shows the initial (un-changed) information.

Paste Traceback/Error Below (if applicable)

n/a

Versions

  • Spyder version: 4.2.5

  • Python version: 3.7.10 64-bit | Qt 5.12.10 | PyQt5 5.12.3 | Windows 10

  • Qt version: 5.12.10

  • PyQt version: 5.12.3

  • Operating System name/version: Windows 10

Dependencies


# Mandatory:
atomicwrites >=1.2.0            :  1.4.0 (OK)
chardet >=2.0.0                 :  4.0.0 (OK)
cloudpickle >=0.5.0             :  1.6.0 (OK)
diff_match_patch >=20181111     :  20200713 (OK)
intervaltree >=3.0.2            :  3.1.0 (OK)
IPython >=7.6.0                 :  7.22.0 (OK)
jedi =0.17.2                    :  0.17.2 (OK)
jsonschema >=3.2.0              :  3.2.0 (OK)
keyring >=17.0.0                :  23.0.1 (OK)
nbconvert >=4.0                 :  6.0.7 (OK)
numpydoc >=0.6.0                :  1.1.0 (OK)
paramiko >=2.4.0                :  2.7.2 (OK)
parso =0.7.0                    :  0.7.0 (OK)
pexpect >=4.4.0                 :  4.8.0 (OK)
pickleshare >=0.4               :  0.7.5 (OK)
psutil >=5.3                    :  5.8.0 (OK)
pygments >=2.0                  :  2.9.0 (OK)
pylint >=1.0                    :  2.7.4 (OK)
pyls >=0.36.2;<1.0.0            :  0.36.2 (OK)
pyls_black >=0.4.6              :  0.4.6 (OK)
pyls_spyder >=0.3.2             :  0.3.2 (OK)
qdarkstyle >=2.8;<3.0           :  2.8.1 (OK)
qtawesome >=0.5.7               :  1.0.2 (OK)
qtconsole >=5.0.3               :  5.0.3 (OK)
qtpy >=1.5.0                    :  1.9.0 (OK)
rtree >=0.8.3                   :  0.9.7 (OK)
setuptools >=39.0.0             :  54.0.0 (OK)
sphinx >=0.6.6                  :  4.0.1 (OK)
spyder_kernels >=1.10.2;<1.11.0 :  1.10.2 (OK)
textdistance >=4.2.0            :  4.2.1 (OK)
three_merge >=0.1.1             :  0.1.1 (OK)
watchdog >=0.10.3;<2.0.0        :  1.0.2 (OK)
zmq >=17                        :  20.0.0 (OK)

# Optional:
cython >=0.21                   :  None (NOK)
matplotlib >=2.0.0              :  None (NOK)
numpy >=1.7                     :  1.20.1 (OK)
pandas >=1.1.1                  :  1.2.5 (OK)
scipy >=0.17.0                  :  None (NOK)
sympy >=0.7.3                   :  None (NOK)

# Spyder plugins:
spyder_unittest                 :  0.4.1 (OK)

@dalthviz
Copy link
Member

Hi there, sorry for such a late response! Checking the scenarios/cases with 6.0.4 from the Windows installer:

expected 1
The tooltip and the HELP pane show the same information for CLASS and ALIAS.

instead 1
The tooltip and the HELP pane for ALIAS do not show any interface information.

I was able to reproduce it:

Image

expected 2
If docstring of CLASS is removed, tooltip and HELP pane of CLASS and ALIAS showing interface description only.

instead 2
tooltip and HELP pane of CLASS is not shown... not even the interface description
tooltip and HELP pane of ALIAS is still showing the old docstring

Partially reproduced (Help pane shows CLASS signature correctly but there is no tooltip for CLASS or ALIAS and ALIAS inspection doesn't bring up anything):

Image

expected 3
If docstring of CLASS is activated again and changed, tooltip and HELP pane of CLASS and ALIAS should show the same (except that the interface information is missing -> based on instead 1).

instead 3
as expected based on instead 1

Same behavior as with scenario/case 1:

Image

expected 4
If docstring of CLASS is removed again, tooltip and HELP pane of ALIAS must still show the changed docstring (based on instead 2)

instead 4
tooltip and HELP pane of ALIAS shows the initial (un-changed) information.

Same behavior as with scenario/case 2:

Image

From my testing then seems like the current behavior (Spyder 6.0.4) is that ALIAS only shows the docstring of CLASS and when CLASS doesn't have a docstring no tooltip is generated (for CLASS or ALIAS) and ALIAS inspection doesn't return anything

Anyhow, maybe this is some sort of jedi/python-lsp-server limitation @ccordoba12 ? I'm not totally sure if there is something that can be done over Spyder 🤔

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

2 participants