Closed adriano-pinaffo closed 4 years ago
Thanks for the detailed report. I was able to repro.
I think this is a jedi bug. All of line
, column
and module_path
are None
.
>>> import jedi
>>> source = 'import numpy;numpy.cos(5)'
>>> script = jedi.Script(source)
>>> script.goto(1, 20)
[<Definition full_name='numpy.core._multiarray_umath.cos', description='instance cos'>]
>>> definition = script.goto(1, 20)[0]
>>> definition.line
>>> definition.column
>>> definition.module_path
>>> definition.line is None and definition.column is None and definition.module_path is None
True
@davidhalter Is jedi supposed to return this kind of definitions? Or is ycmd supposed to handle essentially empty definitions?
@davidhalter Is jedi supposed to return this kind of definitions? Or is ycmd supposed to handle essentially empty definitions?
This is not a Jedi bug. It's perfectly reasonable for all of them to be None. On some systems there's quite a few "builtin" modules that have no module path and no line/column. Before typeshed this was even the case for the most used module of Python: builtins
(e.g. str
).
I got exactly the same Error.
"GoToDefinitionElseDeclaration" works sometimes but it will also throw out the same error as @adriano-pinaffo.
What's more, in the case where "GoToDefinitionElseDeclaration" works, it will jump to somewhere else, but not the path related to virtualenv.
For example, when I code " import time " in my python script and cursor on " time ", then "GoToDefinitionElseDeclaration", YCM will jump to "~/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/jedi_deps/jedi/jedi/third_party/typeshed/stdlib/2and3/time.pyi"
@JunweiZheng93 we have acknowledged this is a bug. PRs are always welcome to fix .... :)
ycm-core/ycmd#1444 should solve this.
same problem on Mac. Could anybody tell me the detail of solution?
Go in YCM/third_party/ycmd
and pull in the latest master.
still has the problem, When I try to goto define of bumpy.zero I'm using virtualenv of python3.8.3, is that any problems?
Error detected while processing function <SNR>327_CompleterCommand:
line 1:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/chenxu/.vim/plugged/YouCompleteMe/python/ycm/youcompleteme.py", line 415, in SendCommandRequest
return SendCommandRequest( final_arguments,
File "/Users/chenxu/.vim/plugged/YouCompleteMe/python/ycm/client/command_request.py", line 179, in SendCommandRequest
request.RunPostCommandActionsIfNeeded( modifiers )
File "/Users/chenxu/.vim/plugged/YouCompleteMe/python/ycm/client/command_request.py", line 81, in RunPostCommandActionsIfNeeded
return self._HandleGotoResponse( modifiers )
File "/Users/chenxu/.vim/plugged/YouCompleteMe/python/ycm/client/command_request.py", line 121, in _HandleGotoResponse
vimsupport.JumpToLocation( self._response[ 'filepath' ],
File "/Users/chenxu/.vim/plugged/YouCompleteMe/python/ycm/vimsupport.py", line 574, in JumpToLocation
vim.current.window.cursor = ( line, column - 1 )
TypeError: an integer is required (got type NoneType)
I'm using virtualenv of python3.8.3, is that any problems?
No, but if you still have a problem, you'll have to do more that say "doesn't work".
Check git log
and confirm that ycm-core/ycmd#1444 is really in your history. If you do still have a problem, show us steps to reproduce.
Issue Prelude
Please complete these steps and check these boxes (by putting an
x
inside the brackets) before filing your issue:vim --version
.:YcmDebugInfo
.:YcmToggleLogs
command.vim -Nu /path/to/YCM/vimrc_ycm_minimal
, including what I expected to happen and what actually happened.install.py
(orcmake
/make
/ninja
) including its invocationThank you for adhering to this process! It ensures your issue is resolved quickly and that neither your nor our time is needlessly wasted.
Issue Details
First of all, the autocompletion suggestion works fine:
Second, if I rest the cursor on top of the method, part of the package installed in the virtual environment ycm shows the tooltip:
PS: in .vimrc I have the following map to crate a shortcut ("\g") to goto: mapg :YcmCompleter GoToDefinitionElseDeclaration
When in a virtual environment, I have packages installed with pip, only available in that virtual environment. Obviously inside vim, with ycm, when I place my cursor in a method (from that specific package and pressg, it won't follow, ycm needs to be able to see that virtual environment. So, first I followed this, which means I created this below, inside my project folder (that is, the same folder where my project01.py file is):
my project01.py:
When open my project01.py (
vim project01.py
) I get the following message:I enter O, position my cursor in the word "cos", part of numpy.cos() and press "\g", then I get:
I also tried this global config. I removed the extra conf file:
$ rm .ycm_extra_conf.py
Then added the following to the .vimrc:Then I create in my home folder the following file:
when I open the .py file (
vim project01.py
), position the cursor in the "cos" word and press "\g" I get the same error message:I also tried this approach, which by the way, seems really neat if it works (you may want to add it to the guide if it works). So, I configured my .vimrc like this: PS.: I addapted from py2 to py3, but I believe the essence should be the same.
But when I do the same process (open my .py file, position the cursor and pres \g) I get the same error as before.
Included above
vim -Nu /path/to/YCM/ycm_vimrc_minimal
:edit test.py
.....
5 dots give me nothing, 4 dots give me the below code:
Included above
I expected ycm to open the class located in a package that was installed with pip in a virtual environment
It gave me the following error (as shown above):
Screenshot of the error:
Diagnostic data
Output of
vim --version
Output of
YcmDebugInfo
Output of
YcmDiags
No warnings or errors detected.
Output of
git rev-parse HEAD
in YouCompleteMe installation directoryContents of YCM, ycmd and completion engine logfiles
Loading with vim -Nu /path/to/YCM/vimrc_ycm_minimal (
vim -Nu ~/.vim/bundle/YouCompleteMe/vimrc_ycm_minimal project01.py
) I get the exact same error. PS.: For this test, I have the local .ycm_extra_conf.py and I try to jump using:YcmCompleter GoToDefinitionElseDeclaration
1 2 3
OS version, distribution, etc.
Output of build/install commands
Not an installation issue.