spyder-ide / spyder

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

Hint and autocomplete displays help for wrong parameter #10266

Open rlabbe opened 5 years ago

rlabbe commented 5 years ago

Description

What steps will reproduce the problem?

Enter the following code into an empty editor

class Foo:
    """my documentation here"""

    def __init__(self):
        """doc2"""
        pass

class Bar:
    """I'm a bar"""
    pass

def nada(foo: Foo, x: Bar, y: Bar):
    """ nada thingy """
    pass

def a(foo: Foo):
    nada(foo, t

Now with the cursor at the t at the very end, type a period. This pops up a hint balloon, but it displays the help for the class Foo, "my documentation here". The autocomplete window displays the choices foo, x, and y - the parameter names of nada. It doesn't make any sense to complete t. with, for example, t.foo or t.x, but these are the options provided to me.

This is a super simplified example of what I'm seeing regularly. I'm passing variables in in the form var.attribute, and when I type the period it shows me the documentation for the first variable in the parameter list, and the autocomplete list is well, long and not related to the parameter I am trying to enter.

This is the simplest failure case that I can generate based on my real code base.

Versions

Dependencies

cloudpickle >=0.5.0          :  1.2.1 (OK)
pygments >=2.0               :  2.4.2 (OK)
qtconsole >=4.5.5            :  4.5.5 (OK)
nbconvert >=4.0              :  5.5.0 (OK)
sphinx >=0.6.6               :  2.1.2 (OK)
pylint >=0.25                :  2.3.1 (OK)
psutil >=0.3                 :  5.6.3 (OK)
qtawesome >=0.5.7            :  0.5.7 (OK)
qtpy >=1.5.0                 :  1.9.0 (OK)
pickleshare >=0.4            :  0.7.5 (OK)
zmq >=17                     :  18.1.0 (OK)
chardet >=2.0.0              :  3.0.4 (OK)
numpydoc >=0.6.0             :  0.9.1 (OK)
spyder_kernels >=1.5.0;<2.0.0:  1.5.0 (OK)
qdarkstyle >=2.7             :  2.7 (OK)
atomicwrites >=1.2.0         :  1.3.0 (OK)
diff_match_patch >=20181111  :  20181111 (OK)
watchdog                     :  None (OK)
keyring                      :  None (OK)
pexpect >=4.4.0              :  4.7.0 (OK)
pympler                      :  None (OK)
sympy >=0.7.3                :  1.4 (OK)
cython >=0.21                :  0.29.13 (OK)
IPython >=4.0                :  7.8.0 (OK)
matplotlib >=2.0.0           :  3.1.1 (OK)
pandas >=0.13.1              :  0.25.1 (OK)
numpy >=1.7                  :  1.16.4 (OK)
scipy >=0.17.0               :  1.3.1 (OK)
pyls >=0.28.2;<0.29.0        :  0.28.2 (OK)
rtree >=0.8.3                :  0.8.3 (OK)
ccordoba12 commented 5 years ago

Thanks for reporting. I can reproduce this problem but it's not something we can solve here but in Jedi, which is the underlining library that provides code completions for us (I verified that that's the case by passing your code directly to Jedi).