Got the below error when I use this code snipets,
In [1]: from elasticsearch import Elasticsearch
In [2]: es = Elasticsearch(hosts=[{"host": "host.docker.internal", "port": 9200}],
...: max_retries=30,
...: retry_on_timeout=True,
...: request_timeout=30)
In [3]: es.info()
Error:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/IPython/terminal/ptutils.py", line 113, in get_completions
yield from self._get_completions(body, offset, cursor_position, self.ipy_completer)
File "/usr/local/lib/python3.8/site-packages/IPython/terminal/ptutils.py", line 129, in _get_completions
for c in completions:
File "/usr/local/lib/python3.8/site-packages/IPython/core/completer.py", line 438, in _deduplicate_completions
completions = list(completions)
File "/usr/local/lib/python3.8/site-packages/IPython/core/completer.py", line 1818, in completions
for c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000):
File "/usr/local/lib/python3.8/site-packages/IPython/core/completer.py", line 1861, in _completions
matched_text, matches, matches_origin, jedi_matches = self._complete(
File "/usr/local/lib/python3.8/site-packages/IPython/core/completer.py", line 2029, in _complete
completions = self._jedi_matches(
File "/usr/local/lib/python3.8/site-packages/IPython/core/completer.py", line 1373, in _jedi_matches
interpreter = jedi.Interpreter(
File "/usr/local/lib/python3.8/site-packages/jedi/api/__init__.py", line 725, in __init__
super().__init__(code, environment=environment,
TypeError: __init__() got an unexpected keyword argument 'column'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 371, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.8/site-packages/django/core/management/commands/shell.py", line 100, in handle
return getattr(self, shell)(options)
File "/usr/local/lib/python3.8/site-packages/django/core/management/commands/shell.py", line 36, in ipython
start_ipython(argv=[])
File "/usr/local/lib/python3.8/site-packages/IPython/__init__.py", line 126, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "/usr/local/lib/python3.8/site-packages/traitlets/config/application.py", line 845, in launch_instance
app.start()
File "/usr/local/lib/python3.8/site-packages/IPython/terminal/ipapp.py", line 356, in start
self.shell.mainloop()
File "/usr/local/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 564, in mainloop
self.interact()
File "/usr/local/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 547, in interact
code = self.prompt_for_code()
File "/usr/local/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 473, in prompt_for_code
text = self.pt_app.prompt(
File "/usr/local/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py", line 1013, in prompt
return self.app.run(set_exception_handler=set_exception_handler)
File "/usr/local/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 816, in run
return loop.run_until_complete(
File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/usr/local/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 783, in run_async
return await _run_async2()
File "/usr/local/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 771, in _run_async2
await self.cancel_and_wait_for_background_tasks()
File "/usr/local/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 872, in cancel_and_wait_for_background_tasks
await task
File "/usr/local/lib/python3.8/site-packages/prompt_toolkit/buffer.py", line 1854, in new_coroutine
await coroutine(*a, **kw)
File "/usr/local/lib/python3.8/site-packages/prompt_toolkit/buffer.py", line 1683, in async_completer
async for completion in self.completer.get_completions_async(
File "/usr/local/lib/python3.8/site-packages/prompt_toolkit/completion/base.py", line 269, in get_completions_async
async for completion in completer.get_completions_async(
File "/usr/local/lib/python3.8/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.8/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
same
same. I've also tried downgrading and trying different versions of python from 3.6 - 3.9 all with varying levels of errors. This is the first time I've seen a bug like this with ipython that seems to affect multiple versions. I wish I had more information to report other than just saying, I'm also affected by this. If I determine what the issue is, I will certainly post and or try to open a PR to address.
Thank you for creating this tool. I've been using it for for 10+ years now.
I think I see the same thing.
Very easy to reproduce.
***************************************************************************
IPython post-mortem report
{'commit_hash': '223e783c4',
'commit_source': 'installation',
'default_encoding': 'utf-8',
'ipython_path': '/Users/damian/Projects/hypermind/env/lib/python3.8/site-packages/IPython',
'ipython_version': '7.19.0',
'os_name': 'posix',
'platform': 'macOS-10.15.7-x86_64-i386-64bit',
'sys_executable': '/Users/damian/Projects/hypermind/env/bin/python',
'sys_platform': 'darwin',
'sys_version': '3.8.5 (default, Jul 21 2020, 10:48:26) \n'
'[Clang 11.0.3 (clang-1103.0.32.62)]'}
***************************************************************************
***************************************************************************
Crash traceback:
---------------------------------------------------------------------------
---------------------------------------------------------------------------
TypeError Python 3.8.5: /Users/damian/Projects/hypermind/env/bin/python
Mon Dec 28 23:01:36 2020
A problem occurred executing Python code. Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.
~/Projects/hypermind/env/lib/python3.8/site-packages/IPython/terminal/ptutils.py in get_completions(self=<IPython.terminal.ptutils.IPythonPTCompleter object>, document=Document('Edge', 4), complete_event=CompleteEvent(text_inserted=False, completion_requested=True))
112 try:
--> 113 yield from self._get_completions(body, offset, cursor_position, self.ipy_completer)
self._get_completions = <function IPythonPTCompleter._get_completions at 0x103d6d550>
body = 'Edge'
offset = 4
cursor_position = 4
self.ipy_completer = <IPython.core.completer.IPCompleter object at 0x103eaa790>
114 except Exception as e:
~/Projects/hypermind/env/lib/python3.8/site-packages/IPython/terminal/ptutils.py in _get_completions(body='Edge', offset=4, cursor_position=4, ipyc=<IPython.core.completer.IPCompleter object>)
128 body, ipyc.completions(body, offset))
--> 129 for c in completions:
c = undefined
completions = <generator object _deduplicate_completions at 0x1041fb900>
130 if not c.text:
~/Projects/hypermind/env/lib/python3.8/site-packages/IPython/core/completer.py in _deduplicate_completions(text='Edge', completions=<generator object IPCompleter.completions>)
437 """
--> 438 completions = list(completions)
completions = <generator object IPCompleter.completions at 0x1041fb890>
global list = undefined
439 if not completions:
~/Projects/hypermind/env/lib/python3.8/site-packages/IPython/core/completer.py in completions(self=<IPython.core.completer.IPCompleter object>, text='Edge', offset=4)
1817 try:
-> 1818 for c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000):
c = undefined
self._completions = <bound method IPCompleter._completions of <IPython.core.completer.IPCompleter object at 0x103eaa790>>
text = 'Edge'
offset = 4
global _timeout = undefined
self.jedi_compute_type_timeout = 400
1819 if c and (c in seen):
~/Projects/hypermind/env/lib/python3.8/site-packages/IPython/core/completer.py in _completions(self=<IPython.core.completer.IPCompleter object>, full_text='Edge', offset=4, _timeout=0.4)
1860
-> 1861 matched_text, matches, matches_origin, jedi_matches = self._complete(
matched_text = undefined
matches = undefined
matches_origin = undefined
jedi_matches = undefined
self._complete = <bound method IPCompleter._complete of <IPython.core.completer.IPCompleter object at 0x103eaa790>>
full_text = 'Edge'
cursor_line = 0
global cursor_pos = undefined
cursor_column = 4
1862 full_text=full_text, cursor_line=cursor_line, cursor_pos=cursor_column)
~/Projects/hypermind/env/lib/python3.8/site-packages/IPython/core/completer.py in _complete(self=<IPython.core.completer.IPCompleter object>, cursor_line=0, cursor_pos=4, line_buffer='Edge', text='Edge', full_text='Edge')
2028 full_text = line_buffer
-> 2029 completions = self._jedi_matches(
completions = ()
self._jedi_matches = <bound method IPCompleter._jedi_matches of <IPython.core.completer.IPCompleter object at 0x103eaa790>>
cursor_pos = 4
cursor_line = 0
full_text = 'Edge'
2030 cursor_pos, cursor_line, full_text)
~/Projects/hypermind/env/lib/python3.8/site-packages/IPython/core/completer.py in _jedi_matches(self=<IPython.core.completer.IPCompleter object>, cursor_column=4, cursor_line=0, text='Edge')
1372
-> 1373 interpreter = jedi.Interpreter(
interpreter = undefined
global jedi.Interpreter = <class 'jedi.api.Interpreter'>
text = 'Edge'
offset = 4
namespaces = [{'__name__': '__main__', '__doc__': 'Automatically created module for IPython interactive environment', '__package__': None, '__loader__': None, '__spec__': None, '__builtin__': <module 'builtins' (built-in)>, '__builtins__': <module 'builtins' (built-in)>, '_ih': ['', "get_ipython().run_line_magic('config', 'Application.verbose_crash=True')", 'from hypergraph.models import Vertex, Edge'], '_oh': {}, '_dh': ['/Users/damian/Projects/hypermind/hypermind'], 'In': ['', "get_ipython().run_line_magic('config', 'Application.verbose_crash=True')", 'from hypergraph.models import Vertex, Edge'], 'Out': {}, 'get_ipython': <bound method InteractiveShell.get_ipython of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x103eaf280>>, 'exit': <IPython.core.autocall.ExitAutocall object at 0x103eaa7f0>, 'quit': <IPython.core.autocall.ExitAutocall object at 0x103eaa7f0>, '_': '', '__': '', '___': '', '_i': '%config Application.verbose_crash=True', '_ii': '', '_iii': '', '_i1': '%config Application.verbose_crash=True', '_i2': 'from hypergraph.models import Vertex, Edge', 'Vertex': <class 'hypergraph.models.Vertex'>, 'Edge': <class 'hypergraph.models.Edge'>}, {'__name__': '__main__', '__doc__': 'Automatically created module for IPython interactive environment', '__package__': None, '__loader__': None, '__spec__': None, '__builtin__': <module 'builtins' (built-in)>, '__builtins__': <module 'builtins' (built-in)>, '_ih': ['', "get_ipython().run_line_magic('config', 'Application.verbose_crash=True')", 'from hypergraph.models import Vertex, Edge'], '_oh': {}, '_dh': ['/Users/damian/Projects/hypermind/hypermind'], 'In': ['', "get_ipython().run_line_magic('config', 'Application.verbose_crash=True')", 'from hypergraph.models import Vertex, Edge'], 'Out': {}, 'get_ipython': <bound method InteractiveShell.get_ipython of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x103eaf280>>, 'exit': <IPython.core.autocall.ExitAutocall object at 0x103eaa7f0>, 'quit': <IPython.core.autocall.ExitAutocall object at 0x103eaa7f0>, '_': '', '__': '', '___': '', '_i': '%config Application.verbose_crash=True', '_ii': '', '_iii': '', '_i1': '%config Application.verbose_crash=True', '_i2': 'from hypergraph.models import Vertex, Edge', 'Vertex': <class 'hypergraph.models.Vertex'>, 'Edge': <class 'hypergraph.models.Edge'>}]
global column = undefined
cursor_column = 4
global line = undefined
cursor_line = 0
1374 text[:offset], namespaces, column=cursor_column, line=cursor_line + 1)
~/Projects/hypermind/env/lib/python3.8/site-packages/jedi/api/__init__.py in __init__(self=<class 'jedi.api.Interpreter'> instance, code='Edge', namespaces=[{'Edge': <class 'hypergraph.models.Edge'>, 'In': ['', "get_ipython().run_line_magic('config', 'Application.verbose_crash=True')", 'from hypergraph.models import Vertex, Edge'], 'Out': {}, 'Vertex': <class 'hypergraph.models.Vertex'>, '_': '', '__': '', '___': '', '__builtin__': <module 'builtins' (built-in)>, '__builtins__': <module 'builtins' (built-in)>, '__doc__': 'Automatically created module for IPython interactive environment', ...}, {'Edge': <class 'hypergraph.models.Edge'>, 'In': ['', "get_ipython().run_line_magic('config', 'Application.verbose_crash=True')", 'from hypergraph.models import Vertex, Edge'], 'Out': {}, 'Vertex': <class 'hypergraph.models.Vertex'>, '_': '', '__': '', '___': '', '__builtin__': <module 'builtins' (built-in)>, '__builtins__': <module 'builtins' (built-in)>, '__doc__': 'Automatically created module for IPython interactive environment', ...}], **kwds={'column': 4, 'line': 1})
724
--> 725 super().__init__(code, environment=environment,
global super.__init__ = undefined
code = 'Edge'
environment = <jedi.api.environment.InterpreterEnvironment object at 0x10413d7f0>
global project = <module 'jedi.api.project' from '/Users/damian/Projects/hypermind/env/lib/python3.8/site-packages/jedi/api/project.py'>
global Project = <class 'jedi.api.project.Project'>
global Path.cwd = <bound method Path.cwd of <class 'pathlib.Path'>>
kwds = {'column': 4, 'line': 1}
726 project=Project(Path.cwd()), **kwds)
TypeError: __init__() got an unexpected keyword argument 'column'
During handling of the above exception, another exception occurred:
---------------------------------------------------------------------------
NameError Python 3.8.5: /Users/damian/Projects/hypermind/env/bin/python
Mon Dec 28 23:01:36 2020
A problem occurred executing Python code. Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.
~/Projects/hypermind/hypermind/manage.py in <module>
7 def main():
8 """Run administrative tasks."""
9 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hypermind.settings")
10 try:
11 from django.core.management import execute_from_command_line
12 except ImportError as exc:
13 raise ImportError(
14 "Couldn't import Django. Are you sure it's installed and "
15 "available on your PYTHONPATH environment variable? Did you "
16 "forget to activate a virtual environment?"
17 ) from exc
18 execute_from_command_line(sys.argv)
19
20
21 if __name__ == "__main__":
---> 22 main()
global main = <function main at 0x101b2a160>
~/Projects/hypermind/hypermind/manage.py in main()
3 import os
4 import sys
5
6
7 def main():
8 """Run administrative tasks."""
9 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hypermind.settings")
10 try:
11 from django.core.management import execute_from_command_line
12 except ImportError as exc:
13 raise ImportError(
14 "Couldn't import Django. Are you sure it's installed and "
15 "available on your PYTHONPATH environment variable? Did you "
16 "forget to activate a virtual environment?"
17 ) from exc
---> 18 execute_from_command_line(sys.argv)
execute_from_command_line = <function execute_from_command_line at 0x1024e28b0>
global sys.argv = ['manage.py', 'shell']
19
20
21 if __name__ == "__main__":
22 main()
~/Projects/hypermind/env/lib/python3.8/site-packages/django/core/management/__init__.py in execute_from_command_line(argv=['manage.py', 'shell'])
386 else:
387 self.fetch_command(options.args[0]).print_help(self.prog_name, options.args[0])
388 # Special-cases: We want 'django-admin --version' and
389 # 'django-admin --help' to work, for backwards compatibility.
390 elif subcommand == 'version' or self.argv[1:] == ['--version']:
391 sys.stdout.write(django.get_version() + '\n')
392 elif self.argv[1:] in (['--help'], ['-h']):
393 sys.stdout.write(self.main_help_text() + '\n')
394 else:
395 self.fetch_command(subcommand).run_from_argv(self.argv)
396
397
398 def execute_from_command_line(argv=None):
399 """Run a ManagementUtility."""
400 utility = ManagementUtility(argv)
--> 401 utility.execute()
utility.execute = <bound method ManagementUtility.execute of <django.core.management.ManagementUtility object at 0x101ab3a90>>
~/Projects/hypermind/env/lib/python3.8/site-packages/django/core/management/__init__.py in execute(self=<django.core.management.ManagementUtility object>)
380
381 if subcommand == 'help':
382 if '--commands' in args:
383 sys.stdout.write(self.main_help_text(commands_only=True) + '\n')
384 elif not options.args:
385 sys.stdout.write(self.main_help_text() + '\n')
386 else:
387 self.fetch_command(options.args[0]).print_help(self.prog_name, options.args[0])
388 # Special-cases: We want 'django-admin --version' and
389 # 'django-admin --help' to work, for backwards compatibility.
390 elif subcommand == 'version' or self.argv[1:] == ['--version']:
391 sys.stdout.write(django.get_version() + '\n')
392 elif self.argv[1:] in (['--help'], ['-h']):
393 sys.stdout.write(self.main_help_text() + '\n')
394 else:
--> 395 self.fetch_command(subcommand).run_from_argv(self.argv)
self.fetch_command = <bound method ManagementUtility.fetch_command of <django.core.management.ManagementUtility object at 0x101ab3a90>>
subcommand.run_from_argv = undefined
self.argv = ['manage.py', 'shell']
396
397
398 def execute_from_command_line(argv=None):
399 """Run a ManagementUtility."""
400 utility = ManagementUtility(argv)
401 utility.execute()
~/Projects/hypermind/env/lib/python3.8/site-packages/django/core/management/base.py in run_from_argv(self=<django.core.management.commands.shell.Command object>, argv=['manage.py', 'shell'])
315 Set up any environment changes requested (e.g., Python path
316 and Django settings), then run this command. If the
317 command raises a ``CommandError``, intercept it and print it sensibly
318 to stderr. If the ``--traceback`` option is present or the raised
319 ``Exception`` is not ``CommandError``, raise it.
320 """
321 self._called_from_command_line = True
322 parser = self.create_parser(argv[0], argv[1])
323
324 options = parser.parse_args(argv[2:])
325 cmd_options = vars(options)
326 # Move positional args out of options to mimic legacy optparse
327 args = cmd_options.pop('args', ())
328 handle_default_options(options)
329 try:
--> 330 self.execute(*args, **cmd_options)
self.execute = <bound method BaseCommand.execute of <django.core.management.commands.shell.Command object at 0x102b766d0>>
args = ()
cmd_options = {'verbosity': 1, 'settings': None, 'pythonpath': None, 'traceback': False, 'no_color': False, 'force_color': False, 'no_startup': False, 'interface': None, 'command': None}
331 except CommandError as e:
332 if options.traceback:
333 raise
334
335 # SystemCheckError takes care of its own formatting.
336 if isinstance(e, SystemCheckError):
337 self.stderr.write(str(e), lambda x: x)
338 else:
339 self.stderr.write('%s: %s' % (e.__class__.__name__, e))
340 sys.exit(e.returncode)
341 finally:
342 try:
343 connections.close_all()
344 except ImproperlyConfigured:
345 # Ignore if connections aren't setup at this point (e.g. no
~/Projects/hypermind/env/lib/python3.8/site-packages/django/core/management/base.py in execute(self=<django.core.management.commands.shell.Command object>, *args=(), **options={'command': None, 'force_color': False, 'interface': None, 'no_color': False, 'no_startup': False, 'pythonpath': None, 'settings': None, 'traceback': False, 'verbosity': 1})
356 raise CommandError("The --no-color and --force-color options can't be used together.")
357 if options['force_color']:
358 self.style = color_style(force_color=True)
359 elif options['no_color']:
360 self.style = no_style()
361 self.stderr.style_func = None
362 if options.get('stdout'):
363 self.stdout = OutputWrapper(options['stdout'])
364 if options.get('stderr'):
365 self.stderr = OutputWrapper(options['stderr'])
366
367 if self.requires_system_checks and not options['skip_checks']:
368 self.check()
369 if self.requires_migrations_checks:
370 self.check_migrations()
--> 371 output = self.handle(*args, **options)
output = undefined
self.handle = <bound method Command.handle of <django.core.management.commands.shell.Command object at 0x102b766d0>>
args = ()
options = {'verbosity': 1, 'settings': None, 'pythonpath': None, 'traceback': False, 'no_color': False, 'force_color': False, 'no_startup': False, 'interface': None, 'command': None}
372 if output:
373 if self.output_transaction:
374 connection = connections[options.get('database', DEFAULT_DB_ALIAS)]
375 output = '%s\n%s\n%s' % (
376 self.style.SQL_KEYWORD(connection.ops.start_transaction_sql()),
377 output,
378 self.style.SQL_KEYWORD(connection.ops.end_transaction_sql()),
379 )
380 self.stdout.write(output)
381 return output
382
383 def check(self, app_configs=None, tags=None, display_num_errors=False,
384 include_deployment_checks=False, fail_level=checks.ERROR,
385 databases=None):
386 """
~/Projects/hypermind/env/lib/python3.8/site-packages/django/core/management/commands/shell.py in handle(self=<django.core.management.commands.shell.Command object>, **options={'command': None, 'force_color': False, 'interface': None, 'no_color': False, 'no_startup': False, 'pythonpath': None, 'settings': None, 'traceback': False, 'verbosity': 1})
85 # Execute the command and exit.
86 if options['command']:
87 exec(options['command'])
88 return
89
90 # Execute stdin if it has anything to read and exit.
91 # Not supported on Windows due to select.select() limitations.
92 if sys.platform != 'win32' and not sys.stdin.isatty() and select.select([sys.stdin], [], [], 0)[0]:
93 exec(sys.stdin.read())
94 return
95
96 available_shells = [options['interface']] if options['interface'] else self.shells
97
98 for shell in available_shells:
99 try:
--> 100 return getattr(self, shell)(options)
global getattr = undefined
self = <django.core.management.commands.shell.Command object at 0x102b766d0>
shell = 'ipython'
options = {'verbosity': 1, 'settings': None, 'pythonpath': None, 'traceback': False, 'no_color': False, 'force_color': False, 'no_startup': False, 'interface': None, 'command': None}
101 except ImportError:
102 pass
103 raise CommandError("Couldn't import {} interface.".format(shell))
~/Projects/hypermind/env/lib/python3.8/site-packages/django/core/management/commands/shell.py in ipython(self=<django.core.management.commands.shell.Command object>, options={'command': None, 'force_color': False, 'interface': None, 'no_color': False, 'no_startup': False, 'pythonpath': None, 'settings': None, 'traceback': False, 'verbosity': 1})
21 parser.add_argument(
22 '--no-startup', action='store_true',
23 help='When using plain Python, ignore the PYTHONSTARTUP environment variable and ~/.pythonrc.py script.',
24 )
25 parser.add_argument(
26 '-i', '--interface', choices=self.shells,
27 help='Specify an interactive interpreter interface. Available options: "ipython", "bpython", and "python"',
28 )
29 parser.add_argument(
30 '-c', '--command',
31 help='Instead of opening an interactive shell, run a command as Django and exit.',
32 )
33
34 def ipython(self, options):
35 from IPython import start_ipython
---> 36 start_ipython(argv=[])
start_ipython = <function start_ipython at 0x103e88280>
global argv = undefined
37
38 def bpython(self, options):
39 import bpython
40 bpython.embed()
41
42 def python(self, options):
43 import code
44
45 # Set up a dictionary to serve as the environment for the shell, so
46 # that tab completion works on objects that are imported at runtime.
47 imported_objects = {}
48 try: # Try activating rlcompleter, because it's handy.
49 import readline
50 except ImportError:
51 pass
~/Projects/hypermind/env/lib/python3.8/site-packages/IPython/__init__.py in start_ipython(argv=[], **kwargs={})
111 This is a public API method, and will survive implementation changes.
112
113 Parameters
114 ----------
115
116 argv : list or None, optional
117 If unspecified or None, IPython will parse command-line options from sys.argv.
118 To prevent any command-line parsing, pass an empty list: `argv=[]`.
119 user_ns : dict, optional
120 specify this dictionary to initialize the IPython user namespace with particular values.
121 kwargs : various, optional
122 Any other kwargs will be passed to the Application constructor,
123 such as `config`.
124 """
125 from IPython.terminal.ipapp import launch_new_instance
--> 126 return launch_new_instance(argv=argv, **kwargs)
launch_new_instance = <bound method Application.launch_instance of <class 'IPython.terminal.ipapp.TerminalIPythonApp'>>
argv = []
kwargs = {}
127
128 def start_kernel(argv=None, **kwargs):
129 """Launch a normal IPython kernel instance (as opposed to embedded)
130
131 `IPython.embed_kernel()` puts a shell in a particular calling scope,
132 such as a function or method for debugging purposes,
133 which is often not desirable.
134
135 `start_kernel()` does full, regular IPython initialization,
136 including loading startup files, configuration, etc.
137 much of which is skipped by `embed()`.
138
139 Parameters
140 ----------
141
~/Projects/hypermind/env/lib/python3.8/site-packages/traitlets/config/application.py in launch_instance(cls=<class 'IPython.terminal.ipapp.TerminalIPythonApp'>, argv=[], **kwargs={})
830 lines.append(cls.class_config_section(config_classes))
831 return '\n'.join(lines)
832
833 def exit(self, exit_status=0):
834 self.log.debug("Exiting application: %s" % self.name)
835 sys.exit(exit_status)
836
837 @classmethod
838 def launch_instance(cls, argv=None, **kwargs):
839 """Launch a global instance of this Application
840
841 If a global instance already exists, this reinitializes and starts it
842 """
843 app = cls.instance(**kwargs)
844 app.initialize(argv)
--> 845 app.start()
app.start = <bound method TerminalIPythonApp.start of <IPython.terminal.ipapp.TerminalIPythonApp object at 0x103378d00>>
846
847 #-----------------------------------------------------------------------------
848 # utility functions, for convenience
849 #-----------------------------------------------------------------------------
850
851 default_aliases = Application.aliases
852 default_flags = Application.flags
853
854 def boolean_flag(name, configurable, set_help='', unset_help=''):
855 """Helper for building basic --trait, --no-trait flags.
856
857 Parameters
858 ----------
859 name : str
860 The name of the flag.
~/Projects/hypermind/env/lib/python3.8/site-packages/IPython/terminal/ipapp.py in start(self=<IPython.terminal.ipapp.TerminalIPythonApp object>)
341 if self.log_level <= logging.INFO: print()
342
343 def _pylab_changed(self, name, old, new):
344 """Replace --pylab='inline' with --pylab='auto'"""
345 if new == 'inline':
346 warnings.warn("'inline' not available as pylab backend, "
347 "using 'auto' instead.")
348 self.pylab = 'auto'
349
350 def start(self):
351 if self.subapp is not None:
352 return self.subapp.start()
353 # perform any prexec steps:
354 if self.interact:
355 self.log.debug("Starting IPython's mainloop...")
--> 356 self.shell.mainloop()
self.shell.mainloop = <bound method TerminalInteractiveShell.mainloop of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x103eaf280>>
357 else:
358 self.log.debug("IPython not interactive...")
359 if not self.shell.last_execution_succeeded:
360 sys.exit(1)
361
362 def load_default_config(ipython_dir=None):
363 """Load the default config file from the default ipython_dir.
364
365 This is useful for embedded shells.
366 """
367 if ipython_dir is None:
368 ipython_dir = get_ipython_dir()
369
370 profile_dir = os.path.join(ipython_dir, 'profile_default')
371 app = TerminalIPythonApp()
~/Projects/hypermind/env/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py in mainloop(self=<IPython.terminal.interactiveshell.TerminalInteractiveShell object>, display_banner=<object object>)
549 if (not self.confirm_exit) \
550 or self.ask_yes_no('Do you really want to exit ([y]/n)?','y','n'):
551 self.ask_exit()
552
553 else:
554 if code:
555 self.run_cell(code, store_history=True)
556
557 def mainloop(self, display_banner=DISPLAY_BANNER_DEPRECATED):
558 # An extra layer of protection in case someone mashing Ctrl-C breaks
559 # out of our internal code.
560 if display_banner is not DISPLAY_BANNER_DEPRECATED:
561 warn('mainloop `display_banner` argument is deprecated since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning, stacklevel=2)
562 while True:
563 try:
--> 564 self.interact()
self.interact = <bound method TerminalInteractiveShell.interact of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x103eaf280>>
565 break
566 except KeyboardInterrupt as e:
567 print("\n%s escaped interact()\n" % type(e).__name__)
568 finally:
569 # An interrupt during the eventloop will mess up the
570 # internal state of the prompt_toolkit library.
571 # Stopping the eventloop fixes this, see
572 # https://github.com/ipython/ipython/pull/9867
573 if hasattr(self, '_eventloop'):
574 self._eventloop.stop()
575
576 self.restore_term_title()
577
578
579 _inputhook = None
~/Projects/hypermind/env/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py in interact(self=<IPython.terminal.interactiveshell.TerminalInteractiveShell object>, display_banner=<object object>)
532 def ask_exit(self):
533 self.keep_running = False
534
535 rl_next_input = None
536
537 def interact(self, display_banner=DISPLAY_BANNER_DEPRECATED):
538
539 if display_banner is not DISPLAY_BANNER_DEPRECATED:
540 warn('interact `display_banner` argument is deprecated since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning, stacklevel=2)
541
542 self.keep_running = True
543 while self.keep_running:
544 print(self.separate_in, end='')
545
546 try:
--> 547 code = self.prompt_for_code()
code = 'from hypergraph.models import Vertex, Edge'
self.prompt_for_code = <bound method TerminalInteractiveShell.prompt_for_code of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x103eaf280>>
548 except EOFError:
549 if (not self.confirm_exit) \
550 or self.ask_yes_no('Do you really want to exit ([y]/n)?','y','n'):
551 self.ask_exit()
552
553 else:
554 if code:
555 self.run_cell(code, store_history=True)
556
557 def mainloop(self, display_banner=DISPLAY_BANNER_DEPRECATED):
558 # An extra layer of protection in case someone mashing Ctrl-C breaks
559 # out of our internal code.
560 if display_banner is not DISPLAY_BANNER_DEPRECATED:
561 warn('mainloop `display_banner` argument is deprecated since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning, stacklevel=2)
562 while True:
~/Projects/hypermind/env/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py in prompt_for_code(self=<IPython.terminal.interactiveshell.TerminalInteractiveShell object>)
458 # In order to make sure that asyncio code written in the
459 # interactive shell doesn't interfere with the prompt, we run the
460 # prompt in a different event loop.
461 # If we don't do this, people could spawn coroutine with a
462 # while/true inside which will freeze the prompt.
463
464 try:
465 old_loop = asyncio.get_event_loop()
466 except RuntimeError:
467 # This happens when the user used `asyncio.run()`.
468 old_loop = None
469
470 asyncio.set_event_loop(self.pt_loop)
471 try:
472 with patch_stdout(raw=True):
--> 473 text = self.pt_app.prompt(
text = undefined
self.pt_app.prompt = <bound method PromptSession.prompt of <prompt_toolkit.shortcuts.prompt.PromptSession object at 0x104036790>>
default = ''
self._extra_prompt_options = <bound method TerminalInteractiveShell._extra_prompt_options of <IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x103eaf280>>
474 default=default,
475 **self._extra_prompt_options())
476 finally:
477 # Restore the original event loop.
478 asyncio.set_event_loop(old_loop)
479
480 return text
481
482 def enable_win_unicode_console(self):
483 # Since IPython 7.10 doesn't support python < 3.6 and PEP 528, Python uses the unicode APIs for the Windows
484 # console by default, so WUC shouldn't be needed.
485 from warnings import warn
486 warn("`enable_win_unicode_console` is deprecated since IPython 7.10, does not do anything and will be removed in the future",
487 DeprecationWarning,
488 stacklevel=2)
~/Projects/hypermind/env/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py in prompt(self=<prompt_toolkit.shortcuts.prompt.PromptSession object>, message=<prompt_toolkit.formatted_text.pygments.PygmentsTokens object>, editing_mode=None, refresh_interval=None, vi_mode=None, lexer=<IPython.terminal.ptutils.IPythonPTLexer object>, completer=None, complete_in_thread=False, is_password=None, key_bindings=None, bottom_toolbar=None, style=None, color_depth=None, include_default_pygments_style=None, style_transformation=None, swap_light_and_dark_colors=None, rprompt=None, multiline=True, prompt_continuation=<function TerminalInteractiveShell._extra_prompt_options.<locals>.<lambda>>, wrap_lines=None, enable_history_search=None, search_ignore_case=None, complete_while_typing=None, validate_while_typing=None, complete_style=<CompleteStyle.MULTI_COLUMN: 'MULTI_COLUMN'>, auto_suggest=None, validator=None, clipboard=None, mouse_support=None, input_processors=[ConditionalProcessor(processor=<prompt_toolkit.l...rompt_options.<locals>.<lambda> at 0x104107790>))], placeholder=None, reserve_space_for_menu=6, enable_system_prompt=None, enable_suspend=None, enable_open_in_editor=None, tempfile_suffix=None, tempfile=None, default='', accept_default=False, pre_run=None, set_exception_handler=True)
998 self.tempfile_suffix = tempfile_suffix
999 if tempfile is not None:
1000 self.tempfile = tempfile
1001
1002 self._add_pre_run_callables(pre_run, accept_default)
1003 self.default_buffer.reset(
1004 default if isinstance(default, Document) else Document(default)
1005 )
1006 self.app.refresh_interval = self.refresh_interval # This is not reactive.
1007
1008 # If we are using the default output, and have a dumb terminal. Use the
1009 # dumb prompt.
1010 if self._output is None and is_dumb_terminal():
1011 return get_event_loop().run_until_complete(self._dumb_prompt(self.message))
1012
-> 1013 return self.app.run(set_exception_handler=set_exception_handler)
self.app.run = <bound method Application.run of <prompt_toolkit.application.application.Application object at 0x104053580>>
set_exception_handler = True
1014
1015 async def _dumb_prompt(self, message: AnyFormattedText = "") -> _T:
1016 """
1017 Prompt function for dumb terminals.
1018
1019 Dumb terminals have minimum rendering capabilities. We can only print
1020 text to the screen. We can't use colors, and we can't do cursor
1021 movements. The Emacs inferior shell is an example of a dumb terminal.
1022
1023 We will show the prompt, and wait for the input. We still handle arrow
1024 keys, and all custom key bindings, but we don't really render the
1025 cursor movements. Instead we only print the typed character that's
1026 right before the cursor.
1027 """
1028 # Send prompt to output.
~/Projects/hypermind/env/lib/python3.8/site-packages/prompt_toolkit/application/application.py in run(self=<prompt_toolkit.application.application.Application object>, pre_run=None, set_exception_handler=True)
801 """
802 # We don't create a new event loop by default, because we want to be
803 # sure that when this is called multiple times, each call of `run()`
804 # goes through the same event loop. This way, users can schedule
805 # background-tasks that keep running across multiple prompts.
806 try:
807 loop = get_event_loop()
808 except RuntimeError:
809 # Possibly we are not running in the main thread, where no event
810 # loop is set by default. Or somebody called `asyncio.run()`
811 # before, which closes the existing event loop. We can create a new
812 # loop.
813 loop = new_event_loop()
814 set_event_loop(loop)
815
--> 816 return loop.run_until_complete(
loop.run_until_complete = <bound method BaseEventLoop.run_until_complete of <_UnixSelectorEventLoop running=False closed=False debug=False>>
self.run_async = <bound method Application.run_async of <prompt_toolkit.application.application.Application object at 0x104053580>>
pre_run = None
set_exception_handler = True
817 self.run_async(pre_run=pre_run, set_exception_handler=set_exception_handler)
818 )
819
820 def _handle_exception(
821 self, loop: AbstractEventLoop, context: Dict[str, Any]
822 ) -> None:
823 """
824 Handler for event loop exceptions.
825 This will print the exception, using run_in_terminal.
826 """
827 # For Python 2: we have to get traceback at this point, because
828 # we're still in the 'except:' block of the event loop where the
829 # traceback is still available. Moving this code in the
830 # 'print_exception' coroutine will loose the exception.
831 tb = get_traceback_from_context(context)
/usr/local/Cellar/[email protected]/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py in run_until_complete(self=<_UnixSelectorEventLoop running=False closed=False debug=False>, future=<Task finished name='Task-32' coro=<Application....exception=NameError("name 'sys' is not defined")>)
601 future.add_done_callback(_run_until_complete_cb)
602 try:
603 self.run_forever()
604 except:
605 if new_task and future.done() and not future.cancelled():
606 # The coroutine raised a BaseException. Consume the exception
607 # to not log a warning, the caller doesn't have access to the
608 # local task.
609 future.exception()
610 raise
611 finally:
612 future.remove_done_callback(_run_until_complete_cb)
613 if not future.done():
614 raise RuntimeError('Event loop stopped before Future completed.')
615
--> 616 return future.result()
future.result = <built-in method result of _asyncio.Task object at 0x10401f5e0>
617
618 def stop(self):
619 """Stop running the event loop.
620
621 Every callback already scheduled will still run. This simply informs
622 run_forever to stop looping after a complete iteration.
623 """
624 self._stopping = True
625
626 def close(self):
627 """Close the event loop.
628
629 This clears the queues and shuts down the executor,
630 but does not wait for the executor to finish.
631
~/Projects/hypermind/env/lib/python3.8/site-packages/prompt_toolkit/application/application.py in run_async(self=<prompt_toolkit.application.application.Application object>, pre_run=None, set_exception_handler=True)
768 # go in the finally! If `_run_async` raises
769 # `KeyboardInterrupt`, we still want to wait for the
770 # background tasks.
771 await self.cancel_and_wait_for_background_tasks()
772
773 # Set the `_is_running` flag to `False`. Normally this
774 # happened already in the finally block in `run_async`
775 # above, but in case of exceptions, that's not always the
776 # case.
777 self._is_running = False
778 return result
779 finally:
780 if set_exception_handler:
781 loop.set_exception_handler(previous_exc_handler)
782
--> 783 return await _run_async2()
_run_async2 = <function Application.run_async.<locals>._run_async2 at 0x10401cb80>
784
785 def run(
786 self,
787 pre_run: Optional[Callable[[], None]] = None,
788 set_exception_handler: bool = True,
789 ) -> _AppResult:
790 """
791 A blocking 'run' call that waits until the UI is finished.
792
793 This will start the current asyncio event loop. If no loop is set for
794 the current thread, then it will create a new loop.
795
796 :param pre_run: Optional callable, which is called right after the
797 "reset" of the application.
798 :param set_exception_handler: When set, in case of an exception, go out
~/Projects/hypermind/env/lib/python3.8/site-packages/prompt_toolkit/application/application.py in _run_async2()
756
757 loop = get_event_loop()
758 if set_exception_handler:
759 previous_exc_handler = loop.get_exception_handler()
760 loop.set_exception_handler(self._handle_exception)
761
762 try:
763 with set_app(self):
764 try:
765 result = await _run_async()
766 finally:
767 # Wait for the background tasks to be done. This needs to
768 # go in the finally! If `_run_async` raises
769 # `KeyboardInterrupt`, we still want to wait for the
770 # background tasks.
--> 771 await self.cancel_and_wait_for_background_tasks()
global self.cancel_and_wait_for_background_tasks = undefined
772
773 # Set the `_is_running` flag to `False`. Normally this
774 # happened already in the finally block in `run_async`
775 # above, but in case of exceptions, that's not always the
776 # case.
777 self._is_running = False
778 return result
779 finally:
780 if set_exception_handler:
781 loop.set_exception_handler(previous_exc_handler)
782
783 return await _run_async2()
784
785 def run(
786 self,
~/Projects/hypermind/env/lib/python3.8/site-packages/prompt_toolkit/application/application.py in cancel_and_wait_for_background_tasks(self=<prompt_toolkit.application.application.Application object>)
857
858 async def cancel_and_wait_for_background_tasks(self) -> None:
859 """
860 Cancel all background tasks, and wait for the cancellation to be done.
861 If any of the background tasks raised an exception, this will also
862 propagate the exception.
863
864 (If we had nurseries like Trio, this would be the `__aexit__` of a
865 nursery.)
866 """
867 for task in self.background_tasks:
868 task.cancel()
869
870 for task in self.background_tasks:
871 try:
--> 872 await task
task = <Task finished name='Task-53' coro=<Buffer._create_completer_coroutine.<locals>.async_completer() done, defined at /Users/damian/Projects/hypermind/env/lib/python3.8/site-packages/prompt_toolkit/buffer.py:1841> exception=NameError("name 'sys' is not defined")>
873 except CancelledError:
874 pass
875
876 def cpr_not_supported_callback(self) -> None:
877 """
878 Called when we don't receive the cursor position response in time.
879 """
880 if not self.output.responds_to_cpr:
881 return # We know about this already.
882
883 def in_terminal() -> None:
884 self.output.write(
885 "WARNING: your terminal doesn't support cursor position requests (CPR).\r\n"
886 )
887 self.output.flush()
~/Projects/hypermind/env/lib/python3.8/site-packages/prompt_toolkit/buffer.py in new_coroutine(*a=(), **kw={'complete_event': CompleteEvent(text_inserted=False, completion_requested=True), 'insert_common_part': True, 'select_first': False, 'select_last': False})
1839 running = False
1840
1841 @wraps(coroutine)
1842 async def new_coroutine(*a: Any, **kw: Any) -> Any:
1843 nonlocal running
1844
1845 # Don't start a new function, if the previous is still in progress.
1846 if running:
1847 return
1848
1849 running = True
1850
1851 try:
1852 while True:
1853 try:
-> 1854 await coroutine(*a, **kw)
global coroutine = undefined
a = ()
kw = {'select_first': False, 'select_last': False, 'insert_common_part': True, 'complete_event': CompleteEvent(text_inserted=False, completion_requested=True)}
1855 except _Retry:
1856 continue
1857 else:
1858 return None
1859 finally:
1860 running = False
1861
1862 return cast(_T, new_coroutine)
1863
1864
1865 class _Retry(Exception):
1866 " Retry in `_only_one_at_a_time`. "
1867
1868
1869 def indent(buffer: Buffer, from_row: int, to_row: int, count: int = 1) -> None:
~/Projects/hypermind/env/lib/python3.8/site-packages/prompt_toolkit/buffer.py in async_completer(select_first=False, select_last=False, insert_common_part=True, complete_event=CompleteEvent(text_inserted=False, completion_requested=True))
1668 complete_event = complete_event or CompleteEvent(text_inserted=True)
1669
1670 # Don't complete when we already have completions.
1671 if self.complete_state or not self.completer:
1672 return
1673
1674 # Create an empty CompletionState.
1675 complete_state = CompletionState(original_document=self.document)
1676 self.complete_state = complete_state
1677
1678 def proceed() -> bool:
1679 """Keep retrieving completions. Input text has not yet changed
1680 while generating completions."""
1681 return self.complete_state == complete_state
1682
-> 1683 async for completion in self.completer.get_completions_async(
completion = undefined
global self.completer.get_completions_async = undefined
document = Document('Edge', 4)
complete_event = CompleteEvent(text_inserted=False, completion_requested=True)
1684 document, complete_event
1685 ):
1686 complete_state.completions.append(completion)
1687 self.on_completions_changed.fire()
1688
1689 # If the input text changes, abort.
1690 if not proceed():
1691 break
1692
1693 completions = complete_state.completions
1694
1695 # When there is only one completion, which has nothing to add, ignore it.
1696 if len(completions) == 1 and completion_does_nothing(
1697 document, completions[0]
1698 ):
~/Projects/hypermind/env/lib/python3.8/site-packages/prompt_toolkit/completion/base.py in get_completions_async(self=DynamicCompleter(<function PromptSession._create...tutils.IPythonPTCompleter object at 0x103edd5e0>), document=Document('Edge', 4), complete_event=CompleteEvent(text_inserted=False, completion_requested=True))
254
255 def __init__(self, get_completer: Callable[[], Optional[Completer]]) -> None:
256 self.get_completer = get_completer
257
258 def get_completions(
259 self, document: Document, complete_event: CompleteEvent
260 ) -> Iterable[Completion]:
261 completer = self.get_completer() or DummyCompleter()
262 return completer.get_completions(document, complete_event)
263
264 async def get_completions_async(
265 self, document: Document, complete_event: CompleteEvent
266 ) -> AsyncGenerator[Completion, None]:
267 completer = self.get_completer() or DummyCompleter()
268
--> 269 async for completion in completer.get_completions_async(
completion = undefined
completer.get_completions_async = <bound method Completer.get_completions_async of <IPython.terminal.ptutils.IPythonPTCompleter object at 0x103edd5e0>>
document = Document('Edge', 4)
complete_event = CompleteEvent(text_inserted=False, completion_requested=True)
270 document, complete_event
271 ):
272 yield completion
273
274 def __repr__(self) -> str:
275 return "DynamicCompleter(%r -> %r)" % (self.get_completer, self.get_completer())
276
277
278 class _MergedCompleter(Completer):
279 """
280 Combine several completers into one.
281 """
282
283 def __init__(self, completers: Sequence[Completer]) -> None:
284 self.completers = completers
~/Projects/hypermind/env/lib/python3.8/site-packages/prompt_toolkit/completion/base.py in get_completions_async(self=<IPython.terminal.ptutils.IPythonPTCompleter object>, document=Document('Edge', 4), complete_event=CompleteEvent(text_inserted=False, completion_requested=True))
181 :param document: :class:`~prompt_toolkit.document.Document` instance.
182 :param complete_event: :class:`.CompleteEvent` instance.
183 """
184 while False:
185 yield
186
187 async def get_completions_async(
188 self, document: Document, complete_event: CompleteEvent
189 ) -> AsyncGenerator[Completion, None]:
190 """
191 Asynchronous generator for completions. (Probably, you won't have to
192 override this.)
193
194 Asynchronous generator of :class:`.Completion` objects.
195 """
--> 196 for item in self.get_completions(document, complete_event):
item = undefined
self.get_completions = <bound method IPythonPTCompleter.get_completions of <IPython.terminal.ptutils.IPythonPTCompleter object at 0x103edd5e0>>
document = Document('Edge', 4)
complete_event = CompleteEvent(text_inserted=False, completion_requested=True)
197 yield item
198
199
200 class ThreadedCompleter(Completer):
201 """
202 Wrapper that runs the `get_completions` generator in a thread.
203
204 (Use this to prevent the user interface from becoming unresponsive if the
205 generation of completions takes too much time.)
206
207 The completions will be displayed as soon as they are produced. The user
208 can already select a completion, even if not all completions are displayed.
209 """
210
211 def __init__(self, completer: Completer) -> None:
~/Projects/hypermind/env/lib/python3.8/site-packages/IPython/terminal/ptutils.py in get_completions(self=<IPython.terminal.ptutils.IPythonPTCompleter object>, document=Document('Edge', 4), complete_event=CompleteEvent(text_inserted=False, completion_requested=True))
101 return
102 # Some bits of our completion system may print stuff (e.g. if a module
103 # is imported). This context manager ensures that doesn't interfere with
104 # the prompt.
105
106 with patch_stdout(), provisionalcompleter():
107 body = document.text
108 cursor_row = document.cursor_position_row
109 cursor_col = document.cursor_position_col
110 cursor_position = document.cursor_position
111 offset = cursor_to_position(body, cursor_row, cursor_col)
112 try:
113 yield from self._get_completions(body, offset, cursor_position, self.ipy_completer)
114 except Exception as e:
115 try:
--> 116 exc_type, exc_value, exc_tb = sys.exc_info()
exc_type = undefined
exc_value = undefined
exc_tb = undefined
global sys.exc_info = undefined
117 traceback.print_exception(exc_type, exc_value, exc_tb)
118 except AttributeError:
119 print('Unrecoverable Error in completions')
120
121 @staticmethod
122 def _get_completions(body, offset, cursor_position, ipyc):
123 """
124 Private equivalent of get_completions() use only for unit_testing.
125 """
126 debug = getattr(ipyc, 'debug', False)
127 completions = _deduplicate_completions(
128 body, ipyc.completions(body, offset))
129 for c in completions:
130 if not c.text:
131 # Guard against completion machinery giving us an empty string.
NameError: name 'sys' is not defined
***************************************************************************
History of session input:get_ipython().run_line_magic('config', 'Application.verbose_crash=True')from hypergraph.models import Vertex, Edge
*** Last line of input (may not be in above history):
from hypergraph.models import Vertex, Edge
Ok that was easy.
The Jedi release on 12/25 version 0.18.0 is breaking tab completion.
pip install --upgrade 'jedi<0.18.0'
gets you going.
I can also confirm the issue is related to Jedi as @yurzo kindly pointed out and not ipython. It took me a moment to figure that out. Here's what I was seeing.
$ pip list
Package Version
---------------- -------------------
appnope 0.1.2
backcall 0.2.0
certifi 2020.12.5
decorator 4.4.2
ipython 7.19.0
ipython-genutils 0.2.0
jedi 0.18.0
parso 0.8.1
pexpect 4.8.0
pickleshare 0.7.5
pip 20.3.3
prompt-toolkit 3.0.8
ptyprocess 0.7.0
Pygments 2.7.3
setuptools 51.0.0.post20201207
traitlets 5.0.5
wcwidth 0.2.5
wheel 0.36.2
$ ipython
Python 3.8.5 (default, Sep 4 2020, 02:22:02)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.19.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import sys
In [2]: sys.
Traceback (most recent call last):
File "/usr/local/Caskroom/miniconda/base/envs/jenkins/lib/python3.8/site-packages/IPython/terminal/ptutils.py", line 113, in get_completions
yield from self._get_completions(body, offset, cursor_position, self.ipy_completer)
File "/usr/local/Caskroom/miniconda/base/envs/jenkins/lib/python3.8/site-packages/IPython/terminal/ptutils.py", line 129, in _get_completions
for c in completions:
File "/usr/local/Caskroom/miniconda/base/envs/jenkins/lib/python3.8/site-packages/IPython/core/completer.py", line 438, in _deduplicate_completions
completions = list(completions)
File "/usr/local/Caskroom/miniconda/base/envs/jenkins/lib/python3.8/site-packages/IPython/core/completer.py", line 1818, in completions
for c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000):
File "/usr/local/Caskroom/miniconda/base/envs/jenkins/lib/python3.8/site-packages/IPython/core/completer.py", line 1861, in _completions
matched_text, matches, matches_origin, jedi_matches = self._complete(
File "/usr/local/Caskroom/miniconda/base/envs/jenkins/lib/python3.8/site-packages/IPython/core/completer.py", line 2029, in _complete
completions = self._jedi_matches(
File "/usr/local/Caskroom/miniconda/base/envs/jenkins/lib/python3.8/site-packages/IPython/core/completer.py", line 1373, in _jedi_matches
interpreter = jedi.Interpreter(
File "/usr/local/Caskroom/miniconda/base/envs/jenkins/lib/python3.8/site-packages/jedi/api/__init__.py", line 725, in __init__
super().__init__(code, environment=environment,
TypeError: __init__() got an unexpected keyword argument 'column'
The fix was exactly as pointed out here: https://github.com/ipython/ipython/issues/12745#issuecomment-751892538
This looks like a duplicate of https://github.com/ipython/ipython/issues/12740.
I get same issue with auto-completion
Python 3.9.1 (default, Dec 16 2020, 01:02:01)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.19.0 -- An enhanced Interactive Python. Type '?' for help.
<IPython.terminal.interactiveshell.TerminalInteractiveShell object at 0x7f924ddd0100>
Using matplotlib backend: Qt5Agg
Populating the interactive namespace from numpy and matplotlib
Unhandled exception in event loop:
File "/home/alex/Python/lib/python3.9/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "/home/alex/Python/lib/python3.9/site-packages/prompt_toolkit/input/vt100.py", line 169, in callback_wrapper
callback()
File "/home/alex/Python/lib/python3.9/site-packages/prompt_toolkit/application/application.py", line 666, in read_from_input
self.key_processor.process_keys()
File "/home/alex/Python/lib/python3.9/site-packages/prompt_toolkit/key_binding/key_processor.py", line 274, in process_keys
self._process_coroutine.send(key_press)
File "/home/alex/Python/lib/python3.9/site-packages/prompt_toolkit/key_binding/key_processor.py", line 186, in _process
self._call_handler(matches[-1], key_sequence=buffer[:])
File "/home/alex/Python/lib/python3.9/site-packages/prompt_toolkit/key_binding/key_processor.py", line 329, in _call_handler
handler.call(event)
File "/home/alex/Python/lib/python3.9/site-packages/prompt_toolkit/key_binding/key_bindings.py", line 101, in call
self.handler(event)
File "/home/alex/Python/lib/python3.9/site-packages/prompt_toolkit/key_binding/bindings/completion.py", line 65, in display_completions_like_readline
completions = list(b.completer.get_completions(b.document, complete_event))
File "/home/alex/Python/lib/python3.9/site-packages/IPython/terminal/ptutils.py", line 116, in get_completions
exc_type, exc_value, exc_tb = sys.exc_info()
Exception name 'sys' is not defined
Posted a pr to pin the dependency #12746
detectable with flake8
flake8 IPython/terminal/ptutils.py | grep F821
IPython/terminal/ptutils.py:116:51: F821 undefined name 'sys'
IPython/terminal/ptutils.py:117:21: F821 undefined name 'traceback'
I found the culprit, it seems that installing a fresh ipython package pulls over the recent jedi==0.18.0 and parso==0.8.1
I downgraded jedi to 0.17.2
and parso 0.7.1
and this error went away.
Not sure of the overall fix, but hopefully this helps anyone for a temp solution. also this solution is found in #12740
For those looking for a quick fix, here's @duysqubix's answer, distilled into a command:
pip install -U jedi==0.17.2 parso==0.7.1
Ugh, can we please stop re-posting the solution and trying to take credit where credit is not due. The bleeding has stopped, a fix has been put in by @yurzo there is no need to re-post the fix.
When is a release with the fix coming?
Most helpful comment
Ok that was easy.
The Jedi release on 12/25 version 0.18.0 is breaking tab completion.
pip install --upgrade 'jedi<0.18.0'
gets you going.