Closed neelkarma closed 3 years ago
Works as expected on my machine. If you are using vim you can try adding this to your vimrc:
call ch_logfile(expand('/tmp/chlogfile.log'), 'w')
Then open a python file. The /tmp/chlogfile.log should contain debug information about pyright that may help find out what is the issue.
On my setup it looks like this:
==== start log session ====
0.064460 : Starting job: /bin/bash -c 'pyright-langserver' --stdio
0.064476 on 0: Created channel
0.064931 : closing
0.065677 SEND on 0(in): 'Content-Length: 1127
{"method":"initialize","jsonrpc":"2.0","id":1,"params":{"initializationOptions":{},"rootUri":"file:///tmp","capabilities":{"workspace":{"workspaceFolders":false,"configuration":false,"symbol":{"dynamicRegistratio
n":false},"applyEdit":false,"didChangeConfiguration":{"dynamicRegistration":false}},"textDocument":{"documentSymbol":{"dynamicRegistration":false,"hierarchicalDocumentSymbolSupport":false},"references":{"dynamicR
egistration":false},"publishDiagnostics":{"relatedInformation":true},"rename":{"dynamicRegistration":false},"completion":{"completionItem":{"snippetSupport":false,"commitCharactersSupport":false,"preselectSupport
":false,"deprecatedSupport":false,"documentationFormat":["plaintext"]},"contextSupport":false,"dynamicRegistration":false},"synchronization":{"didSave":true,"willSaveWaitUntil":false,"willSave":false,"dynamicRegi
stration":false},"codeAction":{"dynamicRegistration":false},"typeDefinition":{"dynamicRegistration":false},"hover":{"dynamicRegistration":false,"contentFormat":["plaintext"]},"definition":{"dynamicRegistration":f
alse,"linkSupport":false}}},"rootPath":"/tmp","processId":2604125}}'
0.147667 : Starting job: /bin/bash -c 'pylint' --version
0.147685 on 1: Created channel
0.148104 : closing
0.150134 : ERROR silent: E803: ID はありません: 3
0.150863 : closing
0.154926 : SafeState: Start triggering
0.156120 RECV on 0(out): 'Content-Length: 119
@hsanson unfortunately, I use NeoVim where ch_logfile
doesn't exist. Do you know whether there's an alternative function?
Unfortunately there is no such functionality yet in neovim. But there is a request to implement it:
Here's the content of g:ale_buffer_info
:
{'1': {'active_linter_list': [], 'loclist': [], 'first_problems': {}, 'count': {'0': 0, '1': 0, 'style_warning': 0, 'info': 0, 'warning': 0, 'total': 0, 'style_error': 0, 'error': 0}, 'active_other_sources_list': []}}
What concerns me is that 'active_linter_list'
is empty. Is there any other way to find the source of this issue?
It's difficult to debug issues running programs in NeoVim. I recommend trying the same thing in Vim where it's a lot easier. I use Pyright with ALE for my day job.
You're using Windows, so I wouldn't be surprised if the issue has something to do with Windows.
Ok, so I tried using Vim instead of NeoVim and it worked fine in Vim (sigh)... The thing is, I would switch to Vim but I have a lot of NeoVim-only plugins installed that I can't work without...
That's even more annoying to debug. I was hoping you'd have the same problem in Vim so you could easily see what was wrong. It's hard to say what the issue is, but you might get some clues by looking at how the command is being run in :ALEInfo
. It'll be something to do with environment variables, the Windows shell, etc.
I put in the request above for debugging issues with channels/jobs for NeoVim a little over two years ago, and it does seem to be a milestone goal, so at least it will be available in future.
So something strange happened - I used :ALEGoToDefinition
and suddenly linting started working again. I have no idea how it happened. So I restarted NeoVim, but the issue was back. It looks like sometimes when you use :ALEGoToDefinition
, there's a file path echoed in the status bar. When it is echoed, linting starts working again, but only until you close NeoVim. When it isn't echoed, the same issue persists. (Sorry I forgot the file path but I'm pretty sure it was the file path to the project folder)
Just thought I'd let you know in case we can trace the echoing of the file path back to some random piece of code that's failing or something
There's probably a problem with one of the messages being sent to the language server where it's not telling it that a file was opened or saved. NeoVim doesn't make it easy to debug these issues like Vim does, but you could try this.
autoload/ale/lsp.vim
echom 'Send: ' . string(l:data)
after the ale#lsp#CreateMessageData
call in ale#lsp#Send
.echom 'Receive: ' . string(a:data)
as the the first line of ale#lsp#ReadMessageData
.Then you should be able to look at :message
and see what's being sent and received. I'll probably add some support for storing these messages and showing them in a window to make it easier.
The above suggestion doesn't give you the complete picture like ch_logfile
does, as that also shows you what messages are printed to stderr
and when programs die, but it's better than nothing.
@w0rp I've done as you've suggested and here's the relevant content of :message
:
Receive: 'Content-Length: 119^M^@^M^@'
Receive: 'Content-Length: 119^M^@^M^@{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Pyright language server 1.1.108 starting"}}'
Receive: 'Content-Length: 170^M^@^M^@{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Server root directory: C:\\Users\\nsdjs\\AppData\\Roaming\\npm\\node_modules\\pyright/dist/"}}'
Receive: 'Content-Length: 790^M^@^M^@'
Receive: 'Content-Length: 790^M^@^M^@{"jsonrpc":"2.0","id":1,"result":{"capabilities":{"textDocumentSync":2,"definitionProvider":{"workDoneProgress":true},"referencesProvider":{"workDoneProgress":true},"documentSymbolProvider":{"workDoneProgress":true},"workspaceSymbolProvider":{"workDoneProgress":true},"hoverProvider":{"workDoneProgress":true},"documentHighlightProvider":{"workDoneProgress":true},"renameProvider":{"workDoneProgress":true},"completionProvider":{"triggerCharacters":[".","["],"resolveProvider":true,"workDoneProgress":true},"signatureHelpProvider":{"triggerCharacters":["(",",",")"],"workDoneProgress":true},"codeActionProvider":{"codeActionKinds":["quickfix","source.organizeImports"],"workDoneProgress":true},"executeCommandProvider":{"commands":[],"workDoneProgress":true},"callHierarchyProvider":true}}}'
Send: 'Content-Length: 57^M^@^M^@{"method": "initialized", "jsonrpc": "2.0", "params": {}}'
Send: 'Content-Length: 104^M^@^M^@{"method": "workspace/didChangeConfiguration", "jsonrpc": "2.0", "params": {"settings": {"python": {}}}}'
Send: 'Content-Length: 318^M^@^M^@{"method": "textDocument/didOpen", "jsonrpc": "2.0", "params": {"textDocument": {"uri": "file:///C:/Users/nsdjs/Documents/Programming/Python/lintertest/lintertest.py", "version": 1, "languageId": "python", "text": "def printInt(integer: int) -> None:\n print(integer)\n\nprintInt(\"432\") # Should cause error\n"}}}'
Receive: 'Content-Length: 107^M^@^M^@'
Receive: 'Content-Length: 107^M^@^M^@{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"No configuration file found."}}Content-Length: 183^M^@^M^@{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":1,"message":"stubPath C:\\Users\\nsdjs\\Documents\\Programming\\Python\\lintertest\\typings is not a valid directory."}}Content-Length: 111^M^@^M^@{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Assuming Python platform Windows"}}Content-Length: 105^M^@^M^@{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Searching for source files"}}'
Receive: 'Content-Length: 98^M^@^M^@{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Found 1 source file"}}'
Receive: 'Content-Length: 602^M^@^M^@{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///c%3A/Users/nsdjs/Documents/Programming/Python/lintertest/lintertest.py","diagnostics":[{"range":{"start":{"line":3,"character":9},"end":{"line":3,"character":14}},"message":"Argument of type \"Literal[''432'']\" cannot be assigned to parameter \"integer\" of type \"int\" in function \"printInt\"\n \"Literal[''432'']\" is incompatible with \"int\"","severity":1,"code":"reportGeneralTypeIssues","source":"Pyright","codeDescription":{"href":"https://github.com/microsoft/pyright/blob/master/docs/configuration.md"}}]}}'
It doesn't look like there's anything wrong with Pyright or how it's executed and it seems to be reporting the error, but ALE isn't picking it up. Also, the message about the stubpath being invalid is normal if you don't have a typings folder iirc
From then on, every time I move the cursor, this is echoed:
Send: 'Content-Length: 217^M^@^M^@{"method": "textDocument/hover", "jsonrpc": "2.0", "id": 2, "params": {"textDocument": {"uri": "file:///C:/Users/nsdjs/Documents/Programming/Python/lintertest/lintertest.py"}, "position": {"character": 0, "line": 0}}}'
Receive: 'Content-Length: 38^M^@^M^@{"jsonrpc":"2.0","id":2,"result":null}'
(But the line
, character
and any other relevant fields are updated when I move the cursor)
P.S. I figured out that the file path I mentioned in my last comment was the absolute file path to the file being edited (if that helps)
I wonder if there might be a bug in Pyright on Windows, because there's one thing I find strange:
Content-Length: 602^M^@^M^@{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///c%3A/Users/nsdjs/Documents/Programming/Python/lintertest/lintertest.py","diagnostics":[{"range":{"start":{"line":3,"character":9},"end":{"line":3,"character":14}},"message":"Argument of type \"Literal[''432'']\" cannot be assigned to parameter \"integer\" of type \"int\" in function \"printInt\"\n \"Literal[''432'']\" is incompatible with \"int\"","severity":1,"code":"reportGeneralTypeIssues","source":"Pyright","codeDescription":{"href":"https://github.com/microsoft/pyright/blob/master/docs/configuration.md"}}]}}
Unless I'm missing something, that's 2 bytes short.
>>> len(br"""{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///c%3A/Users/nsdjs/Documents/Programming/Python/lintertest/lintertest.py","diagnostics":[{"range":{"start":{"line":3,"character":9},"end":{"line":3,"character":14}},"message":"Argument of type \"Literal[''432'']\" cannot be assigned to parameter \"integer\" of type \"int\" in function \"printInt\"\n \"Literal[''432'']\" is incompatible with \"int\"","severity":1,"code":"reportGeneralTypeIssues","source":"Pyright","codeDescription":{"href":"https://github.com/microsoft/pyright/blob/master/docs/configuration.md"}}]}}""")
604
That would explain the messages not working for a while, then starting to come through later. If the Content-Length
is off by even one byte, it will mess up the stream of data. It's worth opening a bug with Pyright to investigate this.
It could be a coincidence, but 2 bytes is the difference between c:/
and c%3A/
.
@w0rp Ok so I did some work, and here is what I found:
I installed Vim and used ch_logfile
to get the output Pyright was passing Vim and compared it with the output that was passed to NeoVim. Here's the diff: https://www.diffchecker.com/Uc7UxfrF (left is NeoVim, right is Vim)
Something in NeoVim is causing double single quotes to appear...? And also, there might be a problem with counting newlines when reading the LSP response. Here are my full findings: https://github.com/neelkarma/pyright-lsp-test/blob/main/README.md
I think it was a red herring. :echo string("'")
will output ''''
, so the number of bytes counted is correct. I think that's the thing I missed.
The next thing to look at is tracing where the message goes. It should be added to l:response_list
, and then it should be send to the callback at the end of ale#lsp#HandleMessage
. If the callback is called correctly, you should be able to see it being sent to the ale#lsp_linter#HandleLSPResponse
function, and then hopefully on to s:HandleLSPDiagnostics
in autoload/ale/lsp_linter.vim
. It you see an issue anywhere, it might be where bufnr
is called in that function.
did you find a resolution to this? i'm having a similar issue but on Mac OS 10.15.7, slightly different setup:
NVIM v0.4.4
Build type: Release
after doing the echom
debugging as mentioned above i get:
Receive: 'Content-Length: 119^M^@^M^@'
Receive: 'Content-Length: 119^M^@^M^@{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Pyright language server 1.1.176 starting"}}Content-Length: 181^M^@^M^@{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Server root directory: /Users/dominic.batten/.nvm/versions/node/v16.8.0/lib/node_modules/pyright/dist/"}}'
Receive: 'Content-Length: 838^M^@^M^@'
Receive: 'Content-Length: 838^M^@^M^@{"jsonrpc":"2.0","id":1,"result":{"capabilities":{"textDocumentSync":2,"definitionProvider":{"workDoneProgress":true},"declarationProvider":{"workDoneProgress":true},"referencesProvider":{"workDoneProgress":true},"documentSymbolProvider":{"workDoneProgress":true},"workspaceSymbolProvider":{"workDoneProgress":true},"hoverProvider":{"workDoneProgress":true},"documentHighlightProvider":{"workDoneProgress":true},"renameProvider":{"workDoneProgress":true},"completionProvider":{"triggerCharacters":[".","["],"resolveProvider":true,"workDoneProgress":true},"signatureHelpProvider":{"triggerCharacters":["(",",",")"],"workDoneProgress":true},"codeActionProvider":{"codeActionKinds":["quickfix","source.organizeImports"],"workDoneProgress":true},"executeCommandProvider":{"commands":[],"workDoneProgress":true},"callHierarchyProvider":true}}}'
Send: 'Content-Length: 57^M^@^M^@{"method": "initialized", "jsonrpc": "2.0", "params": {}}'
Send: 'Content-Length: 104^M^@^M^@{"method": "workspace/didChangeConfiguration", "jsonrpc": "2.0", "params": {"settings": {"python": {}}}}'
Send: 'Content-Length: 344^M^@^M^@{"method": "textDocument/didOpen", "jsonrpc": "2.0", "params": {"textDocument": {"uri": "file:///Users/dominic.batten/projects/work/random/thing.py", "version": 1, "languageId": "python", "text": "\"\"\"test\"\"\"\n\ndef printInt(integer: int) -> None:\n \"\"\"test\"\"\"\n print(integer)\n\nprintInt(\"hello\") # Should cause error\n"}}}'
Send: 'Content-Length: 152^M^@^M^@{"method": "textDocument/didClose", "jsonrpc": "2.0", "params": {"textDocument": {"uri": "file:///Users/dominic.batten/projects/work/random/thing.py"}}}'
Send: 'Content-Length: 344^M^@^M^@{"method": "textDocument/didOpen", "jsonrpc": "2.0", "params": {"textDocument": {"uri": "file:///Users/dominic.batten/projects/work/random/thing.py", "version": 2, "languageId": "python", "text": "\"\"\"test\"\"\"\n\ndef printInt(integer: int) -> None:\n \"\"\"test\"\"\"\n print(integer)\n\nprintInt(\"hello\") # Should cause error\n"}}}'
Send: 'Content-Length: 200^M^@^M^@{"method": "textDocument/hover", "jsonrpc": "2.0", "id": 2, "params": {"textDocument": {"uri": "file:///Users/dominic.batten/projects/work/random/thing.py"}, "position": {"character": 10, "line": 2}}}'
which suggests that nothing is received from the lsp server?
if i run pyright
manually via pyright path/to/file.py
i get a correct error message:
No configuration file found.
No pyproject.toml file found.
stubPath /Users/dominic.batten/projects/work/random/typings is not a valid directory.
Assuming Python platform Darwin
Searching for source files
Found 1 source file
/Users/dominic.batten/projects/work/random/thing.py
/Users/dominic.batten/projects/work/random/thing.py:7:10 - error: Argument of type "Literal['hello']" cannot be assigned to parameter "integer" of type "int" in function "printInt"
"Literal['hello']" is incompatible with "int" (reportGeneralTypeIssues)
1 error, 0 warnings, 0 infos
Completed in 0.863sec
is there some config i'm missing? apologies for hijacking this thread, happy to open another issue if you prefer
Unfortunately I am unable to replicate the issue making it difficult to figure out what the problem may be.
I am using NeoVim 0.6.0 and also tested with Vim 8.1 using pyright 1.1.169.
Using the chlog I can see pyright sends the correct diagnostics and ALE shows them correctly in NeoVim and Vim:
4.309123 RECV on 4(out): '{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/hidden/Projects/HelloWorld/pytho
n/hello-plain/hello.py","version":2,"diagnostics":[{"range":{"start":{"line":9,"character":0},"end":{"line":9,"character":2}},"message":"\"ay\" is not
defined","severity":1,"code":"reportUndefinedVariable","source":"Pyright","codeDescription":{"href":"https://github.com/microsoft/pyright/blob/main/d
ocs/configuration.md"}}]}}'
so i've tried using vim to see if it works there but also no luck, below is the output of chlog
. seems like there's no response from the pyright lsp server?
==== start log session ====
0.080912 : Starting job: /bin/zsh -c 'pyright-langserver' --stdio
0.080996 on 0: Created channel
0.081731 : closing
0.085372 SEND on 0(in): 'Content-Length: 1159
{"method":"initialize","jsonrpc":"2.0","id":1,"params":{"initializationOptions":{},"rootUri":"file:///Users/dominic.batten","capabilities":{"workspace":{"workspaceFolders":false,"configuration":false,"symbol":{"dynamicRegistration":false},"applyEdit":false,"didChangeConfiguration":{"dynamicRegistration":false}},"textDocument":{"documentSymbol":{"dynamicRegistration":false,"hierarchicalDocumentSymbolSupport":false},"references":{"dynamicRegistration":false},"publishDiagnostics":{"relatedInformation":true},"rename":{"dynamicRegistration":false},"completion":{"completionItem":{"snippetSupport":false,"commitCharactersSupport":false,"preselectSupport":false,"deprecatedSupport":false,"documentationFormat":["plaintext"]},"contextSupport":false,"dynamicRegistration":false},"synchronization":{"didSave":true,"willSaveWaitUntil":false,"willSave":false,"dynamicRegistration":false},"codeAction":{"dynamicRegistration":false},"typeDefinition":{"dynamicRegistration":false},"hover":{"dynamicRegistration":false,"contentFormat":["plaintext"]},"definition":{"dynamicRegistration":false,"linkSupport":false}}},"rootPath":"/Users/dominic.batten","processId":38886}}'
0.089057 : SafeState: Start triggering
0.090784 : looking for messages on channels
0.090831 : SafeState: back to waiting, triggering SafeStateAgain
0.327754 RECV on 0(out): 'Content-Length: 119
'
0.327762 on 0: Invoking channel callback <SNR>52_VimOutputCallback
0.328146 : SafeState: back to waiting, triggering SafeStateAgain
0.328412 RECV on 0(out): '{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Pyright language server 1.1.176 starting"}}'
0.328418 : looking for messages on channels
0.328436 on 0: Invoking channel callback <SNR>52_VimOutputCallback
0.328511 RECV on 0(out): 'Content-Length: 181
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Server root directory: /Users/dominic.batten/.nvm/versions/node/v16.8.0/lib/node_modules/pyright/dist/"}}'
0.328882 on 0: Invoking channel callback <SNR>52_VimOutputCallback
0.329266 : SafeState: back to waiting, triggering SafeStateAgain
0.335135 RECV on 0(out): 'Content-Length: 838
'
0.335144 : looking for messages on channels
0.335172 on 0: Invoking channel callback <SNR>52_VimOutputCallback
0.335536 : SafeState: back to waiting, triggering SafeStateAgain
0.335624 RECV on 0(out): '{"jsonrpc":"2.0","id":1,"result":{"capabilities":{"textDocumentSync":2,"definitionProvider":{"workDoneProgress":true},"declarationProvider":{"workDoneProgress":true},"referencesProvider":{"workDoneProgress":true},"documentSymbolProvider":{"workDoneProgress":true},"workspaceSymbolProvider":{"workDoneProgress":true},"hoverProvider":{"workDoneProgress":true},"documentHighlightProvider":{"workDoneProgress":true},"renameProvider":{"workDoneProgress":true},"completionProvider":{"triggerCharacters":[".","["],"resolveProvider":true,"workDoneProgress":true},"signatureHelpProvider":{"triggerCharacters":["(",",",")"],"workDoneProgress":true},"codeActionProvider":{"codeActionKinds":["quickfix","source.organizeImports"],"workDoneProgress":true},"executeCommandProvider":{"commands":[],"workDoneProgress":true},"callHierarchyProvider":true}}}'
0.335627 : looking for messages on channels
0.335663 on 0: Invoking channel callback <SNR>52_VimOutputCallback
0.336480 SEND on 0(in): 'Content-Length: 52
{"method":"initialized","jsonrpc":"2.0","params":{}}'
0.342071 SEND on 0(in): 'Content-Length: 97
{"method":"workspace/didChangeConfiguration","jsonrpc":"2.0","params":{"settings":{"python":{}}}}'
0.342850 SEND on 0(in): 'Content-Length: 309
{"method":"textDocument/didOpen","jsonrpc":"2.0","params":{"textDocument":{"uri":"file:///Users/dominic.batten/projects/work/random/thing.py","version":1,"languageId":"python","text":"\"\"\"test\"\"\"\n\ndef printInt(integer: int) -> None:\n print(integer)\n\nprintInt(\"hello\") # Should cause error\n"}}}'
0.343413 : SafeState: back to waiting, triggering SafeStateAgain
4.092554 : looking for messages on channels
4.092607 : SafeState: back to waiting, triggering SafeStateAgain
����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������319.155023 : SafeState: reset: key typed
319.155183 : SafeState: Start triggering
319.155226 : looking for messages on channels
319.155245 : SafeState: back to waiting, triggering SafeStateAgain
319.309838 : SafeState: reset: key typed
319.309876 : SafeState: Start triggering
319.309905 : looking for messages on channels
319.309927 : SafeState: back to waiting, triggering SafeStateAgain
319.424340 : SafeState: reset: key typed
319.428988 : SafeState: Start triggering
319.447707 : looking for messages on channels
319.447767 : SafeState: back to waiting, triggering SafeStateAgain
323.451052 : SafeState: reset: key typed
323.451225 : SafeState: Start triggering
323.451297 : looking for messages on channels
323.451324 : SafeState: back to waiting, triggering SafeStateAgain
323.904170 : SafeState: reset: key typed
323.908854 : SafeState: Start triggering
323.911327 : looking for messages on channels
323.911379 : SafeState: back to waiting, triggering SafeStateAgain
327.912608 : SafeState: reset: key typed
327.913044 : SafeState: Start triggering
327.913127 : looking for messages on channels
327.913150 : SafeState: back to waiting, triggering SafeStateAgain
329.586632 : SafeState: reset: key typed
329.587079 : SafeState: Start triggering
329.588311 : looking for messages on channels
329.588382 : SafeState: back to waiting, triggering SafeStateAgain
331.126603 : SafeState: reset: key typed
331.126710 : SafeState: Start triggering
331.126742 : looking for messages on channels
331.126766 : SafeState: back to waiting, triggering SafeStateAgain
331.392246 : SafeState: reset: key typed
331.392296 : SafeState: Start triggering
331.392322 : looking for messages on channels
331.392342 : SafeState: back to waiting, triggering SafeStateAgain
331.920826 : SafeState: reset: key typed
331.920899 : SafeState: Start triggering
331.920936 : looking for messages on channels
331.920965 : SafeState: back to waiting, triggering SafeStateAgain
332.333979 : SafeState: reset: key typed
332.336001 : SafeState: Start triggering
332.336075 : looking for messages on channels
332.336100 : SafeState: back to waiting, triggering SafeStateAgain
333.150509 : SafeState: reset: key typed
333.150613 : SafeState: Start triggering
333.150655 : looking for messages on channels
333.150676 : SafeState: back to waiting, triggering SafeStateAgain
334.442663 : SafeState: reset: key typed
334.446221 : closing
334.547857 : looking for messages on channels
335.680185 : SafeState: Start triggering
335.681448 : looking for messages on channels
335.681514 : SafeState: back to waiting, triggering SafeStateAgain
338.541701 : SafeState: reset: key typed
338.541824 : SafeState: Start triggering
338.541891 : looking for messages on channels
338.541943 : SafeState: back to waiting, triggering SafeStateAgain
338.999149 : SafeState: reset: key typed
338.999209 : SafeState: Start triggering
338.999252 : looking for messages on channels
338.999296 : SafeState: back to waiting, triggering SafeStateAgain
340.049581 : SafeState: reset: key typed
340.051850 : closing
UPDATE: i've just noticed that pyright
works fine in one of my repos and doesn't work in another. the one that works uses a conda
env and the one that doesn't uses a .venv
generated by poetry. could that be the issue?
I tried using a plain python project and a poetry manged one and it works fine on both. The only difference I see is that after the didOpen notification I see more messages between the server and ALE. In your example above it seems the server sends some strange data and either the server or ALE are chocking on it:
���������������������������������
This is what continues after didOpen on my case:
{"method":"textDocument/didOpen","jsonrpc":"2.0","params":{"textDocument":{"uri":"file:///home/ryujin/Projects/HelloWorld/python/hello-poetry/hello.py
","version":1,"languageId":"python","text":"\"\"\"\nHello sample\n\"\"\"\n\n\ndef say(msg):\n print(\"Hello %s\" % msg)\n\n\nsay(\"World!\")\n"}}}'
0.427149 RECV on 4(out): 'Content-Length: 107
'
0.427160 : looking for messages on channels
0.427184 on 4: Invoking channel callback <SNR>147_VimOutputCallback
0.427374 RECV on 4(out): '{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"No configuration file found."}}Content-Length:
161
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"pyproject.toml file found at /home/ryujin/Projects/HelloWorld/python/hello
-poetry."}}Content-Length: 177
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Loading pyproject.toml file at /home/ryujin/Projects/HelloWorld/python/hel
lo-poetry/pyproject.toml"}}Content-Length: 202
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":1,"message":"Pyproject file \"/home/ryujin/Projects/HelloWorld/python/hello-poetry/pypr
oject.toml\" is missing \"[tool.pyright] section."}}'
0.427379 : looking for messages on channels
0.427386 on 4: Invoking channel callback <SNR>147_VimOutputCallback
0.427829 RECV on 4(out): 'Content-Length: 174
..... many other messages follow
The best way to fix issues like these is to try and re-create them with a miminal project others can clone from GitHub, or to share the open source project you're working on, if there is one. I use Pyright every day at work via ALE myself. There could be some weird issue due to something in a particular project, or some configuration issue, etc.
ah yep makes sense. added a minimal project here: https://github.com/dbatten5/fastapi-pyright-test
i've done it as a fastapi
project as that's the repo/application which which i'm experiencing issues with pyright
my steps to reproduce no pyright
issues seen in the buffer (pylint
issues do show up):
poetry install
poetry shell
other.py
in neovim and observe there are no pyright
warnings for passing an int
to foo
my ALEInfo
Current Filetype: python
Available Linters: ['bandit', 'flake8', 'jedils', 'mypy', 'prospector', 'pycodestyle', 'pydocstyle', 'pyflakes', 'pylama', 'pylint', 'pyls', 'pyre', 'pyright', 'vulture']
Enabled Linters: ['pyright']
Ignored Linters: []
Suggested Fixers:
'add_blank_lines_for_python_control_statements' - Add blank lines before control statements.
'autoimport' - Fix import issues with autoimport.
'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_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 = v:null
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 = 0
let g:ale_fixers = {}
let b:ale_fixers = {'python': ['black', 'isort']}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = v:null
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 = 0
let g:ale_linter_aliases = {}
let g:ale_linters = {}
let b:ale_linters = {'python': ['pyright']}
let g:ale_linters_explicit = 0
let g:ale_linters_ignore = {}
let g:ale_list_vertical = v:null
let g:ale_list_window_size = v:null
let g:ale_loclist_msg_format = v:null
let g:ale_lsp_root = {}
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:null
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 = 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_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
Command History:
(executable check - success) pyright-langserver
(started) ['/bin/zsh', '-c', '''pyright-langserver'' --stdio']
UPDATE: i closed my laptop with neovim open on other.py
in the repo mentioned above, when i reopened it just now i saw the pyright
error in the buffer. closing neovim and immediately reopening didn't make the errors appear again. not sure what this means
Tested with one additional step and on my machine works fine with NVim 0.6 and Vim 8.1:
^3.9
to ^3.8
because I do not have Python 3.9 on my system.My System:
aha right i've just updated ALE and it seems to be working a lot more consistently now. should have done that a while ago, my bad. thanks so much for your help!
Great, I will close this issue. Re-open or create a new one if you experience any other issues.
ah i'll just mention that i wasn't the OP, they might still be experiencing similar issues but need a different resolution
Information
VIM version
Operating System: Windows 10
What went wrong
When using Pyright with ALE, ALE doesn't pick up errors. All other LSP features work fine (I tested hover, go to definition, find references and symbol search), other python linters work fine and linters for other languages work fine. It's just Pyright linting that's acting up.
Also, the
pyright
CLI tool reports the error, but ALE doesn'tReproducing the bug
init.vim
:(this disables all other linters except for Pyright)
printInt("hello") # Should cause error
Current Filetype: python Available Linters: ['bandit', 'flake8', 'jedils', 'mypy', 'prospector', 'pycodestyle', 'pydocstyle', 'pyflakes', 'pylama', 'pylint', 'pyls', 'pyre', 'pyright', 'vulture'] Enabled Linters: ['pyright'] Ignored Linters: [] Suggested Fixers: 'add_blank_lines_for_python_control_statements' - Add blank lines before control statements. 'autoimport' - Fix import issues with autoimport. '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_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 = v:null 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 = 0 let g:ale_fixers = {} let g:ale_history_enabled = 1 let g:ale_history_log_output = 1 let g:ale_keep_list_window_open = v:null 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': ['pyright']} let g:ale_linters_explicit = 0 let g:ale_linters_ignore = {} let g:ale_list_vertical = v:null let g:ale_list_window_size = v:null let g:ale_loclist_msg_format = v:null let g:ale_lsp_root = {} 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:null 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 = 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_statusline_format = v:null let g:ale_type_map = {} let g:ale_use_global_executables = v:null let g:ale_virtualtext_cursor = 0 let g:ale_warn_about_trailing_blank_lines = 1 let g:ale_warn_about_trailing_whitespace = 1 Command History:
(executable check - success) pyright-langserver (started) 'cmd /s/c ""pyright-langserver" --stdio"'