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
Closed

Fix DeprecationWarning on autocompletion with jedi 0.17.0 #12218

wants to merge 8 commits into from

Conversation

gorogoroumaru
Copy link
Contributor

@gorogoroumaru gorogoroumaru commented Apr 3, 2020

with jedi 0.17.0

In [1]: import warnings
In [2]: warnings.filters.remove(('ignore', None, DeprecationWarning, None, 0))
In [3]: a=0
In [4]: a.<TAB>

throws a deprecation warning below

DeprecationWarning: Providing the column is now done in the functions themselves like Script(...).complete(line, column)

So, I fixed it.

…unctions themselves like `Script(...).complete(line, column)`
…unctions themselves like `Script(...).complete(line, column)`
…unctions themselves like `Script(...).complete(line, column)`
Copy link
Contributor

@LucianaMarques LucianaMarques left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! It's just now clear to me why your changes fixed the problem. Could you please give us some running examples?

(I'm unable at this moment to run the project, so that would help me)

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.

@@ -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?

…unctions themselves like `Script(...).complete(line, column)`
@gorogoroumaru
Copy link
Contributor Author

gorogoroumaru commented Apr 7, 2020

Running Examples

IPython 8.0.0.dev

[before]

In [1]: import jedi

In [2]: jedi.__version__
Out[2]: '0.17.0'

In [3]: import warnings

In [4]: warnings.filters.remove(('ignore', None, DeprecationWarning, None, 0))

In [5]: a=0

In [6]: a.<tab>
\Anaconda3\envs\jedi\lib\site-packages\jedi-0.17.0-py3.8.egg\jedi\api\__init__.py:841: DeprecationWarning: Providing the line is now done in the functions themselves like `Script(...).complete(line, column)`
  super(Interpreter, self).__init__(code, environment=environment,
\Anaconda3\envs\jedi\lib\site-packages\jedi-0.17.0-py3.8.egg\jedi\api\__init__.py:841: DeprecationWarning: Providing the column is now done in the functions themselves like `Script(...).complete(line, column)`
  super(Interpreter, self).__init__(code, environment=environment,

[after]

In [1]: import jedi

In [2]: jedi.__version__
Out[2]: '0.17.0'

In [3]: import warnings

In [4]: warnings.filters.remove(('ignore', None, DeprecationWarning, None, 0))

In [5]: a=0

In [6]: a.<tab>

No Warnings

@gorogoroumaru
Copy link
Contributor Author

gorogoroumaru commented Apr 10, 2020

I couldn't pass the travis-ci checks, so I closed this PR and created another PR #12227.

@Carreau Carreau added this to the no action milestone May 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants