ycm-core / YouCompleteMe

A code-completion engine for Vim
http://ycm-core.github.io/YouCompleteMe/
GNU General Public License v3.0
25.44k stars 2.81k forks source link

in Python virtualenv, goto is failing with: TypeError: an integer is required (got type NoneType) #3665

Closed adriano-pinaffo closed 4 years ago

adriano-pinaffo commented 4 years ago

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside the brackets) before filing your issue:

Thank 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

Provide a clear description of the problem, including the following key questions:

First of all, the autocompletion suggestion works fine: Screenshot_20200501_161632

Second, if I rest the cursor on top of the method, part of the package installed in the virtual environment ycm shows the tooltip: Screenshot_20200501_161600

PS: in .vimrc I have the following map to crate a shortcut ("\g") to goto: map g :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 press g, 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):

$ cat .ycm_extra_conf.py 
def Settings( **kwargs ):
  return {
    'interpreter_path': '/home/myuser/Documents/virtualenv/project01_env/bin/python'
  }

my project01.py:

$ cat project01.py 
import numpy

print(numpy.cos(5))

When open my project01.py (vim project01.py) I get the following message:

Found /home/myuser/Documents/virtualenv/.ycm_extra_conf.py. Load?

(Question can be turned off with options, see YCM docs) [O]k, (C)ancel:

I enter O, position my cursor in the word "cos", part of numpy.cos() and press "\g", then I get:

Error detected while processing function 34_CompleterCommand: line 1: Traceback (most recent call last): File "", line 1, in File "/home/myuser/.vim/bundle/YouCompleteMe/python/ycm/youcompleteme.py", line 415, in SendCommandRequest return SendCommandRequest( final_arguments, File "/home/myuser/.vim/bundle/YouCompleteMe/python/ycm/client/command_request.py", line 179, in SendCommandRequest request.RunPostCommandActionsIfNeeded( modifiers ) File "/home/myuser/.vim/bundle/YouCompleteMe/python/ycm/client/command_request.py", line 81, in RunPostCommandActionsIfNeeded return self._HandleGotoResponse( modifiers ) File "/home/myuser/.vim/bundle/YouCompleteMe/python/ycm/client/command_request.py", line 121, in _HandleGotoResponse vimsupport.JumpToLocation( self._response[ 'filepath' ], File "/home/myuser/.vim/bundle/YouCompleteMe/python/ycm/vimsupport.py", line 574, in JumpToLocation vim.current.window.cursor = ( line, column - 1 ) TypeError: an integer is required (got type NoneType) Press ENTER or type command to continue

I also tried this global config. I removed the extra conf file: $ rm .ycm_extra_conf.py Then added the following to the .vimrc:

let g:ycm_python_interpreter_path = ''
let g:ycm_python_sys_path = []
let g:ycm_extra_conf_vim_data = [
  \  'g:ycm_python_interpreter_path',
  \  'g:ycm_python_sys_path'
  \]
let g:ycm_global_ycm_extra_conf = '~/global_extra_conf.py'

Then I create in my home folder the following file:

$ cat ~/global_extra_conf.py 
def Settings( **kwargs ):
  client_data = kwargs[ 'client_data' ]
  return {
    'interpreter_path': client_data[ 'g:ycm_python_interpreter_path' ],
    'sys_path': client_data[ 'g:ycm_python_sys_path' ]
  }

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:

Error detected while processing function 34_CompleterCommand: line 1: Traceback (most recent call last): File "", line 1, in File "/home/myuser/.vim/bundle/YouCompleteMe/python/ycm/youcompleteme.py", line 415, in SendCommandRequest return SendCommandRequest( final_arguments, File "/home/myuser/.vim/bundle/YouCompleteMe/python/ycm/client/command_request.py", line 179, in SendCommandRequest request.RunPostCommandActionsIfNeeded( modifiers ) File "/home/myuser/.vim/bundle/YouCompleteMe/python/ycm/client/command_request.py", line 81, in RunPostCommandActionsIfNeeded return self._HandleGotoResponse( modifiers ) File "/home/myuser/.vim/bundle/YouCompleteMe/python/ycm/client/command_request.py", line 121, in _HandleGotoResponse vimsupport.JumpToLocation( self._response[ 'filepath' ], File "/home/myuser/.vim/bundle/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 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.

py3 << EOF
import os
import sys
if 'VIRTUAL_ENV' in os.environ:
  project_base_dir = os.environ['VIRTUAL_ENV']
  activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
  exec(open(activate_this).read(), dict(__file__=activate_this))
EOF

But when I do the same process (open my .py file, position the cursor and pres \g) I get the same error as before.

Include steps to reproduce here.

Included above

  1. vim -Nu /path/to/YCM/ycm_vimrc_minimal
  2. :edit test.py
  3. Enter insert mode and type .....

5 dots give me nothing, 4 dots give me the below code:

....
~       __annotations__   s __annotations__: Dict[str, Any]                                                                                         
~       __class__         f def __class__()                                                                                                         
~       __delattr__       f def __delattr__(name: str)                                                                                              
~       __dict__          s __dict__: Dict[str, Any]                                                                                                
~       __dir__           f def __dir__()                                                                                                           
~       __doc__           s __doc__: Optional[str]()                                                                                                
~       __eq__            f def __eq__(o: object)                                                                                                   
~       __format__        f def __format__(format_spec: str)                                                                                        
~       __getattribute__  f def __getattribute__(name: str)                                                                                         
~       __hash__          f def __hash__()                                                                                                          
~       __init_subclass__ f def __init_subclass__()                                                                                                 
~       __init__          f def __init__()                                                                                                          
~       __module__        s __module__: str                                                                                                         
~       __new__           f def __new__()                                                                                                           
~       __ne__            f def __ne__(o: object)                                                                                                   
~       __reduce_ex__     f def __reduce_ex__(protocol: int)                                                                                        
~       __reduce__        f def __reduce__()                                                                                                        
~       __repr__          f def __repr__()                                                                                                          
~       __setattr__       f def __setattr__(name: str, value: Any)                                                                                  
~       __sizeof__        f def __sizeof__()                                                                                                        
~       __slots__         s __slots__: Union[Text, Iterable[Text]]                                                                                  
~       __str__           f def __str__()

Include description of a minimal test case, including any actual code required to reproduce the issue.

Included above

If you made changes to vimrc_ycm_minimal, pase them here:

No changes made

Include description of the expected behaviour.

I expected ycm to open the class located in a package that was installed with pip in a virtual environment

Include description of the observed behaviour, including actual output, screenshots, etc.

It gave me the following error (as shown above):

Error detected while processing function <SNR>34_CompleterCommand:
line    1:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/myuser/.vim/bundle/YouCompleteMe/python/ycm/youcompleteme.py", line 415, in SendCommandRequest
    return SendCommandRequest( final_arguments,
  File "/home/myuser/.vim/bundle/YouCompleteMe/python/ycm/client/command_request.py", line 179, in SendCommandRequest
    request.RunPostCommandActionsIfNeeded( modifiers )
  File "/home/myuser/.vim/bundle/YouCompleteMe/python/ycm/client/command_request.py", line 81, in RunPostCommandActionsIfNeeded
    return self._HandleGotoResponse( modifiers )
  File "/home/myuser/.vim/bundle/YouCompleteMe/python/ycm/client/command_request.py", line 121, in _HandleGotoResponse
    vimsupport.JumpToLocation( self._response[ 'filepath' ],
  File "/home/myuser/.vim/bundle/YouCompleteMe/python/ycm/vimsupport.py", line 574, in JumpToLocation
    vim.current.window.cursor = ( line, column - 1 )
TypeError: an integer is required (got type NoneType)

Screenshot of the error: Screenshot_20200501_161516

Diagnostic data

Output of vim --version

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr  4 2020 13:23:00)
Included patches: 1-510
Compiled by Arch Linux
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               -farsi             -mouse_sysmouse    -tag_old_static
+arabic            +file_in_path      +mouse_urxvt       -tag_any_white
+autocmd           +find_in_path      +mouse_xterm       +tcl/dyn
+autochdir         +float             +multi_byte        +termguicolors
-autoservername    +folding           +multi_lang        +terminal
+balloon_eval      -footer            -mzscheme          +terminfo
+balloon_eval_term +fork()            +netbeans_intg     +termresponse
+browse            +gettext           +num64             +textobjects
++builtin_terms    -hangul_input      +packages          +textprop
+byte_offset       +iconv             +path_extra        +timers
+channel           +insert_expand     +perl/dyn          +title
+cindent           +job               +persistent_undo   +toolbar
+clientserver      +jumplist          +popupwin          +user_commands
+clipboard         +keymap            +postscript        +vartabs
+cmdline_compl     +lambda            +printer           +vertsplit
+cmdline_hist      +langmap           +profile           +virtualedit
+cmdline_info      +libcall           +python/dyn        +visual
+comments          +linebreak         +python3/dyn       +visualextra
+conceal           +lispindent        +quickfix          +viminfo
+cryptv            +listcmds          +reltime           +vreplace
+cscope            +localmap          +rightleft         +wildignore
+cursorbind        +lua/dyn           +ruby/dyn          +wildmenu
+cursorshape       +menu              +scrollbind        +windows
+dialog_con_gui    +mksession         +signs             +writebackup
+diff              +modify_fname      +smartindent       +X11
+digraphs          +mouse             +sound             -xfontset
+dnd               +mouseshape        +spell             +xim
-ebcdic            +mouse_dec         +startuptime       -xpm
+emacs_tags        +mouse_gpm         +statusline        +xsmp_interact
+eval              -mouse_jsbterm     -sun_workshop      +xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +tag_binary        
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "/etc/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/libffi-3.2.1/include -I/usr/include/harfbuzz -I/usr/include/fribidi -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gio-unix-2.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/at-spi-2.0 -pthread    -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -D_REENTRANT  -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.30/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0  -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lelf -lnsl    -lcanberra  -lacl -lattr -lgpm -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.30/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/perl5/5.30/core_perl/CORE -lperl -lpthread -ldl -lm -lcrypt -lutil -lc   -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lm

Output of YcmDebugInfo

Printing YouCompleteMe debug information...
-- Completion API: 1
-- Client logfile: /tmp/ycm_aqea8d28.log
-- Server Python interpreter: /usr/bin/python
-- Server Python version: 3.8.2
-- Server has Clang support compiled in: True
-- Clang version: clang version 10.0.0 (https://github.com/ycm-core/llvm 038587147cf2f97d1c3e677042f69560c65b5bea)
-- No extra configuration file found
-- Python completer debug information:
--   Python interpreter: /home/myuser/Documents/virtualenv/project01_env/bin/python
--   Python root: /home/myuser/Documents/virtualenv
--   Python path: ['/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/myuser/Documents/virtualenv/project01_env/
lib/python3.8/site-packages']
--   Python version: 3.8.2
--   Jedi version: 0.17.0
--   Parso version: 0.7.0
-- Server running at: http://127.0.0.1:40037
-- Server process ID: 319314
-- Server logfiles:
--   /tmp/ycmd_40037_stdout_6b5abf8p.log
--   /tmp/ycmd_40037_stderr_jseahvt1.log
$ cat /tmp/ycmd_40037_stdout_6b5abf8p.log
serving on http://localhost:40037
$ cat /tmp/ycmd_40037_stderr_jseahvt1.log
2020-05-01 16:13:16,517 - INFO - Received ready request
2020-05-01 16:13:16,524 - INFO - Received signature help available request
2020-05-01 16:13:16,530 - INFO - Received event notification
2020-05-01 16:13:16,533 - INFO - Received event notification
2020-05-01 16:13:16,533 - INFO - Adding buffer identifiers for file: /home/myuser/Documents/virtualenv/project01.py
2020-05-01 16:13:16,732 - INFO - Received filetype completion available request
2020-05-01 16:13:19,429 - INFO - Received command request
2020-05-01 16:13:28,842 - INFO - Received command request
2020-05-01 16:13:39,890 - INFO - Received defined subcommands request
2020-05-01 16:13:39,895 - INFO - Received command request
2020-05-01 16:13:43,959 - INFO - Received command request
2020-05-01 16:13:49,678 - INFO - Received command request
2020-05-01 16:13:58,893 - INFO - Received command request
2020-05-01 16:14:05,861 - INFO - Received command request
2020-05-01 16:14:13,358 - INFO - Received command request
2020-05-01 16:14:25,019 - INFO - Received event notification
2020-05-01 16:14:25,429 - INFO - Received event notification
2020-05-01 16:14:26,031 - INFO - Received event notification
2020-05-01 16:14:26,070 - INFO - Received event notification
2020-05-01 16:14:26,116 - INFO - Received event notification
2020-05-01 16:14:26,156 - INFO - Received event notification
2020-05-01 16:14:26,198 - INFO - Received event notification
2020-05-01 16:14:26,236 - INFO - Received event notification
2020-05-01 16:14:26,277 - INFO - Received event notification
2020-05-01 16:14:26,320 - INFO - Received event notification
2020-05-01 16:14:26,359 - INFO - Received event notification
2020-05-01 16:14:26,397 - INFO - Received event notification
2020-05-01 16:14:26,436 - INFO - Received event notification
2020-05-01 16:14:26,480 - INFO - Received event notification
2020-05-01 16:14:28,698 - INFO - Received event notification
2020-05-01 16:14:28,700 - INFO - Received event notification
2020-05-01 16:14:28,700 - INFO - Adding buffer identifiers for file: /home/myuser/Documents/virtualenv/project01.py
2020-05-01 16:14:32,549 - INFO - Received command request
2020-05-01 16:14:39,516 - INFO - Received event notification
2020-05-01 16:14:39,699 - INFO - Received event notification
2020-05-01 16:14:39,853 - INFO - Received event notification
2020-05-01 16:14:39,962 - INFO - Received event notification
2020-05-01 16:14:40,085 - INFO - Received event notification
2020-05-01 16:14:40,205 - INFO - Received event notification
2020-05-01 16:14:40,338 - INFO - Received event notification
2020-05-01 16:14:40,474 - INFO - Received event notification
2020-05-01 16:14:40,606 - INFO - Received event notification
2020-05-01 16:14:40,729 - INFO - Received event notification
2020-05-01 16:14:40,867 - INFO - Received event notification
2020-05-01 16:14:40,997 - INFO - Received event notification
2020-05-01 16:14:42,375 - INFO - Received event notification
2020-05-01 16:14:42,503 - INFO - Received event notification
2020-05-01 16:14:42,643 - INFO - Received event notification
2020-05-01 16:14:42,782 - INFO - Received event notification
2020-05-01 16:14:42,921 - INFO - Received event notification
2020-05-01 16:14:43,043 - INFO - Received event notification
2020-05-01 16:14:44,455 - INFO - Received event notification
2020-05-01 16:14:44,456 - INFO - Adding buffer identifiers for file: /home/myuser/Documents/virtualenv/project01.py
2020-05-01 16:14:44,458 - INFO - Received event notification
2020-05-01 16:14:48,751 - INFO - Received command request
2020-05-01 16:15:29,465 - INFO - Received event notification
2020-05-01 16:15:29,466 - INFO - Adding buffer identifiers for file: /home/myuser/Documents/virtualenv/project01.py
2020-05-01 16:15:31,453 - INFO - Received event notification
2020-05-01 16:15:31,454 - INFO - Adding buffer identifiers for file: /home/myuser/Documents/virtualenv/project01.py
2020-05-01 16:15:31,757 - INFO - Received event notification
2020-05-01 16:15:31,758 - INFO - Adding buffer identifiers for file: /home/myuser/Documents/virtualenv/project01.py
2020-05-01 16:15:32,042 - INFO - Received event notification
2020-05-01 16:15:32,042 - INFO - Adding buffer identifiers for file: /home/myuser/Documents/virtualenv/project01.py
2020-05-01 16:15:32,327 - INFO - Received event notification
2020-05-01 16:15:32,328 - INFO - Adding buffer identifiers for file: /home/myuser/Documents/virtualenv/project01.py
2020-05-01 16:15:32,637 - INFO - Received event notification
2020-05-01 16:15:32,638 - INFO - Adding buffer identifiers for file: /home/myuser/Documents/virtualenv/project01.py
2020-05-01 16:15:33,301 - INFO - Received event notification
2020-05-01 16:15:33,301 - INFO - Adding buffer identifiers for file: /home/myuser/Documents/virtualenv/project01.py
2020-05-01 16:15:34,299 - INFO - Received event notification
2020-05-01 16:15:34,299 - INFO - Adding buffer identifiers for file: /home/myuser/Documents/virtualenv/project01.py
2020-05-01 16:15:40,635 - INFO - Received command request
2020-05-01 16:15:44,721 - INFO - Received command request
2020-05-01 16:15:48,792 - INFO - Received command request
2020-05-01 16:15:52,893 - INFO - Received command request
2020-05-01 16:15:56,958 - INFO - Received command request
2020-05-01 16:16:01,037 - INFO - Received command request
2020-05-01 16:16:07,348 - INFO - Received completion request
2020-05-01 16:16:07,357 - INFO - Received signature help request
2020-05-01 16:16:08,562 - INFO - Received event notification
2020-05-01 16:16:08,562 - INFO - Adding ONE buffer identifier for file: /home/myuser/Documents/virtualenv/project01.py
2020-05-01 16:16:08,564 - INFO - Received completion request
2020-05-01 16:16:08,567 - INFO - Received signature help request
2020-05-01 16:16:11,680 - INFO - Received event notification
2020-05-01 16:16:11,680 - INFO - Adding buffer identifiers for file: /home/myuser/Documents/virtualenv/project01.py
2020-05-01 16:16:11,681 - INFO - Received event notification
2020-05-01 16:16:15,499 - INFO - Received completion request
2020-05-01 16:16:15,503 - INFO - Received signature help request
2020-05-01 16:16:15,639 - INFO - Received completion request
2020-05-01 16:16:15,643 - INFO - Received signature help request
2020-05-01 16:16:15,790 - INFO - Received event notification
2020-05-01 16:16:15,790 - INFO - Adding ONE buffer identifier for file: /home/myuser/Documents/virtualenv/project01.py
2020-05-01 16:16:15,794 - INFO - Received completion request
2020-05-01 16:16:15,798 - INFO - Received signature help request
2020-05-01 16:16:16,111 - INFO - Received completion request
2020-05-01 16:16:16,119 - INFO - Received signature help request
2020-05-01 16:16:17,200 - INFO - Received event notification
2020-05-01 16:16:17,201 - INFO - Adding ONE buffer identifier for file: /home/myuser/Documents/virtualenv/project01.py
2020-05-01 16:16:17,205 - INFO - Received completion request
2020-05-01 16:16:17,211 - INFO - Received signature help request
2020-05-01 16:21:20,230 - INFO - Received completion request
2020-05-01 16:21:20,237 - INFO - Received signature help request
2020-05-01 16:21:21,135 - INFO - Received completion request
2020-05-01 16:21:21,141 - INFO - Received signature help request
2020-05-01 16:21:22,492 - INFO - Received completion request
2020-05-01 16:21:22,497 - INFO - Received signature help request
2020-05-01 16:21:24,956 - INFO - Received event notification
2020-05-01 16:21:24,957 - INFO - Adding buffer identifiers for file: /home/myuser/Documents/virtualenv/project01.py
2020-05-01 16:21:24,960 - INFO - Received event notification
2020-05-01 16:21:25,395 - INFO - Received event notification
2020-05-01 16:21:28,844 - INFO - Received command request
2020-05-01 16:21:33,301 - INFO - Received command request
2020-05-01 16:21:39,147 - INFO - Received debug info request
2020-05-01 16:23:16,266 - INFO - Received health request

Output of YcmDiags

No warnings or errors detected.

Output of git rev-parse HEAD in YouCompleteMe installation directory

$ pwd
/home/myuser/.vim/bundle/YouCompleteMe
$ git rev-parse HEAD
7849c8ec5e21ab0ab79e9023e93304f5b7c09159

Contents of YCM, ycmd and completion engine logfiles

Reproduce the issue with vim -Nu /path/to/YCM/vimrc_ycm_minimal, which enabled debug logging and other useful diagnostics. Include a link to a gist containing all of the log files listed by :YcmToggleLogs.

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

Which logfile do you wish to open (or close if already open)? 1: ycm_uy6_0vez.log 2: ycmd_38045_stderr_djn3r8pn.log 3: ycmd_38045_stdout_kly2ncdt.log Type number and or click with mouse (empty cancels):

1 2 3

OS version, distribution, etc.

$ uname -a
Linux myArch 5.6.4-arch1-1 #1 SMP PREEMPT Mon, 13 Apr 2020 12:21:19 +0000 x86_64 GNU/Linux

$ cat /etc/*lease*
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="0;36"
HOME_URL="https://www.archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://bugs.archlinux.org/"
LOGO=archlinux

Output of build/install commands

Include link to a gist containing the invocation and entire output of install.py if reporting an installation issue.

Not an installation issue.

bstaletic commented 4 years ago

Thanks for the detailed report. I was able to repro.

bstaletic commented 4 years ago

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 commented 4 years ago

@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).

JunweiZheng93 commented 4 years ago

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"

puremourning commented 4 years ago

@JunweiZheng93 we have acknowledged this is a bug. PRs are always welcome to fix .... :)

bstaletic commented 4 years ago

ycm-core/ycmd#1444 should solve this.

cxwx commented 4 years ago

same problem on Mac. Could anybody tell me the detail of solution?

bstaletic commented 4 years ago

Go in YCM/third_party/ycmd and pull in the latest master.

cxwx commented 4 years ago

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)
bstaletic commented 4 years ago

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.