palantir / python-language-server

An implementation of the Language Server Protocol for Python
MIT License
2.6k stars 282 forks source link

TypeError: unhashable type: 'dict' (when using with doom emacs) #874

Open chaoflow opened 3 years ago

chaoflow commented 3 years ago

Using (doom) emacs with lsp-mode, I see the following message when moving the cursor onto code:

LSP :: Error from the Language Server: TypeError: unhashable type: 'dict' (Invalid Parameters)

python-language-server is installed via repo checkout in develop mode into project venv:

pip install -e '../python-language-server[all]'

Emacs Messages buffer shows:

Running direnv in /home/cfl/ternaris/marv/suite/...
Direnv succeeded in /home/cfl/ternaris/marv/suite/
Running direnv in /home/cfl/ternaris/marv/suite/...
Direnv succeeded in /home/cfl/ternaris/marv/suite/
LSP :: Guessed project root is ~/ternaris/marv/suite
LSP :: Connected to [pyls:13295 status:starting].
LSP :: pyls:13295 initialized successfully
LSP :: Error from the Language Server: TypeError: unhashable type: 'dict' (Invalid Parameters) [2 times]

How do I debug this? Can I tell python-language-server to verbosely log to some file? If not, could you point me to the function handling requests, to try/except in there?

Any pointers greatly appreciated.

ccordoba12 commented 3 years ago

Please see the server options with

python -m pyls --help
chaoflow commented 3 years ago

@ccordoba12 Thank you for the fast reply!

It works now with the following:

.doom.d/config.el:

(use-package lsp-mode
  :custom
  (lsp-pyls-server-command '("pyls" "--log-file" "/tmp/pyls.log"))
  (lsp-pyls-configuration-sources ["flake8" "pycodestyle"]))

The error was caused by having a comma in the last line which let to "{',': 'pycodestyle'}" being pass as a config source to pyls.

I think such an error should be caught during server startup and result in an "invalid config source" error instead.

ccordoba12 commented 3 years ago

We don't have time to work on this, so it's up to you if you want to submit a pull request for it.