question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automatically types an attribute which doesn't exist but is a argument name

See original GitHub issue

Issue

jedi-vim automatically types an attribute which does not exist, but seems to have originated from the signature of an unrelated function.

Steps to reproduce

Take this example Python file:

import logging

logger = logging.getLogger(__name__)

def example(**kwargs):
    hello = kwargs['hello']
    logger.info("test %s", hello

With my cursor in the last line and the last character in insert mode, I type .. Unexpectedly, Jedi inserts the characters msg, making the line look like this:

    logger.info("test %s", hello.msg

It seems to be getting msg from the signature of logger.info which is (param msg, param *args, params **kwargs).

I’m sorry, I couldn’t work out how to use both minimal.vimrc and load jedi-vim at the same time.

Output of “:verbose JediDebugInfo”

Jedi-vim debug information

Using Python version: 3

  • sys.version: 3.6.1 (default, Apr 4 2017, 09:40:21), [GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.38)]
  • site module: /usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site.py Jedi path: /Users/flimm/dotfiles/default/vim/bundle/jedi/jedi/jedi/__init__.py
  • version: 0.10.2
  • sys_path:
    • /Users/flimm/dotfiles/default/vim/bundle/jedi
    • /usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python36.zip
    • /usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6
    • /usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload
    • /usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
    • _vim_path_
    • /Users/flimm/dotfiles/default/vim/bundle/riv/autoload/riv/
  • jedi-vim git version: 0.8.0-78-g40a02a7
  • jedi git submodule status: 5427b02712828b2875d35b5ee1c8b5e58f820537 jedi (v0.10.2)
Settings
g:jedi#smart_auto_mappings = 0 (default: 1)


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

:version


VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May 11 2017 11:16:47)
MacOS X (unix) version
Included patches: 1-596
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl             +clipboard       +dialog_con      +file_in_path    +job             -lua             +mouse_sgr       +path_extra      +rightleft       +tag_old_static  +user_commands   +writebackup     
+arabic          +cmdline_compl   +diff            +find_in_path    +jumplist        +menu            -mouse_sysmouse  +perl            +ruby            -tag_any_white   +vertsplit       -X11             
+autocmd         +cmdline_hist    +digraphs        +float           +keymap          +mksession       +mouse_urxvt     +persistent_undo +scrollbind      -tcl             +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          +statusline      +textobjects     +vreplace        -xterm_clipboard 
+channel         +cscope          +ex_extra        -hangul_input    +lispindent      -mouse_gpm       +netbeans_intg   +python3         -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: "$VIM/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/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -framework Cocoa   -mmacosx-version-min=10.12 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.24.1/lib/perl5/5.24.1/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc  -L/usr/local/opt/python3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin -lpython3.6m -framework CoreFoundation  -lruby.2.4.1 -lobjc    

:messages

Messages maintainer: Bram Moolenaar <Bram@vim.org>
"example.py" 7L, 143C

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May 11 2017 11:16:47)
  1: ~/.vimrc
:scriptnames
  1: ~/.vimrc
  2: ~/dotfiles/default/vim/autoload/pathogen.vim
  3: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/filetype.vim
  4: ~/dotfiles/default/vim/ftdetect/vala.vim
  5: ~/dotfiles/default/vim/bundle/blade/ftdetect/blade.vim
  6: ~/dotfiles/default/vim/bundle/json/ftdetect/json.vim
  7: ~/dotfiles/default/vim/bundle/jsx/ftdetect/javascript.vim
  8: ~/dotfiles/default/vim/bundle/less/ftdetect/less.vim
  9: ~/dotfiles/default/vim/bundle/perl/ftdetect/mason-in-html.vim
 10: ~/dotfiles/default/vim/bundle/perl/ftdetect/perl11.vim
 11: ~/dotfiles/default/vim/bundle/puppet/ftdetect/puppet.vim
 12: /usr/local/Cellar/augeas/1.8.0/share/vim/vimfiles/ftdetect/augeas.vim
 13: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/ftplugin.vim
 14: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/indent.vim
 15: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/syntax/syntax.vim
 16: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/syntax/synload.vim
 17: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/syntax/syncolor.vim
 18: ~/dotfiles/default/vim/bundle/ag/plugin/ag.vim
 19: ~/dotfiles/default/vim/bundle/ale/plugin/ale.vim
 20: ~/dotfiles/default/vim/bundle/characterize/plugin/characterize.vim
 21: ~/dotfiles/default/vim/bundle/commentary/plugin/commentary.vim
 22: ~/dotfiles/default/vim/bundle/ctrlp/plugin/ctrlp.vim
 23: ~/dotfiles/default/vim/bundle/ctrlp/autoload/ctrlp/mrufiles.vim
 24: ~/dotfiles/default/vim/bundle/dirdiff/plugin/dirdiff.vim
 25: ~/dotfiles/default/vim/bundle/editorconfig/plugin/editorconfig.vim
 26: ~/dotfiles/default/vim/bundle/eunuch/plugin/eunuch.vim
 27: ~/dotfiles/default/vim/bundle/fugitive/plugin/fugitive.vim
 28: ~/dotfiles/default/vim/bundle/gundo/plugin/gundo.vim
 29: ~/dotfiles/default/vim/bundle/jedi/plugin/jedi.vim
 30: ~/dotfiles/default/vim/bundle/notes/plugin/notes.vim
 31: ~/dotfiles/default/vim/bundle/vim-misc/autoload/xolox/misc.vim
 32: ~/dotfiles/default/vim/bundle/notes/autoload/xolox/notes.vim
 33: ~/dotfiles/default/vim/bundle/vim-misc/autoload/xolox/misc/path.vim
 34: ~/dotfiles/default/vim/bundle/vim-misc/autoload/xolox/misc/os.vim
 35: ~/dotfiles/default/vim/bundle/riv/plugin/riv.vim
 36: ~/dotfiles/default/vim/bundle/riv/autoload/riv.vim
 37: ~/dotfiles/default/vim/bundle/riv/autoload/riv/cmd.vim
 38: ~/dotfiles/default/vim/bundle/riv/autoload/riv/path.vim
 39: ~/dotfiles/default/vim/bundle/riv/autoload/riv/ptn.vim
 40: ~/dotfiles/default/vim/bundle/sneak/plugin/sneak.vim
 41: ~/dotfiles/default/vim/bundle/surround/plugin/surround.vim
 42: ~/dotfiles/default/vim/bundle/tabular/plugin/Tabular.vim
 43: ~/dotfiles/default/vim/bundle/tagbar/plugin/tagbar.vim
 44: ~/dotfiles/default/vim/bundle/vim-misc/plugin/xolox/misc.vim
 45: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/plugin/getscriptPlugin.vim
 46: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/plugin/gzip.vim
 47: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/plugin/logiPat.vim
 48: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/plugin/manpager.vim
 49: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/plugin/matchparen.vim
 50: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/plugin/netrwPlugin.vim
 51: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/plugin/rrhelper.vim
 52: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/plugin/spellfile.vim
 53: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/plugin/tarPlugin.vim
 54: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/plugin/tohtml.vim
 55: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/plugin/vimballPlugin.vim
 56: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/plugin/zipPlugin.vim
 57: ~/dotfiles/default/vim/bundle/ale/after/plugin/ale.vim
 58: ~/dotfiles/default/vim/bundle/tabular/after/plugin/TabularMaps.vim
 59: ~/dotfiles/default/vim/bundle/tabular/autoload/tabular.vim
 60: ~/dotfiles/default/vim/ftplugin/python_fn.vim
 61: ~/dotfiles/default/vim/bundle/jedi/ftplugin/python/jedi.vim
 62: ~/dotfiles/default/vim/bundle/jedi/autoload/jedi.vim
 63: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/ftplugin/python.vim
 64: ~/dotfiles/default/vim/bundle/jedi/after/ftplugin/python/jedi.vim
 65: ~/dotfiles/default/vim/indent/python.vim
 66: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/indent/python.vim
 67: /usr/local/Cellar/vim/8.0.0596/share/vim/vim80/syntax/python.vim
 68: ~/dotfiles/default/vim/bundle/jedi/after/syntax/python.vim
 69: ~/dotfiles/default/vim/bundle/riv/after/syntax/python.vim
 70: ~/dotfiles/default/vim/bundle/ale/autoload/ale.vim
 71: ~/dotfiles/default/vim/bundle/ale/autoload/ale/util.vim
 72: ~/dotfiles/default/vim/bundle/ale/autoload/ale/linter.vim
 73: ~/dotfiles/default/vim/bundle/ale/ale_linters/python/flake8.vim
 74: ~/dotfiles/default/vim/bundle/ale/ale_linters/python/mypy.vim
 75: ~/dotfiles/default/vim/bundle/ale/ale_linters/python/pylint.vim
 76: ~/dotfiles/default/vim/bundle/editorconfig/autoload/editorconfig.vim
 77: ~/dotfiles/default/vim/bundle/ctrlp/autoload/ctrlp/utils.vim
 78: ~/dotfiles/default/vim/bundle/ale/autoload/ale/cursor.vim
 79: ~/dotfiles/default/vim/bundle/ale/autoload/ale/engine.vim
 80: ~/dotfiles/default/vim/bundle/ale/autoload/ale/python.vim
 81: ~/dotfiles/default/vim/bundle/ale/autoload/ale/path.vim
 82: ~/dotfiles/default/vim/bundle/vim-misc/autoload/xolox/misc/cursorhold.vim

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
blueyedcommented, Jun 3, 2017

I could reproduce it now.

I think there are two issues here.

  1. the completions appear to be wrong: why does msg get completed here? (seems to be a Jedi issue)
source = """import logging

logger = logging.getLogger(__name__)

def example(**kwargs):
    hello = kwargs['hello']
    logger.info("test %s", hello."""


import jedi
script = jedi.Script(source, 7, 33)

comps = script.completions()
print(comps)
  1. since there is only one match, and longest is set in completeopt (via g:jedi#auto_vim_configuration) this happens to get inserted then. We set completeopt to menuone,longest,preview by default. Adding noinsert there seems to fix it. Related commits in this regard: 217e56d, 2f06d90 (#399) I am working on a fix.
0reactions
blueyedcommented, Aug 7, 2017

@Flimm You’re welcome. Thanks for the report and testing it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can I pass the name of an attribute when it itself is being ...
The object itself doesn't exist yet, but the constructor is, ultimately a function, so you pass what you need as a function argument....
Read more >
Documentation - Advanced Types - TypeScript
A predicate takes the form parameterName is Type , where parameterName must be the name of a parameter from the current function signature....
Read more >
HTML attribute reference - HTML: HyperText Markup Language
Attribute Name Elements Description accept‑charset List of supported charsets. align, , , , , , , , , , , , , Specifies the horizontal...
Read more >
Error codes enabled by default - mypy 0.991 documentation
Mypy expects that the number and names of arguments match the called function. Note that argument type checks have a separate error code...
Read more >
Attributes and properties - The Modern JavaScript Tutorial
So when an element has id or another standard attribute, the corresponding property gets created. But that doesn't happen if the attribute is ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found