You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Code completion in the Editor doesn't work properly, unlike in the IPython console #2162
Same code in console work fine. I use Anaconda and last spyder version from bitbucket and run it like follow:
"python bootstrap.py --debug"
When I call completion for variable arr. or cap. I got next debug output:
completions request:
[]
completions request from jedi complete: "[]" in 0.1 sec
completions request from rope complete: "[]" in 0.2 sec
got timeout
Steven, do you think we can do something about this? I see two options here:
See if Jedi supports something like type hinting that can help us in this case.
I did a bit of research on the Canopy's architecture and noticed its Editor seems to do code completions using an IPython kernel in the background. Of course, the problem in this case is that code in the Editor can be syntactically incorrect, but given we can verify that by using pyflakes, it could be worth investigating this option.
Ah, I missed the numpy.array part. There is an open issue for that: davidhalter/jedi#372 .
As far as IPython goes, I don't think it makes sense, because you don't want your code executing behind your back. What if it is creating/deleting files or doing long-running operations?
Another idea then: does Jedi support a hooks concept for completions? I mean, if jedi knows an object's type (for example, that arr's is a numpy.array), we could add a hook to show completions for it, either by passing the completion widget a list (saved somewhere in our source code) of np.array's completions, or by evaluating this simple statement in an IPython kernel
import numpy as np
arr = np.array
then getting the list of completions the kernel returns for foo, and passing it to our widget.
Of course, the crucial point here is that Jedi could give us the type of an introspected object.
Carlos, we could back-track to the object definition, then load that in IPython, but there is a snag: np.array is a function, not a class. It also requires an object as its first parameter. We could special case for np.array since it it used so often...
d = jedi.Script('import numpy; a = numpy.array').definition()[0]
if d.name == 'array' and d.module_name == 'numpy.core.multiarray':
completions = [c for c in dir(np.array(1)) if c.startswith(completion_text)]
elif d.type == 'class':
mod = __import__(d.module_name)
cls = getattr(mod, d.name)
completions = [c for c in dir(cls) if c.startswith(completion_text)]
Yes, I was thinking exactly that. Could we make this mechanism extendable? I mean, we don't just need np.array, but also pyplot.figure, pd.groupby, and who knows how many others :-)
changed the title [-]Code completion in editor don't work properly, unlike the Python/IPython console[/-][+]Code completion in the Editor doesn't work properly, unlike in the IPython console[/+]on Mar 12, 2018
Hello I wanted to raise an issue on this, but I see it was raised and closed... It's the same issue that the editor doesn't provide any code completion unlike the IPython on the right...
I uninstalled kite, because it was bugging me with notifications... Was this closed because of kite?
Please forgive me, if I am in the wrong issue or if my question is trivially solved. I do not understand how I can activate default autocompletion of local project modules. Autocompletion works fine in the console, once a module is imported, but not in the editor. I found a workaround by using
import sys
sys.path.append('.')
Do I always need to append the local project folder with sys.path.append('.') in order to allow in the editor for autocompletion of local project folders and modules or can I do this in a better manner? Its surely not a biggie, but I wanted to know if there is a better built-in way.
Some of my system details:
Activity
spyder-bot commentedon Feb 17, 2015
From ccordoba12 on 2015-02-08T09:36:09Z
Steven, do you think we can do something about this? I see two options here:
Status: Accepted
Cc: [email protected]
Labels: Cat-Editor MS-v2.4
spyder-bot commentedon Feb 17, 2015
From ccordoba12 on 2015-02-08T09:43:05Z
issue #1816 has been merged into this issue.
spyder-bot commentedon Feb 17, 2015
From [email protected] on 2015-02-08T10:20:18Z
This is a really tough one, because it is a compiled module, the best I can suggest is to try docstring typehinting: http://jedi.jedidjah.ch/en/latest/docs/features.html#type-hinting .
spyder-bot commentedon Feb 17, 2015
From ccordoba12 on 2015-02-08T11:14:02Z
I see, but that wouldn't help for the code reported by the OP, would it?
And what do you think about option 2? Is it feasible?
spyder-bot commentedon Feb 17, 2015
From [email protected] on 2015-02-08T11:19:39Z
Ah, I missed the
numpy.arraypart. There is an open issue for that: davidhalter/jedi#372 .As far as IPython goes, I don't think it makes sense, because you don't want your code executing behind your back. What if it is creating/deleting files or doing long-running operations?
spyder-bot commentedon Feb 17, 2015
From ccordoba12 on 2015-02-08T11:52:28Z
Oh yeah! I missed that one, a crucial point.
Another idea then: does Jedi support a hooks concept for completions? I mean, if jedi knows an object's type (for example, that arr's is a numpy.array), we could add a hook to show completions for it, either by passing the completion widget a list (saved somewhere in our source code) of np.array's completions, or by evaluating this simple statement in an IPython kernel
then getting the list of completions the kernel returns for foo, and passing it to our widget.
Of course, the crucial point here is that Jedi could give us the type of an introspected object.
spyder-bot commentedon Feb 17, 2015
From ccordoba12 on 2015-02-08T12:12:12Z
Well, according to this SO answer http://stackoverflow.com/a/14710037/438386 Jedi does give completions for np.arrays, but it seems to have problems in virtualenvs. Steven, can you test it in your side?
spyder-bot commentedon Feb 17, 2015
From [email protected] on 2015-02-08T18:47:38Z
I tried the following from IPython (Anaconda Python 3.4) and got an empty list:
import jedi; jedi.Script('import numpy; a = numpy.array().m').completions()spyder-bot commentedon Feb 17, 2015
From [email protected] on 2015-02-09T08:10:11Z
Carlos, we could back-track to the object definition, then load that in IPython, but there is a snag:
np.arrayis a function, not a class. It also requires an object as its first parameter. We could special case fornp.arraysince it it used so often...spyder-bot commentedon Feb 17, 2015
From ccordoba12 on 2015-02-12T08:43:41Z
Yes, I was thinking exactly that. Could we make this mechanism extendable? I mean, we don't just need np.array, but also pyplot.figure, pd.groupby, and who knows how many others :-)
56 remaining items
[-]Code completion in editor don't work properly, unlike the Python/IPython console[/-][+]Code completion in the Editor doesn't work properly, unlike in the IPython console[/+]ccordoba12 commentedon Nov 27, 2019
This can't be closed yet because we could implement a new completion client that uses an IPython kernel behind the scenes.
kaleb-keny commentedon May 23, 2020
Hello I wanted to raise an issue on this, but I see it was raised and closed... It's the same issue that the editor doesn't provide any code completion unlike the IPython on the right...
I uninstalled kite, because it was bugging me with notifications... Was this closed because of kite?
ccordoba12 commentedon May 23, 2020
Please see my comment immediately above yours.
mauricio-fernandez-l commentedon Sep 15, 2020
Please forgive me, if I am in the wrong issue or if my question is trivially solved. I do not understand how I can activate default autocompletion of local project modules. Autocompletion works fine in the console, once a module is imported, but not in the editor. I found a workaround by using
Do I always need to append the local project folder with
sys.path.append('.')in order to allow in the editor for autocompletion of local project folders and modules or can I do this in a better manner? Its surely not a biggie, but I wanted to know if there is a better built-in way.Some of my system details: