Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completion not always working with context managers #1084

Closed
boojum opened this issue Apr 15, 2018 · 4 comments
Closed

Completion not always working with context managers #1084

boojum opened this issue Apr 15, 2018 · 4 comments

Comments

@boojum
Copy link

boojum commented Apr 15, 2018

Problem summary

Completion not always works with context managers. Picture is worth a thousand words:
https://asciinema.org/a/35sDlmrobGcLVHQiUfBOgTaG2

Expected

After the with statement I expect the completion to work normally. For example, I expect conn.cursor() and c.execute() to start completion after conn and c, respectively. This behaviour occurs with deoplete-jedi and ipython completion, both using jedi.

EDIT: tested against completor.vim and jedi-vim, which produces the same issue.

Environment Information

OS:

uname -r
4.15.15-1-ARCH

Neovim version:

nvim -v  
NVIM v0.2.2
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -Wconversion -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/build/neovim/src/build/config -I/build/neovim/src/neovim-0.2.2/src -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/build/neovim/src/build/src/nvim/auto -I/build/neovim/src/build/include
Compiled by builduser

Features: +acl +iconv +jemalloc +tui 
See ":help feature-compile"

system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

Minimal init.vim:

let s:plugin_manager=expand('~/.local/share/nvim/site/autoload/plug.vim')
let s:plugin_url='https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
if empty(glob(s:plugin_manager))
    echom 'vim-plug not found. Installing...'
    silent exec '!curl -fLo ' . s:plugin_manager . ' --create-dirs ' . s:plugin_url
    autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif

call plug#begin('~/.local/share/nvim/plugged')
Plug 'Shougo/deoplete.nvim', {'do': ':UpdateRemotePlugins'}
Plug 'zchee/deoplete-jedi'
call plug#end()

set completeopt=longest,menu

let g:python_host_prog = (expand('$HOME/.config/pyenv/versions/neovim2/bin/python'))
let g:python3_host_prog = (expand('$HOME/.config/pyenv/versions/neovim3/bin/python'))

let g:deoplete#enable_at_startup = 1

let g:jedi#completions_enabled = 1
@davidhalter
Copy link
Owner

sqlite3.connect is a builtin function and it's therefore not that easy to get return types for it. I think your best bet is to wait for #839. In that case we will also try to use https://github.com/python/typeshed which will definitely help you!

@dimaqq
Copy link

dimaqq commented Feb 7, 2019

@boojum looks like your "picture" got archived and is no longer visible. Would you perhaps update the description with a summary?

@boojum
Copy link
Author

boojum commented Feb 15, 2019

@boojum looks like your "picture" got archived and is no longer visible. Would you perhaps update the description with a summary?

Sure thing! I'll test it and update the description this weekend.

@davidhalter
Copy link
Owner

It looks like

import sqlite3

with sqlite3.connect() as c:
    c.

doesn't work, because there is no way that Jedi knows what __enter__ returns in typeshed.

If you look at __enter__, you can see that it's defined like this:

    def __enter__(self, *args, **kwargs): ...

I guess I'll wait until mypy solves this issue, because I'm pretty sure they also have this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants