dense-analysis / ale

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
BSD 2-Clause "Simplified" License
13.53k stars 1.43k forks source link

[python] ALEImport does not import required modules #4433

Closed massimiliano-della-rovere closed 3 months ago

massimiliano-della-rovere commented 1 year ago

ALEImport does not import decimal or collections. Both JediLS and Pyright are installed.


$ cat test.py

print(collections.defaultdict()) decimal.Decimal()


$ pyright

No configuration file found. No pyproject.toml file found. stubPath /home/mader/Documenti/typings is not a valid directory. Assuming Python platform Linux Searching for source files Found 1 source file pyright 1.1.291 /home/mader/Documenti/test.py /home/mader/Documenti/test.py:1:7 - error: "collections" is not defined (reportUndefinedVariable) /home/mader/Documenti/test.py:2:1 - error: "decimal" is not defined (reportUndefinedVariable) 2 errors, 0 warnings, 0 informations Completed in 0.864sec

:ALEInfo

Current Filetype: python Available Linters: ['bandit', 'cspell', 'flake8', 'flakehell', 'jedils', 'mypy', 'prospector', 'pycln', 'pycodest yle', 'pydocstyle', 'pyflakes', 'pylama', 'pylint', 'pylsp', 'pyre', 'pyright', 'refurb', 'ruff', 'unimport', 'vu lture'] Enabled Linters: ['bandit', 'jedils', 'pycln', 'pylama', 'pylsp', 'pyright'] Ignored Linters: [] Suggested Fixers: 'add_blank_lines_for_python_control_statements' - Add blank lines before control statements. 'autoflake' - Fix flake issues with autoflake. 'autoimport' - Fix import issues with autoimport. 'autopep8' - Fix PEP8 issues with autopep8. 'black' - Fix PEP8 issues with black. 'isort' - Sort Python imports with isort. 'pycln' - remove unused python import statements 'pyflyby' - Tidy Python imports with pyflyby. 'remove_trailing_lines' - Remove all blank lines at the end of a file. 'reorder-python-imports' - Sort Python imports with reorder-python-imports. 'ruff' - A python linter/fixer for Python written in Rust 'trim_whitespace' - Remove all trailing whitespace characters at the end of every line. 'yapf' - Fix Python files with yapf. Linter Variables: let g:ale_python_auto_pipenv = 0 let g:ale_python_auto_poetry = 0 let g:ale_python_bandit_auto_pipenv = 0 let g:ale_python_bandit_auto_poetry = 0 let g:ale_python_bandit_executable = 'bandit' let g:ale_python_bandit_options = '' let g:ale_python_bandit_use_config = 1 let g:ale_python_bandit_use_global = 0 let g:ale_python_jedils_auto_pipenv = 0 let g:ale_python_jedils_executable = 'jedi-language-server' let g:ale_python_jedils_use_global = 0 let g:ale_python_pycln_auto_pipenv = 0 let g:ale_python_pycln_auto_poetry = 0 let g:ale_python_pycln_change_directory = 1 let g:ale_python_pycln_config_file = '' let g:ale_python_pycln_executable = 'pycln' let g:ale_python_pycln_options = '' let g:ale_python_pycln_use_global = 0 let g:ale_python_pylama_auto_pipenv = 0 let g:ale_python_pylama_auto_poetry = 0 let g:ale_python_pylama_change_directory = 1 let g:ale_python_pylama_executable = 'pylama' let g:ale_python_pylama_options = '' let g:ale_python_pylama_use_global = 0 let g:ale_python_pylsp_auto_pipenv = 0 let g:ale_python_pylsp_auto_poetry = 0 let g:ale_python_pylsp_config = {} let g:ale_python_pylsp_executable = 'pylsp' let g:ale_python_pylsp_options = '' let g:ale_python_pylsp_use_global = 0 let g:ale_python_pyright_config = {} let g:ale_python_pyright_executable = 'pyright-langserver' Global Variables: let g:ale_cache_executable_check_failures = v:null let g:ale_change_sign_column_color = 0 let g:ale_command_wrapper = '' let g:ale_completion_delay = 100 let g:ale_completion_enabled = 1 let g:ale_completion_max_suggestions = 50 let g:ale_disable_lsp = 0 let g:ale_echo_cursor = 1 let g:ale_echo_msg_error_str = 'Error' let g:ale_echo_msg_format = '%code: %%s' let g:ale_echo_msg_info_str = 'Info' let g:ale_echo_msg_warning_str = 'Warning' let g:ale_enabled = 1 let g:ale_fix_on_save = 0 let g:ale_fixers = {'vim': ['remove_trailing_lines', 'trim_whitespace'], 'sh': ['remove_trailing_lines', 'shfmt', 'trim_whitespace'], 'javascript': ['prettier', 'remove_trailing_lines', 'trim_whitespace', 'xo'], 'python': ['ad d_blank_lines_for_python_control_statements', 'black', 'isort', 'reorder-python-imports', 'remove_trailing_lines' , 'ruff', 'trim_whitespace', 'yapf']} let g:ale_history_enabled = 1 let g:ale_history_log_output = 1 let g:ale_keep_list_window_open = 0 let g:ale_lint_delay = 200 let g:ale_lint_on_enter = 1 let g:ale_lint_on_filetype_changed = 1 let g:ale_lint_on_insert_leave = 1 let g:ale_lint_on_save = 1 let g:ale_lint_on_text_changed = 'normal' let g:ale_linter_aliases = {} let g:ale_linters = {'sh': ['bashate', 'shell', 'shellcheck'], 'dockerfile': ['dockerfile_linter'], 'javascript': ['importjs', 'prettier', 'xo'], 'python': ['bandit', 'jedils', 'pycln', 'pylama', 'pylsp', 'pyright']} let g:ale_linters_explicit = 0 let g:ale_linters_ignore = {} let g:ale_list_vertical = 0 let g:ale_list_window_size = 10 let g:ale_loclist_msg_format = '%code: %%s' let g:ale_max_buffer_history_size = 20 let g:ale_max_signs = -1 let g:ale_maximum_file_size = v:null let g:ale_open_list = 0 let g:ale_pattern_options = v:null let g:ale_pattern_options_enabled = v:null let g:ale_root = {} let g:ale_set_balloons = 1 let g:ale_set_highlights = 1 let g:ale_set_loclist = 1 let g:ale_set_quickfix = 0 let g:ale_set_signs = 1 let g:ale_sign_column_always = 1 let g:ale_sign_error = '' let g:ale_sign_info = '' let g:ale_sign_offset = 1000000 let g:ale_sign_style_error = '' let g:ale_sign_style_warning = '' let g:ale_sign_warning = '' let g:ale_sign_highlight_linenrs = 0 let g:ale_statusline_format = v:null let g:ale_type_map = {} let g:ale_use_neovim_diagnostics_api = 0 let g:ale_use_global_executables = v:null let g:ale_virtualtext_cursor = 'all' let g:ale_warn_about_trailing_blank_lines = 1 let g:ale_warn_about_trailing_whitespace = 1 Command History: (executable check - success) bandit (finished - exit code 0) ['/bin/bash', '-c', '''bandit'' --format custom --msg-template "{line}:{test_id}:{severi ty}:{msg}" - < ''/tmp/vyrgM3T/3/test.py'''] <<>> (executable check - success) jedi-language-server (executable check - success) pycln (finished - exit code 0) ['/bin/bash', '-c', 'cd ''/home/mader/Documenti'' && ''pycln'' --version'] <<>> pycln, version 2.1.3 <<>> (executable check - success) pylama (finished - exit code 0) ['/bin/bash', '-c', 'cd ''/home/mader/Documenti'' && ''pylama'' --version'] <<>> pylama 8.4.1 <<>> (executable check - success) pylsp (executable check - success) pyright-langserver (finished - exit code 0) ['/bin/bash', '-c', 'cd ''/home/mader/Documenti'' && ''pycln'' --check - < ''/tmp/vyrgM3 T/6/test.py'''] <<>> print(collections.defaultdict()) decimal.Decimal() Looks good! sparkles cake sparkles 1 file would be left unchanged. <<>> (started) ['/bin/bash', '-c', 'cd ''/home/mader/Documenti'' && ''pyright-langserver'' --stdio'] (started) ['/bin/bash', '-c', '''jedi-language-server'''] (started) ['/bin/bash', '-c', 'cd ''/home/mader/Documenti'' && ''pylsp'''] (finished - exit code 1) ['/bin/bash', '-c', 'cd ''/home/mader/Documenti'' && ''pylama'' --format json ''/home/ma der/Documenti/test.py'''] <<>> [{"source": "pyflakes", "col": 7, "lnum": 1, "etype": "E", "message": "undefined name 'collections'", "filename": "test.py", "number": "E0602"}, {"source": "pyflakes", "col": 1, "lnum": 2, "etype": "E", "message": "undefined n ame 'decimal'", "filename": "test.py", "number": "E0602"}] <<>>


VIM - Vi IMproved 9.0 (2022 Jun 28, compilato May 10 2022 08:40:37) Patch incluse: 1-749 Modificato da team+vim@tracker.debian.org Compilato da team+vim@tracker.debian.org Versione gigante con GUI GTK3. Funzionalità incluse (+) o escluse (-): +acl +file_in_path +mouse_urxvt -tag_any_white +arabic +find_in_path +mouse_xterm +tcl +autocmd +float +multi_byte +termguicolors +autochdir +folding +multi_lang +terminal -autoservername -footer -mzscheme +terminfo +balloon_eval +fork() +netbeans_intg +termresponse +balloon_eval_term +gettext +num64 +textobjects +browse -hangul_input +packages +textprop ++builtin_terms +iconv +path_extra +timers +byte_offset +insert_expand +perl +title +channel +ipv6 +persistent_undo +toolbar +cindent +job +popupwin +user_commands +clientserver +jumplist +postscript +vartabs +clipboard +keymap +printer +vertsplit +cmdline_compl +lambda +profile +vim9script +cmdline_hist +langmap -python +viminfo +cmdline_info +libcall +python3 +virtualedit +comments +linebreak +quickfix +visual +conceal +lispindent +reltime +visualextra +cryptv +listcmds +rightleft +vreplace +cscope +localmap +ruby +wildignore +cursorbind +lua +scrollbind +wildmenu +cursorshape +menu +signs +windows +dialog_con_gui +mksession +smartindent +writebackup +diff +modify_fname +sodium +X11 +digraphs +mouse +sound -xfontset +dnd +mouseshape +spell +xim -ebcdic +mouse_dec +startuptime +xpm +emacs_tags +mouse_gpm +statusline +xsmp_interact +eval -mouse_jsbterm -sun_workshop +xterm_clipboard +ex_extra +mouse_netterm +syntax -xterm_save +extra_search +mouse_sgr +tag_binary -farsi -mouse_sysmouse -tag_old_static 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 menù 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/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/x86_64-linux-gnu -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wdate-time -g -O2 -ffile-prefix-map=/build/vim-cdpF6P/vim-9.0.0749=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 Link: gcc -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -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 -lselinux -lcanberra -lsodium -lacl -lattr -lgpm -L/usr/lib -llua5.2 -Wl,-E -fstack-protector-strong -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu/perl/5.34/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python3.10/config-3.10-x86_64-linux-gnu -lpython3.10 -lcrypt -ldl -lm -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm -lruby-3.0 -lm -L/usr/lib

w0rp commented 1 year ago

I'll have to look into this one. I've seen it kind of work with maybe just Pyright. It's probably Jedi making something available without the import line for it.

w0rp commented 3 months ago

I tend not to close issues as stale, but in this case I will, as I use ALE for Python every day. If this is still valid, let me know.