Spyder: Strange autocomplete bugs on Ubuntu, depending on space before variable

Created on 9 Mar 2018  路  17Comments  路  Source: spyder-ide/spyder

Problem Description

This is a strange behavior that I only experience under Ubuntu:
Autocompletion very often doesn't work if I do not have a space between the function and the next variable i put into it "function(var1." . Sometimes it seems as this is also the case for variables that follow a comma e.g. "var1,var2. Also from time to time it seems as if the home key is broken in a sense that it doesn't jump before the 1st but before the 2nd character. This could be something else or these two bugs could be related...
I've encountered this behavior now on different machines, and different anaconda setups independently.

What steps will reproduce the problem?

The following doesn't bring up the tab completion on Ubuntu, but it works without any problem on Windows.

import numpy as np
a = np.array([1,2,3])
np.exp(a.<NoTabCompletionHere>

Btw. adding an extra space before the variable name will show up the tab completion correctly:

import numpy as np
a = np.array([1,2,3])
np.exp(<Space>a.<TabCompletionWorksAgain>

Version and main components

  • Spyder Version: 3.2.6 (it seems to be a bug that exists for many months & versions by now.)
  • Python Version: 3.5.4
  • Qt Versions: 5.6.2, PyQt5 5.6 on Linux

Dependencies

pyflakes >=0.6.0 :  1.6.0 (OK)
pycodestyle >=2.3:  2.3.1 (OK)
pygments >=2.0   :  2.2.0 (OK)
pandas >=0.13.1  :  0.21.1 (OK)
numpy >=1.7      :  1.14.1 (OK)
sphinx >=0.6.6   :  1.7.1 (OK)
rope >=0.9.4     :  0.10.7 (OK)
jedi >=0.9.0     :  0.11.1 (OK)
psutil >=0.3     :  5.4.3 (OK)
nbconvert >=4.0  :  5.3.1 (OK)
sympy >=0.7.3    :  1.1.1 (OK)
cython >=0.21    :  None (NOK)
qtconsole >=4.2.0:  4.3.1 (OK)
IPython >=4.0    :  6.2.1 (OK)
pylint >=0.25    :  1.8.2 (OK)

Code Completion Ux-usability Enhancement

All 17 comments

Unfortunately, I can't reproduce this in the editor on the latest anaconda on Ubuntu 16.04.

peek 2018-03-09 15-17

Spyder version: 3.2.7 (works on master as well)

Python Version: 3.6.4

IPython >=4.0 : 6.2.1 (OK)
cython >=0.21 : 0.27.3 (OK)
jedi >=0.9.0 : 0.11.1 (OK)
nbconvert >=4.0 : 5.3.1 (OK)
numpy >=1.7 : 1.14.1 (OK)
pandas >=0.13.1 : 0.22.0 (OK)
psutil >=0.3 : 5.4.3 (OK)
pycodestyle >=2.3: 2.3.1 (OK)
pyflakes >=0.6.0 : 1.6.0 (OK)
pygments >=2.0 : 2.2.0 (OK)
pylint >=0.25 : 1.8.2 (OK)
qtconsole >=4.2.0: 4.3.1 (OK)
rope >=0.9.4 : 0.10.7 (OK)
sphinx >=0.6.6 : 1.7.1 (OK)
sympy >=0.7.3 : 1.1.1 (OK)

Thanks for reporting @hofingermarkus . Can you try with Spyder 3.2.7 and a more modern Python version and see if the bug still occurs?

@csabella, what about you?

Inconclusive. When I first tried it, autocompletion did not work, just as @hofingermarkus said. So, I closed Spyder, reopened it in debug mode, and then autocompletion worked fine! I have not had it 'not work' since, but I definitely saw the issue where np. was returning completions and a. was not. One caveat though - when it wasn't working, even the space before the a didn't help me.

I plan on trying this every so often to see if I can detect a pattern.

Thanks Cheryl! Let us know if/when you find a reproducible use case.

Ok, luckily I already have various anaconda environments (Ubuntu 16.04) and updating spyder is fast...
I did my tests in spyders IPython Console (not the editor) and always get the same error.
No space => not Tabcompletion
without space no tab completion
Extra space => Tabcompletion works
with space tabcompletion

Tested and reproduced with:
Spyder 3.2.6 Python 3.5.4
Spyder 3.2.7 Python 3.5.4
Spyder 3.2.7 Python 3.6.4 Qt 5.6.2 PyQt5 5.6 Ipython 6.2.1
Spyder 3.2.6 Python 3.6.4 Qt 5.6.2 PyQt5 5.6 Ipython 6.2.1

I also tried it directly in the iPython console without spyder => there it works:
image

I did my tests in spyders IPython Console (not the editor) and always get the same error

When I was able to recreate the issue, the IPython console within Spyder worked fine. I had tested both just to make sure. Many reports say that the Spyder editor isn't consistent with the Spyder IPython console, so I sort of expected it to work in the console and not the editor and didn't really pursue that further.

I can reproduce this in the spyder ipthon console, but not in the jupyter-qtconsole

spyder qtconsole

spyder qtconsole

jupyter qtconsole

qtconsole

The fuction tip is also a lot more usefull

I think I found it! It's a bug in the Greedy Completer - once it is turned on, the problems start!

How to reproduce:

  • Reset Spyder Settings by removing the folder containing the settings files
  • Start Spyder
    => Test filename completion (works)
  • Activate Greedy Compiler in the settings: (preferences->Ipyhton console -> Advanced Settings -> greedy completer
  • Restart Ipython Console
  • Check again
    => Filename completion is now broken (needs extra space), also triggers bug #6803

bugingreedycompleter

Thanks for finding the cause of this problem! Then this is a bug in IPython and not in Spyder. Unfortunately, the greedy completer is slated to be removed in a future IPython version, so they probably won't want to fix it.

Ok - muchas gracias por su attenci贸n y la informaci贸n!

I am now able to reproduce part of the behavior in Ipython and the Qt console.
However, Spyders Ipython Console still behaves different on some occasions...

1) I always get code completion for the array example in Ipython but not in Spyder (there it depends on the greedy completer setting).
spyder_bug_annotated

2) If the Greedy completer is turned OFF, I do get code completion for nested lists etc. in the Ipython and Qt shell - but I do not get any completion inside Spyders Shell.
spyderbug2_annotated

spyderbug3

So it seems as spyder is loosing some autocomplete information
Do you have an idea where this completion information could be lost?
(because if it wouldn't be lost - the greedy completer would not be necessary...)

Latest IPython versions use Jedi to get completions like the one you posted above, but we had to deactivate that feature because it was making our console too slow when trying to get completions for large dataframes.

OK,
Maybe a "quickfix" could be to inform the users in the settings dialog.
1.) Update the Textmessage from the Greedy Completer with a passage to warn about the Ipython Bug, and that an extra space helps.
2.) Provide an option to activate Jedi in the Console, but also with a warning that this can slow down code completion for large dataframes.

Please send us a PR against the 3.x branch for this. I don't think we'll have time to work on it right now.

Ok, I'll see If I find time this weekend...

Thanks @hofingermarkus !

This was solved by PR #6832, but never referenced in a milestone.

Was this page helpful?
0 / 5 - 0 ratings