davidhalter / jedi-vim

Using the jedi autocompletion library for VIM.
MIT License
5.28k stars 370 forks source link

Missing docstrings for some modules (sys, hashlib etc.) #692

Closed ddnomad closed 5 years ago

ddnomad commented 7 years ago

Issue

Ok, so I've just installed jedi-vim with vundle and it seems to fail displaying documentation for at least a couple of libraries. For example, it says |No Docstring for <Definition module sys>| and |No Docstring for <Definition module hashlib>|.

Steps to reproduce

First, here is my .vimrc:

" please, make vundle work
set nocompatible
filetype off
set rtp+=/usr/share/vim/vimfiles/autoload/vundle.vim

" please, don't forget vundle plugins
call vundle#begin()
Plugin 'VundleVim/vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'tpope/vim-fugitive'
Plugin 'klen/python-mode'
Plugin 'davidhalter/jedi-vim'
call vundle#end()

" please, make neat indents
filetype plugin indent on

" please, let me F2 directory tree
map <F2> :NERDTreeToggle<CR>

" please, make pymode obey my needs
let g:pymode_rope = 0  " because jedi-vim in use
let g:pymode_doc = 1
let g:pymode_doc_key = 'K'
let g:pymode_lint = 1
let g:pymode_lint_checkers = ['pylint', 'pep8']
let g:pymode_lint_message = 1
let g:pymode_lint_on_fly = 1
let g:pymode_virtualenv = 1
let g:pymode_breakpoint = 1
let g:pymode_options = 1
let g:pymode_quickfix_minheight = 5
let g:pymode_indent = 1
let g:pymode_motion = 1
let g:pymode_trim_whitespaces = 1
let g:pymode_lint_sort = ['E', 'C', 'I']
let g:pymode_breakpoint_bind = '<leader>b'  " so fancy name for \b bind
let g:pymode_folding = 0

Then I try Shift-k on import sys or import hashlib and it gives me nothing.

Output of “:verbose JediDebugInfo”

Jedi-vim debug information

Using Python version: 3

Settings
g:force_py_version = '3' (default: 'auto')

  omnifunc=jedi#completions
        Last set from ~/.vim/bundle/jedi-vim/after/ftplugin/python/jedi.vim
  completeopt=menuone,longest,preview
        Last set from ~/.vim/bundle/jedi-vim/plugin/jedi.vim

:version

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar  6 2017 14:13:23)
Included patches: 1-427
Compiled by Arch Linux
Huge version without GUI.  Features included (+) or not (-):
+acl             -clipboard       +dialog_con      +file_in_path    +job             +lua/dyn         +mouse_sgr       +path_extra      +rightleft       +tag_old_static  +user_commands   +writebackup
+arabic          +cmdline_compl   +diff            +find_in_path    +jumplist        +menu            -mouse_sysmouse  +perl/dyn        +ruby/dyn        -tag_any_white   +vertsplit       -X11
+autocmd         +cmdline_hist    +digraphs        +float           +keymap          +mksession       +mouse_urxvt     +persistent_undo +scrollbind      +tcl/dyn         +virtualedit     -xfontset
-balloon_eval    +cmdline_info    -dnd             +folding         +lambda          +modify_fname    +mouse_xterm     +postscript      +signs           +termguicolors   +visual          -xim
-browse          +comments        -ebcdic          -footer          +langmap         +mouse           +multi_byte      +printer         +smartindent     +terminfo        +visualextra     -xpm
++builtin_terms  +conceal         +emacs_tags      +fork()          +libcall         -mouseshape      +multi_lang      +profile         +startuptime     +termresponse    +viminfo         -xsmp
+byte_offset     +cryptv          +eval            +gettext         +linebreak       +mouse_dec       -mzscheme        +python/dyn      +statusline      +textobjects     +vreplace        -xterm_clipboard
+channel         +cscope          +ex_extra        -hangul_input    +lispindent      +mouse_gpm       +netbeans_intg   +python3/dyn     -sun_workshop    +timers          +wildignore      -xterm_save
+cindent         +cursorbind      +extra_search    +iconv           +listcmds        -mouse_jsbterm   +num64           +quickfix        +syntax          +title           +wildmenu
-clientserver    +cursorshape     +farsi           +insert_expand   +localmap        +mouse_netterm   +packages        +reltime         +tag_binary      -toolbar         +windows
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -D_FORTIFY_SOURCE=2  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro -L/usr/lo
cal/lib -Wl,--as-needed -o vim        -lm -lncurses -lelf -lnsl    -lacl -lattr -lgpm -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector-strong -L
/usr/local/lib  -L/usr/lib/perl5/core_perl/CORE -lperl -lpthread -lnsl -ldl -lm -lcrypt -lutil -lc   -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lieee -lm

:messages

Messages maintainer: Bram Moolenaar <Bram@vim.org>
"rsa.py" 140L, 3231C
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar  6 2017 14:13:23)
:scriptnames ``` 1: /etc/vimrc 2: /usr/share/vim/vimfiles/archlinux.vim 3: ~/.vimrc 4: /usr/share/vim/vim80/ftoff.vim 5: /usr/share/vim/vimfiles/autoload/vundle.vim 6: /usr/share/vim/vimfiles/autoload/vundle/config.vim 7: /usr/share/vim/vim80/filetype.vim 8: /usr/share/vim/vim80/ftplugin.vim 9: /usr/share/vim/vim80/indent.vim 10: /usr/share/vim/vim80/syntax/syntax.vim 11: /usr/share/vim/vim80/syntax/synload.vim 12: /usr/share/vim/vim80/syntax/syncolor.vim 13: ~/.vim/bundle/nerdtree/plugin/NERD_tree.vim 14: ~/.vim/bundle/nerdtree/autoload/nerdtree.vim 15: ~/.vim/bundle/nerdtree/lib/nerdtree/path.vim 16: ~/.vim/bundle/nerdtree/lib/nerdtree/menu_controller.vim 17: ~/.vim/bundle/nerdtree/lib/nerdtree/menu_item.vim 18: ~/.vim/bundle/nerdtree/lib/nerdtree/key_map.vim 19: ~/.vim/bundle/nerdtree/lib/nerdtree/bookmark.vim 20: ~/.vim/bundle/nerdtree/lib/nerdtree/tree_file_node.vim 21: ~/.vim/bundle/nerdtree/lib/nerdtree/tree_dir_node.vim 22: ~/.vim/bundle/nerdtree/lib/nerdtree/opener.vim 23: ~/.vim/bundle/nerdtree/lib/nerdtree/creator.vim 24: ~/.vim/bundle/nerdtree/lib/nerdtree/flag_set.vim 25: ~/.vim/bundle/nerdtree/lib/nerdtree/nerdtree.vim 26: ~/.vim/bundle/nerdtree/lib/nerdtree/ui.vim 27: ~/.vim/bundle/nerdtree/lib/nerdtree/event.vim 28: ~/.vim/bundle/nerdtree/lib/nerdtree/notifier.vim 29: ~/.vim/bundle/nerdtree/autoload/nerdtree/ui_glue.vim 30: ~/.vim/bundle/nerdtree/nerdtree_plugin/exec_menuitem.vim
ddnomad commented 7 years ago

I've just tested pyrope and it successfully finds documentation for both sys and hashlib.

blueyed commented 7 years ago

Isn't this a pymode thing/issue?

let g:pymode_doc_key = 'K'

ddnomad commented 7 years ago

I don't think so, as with the same setup jedi does find docs for os module. So it works rather randomly. I can test out other imports as well tot see with what particular modules issue persists.

ddnomad commented 7 years ago

So this is what I've found out:

import os  # ok
import sys  # fail
import random  # ok
import pprint  # ok
import hashlib  # fail
import pyproj  # ok
import flask  # ok
import abc  # ok
import cmath  # fail

UPDATE: after using default <leader>d bind for goto_declaration() vim freezed and started to consume 100% of CPU.

davidhalter commented 7 years ago

I think this is a Jedi bug, downgrade to Jedi 0.9.0 and check again. I think I've seen similar bugs somewhere.

mg979 commented 5 years ago

I'm also seeing this. Depending on the directory I'm in, docs for some modules don't work. sys and re always work, os rarely. If the module isn't found, completion for that module won't work either.

OS: debian stable

Downgrading does nothing.

davidhalter commented 5 years ago

This has been an issue long ago. I'm a bit confused that someone is still seeing this. It has been working for me very well in these cases. Downgrading likely won't help, use Jedi 0.13.3+.

mg979 commented 5 years ago

If I'm the only one, maybe there's some problem with my setup. But I get the same in vim, Sublime Text and VS Code, so it isn't vim.

Examples: module os working in ~/abs/s2t.py

Imgur

Not working in ~/Dropbox/Progetti/Python/Book/abs/s2t.py

Imgur

davidhalter commented 5 years ago

Can you also add the debug info?

mg979 commented 5 years ago

Where do I take them from?

mg979 commented 5 years ago

Ok


#### Jedi-vim debug information

##### jedi-vim version

 - jedi-vim git version: f26b2a8-dirty
 - jedi git submodule status: +8d0c4d3cec4973a2722652bf33f093ac3f1f385a pythonx/jedi (v0.13.3-19-g8d0c4d3c)
 - parso git submodule status:  acccb4f28d6d57f4ad4c882f3408136ee8f50ff5 pythonx/parso (v0.3.4)

##### Global Python

Using Python version 3 to access Jedi.
 - global sys.version: `3.5.3 (default, Sep 27 2018, 17:25:39), [GCC 6.3.0 20170516]`
 - global site module: `/usr/lib/python3.5/site.py`

##### Jedi

 - path: `/home/gianmaria/.vim/plugged/jedi-vim/pythonx/jedi/jedi/__init__.py`
 - version: 0.13.3

##### Jedi environment: <SameEnvironment: 3.5.3 in /usr>

 - executable: /usr/bin/python3
 - sys_path:
    - `/usr/lib/python35.zip`
    - `/usr/lib/python3.5`
    - `/usr/lib/python3.5/plat-x86_64-linux-gnu`
    - `/usr/lib/python3.5/lib-dynload`
    - `/home/gianmaria/.local/lib/python3.5/site-packages`
    - `/usr/local/lib/python3.5/dist-packages`
    - `/usr/lib/python3/dist-packages`

##### Known environments

 - <Environment: 3.7.2 in /usr> (/usr/bin/python3.7)

 - <Environment: 3.5.3 in /usr> (/usr/bin/python3.5)

 - <Environment: 2.7.13 in /usr> (/usr/bin/python2.7)

##### Settings

g:jedi#force_py_version = 3 (default: 'auto')
g:jedi#use_splits_not_buffers = 'bottom' (default: 1)

  omnifunc=jedi#completions
    Impostata l'ultima volta da ~/.vim/plugged/jedi-vim/autoload/jedi.vim
  completeopt=menuone,noselect
    Impostata l'ultima volta da ~/.vim/plugged/jedi-vim/autoload/jedi.vim
mg979 commented 5 years ago

jedi-vim git version: f26b2a8-dirty

it's dirty because I updated manually the jedi submodule

mg979 commented 5 years ago

This is the debug info if I run it in virtualenv (3.7.2), and removing the g:jedi#force_py_version setting, no change


#### Jedi-vim debug information

##### jedi-vim version

 - jedi-vim git version: f26b2a8-dirty
 - jedi git submodule status: +8d0c4d3cec4973a2722652bf33f093ac3f1f385a pythonx/jedi (v0.13.3-19-g8d0c4d3c)
 - parso git submodule status:  acccb4f28d6d57f4ad4c882f3408136ee8f50ff5 pythonx/parso (v0.3.4)

##### Global Python

Using Python version 3 to access Jedi.
 - global sys.version: `3.5.3 (default, Sep 27 2018, 17:25:39), [GCC 6.3.0 20170516]`
 - global site module: `/usr/lib/python3.5/site.py`

##### Jedi

 - path: `/home/gianmaria/.vim/plugged/jedi-vim/pythonx/jedi/jedi/__init__.py`
 - version: 0.13.3

##### Jedi environment: <Environment: 3.7.2 in /home/gianmaria/.local/virtualenv/pybook>

 - executable: /home/gianmaria/.local/virtualenv/pybook/bin/python
 - sys_path:
    - `/home/gianmaria/.local/virtualenv/pybook/lib/python37.zip`
    - `/home/gianmaria/.local/virtualenv/pybook/lib/python3.7`
    - `/home/gianmaria/.local/virtualenv/pybook/lib/python3.7/lib-dynload`
    - `/home/gianmaria/.pyenv/versions/3.7.2/lib/python3.7`
    - `/home/gianmaria/.local/virtualenv/pybook/lib/python3.7/site-packages`

##### Known environments

 - <Environment: 3.7.2 in /home/gianmaria/.local/virtualenv/pybook> (/home/gianmaria/.local/virtualenv/pybook/bin/python)

 - <Environment: 3.7.2 in /home/gianmaria/.local/virtualenv/pybook> (/home/gianmaria/.local/virtualenv/pybook/bin/python3.7)

 - <Environment: 3.5.3 in /usr> (/usr/bin/python3.5)

 - <Environment: 2.7.13 in /usr> (/usr/bin/python2.7)

##### Settings

g:jedi#use_splits_not_buffers = 'bottom' (default: 1)

  omnifunc=jedi#completions
    Impostata l'ultima volta da ~/.vim/plugged/jedi-vim/autoload/jedi.vim
  completeopt=menuone,noselect
    Impostata l'ultima volta da ~/.vim/plugged/jedi-vim/autoload/jedi.vim
davidhalter commented 5 years ago

I have modified quite a few things about imports on typeshed. So if you ever debug something, please do it on that Jedi branch. Can you quickly try checking out that branch and see if it fails there as well?

I really have no idea, because I haven't seen these issues before.

mg979 commented 5 years ago

On typeshed, no change. Have you tried to create 2 files with the same paths, to see if you can reproduce it on your side? Because if you can't reproduce it, maybe it has to do with my system (debian stretch). Thanks

davidhalter commented 5 years ago

Works without problems. I'm running Ubuntu 16.04.

mg979 commented 5 years ago

Thanks, then it's my system for sure.

davidhalter commented 5 years ago

Is there a special way how Dropbox mounts thing or deals with things in the file system?

mg979 commented 5 years ago

None that I know of, but it seems to work outside Dropbox. Stopping Dropbox doesn't help though.

davidhalter commented 5 years ago

If you want to keep debugging this, you should use direct Jedi calls and check if it's a problem as well with jedi.Script().completions(). If you enable debugging (jedi.set_debug_function()), you can post that here as well. Would be interesting.

mg979 commented 5 years ago

Ok thanks, how do I call jedi.set_debug_function() from vim?

davidhalter commented 5 years ago

:PythonJedi jedi_vim.jedi.set_debug_function()

But as I said, Jedi only calls would be even preferred. It's easier to debug and reason about those.

mg979 commented 5 years ago

Ok I found out the cause. I had a file named os.py in the same directory and I didn't know it would mess up something. The debug helped a lot, thanks for that :). And sorry for the waste of time.

speed: init 29.534035682678223
speed: parsed 29.541239500045776
speed: init 1.043588399887085
speed: parsed 1.0510945320129395
speed: completions start 1.3113021850585938e-05
dbg: global completion scope: <ModuleContext: s2t@3-17>
speed: completions end 0.009578466415405273
speed: init 1.9056410789489746
speed: parsed 1.9118568897247314
speed: completions start 1.2636184692382812e-05
dbg: global completion scope: <ModuleContext: s2t@3-17>
speed: completions end 0.009280681610107422
speed: import (<Name: os@3,7>,) 0.009625673294067383
dbg: global search_module 'os' in '/home/gianmaria/Dropbox/Progetti/Python/Books/abs/s2t.py'
dbg: after import: ContextSet(<ModuleContext: os@1-33>)
speed: init 1.3616366386413574
speed: parsed 1.3653154373168945
speed: completions start 9.059906005859375e-06
 dbg: eval_node <Name: os@7,3>@(7, 3)
  dbg: finder.filter_name 'os' in (<ModuleContext: s2t@3-17>): [<TreeNameDefinition: os@(3, 7)>]@(7, 3)
  speed: import (<Name: os@3,7>,) 0.001535654067993164
  dbg: global search_module 'os' in '/home/gianmaria/Dropbox/Progetti/Python/Books/abs/s2t.py'
  dbg: after import: ContextSet(<ModuleContext: os@1-33>)
  dbg: finder._names_to_types: [<TreeNameDefinition: os@(3, 7)>] -> ContextSet(<ModuleContext: os@1-33>)
dbg: trailer completion contexts: ContextSet(<ModuleContext: os@1-33>)
speed: completions end 0.00455784797668457
speed: import (<Name: os@1,7>,) 0.0048978328704833984
dbg: after import: ContextSet(<ModuleContext: os@1-33>)
speed: import (<Name: zipfile@2,7>,) 0.005310773849487305
dbg: global search_module 'zipfile' in '/home/gianmaria/Dropbox/Progetti/Python/Books/abs/os.py'
dbg: after import: ContextSet(<ModuleContext: zipfile@1-1964>)
 dbg: execute: <CompiledObject: <class 'str'>> <ValuesArguments: []>
 dbg: execute result: ContextSet(<CompiledInstance of <CompiledObject: <class 'str'>>(<ValuesArguments: []>)>) in <CompiledObject: <class 'str'>>
 dbg: execute: <CompiledObject: <class 'str'>> <ValuesArguments: []>
 dbg: execute result: ContextSet(<CompiledInstance of <CompiledObject: <class 'str'>>(<ValuesArguments: []>)>) in <CompiledObject: <class 'str'>>
 dbg: execute: <CompiledObject: <class 'str'>> <ValuesArguments: []>
 dbg: execute result: ContextSet(<CompiledInstance of <CompiledObject: <class 'str'>>(<ValuesArguments: []>)>) in <CompiledObject: <class 'str'>>
 dbg: execute: <CompiledObject: <class 'str'>> <ValuesArguments: []>
 dbg: execute result: ContextSet(<CompiledInstance of <CompiledObject: <class 'str'>>(<ValuesArguments: []>)>) in <CompiledObject: <class 'str'>>
mg979 commented 5 years ago

I can only add that the module was imported by python (os methods could be called), only autocompletion doesn't seem to work in that case.

davidhalter commented 5 years ago

I will close this one then. It's really old and I doubt it's still an issue. The import system has been rewritten anyway. If anyone still thinks it's an issue, please open a new issue.