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

Pyright linter doesn't detect newly added modules until restarting the language server #4792

Open
CGamesPlay opened this issue Jun 13, 2024 · 0 comments
Labels

Comments

@CGamesPlay
Copy link

Information

VIM version

VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Jan 4 2024 03:08:50)
macOS version - arm64

Operating System: macOS 12.7.1 (21G920)

What went wrong

  1. Set up an environment with pyright installed and ale configured to use it.
  2. Create main.py with print("Hello") and verify that Ale can provide the type definition for print.
  3. In the same vim session, create lib.py with def greet(): print("Hello")
  4. Modify main.py to read from lib import greet; greet()
  5. Notice that the Pyright linter produces an error: Import "lib" could not be resolved.
  6. Use :ALEStopAllLSPs and :w to force a restart of the Pyright langserver.
  7. Notice that lib is now detected and Ale can provide the type definition for greet.

A similar issue was reported to Pyright (microsoft/pyright#4635), so to quote from there:

The capability that we rely on is capabilities.workspace.didChangeWatchedFiles.dynamicRegistration. If the client doesn't support this capability, then pyright won't be able to respond to file watcher events. Please check with the lspconfig plugin maintainers to see if they would consider adding this capability.

The issue also references adding this support to NeoVim: neovim/neovim#21293

:ALEInfo

Expand

Current Filetype: python
Available Linters: ['bandit', 'cspell', 'flake8', 'flakehell', 'jedils', 'mypy', 'prospector', 'pycln', 'pycodestyle', 'pydocstyle', 'pyflakes', 'pylama', 'pylint', 'pylsp', 'pyre', 'pyright', 'refurb', 'ruff', 'unimport', 'vulture']
Linter Aliases:
'jedils' -> ['jedi_language_server']
Enabled Linters: ['pyright', 'ruff']
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
'ruff_format' - Fix python files with the ruff formatter.
'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_auto_virtualenv = 0
let g:ale_python_black_auto_pipenv = 0
let g:ale_python_black_auto_poetry = 0
let g:ale_python_black_change_directory = 1
let g:ale_python_black_executable = 'black'
let g:ale_python_black_options = ''
let g:ale_python_black_use_global = 0
let g:ale_python_pyright_auto_pipenv = 0
let g:ale_python_pyright_auto_poetry = 0
let g:ale_python_pyright_config = {}
let g:ale_python_pyright_executable = 'pyright-langserver'
let g:ale_python_pyright_use_global = 0
let g:ale_python_ruff_auto_pipenv = 0
let g:ale_python_ruff_auto_poetry = 0
let g:ale_python_ruff_change_directory = 1
let g:ale_python_ruff_executable = 'ruff'
let g:ale_python_ruff_options = '--unfixable F401,F841'
let g:ale_python_ruff_use_global = 0

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 = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_disable_lsp = 'auto'
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%linter%:%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 = 1
let g:ale_fixers = {'jsonc': ['prettier'], 'go': ['gofmt', 'goimports'], 'hcl': ['remove_trailing_lines', 'terraform', 'trim_whitespace'], 'astro': ['prettier'], 'json': ['prettier'], 'typescript': ['prettier'], 'ruby': ['rubocop'], 'javascript': ['prettier'], 'rust': ['rustfmt'], 'css': ['prettier'], 'python': ['black', 'ruff'], 'typescriptreact': ['prettier']}
let g:ale_history_enabled = 1
let g:ale_info_default_mode = 'preview'
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 = 0
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'never'
let g:ale_linter_aliases = {}
let g:ale_linters = {'graphql': ['gqlint'], 'rust': ['analyzer'], 'python': ['pyright', 'ruff'], 'beancount': []}
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 = '%linter%:%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 = 0
let g:ale_sign_error = ' ✖'
let g:ale_sign_info = 'I'
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_type_map = {}
let g:ale_use_neovim_diagnostics_api = 0
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 1
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1

Command History:

(executable check - success) /Users/rpatterson/Library/Caches/pypoetry/virtualenvs/amelpair-3REbIIao-py3.11/bin/pyright-langserver
(executable check - success) /Users/rpatterson/Library/Caches/pypoetry/virtualenvs/amelpair-3REbIIao-py3.11/bin/ruff
(finished - exit code 0) ['/bin/sh', '-c', 'cd ''/Users/rpatterson/Projects/amel/pair'' && ''/Users/rpatterson/Library/Caches/pypoetry/virtualenvs/amelpair-3REbIIao-py3.11/bin/ruff'' --version']

<<>>
ruff 0.3.7
<<>>

(finished - exit code 0) ['/bin/sh', '-c', 'cd ''/Users/rpatterson/Projects/amel/pair'' && ''/Users/rpatterson/Library/Caches/pypoetry/virtualenvs/amelpair-3REbIIao-py3.11/bin/ruff'' check -q --no-fix --unfixable F401,F841 --output-format json-lines --stdin-filename ''/Users/rpatterson/Projects/amel/pair/main.py'' - < ''/var/folders/g7/9y_ydbnj2fs_fvp8xf44p8gc0000gn/T/viEPC5y/3/main.py''']

<<>>

(started) ['/bin/sh', '-c', 'cd ''/Users/rpatterson/Projects/amel/pair'' && ''/Users/rpatterson/Library/Caches/pypoetry/virtualenvs/amelpair-3REbIIao-py3.11/bin/pyright-langserver'' --stdio']
(finished - exit code 0) ['/bin/sh', '-c', 'cd ''/Users/rpatterson/Projects/amel/pair'' && ''/Users/rpatterson/Library/Caches/pypoetry/virtualenvs/amelpair-3REbIIao-py3.11/bin/black'' - < ''/var/folders/g7/9y_ydbnj2fs_fvp8xf44p8gc0000gn/T/viEPC5y/4/main.py''']
(finished - exit code 0) ['/bin/sh', '-c', 'cd ''/Users/rpatterson/Projects/amel/pair'' && ''/Users/rpatterson/Library/Caches/pypoetry/virtualenvs/amelpair-3REbIIao-py3.11/bin/ruff'' --unfixable F401,F841 --stdin-filename ''main.py'' --fix - < ''/var/folders/g7/9y_ydbnj2fs_fvp8xf44p8gc0000gn/T/viEPC5y/5/main.py''']
(finished - exit code 0) ['/bin/sh', '-c', 'cd ''/Users/rpatterson/Projects/amel/pair'' && ''/Users/rpatterson/Library/Caches/pypoetry/virtualenvs/amelpair-3REbIIao-py3.11/bin/ruff'' check -q --no-fix --unfixable F401,F841 --output-format json-lines --stdin-filename ''/Users/rpatterson/Projects/amel/pair/main.py'' - < ''/var/folders/g7/9y_ydbnj2fs_fvp8xf44p8gc0000gn/T/viEPC5y/6/main.py''']

<<>>

(finished - exit code 0) ['/bin/sh', '-c', 'cd ''/Users/rpatterson/Projects/amel/pair'' && ''/Users/rpatterson/Library/Caches/pypoetry/virtualenvs/amelpair-3REbIIao-py3.11/bin/black'' - < ''/var/folders/g7/9y_ydbnj2fs_fvp8xf44p8gc0000gn/T/viEPC5y/11/main.py''']
(finished - exit code 0) ['/bin/sh', '-c', 'cd ''/Users/rpatterson/Projects/amel/pair'' && ''/Users/rpatterson/Library/Caches/pypoetry/virtualenvs/amelpair-3REbIIao-py3.11/bin/ruff'' --unfixable F401,F841 --stdin-filename ''main.py'' --fix - < ''/var/folders/g7/9y_ydbnj2fs_fvp8xf44p8gc0000gn/T/viEPC5y/12/main.py''']
(finished - exit code 0) ['/bin/sh', '-c', 'cd ''/Users/rpatterson/Projects/amel/pair'' && ''/Users/rpatterson/Library/Caches/pypoetry/virtualenvs/amelpair-3REbIIao-py3.11/bin/ruff'' check -q --no-fix --unfixable F401,F841 --output-format json-lines --stdin-filename ''/Users/rpatterson/Projects/amel/pair/main.py'' - < ''/var/folders/g7/9y_ydbnj2fs_fvp8xf44p8gc0000gn/T/viEPC5y/13/main.py''']

<<>>

(finished - exit code 0) ['/bin/sh', '-c', 'cd ''/Users/rpatterson/Projects/amel/pair'' && ''/Users/rpatterson/Library/Caches/pypoetry/virtualenvs/amelpair-3REbIIao-py3.11/bin/black'' - < ''/var/folders/g7/9y_ydbnj2fs_fvp8xf44p8gc0000gn/T/viEPC5y/14/main.py''']
(finished - exit code 0) ['/bin/sh', '-c', 'cd ''/Users/rpatterson/Projects/amel/pair'' && ''/Users/rpatterson/Library/Caches/pypoetry/virtualenvs/amelpair-3REbIIao-py3.11/bin/ruff'' --unfixable F401,F841 --stdin-filename ''main.py'' --fix - < ''/var/folders/g7/9y_ydbnj2fs_fvp8xf44p8gc0000gn/T/viEPC5y/15/main.py''']
(finished - exit code 0) ['/bin/sh', '-c', 'cd ''/Users/rpatterson/Projects/amel/pair'' && ''/Users/rpatterson/Library/Caches/pypoetry/virtualenvs/amelpair-3REbIIao-py3.11/bin/ruff'' check -q --no-fix --unfixable F401,F841 --output-format json-lines --stdin-filename ''/Users/rpatterson/Projects/amel/pair/main.py'' - < ''/var/folders/g7/9y_ydbnj2fs_fvp8xf44p8gc0000gn/T/viEPC5y/16/main.py''']

<<>>

(started) ['/bin/sh', '-c', 'cd ''/Users/rpatterson/Projects/amel/pair'' && ''/Users/rpatterson/Library/Caches/pypoetry/virtualenvs/amelpair-3REbIIao-py3.11/bin/pyright-langserver'' --stdio']

@CGamesPlay CGamesPlay added the bug label Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant