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

Inconsistent behavior for "import" keyword in Python #775

Closed
sassanh opened this issue Feb 2, 2018 · 6 comments
Closed

Inconsistent behavior for "import" keyword in Python #775

sassanh opened this issue Feb 2, 2018 · 6 comments

Comments

@sassanh
Copy link

sassanh commented Feb 2, 2018

Issue

With g:jedi#smart_auto_mappings set to 1 sometimes when I write

from datetime |CURSOR HERE|

it automatically adds import and I end up with

from datetime import |CURSOR HERE|

but sometimes it opens a completion menu and I should select import (it's the only option.)

Any idea how can I make it consistent? (I prefer first case.)

I'm using nvim-completion-manager
This is the issue I opened there for reference: roxma/nvim-completion-manager#189

Steps to reproduce

Output of “:verbose JediDebugInfo”

@davidhalter
Copy link
Owner

Is this related with the timeout that import is only written after a certain amount of microseconds?

You might just experiment with that one and set it to zero (so the behavior is consistent).

@sassanh
Copy link
Author

sassanh commented Feb 3, 2018

I'll try it and will update you here.

@sassanh
Copy link
Author

sassanh commented Feb 4, 2018

Unfortunately it didn't work, this is "JediDebugInfo" right after a from timezone which didn't add import automatically (excluding script names as the list was too long):

#### Jedi-vim debug information
Using Python version: 3
 - sys.version: `3.6.4 (default, Jan  6 2018, 11:51:59), [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]`
 - site module: `/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site.py`
Jedi path: `/Users/sassanharadji/.config/nvim/plugged/jedi-vim/pythonx/jedi/jedi/__init__.py`
 - version: 0.11.1
 - sys_path:
    - `/Users/sassanharadji/.virtualenvs/escape/lib/python3.6/site-packages`
    - `/Users/sassanharadji/.virtualenvs/escape/lib/python3.6/site-packages`
    - `/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python36.zip`
    - `/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6`
    - `/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload`
    - `/usr/local/lib/python3.6/site-packages`
    - `/usr/local/Cellar/numpy/1.14.0/libexec/nose/lib/python3.6/site-packages`
    - `_vim_path_`
    - `/Users/sassanharadji/.config/nvim/plugged/vim-virtualenv/autoload`
 - jedi-vim git version: 0.8.0-126-g37bd03c-dirty
 - jedi git submodule status:  02f238ce08f2d7f9c4af9a17cbf5754836775e2f pythonx/jedi (v0.11.1)
 2ca629a2f6db2e905ddd5188113b1045f8a00fc2 pythonx/parso (v0.1.1)

##### Settings

g:jedi#popup_select_first = 0 (default: 1)
g:jedi#documentation_command = '<leader>K' (default: 'K')
g:jedi#usages_command = '<leader>U' (default: '<leader>n')
g:jedi#popup_on_dot = 0 (default: 1)
g:jedi#rename_command = '<leader><c-r>' (default: '<leader>r')
g:jedi#auto_vim_configuration = 0 (default: 1)
g:jedi#goto_assignments_command = '<leader><c-]>' (default: '<leader>g')
g:jedi#goto_definitions_command = '<c-]>' (default: '')

  omnifunc=jedi#completions
        Last set from ~/.config/nvim/plugged/jedi-vim/autoload/jedi.vim
  completeopt=menu,menuone,noinsert,noselect,preview
        Last set from ~/.config/nvim/plugged/nvim-completion-manager/autoload/cm.vim


#### :version

NVIM v0.2.3-564-g6452831cf
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM
_UNIBI_HAS_VAR_FROM -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 -I/tmp/neovim-20180131-66382-qf7w7a/build/config -I/tmp/neovim-20180
131-66382-qf7w7a/src -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/opt/gettext/include -I/usr/include -I/tmp/neovim-20180131-66382-qf7w7a/build/src/nvim/auto -I/tmp/neovim-20180131-66382-qf7w7a/build/include
Compiled by sassanharadji@MacBook-Pro

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

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/HEAD-6452831/share/nvim"

Run :checkhealth for more info

#### :messages
"Frontend/scripts/reserve.js" 255L, 12219C
session.vim 2.13.1: Opened global 'escape' session from ~/.config/nvim/sessions/escape.vim.
"reserve/models.py" 37L, 1046C
7 lines yanked
7 more lines
1 change; before #72  2 seconds ago
"reserve/models.py" 44L, 1236C written
"reserve/models.py" 38L, 1129C written
"Frontend/scripts/reserve.js" 255 lines --92%--
"reserve/models.py" 38 lines --94%--
"reserve/serializers.py" 39L, 899C
"reserve/models.py" line 36 of 38 --94%-- col 7
"reserve/serializers.py" line 38 of 39 --97%-- col 13
Back at original
Back at original
Back at original
match 1 of 3
Back at original
Back at original
Back at original
Back at original
Back at original
Back at original
Pattern not found
[flake8] line too long (96 > 79 characters)
[flake8] line too long (96 > 79 characters)
[flake8] line too long (96 > 79 characters)
[flake8] line too long (96 > 79 characters)
[flake8] undefined name 'timezone'
[flake8] undefined name 'timezone'
[flake8] undefined name 'timezone'
[flake8] undefined name 'timezone'
[flake8] undefined name 'timezone'
[flake8] undefined name 'timezone'
[flake8] undefined name 'timezone'
[flake8] undefined name 'timezone'
[flake8] undefined name 'timezone'
[flake8] line too long (93 > 79 characters)
[flake8] line too long (93 > 79 characters)
[flake8] line too long (93 > 79 characters)
[flake8] line too long (93 > 79 characters)
[flake8] line too long (93 > 79 characters)
[flake8] line too long (93 > 79 characters)
[flake8] line too long (93 > 79 characters)
[flake8] line too long (93 > 79 characters)
[flake8] line too long (92 > 79 characters)
1 change; before #52  2 seconds ago
[flake8] line too long (92 > 79 characters)
1 line less; before #51  8 seconds ago
[flake8] undefined name 'timezone'
[flake8] undefined name 'timezone'
[flake8] isort found an unexpected blank line in imports
Pattern not found
Back at original
Back at original
Back at original
The only match
Back at original
The only match
Pattern not found
Pattern not found
Back at original
Back at original
Back at original
Back at original
Back at original
[flake8] SyntaxError: invalid syntax
[flake8] SyntaxError: invalid syntax
NVIM v0.2.3-564-g6452831cf
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM
_UNIBI_HAS_VAR_FROM -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 -I/tmp/neovim-20180131-66382-qf7w7a/build/config -I/tmp/neovim-20180
131-66382-qf7w7a/src -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/us
r/local/opt/gettext/include -I/usr/include -I/tmp/neovim-20180131-66382-qf7w7a/build/src/nvim/auto -I/tmp/neovim-20180131-66382-qf7w7a/build/include
<details><summary>:scriptnames</summary>
</details>

@blueyed
Copy link
Collaborator

blueyed commented Jun 22, 2019

Looks like a bug / conflict with something else.
Might be worth trying / looking into #708 if it bothers you (but it is outdated).
The feature is also no enabled by default anymore.

@davidhalter
Copy link
Owner

Please check again if this is still an issue. Some things have changed and I have never seen this bug (I'm using the feature).

@sassanh
Copy link
Author

sassanh commented Dec 26, 2019

I guess it's safe to close this issue considering I haven't seen any inconsistency recently. I'll reopen again if I see any inconsistency regarding this issue.

@sassanh sassanh closed this as completed Dec 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants