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

Pylsp does not respect configuration #611

Closed
piotr-machura opened this issue Apr 10, 2022 · 2 comments
Closed

Pylsp does not respect configuration #611

piotr-machura opened this issue Apr 10, 2022 · 2 comments

Comments

@piotr-machura
Copy link

piotr-machura commented Apr 10, 2022

Hi,
I can't get pylsp to respect my configuration

[language.python]
filetypes = ["python"]
roots = ["requirements.txt", "setup.py", ".git", ".hg"]
command = "pylsp"
settings_section = "_"
[language.python.settings._]
pylsp.plugins.pyflakes.enabled = false

And in this sample python file:

sd = asd

I still get the lint undefined name 'asd' from pyflakes, even though I have disabled it in my config accourding to the docs.
Here are the logs emmite after openning the file:

Apr 10 10:29:10.681 INFO Starting main event loop, module: kak_lsp::session:28
Apr 10 10:29:10.681 DEBG Searching for vars starting with KAK_LSP_PROJECT_ROOT_PYTHON, module: kak_lsp::project_root:58
Apr 10 10:29:10.681 INFO Found project root "/home/piotr/test" because it contains ".git", module: kak_lsp::project_root:41
Apr 10 10:29:10.681 DEBG Routing editor request to Route { session: "185387", language: "python", root: "/home/piotr/test" }, module: kak_lsp::session:94
Apr 10 10:29:10.681 DEBG Spawning a new controller for Route { session: "185387", language: "python", root: "/home/piotr/test" }, module: kak_lsp::session:116
Apr 10 10:29:10.682 INFO Starting Language server `pylsp `, module: kak_lsp::language_server_transport:20
Apr 10 10:29:10.683 DEBG To editor `185387`: lsp-get-config '/tmp/kak-lsp/piotr/51c66aa482016882', module: kak_lsp::editor_transport:84
Apr 10 10:29:10.684 DEBG lsp_config:
, module: kak_lsp::settings:59
Apr 10 10:29:10.684 DEBG To editor `185387`: lsp-get-server-initialization-options '/tmp/kak-lsp/piotr/e748599328e820d2', module: kak_lsp::editor_transport:84
Apr 10 10:29:10.687 DEBG lsp_server_initialization_options:
, module: kak_lsp::settings:92
Apr 10 10:29:10.688 DEBG To server: {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"markdown":{"parser":"kak-lsp","version":"12.0.1"}},"offsetEncoding":["utf-8","utf-16"],"textDocument":{"callHierarchy":{"dynamicRegistration":false},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dynamicRegistration":false,"isPreferredSupport":false},"codeLens":{"dynamicRegistration":false},"colorProvider":{"dynamicRegistration":false},"completion":{"completionItem":{"commitCharactersSupport":false,"deprecatedSupport":false,"documentationFormat":["markdown","plaintext"],"preselectSupport":false,"resolveSupport":{"properties":["additionalTextEdits"]},"snippetSupport":false},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},"contextSupport":false,"dynamicRegistration":false},"declaration":{"dynamicRegistration":false,"linkSupport":false},"definition":{"dynamicRegistration":false,"linkSupport":false},"documentHighlight":{"dynamicRegistration":false},"documentLink":{"dynamicRegistration":false,"tooltipSupport":false},"documentSymbol":{"dynamicRegistration":false,"hierarchicalDocumentSymbolSupport":true},"formatting":{"dynamicRegistration":false},"hover":{"contentFormat":["markdown","plaintext"],"dynamicRegistration":false},"implementation":{"dynamicRegistration":false,"linkSupport":false},"onTypeFormatting":{"dynamicRegistration":false},"publishDiagnostics":{"relatedInformation":false},"rangeFormatting":{"dynamicRegistration":false},"references":{"dynamicRegistration":false},"rename":{"dynamicRegistration":false,"prepareSupport":false},"selectionRange":{},"semanticTokens":{"dynamicRegistration":false,"formats":["relative"],"requests":{"full":true,"range":false},"tokenModifiers":["constant","documentation","readonly"],"tokenTypes":["comment","operator","variable","function","type","keyword","namespace","string"]},"signatureHelp":{"contextSupport":false,"dynamicRegistration":false,"signatureInformation":{"documentationFormat":["plaintext"],"parameterInformation":{"labelOffsetSupport":false}}},"synchronization":{"didSave":true,"dynamicRegistration":false,"willSave":false,"willSaveWaitUntil":false},"typeDefinition":{"dynamicRegistration":false,"linkSupport":false}},"window":{"workDoneProgress":true},"workspace":{"applyEdit":false,"configuration":true,"didChangeConfiguration":{"dynamicRegistration":false},"executeCommand":{"dynamicRegistration":false},"symbol":{"dynamicRegistration":false,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"workspaceEdit":{"changeAnnotationSupport":{},"documentChanges":true,"failureHandling":"abort","normalizesLineEndings":false,"resourceOperations":["create","delete","rename"]},"workspaceFolders":false}},"clientInfo":{"name":"kak-lsp","version":"12.0.1"},"initializationOptions":{"pylsp":{"plugins":{"pyflakes":{"enabled":false}}}},"processId":185454,"rootPath":"/home/piotr/test","rootUri":"file:///home/piotr/test","trace":"off"},"id":0}, module: kak_lsp::language_server_transport:177
Apr 10 10:29:10.735 DEBG From editor: 
session  = "185387"
buffile  = "/home/piotr/test/example.py"
filetype = "python"
version  = 1
method   = "textDocument/didChange"
[params]
draft    = """
class X:
    def __init__(self):
        pass
sd = asd
"""
Apr 10 10:32:15.873 INFO Starting main event loop, module: kak_lsp::session:28
Apr 10 10:32:15.873 DEBG Searching for vars starting with KAK_LSP_PROJECT_ROOT_PYTHON, module: kak_lsp::project_root:58
Apr 10 10:32:15.873 INFO Found project root "/home/piotr/test" because it contains ".git", module: kak_lsp::project_root:41
Apr 10 10:32:15.873 DEBG Routing editor request to Route { session: "185758", language: "python", root: "/home/piotr/test" }, module: kak_lsp::session:94
Apr 10 10:32:15.873 DEBG Spawning a new controller for Route { session: "185758", language: "python", root: "/home/piotr/test" }, module: kak_lsp::session:116
Apr 10 10:32:15.874 INFO Starting Language server `pylsp `, module: kak_lsp::language_server_transport:20
Apr 10 10:32:15.874 DEBG To editor `185758`: lsp-get-config '/tmp/kak-lsp/piotr/dc2ca1d85ad94070', module: kak_lsp::editor_transport:84
Apr 10 10:32:15.875 DEBG lsp_config:
, module: kak_lsp::settings:59
Apr 10 10:32:15.877 DEBG To editor `185758`: lsp-get-server-initialization-options '/tmp/kak-lsp/piotr/c4cc2ec415a4e0fe', module: kak_lsp::editor_transport:84
Apr 10 10:32:15.880 DEBG lsp_server_initialization_options:
, module: kak_lsp::settings:92
Apr 10 10:32:15.880 DEBG To server: {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"markdown":{"parser":"kak-lsp","version":"12.0.1"}},"offsetEncoding":["utf-8","utf-16"],"textDocument":{"callHierarchy":{"dynamicRegistration":false},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dynamicRegistration":false,"isPreferredSupport":false},"codeLens":{"dynamicRegistration":false},"colorProvider":{"dynamicRegistration":false},"completion":{"completionItem":{"commitCharactersSupport":false,"deprecatedSupport":false,"documentationFormat":["markdown","plaintext"],"preselectSupport":false,"resolveSupport":{"properties":["additionalTextEdits"]},"snippetSupport":false},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},"contextSupport":false,"dynamicRegistration":false},"declaration":{"dynamicRegistration":false,"linkSupport":false},"definition":{"dynamicRegistration":false,"linkSupport":false},"documentHighlight":{"dynamicRegistration":false},"documentLink":{"dynamicRegistration":false,"tooltipSupport":false},"documentSymbol":{"dynamicRegistration":false,"hierarchicalDocumentSymbolSupport":true},"formatting":{"dynamicRegistration":false},"hover":{"contentFormat":["markdown","plaintext"],"dynamicRegistration":false},"implementation":{"dynamicRegistration":false,"linkSupport":false},"onTypeFormatting":{"dynamicRegistration":false},"publishDiagnostics":{"relatedInformation":false},"rangeFormatting":{"dynamicRegistration":false},"references":{"dynamicRegistration":false},"rename":{"dynamicRegistration":false,"prepareSupport":false},"selectionRange":{},"semanticTokens":{"dynamicRegistration":false,"formats":["relative"],"requests":{"full":true,"range":false},"tokenModifiers":["constant","readonly","documentation"],"tokenTypes":["comment","variable","operator","string","type","keyword","function","namespace"]},"signatureHelp":{"contextSupport":false,"dynamicRegistration":false,"signatureInformation":{"documentationFormat":["plaintext"],"parameterInformation":{"labelOffsetSupport":false}}},"synchronization":{"didSave":true,"dynamicRegistration":false,"willSave":false,"willSaveWaitUntil":false},"typeDefinition":{"dynamicRegistration":false,"linkSupport":false}},"window":{"workDoneProgress":true},"workspace":{"applyEdit":false,"configuration":true,"didChangeConfiguration":{"dynamicRegistration":false},"executeCommand":{"dynamicRegistration":false},"symbol":{"dynamicRegistration":false,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"workspaceEdit":{"changeAnnotationSupport":{},"documentChanges":true,"failureHandling":"abort","normalizesLineEndings":false,"resourceOperations":["create","delete","rename"]},"workspaceFolders":false}},"clientInfo":{"name":"kak-lsp","version":"12.0.1"},"initializationOptions":{"pylsp":{"plugins":{"pyflakes":{"enabled":false}}}},"processId":185825,"rootPath":"/home/piotr/test","rootUri":"file:///home/piotr/test","trace":"off"},"id":0}, module: kak_lsp::language_server_transport:177
Apr 10 10:32:15.930 DEBG From editor: 
session  = "185758"
buffile  = "/home/piotr/test/example.py"
filetype = "python"
version  = 1
method   = "textDocument/didChange"
[params]
draft    = """
sd = asd
"""
, module: kak_lsp::editor_transport:129
Apr 10 10:32:15.931 DEBG Searching for vars starting with KAK_LSP_PROJECT_ROOT_PYTHON, module: kak_lsp::project_root:58
Apr 10 10:32:15.931 INFO Found project root "/home/piotr/test" because it contains ".git", module: kak_lsp::project_root:41
Apr 10 10:32:15.931 DEBG Routing editor request to Route { session: "185758", language: "python", root: "/home/piotr/test" }, module: kak_lsp::session:94
Apr 10 10:32:15.931 DEBG Language server is not initialized, parking request, module: kak_lsp::controller:99
Apr 10 10:32:16.399 DEBG From server: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{"codeActionProvider":true,"codeLensProvider":{"resolveProvider":false},"completionProvider":{"resolveProvider":true,"triggerCharacters":["."]},"documentFormattingProvider":true,"documentHighlightProvider":true,"documentRangeFormattingProvider":true,"documentSymbolProvider":true,"definitionProvider":true,"executeCommandProvider":{"commands":[]},"hoverProvider":true,"referencesProvider":true,"renameProvider":true,"foldingRangeProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",",","="]},"textDocumentSync":{"change":2,"save":{"includeText":true},"openClose":true},"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":true}},"experimental":{}},"serverInfo":{"name":"pylsp","version":"1.4.1"}}}, module: kak_lsp::language_server_transport:151
Apr 10 10:32:16.399 DEBG To server: {"jsonrpc":"2.0","method":"initialized","params":{}}, module: kak_lsp::language_server_transport:177
Apr 10 10:32:16.399 DEBG To server: {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"python","text":"sd = asd\n","uri":"file:///home/piotr/test/example.py","version":1}}}, module: kak_lsp::language_server_transport:177
Apr 10 10:32:16.399 DEBG lsp_config:
, module: kak_lsp::settings:59
Apr 10 10:32:16.399 DEBG To server: {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}, module: kak_lsp::language_server_transport:177
Apr 10 10:32:16.908 DEBG From server: {"jsonrpc":"2.0","method":"textDocument\/publishDiagnostics","params":{"uri":"file:\/\/\/home\/piotr\/test\/example.py","diagnostics":[{"source":"pyflakes","range":{"start":{"line":0,"character":5},"end":{"line":0,"character":9}},"message":"undefined name 'asd'","severity":1}]}}, module: kak_lsp::language_server_transport:151
Apr 10 10:32:16.909 DEBG To editor `185758`: eval -buffer '/home/piotr/test/example.py' %§set buffer lsp_diagnostic_error_count 1; set buffer lsp_diagnostic_hint_count 0; set buffer lsp_diagnostic_info_count 0; set buffer lsp_diagnostic_warning_count 0; set buffer lsp_errors 1 1.6,1.9|DiagnosticError; eval "set buffer lsp_error_lines 1 '1|{LineFlagError}%opt[lsp_diagnostic_line_error_sign]' '0|%opt[lsp_diagnostic_line_error_sign]'"; set buffer lsp_diagnostics 1 "1.9+0|%opt[lsp_inlay_diagnostic_gap]{InlayDiagnosticError}%opt[lsp_inlay_diagnostic_sign] {InlayDiagnosticError}{\}undefined name 'asd'"§, module: kak_lsp::editor_transport:84

I am 99% sure my configuration is crooked, because the client clearly sends "initializationOptions":{"pylsp":{"plugins":{"pyflakes":{"enabled":false}}}}, but then the server responds with diagnostics diagnostics":[{"source":"pyflakes"....What am I doing wrong here?

@krobelus
Copy link
Member

krobelus commented Apr 10, 2022

This is a weird behavior in pylsp; they ignore options sent via initializationOptions.
Fixed by cb2f3cf, which re-sends the options via workspace/didChangeConfiguration.
Though it would be nice if pylsp fixed this because this way we send the options twice.
Thanks a lot for reporting!

@krobelus
Copy link
Member

BTW I think it's also weird of pylsp to require users to configure this in their editor settings. Why not use one of the config files like tox.ini (which they already use). Then external tools work too, not just editors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants