Skip to content
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

Fix DeprecationWarning on autocompletion with jedi 0.17.0 #12218

Closed
wants to merge 8 commits into from
7 changes: 3 additions & 4 deletions IPython/core/completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1371,15 +1371,14 @@ def _jedi_matches(self, cursor_column:int, cursor_line:int, text:str):
else:
raise ValueError("Don't understand self.omit__names == {}".format(self.omit__names))

interpreter = jedi.Interpreter(
text[:offset], namespaces, column=cursor_column, line=cursor_line + 1)
script = jedi.Interpreter(text[:offset],namespaces)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change the name here from interpreter to script?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it’s my mistake.
I will fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I changed the variable name to “interpreter”, some checks were not successful.
Why?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change!

About the errors, I don't know why but you can check the tests results by clicking on details right next to them. I will try to take a look with it too tomorrow!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which is your local python version? On one of the failed checks, there is the following message:

Extension error:
Could not import extension configtraits (exception: cannot import name 'l_' from 'sphinx.locale' (/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/sphinx/locale/__init__.py))
Makefile:66: recipe for target 'html' failed
make: *** [html] Error 2
make: Leaving directory '/home/travis/build/ipython/ipython/docs'
The command "if [[ "$TRAVIS_PYTHON_VERSION" == "3.7" ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
  pip install -r docs/requirements.txt
  python tools/fixup_whats_new_pr.py
  make -C docs/ html SPHINXOPTS="-W"
fi
" exited with 2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anaconda python3.7.7 is my local python version.
But why my local python version affects travis-CI checks?

try_jedi = True

try:
# find the first token in the current tree -- if it is a ' or " then we are in a string
completing_string = False
try:
first_child = next(c for c in interpreter._get_module().tree_node.children if hasattr(c, 'value'))
first_child = next(c for c in script._get_module().tree_node.children if hasattr(c, 'value'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you keep interpreter you don't have to change the following lines.

except StopIteration:
pass
else:
Expand All @@ -1399,7 +1398,7 @@ def _jedi_matches(self, cursor_column:int, cursor_line:int, text:str):
if not try_jedi:
return []
try:
return filter(completion_filter, interpreter.complete())
return filter(completion_filter, script.complete(column=cursor_column, line=cursor_line + 1))
except Exception as e:
if self.debug:
return [_FakeJediCompletion('Oops Jedi has crashed, please report a bug with the following:\n"""\n%s\ns"""' % (e))]
Expand Down