Bug 252875 - devel/ipython: completion still broken after 7.19.0_2
Summary: devel/ipython: completion still broken after 7.19.0_2
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Ruslan Makhmatkhanov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-21 05:38 UTC by rsmith
Modified: 2021-02-01 13:47 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (python)


Attachments
Add missing imports to ptutils.py. (287 bytes, patch)
2021-01-21 05:38 UTC, rsmith
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description rsmith 2021-01-21 05:38:38 UTC
Created attachment 221777 [details]
Add missing imports to ptutils.py.

The patch to 7.19.0_2 exposed some other problems:

  File "/usr/local/lib/python3.9/site-packages/prompt_toolkit/completion/base.py", line 196, in get_completions_async
    for item in self.get_completions(document, complete_event):
  File "/usr/local/lib/python3.9/site-packages/IPython/terminal/ptutils.py", line 116, in get_completions
    exc_type, exc_value, exc_tb = sys.exc_info()
NameError: name 'sys' is not defined

It turns out that ptutils.py needs two additional imports:

   import sys
   import traceback

(see attached patch)

This however exposes another bug:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/IPython/terminal/ptutils.py", line 115, in get_completions
    yield from self._get_completions(body, offset, cursor_position, self.ipy_completer)
  File "/usr/local/lib/python3.9/site-packages/IPython/terminal/ptutils.py", line 131, in _get_completions
    for c in completions:
  File "/usr/local/lib/python3.9/site-packages/IPython/core/completer.py", line 438, in _deduplicate_completions
    completions = list(completions)
  File "/usr/local/lib/python3.9/site-packages/IPython/core/completer.py", line 1817, in completions
    for c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000):
  File "/usr/local/lib/python3.9/site-packages/IPython/core/completer.py", line 1874, in _completions
    signature = _make_signature(jm)
  File "/usr/local/lib/python3.9/site-packages/IPython/core/completer.py", line 991, in _make_signature
    return '(%s)'% ', '.join([f for f in (_formatparamchildren(p) for p in completion.params) if f])
AttributeError: 'Completion' object has no attribute 'params'

Looking at the differences between completer.py in this version and the one on github HEAD, they are significant.

It seems to me that until a new version of IPython is released, py-parso and py-jedi should be rolled back as proposed in #252395.
Comment 1 Ruslan Makhmatkhanov freebsd_committer freebsd_triage 2021-01-21 09:08:18 UTC
yes, sorry. it looks like the completion works only once in a session. will see further
Comment 2 commit-hook freebsd_committer freebsd_triage 2021-01-26 10:34:00 UTC
A commit references this bug:

Author: rm
Date: Tue Jan 26 10:33:14 UTC 2021
New revision: 562650
URL: https://svnweb.freebsd.org/changeset/ports/562650

Log:
  devel/ipython: actually unbreak autocompletion

  Remove broader patch added earlier - it still doesn't completely
  solve the problem.
  Instead add tiny patch to fix runtime with jedi 0.18 and add missing
  imports with second patch. Works just well with my tests.
  Both patches should be removed after next ipython release.

  PR:		252875
  Reported by:	rsmith@xs4all.nl
  Approved by:	python (with hat)

Changes:
  head/devel/ipython/Makefile
  head/devel/ipython/files/patch-IPython_core_completer.py
  head/devel/ipython/files/patch-IPython_terminal_ptutils.py
  head/devel/ipython/files/patch-autocompletion-fix
Comment 3 Ruslan Makhmatkhanov freebsd_committer freebsd_triage 2021-01-26 10:34:47 UTC
(In reply to rsmith from comment #0)

fix committed. please let us know how it's going