ale icon indicating copy to clipboard operation
ale copied to clipboard

python filetype nil bug

Open cxwx opened this issue 9 months ago • 2 comments

Information

neovim 0.11

Operating System: macos 15.4

What went wrong

                 Error executing vim.schedule lua callback: function ale#lsp#CallInitCallbacks[11]..<lambda>38[1]..ale#lsp_linter#OnInit[7]..ale#lsp#UpdateConfig[10]..ale#lsp#Send, line 12: Vim(return):E5108: Error executing lua ...lar/neovim/0.11.0/share/nvim/runtime/lua/vim/lsp/rpc.lua:281: Cannot serialise boolean: table key must be a number or string

stack traceback: [C]: in function 'encode' ...lar/neovim/0.11.0/share/nvim/runtime/lua/vim/lsp/rpc.lua:281: in function 'notify' .../neovim/0.11.0/share/nvim/runtime/lua/vim/lsp/client.lua:766: in function 'notify' ...rs/chenxu/software/nvim/lazy/plugins/ale/lua/ale/lsp.lua:135: in function 'send_message' [string "luaeval()"]:1: in main chunk [C]: in function 'ale#lsp#CallInitCallbacks' ...rs/chenxu/software/nvim/lazy/plugins/ale/lua/ale/lsp.lua:88: in function '' vim/_editor.lua: in function '' vim/_editor.lua: in function <vim/_editor.lua:0> stack traceback: [C]: in function 'ale#lsp#CallInitCallbacks' ...rs/chenxu/software/nvim/lazy/plugins/ale/lua/ale/lsp.lua:88: in function '' vim/_editor.lua: in function '' vim/_editor.lua: in function <vim/_editor.lua:0>

Reproducing the bug

only python file cause this errors open a .py file

:ALEInfo

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: ['flake8', 'mypy', 'pylint', '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: " Press Space to read :help for a setting let g:ale_python_auto_pipenv = v:false let g:ale_python_auto_poetry = v:false let g:ale_python_auto_uv = v:false let g:ale_python_auto_virtualenv = v:false let g:ale_python_flake8_auto_pipenv = 0 let g:ale_python_flake8_auto_poetry = 0 let g:ale_python_flake8_auto_uv = 0 let g:ale_python_flake8_change_directory = 'project' let g:ale_python_flake8_executable = 'flake8' let g:ale_python_flake8_options = '--max-line-length=200 --indent-size=2' let g:ale_python_flake8_use_global = 0 let g:ale_python_mypy_auto_pipenv = 0 let g:ale_python_mypy_auto_poetry = 0 let g:ale_python_mypy_auto_uv = 0 let g:ale_python_mypy_executable = 'mypy' let g:ale_python_mypy_ignore_invalid_syntax = 0 let g:ale_python_mypy_options = '' let g:ale_python_mypy_show_notes = 1 let g:ale_python_mypy_use_global = 0 let g:ale_python_pylint_auto_pipenv = 0 let g:ale_python_pylint_auto_poetry = 0 let g:ale_python_pylint_auto_uv = 0 let g:ale_python_pylint_change_directory = 1 let g:ale_python_pylint_executable = 'pylint' let g:ale_python_pylint_options = '' let g:ale_python_pylint_use_global = 0 let g:ale_python_pylint_use_msg_id = 0 let g:ale_python_pyright_auto_pipenv = 0 let g:ale_python_pyright_auto_poetry = 0 let g:ale_python_pyright_auto_uv = 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_auto_uv = 0 let g:ale_python_ruff_change_directory = 1 let g:ale_python_ruff_executable = 'ruff' let g:ale_python_ruff_options = '' let g:ale_python_ruff_use_global = 0

Global Variables: " Press Space to read :help for a setting let g:ale_cache_executable_check_failures = v:null let g:ale_change_sign_column_color = v:null let g:ale_command_wrapper = '' let g:ale_completion_delay = v:null let g:ale_completion_enabled = v:false let g:ale_completion_max_suggestions = v:null let g:ale_disable_lsp = 'auto' let g:ale_echo_cursor = v:true 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 = v:false let g:ale_fixers = {} let g:ale_history_enabled = v:true let g:ale_info_default_mode = 'preview' let g:ale_history_log_output = v:true let g:ale_keep_list_window_open = 0 let g:ale_lint_delay = 200 let g:ale_lint_on_enter = v:true let g:ale_lint_on_filetype_changed = v:true let g:ale_lint_on_insert_leave = v:true let g:ale_lint_on_save = v:true let g:ale_lint_on_text_changed = 'normal' let g:ale_linter_aliases = {} let g:ale_linters = {} let g:ale_linters_explicit = v:false let g:ale_linters_ignore = {'c': ['ccls', 'cspell'], 'sh': ['cspell'], 'markdown': ['languagetool'], 'lua': ['cspell'], 'asciidoc': ['languagetool'], 'rubyinfo': ['cspell'], 'cpp': ['ccls', 'cspell', 'clangtidy', 'cc', 'cpplint', 'flawfinder'], 'ruby': ['cspell']} let g:ale_list_vertical = v:false 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 = v:null let g:ale_maximum_file_size = v:null let g:ale_open_list = v:false let g:ale_pattern_options = v:null let g:ale_pattern_options_enabled = v:null let g:ale_root = {} let g:ale_set_balloons = v:false let g:ale_set_highlights = v:true let g:ale_set_loclist = v:true let g:ale_set_quickfix = v:false let g:ale_set_signs = v:true let g:ale_sign_column_always = v:null let g:ale_sign_error = v:null let g:ale_sign_info = v:null let g:ale_sign_offset = v:null let g:ale_sign_style_error = v:null let g:ale_sign_style_warning = v:null let g:ale_sign_warning = v:null let g:ale_sign_highlight_linenrs = v:null let g:ale_type_map = {} let g:ale_use_neovim_diagnostics_api = v:true let g:ale_use_global_executables = v:null let g:ale_virtualtext_cursor = 'disabled' let g:ale_warn_about_trailing_blank_lines = v:true let g:ale_warn_about_trailing_whitespace = v:true

Command History:

(finished - exit code 0) ['/bin/zsh', '-c', '''pylint'' --version']

<<<OUTPUT STARTS>>> pylint 3.3.6 astroid 3.3.9 Python 3.13.3 (main, Apr 8 2025, 13:54:08) [Clang 16.0.0 (clang-1600.0.26.6)] <<<OUTPUT ENDS>>>

(executable check - success) flake8 (finished - exit code 0) ['/bin/zsh', '-c', 'cd ''/Users/chenxu/cx_rc'' && ''flake8'' --version']

<<<OUTPUT STARTS>>> 7.2.0 (mccabe: 0.7.0, pycodestyle: 2.13.0, pyflakes: 3.3.2) CPython 3.13.3 on Darwin <<<OUTPUT ENDS>>>

(executable check - success) mypy (finished - exit code 0) ['/bin/zsh', '-c', 'cd ''/Users/chenxu/cx_rc'' && ''mypy'' --show-column-numbers --shadow-file ''/Users/chenxu/cx_rc/config/nvim/lua/plugins/aa.py'' ''/var/folders/05/dfw4d4ds0nx2xyyn7yt5ky3r0000gn/T/nvim.chenxu/55tP49/2/aa.py'' ''/Users/chenxu/cx_rc/config/nvim/lua/plugins/aa.py''']

<<<OUTPUT STARTS>>> Success: no issues found in 1 source file <<<OUTPUT ENDS>>>

(executable check - success) pylint (finished - exit code 0) ['/bin/zsh', '-c', 'cd ''/Users/chenxu/cx_rc'' && ''pylint'' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n --from-stdin ''/Users/chenxu/cx_rc/config/nvim/lua/plugins/aa.py'' < ''/var/folders/05/dfw4d4ds0nx2xyyn7yt5ky3r0000gn/T/nvim.chenxu/55tP49/3/aa.py''']

<<<OUTPUT STARTS>>>


Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

<<<OUTPUT ENDS>>>

(executable check - success) pyright-langserver (executable check - success) ruff (finished - exit code 0) ['/bin/zsh', '-c', 'cd ''/Users/chenxu/cx_rc'' && ''ruff'' --version']

<<<OUTPUT STARTS>>> ruff 0.11.4 <<<OUTPUT ENDS>>>

(finished - exit code 1) ['/bin/zsh', '-c', 'cd ''/Users/chenxu/cx_rc'' && ''ruff'' check -q --no-fix --output-format json-lines --stdin-filename ''/Users/chenxu/cx_rc/config/nvim/lua/plugins/aa.py'' - < ''/var/folders/05/dfw4d4ds0nx2xyyn7yt5ky3r0000gn/T/nvim.chenxu/55tP49/4/aa.py''']

<<<OUTPUT STARTS>>> {"cell":null,"code":"F401","end_location":{"column":13,"row":1},"filename":"/Users/chenxu/cx_rc/config/nvim/lua/plugins/aa.py","fix":{"applicability":"safe","edits":[{"content":"","end_location":{"column":1,"row":2},"location":{"column":1,"row":1}}],"message":"Remove unused import: numpy"},"location":{"column":8,"row":1},"message":"numpy imported but unused","noqa_row":1,"url":"https://docs.astral.sh/ruff/rules/unused-import"} <<<OUTPUT ENDS>>>

(finished - exit code 1) ['/bin/zsh', '-c', 'cd ''/Users/chenxu/cx_rc'' && ''flake8'' --max-line-length=200 --indent-size=2 --format=default --stdin-display-name ''/Users/chenxu/cx_rc/config/nvim/lua/plugins/aa.py'' - < ''/var/folders/05/dfw4d4ds0nx2xyyn7yt5ky3r0000gn/T/nvim.chenxu/55tP49/5/aa.py''']

<<<OUTPUT STARTS>>> /Users/chenxu/cx_rc/config/nvim/lua/plugins/aa.py:1:1: F401 'numpy' imported but unused <<<OUTPUT ENDS>>>

cxwx avatar Apr 26 '25 02:04 cxwx

this is some strange behavior from nvim and/or lua

>> call luaeval('vim.print(_A)', {})
{
  [true] = 6
}

and it's everywhere

...
  ale_filename_mappings = {
    [true] = 6
  },
  ale_filetype_blacklist = { "dirvish", "nerdtree", "qf", "tags", "unite" },
  ale_fix_buffer_data = {
    [true] = 6
  },
  ale_fix_on_save = false,
  ale_fixers = {
    [true] = 6
  },
  ale_python_pyright_config = {
    [true] = 6
  }
...

temporal solution is

let g:ale_use_neovim_lsp_api = 0

dicts still have their strange values, but at least lsp works

versusvoid avatar May 26 '25 09:05 versusvoid

I have experienced this issue as well for a while, seeing on nvim startup:

Cannot serialise boolean: table key must be a number or string

I have tried with a minimal config, meaning basically empty init.nvim, just setting up the plugin manager and including ALE plugin (without any config), and the same error is still shown on startup of nvim:

Error executing vim.schedule lua callback: function ale#lsp#CallInitCallbacks[11]..<lambda>17[1]..ale#lsp_linter#OnInit[7]..ale#lsp#UpdateConfig[10]..ale#lsp#Send, line 12: Vim(return):E5108: Error executing lua ...lar/neovim/0.11.4/share/nvim/runtime/lua/vim/lsp/rpc.lua:281: Cann
ot serialise boolean: table key must be a number or string
stack traceback:
        [C]: in function 'encode'
        ...lar/neovim/0.11.4/share/nvim/runtime/lua/vim/lsp/rpc.lua:281: in function 'notify'
        .../neovim/0.11.4/share/nvim/runtime/lua/vim/lsp/client.lua:773: in function 'notify'
        ...ocal/share/nvim/site/pack/packer/opt/ale/lua/ale/lsp.lua:135: in function 'send_message'
        [string "luaeval()"]:1: in main chunk
        [C]: in function 'ale#lsp#CallInitCallbacks'
        ...ocal/share/nvim/site/pack/packer/opt/ale/lua/ale/lsp.lua:88: in function ''
        vim/_editor.lua: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>
stack traceback:
        [C]: in function 'ale#lsp#CallInitCallbacks'
        ...ocal/share/nvim/site/pack/packer/opt/ale/lua/ale/lsp.lua:88: in function ''
        vim/_editor.lua: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

Ineed the only way I managed to get the error message away is by doing one of the two below:

vim.g.ale_disable_lsp = 1
vim.g.ale_use_neovim_lsp_api = 0

erikw avatar Sep 25 '25 09:09 erikw