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
PR: Add option to use Jedi in the IPython console + warning on greedy completer #6832
Conversation
Also updated GUI text of Greedy completion to warn about greedy completion bug.
Also updated GUI text of Greedy completion to warn about greedy completion bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! I found a number of elementary typos and errors in the text; please correct them. Also, overall, the total amount of text really needs to be cut down, and there's quite a bit of crazy and inconsistent formatting; I've provided a few suggestions to try to address both. Finally, can you add a simple test for this?
spyder/plugins/ipythonconsole.py
Outdated
@@ -477,15 +477,42 @@ def setup_page(self): | |||
run_file_group.setLayout(run_file_layout) | |||
|
|||
# ---- Advanced settings ---- | |||
# Enable Jedi completion in Ipyhton Console |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"IPython" is the correct spelling and capitalization, though ipython also works.
spyder/plugins/ipythonconsole.py
Outdated
@@ -477,15 +477,42 @@ def setup_page(self): | |||
run_file_group.setLayout(run_file_layout) | |||
|
|||
# ---- Advanced settings ---- | |||
# Enable Jedi completion in Ipyhton Console | |||
ipy_jedi_group = QGroupBox(_("Jedi completion in Ipython console")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IPython Console, to follow the above convention. Also, needs the article "the" in front of it. So:
"Jedi Completion in the IPython Console"
However, as this is a section title, for consistancy with the general style and with the others on the page, it should be shortened to:
"Jedi Completion"
or something similar, and in Title Case.
spyder/plugins/ipythonconsole.py
Outdated
@@ -477,15 +477,42 @@ def setup_page(self): | |||
run_file_group.setLayout(run_file_layout) | |||
|
|||
# ---- Advanced settings ---- | |||
# Enable Jedi completion in Ipyhton Console | |||
ipy_jedi_group = QGroupBox(_("Jedi completion in Ipython console")) | |||
ipy_jedi_label = QLabel(_("Enable Jedi based <tt>Tab</tt> completion in" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Jedi-based", also needs a space at the end.
spyder/plugins/ipythonconsole.py
Outdated
# Enable Jedi completion in Ipyhton Console | ||
ipy_jedi_group = QGroupBox(_("Jedi completion in Ipython console")) | ||
ipy_jedi_label = QLabel(_("Enable Jedi based <tt>Tab</tt> completion in" | ||
"the Ipython console. E.g. completion of" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"the IPython Console; works with e.g. nested lists, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternately, you can cut everything after the semicolon and instead add "similar to the greedy completer, but without evaluating the code." A little longer and more visually awkward than cutting the second line, but cleaner flow on the textual side.
spyder/plugins/ipythonconsole.py
Outdated
ipy_jedi_group = QGroupBox(_("Jedi completion in Ipython console")) | ||
ipy_jedi_label = QLabel(_("Enable Jedi based <tt>Tab</tt> completion in" | ||
"the Ipython console. E.g. completion of" | ||
"nested lits etc. This is similar to the " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd lean toward cutting this sentence, as it saves a full line, and including it in the popup tip instead; better IMO to put that extra descriptive text in the popup tip as its designed for then clutter the UI with every last detail.
spyder/plugins/ipythonconsole.py
Outdated
# Greedy completer group | ||
greedy_group = QGroupBox(_("Greedy completion")) | ||
greedy_group = QGroupBox(_("Greedy completion in Ipython console")) | ||
greedy_label = QLabel(_("Enable <tt>Tab</tt> completion on elements " | ||
"of lists, results of function calls, etc, " | ||
"<i>without</i> assigning them to a " | ||
"variable.<br>" | ||
"For example, you can get completions on " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're adding so much extra text, I'd recommend you simplify this to something like:
"Get completions on e.g. [...] and [...]"
spyder/plugins/ipythonconsole.py
Outdated
@@ -575,7 +602,7 @@ def setup_page(self): | |||
_("Graphics")) | |||
tabs.addTab(self.create_tab(run_lines_group, run_file_group), | |||
_("Startup")) | |||
tabs.addTab(self.create_tab(greedy_group, autocall_group, sympy_group, | |||
tabs.addTab(self.create_tab(ipy_jedi_group, greedy_group , autocall_group, sympy_group, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra space added after greedy_group
.
spyder/plugins/ipythonconsole.py
Outdated
greedy_label = QLabel(_("Enable <tt>Tab</tt> completion on elements " | ||
"of lists, results of function calls, etc, " | ||
"<i>without</i> assigning them to a " | ||
"variable.<br>" | ||
"For example, you can get completions on " | ||
"things like <tt>li[0].<Tab></tt> or " | ||
"<tt>ins.meth().<Tab></tt>")) | ||
"<tt>ins.meth().<Tab></tt> <br><br>" | ||
"<b>ATTENTION:<br> Ipython's Greedy completer has " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"IPython's greedy completer has "
Or better yet, rewrite the whole thing to read as follows:
"Due to a bug, IPython's greedy completer requires a leading space for some completions; e.g. np.sin(<Space>np.<Tab>)
works, while np.sin(np.<Tab>)
doesn't.
spyder/plugins/ipythonconsole.py
Outdated
"<b>ATTENTION:<br> Ipython's Greedy completer has " | ||
"a bug</b> that requires a leading " | ||
"<tt><Space></tt> " | ||
"for some completions to work. e.g. chane " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo; I presume you mean "change", and e.g. needs to be capitalized if starting a sentence, though I recommend rewriting it as above.
spyder/plugins/ipythonconsole.py
Outdated
"for some completions to work. e.g. chane " | ||
"<tt>np.sin(np.<Tab></tt> " | ||
"to <tt>np.sin(<Space>np.<Tab></tt> " | ||
", and completion for string filenames has " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything after the comma on this line is redundant, you used the same phrase above and it is directly implied by what you've stated. I know it relates to your specific problem, but including every possible case (and this is one few if any others have complained about) is an issue for the documentation IMO, not the UI.
…ompletion in the iypthon console. Also updated GUI text of Greedy completion to warn about greedy completion bug.
Hello @hofingermarkus! Thanks for updating the PR.
Comment last updated on March 27, 2018 at 07:51 Hours UTC |
…ompletion in the iypthon console. Also updated GUI text of Greedy completion to warn about greedy completion bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Now just fix the last few PEP8 issues, update the screenshot, and add a test for enabling/disabling and basic functionality of jedi
completion (spyder/plugins/tests/test_ipythonconsole.py
should give you some good examples of what to do) and you should be good, pending further @ccordoba12 feedback. Thanks!
Changes executed as requested. Thanks!
spyder/config/main.py
Outdated
@@ -158,6 +158,7 @@ | |||
'startup/use_run_file': False, | |||
'startup/run_file': '', | |||
'greedy_completer': False, | |||
'ipy_jedi_completer': False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change this to jedi_completer
. We already know that it's an IPython console option because it's in the right section.
spyder/plugins/ipythonconsole.py
Outdated
"when working with large dataframes!")) | ||
ipy_jedi_label.setWordWrap(True) | ||
ipy_jedi_box = newcb(_("Use Jedi completion in the IPython console"), | ||
"ipy_jedi_completer", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to jedi_completer
spyder/plugins/ipythonconsole.py
Outdated
@@ -477,20 +477,46 @@ def setup_page(self): | |||
run_file_group.setLayout(run_file_layout) | |||
|
|||
# ---- Advanced settings ---- | |||
# Enable Jedi completion in IPyhton Console | |||
ipy_jedi_group = QGroupBox(_("Jedi completion")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the ipy_
prefix from all variables in this section. Again, these are IPython confg options, so there's no need for that prefix.
spyder/utils/ipython/kernelspec.py
Outdated
@@ -124,6 +124,7 @@ def env(self): | |||
'SPY_RUN_FILE_O': CONF.get('ipython_console', 'startup/run_file'), | |||
'SPY_AUTOCALL_O': CONF.get('ipython_console', 'autocall'), | |||
'SPY_GREEDY_O': CONF.get('ipython_console', 'greedy_completer'), | |||
'SPY_IPY_JEDI_O': CONF.get('ipython_console', 'ipy_jedi_completer'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, remove IPY_
and ipy_
here.
spyder/utils/ipython/start_kernel.py
Outdated
@@ -69,10 +69,12 @@ def kernel_config(): | |||
# Until we implement Issue 1052 | |||
spy_cfg.InteractiveShell.xmode = 'Plain' | |||
|
|||
# Jedi completer in IPpthon console | |||
ipy_jedi_o = os.environ.get('SPY_IPY_JEDI_O') == 'True' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove ipy_
and IPY_
also here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, except for some minor formatting issues.
spyder/utils/ipython/start_kernel.py
Outdated
@@ -69,10 +69,12 @@ def kernel_config(): | |||
# Until we implement Issue 1052 | |||
spy_cfg.InteractiveShell.xmode = 'Plain' | |||
|
|||
# Jedi completer in IPpthon console |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove here in IPpthon console
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still missing. Please address it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Updated according to change requests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @hofingermarkus! Great work here!
This adds an option for Jedi Code completion in the ipython shell.
It also adds a warning text for the Greedy completer, to inform users, that the current version of the Greedy completer in ipython needs an extra space to split commands.
Related Spyder-ide issues: #6803 #6700
Related Ipython Console Issues:
https://github.com/ipython/ipython/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+greedy+completer