dense-analysis / ale

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

RunWithVersionCheck with Python Poetry will check version of Poetry rather than tool #4425

Open mkaito opened 1 year ago

mkaito commented 1 year ago

Information

VIM version

NVIM v0.8.2 Build type: Release

Operating System: MacOS Ventura 13.1

What went wrong

Python linters that use RunWithVersionCheck (only flake8 and flakehell as far as I can tell) with poetry will run poetry --version for the version check.

Reproducing the bug

~/dev/playground/python
❯ poetry new repro
Created package repro in repro

~/dev/playground/python
❯ cd repro

~/dev/playground/python/repro
❯ poetry add flake8
Creating virtualenv repro in /Users/mkaito/dev/playground/python/repro/.venv
Using version ^6.0.0 for flake8

Updating dependencies
Resolving dependencies... (0.1s)

Writing lock file

Package operations: 4 installs, 0 updates, 0 removals

  • Installing mccabe (0.7.0)
  • Installing pycodestyle (2.10.0)
  • Installing pyflakes (3.0.1)
  • Installing flake8 (6.0.0)

~/dev/playground/python/repro
❯ nvim repro/__init__.py

# :ALEInfoToClipboard, see below

Note in the ALEInfo below:

  1. It runs poetry --version and thinks the executable to cache for is poetry instead of flake8
  2. It does not run flake8 with the --stdin-display-name argument because it only does that for flake8 >= 3.0.0.

:ALEInfo

Expand Current Filetype: python Available Linters: ['bandit', 'cspell', 'flake8', 'flakehell', 'jedils', 'mypy', 'prospector', 'pycodestyle', 'pydocstyle', 'pyflakes', 'pylama', 'pylint', 'pylsp', 'pyre', 'pyright', 'refurb', 'ruff', 'unimport', 'vulture'] Enabled Linters: ['flake8', 'pylsp'] 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. '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 = 1 let g:ale_python_flake8_auto_pipenv = 0 let g:ale_python_flake8_auto_poetry = 0 let g:ale_python_flake8_change_directory = 'project' let g:ale_python_flake8_executable = 'flake8' let g:ale_python_flake8_options = '' let g:ale_python_flake8_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 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 = 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 = 1 let g:ale_fixers = {'*': ['trim_whitespace', 'remove_trailing_lines'], 'python': ['isort', 'black']} 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 = {'python': ['flake8', 'pylsp']} 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 = 0 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 = '--' 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_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) poetry (finished - exit code 0) ['/bin/zsh', '-c', 'cd ''/Users/mkaito/dev/playground/python/repro'' && ''poetry'' --version'] <<>> Poetry (version 1.3.2) <<>> (finished - exit code 1) ['/bin/zsh', '-c', 'cd ''/Users/mkaito/dev/playground/python/repro'' && ''poetry'' run flake8 --format=default - < ''/var/folders/jl/2thbz14n6zd96785505w3ngw0000gn/T/nvim.mkaito/PUcaZq/3/__init__.py'''] <<>> stdin:1:1: W391 blank line at end of file <<>>
w0rp commented 1 year ago

This is probably a general issue with all Python linters that use poetry. I should look at all of them.

peterzhu1992 commented 1 year ago

Same on pipenv.

akifd commented 3 weeks ago

Any updates on this? Because of this issue with Poetry, having settings like per-file-ignores do not work because the --stdin-display-name is missing and the filename is not detected correctly.

Would be really nice if this would get fixed soon.