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

ALEHover throws error in python using mspyls #3273

Closed
anihm136 opened this issue Aug 7, 2020 · 3 comments
Closed

ALEHover throws error in python using mspyls #3273

anihm136 opened this issue Aug 7, 2020 · 3 comments
Labels

Comments

@anihm136
Copy link

anihm136 commented Aug 7, 2020

Information

VIM version

NVIM v0.5.0-593-g1ca67a73c
Build type: RelWithDebInfo

Operating System: Ubuntu 20.04

What went wrong

Hovering over specific entities in a python file (or running :ALEHover on them) causes the following error to show up -

Error detected while processing function <SNR>181_NeoVimCallback[4]..ale#util#JoinNeovimOutput[2]..<lambda>12[1]..ale#lsp#HandleMessage[30]..ale#hove
r#HandleLSPResponse:
line   35:
E716: Key not present in Dictionary: value]
Error detected while processing function <SNR>181_NeoVimCallback[4]..ale#util#JoinNeovimOutput[2]..<lambda>12[1]..ale#lsp#HandleMessage[30]..ale#hove
r#HandleLSPResponse:
line   35:
E15: Invalid expression: [l:result.value]

I tried printing the dictionary for some of the entities that I identified as throwing errors. It appears that the dictionary does not have the key 'value', but only {'kind': 'plaintext'}

Reproducing the bug

  1. Open a python file
  2. Hover over any entity throwing error. Currently I have identified list indices and dictionary keys to throw errors, there may be more
    Ex: (| indicates cursor)
a = [1,2,3]
b = a[1|] ##Error
c = {1:2, 3:4}
d = c[1|] ##Error

:ALEInfo

 Current Filetype: python
Available Linters: ['mspyls', 'bandit', 'flake8', 'mypy', 'prospector', 'pycodestyle', 'pydocstyle', 'pyflakes', 'pylama', 'pylint', 'pyls', 'pyre', 'vulture']
  Enabled Linters: ['mspyls', 'flake8', 'pylint']
 Suggested Fixers: 
  'add_blank_lines_for_python_control_statements' - Add blank lines before control statements.
  'autopep8' - Fix PEP8 issues with autopep8.
  'black' - Fix PEP8 issues with black.
  'isort' - Sort Python imports with isort.
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'reorder-python-imports' - Sort Python imports with reorder-python-imports.
  '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_flake8_auto_pipenv = 0
let g:ale_python_flake8_change_directory = 1
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_pylint_auto_pipenv = 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
 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_echo_cursor = 1
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {'*': ['remove_trailing_lines', 'trim_whitespace'], 'javascript': ['eslint']}
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 = {'vim': ['ale_custom_linting_rules'], 'zsh': ['shell', 'language_server'], 'typescript': ['eslint', 'tsserver'], 'c': ['clangd', 'clang'], 'json': ['jsonls'], 'typescriptreact': ['eslint', 'tsserver'], 'sh': ['shell', 'language_server'], 'php': ['php'], 'javascript': ['eslint', 'tsserver'], 'cpp': ['clangd', 'clang'], 'css': ['cssls'], 'python': ['pylint', 'flake8', 'mspyls']}
let g:ale_linters_explicit = 1
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '[%linter%] %s [%severity%]'
let g:ale_lsp_root = {}
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_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 = 1
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
  Command History:

(executable check - success) dotnet
(executable check - success) flake8
(finished - exit code 0) ['/usr/bin/zsh', '-c', '''flake8'' --version']

<<<OUTPUT STARTS>>>
3.7.9 (mccabe: 0.6.1, pycodestyle: 2.5.0, pyflakes: 2.2.0) CPython 3.8.2 on Linux
<<<OUTPUT ENDS>>>

(executable check - success) pylint
(finished - exit code 28) ['/usr/bin/zsh', '-c', 'cd ''/home/anirudh/Desktop/cs61a/w3/hw04'' && ''pylint''  --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n ''/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py''']

<<<OUTPUT STARTS>>>
************* Module hw04
hw04.py:1:14: C0326 (bad-whitespace) Exactly one space required around assignment
HW_SOURCE_FILE=__file__
              ^
hw04.py:64:0: C0330 (bad-continuation) Wrong continued indentation (remove 1 space).
                              arm(3, planet(2)))))
                             |^
hw04.py:370:0: C0305 (trailing-newlines) Trailing newlines
hw04.py:1:0: C0114 (missing-module-docstring) Missing module docstring
hw04.py:4:11: W0621 (redefined-outer-name) Redefining name 'left' from outer scope (line 14)
hw04.py:4:17: W0621 (redefined-outer-name) Redefining name 'right' from outer scope (line 19)
hw04.py:10:0: C0103 (invalid-name) Argument name "m" doesn't conform to snake_case naming style
hw04.py:12:11: C0123 (unidiomatic-typecheck) Using type() instead of isinstance() for a typecheck.
hw04.py:14:0: C0103 (invalid-name) Argument name "m" doesn't conform to snake_case naming style
hw04.py:19:0: C0103 (invalid-name) Argument name "m" doesn't conform to snake_case naming style
hw04.py:24:8: W0621 (redefined-outer-name) Redefining name 'length' from outer scope (line 33)
hw04.py:29:0: C0103 (invalid-name) Argument name "s" doesn't conform to snake_case naming style
hw04.py:31:11: C0123 (unidiomatic-typecheck) Using type() instead of isinstance() for a typecheck.
hw04.py:33:0: C0103 (invalid-name) Argument name "s" doesn't conform to snake_case naming style
hw04.py:38:0: C0103 (invalid-name) Argument name "s" doesn't conform to snake_case naming style
hw04.py:43:11: W0621 (redefined-outer-name) Redefining name 'size' from outer scope (line 49)
hw04.py:46:4: W0105 (pointless-string-statement) String statement has no effect
hw04.py:49:0: C0103 (invalid-name) Argument name "w" doesn't conform to snake_case naming style
hw04.py:52:4: W0105 (pointless-string-statement) String statement has no effect
hw04.py:55:0: C0103 (invalid-name) Argument name "w" doesn't conform to snake_case naming style
hw04.py:57:11: C0123 (unidiomatic-typecheck) Using type() instead of isinstance() for a typecheck.
hw04.py:59:0: C0116 (missing-function-docstring) Missing function or method docstring
hw04.py:60:4: C0103 (invalid-name) Variable name "t" doesn't conform to snake_case naming style
hw04.py:62:4: C0103 (invalid-name) Variable name "u" doesn't conform to snake_case naming style
hw04.py:65:4: C0103 (invalid-name) Variable name "v" doesn't conform to snake_case naming style
hw04.py:68:0: C0103 (invalid-name) Argument name "m" doesn't conform to snake_case naming style
hw04.py:83:4: R1705 (no-else-return) Unnecessary "else" after "return"
hw04.py:89:0: C0103 (invalid-name) Argument name "m" doesn't conform to snake_case naming style
hw04.py:109:4: W0105 (pointless-string-statement) String statement has no effect
hw04.py:89:13: W0613 (unused-argument) Unused argument 'm'
hw04.py:111:0: C0103 (invalid-name) Argument name "m" doesn't conform to snake_case naming style
hw04.py:140:4: W0105 (pointless-string-statement) String statement has no effect
hw04.py:111:16: W0613 (unused-argument) Unused argument 'm'
hw04.py:143:0: C0103 (invalid-name) Argument name "t" doesn't conform to snake_case naming style
hw04.py:172:4: W0105 (pointless-string-statement) String statement has no effect
hw04.py:143:17: W0613 (unused-argument) Unused argument 't'
hw04.py:143:20: W0613 (unused-argument) Unused argument 'find_value'
hw04.py:143:32: W0613 (unused-argument) Unused argument 'replace_value'
hw04.py:175:0: C0103 (invalid-name) Argument name "t" doesn't conform to snake_case naming style
hw04.py:185:4: W0105 (pointless-string-statement) String statement has no effect
hw04.py:175:13: W0613 (unused-argument) Unused argument 't'
hw04.py:188:0: C0103 (invalid-name) Argument name "t" doesn't conform to snake_case naming style
hw04.py:217:4: W0105 (pointless-string-statement) String statement has no effect
hw04.py:188:13: W0613 (unused-argument) Unused argument 't'
hw04.py:220:0: C0103 (invalid-name) Argument name "a" doesn't conform to snake_case naming style
hw04.py:220:0: C0103 (invalid-name) Argument name "b" doesn't conform to snake_case naming style
hw04.py:224:0: C0103 (invalid-name) Argument name "x" doesn't conform to snake_case naming style
hw04.py:226:4: W0105 (pointless-string-statement) String statement has no effect
hw04.py:224:16: W0613 (unused-argument) Unused argument 'x'
hw04.py:228:0: C0103 (invalid-name) Argument name "x" doesn't conform to snake_case naming style
hw04.py:230:4: W0105 (pointless-string-statement) String statement has no effect
hw04.py:228:16: W0613 (unused-argument) Unused argument 'x'
hw04.py:231:0: C0103 (invalid-name) Argument name "x" doesn't conform to snake_case naming style
hw04.py:236:0: C0103 (invalid-name) Argument name "x" doesn't conform to snake_case naming style
hw04.py:236:0: C0103 (invalid-name) Argument name "y" doesn't conform to snake_case naming style
hw04.py:242:0: C0103 (invalid-name) Argument name "x" doesn't conform to snake_case naming style
hw04.py:242:0: C0103 (invalid-name) Argument name "y" doesn't conform to snake_case naming style
hw04.py:245:4: C0103 (invalid-name) Variable name "p1" doesn't conform to snake_case naming style
hw04.py:246:4: C0103 (invalid-name) Variable name "p2" doesn't conform to snake_case naming style
hw04.py:247:4: C0103 (invalid-name) Variable name "p3" doesn't conform to snake_case naming style
hw04.py:248:4: C0103 (invalid-name) Variable name "p4" doesn't conform to snake_case naming style
hw04.py:252:0: C0103 (invalid-name) Argument name "x" doesn't conform to snake_case naming style
hw04.py:252:0: C0103 (invalid-name) Argument name "y" doesn't conform to snake_case naming style
hw04.py:255:4: W0105 (pointless-string-statement) String statement has no effect
hw04.py:252:17: W0613 (unused-argument) Unused argument 'x'
hw04.py:252:20: W0613 (unused-argument) Unused argument 'y'
hw04.py:258:0: C0103 (invalid-name) Argument name "x" doesn't conform to snake_case naming style
hw04.py:258:0: C0103 (invalid-name) Argument name "y" doesn't conform to snake_case naming style
hw04.py:262:4: W0105 (pointless-string-statement) String statement has no effect
hw04.py:267:0: C0116 (missing-function-docstring) Missing function or method docstring
hw04.py:271:0: C0103 (invalid-name) Argument name "x" doesn't conform to snake_case naming style
hw04.py:271:0: C0103 (invalid-name) Argument name "a" doesn't conform to snake_case naming style
hw04.py:271:0: C0103 (invalid-name) Argument name "b" doesn't conform to snake_case naming style
hw04.py:271:0: C0103 (invalid-name) Argument name "c" doesn't conform to snake_case naming style
hw04.py:280:4: W0105 (pointless-string-statement) String statement has no effect
hw04.py:271:14: W0613 (unused-argument) Unused argument 'x'
hw04.py:271:17: W0613 (unused-argument) Unused argument 'a'
hw04.py:271:20: W0613 (unused-argument) Unused argument 'b'
hw04.py:271:23: W0613 (unused-argument) Unused argument 'c'
hw04.py:283:0: C0103 (invalid-name) Argument name "r1" doesn't conform to snake_case naming style
hw04.py:283:0: C0103 (invalid-name) Argument name "r2" doesn't conform to snake_case naming style
hw04.py:283:0: C0116 (missing-function-docstring) Missing function or method docstring
hw04.py:286:0: C0103 (invalid-name) Argument name "r1" doesn't conform to snake_case naming style
hw04.py:286:0: C0103 (invalid-name) Argument name "r2" doesn't conform to snake_case naming style
hw04.py:286:0: C0116 (missing-function-docstring) Missing function or method docstring
hw04.py:300:4: C0103 (invalid-name) Variable name "r1" doesn't conform to snake_case naming style
hw04.py:301:4: C0103 (invalid-name) Variable name "r2" doesn't conform to snake_case naming style
hw04.py:308:9: W0621 (redefined-outer-name) Redefining name 'label' from outer scope (line 314)
hw04.py:308:16: W0621 (redefined-outer-name) Redefining name 'branches' from outer scope (line 318)
hw04.py:308:0: W0102 (dangerous-default-value) Dangerous default value [] as argument
hw04.py:314:10: W0621 (redefined-outer-name) Redefining name 'tree' from outer scope (line 308)
hw04.py:318:13: W0621 (redefined-outer-name) Redefining name 'tree' from outer scope (line 308)
hw04.py:322:12: W0621 (redefined-outer-name) Redefining name 'tree' from outer scope (line 308)
hw04.py:324:7: C0123 (unidiomatic-typecheck) Using type() instead of isinstance() for a typecheck.
hw04.py:331:12: W0621 (redefined-outer-name) Redefining name 'tree' from outer scope (line 308)
hw04.py:337:0: C0103 (invalid-name) Argument name "t" doesn't conform to snake_case naming style
hw04.py:357:8: C0103 (invalid-name) Variable name "b" doesn't conform to snake_case naming style
hw04.py:360:0: C0103 (invalid-name) Argument name "t" doesn't conform to snake_case naming style

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

<<<OUTPUT ENDS>>>

(finished - exit code 1) ['/usr/bin/zsh', '-c', 'cd ''/home/anirudh/Desktop/cs61a/w3/hw04'' && ''flake8'' --format=default --stdin-display-name ''/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py'' - < ''/tmp/nvimYLI6N9/3/hw04.py''']

<<<OUTPUT STARTS>>>
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:1:15: E225 missing whitespace around operator
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:10:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:14:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:19:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:24:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:29:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:33:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:38:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:43:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:49:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:55:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:59:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:64:31: E127 continuation line over-indented for visual indent
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:68:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:89:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:111:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:179:80: E501 line too long (85 > 79 characters)
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:224:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:228:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:231:1: E302 expected 2 blank lines, found 0
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:236:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:242:1: E302 expected 2 blank lines, found 0
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:286:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:291:1: E302 expected 2 blank lines, found 0
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:300:24: E261 at least two spaces before inline comment
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:301:24: E261 at least two spaces before inline comment
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:306:1: E303 too many blank lines (3)
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:308:1: E302 expected 2 blank lines, found 3
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:314:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:318:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:322:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:331:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:337:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:346:80: E501 line too long (85 > 79 characters)
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:360:1: E302 expected 2 blank lines, found 1
/home/anirudh/Desktop/cs61a/w3/hw04/hw04.py:370:1: W391 blank line at end of file
<<<OUTPUT ENDS>>>

(started) ['/usr/bin/zsh', '-c', 'dotnet exec /home/anirudh/Applications/python-language-server/output/bin/Release/Microsoft.Python.LanguageServer.dll']
@anihm136 anihm136 added the bug label Aug 7, 2020
@w0rp
Copy link
Member

w0rp commented Aug 7, 2020

Looks like that language server isn't following the LSP spec. The interface says it should be like this.

export interface MarkupContent {
  kind: MarkupKind
  value: string
}

We can handle that error easily, even though it looks like the server is sending the wrong data.

@anihm136
Copy link
Author

anihm136 commented Aug 7, 2020

Ah I see. If its not too complex I'd be happy to work on the fix and send in a PR if you like. Would it be as simple as checking for the key in the returned dictionary?

@w0rp w0rp closed this as completed in f741245 Aug 7, 2020
@w0rp
Copy link
Member

w0rp commented Aug 7, 2020

That should be fixed now.

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

2 participants