davidhalter / jedi

Awesome autocompletion, static analysis and refactoring library for python
http://jedi.readthedocs.io
Other
5.78k stars 508 forks source link

Scope of the usages #1258

Closed drozdowsky closed 5 years ago

drozdowsky commented 5 years ago

Issue

Let's consider following example (Python 2.7 with django) models.py

class Example(models.Model):
    date=modelsDateTimeField(...)

other_file.py

from models import Example  
"""some Example usage e.g."""  
post_save.connect(my_function, sender=Example)

Let's say I I run 'show usages' on definition of Example class. (this line: class Example(models.Model)), the jedi-vim/jedi returns only the same line, there is no other_file.py usage shown. For me it looks like that "show usages" functionality only works when there is direct import and only then jedi can find other usages (it works from other_file.py just fine). This is a issue because it makes this functionality useless imo, it is more useful to run "grep -r" on whole project.

Output of “:verbose JediDebugInfo”

Jedi-vim debug information

jedi-vim version
Global Python

Using Python version 3 to access Jedi.

Jedi
Jedi environment: <Environment: 2.7.14 in /home/self/virtualenvs/rp>
Known environments
Settings
g:jedi#popup_on_dot = 0 (default: 1)
g:jedi#show_call_signatures = '2' (default: 1)

  omnifunc=jedi#completions
    Impostata l'ultima volta da ~/.vim/bundle/jedi-vim/autoload/jedi.vim
  completeopt=menuone,longest
    Impostata l'ultima volta da ~/.vimrc

:version


VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 05 2018 21:42:14)
Patch incluse: 1-1766
Modificato da pkg-vim-maintainers@lists.alioth.debian.org
Compilato da pkg-vim-maintainers@lists.alioth.debian.org
Versione gigante con GUI GTK3.  Funzionalità incluse (+) o escluse (-):
+acl               +cmdline_compl     -ebcdic            -hangul_input      +lua               +mouse_xterm       -python            +tag_binary        +vertsplit         +xpm
+arabic            +cmdline_hist      +emacs_tags        +iconv             +menu              +multi_byte        +python3           +tag_old_static    +virtualedit       +xsmp_interact
+autocmd           +cmdline_info      +eval              +insert_expand     +mksession         +multi_lang        +quickfix          -tag_any_white     +visual            +xterm_clipboard
-autoservername    +comments          +ex_extra          +job               +modify_fname      -mzscheme          +reltime           +tcl               +visualextra       -xterm_save
+balloon_eval      +conceal           +extra_search      +jumplist          +mouse             +netbeans_intg     +rightleft         +termguicolors     +viminfo           
+balloon_eval_term +cryptv            +farsi             +keymap            +mouseshape        +num64             -ruby              +terminal          +vreplace          
+browse            +cscope            +file_in_path      +lambda            +mouse_dec         +packages          +scrollbind        +terminfo          +wildignore        
++builtin_terms    +cursorbind        +find_in_path      +langmap           +mouse_gpm         +path_extra        +signs             +termresponse      +wildmenu          
+byte_offset       +cursorshape       +float             +libcall           -mouse_jsbterm     +perl              +smartindent       +textobjects       +windows           
+channel           +dialog_con_gui    +folding           +linebreak         +mouse_netterm     +persistent_undo   +startuptime       +timers            +writebackup       
+cindent           +diff              -footer            +lispindent        +mouse_sgr         +postscript        +statusline        +title             +X11               
+clientserver      +digraphs          +fork()            +listcmds          -mouse_sysmouse    +printer           -sun_workshop      +toolbar           -xfontset          
+clipboard         +dnd               +gettext           +localmap          +mouse_urxvt       +profile           +syntax            +user_commands     +xim               
   file vimrc di sistema: "$VIM/vimrc"
       file vimrc utente: "$HOME/.vimrc"
    II file vimrc utente: "~/.vim/vimrc"
        file exrc utente: "$HOME/.exrc"
  file gvimrc di sistema: "$VIM/gvimrc"
      file gvimrc utente: "$HOME/.gvimrc"
   II file gvimrc utente: "~/.vim/gvimrc"
        file dei default: "$VIMRUNTIME/defaults.vim"
    file menu di sistema: "$VIMRUNTIME/menu.vim"
         $VIM di riserva: "/usr/share/vim"
Compilazione: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-SKXyA9/vim-8.0.1766=. -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Link: gcc   -Wl,-E  -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim   -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lfribidi -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.26/CORE -lperl -ldl -lm -lpthread -lcrypt  -L/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl -lutil -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm     

:messages

Manutentore messaggi: Vlad Sandrini <marco@sandrini.biz>
"faults/listeners/pronto.py" 406L, 17799C
"faults/models/pronto.py" 820L, 21905C
"faults/signals.py" 67L, 3639C
"faults/models/pronto.py" 820 righe --0%--
"/tmp/vBYaEf4/5.fugitiveblame" 820L, 76025C
Error  Instance of 'ForeignKey' has no 'pronto_id' member (no-member)
Error  Instance of 'ForeignKey' has no 'pronto_id' member (no-member)
Error  Instance of 'ForeignKey' has no 'pronto_id' member (no-member)
Warning  Too few public methods (0/2) (too-few-public-methods)
Warning  Too few public methods (0/2) (too-few-public-methods)
"faults/models/pronto.py" 820L, 21905C scritti
Warning  Too few public methods (0/2) (too-few-public-methods)
Warning  Class has no __init__ method (no-init)
Error  Instance of 'ForeignKey' has no 'pronto_id' member (no-member)
Error  Instance of 'ForeignKey' has no 'pronto_id' member (no-member)
Warning  Class has no __init__ method (no-init)
Error  Instance of 'ForeignKey' has no 'pronto_id' member (no-member)
Error  Instance of 'ForeignKey' has no 'pronto_id' member (no-member)
Warning  Class has no __init__ method (no-init)
Warning  Class has no __init__ method (no-init)
Warning  Class has no __init__ method (no-init)
Error  Instance of 'ForeignKey' has no 'pronto_id' member (no-member)
Error  Instance of 'ForeignKey' has no 'pronto_id' member (no-member)
Warning  Class has no __init__ method (no-init)
Warning  Class has no __init__ method (no-init)
Warning  Parameters differ from overridden 'save' method (arguments-differ)
Error  Class 'Group' has no 'DoesNotExist' member (no-member)
Error  Class 'Group' has no 'DoesNotExist' member (no-member)
Error  Class 'Group' has no 'DoesNotExist' member (no-member)
Warning  Class has no __init__ method (no-init)
Warning  Class has no __init__ method (no-init)
Warning  Class has no __init__ method (no-init)
Warning  Consider using ternary (u'...' if (self.rd_info[:97]) + (len(self.rd_info)) > 100 else u'') (consider-using-ternary)
Warning  Consider using ternary (u'...' if (self.rd_info[:97]) + (len(self.rd_info)) > 100 else u'') (consider-using-ternary)
Warning  Consider using ternary (u'...' if (self.rd_info[:97]) + (len(self.rd_info)) > 100 else u'') (consider-using-ternary)
Warning  Consider using ternary (u'...' if (self.rd_info[:97]) + (len(self.rd_info)) > 100 else u'') (consider-using-ternary)
Warning  Consider using ternary (u'...' if (self.rd_info[:97]) + (len(self.rd_info)) > 100 else u'') (consider-using-ternary)
Warning  Consider using ternary (u'...' if (self.rd_info[:97]) + (len(self.rd_info)) > 100 else u'') (consider-using-ternary)
Warning  Consider using ternary (u'...' if (self.rd_info[:97]) + (len(self.rd_info)) > 100 else u'') (consider-using-ternary)
Warning  Access to a protected member _meta of a client class (protected-access)
Error  Instance of 'ManyToManyField' has no 'filter' member (no-member)
Warning  Access to a protected member _meta of a client class (protected-access)
Error  Instance of 'ManyToManyField' has no 'filter' member (no-member)
Warning  Class has no __init__ method (no-init)
Error  line too long (132 > 120 characters) (E501)
Warning  Class has no __init__ method (no-init)
Error  Instance of 'ManyToManyField' has no 'filter' member (no-member)
Warning  Access to a protected member _meta of a client class (protected-access)
Error  Instance of 'ManyToManyField' has no 'filter' member (no-member)
Warning  Access to a protected member _meta of a client class (protected-access)
Error  Instance of 'ManyToManyField' has no 'filter' member (no-member)
Warning  Access to a protected member _meta of a client class (protected-access)
Error  Instance of 'ManyToManyField' has no 'filter' member (no-member)
Error  Instance of 'ManyToManyField' has no 'filter' member (no-member)
"faults/models/pronto.py" 820L, 21905C scritti
Error  line too long (132 > 120 characters) (E501)
Error  line too long (132 > 120 characters) (E501)
Warning  Class has no __init__ method (no-init)
Warning  Class has no __init__ method (no-init)
Error  line too long (132 > 120 characters) (E501)
Error  line too long (132 > 120 characters) (E501)
Warning  Class has no __init__ method (no-init)
Warning  Access to a protected member _meta of a client class (protected-access)
Warning  Access to a protected member _meta of a client class (protected-access)
Warning  Access to a protected member _meta of a client class (protected-access)
Warning  Access to a protected member _meta of a client class (protected-access)
Warning  Access to a protected member _meta of a client class (protected-access)
Warning  Access to a protected member _meta of a client class (protected-access)
Warning  Access to a protected member _meta of a client class (protected-access)
Warning  Access to a protected member _meta of a client class (protected-access)
Warning  Access to a protected member _meta of a client class (protected-access)
Warning  Class has no __init__ method (no-init)
Error  line too long (132 > 120 characters) (E501)
Error  line too long (132 > 120 characters) (E501)
Error  line too long (132 > 120 characters) (E501)
Error  line too long (132 > 120 characters) (E501)
Warning  Class has no __init__ method (no-init)
Warning  Access to a protected member _meta of a client class (protected-access)
Warning  Access to a protected member _meta of a client class (protected-access)
Warning  Access to a protected member _meta of a client class (protected-access)
Warning  Class has no __init__ method (no-init)
Error  line too long (132 > 120 characters) (E501)
Warning  Class has no __init__ method (no-init)
Warning  Access to a protected member _meta of a client class (protected-access)
Warning  Access to a protected member _meta of a client class (protected-access)
Warning  Consider using ternary (u'...' if (self.rd_info[:97]) + (len(self.rd_info)) > 100 else u'') (consider-using-ternary)
"/tmp/vBYaEf4/9.fugitiveblame" 820L, 76025C
"faults/signals.py" 67 righe --1%--
"faults/signals.py" 67 righe --1%--
Warning  Unused InformationRequest imported from faults.models (unused-import)
"faults/listeners/pronto.py" 406 righe --0%--
Warning  Unused argument 'kwargs' (unused-argument)
Error  local variable 'e' is assigned to but never used (F841)
Error  local variable 'e' is assigned to but never used (F841)
Error  local variable 'e' is assigned to but never used (F841)
Error  local variable 'e' is assigned to but never used (F841)
Error  local variable 'e' is assigned to but never used (F841)
Warning  Unused argument 'kwargs' (unused-argument)
Error  local variable 'e' is assigned to but never used (F841)
Error  local variable 'e' is assigned to but never used (F841)
Warning  Unused argument 'kwargs' (unused-argument)
Warning  Unused argument 'kwargs' (unused-argument)
Error  local variable 'e' is assigned to but never used (F841)
Error  local variable 'e' is assigned to but never used (F841)
Error  local variable 'e' is assigned to but never used (F841)
"faults/signals.py" 67 righe --68%--
jedi-vim: Couldn't find any definitions for this.
jedi-vim: Couldn't find any definitions for this.
jedi-vim: Couldn't find any definitions for this.
jedi-vim: Couldn't find any definitions for this.
jedi-vim: Couldn't find any definitions for this.
jedi-vim: Couldn't find any definitions for this.
jedi-vim: Couldn't find any definitions for this.
"faults/models/__init__.py" 13L, 237C
"faults/models/pronto.py" 820 righe --50%--
"/tmp/vBYaEf4/19.fugitiveblame" 820L, 76025C
:scriptnames ``` 1: /usr/share/vim/vimrc 2: /usr/share/vim/vim80/debian.vim 3: /usr/share/vim/vim80/syntax/syntax.vim 4: /usr/share/vim/vim80/syntax/synload.vim 5: /usr/share/vim/vim80/syntax/syncolor.vim 6: /usr/share/vim/vim80/filetype.vim 7: ~/.vimrc 8: /usr/share/vim/vim80/ftoff.vim 9: ~/.vim/bundle/Vundle.vim/autoload/vundle.vim 10: ~/.vim/bundle/Vundle.vim/autoload/vundle/config.vim 11: /usr/share/vim/vim80/ftplugin.vim 12: /usr/share/vim/vim80/indent.vim 13: /usr/share/vim/vim80/syntax/nosyntax.vim 14: ~/.vim/colors/molokai.vim 15: ~/.vim/plugin/swapsucks.vim 16: ~/.vim/bundle/SimpylFold/plugin/SimpylFold.vim 17: ~/.vim/bundle/jedi-vim/plugin/jedi.vim 18: ~/.vim/bundle/ale/plugin/ale.vim 19: ~/.vim/bundle/ale/autoload/ale/events.vim 20: ~/.vim/bundle/nerdtree/plugin/NERD_tree.vim 21: ~/.vim/bundle/nerdtree/autoload/nerdtree.vim 22: ~/.vim/bundle/nerdtree/lib/nerdtree/path.vim 23: ~/.vim/bundle/nerdtree/lib/nerdtree/menu_controller.vim 24: ~/.vim/bundle/nerdtree/lib/nerdtree/menu_item.vim 25: ~/.vim/bundle/nerdtree/lib/nerdtree/key_map.vim 26: ~/.vim/bundle/nerdtree/lib/nerdtree/bookmark.vim 27: ~/.vim/bundle/nerdtree/lib/nerdtree/tree_file_node.vim 28: ~/.vim/bundle/nerdtree/lib/nerdtree/tree_dir_node.vim 29: ~/.vim/bundle/nerdtree/lib/nerdtree/opener.vim 30: ~/.vim/bundle/nerdtree/lib/nerdtree/creator.vim 31: ~/.vim/bundle/nerdtree/lib/nerdtree/flag_set.vim 32: ~/.vim/bundle/nerdtree/lib/nerdtree/nerdtree.vim 33: ~/.vim/bundle/nerdtree/lib/nerdtree/ui.vim 34: ~/.vim/bundle/nerdtree/lib/nerdtree/event.vim 35: ~/.vim/bundle/nerdtree/lib/nerdtree/notifier.vim 36: ~/.vim/bundle/nerdtree/autoload/nerdtree/ui_glue.vim 37: ~/.vim/bundle/nerdtree/nerdtree_plugin/exec_menuitem.vim 38: ~/.vim/bundle/nerdtree/nerdtree_plugin/fs_menu.vim 39: ~/.vim/bundle/ctrlp.vim/plugin/ctrlp.vim 40: ~/.vim/bundle/ctrlp.vim/autoload/ctrlp/mrufiles.vim 41: ~/.vim/bundle/vim-fugitive/plugin/fugitive.vim 42: ~/.vim/bundle/powerline/powerline/bindings/vim/plugin/powerline.vim 43: ~/.vim/bundle/vim-isort/plugin/python_vimisort.vim 44: ~/.vim/bundle/colorizer/plugin/colorizer.vim 45: /usr/share/vim/vim80/plugin/getscriptPlugin.vim 46: /usr/share/vim/vim80/plugin/gzip.vim 47: /usr/share/vim/vim80/plugin/logiPat.vim 48: /usr/share/vim/vim80/plugin/manpager.vim 49: /usr/share/vim/vim80/plugin/matchparen.vim 50: /usr/share/vim/vim80/plugin/netrwPlugin.vim 51: /usr/share/vim/vim80/plugin/rrhelper.vim 52: /usr/share/vim/vim80/plugin/spellfile.vim 53: /usr/share/vim/vim80/plugin/tarPlugin.vim 54: /usr/share/vim/vim80/plugin/tohtml.vim 55: /usr/share/vim/vim80/plugin/vimballPlugin.vim 56: /usr/share/vim/vim80/plugin/zipPlugin.vim 57: ~/.vim/bundle/ale/autoload/ale.vim 58: /usr/share/vim/vim80/scripts.vim 59: ~/.vim/bundle/nerdtree/syntax/nerdtree.vim 60: ~/.vim/bundle/ctrlp.vim/autoload/ctrlp/utils.vim 61: ~/.vim/bundle/SimpylFold/ftplugin/python/SimpylFold.vim 62: ~/.vim/bundle/SimpylFold/autoload/SimpylFold.vim 63: ~/.vim/bundle/jedi-vim/ftplugin/python/jedi.vim 64: ~/.vim/bundle/jedi-vim/autoload/jedi.vim 65: /usr/share/vim/vim80/ftplugin/python.vim 66: ~/.vim/bundle/jedi-vim/after/ftplugin/python/jedi.vim 67: ~/.vim/bundle/indentpython.vim/indent/python.vim 68: /usr/share/vim/vim80/indent/python.vim 69: ~/.vim/syntax/python.vim 70: /usr/share/vim/vim80/syntax/python.vim 71: ~/.vim/bundle/jedi-vim/after/syntax/python.vim 72: ~/.vim/bundle/ale/autoload/ale/util.vim 73: ~/.vim/bundle/ale/autoload/ale/linter.vim 74: ~/.vim/bundle/ale/ale_linters/python/flake8.vim 75: ~/.vim/bundle/ale/ale_linters/python/mypy.vim 76: ~/.vim/bundle/ale/ale_linters/python/prospector.vim 77: ~/.vim/bundle/ale/ale_linters/python/pycodestyle.vim 78: ~/.vim/bundle/ale/ale_linters/python/pyflakes.vim 79: ~/.vim/bundle/ale/ale_linters/python/pylint.vim 80: ~/.vim/bundle/ale/ale_linters/python/pyls.vim 81: ~/.vim/bundle/ale/ale_linters/python/pyre.vim 82: ~/.vim/bundle/ale/ale_linters/python/vulture.vim 83: ~/.vim/bundle/ale/autoload/ale/engine.vim 84: ~/.vim/bundle/ale/autoload/ale/python.vim 85: ~/.vim/bundle/ale/autoload/ale/path.vim 86: ~/.vim/bundle/ale/autoload/ale/history.vim 87: ~/.vim/bundle/ale/autoload/ale/semver.vim 88: ~/.vim/bundle/ale/autoload/ale/command.vim 89: ~/.vim/bundle/ale/autoload/ale/job.vim 90: ~/.vim/bundle/ale/autoload/ale/cursor.vim 91: ~/.vim/bundle/ale/autoload/ale/sign.vim 92: ~/.vim/bundle/ale/autoload/ale/list.vim 93: ~/.vim/bundle/ale/autoload/ale/highlight.vim 94: ~/.vim/bundle/ale/autoload/ale/toggle.vim 95: /usr/share/vim/vim80/ftplugin/qf.vim 96: /usr/share/vim/vim80/syntax/qf.vim ```
davidhalter commented 5 years ago

Unfortunately usages has been bad for quite a long time :( #1059 is IMO still the way to go. I feel like it would solve this.

davidhalter commented 5 years ago

I'm closing, because usages over multiple files is just way too slow without some form of database index.

At the same time I still feel like #1059 is the issue that will eventually solve all your issues.

Sorry!